AlfrescoIntegration

From RunaWFE
Jump to navigation Jump to search

Using Alfresco ECM

RunaWFE Free Workflow System (BPMS) Version 4.5.0

© 2003 - 2015, Consulting Group Runa

© 2015 - 2024, "Process Technologies" Ltd, this document is available under GNU FDL license. RunaWFE Free is an open source system distributed under a LGPL license (http://www.gnu.org/licenses/lgpl.html).

# Alfresco purpose

Alfresco can be used as content management system:

  • to save documents in folders hierarchy
  • to save documents attributes (meta-data)
  • to support documents versions
  • to search documents by contents and attributes

So Alfresco can be used for business-object storage as data store layer. Alfresco interface supports extensions. It's possible to implement reports using JSF1.1.

# wfe-alfresco project

wfe-alfresco project is a framework that helps to work with Alfresco (it can be found in repository along with other runawfe projects).

Main features:

  • Building Lucene-queries with objects as parameters
  • Converts Alfresco model to Java object model
  • Contains base classes for extension in RunaWFE (handler, orgfunction, tag)

# Alfresco content to Java object mapping

It allows to work with Alfresco objects (content) via Java objects.

# Alfresco API

In order to interact with Alfresco it's possible to use Java API and WebServices API. There are 2 implementations of AlfConn interface: LocalAlfConnection (for Java API) и RemoteAlfConnection (for WebServices API).

LocalAlfConnection can be used only in the JVM where Alfresco runs.

RemoteAlfConnection can be used both locally and remotely. It is used on WFE Server side.

# Search

Search in Alfresco is done with the help of Lucene query and AlfConn connector.

ru.runa.alfresco.search package contains classes that are used to build query dinamically. This query can be later converted to Lucene query.

Search class is a root container of the search query and it contains filter and sorting conditions. It also allows to limit search result objects number. Note. Sorting doesn't work via WebServices API.

Group class is container for a list of child elements (groups or expressions) with an operand for them (AND, OR, NOT).

Operand is a set of operations that can be converted to Lucene query.

Expression Expr consists of operand and parameters that operand requires.

# Creating new type on AlfObject basis

Type correspondence is determined by annotations Type, Property, Assoc.

Every Java type, that corresponds to Alfresco content must extend AlfObject.

The following conditions must be present:

  • a public constructor without parameters
  • for node reference property myProperty methods getMyProperty and setMyProperty
    • type of myProperty must implement IAlfObject interface
    • when getMyProperty is called first cache is checked and then (if myProperty not in cache) a call to Alfresco by object UUID is made
@Property(name = "ewtEmployee")
private Employee employee;
public Employee getEmployee() {
 return employee;
}
public void setEmployee(Employee employee) {
 this.employee = employee;
}
  • for association myAssoc a method getMyAssoc must be used
    • when getMyAssoc is called if collection is not filled a call to Alfresco is made to retrieve association
@Assoc(name = "ewtTimingRecords")
private final Set<TimingRecord> timingRecords = Sets.newHashSet();
public Set<TimingRecord> getTimingRecords() {
 return timingRecords;
}
  • for properties (multiple=true in Alfresco) in Java java.util.ArrayList or array is used. Arrays are not modifiable.
@Property(name="ewtInOuts")
private ArrayList<String> inOuts;

Note. When data is retrieved a proxy-object (for the given type) is created.

# Helper classes in RunaWFE

A set of basic implementation of handler, orgfunction, validator, tag in RunaWFE override similar methods and adds an additional argument to them (AlfSession) which is used to interact with Alfresco.

# Configuration

Configuration file alfwf.settings.xml is used to configure different elements of the system. Different parts of the file are used for different system elements.

For example alf/connection part is used in WSConnectionSettings, while alf/imports part, alf/mappings part are used in Mappings. It's convenient to extend Settings and add new parts to XML file because all configurations are kept in one place.

# Example

Description

On demo site there's an example process approve my doc.

The process allows to approve or decline a document that is stored in Alfresco.

For this process (here is the code) that is used:

  • in Alfresco a data model is defined,
  • in RunaWFE MyDoc class is defined, it corresponds to new document type
  • in RunaWFE handlers for Alfresco interactions are defined: they create, confirm, decline document
  • in RunaWFE a tag is defined that displays document status in task forms

Installation and configuration

Note. The version of Alfresco that is used is AlfrescoLabs 3.0 Final

Note. Project wfe-alfresco is not included in distributive. Add it to project while building with the help of maven.

  • Place in ${Alfresco}/tomcat/shared/classes/alfresco/extension files
    • demo-context.xml Spring context extension
    • demoModel.xml custom content model
    • web-client-config-custom.xml extension to view properties in Alfresco interface
  • While Alfresco is running create a folder where created documents are placed and place its UUID (for example 92253b54-41c5-4873-bfd4-ba8270cba38c) in alfwf.settings.xml instead of one that is there already
  • copy alfwf.settings.xml to RunaWFE extensions folder
  • copy wfe.custom.ftl.form.tags.xml to RunaWFE extensions folder
  • Start RunaWFE and deploy approve my doc.par to the system

File:AlfrescoDemo.zip