mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-25 06:58:39 +00:00
remove conversion from DTO classesl
This commit is contained in:
+4
-3
@@ -423,6 +423,7 @@ import com.sap.sse.filestorage.FileStorageService;
|
||||
import com.sap.sse.filestorage.InvalidPropertiesException;
|
||||
import com.sap.sse.filestorage.dto.FileStorageServiceDTO;
|
||||
import com.sap.sse.filestorage.dto.PropertyErrors;
|
||||
import com.sap.sse.filestorage.impl.FileStorageServiceDTOUtils;
|
||||
import com.sap.sse.replication.OperationWithResult;
|
||||
import com.sap.sse.replication.ReplicationFactory;
|
||||
import com.sap.sse.replication.ReplicationMasterDescriptor;
|
||||
@@ -5433,7 +5434,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
public FileStorageServiceDTO[] getAvailableFileStorageServices() {
|
||||
List<FileStorageServiceDTO> serviceDtos = new ArrayList<>();
|
||||
for (FileStorageService s : getService().getFileStorageManagementService().getAvailableFileStorageServices()) {
|
||||
serviceDtos.add(FileStorageServiceDTO.convert(s));
|
||||
serviceDtos.add(FileStorageServiceDTOUtils.convert(s));
|
||||
}
|
||||
return serviceDtos.toArray(new FileStorageServiceDTO[0]);
|
||||
}
|
||||
@@ -5451,7 +5452,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
try {
|
||||
getFileStorageService(serviceName).testProperties();
|
||||
} catch (InvalidPropertiesException e) {
|
||||
return new PropertyErrors(e);
|
||||
return FileStorageServiceDTOUtils.convert(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -5461,7 +5462,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
try {
|
||||
getService().getFileStorageManagementService().setActiveFileStorageService(getFileStorageService(serviceName));
|
||||
} catch (InvalidPropertiesException e) {
|
||||
return new PropertyErrors(e);
|
||||
return FileStorageServiceDTOUtils.convert(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
-13
@@ -1,11 +1,6 @@
|
||||
package com.sap.sse.filestorage.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sse.filestorage.FileStorageService;
|
||||
import com.sap.sse.filestorage.Property;
|
||||
|
||||
public class FileStorageServiceDTO implements Serializable {
|
||||
private static final long serialVersionUID = 6101940297792100418L;
|
||||
@@ -22,12 +17,4 @@ public class FileStorageServiceDTO implements Serializable {
|
||||
this.description = description;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public static FileStorageServiceDTO convert(FileStorageService s) {
|
||||
List<PropertyDTO> pDtos = new ArrayList<>();
|
||||
for (Property p : s.getProperties()) {
|
||||
pDtos.add(PropertyDTO.convert(p));
|
||||
}
|
||||
return new FileStorageServiceDTO(s.getName(), s.getDescription(), pDtos.toArray(new PropertyDTO[0]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ package com.sap.sse.filestorage.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sap.sse.filestorage.Property;
|
||||
|
||||
public class PropertyDTO implements Serializable {
|
||||
private static final long serialVersionUID = -2721807793068803143L;
|
||||
public boolean isRequired;
|
||||
@@ -21,8 +19,4 @@ public class PropertyDTO implements Serializable {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public static PropertyDTO convert(Property p) {
|
||||
return new PropertyDTO(p.isRequired(), p.getName(), p.getValue(), p.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,19 @@
|
||||
package com.sap.sse.filestorage.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.sap.sse.filestorage.InvalidPropertiesException;
|
||||
import com.sap.sse.filestorage.Property;
|
||||
|
||||
public class PropertyErrors implements Serializable {
|
||||
private static final long serialVersionUID = -7328897153875728802L;
|
||||
public Map<PropertyDTO, String> perPropertyMessages = new HashMap<>();
|
||||
public Map<PropertyDTO, String> perPropertyMessages;
|
||||
public String message;
|
||||
|
||||
// for GWT
|
||||
PropertyErrors() {
|
||||
}
|
||||
|
||||
public PropertyErrors(InvalidPropertiesException e) {
|
||||
message = e.getMessage();
|
||||
for (Entry<Property, String> entry : e.getPerPropertyMessage().entrySet()) {
|
||||
this.perPropertyMessages.put(PropertyDTO.convert(entry.getKey()), entry.getValue());
|
||||
}
|
||||
public PropertyErrors(String message, Map<PropertyDTO, String> perPropertyMessages) {
|
||||
this.message = message;
|
||||
this.perPropertyMessages = perPropertyMessages;
|
||||
}
|
||||
}
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.sap.sse.filestorage.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.sap.sse.filestorage.FileStorageService;
|
||||
import com.sap.sse.filestorage.InvalidPropertiesException;
|
||||
import com.sap.sse.filestorage.Property;
|
||||
import com.sap.sse.filestorage.dto.FileStorageServiceDTO;
|
||||
import com.sap.sse.filestorage.dto.PropertyDTO;
|
||||
import com.sap.sse.filestorage.dto.PropertyErrors;
|
||||
|
||||
public class FileStorageServiceDTOUtils {
|
||||
public static PropertyDTO convert(Property p) {
|
||||
return new PropertyDTO(p.isRequired(), p.getName(), p.getValue(), p.getDescription());
|
||||
}
|
||||
|
||||
public static PropertyErrors convert(InvalidPropertiesException e) {
|
||||
Map<PropertyDTO, String> msgs = new HashMap<>();
|
||||
for (Entry<Property, String> entry : e.getPerPropertyMessage().entrySet()) {
|
||||
msgs.put(convert(entry.getKey()), entry.getValue());
|
||||
}
|
||||
return new PropertyErrors(e.getMessage(), msgs);
|
||||
}
|
||||
|
||||
public static FileStorageServiceDTO convert(FileStorageService s) {
|
||||
List<PropertyDTO> pDtos = new ArrayList<>();
|
||||
for (Property p : s.getProperties()) {
|
||||
pDtos.add(convert(p));
|
||||
}
|
||||
return new FileStorageServiceDTO(s.getName(), s.getDescription(), pDtos.toArray(new PropertyDTO[0]));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user