Version Differences for Remoting Specific Scripts

(AHPSCRIPTS-109)
(AHPSCRIPTS-14)
Line 141:
  print("Committing Changes");    print("Committing Changes"); 
  uow.commitAndClose(); </pre>    uow.commitAndClose(); </pre> 
       
    + = Create Workflow Property for Every Workflow Using Given Library Workflow =  
    + Use this script if you want have added a new property to the library workflow and want to add the property to every workflow using it.  
    + ==== AHPSCRIPTS-67 ====  
    + <pre>import com.urbancode.anthill3.main.client.AnthillClient;  
    + import com.urbancode.anthill3.persistence.UnitOfWork;  
    + import com.urbancode.anthill3.domain.workflow.*;  
       
    + String serverHost = "localhost";  
    + int serverPort = 4567;  
    + String userName = "admin";  
    + String password = "admin";  
       
    + // obtain connection to the Anthill server  
    + AnthillClient anthill = AnthillClient.connect(serverHost, serverPort,  
    + userName, password);  
       
    + // create a Unit of Work  
    + UnitOfWork uow = anthill.createUnitOfWork();  
       
    + workflowDef = WorkflowDefinitionFactory.getInstance().restore(150L);  
       
    + propName = "new text property";  
       
    + workflows = WorkflowFactory.getInstance().restoreAll();  
    + for (int w=0; w<workflows.length; w++) {  
    + if (workflowDef.equals(workflows[w].getWorkflowDefinition())) {  
    + // add the property to the workflow  
    + if (workflows[w].hasProperty(propName)) {  
    + System.out.println("Property '" + propName + "' already exists on " +  
    + workflows[w].getProject().getName() + " - " + workflows[w].getName());  
    + } else {  
    + WorkflowProperty prop = new WorkflowProperty(WorkflowPropertyTypeEnum.TEXT);  
    + prop.setName(propName);  
    + prop.setLabel("label text");  
    + prop.setUserMayOverride(true);  
    + prop.setRequired(true);  
    + prop.setValue("default value");  
    + workflows[w].addProperty(prop);  
    + System.out.println("Property '" + propName + "' added on " +  
    + workflows[w].getProject().getName() + " - " + workflows[w].getName());  
    + }  
    + }  
    + }  
       
    + uow.commit();</pre>