Package org.activiti.workflow.simple.alfresco.conversion.script

Examples of org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference


    // Check if model contains an aspect for the property
    String propertyName = getPropertyName(definition, conversion);

    // Add property-reference to the context to be validated
    PropertyReference reference = new PropertyReference(definition.getName());
    AlfrescoConversionUtil.getPropertyReferences(conversion).add(reference);

    // Add aspect to content-type
    contentType.getMandatoryAspects().add(propertyName);
View Full Code Here


    reviewTask.setForm(finalForm);
   
   
    // Assignment
    if(stepDefinition.getAssignmentType() == HumanStepAssignmentType.USER) {
      reviewTask.setAssignee(new PropertyReference(stepDefinition.getAssignmentPropertyName()).getPlaceholder());
    }
   
    // Add a script-task that initializes the correct variables for the review
    ScriptServiceTaskBuilder builder = new ScriptServiceTaskBuilder();
    builder.setExecutionVariable(getCountVariableName(id, namespacePrefix), "0");
   
    String requiredCount = null;
    if(stepDefinition.getRequiredApprovalCount() != null) {
      if(PropertyReference.isPropertyReference(stepDefinition.getRequiredApprovalCount())) {
        PropertyReference reference = PropertyReference.createReference(stepDefinition.getRequiredApprovalCount());
        requiredCount = reference.getVariableReference(namespacePrefix);
        AlfrescoConversionUtil.getPropertyReferences(conversion).add(reference);
      } else {
        // No reference, use explicit value
        requiredCount = stepDefinition.getRequiredApprovalCount();
      }
    } else {
      requiredCount = "1";
    }
    builder.setExecutionVariable(getRequiredCountVariableName(id, namespacePrefix), requiredCount);
   
    ServiceTask serviceTask = builder.build();
    serviceTask.setName("Review initialization");
    serviceTask.setId(conversion.getUniqueNumberedId(ConversionConstants.SERVICE_TASK_ID_PREFIX));
   
    addFlowElement(conversion, serviceTask, true);

    // Create the actual element
    UserTask userTask = (UserTask) conversion.getConversionFactory().getStepConverterFor(reviewTask)
        .convertStepDefinition(reviewTask, conversion);
    lastElement = userTask;
   

    M2Type userTaskType = model.getType(userTask.getFormKey());
   
    // Update parent, since we use an "outcome" for this task
    userTaskType.setParentName(AlfrescoConversionConstants.OUTCOME_BASE_FORM_TYPE);
   
    // Add script to the complete-task listener to update approval count (if needed)
    ScriptTaskListenerBuilder listenerBuilder = AlfrescoConversionUtil.getScriptTaskListenerBuilder(conversion, userTask.getId(), AlfrescoConversionConstants.TASK_LISTENER_EVENT_COMPLETE);
    String approverCount = getCountVariableName(id, namespacePrefix);
    listenerBuilder.addLine("if(task.getVariableLocal('" + getTransitionProperty(userTaskType, namespacePrefix) + "') == '" + AlfrescoConversionConstants.TRANSITION_APPROVE +"') {");
    listenerBuilder.addLine("execution.setVariable('" +approverCount + "', " + approverCount + " + 1);");
    listenerBuilder.addLine("}");
   
    if(stepDefinition.getAssignmentType() == HumanStepAssignmentType.USERS) {
      String assignmentVariableName = id + "Assignee";
     
      // Add the assignee-property to the content-model
      M2ClassAssociation reviewAssignee = new M2ClassAssociation();
      M2AssociationTarget target = new M2AssociationTarget();
      target.setClassName(AlfrescoConversionConstants.CONTENT_TYPE_PEOPLE);
      target.setMandatory(true);
      target.setMany(false);
     
      M2AssociationSource source = new M2AssociationSource();
      source.setMany(false);
      source.setMandatory(true);
     
      reviewAssignee.setName(AlfrescoConversionUtil.getQualifiedName(namespacePrefix, assignmentVariableName));
      reviewAssignee.setTarget(target);
      reviewAssignee.setSource(source);
     
      userTaskType.getAssociations().add(reviewAssignee);
      userTask.setAssignee(new PropertyReference(assignmentVariableName).getUsernameReferenceExpression(namespacePrefix));
     
      // Finally, add the multi-instance characteristics to the userTask
      MultiInstanceLoopCharacteristics mi = new MultiInstanceLoopCharacteristics();
      mi.setCompletionCondition(getCompletionCondition(id, namespacePrefix));
      mi.setElementVariable(new PropertyReference(assignmentVariableName).getVariableReference(namespacePrefix));
     
      PropertyReference reference = null;
      if(PropertyReference.isPropertyReference(stepDefinition.getAssignmentPropertyName())) {
        reference = PropertyReference.createReference(stepDefinition.getAssignmentPropertyName());
      } else {
        reference = new PropertyReference(stepDefinition.getAssignmentPropertyName());
      }
      mi.setInputDataItem(reference.getVariableReference(namespacePrefix));
      AlfrescoConversionUtil.getPropertyReferences(conversion).add(reference);
      mi.setSequential(false);
      userTask.setLoopCharacteristics(mi);
    }
View Full Code Here

    }
    return lastElement;
  }
 
  protected String getTransitionProperty(M2Type type, String namespacePrefix) {
    return new PropertyReference(AlfrescoConversionUtil.getValidIdString(type.getName() + AlfrescoConversionConstants.PROPERTY_TRANSITIONS_SUFFIX)).getVariableReference(namespacePrefix);
  }
View Full Code Here

  protected String getCompletionCondition(String id, String namespacePrefix) {
    return "${" + getCountVariableName(id, namespacePrefix) + " >= " + getRequiredCountVariableName(id, namespacePrefix) + "}";
  }

  protected String getCountVariableName(String id, String namespacePrefix) {
    return new PropertyReference(id + "ApprovalCount").getVariableReference(namespacePrefix);
  }
View Full Code Here

  protected String getCountVariableName(String id, String namespacePrefix) {
    return new PropertyReference(id + "ApprovalCount").getVariableReference(namespacePrefix);
  }
 
  protected String getRequiredCountVariableName(String id, String namespacePrefix) {
    return new PropertyReference(id + "RequiredApprovalCount").getVariableReference(namespacePrefix);
  }
View Full Code Here

    // is created
    if (humanStep.getAssignmentType() == HumanStepAssignmentType.USER) {
      String assignee = humanStep.getAssignment().getAssignee();

      if (assignee != null && PropertyReference.isPropertyReference(assignee)) {
        PropertyReference reference = PropertyReference.createReference(assignee);
        AlfrescoConversionUtil.getPropertyReferences(conversion).add(reference);
        userTask.setAssignee(reference.getUsernameReferenceExpression(modelNamespace.getPrefix()));
      }
    } else if (humanStep.getAssignmentType() == HumanStepAssignmentType.USERS) {
      if(humanStep.getAssignment().getCandidateUsers() != null) {
        userTask.setCandidateUsers(resolveUserPropertyReferences(humanStep.getAssignment().getCandidateUsers(), modelNamespace.getPrefix(), conversion));
      }
View Full Code Here

  }

  protected List<String> resolveUserPropertyReferences(List<String> list, String namespacePrefix, WorkflowDefinitionConversion conversion) {
    if(list != null) {
      List<String> result = new ArrayList<String>();
      PropertyReference propertyReference = null;
      for(String string : list) {
        if(PropertyReference.isPropertyReference(string)) {
          propertyReference = PropertyReference.createReference(string);
          result.add(propertyReference.getUsernameReferenceExpression(namespacePrefix));
         
          // Add reference to be validated
          AlfrescoConversionUtil.getPropertyReferences(conversion).add(propertyReference);
        } else {
          result.add(string);
View Full Code Here

  }
 
  protected List<String> resolveGroupPropertyReferences(List<String> list, String namespacePrefix, WorkflowDefinitionConversion conversion) {
    if(list != null) {
      List<String> result = new ArrayList<String>();
      PropertyReference propertyReference = null;
      for(String string : list) {
        if(PropertyReference.isPropertyReference(string)) {
          propertyReference = PropertyReference.createReference(string);
          result.add(propertyReference.getGroupReferenceExpression(namespacePrefix));
         
          // Add reference to be validated
          AlfrescoConversionUtil.getPropertyReferences(conversion).add(propertyReference);
        } else {
          result.add(string);
View Full Code Here

TOP

Related Classes of org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference

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.