Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ServiceInfoBo |
|
| 0.0;0 |
1 | /** | |
2 | * Copyright 2005-2011 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 | ||
19 | import javax.persistence.Column | |
20 | import javax.persistence.Version | |
21 | import javax.xml.namespace.QName | |
22 | import org.kuali.rice.ksb.api.registry.ServiceEndpointStatus | |
23 | import org.kuali.rice.ksb.api.registry.ServiceInfo | |
24 | import org.kuali.rice.ksb.api.registry.ServiceInfoContract | |
25 | ||
26 | /** | |
27 | * Model bean that represents the definition of a service on the bus. | |
28 | * | |
29 | * @see ServiceInfo | |
30 | * | |
31 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
32 | */ | |
33 | //@Entity | |
34 | //@Table(name="KRSB_SVC_DEF_T") | |
35 | //@NamedQueries([ | |
36 | // @NamedQuery(name="ServiceInfo.FetchAll", query="select s from ServiceInfo s"), | |
37 | // @NamedQuery(name="ServiceInfo.FetchAllActive",query="select s from ServiceInfo s where s.alive = true"), | |
38 | // @NamedQuery(name="ServiceInfo.FetchActiveByName",query="select s from ServiceInfo s where s.alive = true AND s.serviceName LIKE :serviceName"), | |
39 | // @NamedQuery(name="ServiceInfo.FindLocallyPublishedServices",query="select s from ServiceInfo s where s.serverIp = :serverIp AND s.applicationId = :applicationId"), | |
40 | // @NamedQuery(name="ServiceInfo.DeleteLocallyPublishedServices",query="delete from ServiceInfo s WHERE s.serverIp = :serverIp AND s.applicationId = :applicationId"), | |
41 | // @NamedQuery(name="ServiceInfo.DeleteByEntry",query="delete from ServiceInfo s where s.messageEntryId = :messageEntryId") | |
42 | //]) | |
43 | public class ServiceInfoBo implements ServiceInfoContract, Serializable { | |
44 | ||
45 | private static final long serialVersionUID = -4244884858494208070L; | |
46 | ||
47 | // TODO for some reason groovy won't compile this so commenting out for now... | |
48 | // @Id | |
49 | // @GeneratedValue(generator="KRSB_SVC_DEF_S") | |
50 | // @GenericGenerator(name="KRSB_SVC_DEF_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters=[ | |
51 | // @Parameter(name="sequence_name",value="KRSB_SVC_DEF_S"), | |
52 | // @Parameter(name="value_column",value="id") | |
53 | // ]) | |
54 | @Column(name="SVC_DEF_ID") | |
55 | String serviceId; | |
56 | ||
57 | @Column(name="SVC_NM") | |
58 | String serviceName; | |
59 | ||
60 | @Column(name="SVC_URL", length=500) | |
61 | String endpointUrl; | |
62 | ||
63 | @Column(name="INSTN_ID") | |
64 | String instanceId; | |
65 | ||
66 | @Column(name="APPL_ID") | |
67 | String applicationId; | |
68 | ||
69 | @Column(name="SRVR_IP") | |
70 | String serverIpAddress; | |
71 | ||
72 | @Column(name="TYP_CD") | |
73 | String type; | |
74 | ||
75 | @Column(name="SVC_VER") | |
76 | String serviceVersion; | |
77 | ||
78 | @Column(name="STAT_CD") | |
79 | String statusCode; | |
80 | ||
81 | @Column(name="SVC_DSCRPTR_ID") | |
82 | String serviceDescriptorId; | |
83 | ||
84 | @Column(name="CHKSM", length=30) | |
85 | String checksum; | |
86 | ||
87 | @Version | |
88 | @Column(name="VER_NBR") | |
89 | Long versionNumber; | |
90 | ||
91 | @Override | |
92 | public QName getServiceName() { | |
93 | 0 | if (this.serviceName == null) { |
94 | 0 | return null; |
95 | } | |
96 | 0 | return QName.valueOf(this.serviceName); |
97 | } | |
98 | ||
99 | @Override | |
100 | public ServiceEndpointStatus getStatus() { | |
101 | 0 | if (getStatusCode() == null) { |
102 | 0 | return null; |
103 | } | |
104 | 0 | return ServiceEndpointStatus.fromCode(getStatusCode()); |
105 | } | |
106 | ||
107 | static ServiceInfo to(ServiceInfoBo bo) { | |
108 | 0 | if (bo == null) { |
109 | 0 | return null; |
110 | } | |
111 | 0 | return ServiceInfo.Builder.create(bo).build(); |
112 | } | |
113 | ||
114 | static ServiceInfoBo from(ServiceInfo im) { | |
115 | 0 | if (im == null) { |
116 | 0 | return null; |
117 | } | |
118 | 0 | ServiceInfoBo bo = new ServiceInfoBo(); |
119 | 0 | bo.serviceId = im.getServiceId(); |
120 | 0 | bo.serviceName = im.getServiceName().toString(); |
121 | 0 | bo.endpointUrl = im.getEndpointUrl(); |
122 | 0 | bo.instanceId = im.getInstanceId(); |
123 | 0 | bo.applicationId = im.getApplicationId(); |
124 | 0 | bo.serverIpAddress = im.getServerIpAddress(); |
125 | 0 | bo.type = im.getType(); |
126 | 0 | bo.serviceVersion = im.getServiceVersion(); |
127 | 0 | bo.statusCode = im.getStatus().getCode(); |
128 | 0 | bo.serviceDescriptorId = im.getServiceDescriptorId(); |
129 | 0 | bo.checksum = im.getChecksum(); |
130 | 0 | bo.versionNumber = im.getVersionNumber(); |
131 | 0 | return bo; |
132 | } | |
133 | ||
134 | ||
135 | ||
136 | ||
137 | } |