bug4371 Adjustments in AbstractDataImportResponse hierarchy

This commit is contained in:
Benjamin Barth committed 2017-12-19 17:55:57 +01:00
1 parent ef08782408
commit df2edb9b6a
3 files changed
+34 -12

No files matched your search

@@ -17,6 +17,31 @@ class AbstractDataImportResponse extends JavaScriptObject {
private static final Logger logger = Logger.getLogger(AbstractDataImportResponse.class.getName());
/**
* Extracts {@link ErrorMessage}s contained in this {@link JavaScriptObject JavaScript object}'s <i>errors</i>
* field.
*
* @return the {@link List} of contained {@link ErrorMessage}s or an empty list if the <i>errors</i> field is
* <code>undefined</code> or empty
*
* @see #getJsObjectList(String)
*/
public final List<ErrorMessage> getErrors() {
return getJsObjectList("errors");
}
/**
* Checks if this {@link JavaScriptObject JavaScript object} contained errors.
*
* @return <code>true</code> if the {@link #getErrors() error list} is neither <code>null</code> nor empty,
* <code>false</code> otherwise
* @see #getErrors()
*/
public final boolean hasErrors() {
final List<ErrorMessage> errors = getErrors();
return errors != null && !errors.isEmpty();
}
/**
* {@link JSONParser#parseStrict(String) Strictly parses} the provided {@link String} representation into JSON and
* {@link JavaScriptObject#cast() casts} it to the desired type.
@@ -11,7 +11,7 @@ public class ExpeditionDataImportResponse extends AbstractDataImportResponse {
protected ExpeditionDataImportResponse() {
}
public final UUID getEventId() {
return UUID.fromString(getString("eventId"));
}
@@ -39,17 +39,22 @@ public class ExpeditionDataImportResponse extends AbstractDataImportResponse {
public final native String getFleetName() /*-{
return this.fleetName;
}-*/;
public final List<String> getGpsDeviceIds() {
return getStringList("gpsDeviceIds");
}
public final List<String> getSensorDeviceIds() {
return getStringList("sensorDeviceIds");
}
public final native String getSensorFixImporterType() /*-{
return this.sensorFixImporterType;
}-*/;
public final boolean hasEventId() {
final String stringValue = getString("eventId");
return stringValue != null && !stringValue.isEmpty();
}
}
@@ -15,17 +15,9 @@ public class SensorDataImportResponse extends AbstractDataImportResponse {
return getStringList("uploads");
}
public final List<ErrorMessage> getErrors() {
return getJsObjectList("errors");
}
public final boolean didSucceedImportingAnyFile() {
return getUploads() != null && !getUploads().isEmpty();
}
public final boolean hasErrors() {
final List<ErrorMessage> errors = getErrors();
return errors != null && !errors.isEmpty();
}
}