09-17-2008 01:06 AM
<?xml version="1.0" encoding="UTF-8"?>
<!– Custom Model –>
<!– Note: This model is pre-configured to load at startup of the Repository. So, all custom –>
<!– types and aspects added here will automatically be registered –>
<model name="custom:customModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!– Optional meta-data about the model –>
<description>Custom Model</description>
<author>Stephen M. Wick</author>
<version>1.0</version>
<imports>
<!– Import Alfresco Dictionary Definitions –>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<!– Import Alfresco Content Domain Model Definitions –>
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
</imports>
<!– Introduction of new namespaces defined by this model –>
<!– NOTE: The following namespace custom.model should be changed to reflect your own namespace –>
<namespaces>
<namespace uri="custom.model" prefix="custom"/>
</namespaces>
<types>
<type name="cm:product">
<title>Product</title>
<parent>cm:content</parent>
<associations>
<association name="cm:crops">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:crop</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
<association name="cm:pests">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:pest</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</type>
<type name="cm:crop">
<title>Crop</title>
<parent>cm:content</parent>
<associations>
<association name="cm:products">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:product</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
<association name="cm:pests">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:pest</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</type>
<type name="cm:pest">
<title>Pest</title>
<parent>cm:content</parent>
<associations>
<association name="cm:products">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:product</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
<association name="cm:crops">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:crop</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</type>
</types>
</model>
<?xml version="1.0" encoding="UTF-8"?>
<!– Custom Model –>
<!– Note: This model is pre-configured to load at startup of the Repository. So, all custom –>
<!– types and aspects added here will automatically be registered –>
<model name="custom:customModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!– Optional meta-data about the model –>
<description>Custom Model</description>
<author>Stephen M. Wick</author>
<version>1.0</version>
<imports>
<!– Import Alfresco Dictionary Definitions –>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<!– Import Alfresco Content Domain Model Definitions –>
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
</imports>
<!– Introduction of new namespaces defined by this model –>
<!– NOTE: The following namespace custom.model should be changed to reflect your own namespace –>
<namespaces>
<namespace uri="custom.model" prefix="custom"/>
</namespaces>
<types>
<type name="cm:product">
<title>Product</title>
<parent>cm:content</parent>
<associations>
<association name="cm:crops">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:crop</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
<association name="cm:pests">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:pest</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</type>
<type name="cm:crop">
<title>Crop</title>
<parent>cm:content</parent>
</type>
<type name="cm:pest">
<title>Pest</title>
<parent>cm:content</parent>
</type>
</types>
</model>
09-23-2008 05:19 PM
09-24-2008 03:45 AM
* Represents a generic association between two nodes. The association is named
* and bidirectional by default.
<config evaluator="node-type" condition="cns:text">
<property-sheet>
<show-association name="cns:textTemplateAssoc" />
</property-sheet>
</config>
<config evaluator="node-type" condition="cns:textTemplate">
<property-sheet>
<show-association name="cns:textTemplateAssoc" />
</property-sheet>
</config>
09:33:13,450 User:admin WARN [component.property.UIAssociation] Failed to find association definition for association 'cns:textTemplateAssoc'
09-24-2008 05:49 PM
/**
* @throws UnsupportedOperationException always
*/
public List<AssociationRef> getSourceAssocs(NodeRef sourceRef, QNamePattern qnamePattern)
{
// This operation is not supported for a version store
throw new UnsupportedOperationException(MSG_UNSUPPORTED);
}
09-24-2008 06:05 PM
<#– Shows some Crop info about the current document –>
<#if document?exists>
<h4>Crop Info:</h4>
<table>
<tr><td><b>Name:</b></td><td>${document.name}</td></tr>
<tr><td><b>Products:</b></td><td>
<table>
<#list companyhome.childrenByLuceneSearch["+TYPE:\"fs:product\""] as product>
<#list product.assocs["fs:crops"] as crop>
<#if crop.name == document.name>
<tr><td><a href="/alfresco/n/showDocDetails/workspace/SpacesStore/${product.id}">${product.name}</a></td></tr>
</#if>
</#list>
</#list>
</table>
</td></tr>
</table>
<#else>
No document found!
</#if>
09-25-2008 12:40 PM
09-29-2008 11:15 AM
10-06-2008 12:17 PM
public class RuleTriggerBidirectionalAssoc extends RuleTriggerAbstractBase
implements NodeServicePolicies.OnDeleteAssociationPolicy, NodeServicePolicies.OnCreateAssociationPolicy {
public void onDeleteAssociation(AssociationRef nodeAssocRef) {
nodeService.removeAssociation(nodeAssocRef.getTargetRef(), nodeAssocRef.getSourceRef(),
getReverseQnameAssociationName(nodeAssocRef.getTypeQName()));
}
public void onCreateAssociation(AssociationRef nodeAssocRef) {
nodeService.createAssociation(nodeAssocRef.getTargetRef(), nodeAssocRef.getSourceRef(),
getReverseQnameAssociationName(nodeAssocRef.getTypeQName()));
}
public void registerRuleTrigger() {
this.policyComponent.bindAssociationBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateAssociation"), this,
new JavaBehaviour(this, "onCreateAssociation"));
this.policyComponent.bindAssociationBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteAssociation"), this,
new JavaBehaviour(this, "onDeleteAssociation"));
}
}
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="on-association-change-trigger" class="org.test.alfresco.repo.rule.trigger.RuleTriggerBidirectionalAssoc"
parent="rule-trigger-base" />
</beans>
10-06-2008 05:43 PM
12-22-2008 06:45 PM
public QName getReverseQnameAssociationName(QName qName) {
String reverseLocalName = new StringBuffer(qName.getLocalName()).reverse().toString();
QName reverseQName = QName.createQName(qName.getNamespaceURI(), reverseLocalName);
return reverseQName;
}
<property-sheet>
<show-association name="sample:s2c" read-only="true" />
</property-sheet>
Also this constraint imposes to have a reverse association for all associations defined in Alfresco. To remove such a restriction we can catch and ignore the corresponding exception
public void onDeleteAssociation(AssociationRef nodeAssocRef) {
try {
nodeService.removeAssociation(nodeAssocRef.getTargetRef(), nodeAssocRef.getSourceRef(), getReverseQnameAssociationName(nodeAssocRef.getTypeQName()));
} catch (IllegalArgumentException exception) {
if (exception.getMessage().indexOf(NOT_DEFINED_EXCEPTION_MESSAGE) == -1)
throw exception;
// otherwise ignore it
}
}
public void onCreateAssociation(AssociationRef nodeAssocRef) {
try {
nodeService.createAssociation(nodeAssocRef.getTargetRef(), nodeAssocRef.getSourceRef(), getReverseQnameAssociationName(nodeAssocRef.getTypeQName()));
} catch (IllegalArgumentException exception) {
if (exception.getMessage().indexOf(NOT_DEFINED_EXCEPTION_MESSAGE) == -1)
throw exception;
// otherwise ignore it
}
}
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.