CMDBuild Forum

setting domain attributes with advanced connector

Dear CMDBuild Team,

 

how is it possible, to import values for an attribute of an domain (N:N relation) with the advanced connector?

My little sample:

two classes

Class A: contains usergroup

Class B: contains the directories of the filesystem

and one domain A2B (N:N relation) between Class A and Class B

at the domain A2B i defined an attribute "rights"; represents the rights of a usergroup in the specific filesystemdirectory.

Which method would be to use in the "newRelation(domain)" function (.withAttribute or .withDomainAttribute or how ) in the connector-sql.groovy?

Thanks Peter.

 

 

 

 

Dear Hesse,
when you create new relations you should be able to set its attributes using the syntax ".withAttribute(key,value)". For example:
final relationCreator = newRelation(relationName) 
.withReference(card1) 
.withReference(card2)
.withAttribute("Name","Value");
relation = addRelation(relationCreator);
Regards,
 
CMDBuild Team
 
 
Previously Hesse wrote:

Dear CMDBuild Team,

 

how is it possible, to import values for an attribute of an domain (N:N relation) with the advanced connector?

My little sample:

two classes

Class A: contains usergroup

Class B: contains the directories of the filesystem

and one domain A2B (N:N relation) between Class A and Class B

at the domain A2B i defined an attribute "rights"; represents the rights of a usergroup in the specific filesystemdirectory.

Which method would be to use in the "newRelation(domain)" function (.withAttribute or .withDomainAttribute or how ) in the connector-sql.groovy?

Thanks Peter.

 

 

 

 

 

Hi CMDBuild Team,

 

this was also my first idea, but i receive a "MissingMethodException" and i was not sure ......:

 Caused by: org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: org.cmdbuild.connector.commons.data.ConnectorRelation$ConnectorRelationBuilder.withAttribute() is applicable for argument types: (java.lang.String, java.lang.String) values: [Rights, Rechtexyz]

My Syntax is:

connector-schema.groovy: (this part works)

def domainEdirgroup2Fsdir(Edirgroup, Fsdir){
 addDomain(newDomain("Edirgroup2Fsdir")
  .withDomainName("Edirgroup2Fsdir")
  .withClass(Edirgroup)
  .withClass(Fsdir)
  .withAttribute("Rights"));
}

connector-sql.groovy: (this part works without the .withAttribute )

final relation = newRelation("Edirgroup2Fsdir")
 .withReference(Edirgroup)
 .withReference(Fsdir)
 .withAttribute("Rights","Rechtexyz");   ==>  this row caused the error; the fixed value "Rechtexyz" only for first tests and will replaced with a variable later
addRelation(relation);

 Need i an additional "Import" Statement ? Actually defined:

import org.cmdbuild.connector.commons.data.ConnectorRelation;
import org.cmdbuild.connector.commons.data.ConnectorRelation.ConnectorRelationBuilder;

import org.cmdbuild.connector.commons.data.schema.ConnectorDomain;
import org.cmdbuild.connector.commons.data.schema.ConnectorDomainAttribute;
import org.cmdbuild.connector.commons.data.schema.ConnectorDomainAttribute.ConnectorDomainAttributeBuilder;

 

Many thanks

Peter

Previously Tecnoteca wrote:

Dear Hesse,
when you create new relations you should be able to set its attributes using the syntax ".withAttribute(key,value)". For example:
final relationCreator = newRelation(relationName) 
.withReference(card1) 
.withReference(card2)
.withAttribute("Name","Value");
relation = addRelation(relationCreator);
Regards,
 
CMDBuild Team
 
 
Previously Hesse wrote:

Dear CMDBuild Team,

 

how is it possible, to import values for an attribute of an domain (N:N relation) with the advanced connector?

My little sample:

two classes

Class A: contains usergroup

Class B: contains the directories of the filesystem

and one domain A2B (N:N relation) between Class A and Class B

at the domain A2B i defined an attribute "rights"; represents the rights of a usergroup in the specific filesystemdirectory.

Which method would be to use in the "newRelation(domain)" function (.withAttribute or .withDomainAttribute or how ) in the connector-sql.groovy?

Thanks Peter.