Package com.dotmarketing.portlets.workflows.model

Examples of com.dotmarketing.portlets.workflows.model.WorkflowStep


      }
      return task;
   }
   protected WorkflowStep getStep(Contentlet contentlet){
     
     WorkflowStep step = null;
      try {
        String stepId = (String) cache.get(contentlet.getIdentifier(), STEP_GROUP);
        step = (WorkflowStep) cache.get(stepId, STEP_GROUP);
      } catch (Exception e) {
        Logger.debug(this.getClass(), e.getMessage());
View Full Code Here


      throw new DotDataException(e.getLocalizedMessage());
    }
    List<WorkflowStep> newSteps = new ArrayList<WorkflowStep>();
    order = (order < 0) ? 0 : (order >= steps.size()) ? (steps.size() - 1) : order;
    for (int i = 0; i < steps.size(); i++) {
      WorkflowStep s = steps.get(i);
      if (s.equals(step)) {
        continue;
      }
      newSteps.add(s);
    }
View Full Code Here

    boolean hasLock = user.getUserId().equals(lockedUserId);



    WorkflowStep step= findStepByContentlet(contentlet);


    List<WorkflowAction> unfilteredActions = findActions(step, user);
    if(hasLock || isNew){
      return unfilteredActions;
View Full Code Here

  public void reorderAction(WorkflowAction action, int order) throws DotDataException, AlreadyExistException {




    WorkflowStep step = findStep(action.getStepId());
    List<WorkflowAction> actions = null;
    List<WorkflowAction> newActions = new ArrayList<WorkflowAction>();
    try {
      actions = findActions(step, APILocator.getUserAPI().getSystemUser());
    } catch (Exception e) {
View Full Code Here

  }

  public WorkflowAction findEntryAction(Contentlet contentlet, User userthrows DotDataException, DotSecurityException {

    WorkflowScheme scheme = findSchemeForStruct(contentlet.getStructure());
    WorkflowStep entryStep = null;
    List<WorkflowStep> wfSteps = findSteps(scheme);

    for(WorkflowStep wfStep : wfSteps){
      if(!UtilMethods.isSet(entryStep))
        entryStep = wfStep;
      if(wfStep.getMyOrder() < entryStep.getMyOrder())
        entryStep = wfStep;
    }

    WorkflowAction entryAction = null;
    List<WorkflowAction> wfActions = findActions(entryStep, user);
View Full Code Here

    baseURL = "http://"+req.getServerName()+":"+req.getServerPort()+"/DotAjaxDirector/com.dotmarketing.portlets.workflows.business.TestableWfStepAjax?cmd=add&stepName=Edit&schemeId=" +  ws.getId();
    testUrl = new URL(baseURL);
    IOUtils.toString(testUrl.openStream(),"UTF-8");
    List<WorkflowStep> steps = wapi.findSteps(ws);
    Assert.assertTrue(steps.size()==1);
    WorkflowStep step1 = steps.get(0);

    /*
     * Create scheme step2
     */
    baseURL = "http://"+req.getServerName()+":"+req.getServerPort()+"/DotAjaxDirector/com.dotmarketing.portlets.workflows.business.TestableWfStepAjax?cmd=add&stepName=Publish&schemeId=" +  ws.getId();
    testUrl = new URL(baseURL);
    IOUtils.toString(testUrl.openStream(),"UTF-8");
    steps = wapi.findSteps(ws);
    Assert.assertTrue(steps.size()==2);
    WorkflowStep step2 = steps.get(1);

    /*
     * Add action to scheme step1
     */
    baseURL = "http://"+req.getServerName()+":"+req.getServerPort()+"/DotAjaxDirector/com.dotmarketing.portlets.workflows.business.TestableWfActionAjax?cmd=save&stepId="+step1.getId()+"&schemeId="+UtilMethods.webifyString(ws.getId())+"&actionName=Edit&whoCanUse=";
    baseURL+=role.getId()+",&actionIconSelect=workflowIcon&actionAssignable=true&actionCommentable=true&actionRequiresCheckout=false&actionRoleHierarchyForAssign=false";
    baseURL+="&actionAssignToSelect="+role.getId()+"&actionNextStep="+step2.getId()+"&actionCondition=";
    testUrl = new URL(baseURL);
    IOUtils.toString(testUrl.openStream(),"UTF-8");
    List<WorkflowAction> actions1= wapi.findActions(step1, systemUser);
    Assert.assertTrue(actions1.size()==1);
    WorkflowAction action1 = actions1.get(0);

    /*
     * Add action to scheme step2
     */
    baseURL = "http://"+req.getServerName()+":"+req.getServerPort()+"/DotAjaxDirector/com.dotmarketing.portlets.workflows.business.TestableWfActionAjax?cmd=save&stepId="+step2.getId()+"&schemeId="+UtilMethods.webifyString(ws.getId())+"&actionName=Publish&whoCanUse=";
    baseURL+=role.getId()+",&actionIconSelect=workflowIcon&actionAssignable=true&actionCommentable=true&actionRequiresCheckout=false&actionRoleHierarchyForAssign=false";
    baseURL+="&actionAssignToSelect="+role.getId()+"&actionNextStep="+step2.getId()+"&actionCondition=";

    testUrl = new URL(baseURL);
    IOUtils.toString(testUrl.openStream(),"UTF-8");
    List<WorkflowAction> actions2= wapi.findActions(step2, systemUser);
    Assert.assertTrue(actions2.size()==1);
    WorkflowAction action2 = actions2.get(0);

    /*
     * Create structure and add workflow scheme
     */
    Structure st = StructureCache.getStructureByVelocityVarName("Issue5197Structure");
    if(!UtilMethods.isSet(st) || !UtilMethods.isSet(st.getInode())){
      st = new Structure();
      st.setHost(host.getIdentifier());
      st.setDescription("Testing issue 5197");
      st.setName("Issue5197Structure");
      st.setVelocityVarName("Issue5197Structure");
      st.setStructureType(Structure.STRUCTURE_TYPE_CONTENT);
      st.setFixed(false);
      st.setOwner(systemUser.getUserId());
      st.setExpireDateVar("");
      st.setPublishDateVar("");
      StructureFactory.saveStructure(st);

      Permission p = new Permission();
      p.setInode(st.getPermissionId());
      p.setRoleId(roleAPI.loadCMSAnonymousRole().getId());
      p.setPermission(PermissionAPI.PERMISSION_READ);
      perAPI.save(p, st, systemUser, true);

      p = new Permission();
      p.setInode(st.getPermissionId());
      p.setRoleId(roleAPI.loadCMSAnonymousRole().getId());
      p.setPermission(PermissionAPI.PERMISSION_EDIT);
      perAPI.save(p, st, systemUser, true);

      p = new Permission();
      p.setInode(st.getPermissionId());
      p.setRoleId(roleAPI.loadCMSAnonymousRole().getId());
      p.setPermission(PermissionAPI.PERMISSION_PUBLISH);
      perAPI.save(p, st, systemUser, true)

      Field title = new Field("Title",Field.FieldType.TEXT,Field.DataType.TEXT,st,true,true,true,1,"", "", "", false, false, true);
      title.setVelocityVarName("title");
      FieldFactory.saveField(title);
      FieldsCache.addField(title);
    }
    APILocator.getWorkflowAPI().saveSchemeForStruct(st, ws);
    /*
     * Create test content and set it up in scheme step
     */
    Contentlet contentlet1 = new Contentlet();
    contentlet1.setStructureInode(st.getInode());
    contentlet1.setHost(host.getIdentifier());
    contentlet1.setLanguageId(APILocator.getLanguageAPI().getDefaultLanguage().getId());
    contentlet1.setStringProperty("title", "test5197-1"+UtilMethods.dateToHTMLDate(new Date(), "MM-dd-yyyy-HHmmss"));
    contentlet1.setHost(host.getIdentifier());

    contentlet1 = APILocator.getContentletAPI().checkin(contentlet1, systemUser,false);
    if(perAPI.doesUserHavePermission(contentlet1, PermissionAPI.PERMISSION_PUBLISH, systemUser))
      APILocator.getVersionableAPI().setLive(contentlet1);

    /*
     * Test that delete is not possible for step2
     * while has associated step or content
     */
    contentlet1.setStringProperty("wfActionId", action1.getId());
    contentlet1.setStringProperty("wfActionComments", "step1");
    contentlet1.setStringProperty("wfActionAssign", role.getId());
    wapi.fireWorkflowNoCheckin(contentlet1, systemUser);

    contentlet1.setStringProperty("wfActionId", action2.getId());
    contentlet1.setStringProperty("wfActionComments", "step2");
    contentlet1.setStringProperty("wfActionAssign", role.getId());
    wapi.fireWorkflowNoCheckin(contentlet1, systemUser);

    WorkflowStep  currentStep = wapi.findStepByContentlet(contentlet1);
    Assert.assertTrue(currentStep.getId().equals(step2.getId()));

    /*
     * Validate that step2 could not be deleted
     */
    try{
      wapi.deleteStep(step2);
    }catch(Exception e){
      /*
       * Should enter here with this exception
       * </br> <b> Step : 'Publish' is being referenced by </b> </br></br> Step : 'Edit' ->  Action : 'Edit' </br></br>
       */
    }
    Assert.assertTrue(UtilMethods.isSet(wapi.findStep(step2.getId())));
    /*
     * Validate correct deletion of step1
     */
    wapi.deleteStep(step1);
   
    /*
     * Validate that the step 1 was deleted from the scheme
     */
    steps = wapi.findSteps(ws);
    Assert.assertTrue(steps.size()==1);
    Assert.assertTrue(steps.get(0).getId().equals(step2.getId()));

    /*
     * Validate that step2 could not be deleted
     */
    try{
      wapi.deleteStep(step2);
    }catch(Exception e){
      /*
       * Should enter here with this exception
       * </br> <b> Step : 'Publish' is being referenced by: X Contentlet(s) </br></br>
       */
    }
    currentStep = wapi.findStepByContentlet(contentlet1);
    Assert.assertTrue(currentStep.getId().equals(step2.getId()));
   
    /*
     * Validate that step2 is not deleted
     */
    steps = wapi.findSteps(ws);
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.workflows.model.WorkflowStep

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.