Package org.drools.process.core

Examples of org.drools.process.core.Work


    }
   
    public void setNode(Node node) {
        super.setNode(node);
        if (this.workDefinition != null) {
            Work work = getWorkItemNode().getWork();
            if (work == null) {
                work = new WorkImpl();
                work.setName(workDefinition.getName());
                getWorkItemNode().setWork(work);
            }
            work.setParameterDefinitions(workDefinition.getParameters());
        }
    }
View Full Code Here


        }
    }
   
    public void setWorkDefinition(WorkDefinition workDefinition) {
        this.workDefinition = workDefinition;
        Work work = getWorkItemNode().getWork();
        if (work == null) {
            work = new WorkImpl();
            work.setName(workDefinition.getName());
            getWorkItemNode().setWork(work);
        }
        work.setParameterDefinitions(workDefinition.getParameters());
    }
View Full Code Here

            return new TimerWrapper();
        } else if (node instanceof HumanTaskNode) {
            return new HumanTaskNodeWrapper();
        } else if (node instanceof WorkItemNode) {
            WorkItemWrapper workItemWrapper = new WorkItemWrapper();
            Work work = ((WorkItemNode) node).getWork();
            if (work != null && work.getName() != null) {
                try {
                    WorkDefinition workDefinition =
                        WorkItemDefinitions.getWorkDefinitions(project)
                            .get(work.getName());
                    if (workDefinition == null) {
    //                    DroolsEclipsePlugin.log(
    //                        new IllegalArgumentException("Could not find work definition for work " + work.getName()));
                        workDefinition = new WorkDefinitionImpl();
                        ((WorkDefinitionImpl) workDefinition).setName(work.getName());
                    }
                    workItemWrapper.setWorkDefinition(workDefinition);
                } catch (Throwable t) {
                    // an error might be thrown when parsing the work definitions,
                    // but this should already be displayed to the user
View Full Code Here

        Composite composite = (Composite) super.createDialogArea(parent);
        GridLayout gridLayout = new GridLayout();
        gridLayout.numColumns = 2;
        composite.setLayout(gridLayout);
       
        Work work = (Work) getValue();
       
        Label nameLabel = new Label(composite, SWT.NONE);
        nameLabel.setText("Name: ");
        nameText = new Text(composite, 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(composite, SWT.NONE);
        label.setText("Actor(s): ");
        actorText = new Text(composite, 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(composite, SWT.NONE);
        label.setText("Comment: ");
        commentText = new Text(composite, 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(composite, SWT.NONE);
        label.setText("Priority: ");
        priorityText = new Text(composite, 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(composite, 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(composite, SWT.NONE);
        label.setText("Content: ");
        contentText = new Text(composite, 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());
       
        return composite;
    }
View Full Code Here

       
        return composite;
    }
   
    protected Work updateValue(Work value) {
        Work work = new WorkImpl();
        work.setName("Human Task");
        work.setParameter("TaskName", nameText.getText());
        work.setParameter("ActorId", actorText.getText());
        work.setParameter("Comment", commentText.getText());
        work.setParameter("Priority", priorityText.getText());
        work.setParameter("Skippable", skippableButton.getSelection() + "");
        work.setParameter("Content", contentText.getText());
        work.setParameterDefinitions(((Work) value).getParameterDefinitions());
        return work;
    }
View Full Code Here

    }
   
    public void setNode(Node node) {
        super.setNode(node);
        if (this.workDefinition != null) {
            Work work = getWorkItemNode().getWork();
            if (work == null) {
                work = new WorkImpl();
                work.setName(workDefinition.getName());
                getWorkItemNode().setWork(work);
            }
            work.setParameterDefinitions(workDefinition.getParameters());
        }
    }
View Full Code Here

        }
    }
   
    public void setWorkDefinition(WorkDefinition workDefinition) {
        this.workDefinition = workDefinition;
        Work work = getWorkItemNode().getWork();
        if (work == null) {
            work = new WorkImpl();
            work.setName(workDefinition.getName());
            getWorkItemNode().setWork(work);
        }
        work.setParameterDefinitions(workDefinition.getParameters());
    }
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<Map.Entry<String, String>> iterator = workItemNode.getInMappings().entrySet().iterator(); iterator.hasNext(); ) {
            Map.Entry<String, String> mapping = iterator.next();
            Object parameterValue = null;
            VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
                resolveContextInstance(VariableScope.VARIABLE_SCOPE, mapping.getValue());
            if (variableScopeInstance != null) {
              parameterValue = variableScopeInstance.getVariable(mapping.getValue());
            } else {
              try {
                parameterValue = MVEL.eval(mapping.getValue(), new NodeInstanceResolverFactory(this));
              } catch (Throwable t) {
                  System.err.println("Could not find variable scope for variable " + mapping.getValue());
                  System.err.println("when trying to execute Work Item " + work.getName());
                  System.err.println("Continuing without setting parameter.");
              }
            }
            if (parameterValue != null) {
              ((WorkItem) workItem).setParameter(mapping.getKey(), parameterValue);
            }
        }
        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

          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<Map.Entry<String, String>> iterator = workItemNode.getInMappings().entrySet().iterator(); iterator.hasNext(); ) {
            Map.Entry<String, String> mapping = iterator.next();
            Object parameterValue = null;
            VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
                resolveContextInstance(VariableScope.VARIABLE_SCOPE, mapping.getValue());
            if (variableScopeInstance != null) {
              parameterValue = variableScopeInstance.getVariable(mapping.getValue());
            } else {
              try {
                parameterValue = MVEL.eval(mapping.getValue(), new NodeInstanceResolverFactory(this));
              } catch (Throwable t) {
                  System.err.println("Could not find variable scope for variable " + mapping.getValue());
                  System.err.println("when trying to execute Work Item " + work.getName());
                  System.err.println("Continuing without setting parameter.");
              }
            }
            if (parameterValue != null) {
              ((WorkItem) workItem).setParameter(mapping.getKey(), parameterValue);
            }
        }
        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

                            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

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.