U

3 Messages

 • 

1K Points

Tuesday, April 23rd, 2024 6:37 AM

workflow to move assets between domain

I'm seeking a  workflow to move assets from Domain A to Domain B, retaining all attributes and relations.

@laurenzhiller1 @SeanPyle @pareshmaharana1 

63 Messages

 • 

1.4K Points

8 days ago

@user_fefd40  Here's an example I tested. Just make sure to change the UUIDs to match the domains in your Collibra environment.

import com.collibra.dgc.core.api.dto.instance.asset.FindAssetsRequest
import com.collibra.dgc.core.api.dto.instance.asset.ChangeAssetRequest

//find assets in old domain
def assetsInOldDomain = assetApi.findAssets(FindAssetsRequest.builder()
                                      .domainId(string2Uuid("fb56eb5a-851c-455b-8b55-be9879dd2837"))    //old domain, update UUID with your own
                                      .build()
                                      ).getResults()

def assetOldDomainCount = assetsInOldDomain.size() //get size of list for the loop

// loop through list of assets and use their Id to add them to a new domain
for(int i = 0; i < assetOldDomainCount ; i++) { 
  
  assetApi.changeAsset(ChangeAssetRequest.builder()
                       				  .id(assetsInOldDomain.get(i).id)
                                      .domainId(string2Uuid("018f16ea-4234-7126-92ab-ddfe82310488"))   //new domain, update UUID with your own
                                      .build()
                                      )
  
}

3 Messages

 • 

1K Points

Hi @SeanPyle​ Thanks for your help .... your code works fine. However,  Instead of moving assets between domains, I need to copy them. The copy operation should ensure that the assets remain in the source domain without being deleted.

63 Messages

 • 

1.4K Points

@user_fefd40 , glad to help.

As far as I know, we do not have an API that duplicates assets. 

Your best bet would be to create a new asset and use the attributes from the old asset. You would do this with AddAssetRequest.builder() in place of where I listed  ChangeAssetRequest.builder(). Both builders have the domainId method, so no changes needed there. You'll also need to use the required fields typeId and name to indicate the asset type and nae respectively.

Then, if the assets have any attributes that you also need to assign, you can use SetAssetAttributesRequest.builder() to assign those. 

24 Messages

 • 

955 Points

Make sure the Scope is the same between the source & target, or you will lose (sight) of the characteristics in source / not in target

Loading...