001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.kew.impl.type;
017
018import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
019import org.kuali.rice.kew.api.repository.type.KewAttributeDefinition;
020import org.kuali.rice.kew.api.repository.type.KewAttributeDefinitionContract;
021import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
022import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
023
024import javax.persistence.Column;
025import javax.persistence.Convert;
026import javax.persistence.Entity;
027import javax.persistence.GeneratedValue;
028import javax.persistence.Id;
029import javax.persistence.Table;
030import javax.persistence.Version;
031
032/**
033 * Kuali workflow attribute definition business object.
034 *
035 * @author Kuali Rice Team (rice.collab@kuali.org)
036 */
037@Entity
038@Table(name = "KREW_ATTR_DEFN_T")
039public class KewAttributeDefinitionBo implements KewAttributeDefinitionContract, MutableInactivatable {
040
041    @Id
042    @GeneratedValue(generator = "KREW_ATTR_DEFN_S")
043    @PortableSequenceGenerator(name = "KREW_ATTR_DEFN_S")
044    @Column(name = "ATTR_DEFN_ID", nullable = false)
045    private String id;
046
047    @Column(name = "NM", nullable = false)
048    private String name;
049
050    @Column(name = "NMSPC_CD", nullable = false)
051    private String namespace;
052
053    @Column(name = "LBL")
054    private String label;
055
056    @Column(name = "ACTV", nullable = false)
057    @Convert(converter = BooleanYNConverter.class)
058    private boolean active;
059
060    @Column(name = "CMPNT_NM")
061    private String componentName;
062
063    @Version
064    @Column(name = "VER_NBR", nullable = false)
065    private Long versionNumber;
066
067    @Column(name = "DESC_TXT")
068    private String description;
069
070    /**
071     * Default constructor.
072     */
073    public KewAttributeDefinitionBo() { }
074
075    /**
076     * Converts a mutable bo to it's immutable counterpart
077     * @param kadBo the mutable business object
078     * @return the immutable object
079     */
080    public static KewAttributeDefinition to(KewAttributeDefinitionBo kadBo) {
081        if(null == kadBo) {
082            return null;
083        } else {
084            return org.kuali.rice.kew.api.repository.type.KewAttributeDefinition.Builder.create(kadBo).build();
085        }
086    }
087
088    /**
089     * Converts a immutable object to it's mutable bo counterpart
090     * @param kadIm immutable object
091     * @return the mutable bo
092     */
093    public static KewAttributeDefinitionBo from(KewAttributeDefinition kadIm) {
094        if (null == kadIm) {
095            return null;
096        } else {
097            KewAttributeDefinitionBo kadBo = new KewAttributeDefinitionBo();
098            kadBo.setId(kadIm.getId());
099            kadBo.setName(kadIm.getName());
100            kadBo.setNamespace(kadIm.getNamespace());
101            kadBo.setLabel(kadIm.getLabel());
102            kadBo.setDescription(kadIm.getDescription());
103            kadBo.setActive(kadIm.isActive());
104            kadBo.setComponentName(kadIm.getComponentName());
105            kadBo.setVersionNumber(kadIm.getVersionNumber());
106
107            return kadBo;
108        }
109    }
110
111    /**
112     * returns the unique identifier for this class
113     * @return the unique identifier for this class
114     */
115    public String getId() {
116        return id;
117    }
118
119    /**
120     * @see #getId()
121     */
122    public void setId(String id) {
123        this.id = id;
124    }
125
126    /**
127     * Returns the attribute name
128     * @return the attribute name
129     */
130    public String getName() {
131        return name;
132    }
133
134    /**
135     * @see #getName()
136     */
137    public void setName(String name) {
138        this.name = name;
139    }
140
141    /**
142     * Returns the name space
143     * @return the name space
144     */
145    public String getNamespace() {
146        return namespace;
147    }
148
149    /**
150     * @see #getNamespace()
151     */
152    public void setNamespace(String namespace) {
153        this.namespace = namespace;
154    }
155
156    /**
157     * Returns the label
158     * @return the label
159     */
160    public String getLabel() {
161        return label;
162    }
163
164    /**
165     * @see #getLabel
166     */
167    public void setLabel(String label) {
168        this.label = label;
169    }
170
171    /**
172     * Returns the status of this record
173     * @return TRUE if the record is active, FALSE otherwise
174     */
175    public boolean isActive() {
176        return active;
177    }
178
179    /**
180     * @see #isActive()
181     */
182    public void setActive(boolean active) {
183        this.active = active;
184    }
185
186    /**
187     * Returns the component name.
188     * @return the component name
189     */
190    public String getComponentName() {
191        return componentName;
192    }
193
194    /**
195     * @see #getComponentName()
196     */
197    public void setComponentName(String componentName) {
198        this.componentName = componentName;
199    }
200
201    public Long getVersionNumber() {
202        return versionNumber;
203    }
204
205    public void setVersionNumber(Long versionNumber) {
206        this.versionNumber = versionNumber;
207    }
208
209    /**
210     * Returns the description.
211     * @return the description
212     */
213    public String getDescription() {
214        return description;
215    }
216
217    /**
218     * @see #getDescription()
219     */
220    public void setDescription(String description) {
221        this.description = description;
222    }
223}