001/** 002 * Copyright 2005-2017 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.krms.impl.repository; 017 018import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter; 019import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator; 020import org.kuali.rice.krms.api.repository.language.NaturalLanguageUsage; 021import org.kuali.rice.krms.api.repository.language.NaturalLanguageUsageContract; 022 023import javax.persistence.Column; 024import javax.persistence.Convert; 025import javax.persistence.Entity; 026import javax.persistence.GeneratedValue; 027import javax.persistence.Id; 028import javax.persistence.Table; 029import javax.persistence.Version; 030import java.io.Serializable; 031 032/** 033 * The mutable implementation of the @{link NaturalLanguageUsageContract} interface, the counterpart to the immutable implementation {@link NaturalLanguageUsage}. 034 * @author Kuali Rice Team (rice.collab@kuali.org) 035 * 036 */ 037@Entity 038@Table(name = "KRMS_NL_USAGE_T") 039public class NaturalLanguageUsageBo implements NaturalLanguageUsageContract, Serializable { 040 041 private static final long serialVersionUID = 1l; 042 043 @PortableSequenceGenerator(name = "KRMS_NL_USAGE_S") 044 @GeneratedValue(generator = "KRMS_NL_USAGE_S") 045 @Id 046 @Column(name = "NL_USAGE_ID") 047 private String id; 048 049 @Column(name = "NM") 050 private String name; 051 052 @Column(name = "DESC_TXT") 053 private String description; 054 055 @Column(name = "NMSPC_CD") 056 private String namespace; 057 058 @Column(name = "ACTV") 059 @Convert(converter = BooleanYNConverter.class) 060 private boolean active; 061 062 @Column(name = "VER_NBR") 063 @Version 064 private Long versionNumber; 065 066 /** 067 * Default Constructor 068 * 069 */ 070 public NaturalLanguageUsageBo() { 071 } 072 073 @Override 074 public String getName() { 075 return this.name; 076 } 077 078 @Override 079 public String getDescription() { 080 return this.description; 081 } 082 083 @Override 084 public String getNamespace() { 085 return this.namespace; 086 } 087 088 @Override 089 public String getId() { 090 return this.id; 091 } 092 093 @Override 094 public boolean isActive() { 095 return this.active; 096 } 097 098 @Override 099 public Long getVersionNumber() { 100 return this.versionNumber; 101 } 102 103 /** 104 * Sets the value of name on this builder to the given value. 105 * 106 * @param name the name value to set. 107 * 108 */ 109 public void setName(String name) { 110 this.name = name; 111 } 112 113 /** 114 * Sets the value of description on this builder to the given value. 115 * 116 * @param description the description value to set. 117 * 118 */ 119 public void setDescription(String description) { 120 this.description = description; 121 } 122 123 /** 124 * Sets the value of namespace on this builder to the given value. 125 * 126 * @param namespace the namespace value to set. 127 * 128 */ 129 public void setNamespace(String namespace) { 130 this.namespace = namespace; 131 } 132 133 /** 134 * Sets the value of id on this builder to the given value. 135 * 136 * @param id the id value to set. 137 * 138 */ 139 public void setId(String id) { 140 this.id = id; 141 } 142 143 /** 144 * Sets the value of active on this builder to the given value. 145 * 146 * @param active the active value to set. 147 * 148 */ 149 public void setActive(boolean active) { 150 this.active = active; 151 } 152 153 /** 154 * Sets the value of versionNumber on this builder to the given value. 155 * 156 * @param versionNumber the versionNumber value to set. 157 * 158 */ 159 public void setVersionNumber(Long versionNumber) { 160 this.versionNumber = versionNumber; 161 } 162 163 /** 164 * Converts a mutable {@link NaturalLanguageUsageBo} to its immutable counterpart, {@link NaturalLanguageUsage}. 165 * @param naturalLanguageUsageBo the mutable business object. 166 * @return a {@link NaturalLanguageUsage} the immutable object. 167 * 168 */ 169 public static NaturalLanguageUsage to(NaturalLanguageUsageBo naturalLanguageUsageBo) { 170 if (naturalLanguageUsageBo == null) { 171 return null; 172 } 173 174 return NaturalLanguageUsage.Builder.create(naturalLanguageUsageBo).build(); 175 } 176 177 /** 178 * Converts a immutable {@link NaturalLanguageUsage} to its mutable {@link NaturalLanguageUsageBo} counterpart. 179 * @param naturalLanguageUsage the immutable object. 180 * @return a {@link NaturalLanguageUsageBo} the mutable NaturalLanguageUsageBo. 181 * 182 */ 183 public static org.kuali.rice.krms.impl.repository.NaturalLanguageUsageBo from(NaturalLanguageUsage naturalLanguageUsage) { 184 if (naturalLanguageUsage == null) { 185 return null; 186 } 187 188 NaturalLanguageUsageBo naturalLanguageUsageBo = new NaturalLanguageUsageBo(); 189 naturalLanguageUsageBo.setName(naturalLanguageUsage.getName()); 190 naturalLanguageUsageBo.setDescription(naturalLanguageUsage.getDescription()); 191 naturalLanguageUsageBo.setNamespace(naturalLanguageUsage.getNamespace()); 192 naturalLanguageUsageBo.setId(naturalLanguageUsage.getId()); 193 naturalLanguageUsageBo.setActive(naturalLanguageUsage.isActive()); 194 naturalLanguageUsageBo.setVersionNumber(naturalLanguageUsage.getVersionNumber()); 195 196 return naturalLanguageUsageBo; 197 } 198}