U

3 Messages

 • 

1K Points

Thursday, June 13th, 2024 8:59 PM

Copy or Clone a Business Term

I would like to copy or clone a business term from 1 glossary or sub-community to another with all related metadata (attributes, roles, business rules, physical assets etc).  I know I can create a relationship between the terms but that's not what the users are asking for.  I know this can be achieved through export/re-import but we are looking for a smoother user experience.  Any information, experience, links etc on this topic are appreciated.

Accepted Solution

88 Messages

 • 

2.8K Points

5 months ago

You can create a workflow in Workflow Designer to accomplish this. Then limit the scope of the workflow to run on assets. Here's an example workflow that copies the asset and attributes.

You can add to the example if you also want to copy the relations and responsibilities. We have some great courses on workflows on Collibra University and unlimited live training you can take as part of our Premium subscription.  I highly recommend studying them if you want to start automating business processes within Collibra.

Code from the script task in the example:

import com.collibra.dgc.core.api.model.ResourceType
import com.collibra.dgc.core.api.dto.instance.asset.AddAssetRequest
import com.collibra.dgc.core.api.dto.instance.attribute.AddAttributeRequest
import com.collibra.dgc.core.api.dto.instance.attribute.FindAttributesRequest
import com.collibra.dgc.core.api.dto.instance.asset.FindAssetsRequest

def findcurrentAsset =  assetApi.findAssets(FindAssetsRequest.builder()
                                            .name(item.getName())
                                            .build()
                                      ).getResults().get(0).getType().getId() //get type Id of asset your duplicating


def newAsset = assetApi.addAsset(AddAssetRequest.builder() // Creates new asset in chosen domain 
	.name(item.getName())//takes the current asset name and uses it for the new asset name
	.displayName(item.getName()) //takes the current asset name and uses it for the new asset display name
	.typeId(findcurrentAsset) //uses the the current asset type for teh new asset tyupe
	.domainId(string2Uuid(domainId)) //domainId is the form variable from the dropdown where users pick a domain to put the ID in.
	.build()
                                )

newAssetId = newAsset.getId() //Id of duplicat4ed asset

def cloneAttribute = "" // container for duplicated attributes
def attributeStringValue = "" //container for duplicate attribute string values
		
//Get and clone attributes to newly created asset
def attributes = attributeApi.findAttributes(FindAttributesRequest.builder()
                                             .assetId(item.getId())
                                             .build()).getResults()
	
//duplicate attributes for asset using a loop
for (attribute in attributes.sort { it.getType().getName() }) {
		attributeStringValue = attribute.getValue()
		cloneAttribute = attributeApi.addAttribute(AddAttributeRequest.builder()
                                                   .assetId(newAssetId)
                                                   .typeId(attribute.getType().getId())
                                                   .value(attributeStringValue)
                                                   .build()
                                                  )
	}

1 Message

 • 

100 Points

@SeanPyle​ Is this script task still functional in 2024.06.3 version? This worked fine in previous versions, but now I am getting this error: 

Caused by: org.flowable.common.engine.impl.scripting.FlowableScriptEvaluationException: groovy script evaluation failed: 'javax.script.ScriptException: java.lang.UnsupportedOperationException'

3 Messages

 • 

1K Points

@SeanPyle​ Thank you!!!

Loading...