Hi Experts....
We are currently running into an issue with the ObjectService specifically the "Create" method that has either Referrence or Object relationship.
This is what we are trying to do:
1. Create DataObject: ABC (type: dm_document) in "Cabinet A/Folder A/"
2. Create DataObject: DEF (type: dm_document) in "Cabinet D/Folder D/"
3. Create an ObjectRelationship and added it to DataObject ABC and set the TargetRole as Parent and set the name to Peer
4. DataObject ABC and DEF are now related as a dm_relation (peer)...specifically ABC being the parent and DEF as the child
However this is not working as expected. What we are seeing is the two objects get created in their designated cabinet/folder but the relationship never gets created. So are we mising something or does the ObjectService don't handle these types of relationship and only allows folder relationships (linking)?
Here is the code...
//Creating the ABC Object
String parName = "parentTestDocWebServiceCreated";
ObjectIdentity parObjIdentity = new ObjectIdentity();
parObjIdentity.setRepositoryName(repository);
DataObject ABC= new DataObject(parObjIdentity, "dm_document");
PropertySet parProp = new PropertySet();
parProp.set("object_name", parName);
ABC.setProperties(parProp);
String folderPath = "/Cabinet A/Folder A";
ObjectPath objectPath = new ObjectPath(folderPath);
ObjectIdentity<ObjectPath> primFolderIdentity =
new ObjectIdentity<ObjectPath>(objectPath,repository);
ReferenceRelationship primFolderRelationship = new ReferenceRelationship();
primFolderRelationship.setName(Relationship.RELATIONSHIP_FOLDER);
primFolderRelationship.setTarget(primFolderIdentity);
primFolderRelationship.setTargetRole(Relationship.ROLE_PARENT);
ABC.getRelationships().add(new ReferenceRelationship(primFolderRelationship));
List<Content> contentList = new ArrayList<Content>();
FileContent pFile = new FileContent("C:\\Test.txt", "crtext");
contentList.add(pFile);
ABC.setContents(contentList);
//Creating the DEF Object
String attName = "attachTestDocWebServiceCreated";
ObjectIdentity attObjIdentity = new ObjectIdentity();
attObjIdentity.setRepositoryName(repository);
DataObject DEF = new DataObject(attObjIdentity, "dm_document");
PropertySet attProp = new PropertySet();
attProp.set("object_name", attName);
DEF.setProperties(attProp);
String attFolderPath = "/Cabinet D/Folder D";
ObjectPath attObjectPath = new ObjectPath(attFolderPath);
ObjectIdentity<ObjectPath> attFolderIdentity =
new ObjectIdentity<ObjectPath>(attObjectPath,repository);
ReferenceRelationship attFolderRelationship = new ReferenceRelationship();
attFolderRelationship.setName(Relationship.RELATIONSHIP_FOLDER);
attFolderRelationship.setTarget(attFolderIdentity);
attFolderRelationship.setTargetRole(Relationship.ROLE_PARENT);
DEF.getRelationships().add(new ReferenceRelationship(attFolderRelationship));
List<Content> attContentList = new ArrayList<Content>();
FileContent attFile = new FileContent("C:\\AttachmentTest.txt", "crtext");
attContentList.add(attFile);
DEF.setContents(attContentList);
//Creating the ObjectRelationship
ObjectRelationship attRelationship = new ObjectRelationship();
attRelationship.setTarget(attDataObj);
attRelationship.setName("peer");
attRelationship.setTargetRole(Relationship.ROLE_CHILD);
attRelationship.setIntentModifier(attRelationship.ADD);
ABC.getRelationships().add(new ObjectRelationship(attRelationship));
DataPackage dataPackage = new DataPackage();
dataPackage.addDataObject(ABC);
OperationOptions options = null;
newDataObject = ObjectService.create(dataPackage,options);
Any help will be appreciated.
Thanks!