diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java index d835c63..cf543ce 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java @@ -8806,7 +8806,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements OpExecutionDirector director = new OpExecutionDirector(); director.setOperationExecutionBuilder(opEx); director.constructOperationExecution(); - OperationExecution invocation = director.getOperationExecution(); + + ArrayList invocation = director + .getListOperationExecution(); if (invocation == null) { throw new TDGWTServiceException( @@ -8814,7 +8816,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } logger.debug("OperationInvocation: \n" + invocation.toString()); - Task trTask = service.execute(invocation, tabularResourceId); + Task trTask = service.executeBatch(invocation, tabularResourceId); logger.debug("GeometryCreatePoint on service: TaskId " + trTask.getId()); diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4GeometryCreatePoint.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4GeometryCreatePoint.java index dc53581..2409c9f 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4GeometryCreatePoint.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4GeometryCreatePoint.java @@ -1,5 +1,6 @@ package org.gcube.portlets.user.td.gwtservice.server.opexecution; +import java.util.ArrayList; import java.util.HashMap; 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.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 * @@ -34,6 +39,8 @@ import org.slf4j.LoggerFactory; * */ public class OpExecution4GeometryCreatePoint extends OpExecutionBuilder { + + protected static Logger logger = LoggerFactory .getLogger(OpExecution4GeometryCreatePoint.class); @@ -49,12 +56,10 @@ public class OpExecution4GeometryCreatePoint extends OpExecutionBuilder { @Override public void buildOpEx() throws TDGWTServiceException { - OperationExecution invocation = null; - logger.debug(geometryCreatePointSession.toString()); - OperationDefinition operationDefinition; - Map map = new HashMap(); + ArrayList invocations = new ArrayList(); + //Retrieve longitude and latitude TRId trId = geometryCreatePointSession.getTrId(); logger.debug("trID: " + trId); if (trId == null) { @@ -94,10 +99,33 @@ public class OpExecution4GeometryCreatePoint extends OpExecutionBuilder { longitudeId); + + //Validations + OperationDefinition operationValidation; + Map validationParameters = new HashMap(); + + 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( longitudeColumnReference, new Concat(new TDText(" "), new Concat(latitudeColumnReference, new TDText(")"))))),new GeometryType()); - + + OperationDefinition operationDefinition; + Map map = new HashMap(); + operationDefinition = OperationDefinitionMap.map( OperationsId.AddColumn.toString(), service); @@ -108,10 +136,11 @@ public class OpExecution4GeometryCreatePoint extends OpExecutionBuilder { new ImmutableLocalizedText(geometryCreatePointSession .getColumnLabel())); map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, point); - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); - - operationExecutionSpec.setOp(invocation); + invocations.add(new OperationExecution( + operationDefinition.getOperationId(), map)); + + //Set ops + operationExecutionSpec.setOps(invocations); } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java index 3b6c7d5..940ab18 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java @@ -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_USER = "user"; 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"; }