Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2010 JBoss Inc 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.impl.model;
 
 import java.util.List;
 
 import  javax.persistence.Basic;
 import  javax.persistence.CascadeType;
 import  javax.persistence.Column;
 import  javax.persistence.Embedded;
 import  javax.persistence.Entity;
 import  javax.persistence.EnumType;
 import  javax.persistence.Enumerated;
 import  javax.persistence.GeneratedValue;
 import  javax.persistence.GenerationType;
 import  javax.persistence.Id;
 import  javax.persistence.JoinColumn;
 import  javax.persistence.OneToMany;
 import  javax.persistence.SequenceGenerator;
 import  javax.persistence.Table;
 import  javax.persistence.Version;
 
 import  org.kie.api.task.model.I18NText;
 import  org.kie.api.task.model.PeopleAssignments;
 import  org.kie.api.task.model.TaskData;
 import  org.kie.internal.task.api.model.Deadlines;
 import  org.kie.internal.task.api.model.Delegation;
 import  org.kie.internal.task.api.model.InternalTask;
 import  org.kie.internal.task.api.model.SubTasksStrategy;
 
 @Entity
 @Table(name="Task")
 @SequenceGenerator(name="taskIdSeq", sequenceName="TASK_ID_SEQ", allocationSize=1)
 public class TaskImpl implements InternalTask {
    
WSHT uses a name for the unique identifier, for now we use a generated ID which is also the key, which can be mapped to the name or a unique name field added later.
 
     @Id
     @GeneratedValue(strategy = GenerationType.AUTO, generator="taskIdSeq")
     @Column(name = "id")
     private Long                 id = 0L;
     
     @Version
     @Column(name = "OPTLOCK")
     private int                  version;

    
While WSHT says this is an expression, it always resolves to an integer, so resolve before setting default value is 0.
 
     private int                  priority;
 
     private String name;
     
     private String subject;
     
     private String description;
     
     @OneToMany(cascade = CascadeType.ALL, targetEntity=I18NTextImpl.class)
     @JoinColumn(name = "Task_Names_Id", nullable = true)
     private List<I18NText> names        = Collections.emptyList();
 
     @OneToMany(cascade = CascadeType.ALL, targetEntity=I18NTextImpl.class)
     @JoinColumn(name = "Task_Subjects_Id", nullable = true)
     private List<I18NText> subjects     = Collections.emptyList();
 
     @OneToMany(cascade = CascadeType.ALL, targetEntity=I18NTextImpl.class)
     @JoinColumn(name = "Task_Descriptions_Id", nullable = true)
     private List<I18NText> descriptions = Collections.emptyList();
 
 
     @Embedded
     private PeopleAssignmentsImpl    peopleAssignments;
 
     @Embedded
     private DelegationImpl           delegation;
 
     @Embedded
     private TaskDataImpl             taskData;
    @Embedded
    private DeadlinesImpl            deadlines;
    @Enumerated(EnumType.STRING)
    // Default Behaviour
    private SubTasksStrategy subTaskStrategy = SubTasksStrategy.NoAction;
    
    private String               taskType;
    
    private String               formName;
    
    @Basic
    private Short archived = 0;
    
    public TaskImpl() {
    }
    public void writeExternal(ObjectOutput outthrows IOException {
        out.writeLong );
        out.writeInt );
        out.writeShort );
        if ( != null) {
        	out.writeUTF();
        } else {
        	out.writeUTF("");
        }
        
        if ( != null) {
        	out.writeUTF();
        } else {
        	out.writeUTF("");
        }
        
        if ( != null) {
        	out.writeUTF();
        } else {
        	out.writeUTF("");
        }
               
        if ( != null) {
        	out.writeUTF();
        } else {
        	out.writeUTF("");
        }
               
        if ( != null) {
        	out.writeUTF();
        } else {
        	out.writeUTF("");
        }
        
        
        CollectionUtils.writeI18NTextListout );
        CollectionUtils.writeI18NTextListout );
        CollectionUtils.writeI18NTextListout );
        if ( != null) {
            out.writeBoolean(true);
            out.writeUTF(.toString());
        } else {
            out.writeBoolean(false);
        }
        
        if (  != null ) {
            out.writeBooleantrue );
            .writeExternalout );
        } else {
            out.writeBooleanfalse );
        }
        if (  != null ) {
            out.writeBooleantrue );
            .writeExternalout );
        } else {
            out.writeBooleanfalse );
        }
        if (  != null ) {
            out.writeBooleantrue );
            .writeExternalout );
        } else {
            out.writeBooleanfalse );
        }
        if (  != null ) {
            out.writeBooleantrue );
            .writeExternalout );
        } else {
            out.writeBooleanfalse );
        }
    }
    public void readExternal(ObjectInput inthrows IOException,
                                            ClassNotFoundException {
         = in.readLong();
         = in.readInt();
         = in.readShort();
         = in.readUTF();
         = in.readUTF();
         = in.readUTF();
         = in.readUTF();
         = in.readUTF();
         = CollectionUtils.readI18NTextListin );
         = CollectionUtils.readI18NTextListin );
         = CollectionUtils.readI18NTextListin );
        
        if (in.readBoolean()) {
             = SubTasksStrategy.valueOf(in.readUTF());
        }
        
        if ( in.readBoolean() ) {
             = new PeopleAssignmentsImpl();
            .readExternalin );
        }
        if ( in.readBoolean() ) {
             = new DelegationImpl();
            .readExternalin );
        }
        if ( in.readBoolean() ) {
             = new TaskDataImpl();
            .readExternalin );
        }
        if ( in.readBoolean() ) {
             = new DeadlinesImpl();
            .readExternalin );
        }
    }
    
    public Long getId() {
        return ;
    }
    public void setId(long id) {
        this. = id;
    }
     public Boolean isArchived() {
        if ( == null) {
            return null;
        }
        return ( == 1) ? . : .;
    }
    public void setArchived(Boolean archived) {
        if (archived == null) {
            this. = null;
        } else {
            this. = (archived == true) ? new Short("1") : new Short("0");
        }
    }
    
    public int getVersion() {
        return this.;
    }
    public int getPriority() {
        return ;
    }
    public void setPriority(int priority) {
        this. = priority;
    }
    public List<I18NText> getNames() {
        return ;
    }
    public void setNames(List<I18NText> names) {
        this. = names;
    }
    public List<I18NText> getSubjects() {
        return ;
    }
    public void setSubjects(List<I18NText> subjects) {
        this. = subjects;
    }
    public List<I18NText> getDescriptions() {
        return ;
    }
    public void setDescriptions(List<I18NText> descriptions) {
        this. = descriptions;
    }
    public PeopleAssignments getPeopleAssignments() {
        return ;
    }
    public void setPeopleAssignments(PeopleAssignments peopleAssignments) {
        this. = (PeopleAssignmentsImplpeopleAssignments;
    }
    public Delegation getDelegation() {
        return ;
    }
    public void setDelegation(Delegation delegation) {
        this. = (DelegationImpldelegation;
    }
    public TaskData getTaskData() {
        return ;
    }
    public void setTaskData(TaskData taskData) {
        this. = (TaskDataImpltaskData;
    }
    public Deadlines getDeadlines() {
        return ;
    }
    public void setDeadlines(Deadlines deadlines) {
        this. = (DeadlinesImpldeadlines;
    }
    public String getTaskType() {
        return ;
    }
    public void setTaskType(String taskType) {
        this. = taskType;
    }
    public String getFormName() {
        return ;
    }
    public void setFormName(String formName) {
        this. = formName;
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ;
        result = prime * result + ;
        result = prime * result + .hashCode();
        result = prime * result + (( == null) ? 0 : .hashCode());
        result = prime * result + CollectionUtils.hashCode );
        result = prime * result + CollectionUtils.hashCode );
        result = prime * result + CollectionUtils.hashCode );
        result = prime * result + (( == null) ? 0 : .hashCode());
        result = prime * result + (( == null) ? 0 : .hashCode());
        result = prime * result + (( == null) ? 0 : .hashCode());
        result = prime * result + (( == null) ? 0 : .hashCode());
        return result;
    }
    @Override
    public boolean equals(Object obj) {
        if ( this == obj ) return true;
        if ( obj == null ) return false;
        if ( !(obj instanceof TaskImpl) ) return false;
        TaskImpl other = (TaskImplobj;
        if ( this. != other.version ) {
            return false;
        }
        if ( this. != other.archived ) {
            return false;
        }
        if ( == null) {
            if (other.taskType != nullreturn false;
        } else if (!.equals(other.taskType)) return false;
        if (  == null ) {
            if ( other.deadlines != null ) {
            }
        } else if ( !.equalsother.deadlines ) ) return false;
        if (  == null ) {
            if ( other.delegation != null ) return false;
        } else if ( !.equalsother.delegation ) ) return false;
        if (  == null ) {
            if ( other.peopleAssignments != null ) return false;
        } else if ( !.equalsother.peopleAssignments ) ) return false;
        if (  != other.priority ) return false;
        if (  == null ) {
            if ( other.taskData != null ) return false;
        } else if ( !.equalsother.taskData ) ) return false;
        return ( CollectionUtils.equalsother.descriptions ) && CollectionUtils.equalsother.names )
        && CollectionUtils.equalsother.subjects ));
    }
    public SubTasksStrategy getSubTaskStrategy() {
        return ;
    }
    public void setSubTaskStrategy(SubTasksStrategy subTaskStrategy) {
        this. = subTaskStrategy;
    }
    public String getName() {
        return ;
    }
    public void setName(String name) {
        this. = name;
    }
    public String getSubject() {
        return ;
    }
    public void setSubject(String subject) {
        this. = subject;
    }
    public String getDescription() {
        return ;
    }
    public void setDescription(String description) {
        this. = description;
    }
    
    
New to GrepCode? Check out our FAQ X