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