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;
}
Aggregations