package com.thingtrack.konekti.domain; /* * #%L * Konekti Domain Layer * $Id:$ * $HeadURL:$ * %% * Copyright (C) 2010 - 2014 Thingtrack s.l. * %% * 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. * #L% */ import java.io.Serializable; import java.util.Arrays; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.Lob; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Transient; /** * @author Thingtrack S.L. * */ @SuppressWarnings("serial") @Entity @Table(name="KNOWLEDGE") public class Knowledge implements Serializable { @Id @Column(name="KNOWLEDGE_ID") @GeneratedValue(strategy=GenerationType.IDENTITY) private Integer knowledgeId; @Column(name="ID", nullable=false, unique=true) private String id; @Column(name="NAME", nullable=false) private String name; @Column(name="DESCRIPTION") private String description; @Column(name="PACKAGE", nullable=false) private String packageName; @Column(name="VERSION", nullable=false) private String version; @Column(name="FILE", nullable=false) @Lob private byte[] file; @ManyToOne @JoinColumn(name = "ORGANIZATION_ID", nullable = false) private Organization organization; @Transient private String errorMessage; @Column(name="ERROR") private Boolean error; @Column(name = "ACTIVE", nullable = false) private Boolean active = true; /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return "Knowledge [knowledgeId=" + knowledgeId + ", id=" + id + ", name=" + name + ", description=" + description + ", packageName=" + packageName + ", version=" + version + ", file=" + Arrays.toString(file) + ", error=" + error + ", active=" + active + "]"; } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((knowledgeId == null) ? 0 : knowledgeId.hashCode()); return result; } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Knowledge other = (Knowledge) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; if (knowledgeId == null) { if (other.knowledgeId != null) return false; } else if (!knowledgeId.equals(other.knowledgeId)) return false; return true; } /** * @return the knowledgeId */ public Integer getKnowledgeId() { return knowledgeId; } /** * @param knowledgeId the knowledgeId to set */ public void setKnowledgeId(Integer knowledgeId) { this.knowledgeId = knowledgeId; } /** * @return the id */ public String getId() { return id; } /** * @param id the id to set */ public void setId(String id) { this.id = id; } /** * @return the name */ public String getName() { return name; } /** * @param name the name to set */ public void setName(String name) { this.name = name; } /** * @return the description */ public String getDescription() { return description; } /** * @param description the description to set */ public void setDescription(String description) { this.description = description; } /** * @return the packageName */ public String getPackageName() { return packageName; } /** * @param packageName the packageName to set */ public void setPackageName(String packageName) { this.packageName = packageName; } /** * @return the version */ public String getVersion() { return version; } /** * @param version the version to set */ public void setVersion(String version) { this.version = version; } /** * @return the file */ public byte[] getFile() { return file; } /** * @param file the file to set */ public void setFile(byte[] file) { this.file = file; } /** * @return the active */ public Boolean getActive() { return active; } /** * @param active the active to set */ public void setActive(Boolean active) { this.active = active; } /** * @return the organization */ public Organization getOrganization() { return organization; } /** * @param organization the organization to set */ public void setOrganization(Organization organization) { this.organization = organization; } /** * @return the errorMessage */ public String getErrorMessage() { return errorMessage; } /** * @param errorMessage the errorMessage to set */ public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; } /** * @return the error */ public Boolean getError() { return error; } /** * @param error the error to set */ public void setError(Boolean error) { this.error = error; } }