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 2f13332..be8df79 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 @@ -19,7 +19,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; -import java.lang.SecurityException; import javax.servlet.http.HttpSession; @@ -37,17 +36,14 @@ import org.gcube.common.resources.gcore.ServiceEndpoint.Profile; import org.gcube.common.resources.gcore.utils.Group; import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationProvider; import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken; - import org.gcube.data.analysis.tabulardata.commons.webservice.types.TaskStatus; import org.gcube.data.analysis.tabulardata.commons.webservice.types.TemplateDescription; import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition; import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution; import org.gcube.data.analysis.tabulardata.commons.webservice.types.tasks.ValidationDescriptor; -import org.gcube.data.analysis.tabulardata.expression.Expression; import org.gcube.data.analysis.tabulardata.metadata.NoSuchMetadataException; import org.gcube.data.analysis.tabulardata.model.column.Column; import org.gcube.data.analysis.tabulardata.model.column.ColumnLocalId; -import org.gcube.data.analysis.tabulardata.model.column.ColumnReference; import org.gcube.data.analysis.tabulardata.model.column.ColumnType; import org.gcube.data.analysis.tabulardata.model.column.type.AnnotationColumnType; import org.gcube.data.analysis.tabulardata.model.column.type.CodeColumnType; @@ -62,7 +58,6 @@ import org.gcube.data.analysis.tabulardata.model.metadata.column.DataLocaleMetad import org.gcube.data.analysis.tabulardata.model.metadata.column.ValidationReferencesMetadata; import org.gcube.data.analysis.tabulardata.model.metadata.column.ViewColumnMetadata; import org.gcube.data.analysis.tabulardata.model.metadata.common.DescriptionsMetadata; -import org.gcube.data.analysis.tabulardata.model.metadata.common.ImmutableLocalizedText; import org.gcube.data.analysis.tabulardata.model.metadata.common.LocalizedText; import org.gcube.data.analysis.tabulardata.model.metadata.common.NamesMetadata; import org.gcube.data.analysis.tabulardata.model.metadata.common.TableDescriptorMetadata; @@ -108,18 +103,19 @@ import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Code import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4DeleteColumn; import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4DeleteRows; import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Duplicates; +import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4EditRow; +import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ExtractCodelist; +import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4LabelColumn; +import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4MergeColumn; +import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ReplaceBatch; +import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ReplaceColumn; +import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4SplitColumn; import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecutionDirector; import org.gcube.portlets.user.td.gwtservice.server.storage.FilesStorage; -import org.gcube.portlets.user.td.gwtservice.server.trservice.ColumnDataTypeMap; -import org.gcube.portlets.user.td.gwtservice.server.trservice.ColumnTypeCodeMap; -import org.gcube.portlets.user.td.gwtservice.server.trservice.ExpressionGenerator; -import org.gcube.portlets.user.td.gwtservice.server.trservice.ExtractCodelistOperationMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.ExtractReferences; import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.QueryService; -import org.gcube.portlets.user.td.gwtservice.server.trservice.TDTypeValueMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.TaskStateMap; -import org.gcube.portlets.user.td.gwtservice.server.trservice.ValueMap; import org.gcube.portlets.user.td.gwtservice.shared.Constants; import org.gcube.portlets.user.td.gwtservice.shared.OperationsId; import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingMonitor; @@ -165,7 +161,6 @@ import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData; import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnViewData; -import org.gcube.portlets.user.td.gwtservice.shared.tr.DefNewColumn; import org.gcube.portlets.user.td.gwtservice.shared.tr.RefColumn; import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData; @@ -173,7 +168,6 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurrences; import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.OccurrencesForReplaceBatchColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnSession; -import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceEntry; import org.gcube.portlets.user.td.gwtservice.shared.tr.clone.CloneTabularResourceSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.AddColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.AddColumnSession; @@ -221,8 +215,6 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies; import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist; import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; -import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType; -import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode; import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.RelationshipData; import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.queries.api.SimpleQuery; @@ -3871,756 +3863,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } } - /** - * Retrieve OperationExecution for change column type - * - * @param changeColumnTypeSession - * @return - */ - protected OperationExecution retrieveOperationExecution( - TabularDataService service, - ChangeColumnTypeSession changeColumnTypeSession) - throws TDGWTServiceException { - - OperationExecution invocation = null; - - logger.debug(changeColumnTypeSession.toString()); - OperationDefinition operationDefinition; - Map map = new HashMap(); - - ColumnTypeCode type = changeColumnTypeSession.getColumnTypeCodeTarget(); - - switch (type) { - case ANNOTATION: - operationDefinition = OperationDefinitionMap.map( - OperationsId.ChangeToAnnotationColumn.toString(), service); - invocation = new OperationExecution(changeColumnTypeSession - .getColumnData().getColumnId(), - operationDefinition.getOperationId(), map); - break; - case ATTRIBUTE: - operationDefinition = OperationDefinitionMap.map( - OperationsId.ChangeToAttributeColumn.toString(), service); - - map.put(Constants.PARAMETER_TARGET_DATA_TYPE, ColumnDataTypeMap - .map(changeColumnTypeSession.getColumnDataTypeTarget())); - invocation = new OperationExecution(changeColumnTypeSession - .getColumnData().getColumnId(), - operationDefinition.getOperationId(), map); - break; - case CODE: - operationDefinition = OperationDefinitionMap.map( - OperationsId.ChangeToCodeColumn.toString(), service); - invocation = new OperationExecution(changeColumnTypeSession - .getColumnData().getColumnId(), - operationDefinition.getOperationId(), map); - break; - case CODEDESCRIPTION: - operationDefinition = OperationDefinitionMap.map( - OperationsId.ChangeToCodeDescription.toString(), service); - invocation = new OperationExecution(changeColumnTypeSession - .getColumnData().getColumnId(), - operationDefinition.getOperationId(), map); - break; - case CODENAME: - DataLocaleMetadata locale = new DataLocaleMetadata( - changeColumnTypeSession.getLocale()); - map.put(Constants.PARAMETER_ADDITIONAL_META, locale); - operationDefinition = OperationDefinitionMap.map( - OperationsId.ChangeToCodeName.toString(), service); - invocation = new OperationExecution(changeColumnTypeSession - .getColumnData().getColumnId(), - operationDefinition.getOperationId(), map); - break; - case DIMENSION: - operationDefinition = OperationDefinitionMap.map( - OperationsId.ChangeToDimensionColumn.toString(), service); - ColumnData col = changeColumnTypeSession - .getCodelistColumnReference(); - logger.debug("ReferenceColumn To Set: " + col); - ColumnLocalId cId = new ColumnLocalId(col.getColumnId()); - TRId trId = col.getTrId(); - logger.debug("trID: " + trId); - long tabId = new Long(trId.getTableId()); - TableId tId = new TableId(tabId); - ColumnReference columnReference = new ColumnReference(tId, cId); - map.put(Constants.PARAMETER_REFERENCE_COLUMN, columnReference); - - invocation = new OperationExecution(changeColumnTypeSession - .getColumnData().getColumnId(), - operationDefinition.getOperationId(), map); - break; - case MEASURE: - operationDefinition = OperationDefinitionMap.map( - OperationsId.ChangeToMeasureColumn.toString(), service); - - map.put(Constants.PARAMETER_TARGET_DATA_TYPE, ColumnDataTypeMap - .map(changeColumnTypeSession.getColumnDataTypeTarget())); - invocation = new OperationExecution(changeColumnTypeSession - .getColumnData().getColumnId(), - operationDefinition.getOperationId(), map); - break; - case TIMEDIMENSION: - operationDefinition = OperationDefinitionMap.map( - OperationsId.ChangeToTimeDimensionColumn.toString(), - service); - - map.put(Constants.PARAMETER_PERIOD_FORMAT, changeColumnTypeSession - .getTimeDimensionType().toString()); - invocation = new OperationExecution(changeColumnTypeSession - .getColumnData().getColumnId(), - operationDefinition.getOperationId(), map); - break; - default: - break; - - } - - return invocation; - } - - /** - * Retrieve OperationExecution for change column type - * - * @param replaceColumnSession - * @return - */ - protected OperationExecution retrieveOperationExecution( - TabularDataService service, - ReplaceColumnSession replaceColumnSession) - throws TDGWTServiceException { - - OperationExecution invocation = null; - - logger.debug(replaceColumnSession.toString()); - OperationDefinition operationDefinition; - Map map = new HashMap(); - - if (replaceColumnSession.isReplaceDimension()) { - logger.debug("Is a Replace of view column"); - operationDefinition = OperationDefinitionMap.map( - OperationsId.ReplaceColumnByExpression.toString(), service); - - Expression condition = ExpressionGenerator - .genReplaceValueParameterCondition(replaceColumnSession); - Expression value = ExpressionGenerator - .genReplaceValueParameterValue(replaceColumnSession); - - map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_CONDITION, - condition); - map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_VALUE, - value); - - invocation = new OperationExecution(replaceColumnSession - .getColumnData().getColumnViewData() - .getSourceTableDimensionColumnId(), - operationDefinition.getOperationId(), map); - - } else { - logger.debug("Is a Replace of basic column"); - - operationDefinition = OperationDefinitionMap.map( - OperationsId.ReplaceColumnByExpression.toString(), service); - - Expression condition = ExpressionGenerator - .genReplaceValueParameterCondition(replaceColumnSession); - Expression value = ExpressionGenerator - .genReplaceValueParameterValue(replaceColumnSession); - - map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_CONDITION, - condition); - map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_VALUE, - value); - - invocation = new OperationExecution(replaceColumnSession - .getColumnData().getColumnId(), - operationDefinition.getOperationId(), map); - } - - return invocation; - } - - /** - * Retrieve OperationExecution for change column type - * - * @param replaceColumnSession - * @return - */ - // TODO - protected OperationExecution retrieveOperationExecution( - TabularDataService service, - ExtractCodelistSession extractCodelistSession) - throws TDGWTServiceException { - - OperationExecution invocation = null; - - logger.debug(extractCodelistSession.toString()); - OperationDefinition operationDefinition; - - Map map = new HashMap(); - ExtractCodelistOperationMap extractMap = new ExtractCodelistOperationMap(); - ArrayList> compositeValue = extractMap - .genMap(extractCodelistSession); - - operationDefinition = OperationDefinitionMap.map( - OperationsId.ExtractCodelist.toString(), service); - - map.put(Constants.PARAMETER_EXTRACT_CODELIST_COMPOSITE, compositeValue); - - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); - - return invocation; - } - - /** - * Retrieve OperationExecution for change column type - * - * @param replaceColumnSession - * @return - */ - - protected OperationExecution retrieveOperationExecution( - TabularDataService service, EditRowSession editRowSession) - throws TDGWTServiceException { - - OperationExecution invocation = null; - - logger.debug(editRowSession.toString()); - OperationDefinition operationDefinition; - - Map map = new HashMap(); - ValueMap valueMap = new ValueMap(); - ArrayList> compositeValue = valueMap - .genValueMap(editRowSession); - - if (editRowSession.isNewRow()) { - logger.debug("Is a add row"); - operationDefinition = OperationDefinitionMap.map( - OperationsId.AddRow.toString(), service); - - map.put(Constants.PARAMETER_ADD_ROW_COMPOSITE, compositeValue); - - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); - - } else { - logger.debug("Is a edit row"); - - Expression exp = ExpressionGenerator.genEditRowParamaterCondition( - service, editRowSession); - - operationDefinition = OperationDefinitionMap.map( - OperationsId.ModifyTuplesValuesByExpression.toString(), - service); - - map.put(Constants.PARAMETER_ADD_ROW_COMPOSITE, compositeValue); - map.put(Constants.PARAMETER_EDIT_ROW_CONDITION, exp); - - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); - } - - return invocation; - } - - /** - * Retrieve OperationExecution for replaceBatch - * - * @param replaceColumnSession - * @return - */ - protected List retrieveOperationExecution( - TabularDataService service, - ReplaceBatchColumnSession replaceBatchColumnSession) - throws TDGWTServiceException { - - ArrayList invocations = new ArrayList(); - for (ReplaceEntry re : replaceBatchColumnSession.getReplaceEntryList()) { - - OperationExecution invocation = null; - - logger.debug(replaceBatchColumnSession.toString()); - OperationDefinition operationDefinition; - Map map = new HashMap(); - - if (replaceBatchColumnSession.isReplaceDimension()) { - logger.debug("Is a Replace of view column"); - operationDefinition = OperationDefinitionMap.map( - OperationsId.ReplaceColumnByExpression.toString(), - service); - - Expression condition = ExpressionGenerator - .genReplaceValueParameterCondition( - replaceBatchColumnSession, re); - Expression value = ExpressionGenerator - .genReplaceBatchValueParameterValue( - replaceBatchColumnSession, re); - - map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_CONDITION, - condition); - map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_VALUE, - value); - - invocation = new OperationExecution(replaceBatchColumnSession - .getColumnData().getColumnViewData() - .getSourceTableDimensionColumnId(), - operationDefinition.getOperationId(), map); - - } else { - logger.debug("Is a Replace of basic column"); - - operationDefinition = OperationDefinitionMap.map( - OperationsId.ReplaceColumnByExpression.toString(), - service); - - Expression condition = ExpressionGenerator - .genReplaceValueParameterCondition( - replaceBatchColumnSession, re); - Expression value = ExpressionGenerator - .genReplaceBatchValueParameterValue( - replaceBatchColumnSession, re); - - map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_CONDITION, - condition); - map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_VALUE, - value); - - invocation = new OperationExecution(replaceBatchColumnSession - .getColumnData().getColumnId(), - operationDefinition.getOperationId(), map); - } - invocations.add(invocation); - } - return invocations; - } - - /** - * - * @param service - * @param addColumnSession - * @return - * @throws TDGWTServiceException - */ - protected OperationExecution retrieveOperationExecution( - TabularDataService service, AddColumnSession addColumnSession) - throws TDGWTServiceException { - - logger.debug(addColumnSession.toString()); - - OperationExecution invocation = null; - - OperationDefinition operationDefinition = OperationDefinitionMap.map( - OperationsId.AddColumn.toString(), service); - - Map map = new HashMap(); - - DefNewColumn defNewColumn = addColumnSession.getColumn(); - - ColumnTypeCode type = defNewColumn.getColumnType(); - - switch (type) { - case ANNOTATION: - map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, - ColumnTypeCodeMap.getColumnType(defNewColumn - .getColumnType())); - map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, - ColumnDataTypeMap.map(ColumnDataType.Text)); - map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, - new ImmutableLocalizedText(defNewColumn.getLabel())); - map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, - TDTypeValueMap.map(ColumnDataType.Text, - defNewColumn.getDefaultValue())); - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); - break; - case ATTRIBUTE: - map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, - ColumnTypeCodeMap.getColumnType(defNewColumn - .getColumnType())); - map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, - ColumnDataTypeMap.map(defNewColumn.getColumnDataType())); - map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, - new ImmutableLocalizedText(defNewColumn.getLabel())); - map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, TDTypeValueMap.map( - defNewColumn.getColumnDataType(), - defNewColumn.getDefaultValue())); - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); - break; - case CODE: - map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, - ColumnTypeCodeMap.getColumnType(defNewColumn - .getColumnType())); - map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, - ColumnDataTypeMap.map(ColumnDataType.Text)); - map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, - new ImmutableLocalizedText(defNewColumn.getLabel())); - map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, - TDTypeValueMap.map(ColumnDataType.Text, - defNewColumn.getDefaultValue())); - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); - break; - case CODEDESCRIPTION: - map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, - ColumnTypeCodeMap.getColumnType(defNewColumn - .getColumnType())); - map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, - ColumnDataTypeMap.map(ColumnDataType.Text)); - map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, - new ImmutableLocalizedText(defNewColumn.getLabel())); - map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, - TDTypeValueMap.map(ColumnDataType.Text, - defNewColumn.getDefaultValue())); - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); - break; - case CODENAME: - map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, - ColumnTypeCodeMap.getColumnType(defNewColumn - .getColumnType())); - map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, - ColumnDataTypeMap.map(ColumnDataType.Text)); - map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, - new ImmutableLocalizedText(defNewColumn.getLabel())); - map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, - TDTypeValueMap.map(ColumnDataType.Text, - defNewColumn.getDefaultValue())); - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); - break; - case DIMENSION: - break; - case MEASURE: - map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, - ColumnTypeCodeMap.getColumnType(defNewColumn - .getColumnType())); - map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, - ColumnDataTypeMap.map(defNewColumn.getColumnDataType())); - map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, - new ImmutableLocalizedText(defNewColumn.getLabel())); - map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, TDTypeValueMap.map( - defNewColumn.getColumnDataType(), - defNewColumn.getDefaultValue())); - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); - break; - case TIMEDIMENSION: - break; - default: - break; - - } - - return invocation; - } - - /** - * - * @param service - * @param deleteColumnSession - * @return - * @throws TDGWTServiceException - */ - protected ArrayList retrieveOperationExecution( - TabularDataService service, DeleteColumnSession deleteColumnSession) - throws TDGWTServiceException { - - logger.debug(deleteColumnSession.toString()); - - OperationDefinition operationDefinition; - operationDefinition = OperationDefinitionMap.map( - OperationsId.RemoveColumn.toString(), service); - Map map = new HashMap(); - - ArrayList invocations = new ArrayList(); - for (ColumnData col : deleteColumnSession.getColumns()) { - - OperationExecution invocation = null; - - invocation = new OperationExecution(col.getColumnId(), - operationDefinition.getOperationId(), map); - invocations.add(invocation); - } - - return invocations; - } - - /** - * - * @param service - * @param duplicatesSession - * @return - * @throws TDGWTServiceException - */ - protected OperationExecution retrieveOperationExecution( - TabularDataService service, DuplicatesSession duplicatesSession) - throws TDGWTServiceException { - - OperationExecution invocation = null; - - logger.debug(duplicatesSession.toString()); - OperationDefinition operationDefinition; - Map map = new HashMap(); - - ArrayList cols = duplicatesSession.getColumns(); - logger.debug("ReferenceColumn To Set: " + cols); - ArrayList columnReferences = new ArrayList(); - - for (ColumnData col : cols) { - ColumnLocalId cId = new ColumnLocalId(col.getColumnId()); - TRId trId = col.getTrId(); - logger.debug("trID: " + trId); - long tabId = new Long(trId.getTableId()); - TableId tId = new TableId(tabId); - ColumnReference columnReference = new ColumnReference(tId, cId); - columnReferences.add(columnReference); - } - - switch (duplicatesSession.getDuplicateOp()) { - case VALIDATE: - operationDefinition = OperationDefinitionMap.map( - OperationsId.DuplicateTupleValidation.toString(), service); - - map.put(Constants.PARAMETER_KEY, columnReferences); - - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); - - break; - case DELETE: - operationDefinition = OperationDefinitionMap.map( - OperationsId.RemoveDuplicateTuples.toString(), service); - - map.put(Constants.PARAMETER_KEY, columnReferences); - - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); - - break; - default: - break; - - } - - return invocation; - } - - /** - * - * @param service - * @param labelColumnSession - * @return - * @throws TDGWTServiceException - */ - protected OperationExecution retrieveOperationExecution( - TabularDataService service, LabelColumnSession labelColumnSession) - throws TDGWTServiceException { - - OperationExecution invocation = null; - - logger.debug(labelColumnSession.toString()); - OperationDefinition operationDefinition; - Map map = new HashMap(); - - ImmutableLocalizedText localizedText = new ImmutableLocalizedText( - labelColumnSession.getLabel()); - - map.put(Constants.NAME_PARAMETER_ID, localizedText); - - operationDefinition = OperationDefinitionMap.map( - OperationsId.ColumnNameAdd.toString(), service); - - invocation = new OperationExecution(labelColumnSession.getColumnData() - .getColumnId(), operationDefinition.getOperationId(), map); - - return invocation; - } - - /** - * - * @param service - * @param changeTableTypeSession - * @return - * @throws TDGWTServiceException - */ - protected OperationExecution retrieveOperationExecution( - TabularDataService service, - ChangeTableTypeSession changeTableTypeSession) - throws TDGWTServiceException { - - OperationExecution invocation = null; - - logger.debug(changeTableTypeSession.toString()); - OperationDefinition operationDefinition; - Map map = new HashMap(); - - operationDefinition = OperationDefinitionMap.map( - OperationsId.ChangeTableType.toString(), service); - map.put(Constants.PARAMETER_TABLE_TYPE, changeTableTypeSession - .getTableType().toString()); - - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); - - return invocation; - } - - /** - * - * @param service - * @param changeTableTypeSession - * @return - * @throws TDGWTServiceException - */ - protected OperationExecution retrieveOperationExecution( - TabularDataService service, - CodelistMappingSession codelistMappingSession, String importUrl) - throws TDGWTServiceException { - - OperationExecution invocation = null; - - logger.debug(codelistMappingSession.toString()); - OperationDefinition operationDefinition; - Map map = new HashMap(); - - operationDefinition = OperationDefinitionMap.map( - OperationsId.CodelistMappingImport.toString(), service); - map.put(Constants.PARAMETER_URL, importUrl); - - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); - - return invocation; - } - - /** - * - * @param service - * @param changeTableTypeSession - * @return - * @throws TDGWTServiceException - */ - protected ArrayList retrieveOperationExecution( - TabularDataService service, SplitColumnSession splitColumnSession) - throws TDGWTServiceException { - - ArrayList invocations = new ArrayList(); - - logger.debug(splitColumnSession.toString()); - - OperationDefinition operationDefinition = OperationDefinitionMap.map( - OperationsId.AddColumn.toString(), service); - - Map map1 = new HashMap(); - Map map2 = new HashMap(); - - ArrayList expressions = splitColumnSession.getExpressions(); - - if (expressions == null || expressions.size() <= 1) { - throw new TDGWTServiceException( - "No valid expressions in splitColumnSession"); - } - - map1.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, ColumnTypeCodeMap - .getColumnType(splitColumnSession.getFirstSplitColumnType())); - map1.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, ColumnDataTypeMap - .map(splitColumnSession.getFirstSplitColumnDataType())); - map1.put(Constants.PARAMETER_ADD_COLUMN_LABEL, - new ImmutableLocalizedText(splitColumnSession.getLabel1())); - map1.put(Constants.PARAMETER_ADD_COLUMN_VALUE, expressions.get(0)); - invocations.add(new OperationExecution(operationDefinition - .getOperationId(), map1)); - map2.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, ColumnTypeCodeMap - .getColumnType(splitColumnSession.getSecondSplitColumnType())); - map2.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, ColumnDataTypeMap - .map(splitColumnSession.getSecondSplitColumnDataType())); - map2.put(Constants.PARAMETER_ADD_COLUMN_LABEL, - new ImmutableLocalizedText(splitColumnSession.getLabel2())); - map2.put(Constants.PARAMETER_ADD_COLUMN_VALUE, expressions.get(1)); - invocations.add(new OperationExecution(operationDefinition - .getOperationId(), map2)); - - return invocations; - } - - /** - * - * @param service - * @param changeTableTypeSession - * @return - * @throws TDGWTServiceException - */ - protected OperationExecution retrieveOperationExecution( - TabularDataService service, MergeColumnSession mergeColumnSession) - throws TDGWTServiceException { - - OperationExecution invocation = null; - - logger.debug(mergeColumnSession.toString()); - - OperationDefinition operationDefinition = OperationDefinitionMap.map( - OperationsId.AddColumn.toString(), service); - - Map map = new HashMap(); - - Expression expression = mergeColumnSession.getExpression(); - if (expression == null) { - throw new TDGWTServiceException( - "No valid expression in splitColumnSession"); - } - - map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, ColumnTypeCodeMap - .getColumnType(mergeColumnSession.getMergeColumnType())); - map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, ColumnDataTypeMap - .map(mergeColumnSession.getMergeColumnDataType())); - map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, - new ImmutableLocalizedText(mergeColumnSession.getLabel())); - map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, expression); - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); - - return invocation; - } - - /** - * - * @param service - * @param deleteRowsSession - * @return - * @throws TDGWTServiceException - */ - protected OperationExecution retrieveOperationExecution( - TabularDataService service, DeleteRowsSession deleteRowsSession) - throws TDGWTServiceException { - - OperationExecution invocation = null; - - logger.debug(deleteRowsSession.toString()); - OperationDefinition operationDefinition; - Map map = new HashMap(); - - ArrayList rows = deleteRowsSession.getRows(); - ArrayList rowsInt = new ArrayList(); - for (String r : rows) { - try { - Integer row = new Integer(r); - rowsInt.add(row); - } catch (NumberFormatException e) { - logger.error("Row:" + r + " is invalid Integer"); - } - } - operationDefinition = OperationDefinitionMap.map( - OperationsId.RemoveRowById.toString(), service); - map.put(Constants.PARAMETER_ROW_ID, rowsInt); - - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); - - return invocation; - } - + /** * * {@inheritDoc} @@ -5112,9 +4355,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements AuthorizationProvider.instance.set(new AuthorizationToken( aslSession.getUsername())); TabularDataService service = TabularDataServiceFactory.getService(); - - OperationExecution invocation = retrieveOperationExecution(service, - labelColumnSession); + + OpExecution4LabelColumn opEx=new OpExecution4LabelColumn(service, labelColumnSession); + OpExecutionDirector director=new OpExecutionDirector(); + director.setOperationExecutionBuilder(opEx); + director.constructOperationExecution(); + OperationExecution invocation = director.getOperationExecution(); + if (invocation == null) { throw new TDGWTServiceException( "Error Changing the Column Label: Operation not supported for now!"); @@ -6399,9 +5646,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements AuthorizationProvider.instance.set(new AuthorizationToken( aslSession.getUsername())); TabularDataService service = TabularDataServiceFactory.getService(); - - OperationExecution invocation = retrieveOperationExecution(service, - replaceColumnSession); + + OpExecution4ReplaceColumn opEx=new OpExecution4ReplaceColumn(service, replaceColumnSession); + OpExecutionDirector director=new OpExecutionDirector(); + director.setOperationExecutionBuilder(opEx); + director.constructOperationExecution(); + OperationExecution invocation = director.getOperationExecution(); + if (invocation == null) { throw new TDGWTServiceException( "Error Replace Column Value invocation: Operation not supported"); @@ -6560,8 +5811,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements aslSession.getUsername())); TabularDataService service = TabularDataServiceFactory.getService(); - List invocations = retrieveOperationExecution( - service, replaceBatchColumnSession); + OpExecution4ReplaceBatch opEx=new OpExecution4ReplaceBatch(service, replaceBatchColumnSession); + OpExecutionDirector director=new OpExecutionDirector(); + director.setOperationExecutionBuilder(opEx); + director.constructOperationExecution(); + + List invocations = director.getListOperationExecution(); + if (invocations == null) { throw new TDGWTServiceException("Operation not supported"); } @@ -7296,9 +6552,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements AuthorizationProvider.instance.set(new AuthorizationToken( aslSession.getUsername())); TabularDataService service = TabularDataServiceFactory.getService(); - - OperationExecution invocation = retrieveOperationExecution(service, - editRowSession); + + OpExecution4EditRow opEx=new OpExecution4EditRow(service, editRowSession); + OpExecutionDirector director=new OpExecutionDirector(); + director.setOperationExecutionBuilder(opEx); + director.constructOperationExecution(); + OperationExecution invocation = director.getOperationExecution(); + if (invocation == null) { throw new TDGWTServiceException( "Error in invocation: Operation not supported"); @@ -7791,9 +7051,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements AuthorizationProvider.instance.set(new AuthorizationToken( aslSession.getUsername())); TabularDataService service = TabularDataServiceFactory.getService(); - - OperationExecution invocation = retrieveOperationExecution(service, - extractCodelistSession); + + OpExecution4ExtractCodelist opEx=new OpExecution4ExtractCodelist(service, extractCodelistSession); + OpExecutionDirector director=new OpExecutionDirector(); + director.setOperationExecutionBuilder(opEx); + director.constructOperationExecution(); + OperationExecution invocation = director.getOperationExecution(); + if (invocation == null) { throw new TDGWTServiceException( "Error in invocation: Operation not supported"); @@ -7939,9 +7203,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements AuthorizationProvider.instance.set(new AuthorizationToken( aslSession.getUsername())); TabularDataService service = TabularDataServiceFactory.getService(); - - ArrayList invocations = retrieveOperationExecution( - service, splitColumnSession); + + OpExecution4SplitColumn opEx=new OpExecution4SplitColumn(service, splitColumnSession); + OpExecutionDirector director=new OpExecutionDirector(); + director.setOperationExecutionBuilder(opEx); + director.constructOperationExecution(); + ArrayList invocations = director.getListOperationExecution(); + if (invocations == null) { throw new TDGWTServiceException( "Error in invocation: Operation not supported"); @@ -8088,9 +7356,14 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements AuthorizationProvider.instance.set(new AuthorizationToken( aslSession.getUsername())); TabularDataService service = TabularDataServiceFactory.getService(); - - OperationExecution invocation = retrieveOperationExecution(service, - mergeColumnSession); + + OpExecution4MergeColumn opEx=new OpExecution4MergeColumn(service, mergeColumnSession); + OpExecutionDirector director=new OpExecutionDirector(); + director.setOperationExecutionBuilder(opEx); + director.constructOperationExecution(); + OperationExecution invocation = director.getOperationExecution(); + + if (invocation == null) { throw new TDGWTServiceException( "Error in invocation: Operation not supported");