Package com.dotmarketing.portlets.workflows.model

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


   */
  public static void createWorkFlowTask(Contentlet contentlet, String userId, String moderatorRole) throws DotDataException{

    User user = getUserFromId(userId);
    StringBuffer changeHist = new StringBuffer("Task Added<br>");
    WorkflowTask task = new WorkflowTask();

    changeHist.append("Title: " + UtilHTML.escapeHTMLSpecialChars(contentlet.getTitle()) + "<br>");
    task.setTitle("A new content titled: " + UtilHTML.escapeHTMLSpecialChars(contentlet.getTitle())+ " has been posted.");
    task.setDescription("A new content titled \"" + UtilHTML.escapeHTMLSpecialChars(contentlet.getTitle().trim()) +
        "\" has been posted by " + UtilHTML.escapeHTMLSpecialChars(user.getFullName()) + " ("+user.getEmailAddress()+")");
    changeHist.append("Description: " + UtilHTML.escapeHTMLSpecialChars(task.getDescription()) + "<br>");

    Role role = roleAPI.loadRoleByKey(moderatorRole);
    task.setBelongsTo(role.getId());
    task.setAssignedTo("Nobody");
    task.setModDate(new Date());
    task.setCreationDate(new Date());
    task.setCreatedBy(user.getUserId());

    task.setStatus(WorkflowStatuses.OPEN.toString());
    changeHist.append("Due Date: " + UtilMethods.dateToHTMLDate(task.getDueDate()) + " -> <br>");
    task.setDueDate(null);
    task.setWebasset(contentlet.getInode());

    //HibernateUtil.saveOrUpdate(task);

    //Save the work flow comment
    WorkflowComment taskComment = new WorkflowComment ();
    taskComment.setComment(task.getDescription());
    taskComment.setCreationDate(new Date());
    taskComment.setPostedBy(user.getUserId());
    HibernateUtil.saveOrUpdate(taskComment);
    relAPI.addRelationship(task.getInode(), taskComment.getInode(), "child");

    //Save the work flow history
    WorkflowHistory hist = new WorkflowHistory ();
    hist.setChangeDescription("Task Creation");
    hist.setCreationDate(new Date ());
    hist.setMadeBy(user.getUserId());
    HibernateUtil.saveOrUpdate(hist);
    relAPI.addRelationship(task.getInode(), hist.getInode(), "child");

    //WorkflowEmailUtil.sendWorkflowChangeEmails (task, "New user content has been submitted", "New Task", null);


  }
View Full Code Here


   */
  public static void createWorkFlowTask(Contentlet contentlet, String userId, String moderatorRoleId) throws DotDataException{

    User user = getUserFromId(userId);
    StringBuffer changeHist = new StringBuffer("Task Added<br>");
    WorkflowTask task = new WorkflowTask();

    changeHist.append("Title: " + UtilHTML.escapeHTMLSpecialChars(contentlet.getTitle()) + "<br>");
    task.setTitle("A new content titled: " + UtilHTML.escapeHTMLSpecialChars(contentlet.getTitle())+ " has been posted.");
    task.setDescription("A new content titled \"" + UtilHTML.escapeHTMLSpecialChars(contentlet.getTitle().trim()) +
        "\" has been posted by " + UtilHTML.escapeHTMLSpecialChars(user.getFullName()) + " ("+user.getEmailAddress()+")");
    changeHist.append("Description: " + UtilHTML.escapeHTMLSpecialChars(task.getDescription()) + "<br>");

    Role role = APILocator.getRoleAPI().loadRoleById(moderatorRoleId);
    task.setBelongsTo(role.getId());
    task.setAssignedTo("Nobody");
    task.setModDate(new Date());
    task.setCreationDate(new Date());
   
    task.setStatus(WorkflowStatuses.OPEN.toString());
    changeHist.append("Due Date: " + UtilMethods.dateToHTMLDate(task.getDueDate()) + " -> <br>");
    task.setDueDate(null);
    task.setWebasset(contentlet.getInode());
    //APILocator.getWorkflowAPI().saveWorkflowTask(task);

    //Save the work flow comment
    WorkflowComment taskComment = new WorkflowComment ();
    taskComment.setComment(task.getDescription());
    taskComment.setCreationDate(new Date());
    taskComment.setPostedBy(user.getUserId());
    taskComment.setWorkflowtaskId(task.getId());
    APILocator.getWorkflowAPI().saveComment(taskComment);

    //Save the work flow history
    WorkflowHistory hist = new WorkflowHistory ();
    hist.setChangeDescription("Task Creation");
    hist.setCreationDate(new Date ());
    hist.setMadeBy(user.getUserId());
    hist.setWorkflowtaskId(task.getId());
    APILocator.getWorkflowAPI().saveWorkflowHistory(hist);
   
    //WorkflowEmailUtil.sendWorkflowChangeEmails (task, "New user content has been submitted", "New Task", null);       


View Full Code Here

        for (Contentlet con : contentlets) {
            cc.remove(con.getInode());

            // delete workflow task for contentlet
            WorkFlowFactory wff = FactoryLocator.getWorkFlowFactory();
            WorkflowTask wft = wff.findTaskByContentlet(con);
            if ( InodeUtils.isSet(wft.getInode() ) ) {
                wff.deleteWorkflowTask(wft);
            }

           
            if(InodeUtils.isSet(con.getInode())){
View Full Code Here

        APILocator.getVersionableAPI().setWorking(con);
      }

      // https://github.com/dotCMS/dotCMS/issues/5620
      // copy the workflow state
      WorkflowTask task = APILocator.getWorkflowAPI().findTaskByContentlet(contentletToCopy);
      if(task!=null) {
          WorkflowTask newTask=new WorkflowTask();
          BeanUtils.copyProperties(task, newTask);
          newTask.setId(null);
          newTask.setWebasset(resultContentlet.getIdentifier());
          APILocator.getWorkflowAPI().saveWorkflowTask(newTask);

          for(WorkflowComment comment : APILocator.getWorkflowAPI().findWorkFlowComments(task)) {
              WorkflowComment newComment=new WorkflowComment();
              BeanUtils.copyProperties(comment, newComment);
              newComment.setId(null);
              newComment.setWorkflowtaskId(newTask.getId());
              APILocator.getWorkflowAPI().saveComment(newComment);
          }

          for(WorkflowHistory history : APILocator.getWorkflowAPI().findWorkflowHistory(task)) {
              WorkflowHistory newHistory=new WorkflowHistory();
              BeanUtils.copyProperties(history, newHistory);
              newHistory.setId(null);
              newHistory.setWorkflowtaskId(newTask.getId());
              APILocator.getWorkflowAPI().saveWorkflowHistory(newHistory);
          }

          List<IFileAsset> files = APILocator.getWorkflowAPI().findWorkflowTaskFiles(task);
          files.addAll(APILocator.getWorkflowAPI().findWorkflowTaskFilesAsContent(task, APILocator.getUserAPI().getSystemUser()));
View Full Code Here

    // delete tasks referencing it
    db.setSQL("select id from workflow_task where status=?");
    db.addParam(step.getId());
    for(Map<String,Object> res : db.loadObjectResults()) {
        String taskId=(String)res.get("id");
        WorkflowTask task=findWorkFlowTaskById(taskId);
        deleteWorkflowTask(task);
    }
   
    db.setSQL(sql.DELETE_STEP);
    db.addParam(step.getId());
View Full Code Here

    return this.convertListToObjects(db.loadObjectResults(), WorkflowStep.class);

  }

  public WorkflowTask findTaskByContentlet(Contentlet contentlet) throws DotDataException {
    WorkflowTask task = cache.getTask(contentlet);
    if (task == null) {
      final HibernateUtil hu = new HibernateUtil(WorkflowTask.class);
      hu.setQuery("from workflow_task in class com.dotmarketing.portlets.workflows.model.WorkflowTask where webasset = ?");
      hu.setParam(contentlet.getIdentifier());
      task = (WorkflowTask) hu.load();
View Full Code Here

    dc.setMaxRows(searcher.getCount());
    List<Map<String,Object>> results = dc.loadObjectResults();
    List<WorkflowTask> wfTasks = new ArrayList<WorkflowTask>();

    for (Map<String, Object> row : results) {
      WorkflowTask wt = new WorkflowTask();
      wt.setId(row.get("id").toString());
      wt.setCreationDate((Date)row.get("creation_date"));
      wt.setModDate((Date)row.get("mod_date"));
      wt.setDueDate((Date)row.get("due_date"));
      wt.setCreatedBy(row.get("created_by").toString());
      wt.setAssignedTo(row.get("assigned_to").toString());
      wt.setBelongsTo(row.get("belongs_to")!=null?row.get("belongs_to").toString():"");
      wt.setTitle(row.get("title").toString());
      wt.setDescription(row.get("description")!=null?row.get("description").toString():"");
      wt.setStatus(row.get("status").toString());
      wt.setWebasset(row.get("webasset").toString());
      wfTasks.add(wt);
    }

    return wfTasks;
  }
View Full Code Here

        try {
            db.setSQL(sql.SELECT_EXPIRED_TASKS);
            List<Map<String,Object>> results=db.loadResults();
            for (Map<String, Object> map : results) {
                String taskId=(String)map.get("id");
                WorkflowTask task=findWorkFlowTaskById(taskId);
                list.add(task);
            }
        } catch (final Exception e) {
            Logger.error(this, e.getMessage(), e);
        }
View Full Code Here

     
      db.setSQL("select id from workflow_task where webasset = ?");
      db.addParam(ident.getId());
      List<Map<String,Object>> tasksToDelete=db.loadResults();
      for(Map<String,Object> task : tasksToDelete) {
          WorkflowTask wft = APILocator.getWorkflowAPI().findTaskById((String)task.get("id"));
          APILocator.getWorkflowAPI().deleteWorkflowTask(wft);
      }
     
      db.setSQL("delete from " + ident.getAssetType()+ " where identifier = ?");
      db.addParam(ident.getId());
View Full Code Here

            for(com.dotmarketing.portlets.contentlet.business.Contentlet fatCont : fatContentlets){
              contentlets.add(conAPI.convertFatContentletToContentlet(fatCont));
            }
            for (Contentlet cont : contentlets) {
                try {
                  WorkflowTask task = wapi.findTaskByContentlet(cont);
                  User systemUser = userAPI.getSystemUser();
                 
                  if(UtilMethods.isSet(task.getAssignedTo())){
                    // If a task exists for this content, placing a comment and an email to review the content.
                   
              String assignedTo = task.getAssignedTo();
             
              // add the user if assign is a user
              Set<String> recipients = new HashSet<String>();
              User usr=null;
              try {
                  usr=userAPI.loadUserById(task.getAssignedTo(), userAPI.getSystemUser(), false);
                recipients.add(usr.getEmailAddress());
              } catch (Exception e) {

              }

              // add the user if assign is a role
              try {
                List<User> users = roleAPI.findUsersForRole(roleAPI.loadRoleById(assignedTo), false);
                for(User u : users){
                  recipients.add(u.getEmailAddress());
                }
                usr=systemUser;
              } catch (Exception e) {

              }
             
              String[] to = (String[]) recipients.toArray(new String[recipients.size()]);

              WorkflowProcessor processor = new WorkflowProcessor(cont,usr);
                        WorkflowComment comment = new WorkflowComment();
             
              // Commenting on task to review
              comment.setComment(LanguageUtil.get(PublicCompanyFactory.getDefaultCompany(), "Please-review-this-content-comment"));             
              comment.setWorkflowtaskId(task.getId());
              comment.setCreationDate(new Date());
              comment.setPostedBy(systemUser.getUserId());
              wapi.saveComment(comment);
             
              // Sending Email to review the content
View Full Code Here

TOP

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

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.