Does anyone have a java example how to update an attribute value of a document that already has a category attached with some of the attributes already set?
I'm trying to follow the C# example but it's totally different in java.
I don't have an IntegerValue class under docman.
IntegerValue runningTimeValue = categoryTemplate.Values[3] as IntegerValue; runningTimeValue.Values = new int?[] { 136 };
Here's what have so far:
// Get nodeID of the document objNode = objDocMan.getNodeByName(intNodeID, strFileName); intNodeID = objNode.getID(); // Get the document's metadata objMetadata = objNode.getMetadata();
// Get the attribute(s) attached to the document lstAttrGroups = objMetadata.getAttributeGroups();
// Get the eRexS Documents attribute group objAttributeGroup = lstAttrGroups.get(0);
Now how do I update the Metadata object? There's no set method at all. I can't do "metadata.AttributeGroups =" like in the C# example.
Perhaps this could help know not...
https://knowledge.opentext.com/knowledge/cs.dll/Open/30750685
Thanks for the reply. I read that post but I'm still not understanding how to set the attribute value.
Here's what I have so far:
// Set the OwnID value objDataValue = new DataValue(); objDataValue.setKey("OwnID"); How do I set the value now? objAttributeGroup.getValues().add(objDataValue);
How do I set the "OwnID" attribute value?
I think I'm close but I still don't know how to set the attribute value:
// Get the effective document's metadata objNode = objDocMan.getNodeByName(objDocData.getIntEffectiveID(), objDocData.getStrEffectiveDocName()); objMetadata = objNode.getMetadata();// Get the attribute(s) attached to the effective document lstAttrGroups = objMetadata.getAttributeGroups();// Get the eRexS Documents attribute group objAttributeGroup = lstAttrGroups.get(0); lstDataValues = objAttributeGroup.getValues(); iterDataValues = lstDataValues.iterator(); i = 0; while(iterDataValues.hasNext()) { objDataValue = lstDataValues.get(i); if(objDataValue.getKey().endsWith(MigrationUtilProps.getOwnIdAttrID(lstPropList))) { I now have the DataValue for the attribute I want to update the value for. How do I do it? break; } i++; }
I'm got it working but I don't think what I'm doing is the best way to do it. Does this look correct?
// Get the effective document's metadata objNode = objDocMan.getNodeByName(objDocData.getIntEffectiveID(), objDocData.getStrEffectiveDocName()); objMetadata = objNode.getMetadata(); objMetadata2 = new Metadata();// Get the attribute(s) attached to the effective document lstAttrGroups = objMetadata.getAttributeGroups();// Get the eRexS Documents attribute group objAttributeGroup = lstAttrGroups.get(0); lstDataValues = objAttributeGroup.getValues(); iterDataValues = lstDataValues.iterator(); for(int i=0;i<lstDataValues.size();i++) { objDataValue = lstDataValues.get(i); // Get the DataValue for the OwnID attribute if(objDataValue.getKey().endsWith(MigrationUtilProps.getOwnIdAttrID(lstPropList))) { // Set the OwnID value objIntegerValue = new IntegerValue(); objIntegerValue.getValues().add(objDocData.getIntEffectiveID()); objIntegerValue.setKey(objDataValue.getKey()); objAttributeGroup.getValues().remove(i); objAttributeGroup.getValues().add(objIntegerValue); do i need to remove then add new? } else { objAttributeGroup.getValues().remove(i); objAttributeGroup.getValues().add(objDataValue); do i need to remove then add new? } } objNode.getMetadata().getAttributeGroups().remove(0); objMetadata2.getAttributeGroups().add(objAttributeGroup); do i need to remove then add new? objNode.setMetadata(objMetadata2);// Update the effective document Node objDocMan.updateNode(objNode);
Does this get answered by anyone yet ?
I don't see docman webservice has all those Objects available in C# , so C# samples are useful to some extent , but using Java Docman api methods seems lacking few object defintions .
If anybody has any example of how to read/modify an Attribute Values using Java Docman web service , please share.
This replay is late, but we set attributes all the time in Java. Here is some code that might help.
package GEN3.OpenText ;