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 static org.jbpm.services.task.impl.model.TaskDataImpl.convertToUserImpl;
 
 import java.util.List;
 
 import  javax.persistence.Embeddable;
 import  javax.persistence.JoinColumn;
 import  javax.persistence.JoinTable;
 import  javax.persistence.ManyToMany;
 import  javax.persistence.ManyToOne;
 
 import  org.kie.api.task.model.Group;
 import  org.kie.api.task.model.OrganizationalEntity;
 import  org.kie.api.task.model.User;
 import  org.kie.internal.task.api.model.InternalPeopleAssignments;
 
 @Embeddable
 public class PeopleAssignmentsImpl implements InternalPeopleAssignments {
 	
     @ManyToOne()
     private UserImpl                       taskInitiator;
 
     @ManyToMany(targetEntity=OrganizationalEntityImpl.class)
     @JoinTable(name = "PeopleAssignments_PotOwners", joinColumns = @JoinColumn(name = "task_id"), inverseJoinColumns = @JoinColumn(name = "entity_id"))
     private List<OrganizationalEntity> potentialOwners        = Collections.emptyList();
 
     @ManyToMany(targetEntity=OrganizationalEntityImpl.class)
     @JoinTable(name = "PeopleAssignments_ExclOwners", joinColumns = @JoinColumn(name = "task_id"), inverseJoinColumns = @JoinColumn(name = "entity_id"))
     private List<OrganizationalEntity> excludedOwners         = Collections.emptyList();
 
     @ManyToMany(targetEntity=OrganizationalEntityImpl.class)
     @JoinTable(name = "PeopleAssignments_Stakeholders", joinColumns = @JoinColumn(name = "task_id"), inverseJoinColumns = @JoinColumn(name = "entity_id"))
     private List<OrganizationalEntity> taskStakeholders       = Collections.emptyList();
 
     @ManyToMany(targetEntity=OrganizationalEntityImpl.class)
     @JoinTable(name = "PeopleAssignments_BAs", joinColumns = @JoinColumn(name = "task_id"), inverseJoinColumns = @JoinColumn(name = "entity_id"))
     private List<OrganizationalEntity> businessAdministrators = Collections.emptyList();
 
     @ManyToMany(targetEntity=OrganizationalEntityImpl.class)
     @JoinTable(name = "PeopleAssignments_Recipients", joinColumns = @JoinColumn(name = "task_id"), inverseJoinColumns = @JoinColumn(name = "entity_id"))
     private List<OrganizationalEntity> recipients             = Collections.emptyList();
 
     public PeopleAssignmentsImpl() {
 
     }
 
     public void writeExternal(ObjectOutput outthrows IOException {
         if (  != null ) {
             out.writeBooleantrue );
             .writeExternalout );
         } else {
             out.writeBooleanfalse );
         }
         CollectionUtils.writeOrganizationalEntityList,
                                                        out );
         CollectionUtils.writeOrganizationalEntityList,
                                                        out );
         CollectionUtils.writeOrganizationalEntityList,
                                                        out );
         CollectionUtils.writeOrganizationalEntityList,
                                                        out );
         CollectionUtils.writeOrganizationalEntityList,
                                                        out );
     }
 
     public void readExternal(ObjectInput inthrows IOException,
                                             ClassNotFoundException {
         if ( in.readBoolean() ) {
              = new UserImpl();
             .readExternalin );
         }
          = CollectionUtils.readOrganizationalEntityListin );
          = CollectionUtils.readOrganizationalEntityListin );
          = CollectionUtils.readOrganizationalEntityListin );
          = CollectionUtils.readOrganizationalEntityListin );
         = CollectionUtils.readOrganizationalEntityListin );
    }
    public User getTaskInitiator() {
        return ;
    }
    public void setTaskInitiator(User taskInitiator) {
        this. =  convertToUserImpl(taskInitiator);
    }
    public List<OrganizationalEntity> getPotentialOwners() {
        return ;
    }
    public void setPotentialOwners(List<OrganizationalEntity> potentialOwners) {
        this. = convertToPersistentOrganizationalEntity(potentialOwners);
    }
    public List<OrganizationalEntity> getExcludedOwners() {
        return ;
    }
    public void setExcludedOwners(List<OrganizationalEntity> excludedOwners) {
        this. = convertToPersistentOrganizationalEntity(excludedOwners);
    }
    public List<OrganizationalEntity> getTaskStakeholders() {
        return ;
    }
    public void setTaskStakeholders(List<OrganizationalEntity> taskStakeholders) {
        this. = convertToPersistentOrganizationalEntity(taskStakeholders);
    }
    public List<OrganizationalEntity> getBusinessAdministrators() {
        return ;
    }
    public void setBusinessAdministrators(List<OrganizationalEntity> businessAdministrators) {
        this. = convertToPersistentOrganizationalEntity(businessAdministrators);
    }
    public List<OrganizationalEntity> getRecipients() {
        return ;
    }
    public void setRecipients(List<OrganizationalEntity> recipients) {
        this. = convertToPersistentOrganizationalEntity(recipients);
    }
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + CollectionUtils.hashCode );
        result = prime * result + CollectionUtils.hashCode );
        result = prime * result + (( == null) ? 0 : CollectionUtils.hashCode ));
        result = prime * result + CollectionUtils.hashCode );
        result = prime * result + (( == null) ? 0 : .hashCode());
        result = prime * result + CollectionUtils.hashCode );
        return result;
    }
    @Override
    public boolean equals(Object obj) {
        if ( this == obj ) return true;
        if ( obj == null ) return false;
        if ( !(obj instanceof PeopleAssignmentsImpl) ) return false;
        PeopleAssignmentsImpl other = (PeopleAssignmentsImplobj;
        if (  == null ) {
            if ( other.taskInitiator != null ) return false;
        } else if ( !.equalsother.taskInitiator ) ) return false;
        return CollectionUtils.equals,
                                       other.businessAdministrators ) && CollectionUtils.equals,
                                                                                                 other.excludedOwners ) && CollectionUtils.equals,
                                                                                                                                                   other.potentialOwners ) && CollectionUtils.equals,
                                                                                                                                                                                                      other.recipients )
               && CollectionUtils.equals,
                                          other.taskStakeholders );
    }
    static List<OrganizationalEntity> convertToPersistentOrganizationalEntity(List<OrganizationalEntity> orgEntList) { 
        List<OrganizationalEntity> persistentOrgEnts = orgEntList;
        ifpersistentOrgEnts != null && ! persistentOrgEnts.isEmpty() ) {
            persistentOrgEnts = new ArrayList<OrganizationalEntity>(orgEntList.size());
            for( OrganizationalEntity orgEnt : orgEntList ) { 
                iforgEnt instanceof UserImpl || orgEnt instanceof GroupImpl ) {
                    persistentOrgEnts.add(orgEnt);
                } else iforgEnt instanceof User ) { 
                    persistentOrgEnts.add(new UserImpl(orgEnt.getId())); 
                } else iforgEnt instanceof Group ) { 
                    persistentOrgEnts.add(new GroupImpl(orgEnt.getId())); 
                } else { 
                    throw new IllegalStateException("Unknown user or group object: " + orgEnt.getClass().getName() );
                }
            }
        } 
        return persistentOrgEnts;
    }
New to GrepCode? Check out our FAQ X