001 /** 002 * Copyright 2005-2013 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 */ 016 package org.kuali.rice.ksb.impl.registry; 017 018 import org.kuali.rice.ksb.api.registry.ServiceEndpointStatus; 019 import org.kuali.rice.ksb.api.registry.ServiceInfo; 020 import org.kuali.rice.ksb.api.registry.ServiceInfoContract; 021 022 import javax.xml.namespace.QName; 023 import java.io.Serializable; 024 025 /** 026 * Model bean that represents the definition of a service on the bus. 027 * 028 * @see ServiceInfo 029 * 030 * @author Kuali Rice Team (rice.collab@kuali.org) 031 */ 032 //@Entity 033 //@Table(name="KRSB_SVC_DEF_T") 034 //@NamedQueries([ 035 // @NamedQuery(name="ServiceInfo.FetchAll", query="select s from ServiceInfo s"), 036 // @NamedQuery(name="ServiceInfo.FetchAllActive",query="select s from ServiceInfo s where s.alive = true"), 037 // @NamedQuery(name="ServiceInfo.FetchActiveByName",query="select s from ServiceInfo s where s.alive = true AND s.serviceName LIKE :serviceName"), 038 // @NamedQuery(name="ServiceInfo.FindLocallyPublishedServices",query="select s from ServiceInfo s where s.serverIp = :serverIp AND s.applicationId = :applicationId"), 039 // @NamedQuery(name="ServiceInfo.DeleteLocallyPublishedServices",query="delete from ServiceInfo s WHERE s.serverIp = :serverIp AND s.applicationId = :applicationId"), 040 // @NamedQuery(name="ServiceInfo.DeleteByEntry",query="delete from ServiceInfo s where s.messageEntryId = :messageEntryId") 041 //]) 042 public class ServiceInfoBo implements ServiceInfoContract, Serializable { 043 044 private static final long serialVersionUID = -4244884858494208070L; 045 046 // TODO for some reason groovy won't compile this so commenting out for now... 047 // @Id 048 // @GeneratedValue(generator="KRSB_SVC_DEF_S") 049 // @GenericGenerator(name="KRSB_SVC_DEF_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters=[ 050 // @Parameter(name="sequence_name",value="KRSB_SVC_DEF_S"), 051 // @Parameter(name="value_column",value="id") 052 // ]) 053 @javax.persistence.Column(name="SVC_DEF_ID") 054 private String serviceId; 055 056 @javax.persistence.Column(name="SVC_NM") 057 private String serviceName; 058 059 @javax.persistence.Column(name="SVC_URL", length=500) 060 private String endpointUrl; 061 062 @javax.persistence.Column(name="INSTN_ID") 063 private String instanceId; 064 065 @javax.persistence.Column(name="APPL_ID") 066 private String applicationId; 067 068 @javax.persistence.Column(name="SRVR_IP") 069 private String serverIpAddress; 070 071 @javax.persistence.Column(name="TYP_CD") 072 private String type; 073 074 @javax.persistence.Column(name="SVC_VER") 075 private String serviceVersion; 076 077 @javax.persistence.Column(name="STAT_CD") 078 private String statusCode; 079 080 @javax.persistence.Column(name="SVC_DSCRPTR_ID") 081 private String serviceDescriptorId; 082 083 @javax.persistence.Column(name="CHKSM", length=30) 084 private String checksum; 085 086 @javax.persistence.Version 087 @javax.persistence.Column(name="VER_NBR") 088 private Long versionNumber; 089 090 public String getServiceId() { 091 return serviceId; 092 } 093 094 public void setServiceId(String serviceId) { 095 this.serviceId = serviceId; 096 } 097 098 @Override 099 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 }