02-26-2015 11:04 AM
protected void addCategory(
Session session,
Document testDoc,
String categoryName
)
{
ItemIterable<QueryResult> rs = session.query(
"select * from cm:category where cmis:name = '" + categoryName + "'",false);
if (rs.getTotalNumItems() == 0) {
System.out.println("Couldn't find category with name: " + categoryName);
return;
}
int i=0;
String catId=null;;
for (QueryResult resultRow : rs)
{
if (i==0)
{
catId = resultRow.getPropertyValueById("cmis:objectId");
}
}
testDoc.refresh();
List<String> aspects = testDoc.getPropertyValue("cmis:secondaryObjectTypeIds");
//je contrôle l'existence de l'aspect 'categorisable' par une méthode adhoc
if (! CmisClientAspectUtil.readAspectsForExistingDocument(session,
testDoc, "P:cm:generalclassifiable"))
{
//et j'attribue l'aspect le cas échéant
CmisClientAspectUtil.addAspectToExistingDocument(
testDoc,"P:cm:generalclassifiable",debug);
}
if (!testDoc.isLatestVersion())
{
testDoc = testDoc.getObjectOfLatestVersion(false);
}
List<String> catIds = testDoc.getPropertyValue("cm:categories");
if (!catIds.contains(catId)) {
catIds.add(catId);
for (int k=0; k<catIds.size(); k++)
{
catIds.set(k,"workspace://SpacesStore/"+catIds.get(k));
}
HashMap<String, List<String>> props = new HashMap<String, List<String>>();
props.put("cm:categories",catIds);
testDoc.updateProperties(props, false);
}
}
03-05-2015 05:15 AM
03-09-2015 07:13 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.