Search in sources :

Example 6 with SettingListType

use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType in project UVMS-ExchangeModule-APP by UnionVMS.

the class PluginServiceBean method registerService.

private void registerService(RegisterServiceRequest register, String messageId) throws ExchangeModelMarshallException, ExchangeMessageException {
    try {
        overrideSettingsFromConfig(register);
        ServiceResponseType service = exchangeService.registerService(register.getService(), register.getCapabilityList(), register.getSettingList(), register.getService().getName());
        // push to config module
        try {
            String serviceClassName = register.getService().getServiceClassName();
            SettingListType settings = register.getSettingList();
            for (SettingType setting : settings.getSetting()) {
                String description = "Plugin " + serviceClassName + " " + setting.getKey() + " setting";
                configService.pushSettingToConfig(SettingTypeMapper.map(setting.getKey(), setting.getValue(), description), false);
            }
        } catch (ConfigServiceException e) {
            LOG.error("Couldn't register plugin settings in config parameter table");
        }
        // TODO log to exchange log
        String response = ExchangePluginResponseMapper.mapToRegisterServiceResponseOK(messageId, service);
        producer.sendEventBusMessage(response, register.getService().getServiceResponseMessageName());
        setServiceStatusOnRegister(register.getService().getServiceClassName());
    } catch (ExchangeServiceException | ExchangeModelMapperException e) {
        String response = ExchangePluginResponseMapper.mapToRegisterServiceResponseNOK(messageId, "Exchange service exception when registering plugin [ " + e.getMessage() + " ]");
        producer.sendEventBusMessage(response, register.getService().getServiceResponseMessageName());
    }
}
Also used : ExchangeModelMapperException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException) ServiceResponseType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType) ConfigServiceException(eu.europa.ec.fisheries.uvms.config.exception.ConfigServiceException) SettingType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType) SettingListType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Example 7 with SettingListType

use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType in project UVMS-ExchangeModule-APP by UnionVMS.

the class PluginServiceBean method updatePluginSetting.

private void updatePluginSetting(String serviceClassName, SettingType updatedSetting, String username) throws ExchangeServiceException, ExchangeModelMarshallException, ExchangeMessageException {
    SettingListType settingListType = new SettingListType();
    settingListType.getSetting().add(updatedSetting);
    ServiceResponseType service = exchangeService.upsertSettings(serviceClassName, settingListType, username);
    // Send the plugin settings to the topic where all plugins should listen to
    String text = ExchangePluginRequestMapper.createSetConfigRequest(service.getSettingList());
    producer.sendEventBusMessage(text, serviceClassName);
}
Also used : ServiceResponseType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType) SettingListType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType)

Example 8 with SettingListType

use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType in project UVMS-ExchangeModule-APP by UnionVMS.

the class MockData method getSettingList.

public static SettingListType getSettingList() {
    SettingListType dto = new SettingListType();
    SettingType setting = new SettingType();
    setting.setKey(SETTING_KEY);
    setting.setValue("setting.value");
    dto.getSetting().add(setting);
    return dto;
}
Also used : SettingType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType) SettingListType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType)

Example 9 with SettingListType

use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType 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());
}
Also used : CapabilityListType(eu.europa.ec.fisheries.schema.exchange.service.v1.CapabilityListType) ServiceType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceType) Service(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service) SettingListType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType) Test(org.junit.Test)

Example 10 with SettingListType

use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType in project UVMS-ExchangeModule-APP by UnionVMS.

the class MapperTest method testUpsert.

@Test
public void testUpsert() {
    String newValue = "NEW_VALUE";
    Service entity = MockData.getEntity(1);
    entity.setServiceCapabilityList(MockData.getEntityCapabilities(entity));
    entity.setServiceSettingList(MockData.getEntitySettings(entity));
    SettingListType updateSettings = new SettingListType();
    SettingType updateSetting = new SettingType();
    updateSetting.setKey(MockData.SETTING_KEY);
    updateSetting.setValue(newValue);
    updateSettings.getSetting().add(updateSetting);
    List<ServiceSetting> list = mapper.mapSettingsList(entity, updateSettings, "TEST");
    assertFalse(list.isEmpty());
    for (ServiceSetting setting : list) {
        assertSame(setting.getValue(), newValue);
    }
    SettingListType newSettings = new SettingListType();
    SettingType newSetting = new SettingType();
    newSetting.setKey("NEW.KEY");
    newSetting.setValue("NEW.VALUE");
    newSettings.getSetting().add(newSetting);
    list = mapper.mapSettingsList(entity, newSettings, "TEST");
    assertTrue(list.size() == 1);
}
Also used : Service(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service) SettingType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType) SettingListType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType) ServiceSetting(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting) Test(org.junit.Test)

Aggregations

SettingListType (eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType)8 ServiceResponseType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType)6 CapabilityListType (eu.europa.ec.fisheries.schema.exchange.service.v1.CapabilityListType)4 SettingType (eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType)4 Service (eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service)4 Test (org.junit.Test)4 ServiceType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceType)3 ServiceSetting (eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting)3 ExchangeServiceException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)3 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)2 ExchangeModelMapperException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException)2 ArrayList (java.util.ArrayList)2 ConfigServiceException (eu.europa.ec.fisheries.uvms.config.exception.ConfigServiceException)1 ServiceCapability (eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceCapability)1 HashMap (java.util.HashMap)1 Ignore (org.junit.Ignore)1