Search in sources :

Example 11 with SettingListType

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

the class ServiceMapper method mapSettingsList.

public static List<ServiceSetting> mapSettingsList(Service parent, SettingListType settingList, String username) {
    List<ServiceSetting> newSettings = new ArrayList<>();
    List<ServiceSetting> currentSettings = parent.getServiceSettingList();
    Map<String, ServiceSetting> map = new HashMap<>();
    if (currentSettings != null) {
        for (ServiceSetting i : currentSettings) {
            map.put(i.getSetting(), i);
        }
    }
    for (SettingType setting : settingList.getSetting()) {
        ServiceSetting currentSetting = map.get(setting.getKey());
        if (currentSetting == null) {
            ServiceSetting newSetting = toSettingEntity(parent, setting, username);
            newSettings.add(newSetting);
        } else {
            if (!currentSetting.getValue().equalsIgnoreCase(setting.getValue())) {
                currentSetting.setValue(setting.getValue());
                currentSetting.setUpdatedTime(DateUtils.nowUTC().toDate());
                currentSetting.setUser(username);
            }
            newSettings.add(currentSetting);
        }
    }
    return newSettings;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SettingType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType) ServiceSetting(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting)

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