use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceCapability in project UVMS-ExchangeModule-APP by UnionVMS.
the class ServiceMapper method toCapabilityEntity.
private static ServiceCapability toCapabilityEntity(Service parent, CapabilityType capability, String username) {
ServiceCapability entity = new ServiceCapability();
entity.setService(parent);
entity.setCapability(capability.getType());
entity.setUpdatedBy(username);
entity.setUpdatedTime(DateUtils.nowUTC().toDate());
entity.setValue(capability.getValue());
return entity;
}
use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceCapability in project UVMS-ExchangeModule-APP by UnionVMS.
the class ServiceRegistryModelBean method registerService.
@Override
public ServiceResponseType registerService(ServiceType serviceType, CapabilityListType capabilityList, SettingListType settingList, String username) throws ExchangeModelException {
// Look for existing service
Service service = dao.getServiceByServiceClassName(serviceType.getServiceClassName());
if (service == null) {
// create
service = ServiceMapper.toServiceEntity(serviceType, capabilityList, settingList, username);
service.setActive(true);
service.setStatus(StatusType.STARTED.name());
dao.createEntity(service);
} else {
service.setActive(true);
service.setStatus(StatusType.STARTED.name());
List<ServiceSetting> newSettings = ServiceMapper.mapSettingsList(service, settingList, username);
List<ServiceCapability> serviceCapabilityList = ServiceMapper.upsetCapabilityList(service, capabilityList, username);
service.getServiceCapabilityList().clear();
service.getServiceCapabilityList().addAll(serviceCapabilityList);
service.getServiceSettingList().clear();
service.getServiceSettingList().addAll(newSettings);
service.setDescription(serviceType.getDescription());
service.setName(serviceType.getName());
service.setUpdated(new DateTime(DateTimeZone.UTC).toDate());
service.setUpdatedBy(username);
dao.updateService(service);
}
return ServiceMapper.toServiceModel(service);
}
use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceCapability in project UVMS-ExchangeModule-APP by UnionVMS.
the class ServiceMapper method upsetCapabilityList.
public static List<ServiceCapability> upsetCapabilityList(Service parent, CapabilityListType capabilityList, String username) {
List<ServiceCapability> newCapabilityList = new ArrayList<>();
for (CapabilityType capabilityType : capabilityList.getCapability()) {
ServiceCapability newServiceCapability = toCapabilityEntity(parent, capabilityType, username);
newCapabilityList.add(newServiceCapability);
}
return newCapabilityList;
}
use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceCapability in project UVMS-ExchangeModule-APP by UnionVMS.
the class ServiceRegistryDaoBean method getServiceCapabilities.
@Override
public List<ServiceCapability> getServiceCapabilities(String serviceClassName) throws ExchangeDaoException {
try {
TypedQuery<ServiceCapability> query = em.createNamedQuery(ExchangeConstants.CAPABILITY_FIND_BY_SERVICE, ServiceCapability.class);
query.setParameter(SERVICE_CLASS_NAME_PARAMETER, serviceClassName);
return query.getResultList();
} catch (IllegalArgumentException e) {
LOG.error("[ Error when getting capabilities ] {}", e.getMessage());
throw new ExchangeDaoException("[ Error when getting capabilities ] ");
} catch (Exception e) {
LOG.error("[ Error when getting capabilities ] {}", e.getMessage());
throw new ExchangeDaoException("[ Error when getting capabilities ] ");
}
}
Aggregations