You start the workflow by setting up some process variables like the universally unique identifiers (UUIDs) for the attribute types. This also makes the variables available for later edits on the workflow definition page in Collibra Data Governance Center.
You then write a script task retrieve all the assets under a domain and insert that into a HashMap.
With the first user task, you ask start user to select assets from the checkbox provided. Here you use dynamic_checkbox variable to create a dynamic checkbox.
Before moving forward, you write a script task to initialize variables - counter and selectedAsset. As you'll be modifying assets in a loop, counter decides when to stop the iteration. The other variable selectedAsset stores the asset's UUIDs.
With the new user task, you ask the startUser to enter new attribute Values and store that into variables.
You create a script task to implement the changes. If an attribute of the selected asset didn't have a value earlier, then you'll add new attribute value using AddAttributeRequest.Builder. Otherwise you simply change the attribute value using ChangeAttributeRequest.Builder.
Finally while creating the sequence flow, you have to define a condition to repeat step 5 and step 6 in a loop.
Add a pool and configure the pool properties:
From the Start event section of the Palette, drag a StartEvent
In the Properties view, select the Main config section. In the Initiator field, enter a name for the variable that defines the user who starts the workflow. We are using startUser in this example. The value of the variable will be the username of that user
In the Properties view, select the Form section
Add a variable to set the UUID of the Definition attribute type:
Click New
Click New
import java.util.HashMap
import java.util.Map
import com.collibra.dgc.core.api.model.instance.Asset
import com.collibra.dgc.core.api.dto.instance.asset.FindAssetsRequest
import com.collibra.dgc.core.api.model.instance.Domain
import com.collibra.dgc.core.api.model.instance.Community
def buildAndRegister = {
Domain currentDomain = domainApi.getDomain(item.getId());
UUID initialCommunityId = currentDomain.getCommunity().getId();
Map<String, String> dynamicMapOfValues = new HashMap<String, String>();
def lst = []
fromAssets = assetApi.findAssets(FindAssetsRequest.builder()
.domainId(currentDomain.getId())
.build())
.getResults();
for(asset in fromAssets) {
String assetDisplayName = (asset.getDisplayName().toString());
lst.add(asset.getId())
dynamicMapOfValues.put(asset.getId().toString(), "<em><b>"+assetDisplayName+"</b></em>");
}
execution.setVariable("dynamicMapOfValues", dynamicMapOfValues.sort { it.value.toLowerCase() });
execution.setVariable('proposedTerms', lst)
}
buildAndRegister();
The user task ask the start user to select assets from the checkbox provided.
List selectedAsset= Arrays.asList(dynamic_checkbox.split("\\s*,\\s*"));
counter = 0
execution.setVariable('selectedAsset', selectedAsset)
execution.setVariable('counter', counter)
With the new user task, you ask the startUser to enter new attribute Values and store that into variables..
import com.collibra.dgc.core.api.dto.instance.attribute.FindAttributesRequest
import com.collibra.dgc.core.api.dto.instance.attribute.ChangeAttributeRequest
import com.collibra.dgc.core.api.dto.instance.attribute.AddAttributeRequest
def attributeValue = [:]
noOfAssets = selectedAsset.size()
counter = execution.getVariable('counter')
assetId = selectedAsset[counter]
fromAttributes = attributeApi.findAttributes(FindAttributesRequest.builder().assetId(string2Uuid(assetId)).build()).getResults()
for(attribute in fromAttributes) {
attributeValue.put(attribute.getType().getName().toString(),attribute)
}
// Implementing Modification
if (attributeValue['Definition'] == null){
attributeApi.addAttribute(AddAttributeRequest.builder().assetId(string2Uuid(assetId)).typeId(string2Uuid(uuid_asset_definition)).value(varAssetDefinition.toString()).build())
}
else if (attributeValue['Definition'].getValueAsString() != varAssetDefinition){
ChangeAttributeRequest changeAttributeRequest = ChangeAttributeRequest.builder().id(attributeValue['Definition'].getId()).value(varAssetDefinition.toString()).build()
attributeApi.changeAttribute(changeAttributeRequest)
}
if (attributeValue['Descriptive Example'] == null){
attributeApi.addAttribute(AddAttributeRequest.builder().assetId(string2Uuid(assetId)).typeId(string2Uuid(uuid_asset_descriptive_example)).value(varAssetDescriptiveExample.toString()).build())
}
else if (attributeValue['Descriptive Example'].getValueAsString() != varAssetDescriptiveExample){
ChangeAttributeRequest changeAttributeRequest = ChangeAttributeRequest.builder().id(attributeValue['Descriptive Example'].getId()).value(varAssetDescriptiveExample.toString()).build()
attributeApi.changeAttribute(changeAttributeRequest)
}
execution.setVariable('noOfAssets', noOfAssets);
execution.setVariable('counter',counter+1);
execution.setVariable('varAssetDefinition','');
execution.setVariable('varAssetDescriptiveExample','');