Monday, October 3, 2016

Exporting Documents from Ephesoft to Alfresco via CMIS: Identifying Alfresco Aspects and Properties


Configuring Ephesoft to export documents to Alfresco via CMIS is a fairly straightforward process:
  1. Enable and configure the CMIS export plug-in for your batch class inside Ephesoft
  2. Define your aspect mappings here:  <Ephesoft-Installation-Folder>\SharedFolders\<Batch Class #>\cmis-plugin-mapping\aspects-mapping.properties
  3. Define your Alfresco document type and property mappings here:  <Ephesoft-Installation-Folder>\SharedFolders\<Batch Class #>\cmis-plugin-mapping\DLF-Attribute-mapping.properties
  4. Create a drop location in Alfresco to receive the files, and configure rules or scripts to move the files to their final destination
(Both of the folders above represent the default locations of those properties files, but your environment may be configured differently.)
Ephesoft has this overall process well-documented on their public wiki (http://wiki.ephesoft.com/cmis-export-plugin).  However, when defining your mappings, it can be difficult to determine whether you’re dealing with aspects or properties on the Alfresco side.  You’ll need to look through the content model to know for sure, and this article will tell you how.
                               
If the documents are going to be identified as a custom content type in Alfresco, you’ll need access to the custom content model definition file.  Once you find the custom content model definition file, you can use the steps below to understand how to read it.

If you’re going to simply use Alfresco’s standard content model, the content model configuration file can be found inside the following jar file:  
<Alfresco-Installation-Folder>\tomcat\webapps\alfresco\WEB-INF\lib\alfresco-repository-5.1.jar
(the actual name may differ depending on your Alfresco version)
Copy that jar file to a temporary location, and change its extension from .jar to .zip.  Extract the zip file to a temporary folder, or use a zip reader to navigate through the structure to find the alfresco\model\contentModel.xml file.  Open the contentModel.xml file in an editor and look for the Alfresco aspect/property that you want to populate.  For example, if you want to populate the cm:description field inside Alfresco, search for “cm:description” in the xml file.  It will look something like this:


Work your way up the xml structure from the cm:description line, and you can see that cm:description is a property under the cm:titled aspect.  This means that the mapping to the Description field in Alfresco must be defined in the aspect-mapping.properties file in Ephesoft.  If you’re using CMIS 1.1, you can define that mapping like this:
PartsManuals= P:cm:titled|ManualDescription::cm:description
(Refer to the Ephesoft wiki page for details on how to set up the same mapping for CMIS 1.0.)
In the example above, PartsManuals is the document type in Ephesoft, and ManualDescription is the index field.  With this mapping, Ephesoft will create the dm:titled aspect on the document when it’s exported to Alfresco, then it’ll assign the value from the ManualDescription index field in Ephesoft into cm:description in Alfresco.

You can also combine multiple mappings onto a single line by separating them with a semicolon, like this:
PartsManuals= P:cm:titled|ManualDescription::cm:description;P:cm:auditable|Author::cm:creator
This example (also for CMIS 1.1) executes the same mapping as above, and also adds the cm:auditable aspect, populating the cm:creator value with the Author index field from Ephesoft.

Most well-designed custom content models will use aspects instead of properties, so you’ll rarely have to add anything to the DLF-Attribute-mapping.properties file other than the Alfresco document type.  However, older versions of Alfresco didn’t provide good support for mapping values into aspects, so it may be necessary to use properties instead of aspects in those cases.

For another example, say that you have a custom content model, and you want to populate the hvac:modelNum field in Alfresco with the model number extracted from Ephesoft.  If you search for hvac:modelNum in the content model XML file for your custom content model, it could look something like this:


Work your way back up the xml structure, and you’ll see that hvac:modelNum is a property of the hvac:hvacDocuments type.  This means that the mapping to the hvac:modelNum value in Alfresco must be defined in the DLF-Attribute-mapping.properties file in Ephesoft.  You can define that mapping like this: 
PartsManuals=D:hvac:hvacDocuments
PartsManuals.ModelNumber=hvac:modelNum
 (The syntax for the DLF-Attribute-mapping.properties file is the same for both CMIS 1.0 and 1.1.)

In the example above, the first line states that documents of the PartsManuals type in Ephesoft should be imported into Alfresco as the custom document type hvacDocuments.  The second line says that the ModelNumber index field in Ephesoft should be inserted into the modelNum property of the hvacDocuments document type.

Even if you aren’t importing values into Alfresco properties, the first line is necessary to tell Alfresco what custom document type these imported documents should enter Alfresco as.  If you don’t specify a custom document type, documents will be imported into Alfresco using the standard Alfresco document type.

With the combined aspects and properties mappings described above, you can successfully map a variety of Ephesoft index fields into Alfresco fields via CMIS. 


                                                                                                                                                                                                                                           


No comments:

Post a Comment