Package com.dotmarketing.portlets.workflows.model

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


      Logger.error(this, "Could not load files : ", e2);
    }

    Contentlet contentlet;
    WorkflowStep wfStep;
    WorkflowScheme wfScheme = null;

    for (Versionable file : files) {

      if (file == null)
        continue;

      List<Integer> permissions = new ArrayList<Integer>();
      try {
        permissions = permissionAPI.getPermissionIdsFromRoles(
            (Permissionable) file, roles, user);
      } catch (DotDataException e) {
        Logger.error(this, "Could not load permissions : ", e);
      }

      List<WorkflowAction> wfActions = new ArrayList<WorkflowAction>();

      contentlet = null;
      if (file instanceof com.dotmarketing.portlets.fileassets.business.FileAsset)
        contentlet = (Contentlet) file;
      try {
        if (contentlet != null) {
          wfStep = APILocator.getWorkflowAPI().findStepByContentlet(
              contentlet);
          wfScheme = APILocator.getWorkflowAPI().findScheme(
              wfStep.getSchemeId());
          wfActions = APILocator.getWorkflowAPI()
              .findAvailableActions(contentlet, user);
        }
      } catch (Exception e) {
        Logger.error(this, "Could not load workflow actions : ", e);
        // wfActions = new ArrayList();
      }
      boolean contentEditable = false;
      if (contentlet != null) {
        if (perAPI.doesUserHavePermission(contentlet,
            PermissionAPI.PERMISSION_WRITE, user)
            && contentlet.isLocked()) {
          String lockedUserId = APILocator.getVersionableAPI()
              .getLockedBy(contentlet);
          if (user.getUserId().equals(lockedUserId)) {
            contentEditable = true;
          } else {
            contentEditable = false;
          }
        } else {
          contentEditable = false;
        }
      }

      try {
        if (permissions.contains(PERMISSION_READ)) {
          boolean hasPushPublishActionlet = false;
          if (!showArchived && file.isArchived()) {
            continue;
          }
          IFileAsset fileAsset = (IFileAsset) file;
          List<Map<String, Object>> wfActionMapList = new ArrayList<Map<String, Object>>();
          for (WorkflowAction action : wfActions) {
            List<WorkflowActionClass> actionlets = APILocator
                .getWorkflowAPI().findActionClasses(action);
            if (action.requiresCheckout()) {
              continue;
            }
            Map<String, Object> wfActionMap = new HashMap<String, Object>();
            wfActionMap.put("name", action.getName());
            wfActionMap.put("id", action.getId());
            wfActionMap.put("icon", action.getIcon());
            wfActionMap.put("assignable", action.isAssignable());
            wfActionMap.put("commentable", action.isCommentable()
                || UtilMethods.isSet(action.getCondition()));
            wfActionMap.put("requiresCheckout",
                action.requiresCheckout());
            wfActionMap.put("wfActionNameStr",
                LanguageUtil.get(user, action.getName()));
            for (WorkflowActionClass actionlet : actionlets) {
              if (actionlet
                  .getActionlet()
                  .getClass()
                  .getCanonicalName()
                  .equals(PushPublishActionlet.class
                      .getCanonicalName())) {
                hasPushPublishActionlet = true;
              }
            }
            wfActionMap.put("hasPushPublishActionlet",
                hasPushPublishActionlet);
            wfActionMapList.add(wfActionMap);
          }
          if (wfScheme != null && wfScheme.isMandatory()) {
            permissions.remove(new Integer(
                PermissionAPI.PERMISSION_PUBLISH));
          }

          // check for multilingual. we don't need to see the item
          // more than once for every language
          boolean skip = false;
          if (contentlet != null) {
            List<Map<String, Object>> toDelete = new ArrayList<Map<String, Object>>();
            for (Map<String, Object> map : returnList) {
              if (map.get("identifier").equals(
                  contentlet.getIdentifier())) {
                if (contentlet.getLanguageId() != APILocator
                    .getLanguageAPI().getDefaultLanguage()
                    .getId()) {
                  // if this is no for the default lang and
                  // there is another one in the list skip.
                  skip = true;
                } else {
                  // if this is for def lang then delete any
                  // other we find
                  toDelete.add(map);
                }
              }
            }
            returnList.removeAll(toDelete);
          }

          if (skip)
            continue;

          Map<String, Object> fileMap = fileAsset.getMap();

          Identifier ident = APILocator.getIdentifierAPI().find(
              fileAsset.getVersionId());

          fileMap.put("wfMandatoryWorkflow", wfScheme!=null && wfScheme.isMandatory());
          fileMap.put("permissions", permissions);
          fileMap.put("mimeType", APILocator.getFileAPI()
              .getMimeType(fileAsset.getFileName()));
          fileMap.put("name", ident.getAssetName());
          fileMap.put("fileName", ident.getAssetName());
View Full Code Here


              String oldWorkflowId = (String) result.get( "local_inode" );
                String newWorkflowId = (String) result.get( "remote_inode" );

                WorkflowCache workflowCache = CacheLocator.getWorkFlowCache();
                //Verify if the workflow is the default one
                WorkflowScheme defaultScheme = workflowCache.getDefaultScheme();
                if ( defaultScheme != null && defaultScheme.getId().equals( oldWorkflowId ) ) {
                    CacheLocator.getCacheAdministrator().remove( workflowCache.defaultKey, workflowCache.getPrimaryGroup() );
                } else {
                    //Clear the cache
                    WorkflowScheme scheme = workflowCache.getScheme( oldWorkflowId );
                    workflowCache.remove( scheme );
                }

             // THIS IS THE NEW CODE
View Full Code Here

         
        } catch (DotSecurityException e) {
          Logger.error(getClass(), "Couldn't add the Host to the Bundle. Bundle ID: " + config.getId() + ", Host ID: " + asset.getAsset(), e);
        }
      } else if(asset.getType().equals("workflow")) {
        WorkflowScheme scheme = APILocator.getWorkflowAPI().findScheme(asset.getAsset());
       
        if(scheme == null){
          Logger.warn(getClass(), "WorkflowScheme id: "+ (asset.getAsset() != null ? asset.getAsset() : "N/A") +" does NOT have working or live version, not Pushed");
        } else {
          workflows.add(asset.getAsset(),scheme.getModDate());
        }
      }
    }

    setHostDependencies();
View Full Code Here

    Folder f = APILocator.getFolderAPI().find(st.getFolder(), user, false);
    folders.addOrClean(st.getFolder(), f.getModDate()); // add the folder dependency

    try {
      WorkflowScheme scheme = APILocator.getWorkflowAPI().findSchemeForStruct(st);
      workflows.addOrClean(scheme.getId(), scheme.getModDate());
    } catch (DotDataException e) {
      Logger.debug(getClass(), "Could not get the Workflow Scheme Dependency for Structure ID: " + st.getInode());
    }

    // Related structures
View Full Code Here

    @Test
    public void workflowTask() throws  Exception {
        final String salt=Long.toString(System.currentTimeMillis());
               
        // a mandatory scheme to test
        WorkflowScheme scheme = new WorkflowScheme();
        scheme.setMandatory(true);
        scheme.setName("Rest Mandatory Workflow "+salt);
        scheme.setDescription("testing rest save content");
        scheme.setCreationDate(new Date());
        APILocator.getWorkflowAPI().saveScheme(scheme);
       
        WorkflowStep step1=new WorkflowStep();
        step1.setCreationDate(new Date());
        step1.setEnableEscalation(false);
        step1.setMyOrder(1);
        step1.setName("Step 1");
        step1.setResolved(false);
        step1.setSchemeId(scheme.getId());
        APILocator.getWorkflowAPI().saveStep(step1);
       
        WorkflowStep step2=new WorkflowStep();
        step2.setCreationDate(new Date());
        step2.setEnableEscalation(false);
        step2.setMyOrder(2);
        step2.setName("Step 2");
        step2.setResolved(false);
        step2.setSchemeId(scheme.getId());
        APILocator.getWorkflowAPI().saveStep(step2);
       
        WorkflowStep step3=new WorkflowStep();
        step3.setCreationDate(new Date());
        step3.setEnableEscalation(false);
        step3.setMyOrder(3);
        step3.setName("Step 3");
        step3.setResolved(true);
        step3.setSchemeId(scheme.getId());
        APILocator.getWorkflowAPI().saveStep(step3);
       
        // Save as Draft Step1 -> Step1
        WorkflowAction saveDraft=new WorkflowAction();
        saveDraft.setId(UUIDGenerator.generateUuid());
View Full Code Here

      return this.convert(obj, map);
    }
  }

  private WorkflowScheme convertScheme(Map<String, Object> row) throws IllegalAccessException, InvocationTargetException {
    final WorkflowScheme scheme = new WorkflowScheme();
    row.put("entryActionId", row.get("entry_action_id"));
    row.put("defaultScheme", row.get("default_scheme"));
    row.put("modDate", row.get("mod_date"));

    BeanUtils.copyProperties(scheme, row);
View Full Code Here

    proxy.setId(action.getStepId());
    cache.removeActions(proxy);

    // update scheme mod date
    WorkflowStep step = findStep(stepId);
    WorkflowScheme scheme = findScheme(step.getSchemeId());
    saveScheme(scheme);
  }
View Full Code Here

    db.loadResult();

    // update scheme mod date
    WorkflowAction action = findAction(actionId);
    WorkflowStep step = findStep(action.getStepId());
    WorkflowScheme scheme = findScheme(step.getSchemeId());
    saveScheme(scheme);
  }
View Full Code Here

    db.setSQL(sql.DELETE_ACTION_CLASS_BY_ACTION);
    db.addParam(action.getId());

    // update scheme mod date
    WorkflowStep step = findStep(actionId);
    WorkflowScheme scheme = findScheme(step.getSchemeId());
    saveScheme(scheme);
  }
View Full Code Here

    db.addParam(step.getId());
    db.loadResult();
    cache.remove(step);

    // update scheme mod date
    WorkflowScheme scheme = findScheme(schemeId);
    saveScheme(scheme);
  }
View Full Code Here

TOP

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

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.