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.*;
 import java.util.Date;
 
 import  javax.persistence.Column;
 import  javax.persistence.Entity;
 import  javax.persistence.GeneratedValue;
 import  javax.persistence.GenerationType;
 import  javax.persistence.Id;
 import  javax.persistence.ManyToOne;
 import  javax.persistence.SequenceGenerator;
 import  javax.persistence.Table;
 
 import  org.kie.api.task.model.Content;
 import  org.kie.api.task.model.User;
 import  org.kie.internal.task.api.model.AccessType;
 import  org.kie.internal.task.api.model.InternalAttachment;
 
 @Entity
 @Table(name="Attachment")
 @SequenceGenerator(name="attachmentIdSeq", sequenceName="ATTACHMENT_ID_SEQ", allocationSize=1)
 public class AttachmentImpl implements InternalAttachment {
     
     @Id
     @GeneratedValue(strategy = GenerationType.AUTO, generator="attachmentIdSeq")
     @Column(name = "id")
     private Long   id = 0L;

    
Several attachments may have the same name
 
     private String name;

    
current "inline" and "URL" are allowed, this is extendable though and others may be added
 
     private AccessType accessType = AccessType.Unknown;

    
MIME type
 
     private String contentType;
 
     @ManyToOne()
     private UserImpl   attachedBy;
     
     private Date   attachedAt;    
 
     @Column(name = "attachment_size")
     private int    size;    
     
     private long   attachmentContentId;
     
     public void writeExternal(ObjectOutput outthrows IOException {
         out.writeLong );
         if == null ) { 
              = "";
         }
         out.writeUTF );
         out.writeUTF.toString() );
         if == null ) {
            = "";
         }
         out.writeUTF );
         // There are no guarantees that attachedBy is not null == potential bug
         .writeExternalout );
         long attachedAtTime = 0;
         if != null ) { 
             attachedAtTime = .getTime();
         }
         out.writeLongattachedAtTime );
         out.writeInt );
         out.writeLong );
     }
     
     public void readExternal(ObjectInput inthrows IOException,
                                             ClassNotFoundException {
          = in.readLong();
          = in.readUTF();
         = AccessType.valueOf( in.readUTF() );
         = in.readUTF();
         = new UserImpl();
        .readExternalin );        
         = new Datein.readLong() );
         = in.readInt( );
         = in.readLong();
    }
    public Long getId() {
        return ;
    }
    public void setId(long id) {
        this. = id;
    }
    public String getName() {
        return ;
    }
    public void setName(String name) {
        this. = name;
    }
    public AccessType getAccessType() {
        return ;
    }
    public void setAccessType(AccessType accessType) {
        this. = accessType;
    }
    public String getContentType() {
        return ;
    }
    public void setContentType(String contentType) {
        this. = contentType;
    }
    public Date getAttachedAt() {
        return ;
    }
    public void setAttachedAt(Date attachedAt) {
        this. = attachedAt;
    }
    public User getAttachedBy() {
        return ;
    }
    public void setAttachedBy(User attachedBy) {
        this. = convertToUserImpl(attachedBy);
    }    
    
    public int getSize() {
        return ;
    }

    
Sets the content for this attachment, i.e. the <field>size</field> and the <field>attachmentContentId</field>.

Parameters:
content attachment content
    public void setContent(Content content) {
        setSize(content.getContent().length);
        setAttachmentContentId(content.getId());
    }
    public void setSize(int size) {
        this. = size;
    }
        
    public long getAttachmentContentId() {
        return ;
    }
    public void setAttachmentContentId(long contentId) {
        this. = contentId;
    }
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + (( == null) ? 0 : .hashCode());
        result = prime * result + (( == null) ? 0 : .hashCode());
        result = prime * result + (( == null) ? 0 : .hashCode());
        result = prime * result + ;
        result = prime * result + (int) ( ^ ( >>> 32));
        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 AttachmentImpl) ) return false;
        AttachmentImpl other = (AttachmentImplobj;
        if (  == null ) {
            if ( other.accessType != null ) return false;
        } else if ( !.equals( other.accessType ) ) return false;
        if (  == null ) {
            if ( other.attachedAt != null ) return false;            
        } else if ( .getTime() != other.attachedAt.getTime() ) return false;
        if (  == null ) {
            if ( other.attachedBy != null ) return false;
        } else if ( !.equalsother.attachedBy ) ) return false;
        if (  != other.size ) return false;
        if (  != other.attachmentContentId ) return false;
        if (  == null ) {
            if ( other.contentType != null ) return false;
        } else if ( !.equalsother.contentType ) ) return false;
        if (  == null ) {
            if ( other.name != null ) return false;
        } else if ( !.equalsother.name ) ) return false;
        return true;
    }
 
 
    
    
New to GrepCode? Check out our FAQ X