Hi folks,While using advanced search functionality in alfresco I am not able to search the document when I used certain fields.I have two fields courtName and matterType, matterType depends on courtName(cascading dropdown), when I try to search by these two fields individually or in combination I am not able to search the documents. Similarly I have another field caseReference which is created using behavior and is a combination of 3 fields in format {matterType/caseNumber/caseYear}; advanced search fails for this field also.Below are snippets of my code.<strong>Custom Model</strong>
<constraints>
//the value on Share will be shown as <strong>A</strong> instead of <strong>1 - A</strong>
// through the use of ftl
<constraint name="evl:courtNames" type="LIST">
<parameter name="allowedValues">
<list>
<value></value>
<value>1 - A</value>
<value>2 - B</value>
</parameter>
</constraint>
//the value on Share will be shown as <strong>Arbitration Petition</strong> instead of <strong>1 - Arbitration Petition through the use of ftl</strong>
<constraint name="evl:matterTypes" type="LIST">
<parameter name="allowedValues">
<list>
<value></value>
<value>1 - Arbitration Petition</value>
<value>1 - Civil Appeal</value>
<value>1 - REF. U/A 317(1)</value>
<value>2 - CAVEAT(CO.)</value>
<value>2 - CCP(CO.)</value>
<value>2 - CCP(O)</value>
<value>2 - CCP(REF)</value>
<value>2 - CEAC</value>
<value>2 - O.M.P. (T) (COMM.)</value>
</list>
</parameter>
</constraint>
</constraints>
<types>
<!– Enterprise-wide generic legal document type –>
<type name="evl:legalDocument">
<title>Legal Document</title>
<parent>cm:content</parent>
<properties>
<!– Year of the Case. –>
<property name="evl:yearOfCreation">
<title>Document Year</title>
<type>d:long</type>
<mandatory>true</mandatory>
<multiple>false</multiple>
<constraints>
<constraint ref="evl:yearConstraint" />
</constraints>
</property>
<!– Which court is the case in –>
<property name="evl:courtName">
<title>Name of the Court</title>
<type>d:text</type>
<multiple>false</multiple>
<index enabled="true">
<tokenised>false</tokenised>
</index>
<constraints>
<constraint ref="evl:courtNames" />
</constraints>
</property>
<!– A number assigned to a legal case by a court –>
<property name="evl:caseNumber">
<title>Case Number </title>
<type>d:long</type>
</property>
<!– A short code for the type of matter at hand –>
<property name="evl:matterType">
<title>Matter Type</title>
<type>d:text</type>
<multiple>false</multiple>
<index enabled="true">
<tokenised>false</tokenised>
</index>
<constraints>
<constraint ref="evl:matterTypes" />
</constraints>
</property>
<!– Will be auto-generated based on Matter Type, Case Number and Case
Year –>
<property name="evl:caseReference">
<title>Case Reference</title>
<type>d:text</type>
<index enabled="true">
<tokenised>false</tokenised>
</index>
</property>
</properties>
</type>
</types>
<strong>share-custom-config.xml</strong>
<!– Advanced search form configuration –>
<config evaluator="model-type" condition="evl:legalDocument"
override="true">
<forms>
<!– Search form –>
<form id="search">
<field-visibility>
<show id="evl:caseNumber" force="true" />
<show id="evl:yearOfCreation" force="true" />
<show id="evl:courtName" force="true" />
<show id="evl:matterType" force="true" />
<show id="evl:caseReference" force="true" />
</field-visibility>
<appearance>
<field id="evl:caseNumber" label-id="prop.evl_caseNumber">
<!– <control> <control template="" /> </control> –>
</field>
<field id="evl:yearOfCreation" label-id="prop.evl_yearOfCreation">
<control>
<control-param name="maxLength">4</control-param>
</control>
</field>
<field id="evl:courtName" label-id="prop.evl_courtName">
<control template="/form-controls/parent-filter-selectone.ftl">
<control-param name="filteredProperty">evl_matterType</control-param>
</control>
</field>
<field id="evl:matterType" label-id="prop.evl_matterType">
<control template="/form-controls/filtered-selectone.ftl" />
</field>
<!– <field id="evl:caseReference" label-id="prop.evl_caseReference"></field> –>
</appearance>
</form>
</forms>
</config>
<strong>Behavior for generating caseReference fiels</strong>
public class LegalPropertyGenerator implements
NodeServicePolicies.OnCreateNodePolicy,
NodeServicePolicies.OnUpdatePropertiesPolicy {
// Dependencies
private NodeService nodeService;
private PolicyComponent policyComponent;
// Behaviours
private Behaviour onCreateNode;
private Behaviour onUpdateProperties;
private Logger logger = Logger.getLogger(LegalPropertyGenerator.class);
public void init() {
if (logger.isDebugEnabled())
logger.debug("******************* Initializing legal property generator behavior *******************");
// Create behaviours
this.onCreateNode = new JavaBehaviour(this, "onCreateNode",
NotificationFrequency.TRANSACTION_COMMIT);
this.onUpdateProperties = new JavaBehaviour(this, "onUpdateProperties",
NotificationFrequency.TRANSACTION_COMMIT);
// Bind behaviours to node policies
this.policyComponent.bindClassBehaviour(QName.createQName(
NamespaceService.ALFRESCO_URI, "onCreateNode"), LegalDocumentModel.TYPE_LEGAL_DOCUMENT,
this.onCreateNode);
this.policyComponent.bindClassBehaviour(QName.createQName(
NamespaceService.ALFRESCO_URI, "onUpdateProperties"), LegalDocumentModel.TYPE_LEGAL_DOCUMENT,
this.onUpdateProperties);
}
@Override
public void onCreateNode(ChildAssociationRef childAssocRef) {
if (logger.isDebugEnabled())
logger.debug("Inside onCreateNode");
generateLegalTypeFields(childAssocRef.getChildRef());
}
@Override
public void onUpdateProperties(NodeRef nodeRef,
Map<QName, Serializable> before, Map<QName, Serializable> after) {
if (logger.isDebugEnabled())
logger.debug("Inside onUpdateProperties");
generateLegalTypeFields(nodeRef);
}
/**
* Method used for generating the ev:legalDocument type fields
*
* @param caseNumber
* case number of the document
* @param caseYear
* year of the case
* @param matterType
* matter type of the case
*/
public void generateLegalTypeFields(NodeRef nodeRef) {
if (logger.isDebugEnabled())
logger.debug("Inside generateFieldCaseRef");
// get the required fields for generating the case reference field
Serializable caseNumber = nodeService.getProperty(nodeRef, LegalDocumentModel.PROP_CASE_NUMBER);
Serializable caseYear = nodeService.getProperty(nodeRef, LegalDocumentModel.PROP_CASE_YEAR);
Serializable matterType = nodeService.getProperty(nodeRef, LegalDocumentModel.PROP_MATTER_TYPE);
generateCaseRefField(nodeRef, caseNumber, caseYear, matterType);
}
private void generateCaseRefField(NodeRef nodeRef, Serializable caseNumber,
Serializable caseYear, Serializable matterType) {
if (caseNumber == null || caseYear == null || matterType == null
|| matterType.toString().equals("")) {
nodeService.setProperty(nodeRef, LegalDocumentModel.PROP_CASE_REFERENCE, null);
} else {
// as the value is coming as "1 - courtName", we need to extract the "courtName"
int index = matterType.toString().indexOf("-") + 1;
nodeService.setProperty(nodeRef, LegalDocumentModel.PROP_CASE_REFERENCE, matterType
.toString().substring(index)
+ "/"
+ caseNumber.toString()
+ "/"
+ caseYear.toString());
}
}
public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;
}
public void setPolicyComponent(PolicyComponent policyComponent) {
this.policyComponent = policyComponent;
}
}
Thanks