Package org.drools.process.core

Examples of org.drools.process.core.Work


        startNode.setId(1);

        WorkItemNode workItemNode = new WorkItemNode();
        workItemNode.setName( "workItemNode" );
        workItemNode.setId( 2 );
        Work work = new WorkImpl();
        work.setName( workName );
        workItemNode.setWork( work );

        EndNode endNode = new EndNode();
        endNode.setName("EndNode");
        endNode.setId(4);
View Full Code Here


        startNode.setId(1);

        WorkItemNode workItemNode = new WorkItemNode();
        workItemNode.setName( "workItemNode" );
        workItemNode.setId( 2 );
        Work work = new WorkImpl();
        work.setName( workName );
        workItemNode.setWork( work );

        EndNode endNode = new EndNode();
        endNode.setName("EndNode");
        endNode.setId(4);
View Full Code Here

        }
        this.workItemId = workItem.getId();
    }   

    protected WorkItem createWorkItem(WorkItemNode workItemNode) {
        Work work = workItemNode.getWork();
        workItem = new WorkItemImpl();
        ((WorkItem) workItem).setName(work.getName());
        ((WorkItem) workItem).setProcessInstanceId(getProcessInstance().getId());
        ((WorkItem) workItem).setParameters(new HashMap<String, Object>(work.getParameters()));
        for (Iterator<DataAssociation> iterator = workItemNode.getInAssociations().iterator(); iterator.hasNext(); ) {
            DataAssociation association = iterator.next();
            if (association.getAssignments() == null || association.getAssignments().isEmpty()) {
                Object parameterValue = null;
                VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
                resolveContextInstance(VariableScope.VARIABLE_SCOPE, association.getSources().get(0));
                if (variableScopeInstance != null) {
                    parameterValue = variableScopeInstance.getVariable(association.getSources().get(0));
                } else {
                    try {
                        parameterValue = MVEL.eval(association.getSources().get(0), new NodeInstanceResolverFactory(this));
                    } catch (Throwable t) {
                        System.err.println("Could not find variable scope for variable " + association.getSources().get(0));
                        System.err.println("when trying to execute Work Item " + work.getName());
                        System.err.println("Continuing without setting parameter.");
                    }
                }
                if (parameterValue != null) {
                    ((WorkItem) workItem).setParameter(association.getTarget(), parameterValue);
                }
            } else {
                for(Iterator<Assignment> it = association.getAssignments().iterator(); it.hasNext(); ) {
                    handleAssignment(it.next());
                }
            }
        }
       
        for (Map.Entry<String, Object> entry: workItem.getParameters().entrySet()) {
            if (entry.getValue() instanceof String) {
                String s = (String) entry.getValue();
                Map<String, String> replacements = new HashMap<String, String>();
                Matcher matcher = PARAMETER_MATCHER.matcher(s);
                while (matcher.find()) {
                    String paramName = matcher.group(1);
                    if (replacements.get(paramName) == null) {
                        VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
                            resolveContextInstance(VariableScope.VARIABLE_SCOPE, paramName);
                        if (variableScopeInstance != null) {
                            Object variableValue = variableScopeInstance.getVariable(paramName);
                            String variableValueString = variableValue == null ? "" : variableValue.toString();
                            replacements.put(paramName, variableValueString);
                        } else {
                            try {
                                Object variableValue = MVEL.eval(paramName, new NodeInstanceResolverFactory(this));
                                String variableValueString = variableValue == null ? "" : variableValue.toString();
                                replacements.put(paramName, variableValueString);
                            } catch (Throwable t) {
                                System.err.println("Could not find variable scope for variable " + paramName);
                                System.err.println("when trying to replace variable in string for Work Item " + work.getName());
                                System.err.println("Continuing without setting parameter.");
                            }
                        }
                    }
                }
View Full Code Here

    private static final long serialVersionUID = 510l;

    private String swimlane;
   
    public HumanTaskNode() {
        Work work = new WorkImpl();
        work.setName("Human Task");
        Set<ParameterDefinition> parameterDefinitions = new HashSet<ParameterDefinition>();
        parameterDefinitions.add(new ParameterDefinitionImpl("TaskName", new StringDataType()));
        parameterDefinitions.add(new ParameterDefinitionImpl("ActorId", new StringDataType()));
        parameterDefinitions.add(new ParameterDefinitionImpl("Priority", new StringDataType()));
        parameterDefinitions.add(new ParameterDefinitionImpl("Comment", new StringDataType()));
        parameterDefinitions.add(new ParameterDefinitionImpl("Skippable", new StringDataType()));
        parameterDefinitions.add(new ParameterDefinitionImpl("Content", new StringDataType()));
        // TODO: initiator
        // TODO: attachments
        // TODO: deadlines
        // TODO: delegates
        // TODO: recipients
        // TODO: ...
        work.setParameterDefinitions(parameterDefinitions);
        setWork(work);
    }
View Full Code Here

                            actionNode,
                            Node.CONNECTION_DEFAULT_TYPE );
        WorkItemNode workItemNode = new WorkItemNode();
        workItemNode.setId( 3 );
        workItemNode.setName( "WorkItem1" );
        Work work = new WorkImpl();
        work.setName( "MyWork" );
        workItemNode.setWork( work );
        process.addNode( workItemNode );
        new ConnectionImpl( actionNode,
                            Node.CONNECTION_DEFAULT_TYPE,
                            workItemNode,
                            Node.CONNECTION_DEFAULT_TYPE );
        WorkItemNode workItemNode2 = new WorkItemNode();
        workItemNode2.setId( 4 );
        workItemNode2.setName( "WorkItem2" );
        work = new WorkImpl();
        work.setName( "MyWork" );
        workItemNode2.setWork( work );
        process.addNode( workItemNode2 );
        new ConnectionImpl( workItemNode,
                            Node.CONNECTION_DEFAULT_TYPE,
                            workItemNode2,
                            Node.CONNECTION_DEFAULT_TYPE );
        WorkItemNode workItemNode3 = new WorkItemNode();
        workItemNode3.setId( 5 );
        workItemNode3.setName( "WorkItem3" );
        work = new WorkImpl();
        work.setName( "MyWork" );
        workItemNode3.setWork( work );
        process.addNode( workItemNode3 );
        new ConnectionImpl( workItemNode2,
                            Node.CONNECTION_DEFAULT_TYPE,
                            workItemNode3,
View Full Code Here

                            actionNode,
                            Node.CONNECTION_DEFAULT_TYPE );
        WorkItemNode workItemNode = new WorkItemNode();
        workItemNode.setId( 3 );
        workItemNode.setName( "WorkItem1" );
        Work work = new WorkImpl();
        work.setName( "MyWork" );
        workItemNode.setWork( work );
        process.addNode( workItemNode );
        new ConnectionImpl( actionNode,
                            Node.CONNECTION_DEFAULT_TYPE,
                            workItemNode,
View Full Code Here

        startNode.setId(1);

        WorkItemNode workItemNode = new WorkItemNode();
        workItemNode.setName( "workItemNode" );
        workItemNode.setId( 2 );
        Work work = new WorkImpl();
        work.setName( "MyWork" );
        workItemNode.setWork( work );
       
        ActionNode actionNode = new ActionNode();
        actionNode.setName( "Print" );
        DroolsAction action = new DroolsConsequenceAction( "java" , null);
View Full Code Here

        startNode.setName("Start");
        startNode.setId(1);
        WorkItemNode workItemNode = new WorkItemNode();
        workItemNode.setName("workItemNode");
        workItemNode.setId(2);
        Work work = new WorkImpl();
        work.setName(workName);
        workItemNode.setWork(work);
        EndNode endNode = new EndNode();
        endNode.setName("EndNode");
        endNode.setId(4);
        connect(startNode, workItemNode);
View Full Code Here

        startNode.setName("Start");
        startNode.setId(1);
        WorkItemNode workItemNode = new WorkItemNode();
        workItemNode.setName("workItemNode");
        workItemNode.setId(2);
        Work work = new WorkImpl();
        work.setName(workName);
        workItemNode.setWork(work);
        EndNode endNode = new EndNode();
        endNode.setName("EndNode");
        endNode.setId(4);
        connect(startNode, workItemNode);
View Full Code Here

        final GridLayout gridLayout = new GridLayout();
        gridLayout.horizontalSpacing = 2;
        container.setLayout(gridLayout);
        headersTabItem.setControl(container);
       
        Work work = (Work) getValue();
       
        Label nameLabel = new Label(container, SWT.NONE);
        nameLabel.setText("Name: ");
        nameText = new Text(container, SWT.NONE);
        GridData gridData = new GridData();
        gridData.grabExcessHorizontalSpace = true;
        gridData.horizontalAlignment = GridData.FILL;
        nameText.setLayoutData(gridData);
        String name = (String) work.getParameter("TaskName");
        nameText.setText(name == null ? "" : name);
       
    Label label = new Label(container, SWT.NONE);
    label.setText("Actor(s): ");
    actorText = new Text(container, SWT.NONE);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    actorText.setLayoutData(gridData);
    String value = (String) work.getParameter("ActorId");
    actorText.setText(value == null ? "" : value);

    label = new Label(container, SWT.NONE);
    label.setText("Group(s): ");
    groupText = new Text(container, SWT.NONE);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    groupText.setLayoutData(gridData);
    value = (String) work.getParameter("GroupId");
    groupText.setText(value == null ? "" : value);

    label = new Label(container, SWT.NONE);
    label.setText("Comment: ");
    commentText = new Text(container, SWT.MULTI);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    commentText.setLayoutData(gridData);
    value = (String) work.getParameter("Comment");
    commentText.setText(value == null ? "" : value.toString());

    label = new Label(container, SWT.NONE);
    label.setText("Priority: ");
    priorityText = new Text(container, SWT.NONE);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    priorityText.setLayoutData(gridData);
    value = (String) work.getParameter("Priority");
    priorityText.setText(value == null ? "" : value);

    skippableButton = new Button(container, SWT.CHECK | SWT.LEFT);
    skippableButton.setText("Skippable");
    value = (String) work.getParameter("Skippable");
    skippableButton.setSelection("true".equals(value));
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    skippableButton.setLayoutData(gridData);

    label = new Label(container, SWT.NONE);
    label.setText("Content: ");
    contentText = new Text(container, SWT.MULTI);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    contentText.setLayoutData(gridData);
    value = (String) work.getParameter("Content");
    contentText.setText(value == null ? "" : value.toString());
   
    label = new Label(container, SWT.NONE);
    label.setText("Created by: ");
    createdByText = new Text(container, SWT.NONE);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    createdByText.setLayoutData(gridData);
    value = (String) work.getParameter("CreatedBy");
    createdByText.setText(value == null ? "" : value.toString());
   
    label = new Label(container, SWT.NONE);
    label.setText("Locale: ");
    localeText = new Text(container, SWT.NONE);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    localeText.setLayoutData(gridData);
    value = (String) work.getParameter("Locale");
    localeText.setText(value == null ? "en-UK" : value.toString());
  }
View Full Code Here

TOP

Related Classes of org.drools.process.core.Work

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.