View Javadoc
1   /**
2    * Copyright 2005-2016 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.coreservice.impl.namespace;
17  
18  import org.apache.commons.lang.builder.HashCodeBuilder;
19  import org.apache.commons.lang.builder.EqualsBuilder;
20  import org.kuali.rice.coreservice.api.namespace.Namespace;
21  import org.kuali.rice.coreservice.framework.namespace.NamespaceEbo;
22  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
23  import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
24  
25  import javax.persistence.Column;
26  import javax.persistence.Convert;
27  import javax.persistence.Entity;
28  import javax.persistence.Id;
29  import javax.persistence.Table;
30  
31  @Entity
32  @Table(name="KRCR_NMSPC_T")
33  public class NamespaceBo extends PersistableBusinessObjectBase implements NamespaceEbo {
34  
35      private static final long serialVersionUID = 1L;
36  
37      @Column(name="APPL_ID")
38      private String applicationId;
39  
40      @Id
41      @Column(name="NMSPC_CD")
42      private String code;
43  
44      @Column(name="NM")
45      private String name;
46  
47      @Column(name="ACTV_IND")
48      @Convert(converter = BooleanYNConverter.class)
49      private boolean active = true;
50  
51      @Override
52      public String getApplicationId() {
53          return applicationId;
54      }
55  
56      public void setApplicationId(String applicationId) {
57          this.applicationId = applicationId;
58      }
59  
60      @Override
61      public String getCode() {
62          return code;
63      }
64  
65      public void setCode(String code) {
66          this.code = code;
67      }
68  
69      @Override
70      public String getName() {
71          return name;
72      }
73  
74      public void setName(String name) {
75          this.name = name;
76      }
77  
78      @Override
79      public boolean isActive() {
80          return active;
81      }
82  
83      public void setActive(boolean active) {
84          this.active = active;
85      }
86  
87      /**
88       * Converts a mutable bo to its immutable counterpart
89       * @param bo the mutable business object
90       * @return the immutable object
91       */
92      public static Namespace to(NamespaceBo bo) {
93          if (bo == null) {
94              return null;
95          }
96  
97          return Namespace.Builder.create(bo).build();
98      }
99  
100     /**
101      * Converts a immutable object to its mutable counterpart
102      * @param im immutable object
103      * @return the mutable bo
104      */
105     public static NamespaceBo from(Namespace im) {
106         if (im == null) {
107             return null;
108         }
109 
110         NamespaceBo bo = new NamespaceBo();
111         bo.applicationId = im.getApplicationId();
112         bo.active = im.isActive();
113         bo.code = im.getCode();
114         bo.name = im.getName();
115         bo.versionNumber = im.getVersionNumber();
116         bo.objectId = im.getObjectId();
117 
118         return bo;
119     }
120 
121     @Override
122     public boolean equals(Object o) {
123         if (this == o) {
124             return true;
125         }
126 
127         if (o == null || getClass() != o.getClass()) {
128             return false;
129         }
130 
131         return EqualsBuilder.reflectionEquals(o, this);
132     }
133 
134     @Override
135     public int hashCode() {
136         return HashCodeBuilder.reflectionHashCode(this);
137     }
138 
139 }