From 1137642a65efe412335fb03166b4de5e99e9bf09 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 17 Apr 2015 16:52:25 +0000 Subject: [PATCH] Updated Rules git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@114235 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gwtservice/server/SessionConstants.java | 100 ++++++------- .../td/gwtservice/server/SessionUtil.java | 39 +++++- .../gwtservice/server/TDGWTServiceImpl.java | 90 +++++++++++- .../server/storage/FilesStorage.java | 31 +++-- .../trservice/OperationDefinitionMap.java | 2 +- .../server/trservice/QueryService.java | 2 +- .../shared/rule/RuleDescriptionData.java | 131 ++++++++++++++++++ .../gwtservice/shared/rule/RuleScopeType.java | 37 +++++ .../rule/RulesOnColumnApplySession.java | 67 +++++++++ .../rule/type/TDBaseColumnRuleType.java | 41 ++++++ .../rule/type/TDDimensionColumnRuleType.java | 41 ++++++ .../shared/rule/type/TDRuleColumnType.java | 25 ++++ .../gwtservice/client/TestServiceColumn.java | 9 +- .../gwtservice/client/TestServiceTable.java | 9 +- 14 files changed, 539 insertions(+), 85 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/RuleDescriptionData.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/RuleScopeType.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/RulesOnColumnApplySession.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/type/TDBaseColumnRuleType.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/type/TDDimensionColumnRuleType.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/type/TDRuleColumnType.java diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionConstants.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionConstants.java index 9a2d5fc..658ddae 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionConstants.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionConstants.java @@ -2,120 +2,122 @@ package org.gcube.portlets.user.td.gwtservice.server; /** * - * @author "Giancarlo Panichi" - * email: g.panichi@isti.cnr.it + * @author "Giancarlo Panichi" email: g.panichi@isti.cnr.it * */ public class SessionConstants { public static final String SCOPE_TO_CURRENT_TRID_MAP = "SCOPE_TO_CURRENT_TRID_MAP"; public static final String SCOPE_TO_CURRENT_TABULAR_RESOURCE_MAP = "SCOPE_TO_CURRENT_TABULAR_RESOURCE_MAP"; public static final String SCOPE_TO_CURRENT_TABULAR_RESOURCES_OPEN_MAP = "SCOPE_TO_CURRENT_TABULAR_RESOURCES_OPEN_MAP"; - - public static final String SCOPE_TO_OPERATIONS_TASKS_STARTED_MAP="SCOPE_TO_OPERATIONS_TASKS_STARTED_MAP"; - public static final String SCOPE_TO_OPERATIONS_TASKS_IN_BACKGROUND_MAP="SCOPE_TO_OPERATIONS_TASKS_IN_BACKGROUND_MAP"; - public static final String SCOPE_TO_OPERATIONS_TASKS_ABORTED_MAP="SCOPE_TO_OPERATIONS_TASKS_ABORTED_MAP"; - public static final String SCOPE_TO_OPERATIONS_TASKS_HIDDEN_MAP="SCOPE_TO_OPERATIONS_TASKS_HIDDEN_MAP"; - + + public static final String SCOPE_TO_OPERATIONS_TASKS_STARTED_MAP = "SCOPE_TO_OPERATIONS_TASKS_STARTED_MAP"; + public static final String SCOPE_TO_OPERATIONS_TASKS_IN_BACKGROUND_MAP = "SCOPE_TO_OPERATIONS_TASKS_IN_BACKGROUND_MAP"; + public static final String SCOPE_TO_OPERATIONS_TASKS_ABORTED_MAP = "SCOPE_TO_OPERATIONS_TASKS_ABORTED_MAP"; + public static final String SCOPE_TO_OPERATIONS_TASKS_HIDDEN_MAP = "SCOPE_TO_OPERATIONS_TASKS_HIDDEN_MAP"; + public static final String SCOPE_TO_TABULAR_RESOURCE_LIST_MAP = "SCOPE_TO_TABULAR_RESOURCE_LIST_MAP"; - + public static final String TDOPEN_SESSION = "TDOPEN_SESSION"; - + public static final String FILE_UPLOAD_MONITOR = "FILE_UPLOAD_MONITOR"; public static final String TR_TASK_MANAGER = "TR_TASK_MANAGER"; public static final String SDMX_REGISTRY_SOURCE = "SDMX_REGISTRY_SOURCE"; - + public static final String SDMX_CLIENT_ATTRIBUTE = "SDMX_CLIENT"; public static final String SDMX_IMPORT_SESSION = "SDMX_IMPORT"; public static final String SDMX_IMPORT_TABULAR_RESOURCE = "SDMX_IMPORT_TABULAR_RESOURCE"; - + public static final String SDMX_EXPORT_SESSION = "SDMX_EXPORT_SESSION"; - + public static final String CSV_IMPORT_SESSION = "CSV_IMPORT"; public static final String CSV_IMPORT_FILE_UPLOAD_SESSION = "CSV_IMPORT_FILE_UPLOAD"; - public static final String CSV_IMPORT_TABULAR_RESOURCE = "CSV_IMPORT_TABULAR_RESOURCE"; - + public static final String CSV_IMPORT_TABULAR_RESOURCE = "CSV_IMPORT_TABULAR_RESOURCE"; + public static final String CSV_EXPORT_SESSION = "CSV_EXPORT_SESSION"; public static final String CSV_EXPORT_END = "CSV_EXPORT_END"; - + public static final String JSON_EXPORT_SESSION = "JSON_EXPORT_SESSION"; public static final String JSON_EXPORT_END = "JSON_EXPORT_END"; public static final String CLONE_TABULAR_RESOURCE_SESSION = "CLONE_TABULAR_RESOURCE_SESSION"; - + public static final String CHANGE_COLUMN_TYPE_SESSION = "CHANGE_COLUMN_TYPE_SESSION"; - + public static final String ADD_COLUMN_SESSION = "ADD_COLUMN_SESSION"; - + public static final String DELETE_COLUMN_SESSION = "DELETE_COLUMN_SESSION"; - + public static final String FILTER_COLUMN_SESSION = "FILTER_COLUMN_SESSION"; - + public static final String REPLACE_COLUMN_BY_EXPRESSION_SESSION = "REPLACE_COLUMN_BY_EXPRESSION_SESSION"; - + public static final String EDIT_ROW_SESSION = "EDIT_ROW_SESSION"; - + public static final String TASK_RESUBMIT_SESSION = "TASK_RESUBMIT_SESSION"; - + public static final String TASK_RESUME_SESSION = "TASK_RESUME_SESSION"; - + public static final String REPLACE_COLUMN_SESSION = "REPLACE_COLUMN_SESSION"; - + public static final String GROUPBY_SESSION = "GROUPBY_SESSION"; - + public static final String TIME_AGGREGATION_SESSION = "TIME_AGGREGATION_SESSION"; - + public static final String UNION_SESSION = "UNION_SESSION"; - + public static final String CHANGE_COLUMNS_POSITION_SESSION = "CHANGE_COLUMNS_POSITION_SESSION"; - + public static final String REPLACE_BY_EXTERNAL_SESSION = "REPLACE_BY_EXTERNAL_SESSION"; - + public static final String STATISTICAL_OPERATION_SESSION = "STATISTICAL_OPERATION_SESSION"; - + public static final String NORMALIZATION_SESSION = "NORMALIZATION_SESSION"; - + public static final String DENORMALIZATION_SESSION = "DENORMALIZATION_SESSION"; - + public static final String REPLACE_BATCH_COLUMN_SESSION = "REPLACE_BATCH_COLUMN_SESSION"; - + public static final String CHANGE_THE_COLUMN_LABEL_SESSION = "CHANGE_THE_COLUMN_LABEL_SESSION"; - + public static final String CHANGE_TABLE_TYPE_SESSION = "CHANGE_TABLE_TYPE_SESSION"; - + public static final String DELETE_ROWS_SESSION = "DELETE_ROWS_SESSION"; - + public static final String DUPLICATES_ROWS_SESSION = "DUPLICATES_ROWS_SESSION"; - + public static final String MAP_CREATION_SESSION = "MAP_CREATION_SESSION"; - + public static final String TEMPLATE_APPLY_SESSION = "TEMPLATE_APPLY_SESSION"; - + public static final String CODELISTS_PAGING_LOADED = "CODELISTS_PAGING_LOADED"; public static final String CODELISTS_PAGING_LOADED_FILTERED_COPY = "CODELISTS_PAGING_LOADED_FILTERED_COPY"; public static final String CODELISTS_PAGING_LOADED_FILTER = "CODELISTS_PAGING_LOADED_FILTER"; public static final String ROLLBACK_SESSION = "ROLLBACK_SESSION"; - + public static final String EXTRACT_CODELIST_SESSION = "EXTRACT_CODELIST_SESSION"; - + public static final String SPLIT_COLUMN_SESSION = "SPLIT_COLUMN_SESSION"; - + public static final String MERGE_COLUMN_SESSION = "MERGE_COLUMN_SESSION"; - + public static final String CODELIST_MAPPING_SESSION = "CODELIST_MAPPING_SESSION"; public static final String CODELIST_MAPPING_FILE_UPLOAD_SESSION = "CODELIST_MAPPING_FILE_UPLOAD_SESSION"; - + public static final String CHART_TOPRATING_SESSION = "CHART_TOPRATING_SESSION"; - + public static final String RESOURCE_SAVE_SESSION = "RESOURCE_SAVE_SESSION"; public static final String GEOSPATIAL_CREATE_COORDINATES_SESSION = "GEOSPATIAL_CREATE_COORDINATES_SESSION"; + public static final String GEOSPATIAL_DOWNSCALE_CSQUARE_SESSION = "GEOSPATIAL_DOWNSCALE_CSQUARE_SESSION"; - - + public static final String GEOMETRY_CREATE_POINT_SESSION = "GEOMETRY_CREATE_POINT_SESSION"; + public static final String RULES_ON_COLUMN_APPLY_SESSION = "RULES_ON_COLUMN_APPLY_SESSION"; + } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java index 0bfaf28..66db9d8 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java @@ -17,6 +17,7 @@ import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portlets.user.td.gwtservice.server.file.CSVFileUploadSession; import org.gcube.portlets.user.td.gwtservice.server.file.CodelistMappingFileUploadSession; import org.gcube.portlets.user.td.gwtservice.server.trservice.TRTasksManager; +import org.gcube.portlets.user.td.gwtservice.shared.Constants; import org.gcube.portlets.user.td.gwtservice.shared.chart.ChartTopRatingSession; import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession; @@ -30,6 +31,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.geospatial.GeospatialDownsca import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession; import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession; import org.gcube.portlets.user.td.gwtservice.shared.map.MapCreationSession; +import org.gcube.portlets.user.td.gwtservice.shared.rule.RulesOnColumnApplySession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession; import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource; @@ -87,10 +89,9 @@ public class SessionUtil { ASLSession session; if (username == null) { logger.warn("no user found in session, using test one"); - throw new TDGWTSessionExpiredException("Session Expired!"); + /*throw new TDGWTSessionExpiredException("Session Expired!");*/ // Remove comment for Test - /* username = Constants.DEFAULT_USER; String scope = Constants.DEFAULT_SCOPE; @@ -98,7 +99,7 @@ public class SessionUtil { session = SessionManager.getInstance().getASLSession( httpSession.getId(), username); session.setScope(scope); - */ + } else { session = SessionManager.getInstance().getASLSession( httpSession.getId(), username); @@ -1089,6 +1090,38 @@ public class SessionUtil { replaceColumnByExpressionSession); } + + + // + public static RulesOnColumnApplySession getRulesOnColumnApplySession( + HttpSession httpSession) { + RulesOnColumnApplySession rulesOnColumnApplySession = (RulesOnColumnApplySession) httpSession + .getAttribute(SessionConstants.RULES_ON_COLUMN_APPLY_SESSION); + if (rulesOnColumnApplySession != null) { + return rulesOnColumnApplySession; + } else { + rulesOnColumnApplySession = new RulesOnColumnApplySession(); + httpSession.setAttribute( + SessionConstants.RULES_ON_COLUMN_APPLY_SESSION, + rulesOnColumnApplySession); + return rulesOnColumnApplySession; + } + } + + public static void setRulesOnColumnApplySession( + HttpSession httpSession, + RulesOnColumnApplySession rulesOnColumnApplySession) { + RulesOnColumnApplySession rules = (RulesOnColumnApplySession) httpSession + .getAttribute(SessionConstants.RULES_ON_COLUMN_APPLY_SESSION); + if (rules != null) { + httpSession + .removeAttribute(SessionConstants.RULES_ON_COLUMN_APPLY_SESSION); + } + httpSession.setAttribute( + SessionConstants.RULES_ON_COLUMN_APPLY_SESSION, + rulesOnColumnApplySession); + + } // public static TaskResubmitSession getTaskResubmitSession( 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 a1bd94b..1687cc5 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 @@ -42,6 +42,7 @@ 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.utils.Licence; +import org.gcube.data.analysis.tabulardata.commons.webservice.exception.NoSuchTemplateException; import org.gcube.data.analysis.tabulardata.commons.webservice.types.TabularResourceType; import org.gcube.data.analysis.tabulardata.commons.webservice.types.TaskStatus; import org.gcube.data.analysis.tabulardata.commons.webservice.types.TemplateDescription; @@ -90,12 +91,12 @@ import org.gcube.data.analysis.tabulardata.model.table.TableId; import org.gcube.data.analysis.tabulardata.model.table.type.CodelistTableType; import org.gcube.data.analysis.tabulardata.model.time.PeriodType; import org.gcube.data.analysis.tabulardata.service.TabularDataService; -import org.gcube.data.analysis.tabulardata.service.exception.NoSuchTemplateException; import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory; import org.gcube.data.analysis.tabulardata.service.operation.Job; import org.gcube.data.analysis.tabulardata.service.operation.Task; import org.gcube.data.analysis.tabulardata.service.operation.TaskId; import org.gcube.data.analysis.tabulardata.service.operation.TaskResult; +import org.gcube.data.analysis.tabulardata.service.rules.RuleId; import org.gcube.data.analysis.tabulardata.service.tabular.HistoryStep; import org.gcube.data.analysis.tabulardata.service.tabular.HistoryStepId; import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource; @@ -192,6 +193,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.monitor.BackgroundOperationM import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitor; import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitorCreator; import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitorSession; +import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData; +import org.gcube.portlets.user.td.gwtservice.shared.rule.RulesOnColumnApplySession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession; import org.gcube.portlets.user.td.gwtservice.shared.share.Contacts; @@ -4872,7 +4875,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements * @param trId * @throws TDGWTServiceException */ - private void checkTRId(TRId trId) throws TDGWTServiceException { + protected void checkTRId(TRId trId) throws TDGWTServiceException { if (trId == null) { logger.error("TRId is null"); new TDGWTServiceException(NO_VALID_TABULAR_RESOURCE_ID_PRESENT); @@ -4890,7 +4893,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements * @param trId * @throws TDGWTServiceException */ - private void checkTabularResourceLocked(TabularResource tabularResource) + protected void checkTabularResourceLocked(TabularResource tabularResource) throws TDGWTServiceException { try { @@ -4915,7 +4918,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements * @param trId * @throws TDGWTServiceException */ - private void checkTabularResourceIsFinal(TabularResource tabularResource) + protected void checkTabularResourceIsFinal(TabularResource tabularResource) throws TDGWTServiceException { try { if (tabularResource.isFinalized()) { @@ -4939,7 +4942,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements * @param trId * @throws TDGWTServiceException */ - private void checkTabularResourceIsFlow(TabularResource tabularResource) + protected void checkTabularResourceIsFlow(TabularResource tabularResource) throws TDGWTServiceException { try { @@ -9382,5 +9385,82 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } } + + /** + * + * @param rulesOnColumnApplySession + * @param session + * @return + * @throws TDGWTServiceException + */ + public String startRulesOnColumnApply( + RulesOnColumnApplySession rulesOnColumnApplySession, + HttpSession session) throws TDGWTServiceException { + try { + // HttpSession session = this.getThreadLocalRequest().getSession(); + ASLSession aslSession = SessionUtil.getAslSession(session); + + SessionUtil.setRulesOnColumnApplySession(session, rulesOnColumnApplySession); + + if (rulesOnColumnApplySession == null) { + logger.error("RulesOnColumnApplySession is null"); + throw new TDGWTServiceException( + "Error in apply rules on column: RulesOnColumnApplySession is null"); + } + + AuthorizationProvider.instance.set(new AuthorizationToken( + aslSession.getUsername(), aslSession.getScope())); + TabularDataService service = TabularDataServiceFactory.getService(); + + checkTRId(rulesOnColumnApplySession.getTrId()); + + TabularResourceId tabularResourceId = new TabularResourceId( + Long.valueOf(rulesOnColumnApplySession + .getTrId().getId())); + TabularResource tabularResource = service + .getTabularResource(tabularResourceId); + + checkTabularResourceIsFlow(tabularResource); + checkTabularResourceLocked(tabularResource); + checkTabularResourceIsFinal(tabularResource); + + ColumnData column=rulesOnColumnApplySession.getColumn(); + if(column==null){ + logger.error("Error in apply rules on column: No column selected."); + throw new TDGWTServiceException( + "Error in apply rules on column: No column selected."); + } + + ArrayList rules=rulesOnColumnApplySession.getRules(); + ArrayList ruleIds=new ArrayList(); + for(RuleDescriptionData r:rules){ + RuleId ruleId=new RuleId(r.getId()); + ruleIds.add(ruleId); + } + + Task trTask = service.applyColumnRule(tabularResourceId, column.getColumnId(),ruleIds ); + logger.debug("Rules On Column Apply: TaskId " + + trTask.getId()); + + TaskWrapper taskWrapper = new TaskWrapper(trTask, + UIOperationsId.RuleOnColumnApply, + rulesOnColumnApplySession.getTrId()); + SessionUtil.setStartedTask(session, taskWrapper); + return trTask.getId().getValue(); + + } catch (TDGWTServiceException e) { + throw e; + } catch (SecurityException e) { + e.printStackTrace(); + throw new TDGWTServiceException(SECURITY_EXCEPTION_RIGHTS); + } catch (Throwable e) { + e.printStackTrace(); + throw new TDGWTServiceException( + "Error in apply rules on column: " + + e.getLocalizedMessage()); + } + + } + } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/storage/FilesStorage.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/storage/FilesStorage.java index 9fd910b..394b152 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/storage/FilesStorage.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/storage/FilesStorage.java @@ -6,9 +6,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.net.URL; import java.net.URLConnection; -import java.net.URLStreamHandler; import org.gcube.common.homelibrary.home.HomeLibrary; import org.gcube.common.homelibrary.home.workspace.Workspace; @@ -16,8 +14,7 @@ import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder; import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; import org.gcube.common.homelibrary.util.WorkspaceUtil; import org.gcube.contentmanagement.blobstorage.service.IClient; -import org.gcube.contentmanager.storageclient.model.protocol.smp.Handler; -import org.gcube.contentmanager.storageclient.model.protocol.smp.SMPURLConnection; +import org.gcube.contentmanager.storageclient.model.protocol.smp.SMPUrl; import org.gcube.contentmanager.storageclient.wrapper.AccessType; import org.gcube.contentmanager.storageclient.wrapper.MemoryType; import org.gcube.contentmanager.storageclient.wrapper.StorageClient; @@ -31,6 +28,7 @@ import org.slf4j.LoggerFactory; * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it * */ + public class FilesStorage { public static final Logger logger = LoggerFactory @@ -90,9 +88,11 @@ public class FilesStorage { try { org.gcube.common.homelibrary.home.workspace.folder.items.File gcubeItem = ((org.gcube.common.homelibrary.home.workspace.folder.items.File) wi); + SMPUrl smsHome= new SMPUrl(gcubeItem.getPublicLink()); + /* Handler.activateProtocol(); URL smsHome = null; - smsHome = new URL(gcubeItem.getPublicLink()); + smsHome = new URL(gcubeItem.getPublicLink());*/ logger.debug("smsHome: [host:" + smsHome.getHost() + " path:" + smsHome.getPath() + " ref:" + smsHome.getRef() + " userinfo:" + smsHome.getUserInfo() + " ]"); @@ -145,6 +145,9 @@ public class FilesStorage { try { org.gcube.common.homelibrary.home.workspace.folder.items.File gcubeItem = ((org.gcube.common.homelibrary.home.workspace.folder.items.File) wi); + SMPUrl smsHome= new SMPUrl(gcubeItem.getPublicLink()); + + /* Handler.activateProtocol(); URL smsHome = null; smsHome = new URL(null, gcubeItem.getPublicLink(), @@ -157,8 +160,7 @@ public class FilesStorage { } }); - - // new URL(gcubeItem.getPublicLink()); + */ logger.debug("smsHome: [host:" + smsHome.getHost() + " path:" + smsHome.getPath() + " ref:" + smsHome.getRef() + " userinfo:" + smsHome.getUserInfo() + " ]"); @@ -191,7 +193,9 @@ public class FilesStorage { throws TDGWTServiceException { InputStream is = null; try { - + + SMPUrl smsHome= new SMPUrl(uri); + /* Handler.activateProtocol(); URL smsHome = null; smsHome = new URL(null, uri, new URLStreamHandler() { @@ -202,7 +206,7 @@ public class FilesStorage { return new SMPURLConnection(u); } - }); + });*/ logger.debug("smsHome: [host:" + smsHome.getHost() + " path:" + smsHome.getPath() + " ref:" + smsHome.getRef() @@ -238,8 +242,10 @@ public class FilesStorage { InputStream is = null; try { - Handler.activateProtocol(); - URL smsHome = null; + SMPUrl smsHome= new SMPUrl(uri); + + /* + URL smsHome = new SMPUrl(); smsHome = new URL(null, uri, new URLStreamHandler() { @Override @@ -248,11 +254,12 @@ public class FilesStorage { return new SMPURLConnection(u); } - }); + });*/ logger.debug("smsHome: [host:" + smsHome.getHost() + " path:" + smsHome.getPath() + " ref:" + smsHome.getRef() + " userinfo:" + smsHome.getUserInfo() + " ]"); + URLConnection uc = null; uc = (URLConnection) smsHome.openConnection(); is = uc.getInputStream(); diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/OperationDefinitionMap.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/OperationDefinitionMap.java index 9e574b4..33a6e76 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/OperationDefinitionMap.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/OperationDefinitionMap.java @@ -1,8 +1,8 @@ package org.gcube.portlets.user.td.gwtservice.server.trservice; +import org.gcube.data.analysis.tabulardata.commons.webservice.exception.NoSuchOperationException; import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition; import org.gcube.data.analysis.tabulardata.service.TabularDataService; -import org.gcube.data.analysis.tabulardata.service.exception.NoSuchOperationException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/QueryService.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/QueryService.java index 0da61ec..4d7c43f 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/QueryService.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/QueryService.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.gcube.data.analysis.tabulardata.commons.webservice.exception.NoSuchTableException; import org.gcube.data.analysis.tabulardata.expression.Expression; import org.gcube.data.analysis.tabulardata.expression.composite.comparable.Equals; import org.gcube.data.analysis.tabulardata.model.column.Column; @@ -22,7 +23,6 @@ import org.gcube.data.analysis.tabulardata.query.parameters.select.QueryColumn; import org.gcube.data.analysis.tabulardata.query.parameters.select.QueryColumn.Function; import org.gcube.data.analysis.tabulardata.query.parameters.select.QuerySelect; import org.gcube.data.analysis.tabulardata.service.TabularDataService; -import org.gcube.data.analysis.tabulardata.service.exception.NoSuchTableException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException; import org.gcube.portlets.user.td.gwtservice.shared.tr.ConditionCode; import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurrences; diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/RuleDescriptionData.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/RuleDescriptionData.java new file mode 100644 index 0000000..2537378 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/RuleDescriptionData.java @@ -0,0 +1,131 @@ +package org.gcube.portlets.user.td.gwtservice.shared.rule; + +import java.io.Serializable; + +import org.gcube.portlets.user.td.gwtservice.shared.rule.type.TDRuleColumnType; +import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression; + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class RuleDescriptionData implements Serializable { + + private static final long serialVersionUID = 2238695825091799598L; + private long id; + private String name; + private String description; + private String owner; + private RuleScopeType scope; + private TDRuleColumnType tdRuleColumnType; + private C_Expression expression; + + public RuleDescriptionData() { + super(); + } + + public RuleDescriptionData(long id, String name, String description, String owner, + RuleScopeType scope, + C_Expression expression) { + super(); + this.id = id; + this.name = name; + this.description = description; + this.owner=owner; + this.scope = scope; + this.tdRuleColumnType = null; + this.expression = expression; + } + + + public RuleDescriptionData(long id, String name, String description,String owner, + RuleScopeType scope, TDRuleColumnType tdRuleColumnType, + C_Expression expression) { + super(); + this.id = id; + this.name = name; + this.description = description; + this.owner=owner; + this.scope = scope; + this.tdRuleColumnType = tdRuleColumnType; + this.expression = expression; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public RuleScopeType getScope() { + return scope; + } + + public void setScope(RuleScopeType scope) { + this.scope = scope; + } + + public TDRuleColumnType getTdRuleColumnType() { + return tdRuleColumnType; + } + + public void setTdRuleColumnType(TDRuleColumnType tdRuleColumnType) { + this.tdRuleColumnType = tdRuleColumnType; + } + + public C_Expression getExpression() { + return expression; + } + + public void setExpression(C_Expression expression) { + this.expression = expression; + } + + + public String getReadableExpression() { + if (expression != null) { + return expression.getReadableExpression(); + } else { + return ""; + } + } + + @Override + public String toString() { + return "RuleDescriptionData [id=" + id + ", name=" + name + + ", description=" + description + ", owner=" + owner + + ", scope=" + scope + ", tdRuleColumnType=" + tdRuleColumnType + + ", expression=" + expression + "]"; + } + + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/RuleScopeType.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/RuleScopeType.java new file mode 100644 index 0000000..9792a1a --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/RuleScopeType.java @@ -0,0 +1,37 @@ +package org.gcube.portlets.user.td.gwtservice.shared.rule; + + +/** + * + * @author giancarlo email: g.panichi@isti.cnr.it + * + */ +public enum RuleScopeType { + TABLE("Table"), COLUMN("Column"); + /** + * @param text + */ + private RuleScopeType(final String id) { + this.id = id; + } + + private final String id; + + @Override + public String toString() { + return id; + } + + + public static RuleScopeType get(String ruleScopeType) { + for(RuleScopeType ws:values()){ + if(ws.id.compareTo(ruleScopeType)==0){ + return ws; + } + } + + return null; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/RulesOnColumnApplySession.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/RulesOnColumnApplySession.java new file mode 100644 index 0000000..4374dec --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/RulesOnColumnApplySession.java @@ -0,0 +1,67 @@ +package org.gcube.portlets.user.td.gwtservice.shared.rule; + +import java.io.Serializable; +import java.util.ArrayList; + +import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; +import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData; + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class RulesOnColumnApplySession implements Serializable { + + private static final long serialVersionUID = -7746819321348425711L; + private TRId trId; + private ColumnData column; + private ArrayList rules; + + public RulesOnColumnApplySession() { + super(); + } + + public RulesOnColumnApplySession(TRId trId, ColumnData column, + ArrayList rules) { + super(); + this.trId = trId; + this.column = column; + this.rules = rules; + } + + public TRId getTrId() { + return trId; + } + + public void setTrId(TRId trId) { + this.trId = trId; + } + + public ColumnData getColumn() { + return column; + } + + public void setColumn(ColumnData column) { + this.column = column; + } + + public ArrayList getRules() { + return rules; + } + + public void setRules(ArrayList rules) { + this.rules = rules; + } + + @Override + public String toString() { + return "RulesOnColumnApplySession [trId=" + trId + ", column=" + column + + ", rules=" + rules + "]"; + } + + + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/type/TDBaseColumnRuleType.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/type/TDBaseColumnRuleType.java new file mode 100644 index 0000000..1711152 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/type/TDBaseColumnRuleType.java @@ -0,0 +1,41 @@ +package org.gcube.portlets.user.td.gwtservice.shared.rule.type; + +import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType; + +/** + * + * @author giancarlo + * email: g.panichi@isti.cnr.it + * + */ +public class TDBaseColumnRuleType extends TDRuleColumnType { + + private static final long serialVersionUID = -2967788094664606371L; + private ColumnDataType columnDataType; + + public TDBaseColumnRuleType(){ + super(); + } + + public TDBaseColumnRuleType(ColumnDataType columnDataType) { + super(); + this.columnDataType = columnDataType; + } + + public ColumnDataType getColumnDataType() { + return columnDataType; + } + + public void setColumnDataType(ColumnDataType columnDataType) { + this.columnDataType = columnDataType; + } + + @Override + public String toString() { + return "TDBaseColumnRuleType [columnDataType=" + columnDataType + "]"; + } + + + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/type/TDDimensionColumnRuleType.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/type/TDDimensionColumnRuleType.java new file mode 100644 index 0000000..206c15b --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/type/TDDimensionColumnRuleType.java @@ -0,0 +1,41 @@ +package org.gcube.portlets.user.td.gwtservice.shared.rule.type; + +import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.DimensionReferenceData; + +/** + * + * @author giancarlo email: g.panichi@isti.cnr.it + * + */ +public class TDDimensionColumnRuleType extends TDRuleColumnType { + + private static final long serialVersionUID = -2967788094664606371L; + private DimensionReferenceData dimensionReferenceData; + + public TDDimensionColumnRuleType() { + super(); + } + + public TDDimensionColumnRuleType( + DimensionReferenceData dimensionReferenceData) { + super(); + this.dimensionReferenceData = dimensionReferenceData; + } + + public DimensionReferenceData getDimensionReferenceData() { + return dimensionReferenceData; + } + + public void setDimensionReferenceData( + DimensionReferenceData dimensionReferenceData) { + this.dimensionReferenceData = dimensionReferenceData; + } + + @Override + public String toString() { + return "TDDimensionColumnRuleType [dimensionReferenceData=" + + dimensionReferenceData + "]"; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/type/TDRuleColumnType.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/type/TDRuleColumnType.java new file mode 100644 index 0000000..32ea37c --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/rule/type/TDRuleColumnType.java @@ -0,0 +1,25 @@ +package org.gcube.portlets.user.td.gwtservice.shared.rule.type; + +import java.io.Serializable; + + +/** + * + * @author giancarlo + * email: g.panichi@isti.cnr.it + * + */ +public class TDRuleColumnType implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 8230123565752504602L; + + public TDRuleColumnType(){ + + } + + + +} diff --git a/src/test/java/org/gcube/portlets/user/td/gwtservice/client/TestServiceColumn.java b/src/test/java/org/gcube/portlets/user/td/gwtservice/client/TestServiceColumn.java index f4dbdd7..c16e02e 100644 --- a/src/test/java/org/gcube/portlets/user/td/gwtservice/client/TestServiceColumn.java +++ b/src/test/java/org/gcube/portlets/user/td/gwtservice/client/TestServiceColumn.java @@ -3,13 +3,12 @@ package org.gcube.portlets.user.td.gwtservice.client; import org.gcube.common.scope.api.ScopeProvider; 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.exception.NoSuchTableException; +import org.gcube.data.analysis.tabulardata.commons.webservice.exception.NoSuchTabularResourceException; 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.table.Table; import org.gcube.data.analysis.tabulardata.service.TabularDataService; -import org.gcube.data.analysis.tabulardata.service.exception.InvalidTabularResourceException; -import org.gcube.data.analysis.tabulardata.service.exception.NoSuchTableException; -import org.gcube.data.analysis.tabulardata.service.exception.NoSuchTabularResourceException; import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory; import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId; import org.gcube.portlets.user.td.gwtservice.shared.Constants; @@ -44,10 +43,6 @@ public class TestServiceColumn { System.out.println("No such tabular resource with id: " + trId); e.printStackTrace(); return; - } catch (InvalidTabularResourceException e) { - System.out.println("Invalid tabular resource with id: " + trId); - e.printStackTrace(); - return; } catch (NoSuchTableException e) { System.out.println("No such last table for: " + trId); e.printStackTrace(); diff --git a/src/test/java/org/gcube/portlets/user/td/gwtservice/client/TestServiceTable.java b/src/test/java/org/gcube/portlets/user/td/gwtservice/client/TestServiceTable.java index 6cc5746..c87f8d0 100644 --- a/src/test/java/org/gcube/portlets/user/td/gwtservice/client/TestServiceTable.java +++ b/src/test/java/org/gcube/portlets/user/td/gwtservice/client/TestServiceTable.java @@ -3,12 +3,11 @@ package org.gcube.portlets.user.td.gwtservice.client; import org.gcube.common.scope.api.ScopeProvider; 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.exception.NoSuchTableException; +import org.gcube.data.analysis.tabulardata.commons.webservice.exception.NoSuchTabularResourceException; import org.gcube.data.analysis.tabulardata.model.table.Table; import org.gcube.data.analysis.tabulardata.model.table.TableId; import org.gcube.data.analysis.tabulardata.service.TabularDataService; -import org.gcube.data.analysis.tabulardata.service.exception.InvalidTabularResourceException; -import org.gcube.data.analysis.tabulardata.service.exception.NoSuchTableException; -import org.gcube.data.analysis.tabulardata.service.exception.NoSuchTabularResourceException; import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory; import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId; import org.gcube.portlets.user.td.gwtservice.shared.Constants; @@ -44,10 +43,6 @@ public class TestServiceTable { System.out.println("No such tabular resource with id: " + trId); e.printStackTrace(); return; - } catch (InvalidTabularResourceException e) { - System.out.println("Invalid tabular resource with id: " + trId); - e.printStackTrace(); - return; } catch (NoSuchTableException e) { System.out.println("No such last table for: " + trId); e.printStackTrace();