Package org.drools.process.core

Examples of org.drools.process.core.Work


    value = (String) work.getParameter("Locale");
    localeText.setText(value == null ? "en-UK" : value.toString());
  }

  private void createReassignmentTab(TabFolder tabFolder) {
    Work work = (Work) getValue();
   
    String notStartedReassign = (String) work.getParameter("NotStartedReassign");
    String notCompletedReassign = (String) work.getParameter("NotCompletedReassign");
   
    if (notStartedReassign != null) {
      String[] reassigns = notStartedReassign.split(COMPONENT_SEPARATOR_ESCAPED);
     
      for (String reassign : reassigns) {
View Full Code Here


            }
        });
  }
 
  private void createNotificationTab(TabFolder tabFolder) {
    Work work = (Work) getValue();
   
    String notStartedNotify = (String) work.getParameter("NotStartedNotify");
    String notCompletedNotify = (String) work.getParameter("NotCompletedNotify");
   
    if (notStartedNotify != null) {
      String[] notifies = notStartedNotify.split(COMPONENT_SEPARATOR_ESCAPED);
     
      for (String notification : notifies) {
View Full Code Here

        });
   
  }

  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("GroupId", groupText.getText());
        work.setParameter("Comment", commentText.getText());
        work.setParameter("Priority", priorityText.getText());
        work.setParameter("Skippable", skippableButton.getSelection() + "");
        String content = contentText.getText();
        work.setParameter("Content", content.trim().length() == 0 ? null : content);
        work.setParameter("CreatedBy", createdByText.getText());
        work.setParameter("Locale", localeText.getText());
       
        // process reassignment
        if (!reassignments.isEmpty()) {
          StringBuffer notStartedReassignments = new StringBuffer();
          StringBuffer notCompletedReassignments = new StringBuffer();
          for (Reassignment reassign : reassignments) {
            if ("not-started".equalsIgnoreCase(reassign.getTypeAsString())) {
              if (notStartedReassignments.length() > 0) {
                notStartedReassignments.append(COMPONENT_SEPARATOR);
              }
              notStartedReassignments.append(reassign.toDataInput());
            } else if ("not-completed".equalsIgnoreCase(reassign.getTypeAsString())) {
              if (notCompletedReassignments.length() > 0) {
                notCompletedReassignments.append(COMPONENT_SEPARATOR);
              }
              notCompletedReassignments.append(reassign.toDataInput());
            }
          }
          if (notStartedReassignments.length() > 0) {
            work.setParameter("NotStartedReassign", notStartedReassignments.toString());
          }
          if (notCompletedReassignments.length() > 0) {
            work.setParameter("NotCompletedReassign", notCompletedReassignments.toString());
          }
        }
       
        // process notifications
        if (!notifications.isEmpty()) {
          StringBuffer notStartedNotifications = new StringBuffer();
          StringBuffer notCompletedNotifications = new StringBuffer();
          for (Notification notification : notifications) {
            if ("not-started".equalsIgnoreCase(notification.getType())) {
              if (notStartedNotifications.length() > 0) {
                notStartedNotifications.append(COMPONENT_SEPARATOR);
              }
              notStartedNotifications.append(notification.toDataInput());
            } else if ("not-completed".equalsIgnoreCase(notification.getType())) {
              if (notCompletedNotifications.length() > 0) {
                notCompletedNotifications.append(COMPONENT_SEPARATOR);
              }
              notCompletedNotifications.append(notification.toDataInput());
            }
          }
          if (notStartedNotifications.length() > 0) {
            work.setParameter("NotStartedNotify", notStartedNotifications.toString());
          }
          if (notCompletedNotifications.length() > 0) {
            work.setParameter("NotCompletedNotify", notCompletedNotifications.toString());
          }
        }
       
       
        work.setParameterDefinitions(((Work) value).getParameterDefinitions());
        return 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

        endNode.setName("EndNode");
        endNode.setId(2);
        process.addNode(endNode);
        WorkItemNode workItemNode = new WorkItemNode();
        workItemNode.setName("WorkItem");
        Work work = new WorkImpl();
        work.setName("MyWork");
        workItemNode.setWork(work);
        process.addNode(workItemNode);
        new ConnectionImpl(
            startNode, Node.CONNECTION_DEFAULT_TYPE,
            workItemNode, Node.CONNECTION_DEFAULT_TYPE
View Full Code Here

                }
                if (workItemNode.getWork() == null) {
                    errors.add(new ProcessValidationErrorImpl(process,
                        "WorkItem node '" + node.getName() + "' [" + node.getId() + "] has no work specified."));
                } else {
                    Work work = workItemNode.getWork();
                    if (work.getName() == null) {
                        errors.add(new ProcessValidationErrorImpl(process,
                            "WorkItem node '" + node.getName() + "' [" + node.getId() + "] has no work name."));
                    }
                }
            } else if (node instanceof ForEachNode) {
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

    private static final long serialVersionUID = 4L;

    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

        getNode().setName(name);
        return this;
    }
   
    public HumanTaskNodeFactory taskName(String taskName) {
      Work work = getHumanTaskNode().getWork();
      if (work == null) {
        work = new WorkImpl();
        getHumanTaskNode().setWork(work);
      }
      work.setParameter("TaskName", taskName);
      return this;
    }
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.