use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service in project UVMS-ExchangeModule-APP by UnionVMS.
the class ServiceRegistryModelBean method unregisterService.
@Override
public ServiceResponseType unregisterService(ServiceType serviceType, String username) throws ExchangeModelException {
// Look for existing service
Service service = dao.getServiceByServiceClassName(serviceType.getServiceClassName());
ServiceResponseType response = null;
if (service != null) {
service.setActive(false);
service.setStatus(StatusType.STOPPED.name());
service.getServiceCapabilityList().clear();
service.getServiceSettingList().clear();
service.setUpdatedBy(username);
Service updateService = dao.updateService(service);
response = ServiceMapper.toServiceModel(updateService);
}
if (response != null) {
return response;
}
// TODO handle unable to unregister
throw new ExchangeDaoException("[ No service to unregister ]");
}
use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service 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.Service in project UVMS-ExchangeModule-APP by UnionVMS.
the class DaoBeanTest method testCreateService.
@Test
public void testCreateService() throws ExchangeDaoException {
Service carrier = new Service();
dao.createEntity(carrier);
verify(em).persist(carrier);
}
use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service in project UVMS-ExchangeModule-APP by UnionVMS.
the class MockData method getEntity.
public static Service getEntity(long id) {
Service entity = new Service();
entity.setId(id);
entity.setName("Plugin name");
entity.setDescription("Some description");
entity.setServiceClassName("the.qualified.id.of.plugin" + id);
return entity;
}
use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service in project UVMS-ExchangeModule-APP by UnionVMS.
the class MapperTest method testEntityAndModelToEntity.
@Test
public void testEntityAndModelToEntity() throws ExchangeDaoException, ExchangeDaoMappingException {
Integer id = 1;
Service entity = MockData.getEntity(id);
ServiceType service = MockData.getModel(1);
CapabilityListType capabilityListType = MockData.getCapabilityList();
SettingListType settingListType = MockData.getSettingList();
// mockDaoToEntity();
Service result = mapper.toServiceEntity(entity, service, capabilityListType, settingListType, "TEST");
assertSame(entity.getName(), result.getName());
assertSame(entity.getServiceClassName(), result.getServiceClassName());
}
Aggregations