Search in sources :

Example 6 with Service

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());
}
Also used : CapabilityListType(eu.europa.ec.fisheries.schema.exchange.service.v1.CapabilityListType) ServiceType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceType) ServiceResponseType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType) ArrayList(java.util.ArrayList) Service(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service) ServiceCapability(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceCapability) SettingListType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType) ServiceSetting(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with Service

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;
}
Also used : ArrayList(java.util.ArrayList) Service(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service)

Example 8 with Service

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] ");
    }
}
Also used : ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) Service(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service) EntityExistsException(javax.persistence.EntityExistsException) NoResultException(javax.persistence.NoResultException) ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) NoEntityFoundException(eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException)

Example 9 with Service

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");
}
Also used : ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) Service(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service) ServiceSetting(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting)

Example 10 with Service

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());
}
Also used : Service(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) Date(java.util.Date)

Aggregations

Service (eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service)16 Test (org.junit.Test)9 ServiceSetting (eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting)6 ServiceType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceType)5 SettingListType (eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType)4 ServiceCapability (eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceCapability)4 ArrayList (java.util.ArrayList)4 CapabilityListType (eu.europa.ec.fisheries.schema.exchange.service.v1.CapabilityListType)3 ExchangeDaoException (eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException)3 ServiceResponseType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType)1 SettingType (eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType)1 NoEntityFoundException (eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException)1 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)1 Date (java.util.Date)1 EntityExistsException (javax.persistence.EntityExistsException)1 NoResultException (javax.persistence.NoResultException)1 DateTime (org.joda.time.DateTime)1 Ignore (org.junit.Ignore)1