cancel
Showing results for 
Search instead for 
Did you mean: 

Business rule Specialise the type of an item

jlabuelo
Champ on-the-rise
Champ on-the-rise
Hi all

Lets see if any of you can help me here please.

I am trying to add a new type automatically to any item I will drop in a dropbox folder using CIFS.

I have especified the new type in the Data Model, and if I add the item manually vía WEB_UI, I can chose the type manually and assign it to the item and modify the properties of the type.

But now what I want to do is creating a rule, that will assign this type automatically to all the items droped in this box, so then a JS will extract and update the Meta-Data of this type.

To create the rule, I just thought that I had to create a business rule in the UI, selecting all the items as filter, and then in the actions I have chosen "Specialise the type of an Item". The problem is that when I clink in "select values and add" I dont find the type I have created.

Here I pass you the code I have created in the customModel.xml and web-client-config-custom.xml to see if you can find any error I am missing.

Also if you know a better way of doing this,or any place where it is explained how to get all this process I will really appreciate it.

The code of the CustomModel.xml where I define the type is:

 <!– 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>
   <!– Definition of new Content Type: Press Release –>
      <type name="custom:CheckInformation">
         <title>Informacion de Cheque</title>
         <parent>cm:content</parent>
         <properties>
            <property name="custom:CompanyName">
            <title>Nombre Sociedad</title>
            <type>d:text</type>
            </property>

            <property name="custom:CompanyCIF">
            <title>CIF/NIF</title>
            <type>d:text</type>
            </property>
        </properties>    
      </type>
   </types>

Then I modify the web-client-config-custom.xml, so the type can be added manually in the content wizard, in the action wizard, and also used in the Advanced search. But it in the Action wizar where I think the problem is…even I dont know why:

<!– Lists the custom aspect in business rules Action wizard –> 
<config evaluator="string-compare" condition="Action Wizards">
   <subtypes>
      <type name="custom:CheckInformation"/>
   </subtypes>
</config>

<config evaluator="string-compare" condition="Content Wizards">
   <content-types>
      <type name="custom:CheckInformation" />
   </content-types>
</config>

<config evaluator="node-type" condition="custom:CheckInformation">
   <property-sheet>
      <show-property name="mimetype"
        display-label-id="content_type"
        component-generator="MimeTypeSelectorGenerator" />
     <show-property name="size"
        display-label-id="size"
        converter="org.alfresco.faces.BByteSizeConverter"
        show-in-edit-mode="false" />
     <show-property name="custom:CompanyName" />
     <show-property name="custom:CompanyCIF" />
   </property-sheet>
</config>
  

  
   <config evaluator="string-compare" condition="Advanced Search">
      <advanced-search>
         <content-types>
         <type name="custom:CheckInformation" />
         </content-types>
         <custom-properties>
            <meta-data type="custom:CheckInformation" property="custom:CompanyName" />
         <meta-data type="custom:CheckInformation" property="custom:CompanyCIF" />
         </custom-properties>
      </advanced-search>
   </config>
    

Any help or guideness on this will be appreciated :-).

Thanks in advance guys
3 REPLIES 3

mikef
Champ in-the-making
Champ in-the-making
You need to add specialise-type to your web-client-custom-config.xml i.e.

<config evaluator="string-compare" condition="Action Wizards">
   <subtypes>
       <type name="custom:CheckInformation"/>
   </subtypes>
   <specialise-types>
       <type name="custom:CheckInformation"/>
   </specialise-types>
</config>

Hint: If you have having problems configuring the Web Client UI, check web-client-config files in the webapps\alfresco\WEB-INF\classess\alfresco to find examples of how the standard client UI is configured.

jlabuelo
Champ on-the-rise
Champ on-the-rise
Hi Mike

Thanks a lot for the help, I just tried it and worked fine!!!. I was checking the examples that I got after installing Alfresco in tomcat/shared/classes/alfresco/extension. But from now on I will be checking the ones you just  pointed out.

Thanks again

jlabuelo
Champ on-the-rise
Champ on-the-rise
Hi again

Now that I got it working thanks to your help I am trying to make my configuration a little bit more difficult.

Let me explain what I pretend to get

a) Move a Word, Excel, PDF document to a Drop Space in my application using CIFS – DONE
b) As soon as the file arrives to the Drop Space, it will get a new type assigned, which I have defined, using a business rule – DONE

c) The third step, would be reading the document (the content of the document) and find in there the values of the metadata of the type defined in step b) so I can assign it to the document.

For example, I have defined the type "CompanyInfomation" which contains two properties:
1) CompanyName
2) CompanyId.

I will load documents in a drop space, and each document will have inside somewhere in the text "Name of the Company: NAME" and "Id of the Company: Id". I would need to identify those words somehow and extract the value s NAME and ID to assign them to the properties of the document "CompanyName" and "CompanyId".

I am able to assign fixed values using a javascript script, but now would like to get the values from the documents and dont know exactly how to do it.

I have been reading the wiki page about the MetaDataExtractor, but I did not find (maybe I did not searched well even I tried hard!!) how to extract metadata from inside the document, I know how to extract, the author, the creation date of the document…… but nothing from iside.

I have tried this JavaScript… but of course did not work….

Any ideas about how this should be focused????

Thanks a lot in advance guys!!

(JS code  tried to use)

// First we read the document to find the values
var Sociedad ="";
var CIF ="";


var FileContent = document.content;
var FileLines = FileContent.split("\n");
var Lines=0;

var words;
var foundSociedad = False;
var foundtradoCIF = False;

while ((foundSociedad == False) || (foundtradoCIF == False)) && (Lines <= FileLines.length)
{
   var Word_Count=0;
   words = FileLines[Lines].split(" ");
   while ((foundSociedad == False) || (foundtradoCIF == False)) && (Word_Count <= words.length)
   {
      if (words[Word_Count] =="Sociedad:")
      {
        foundSociedad = True;
        Sociedad = words[(Word_Count +1)];
      }
      
      if (words[Word_Count] =="CIF:")
      {
        foundtradoCIF = True;
        CIF = words[(Word_Count +1)];
      }
      Word_Count=Word_Count+1;
   }
   Lines = Lines+1;

}

// Now that we have the values we apply them to the properties of the custom type.

document.properties.name="Doc_"+Sociedad+"_"+CIF;
document.properties["custom:CompanyName"]=Sociedad;
document.properties["custom:CompanyCIF"]=CIF;
document.save();