D

Tuesday, March 29th, 2022 10:00 AM

Import responsability API for workflow

I am trying to run this part of the code

responsabilityIds = responsabilityApi.findResponsibilities(FindResponsibilitiesRequest.builder()
.resourceIds(tableId)
.build())
getResults()

with the import below

import com.collibra.dgc.core.api.dto.instance.responsibility.FindResponsibilitiesRequest
import com.collibra.dgc.core.api.component.instance.ResponsibilityApi

I have the error below

Caused by: groovy.lang.MissingPropertyException: No such property: responsabilityApi for class: Script23

So I understand that the import class is wrong, what is the good class import ?

I will also have to add a responsability, I understand the class import will be
import com.collibra.dgc.core.api.dto.instance.responsibility.AddResponsibilitiyRequest

Can you confirm it ?
thanks

1.2K Messages

2 years ago

You have a typo:

responsabilityApi
responsibilityApi

You also have an a syntax error

.resourceIds(tableId)
.resourceIds([tableId])

And you should not import the APIs, they are already instantiated.
For more info, I recommend this post: The best autocomplete trick for eclipse! Get hints to java apis directly. - :question:Product Q&A - The Data Citizens Community (collibra.com)
It explains how to automatically get autocomplete in Eclipse.

Here’s what valid code looks like:

import com.collibra.dgc.core.api.dto.instance.responsibility.FindResponsibilitiesRequest

def responsibilityIds = responsibilityApi.findResponsibilities(FindResponsibilitiesRequest.builder()
	.resourceIds([string2Uuid(tableId)])
	.build()
	).results.collect{it.id}

Notice that I can use .results instead of .getResults() and I can chain tranformations with .collect{}.
it is the syntactical default to refer to each element being iterated on by .collect{}.

44 Messages

2 years ago

Hi,

Here my new code

responsibilityApi.addResponsibility(AddResponsibilityRequest.builder()
.ownerId([string2Uuid(userIdId)])
.resourceId([string2Uuid(tableId)])
.roleId([string2Uuid(“00000000-0000-0000-0000-000000005038”)])
.resourceType([string2Uuid(“00000000-0000-0000-0000-000000031007”)])
.build()




Still not working, seems to have trouble with the Uuid part,

Caused by: groovy.lang.MissingMethodException: No signature of method: Script48.string2Uuid() is applicable for argument types: (UUID) values: [f225b023-980e-4d6b-9479-58d8921d61f5]

Possible solutions: string2Uuid(java.lang.String)

Loading...