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.ksb.impl.registry;
17  
18  import org.kuali.rice.ksb.api.registry.ServiceEndpointStatus;
19  import org.kuali.rice.ksb.api.registry.ServiceInfo;
20  import org.kuali.rice.ksb.api.registry.ServiceInfoContract;
21  
22  import javax.xml.namespace.QName;
23  import java.io.Serializable;
24  
25  /**
26   * Model bean that represents the definition of a service on the bus.
27   * 
28   * @see ServiceInfo
29   *
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  //@Entity
33  //@Table(name="KRSB_SVC_DEF_T")
34  //@NamedQueries([
35  //	@NamedQuery(name="ServiceInfo.FetchAll", query="select s from ServiceInfo s"),
36  //	@NamedQuery(name="ServiceInfo.FetchAllActive",query="select s from ServiceInfo s where s.alive = true"),
37  //	@NamedQuery(name="ServiceInfo.FetchActiveByName",query="select s from ServiceInfo s where s.alive = true AND s.serviceName LIKE :serviceName"),
38  //	@NamedQuery(name="ServiceInfo.FindLocallyPublishedServices",query="select s from ServiceInfo s where s.serverIp = :serverIp AND s.applicationId = :applicationId"),
39  //	@NamedQuery(name="ServiceInfo.DeleteLocallyPublishedServices",query="delete from ServiceInfo s WHERE s.serverIp = :serverIp AND s.applicationId = :applicationId"),
40  //	@NamedQuery(name="ServiceInfo.DeleteByEntry",query="delete from ServiceInfo s where s.messageEntryId = :messageEntryId")			
41  //])
42  public class ServiceInfoBo implements ServiceInfoContract, Serializable {
43   
44  	private static final long serialVersionUID = -4244884858494208070L;
45  
46  	// TODO for some reason groovy won't compile this so commenting out for now...
47  //	@Id
48  //	@GeneratedValue(generator="KRSB_SVC_DEF_S")
49  //	@GenericGenerator(name="KRSB_SVC_DEF_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters=[
50  //			@Parameter(name="sequence_name",value="KRSB_SVC_DEF_S"),
51  //			@Parameter(name="value_column",value="id")
52  //	])
53  	@javax.persistence.Column(name="SVC_DEF_ID")
54  	private String serviceId;
55  	
56  	@javax.persistence.Column(name="SVC_NM")
57  	private String serviceName;
58      
59  	@javax.persistence.Column(name="SVC_URL", length=500)
60  	private String endpointUrl;
61  	
62  	@javax.persistence.Column(name="INSTN_ID")
63  	private String instanceId;
64  
65  	@javax.persistence.Column(name="APPL_ID")
66  	private String applicationId;
67  
68  	@javax.persistence.Column(name="SRVR_IP")
69  	private String serverIpAddress;
70  	
71  	@javax.persistence.Column(name="TYP_CD")
72  	private String type;
73  	
74  	@javax.persistence.Column(name="SVC_VER")
75  	private String serviceVersion;
76  	
77  	@javax.persistence.Column(name="STAT_CD")
78  	private String statusCode;
79  	
80  	@javax.persistence.Column(name="SVC_DSCRPTR_ID")
81  	private String serviceDescriptorId;
82  	
83  	@javax.persistence.Column(name="CHKSM", length=30)
84  	private String checksum;
85  	
86  	@javax.persistence.Version
87  	@javax.persistence.Column(name="VER_NBR")
88  	private Long versionNumber;
89  
90      public String getServiceId() {
91          return serviceId;
92      }
93  
94      public void setServiceId(String serviceId) {
95          this.serviceId = serviceId;
96      }
97  
98      @Override
99      public QName getServiceName() {
100         if (this.serviceName == null) {
101             return null;
102         }
103         return QName.valueOf(this.serviceName);
104     }
105 
106     public void setServiceName(String serviceName) {
107         this.serviceName = serviceName;
108     }
109 
110     public String getEndpointUrl() {
111         return endpointUrl;
112     }
113 
114     public void setEndpointUrl(String endpointUrl) {
115         this.endpointUrl = endpointUrl;
116     }
117 
118     public String getInstanceId() {
119         return instanceId;
120     }
121 
122     public void setInstanceId(String instanceId) {
123         this.instanceId = instanceId;
124     }
125 
126     public String getApplicationId() {
127         return applicationId;
128     }
129 
130     public void setApplicationId(String applicationId) {
131         this.applicationId = applicationId;
132     }
133 
134     public String getServerIpAddress() {
135         return serverIpAddress;
136     }
137 
138     public void setServerIpAddress(String serverIpAddress) {
139         this.serverIpAddress = serverIpAddress;
140     }
141 
142     public String getType() {
143         return type;
144     }
145 
146     public void setType(String type) {
147         this.type = type;
148     }
149 
150     public String getServiceVersion() {
151         return serviceVersion;
152     }
153 
154     public void setServiceVersion(String serviceVersion) {
155         this.serviceVersion = serviceVersion;
156     }
157 
158     public String getStatusCode() {
159         return statusCode;
160     }
161 
162     public void setStatusCode(String statusCode) {
163         this.statusCode = statusCode;
164     }
165 
166     public String getServiceDescriptorId() {
167         return serviceDescriptorId;
168     }
169 
170     public void setServiceDescriptorId(String serviceDescriptorId) {
171         this.serviceDescriptorId = serviceDescriptorId;
172     }
173 
174     public String getChecksum() {
175         return checksum;
176     }
177 
178     public void setChecksum(String checksum) {
179         this.checksum = checksum;
180     }
181 
182     public Long getVersionNumber() {
183         return versionNumber;
184     }
185 
186     public void setVersionNumber(Long versionNumber) {
187         this.versionNumber = versionNumber;
188     }
189 
190     @Override
191 	public ServiceEndpointStatus getStatus() {
192 		if (getStatusCode() == null) {
193 			return null;
194 		}
195 		return ServiceEndpointStatus.fromCode(getStatusCode());
196 	}
197 
198 	static ServiceInfo to(ServiceInfoBo bo) {
199 		if (bo == null) {
200 			return null;
201 		}
202 		return ServiceInfo.Builder.create(bo).build();
203 	}
204 	
205 	static ServiceInfoBo from(ServiceInfo im) {
206 		if (im == null) {
207 			return null;
208 		}
209 		ServiceInfoBo bo = new ServiceInfoBo();
210 		bo.serviceId = im.getServiceId();
211 		bo.serviceName = im.getServiceName().toString();
212 		bo.endpointUrl = im.getEndpointUrl();
213 		bo.instanceId = im.getInstanceId();
214 		bo.applicationId = im.getApplicationId();
215 		bo.serverIpAddress = im.getServerIpAddress();
216 		bo.type = im.getType();
217 		bo.serviceVersion = im.getServiceVersion();
218 		bo.statusCode = im.getStatus().getCode();
219 		bo.serviceDescriptorId = im.getServiceDescriptorId();
220 		bo.checksum = im.getChecksum();
221 		bo.versionNumber = im.getVersionNumber();
222 		return bo;
223 	}
224 	
225 	
226 	
227 	
228 }