Fixed Geometry Validation
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@112206 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ddc0afa3c7
commit
ff146461b9
|
@ -8806,7 +8806,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
OpExecutionDirector director = new OpExecutionDirector();
|
OpExecutionDirector director = new OpExecutionDirector();
|
||||||
director.setOperationExecutionBuilder(opEx);
|
director.setOperationExecutionBuilder(opEx);
|
||||||
director.constructOperationExecution();
|
director.constructOperationExecution();
|
||||||
OperationExecution invocation = director.getOperationExecution();
|
|
||||||
|
ArrayList<OperationExecution> invocation = director
|
||||||
|
.getListOperationExecution();
|
||||||
|
|
||||||
if (invocation == null) {
|
if (invocation == null) {
|
||||||
throw new TDGWTServiceException(
|
throw new TDGWTServiceException(
|
||||||
|
@ -8814,7 +8816,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||||
Task trTask = service.execute(invocation, tabularResourceId);
|
Task trTask = service.executeBatch(invocation, tabularResourceId);
|
||||||
logger.debug("GeometryCreatePoint on service: TaskId "
|
logger.debug("GeometryCreatePoint on service: TaskId "
|
||||||
+ trTask.getId());
|
+ trTask.getId());
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.gcube.portlets.user.td.gwtservice.server.opexecution;
|
package org.gcube.portlets.user.td.gwtservice.server.opexecution;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -26,6 +27,10 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.operations.Operations
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import static org.gcube.data.analysis.tabulardata.expression.dsl.Comparators.*;
|
||||||
|
import static org.gcube.data.analysis.tabulardata.expression.dsl.Logicals.*;
|
||||||
|
import static org.gcube.data.analysis.tabulardata.expression.dsl.Types.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operation Execution for change table type
|
* Operation Execution for change table type
|
||||||
*
|
*
|
||||||
|
@ -34,6 +39,8 @@ import org.slf4j.LoggerFactory;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class OpExecution4GeometryCreatePoint extends OpExecutionBuilder {
|
public class OpExecution4GeometryCreatePoint extends OpExecutionBuilder {
|
||||||
|
|
||||||
|
|
||||||
protected static Logger logger = LoggerFactory
|
protected static Logger logger = LoggerFactory
|
||||||
.getLogger(OpExecution4GeometryCreatePoint.class);
|
.getLogger(OpExecution4GeometryCreatePoint.class);
|
||||||
|
|
||||||
|
@ -49,12 +56,10 @@ public class OpExecution4GeometryCreatePoint extends OpExecutionBuilder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildOpEx() throws TDGWTServiceException {
|
public void buildOpEx() throws TDGWTServiceException {
|
||||||
OperationExecution invocation = null;
|
|
||||||
|
|
||||||
logger.debug(geometryCreatePointSession.toString());
|
logger.debug(geometryCreatePointSession.toString());
|
||||||
OperationDefinition operationDefinition;
|
ArrayList<OperationExecution> invocations = new ArrayList<OperationExecution>();
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
|
||||||
|
|
||||||
|
//Retrieve longitude and latitude
|
||||||
TRId trId = geometryCreatePointSession.getTrId();
|
TRId trId = geometryCreatePointSession.getTrId();
|
||||||
logger.debug("trID: " + trId);
|
logger.debug("trID: " + trId);
|
||||||
if (trId == null) {
|
if (trId == null) {
|
||||||
|
@ -94,10 +99,33 @@ public class OpExecution4GeometryCreatePoint extends OpExecutionBuilder {
|
||||||
longitudeId);
|
longitudeId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Validations
|
||||||
|
OperationDefinition operationValidation;
|
||||||
|
Map<String, Object> validationParameters = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
operationValidation = OperationDefinitionMap.map(
|
||||||
|
OperationsId.ExpressionValidation.toString(), service);
|
||||||
|
|
||||||
|
validationParameters.put(Constants.PARAMETER_EXPRESSION_VALIDATION_TITLE, "Coordinates validation");
|
||||||
|
String description = new String("Longitude value must be between [-180, 180], Latitude value must be between [-90, 90]");
|
||||||
|
Expression expression = and(lessEq(longitudeColumnReference, numeric(180)), greaterEq(longitudeColumnReference, numeric(-180)), lessEq(latitudeColumnReference, numeric(90)), greaterEq(latitudeColumnReference, numeric(-90)));
|
||||||
|
validationParameters.put(Constants.PARAMETER_EXPRESSION_VALIDATION_DESCRIPTION, description);
|
||||||
|
validationParameters.put(Constants.PARAMETER_EXPRESSION_VALIDATION_EXPRESSION, expression);
|
||||||
|
|
||||||
|
invocations.add(new OperationExecution(
|
||||||
|
operationValidation.getOperationId(), validationParameters));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Add Column
|
||||||
Expression point = new Cast(new Concat(new TDText("POINT("), new Concat(
|
Expression point = new Cast(new Concat(new TDText("POINT("), new Concat(
|
||||||
longitudeColumnReference, new Concat(new TDText(" "),
|
longitudeColumnReference, new Concat(new TDText(" "),
|
||||||
new Concat(latitudeColumnReference, new TDText(")"))))),new GeometryType());
|
new Concat(latitudeColumnReference, new TDText(")"))))),new GeometryType());
|
||||||
|
|
||||||
|
OperationDefinition operationDefinition;
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
|
||||||
operationDefinition = OperationDefinitionMap.map(
|
operationDefinition = OperationDefinitionMap.map(
|
||||||
OperationsId.AddColumn.toString(), service);
|
OperationsId.AddColumn.toString(), service);
|
||||||
|
|
||||||
|
@ -108,10 +136,11 @@ public class OpExecution4GeometryCreatePoint extends OpExecutionBuilder {
|
||||||
new ImmutableLocalizedText(geometryCreatePointSession
|
new ImmutableLocalizedText(geometryCreatePointSession
|
||||||
.getColumnLabel()));
|
.getColumnLabel()));
|
||||||
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, point);
|
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, point);
|
||||||
invocation = new OperationExecution(
|
invocations.add(new OperationExecution(
|
||||||
operationDefinition.getOperationId(), map);
|
operationDefinition.getOperationId(), map));
|
||||||
|
|
||||||
operationExecutionSpec.setOp(invocation);
|
//Set ops
|
||||||
|
operationExecutionSpec.setOps(invocations);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,5 +117,9 @@ public class Constants {
|
||||||
public static final String PARAMETER_GEOSPATIAL_CREATE_COORDINATES_RESOLUTION = "resolution";
|
public static final String PARAMETER_GEOSPATIAL_CREATE_COORDINATES_RESOLUTION = "resolution";
|
||||||
public static final String PARAMETER_GEOSPATIAL_CREATE_COORDINATES_USER = "user";
|
public static final String PARAMETER_GEOSPATIAL_CREATE_COORDINATES_USER = "user";
|
||||||
public static final String PARAMETER_GEOSPATIAL_CREATE_COORDINATES_QUADRANT = "quadrant";
|
public static final String PARAMETER_GEOSPATIAL_CREATE_COORDINATES_QUADRANT = "quadrant";
|
||||||
|
|
||||||
|
public static final String PARAMETER_EXPRESSION_VALIDATION_EXPRESSION = "expression";
|
||||||
|
public static final String PARAMETER_EXPRESSION_VALIDATION_DESCRIPTION = "description";
|
||||||
|
public static final String PARAMETER_EXPRESSION_VALIDATION_TITLE = "title";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue