/* * Copyright 2014 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 io.apiman.manager.api.beans.orgs; import io.apiman.manager.api.beans.apis.ApiBean; import io.apiman.manager.api.beans.clients.ClientBean; import io.apiman.manager.api.beans.plans.PlanBean; import java.io.Serializable; import java.util.Date; import java.util.LinkedHashSet; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.Table; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; /** * An APIMan Organization. This is an important top level entity in the APIMan * data model. It contains the APIs, Plans, etc. * * @author eric.wittmann@redhat.com */ @Entity @Table(name = "organizations") @JsonInclude(Include.NON_NULL) public class OrganizationBean implements Serializable { private static final long serialVersionUID = -506427154633682906L; @Id @Column(nullable=false) private String id; @Column(nullable=false) private String name; @Column(updatable=true, nullable=true, length=512) private String description; @Column(name = "created_by", updatable=false, nullable=false) private String createdBy; @Column(name = "created_on", updatable=false, nullable=false) private Date createdOn; @Column(name = "modified_by", updatable=true, nullable=false) private String modifiedBy; @Column(name = "modified_on", updatable=true, nullable=false) private Date modifiedOn; @OneToMany(fetch=FetchType.LAZY, orphanRemoval=true, cascade={CascadeType.REMOVE}, mappedBy="organization") @JsonIgnore private Set<PlanBean> planSet = new LinkedHashSet<>(); @OneToMany(fetch=FetchType.LAZY, orphanRemoval=true, cascade={CascadeType.REMOVE}, mappedBy="organization") @JsonIgnore private Set<ApiBean> apiSet = new LinkedHashSet<>(); @OneToMany(fetch=FetchType.LAZY, orphanRemoval=true, cascade={CascadeType.REMOVE}, mappedBy="organization") @JsonIgnore private Set<ClientBean> clientSet = new LinkedHashSet<>(); /** * Constructor. */ public OrganizationBean() { } /** * @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 createdOn */ public Date getCreatedOn() { return createdOn; } /** * @param createdOn the createdOn to set */ public void setCreatedOn(Date createdOn) { this.createdOn = createdOn; } /** * @return the description */ public String getDescription() { return description; } /** * @param description the description to set */ public void setDescription(String description) { this.description = description; } /** * @return the createdBy */ public String getCreatedBy() { return createdBy; } /** * @param createdBy the createdBy to set */ public void setCreatedBy(String createdBy) { this.createdBy = createdBy; } /** * @return the modifiedBy */ public String getModifiedBy() { return modifiedBy; } /** * @param modifiedBy the modifiedBy to set */ public void setModifiedBy(String modifiedBy) { this.modifiedBy = modifiedBy; } /** * @return the modifiedOn */ public Date getModifiedOn() { return modifiedOn; } /** * @param modifiedOn the modifiedOn to set */ public void setModifiedOn(Date modifiedOn) { this.modifiedOn = modifiedOn; } /** * @see java.lang.Object#hashCode() */ @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); return result; } /** * @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; OrganizationBean other = (OrganizationBean) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; return true; } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override @SuppressWarnings("nls") public String toString() { return "OrganizationBean [id=" + id + ", name=" + name + ", description=" + description + ", createdBy=" + createdBy + ", createdOn=" + createdOn + ", modifiedBy=" + modifiedBy + ", modifiedOn=" + modifiedOn + "]"; } }