use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service in project UVMS-ExchangeModule-APP by UnionVMS.
the class DomainModelBeanTest method testCreateModel.
@Ignore
@Test
public void testCreateModel() throws ExchangeModelException, ExchangeDaoException, ExchangeDaoMappingException {
Long id = 1L;
ServiceType serviceType = MockData.getModel(id.intValue());
CapabilityListType capabilityListType = MockData.getCapabilityList();
SettingListType settingListType = MockData.getSettingList();
Service service = new Service();
service.setId(id);
service.setActive(false);
List<ServiceCapability> serviceCapabilityList = new ArrayList<>();
service.setServiceCapabilityList(serviceCapabilityList);
List<ServiceSetting> serviceSettingList = new ArrayList<>();
service.setServiceSettingList(serviceSettingList);
when(dao.getServiceByServiceClassName(any(String.class))).thenReturn(null);
// when(dao.updateService(any(Service.class))).thenReturn(service);
ServiceResponseType result = model.registerService(serviceType, capabilityListType, settingListType, "TEST");
// assertEquals(id.toString(), result.getId());
}
use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service in project UVMS-ExchangeModule-APP by UnionVMS.
the class ServiceRegistryModelBean method getPlugins.
@Override
public List<ServiceResponseType> getPlugins(List<PluginType> pluginTypes) throws ExchangeModelException {
List<ServiceResponseType> services = new ArrayList<>();
List<Service> entityList = new ArrayList<>();
if (pluginTypes == null || pluginTypes.isEmpty()) {
entityList = dao.getServices();
} else {
entityList = dao.getServicesByTypes(pluginTypes);
}
for (Service entity : entityList) {
services.add(ServiceMapper.toServiceModel(entity));
}
return services;
}
use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service in project UVMS-ExchangeModule-APP by UnionVMS.
the class ServiceRegistryDaoBean method getServicesByTypes.
@Override
public List<Service> getServicesByTypes(List<PluginType> pluginTypes) throws ExchangeDaoException {
try {
TypedQuery<Service> query = em.createNamedQuery(ExchangeConstants.SERVICE_FIND_BY_TYPES, Service.class);
query.setParameter("types", pluginTypes);
return query.getResultList();
} catch (IllegalArgumentException e) {
LOG.error("[ Error when getting service list by types ] {}", e.getMessage());
throw new ExchangeDaoException("[ Error when getting service list by types ] ");
} catch (Exception e) {
LOG.error("[ Error when getting service list by types ] {}", e.getMessage());
throw new ExchangeDaoException("[ Error when getting service list by types] ");
}
}
use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service in project UVMS-ExchangeModule-APP by UnionVMS.
the class ServiceRegistryModelBean method updatePluginSettings.
@Override
public ServiceResponseType updatePluginSettings(String serviceClassName, SettingListType settings, String username) throws ExchangeModelException {
LOG.info("Update plugin settings for " + serviceClassName);
Service service = dao.getServiceByServiceClassName(serviceClassName);
if (service != null) {
List<ServiceSetting> newSettings = ServiceMapper.mapSettingsList(service, settings, username);
service.getServiceSettingList().addAll(newSettings);
dao.updateService(service);
return ServiceMapper.toServiceModel(service);
}
throw new ExchangeDaoException("No plugin found when update plugin settings");
}
use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service in project UVMS-ExchangeModule-APP by UnionVMS.
the class ServiceRegistryModelBean method updatePluginStatus.
@Override
public ServiceResponseType updatePluginStatus(String serviceName, StatusType status, String username) throws ExchangeModelException {
Service service = dao.getServiceByServiceClassName(serviceName);
if (service != null) {
service.setStatus(status.name());
service.setUpdatedBy(username);
service.setUpdated(new Date());
return ServiceMapper.toServiceModel(dao.updateService(service));
}
throw new ExchangeModelException("[ Error when update plugin " + serviceName + " with status " + status.name());
}
Aggregations