U

3 Messages

 • 

1K Points

Monday, April 15th, 2024 9:06 PM

get all domains name with a community, sub community

Can anyone help me with logic which needs to implemented via workflow
How to get all domain name from a community, sub community by filtering based on domain type.
get all domain name by filtering domain type "Glossary"
Community :  ParentCommunity
       Domain : HR         Type : Glossary
   Domain  :Finance    Type : Business Asset
   
   Sub-Community : Subcommunity
          Domain : HR-New        Type : Glossary
  Domain  :Finance    Type : Technical Asset
  
  
  
Result :     
Domain : HR , HR-New 

6 Messages

 • 

865 Points

16 days ago

Hi @user_fefd40 ,

to retrieve all domains of a certain domain type in a specific community, you can use:

import com.collibra.dgc.core.api.dto.instance.domain.FindDomainsRequest

def domains = domainApi.findDomains(FindDomainsRequest.builder() 
    .communityId(string2Uuid("270a5361-2b22-4f63-a4a6-4953d1e65640"))
    .typeId(string2Uuid("00000000-0000-0000-0000-000000010001"))
    .build()).getResults()

// You can for example get the name of the first domain in the results using domains.get(0).getName().

 You also mentioned that you need to get the sub communities of a community. To achieve this, you can use FindCommunitiesRequest and submit the Resource Id of the parent community as parentID in the build() method.

(edited)

62 Messages

 • 

1.3K Points

15 days ago

To add to Lauren’s idea, you probably want a loop to extract all the names since I assume you won’t know how many domains you need to ask for. You can do it like this:

 

def domainCount = domains.size() // Get a count of how many domains returned by FindDomainsRequest

List<String> domainList = new ArrayList<String>() //declare new  list to store results

for(int i = 0; i < domainCount; i++) {      // loop through PagedResponse of Domains, extract their names and add them to a new list
domainList.add(domains.get(i).name)
}

 

Then you can pass the list to a form, etc.

13 Messages

 • 

800 Points

Hi, 

You can use output module ( com.collibra.dgc.core.api.dto.query.outputmodule.ExportJSONRequest ) to do so and modify the code accordingly

def outputResult = outputModuleApi.exportJSON(
 ExportJSONRequest.builder()
 .viewConfig("""---
TableViewConfig:
  displayLength: 50
  Resources:
    Term:
      Id: {"name": "assetId"}
      Signifier: {"name": "assetName"}
      ConceptType: 
        Id: {"name": "assetTypeId"}
      Status:
        Id: {"name":"statusId"}
      Vocabulary: {"Id": {"name": "domainId"}, "Community": {"Id": {"name": "communityId"}}}
      NumericAttribute:
        - labelId: 00000000-0000-0000-0000-000000000240
          NumericValue: {"name": "myNumericAttribute"}
      Filter:
        AND:
        - Field: {"name": "communityTypeId", "operator":"EQUALS", "value": "${communitytypeId}" }
        - Field: {"name": "domainTypeId", "operator":"EQUALS", "value": "${communitytypeId}" }
  Columns:
  - Column: {"fieldName": "assetId"}
  - Column: {"fieldName": "assetName"}
  - Column: {"fieldName": "statusId"}
  - Column: {"fieldName": "domainId"}
  - Column: {"fieldName": "myNumericAttribute"}
""").build())

ObjectMapper mapper = new ObjectMapper()
def response = mapper.readValue(outputResult, Map.class)


response.aaData.each { aaDataItem ->

}

Thanks,
Paresh

Loading...