cancel
Showing results for 
Search instead for 
Did you mean: 

Override AssignmentHandler

skank
Champ in-the-making
Champ in-the-making
Hello,

I'm trying to implement a new AssignmentHandler, with no success.

    <task-node name="Read">
        <task name="my:read">
            <assignment class="com.workflow.handler.MyAssignmentHandler" />
            <event type="task-create">
                 (…)
            </event>
        </task>
    </task-node>

Here is MyAssignmentHandler :

public class MyAssignmentHandler implements AssignmentHandler {

    public void assign(Assignable assignable, ExecutionContext ec) throws Exception {
        NodeService nodeservice = (NodeService) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "NodeService");

        JBPMNodeList assigneesNode = (JBPMNodeList) ec.getContextInstance().getVariable("bpm_assignees");
        String[] pooledActors = new String[assigneesNode.size()];


        for (int i = 0; i < assigneesNode.size(); i++) {
            Map<QName, Serializable> contextProps = new HashMap<QName, Serializable>();
            contextProps = nodeservice.getProperties(assigneesNode.get(i).getNodeRef());
            pooledActors[i] = (String)contextProps.get(ContentModel.PROP_USERNAME);
        }
        assignable.setPooledActors(pooledActors);
    }
}

I've read in the wiki (http://wiki.alfresco.com/wiki/WorkflowAdministration#Task_assignment) that "The JBoss jBPM Identity Component is not yet plugged into Alfresco User management and thus cannot be used for swimlane and task assignments."

But I've checked the source code of org.alfresco.repo.workflow.jbpm.AlfrescoAssignment and I'm doing quite the same (especially the mapAuthorityToName method) :

    /**
     * Convert Alfresco authority to actor id
     * 
     * @param authority
     * @return  actor id
     */
    private String mapAuthorityToName(ScriptNode authority, boolean allowGroup)
    {
        String name = null;
        QName type = authority.getQNameType();
[b]
        if (dictionaryService.isSubClass(type, ContentModel.TYPE_PERSON))
        {
            name = (String)authority.getProperties().get(ContentModel.PROP_USERNAME);
        }[/b]
        else if (allowGroup && dictionaryService.isSubClass(type, ContentModel.TYPE_AUTHORITY_CONTAINER))
        {
            name = authorityDAO.getAuthorityName(authority.getNodeRef());
        }
        else if (type.equals(ContentModel.TYPE_AUTHORITY))
        {
            name = authorityDAO.getAuthorityName(authority.getNodeRef());
        }
        return name;
    }

This method takes the username of the person and returns it as a string for jBPM. (My "assigneesNode" is also a list of person nodes).

Anybody has an idea ?

Cordially,

Skank
1 REPLY 1

skank
Champ in-the-making
Champ in-the-making
I' ve also tried to put the entire noderef, and just the id, that doesn't works too.