Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014 JBoss by Red Hat.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.jbpm.services.task.utils;
 
 import java.util.Date;
 import java.util.List;
 import  org.kie.api.task.model.I18NText;
 import  org.kie.api.task.model.OrganizationalEntity;
 import  org.kie.api.task.model.Task;

Author(s):
salaboy
 
 public class TaskFluent {
 
     private TaskImpl task;
     private List<I18NText> names;
     private List<I18NText> descriptions;
     private List<I18NText> subjects;
 
     public TaskFluent() {
         if ( == null) {
              = new TaskImpl();
             .setTaskData(new TaskDataImpl());
              = new PeopleAssignmentsImpl();
             .setPeopleAssignments();
              = new ArrayList<I18NText>();
             .setNames();
              = new ArrayList<I18NText>();
             .setDescriptions();
              = new ArrayList<I18NText>();
             .setSubjects();
         }
     }
 
     public Task getTask() {
         if(((TaskDataImpl).getTaskData()).getCreatedOn() == null){
             ((TaskDataImpl).getTaskData()).setCreatedOn(new Date());
         }
         return ;
     }
 
     public TaskFluent setName(String name) {
         .setName(name);
         return this;
     }
     
     public TaskFluent setDescription(String description) {
         .setDescription(description);
         return this;
     }
     
     public TaskFluent setSubject(String subject) {
         .setSubject(subject);
         return this;
     }
     
     public TaskFluent setWorkItemId(long workItemId){
         ((TaskDataImpl).getTaskData()).setWorkItemId(workItemId);
         return this;
     }
     
     public TaskFluent setWorkItemId(String deploymentId){
         ((TaskDataImpl).getTaskData()).setDeploymentId(deploymentId);
         return this;
     }
     
     public TaskFluent setProcessId(String processId){
         ((TaskDataImpl).getTaskData()).setProcessId(processId);
         return this;
     }
     
     public TaskFluent setProcessInstanceId(long processInstanceId){
         ((TaskDataImpl).getTaskData()).setProcessInstanceId(processInstanceId);
         return this;
     }
     
    public TaskFluent setProcessSessionId(int processSessionId){
        ((TaskDataImpl).getTaskData()).setProcessSessionId(processSessionId);
        return this;
    }
    
    public TaskFluent setParentId(long parentId){
        ((TaskDataImpl).getTaskData()).setParentId(parentId);
        return this;
    }
    
    public TaskFluent setCreatedBy(String userId){
        ((TaskDataImpl).getTaskData()).setCreatedBy(new UserImpl(userId));
        return this;
    }
    
    public TaskFluent setCreatedOn(Date createdOn){
        ((TaskDataImpl).getTaskData()).setCreatedOn(createdOn);
        return this;
    }
    
    public TaskFluent setDueDate(Date dueDate){
        ((TaskDataImpl).getTaskData()).setExpirationTime(dueDate);
        return this;
    }
    
    public TaskFluent addI18NName(String languageString name){
        .getNames().add(new I18NTextImpl(languagename));
        return this;
    }
    
    public TaskFluent addI18NDescription(String languageString description){
        .getDescriptions().add(new I18NTextImpl(languagedescription));
        return this;
    }
    
    public TaskFluent addI18NSubject(String languageString subject){
        .getSubjects().add(new I18NTextImpl(languagesubject));
        return this;
    }
    public TaskFluent setPriority(int priority) {
        .setPriority(priority);
        return this;
    }
    public TaskFluent addPotentialUser(String userId) {
        if(.getPotentialOwners().isEmpty()){
            List<OrganizationalEntity> potentialOwners = new ArrayList<OrganizationalEntity>();
            .setPotentialOwners(potentialOwners);    
        }
        .getPotentialOwners().add(new UserImpl(userId));
        
        return this;
    }
    
    public TaskFluent addPotentialGroup(String groupId) {
        if(.getPotentialOwners().isEmpty()){
            List<OrganizationalEntity> potentialOwners = new ArrayList<OrganizationalEntity>();
            .setPotentialOwners(potentialOwners);    
        }
        .getPotentialOwners().add(new GroupImpl(groupId));
        
        return this;
    }
    
    public TaskFluent setAdminUser(String userId) {
        if(.getBusinessAdministrators().isEmpty()){
            List<OrganizationalEntity> businessAdmins = new ArrayList<OrganizationalEntity>();
            .setBusinessAdministrators(businessAdmins);    
        }
        .getBusinessAdministrators().add(new UserImpl(userId));
        
        return this;
    }
    
     public TaskFluent setAdminGroup(String groupId) {
        if(.getBusinessAdministrators().isEmpty()){
            List<OrganizationalEntity> businessAdmins = new ArrayList<OrganizationalEntity>();
            .setBusinessAdministrators(businessAdmins);    
        }
        .getBusinessAdministrators().add(new GroupImpl(groupId));
        
        return this;
    }
     
    public TaskFluent setFormName(String formName){
        .setFormName(formName);
        return this;
    }
    
    public TaskFluent setDeploymentID(String deploymentId){
        ((TaskDataImpl).getTaskData()).setDeploymentId(deploymentId);
        return this;
    }
New to GrepCode? Check out our FAQ X