cancel
Showing results for 
Search instead for 
Did you mean: 

Advanced Search on some custom fields not working

hiten_rastogi1
Star Contributor
Star Contributor
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
6 REPLIES 6

hiten_rastogi1
Star Contributor
Star Contributor
Hi,

I am still not able to find out why I am able to search in some cases and not in some. Though I was able to solve this problem by removing the children from the appearance tag but this is not desirable as I have custom ftl's that are required.

Thanks

muralidharand
Star Contributor
Star Contributor
Can you please share the share-custom-config.xml with comments for appearance tag?

Copied files in the question.

Hi Murali,

I have copied the file in the question itself, please find the file there. Also I have changed the question to reflect my original concern.

netwidz
Champ in-the-making
Champ in-the-making
You need to add your custom type in share-config-custom.xml to work
 
   <config evaluator="string-compare" condition="Advanced Search">
      <!– advanced search custom attribute config –>
      <!– see http://wiki.alfresco.com/wiki/Advanced_Search_Custom_Attributes –>
      <advanced-search>
         <!– type constraint drop-down –>
         <content-types>
            <!– cm:content type is implicit in this list –>
            <!– types must extend cm:content for display in the Alfresco web-client –>
           <type name="evl:legalDocument" />
            <type name="fm:post" />
         </content-types>
         <folder-types>
            <!– cm:folder type is implicit in this list –>
            <!– types must extend cm:folder for display in the Alfresco web-client –>
            <type name="fm:forums" />
         </folder-types>
      </advanced-search>
   </config>

Hi Netwidz,

I have Advanced Search config tag already in my share-custom-config.xml. My question here is that I am not able to search with fields I have mentioned means when I enter the value to be searched in these fields they return no document.


<!– Advanced Search config section –>
   <config replace="true" evaluator="string-compare" condition="AdvancedSearch">
      <advanced-search>
         <!– Forms for the advanced search type list –>
         <forms>

            <form labelId="type.evl_legalDocument" descriptionId="search.form.desc.evl_legalDocument">evl:legalDocument
            </form>
            <form labelId="search.form.label.cm_content" descriptionId="search.form.desc.cm_content">cm:content
            </form>
            <form labelId="search.form.label.cm_folder" descriptionId="search.form.desc.cm_folder">cm:folder
            </form>

         </forms>
      </advanced-search>
   </config>