06-12-2014 10:46 AM
if (alfDoc.hasAspect("P:ra:reportProperties"))
{
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("ra:department", "Accounting");
alfDoc.updateProperties(properties);
}
<?xml version="1.0" encoding="UTF-8"?>
<!– First namespace prefix in namespace array is used for model prefix –>
<model xmlns="http://www.alfresco.org/model/dictionary/1.0" name="ra:reportAspect">
<description>Alfresco Form Builder Project</description>
<author>admin</author>
<version>1.0</version>
<imports>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
</imports>
<namespaces>
<namespace uri="ra.model" prefix="ra" />
</namespaces>
<aspects>
<aspect name="ra:reportProperties">
<title>reportProperties</title>
<properties>
<property name="ra:reportName">
<title>Report Name</title>
<type>d:text</type>
</property>
<property name="ra:department">
<title>Department</title>
<type>d:text</type>
</property>
<property name="ra:frequency">
<title>Frequency</title>
<type>d:text</type>
</property>
<property name="ra:suffix">
<title>Suffix</title>
<type>d:text</type>
</property>
<property name="ra:uniqueIdentifier">
<title>Report Unique Identifier</title>
<type>d:text</type>
</property>
<property name="ra:date">
<title>Report Date</title>
<type>d:date</type>
</property>
<property name="ra:notInWorkflow">
<title>Not In Workflow</title>
<type>d:boolean</type>
</property>
</properties>
</aspect>
</aspects>
</model>
06-12-2014 11:04 PM
List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>();
CmisExtensionElement valueElem = new CmisExtensionElementImpl(CMISConnector.ALFRESCO_EXTENSION_NAMESPACE, "value", null, "Accounting");
List<CmisExtensionElement> valueElems = new ArrayList<CmisExtensionElement>();
valueElems.add(valueElem);
List<CmisExtensionElement> children = new ArrayList<CmisExtensionElement>();
Map<String, String> attributes = new HashMap<String, String>();
attributes.put("propertyDefinitionId", "ra:department");
children.add(new CmisExtensionElementImpl(CMISConnector.ALFRESCO_EXTENSION_NAMESPACE, "propertyString", attributes, valueElems));
List<CmisExtensionElement> propertyValuesExtension = new ArrayList<CmisExtensionElement>();
propertyValuesExtension.add(new CmisExtensionElementImpl(CMISConnector.ALFRESCO_EXTENSION_NAMESPACE, CMISConnector.PROPERTIES, null, children));
CmisExtensionElement setAspectsExtension = new CmisExtensionElementImpl(CMISConnector.ALFRESCO_EXTENSION_NAMESPACE, CMISConnector.SET_ASPECTS, null, propertyValuesExtension);
extensions.add(setAspectsExtension);
06-13-2014 09:18 AM
06-13-2014 10:21 AM
06-13-2014 01:46 PM
06-14-2014 12:51 AM
String ALFRESCO_EXTENSION_NAMESPACE = "http://www.alfresco.org";
String SET_ASPECTS = "setAspects";
String PROPERTIES = "properties";
String VALUE = "value";
String PROPERTY_DEFINITION_ID="propertyDefinitionId";
String PROPERTY_STRING="propertyString";
String servalUrl = "http://localhost:8080/alfresco/cmisatom";
String userName = "admin";
String password = "admin";
Session session = getSession(servalUrl, userName, password);
AlfrescoDocument alfDoc = (AlfrescoDocument) session
.getObjectByPath("/TESTFOLDER1/20130822.doc");
Properties properties = new PropertiesImpl();
List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>();
CmisExtensionElement valueElem = new CmisExtensionElementImpl(ALFRESCO_EXTENSION_NAMESPACE, VALUE, null, "Accounting"); //property value of custom property ra:department is accounting
List<CmisExtensionElement> valueElems = new ArrayList<CmisExtensionElement>();
valueElems.add(valueElem);
List<CmisExtensionElement> children = new ArrayList<CmisExtensionElement>();
Map<String, String> attributes = new HashMap<String, String>();
attributes.put(PROPERTY_DEFINITION_ID, "ra:department");//property name is ra:department
children.add(new CmisExtensionElementImpl(ALFRESCO_EXTENSION_NAMESPACE, PROPERTY_STRING, attributes, valueElems));
List<CmisExtensionElement> propertyValuesExtension = new ArrayList<CmisExtensionElement>();
propertyValuesExtension.add(new CmisExtensionElementImpl(ALFRESCO_EXTENSION_NAMESPACE, PROPERTIES, null, children));
CmisExtensionElement setAspectsExtension = new CmisExtensionElementImpl(ALFRESCO_EXTENSION_NAMESPACE, SET_ASPECTS, null, propertyValuesExtension);
extensions.add(setAspectsExtension);
System.out.println(extensions);
properties.setExtensions(extensions);
String repId = session.getRepositoryInfo().getId();
Holder<String> objectIdHolder = new Holder<String>(alfDoc.getId());
session.getBinding().getObjectService().updateProperties(repId, objectIdHolder, null, properties, null);
06-16-2014 04:37 PM
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.