From 182f35c4063ee2e64d56067ec938e50965f15c33 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Wed, 9 Apr 2014 13:22:08 +0000 Subject: [PATCH] Minor Update git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@94620 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gwtservice/server/TDGWTServiceImpl.java | 66 +++++++++++++++++-- .../server/trservice/ExpressionGenerator.java | 16 ++++- .../server/trservice/QueryService.java | 21 ++++-- .../shared/operation/Operation.java | 45 +++++++++++++ 4 files changed, 133 insertions(+), 15 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/shared/operation/Operation.java 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 b1869a6..d1072b3 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 @@ -74,6 +74,7 @@ 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.Task; +import org.gcube.data.analysis.tabulardata.service.tabular.HistoryStep; import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource; import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId; import org.gcube.data.analysis.tabulardata.service.tabular.metadata.AgencyMetadata; @@ -108,6 +109,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceExcept import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor; import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadState; import org.gcube.portlets.user.td.gwtservice.shared.file.HeaderPresence; +import org.gcube.portlets.user.td.gwtservice.shared.operation.Operation; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportMonitor; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportMonitor; @@ -348,8 +350,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } /** - * Returns ArrayList other than IdColumnType, - * ValidationColumnType, DimensionColumnType and TimeDimensionColumnType + * Returns ArrayList other than IdColumnType and + * ValidationColumnType * * {@inheritDoc} */ @@ -377,11 +379,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements List cols = table.getColumns(); int i = 0; + //|| c.getColumnType() instanceof DimensionColumnType + //|| c.getColumnType() instanceof TimeDimensionColumnType for (Column c : cols) { if (c.getColumnType() instanceof IdColumnType || c.getColumnType() instanceof ValidationColumnType - || c.getColumnType() instanceof DimensionColumnType - || c.getColumnType() instanceof TimeDimensionColumnType) { + ) { } else { if (c.contains(ViewColumnMetadata.class)) { @@ -484,9 +487,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements int i = 0; for (Column c : cols) { if (c.getColumnType() instanceof IdColumnType - || c.getColumnType() instanceof ValidationColumnType - || c.getColumnType() instanceof DimensionColumnType - || c.getColumnType() instanceof TimeDimensionColumnType) { + || c.getColumnType() instanceof ValidationColumnType) { } else { if (c.contains(ViewColumnMetadata.class)) { @@ -5644,5 +5645,56 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } } + + + /** + * + * OperationInfo + */ + public Operation getLastOperationInfo() throws TDGWTServiceException { + try { + HttpSession session = this.getThreadLocalRequest().getSession(); + ASLSession aslSession = SessionUtil.getAslSession(session); + + logger.debug("getLastDiscardOperation()"); + TabResource currentTR = SessionUtil.getTabResource(session); + if (currentTR == null) { + logger.error("CURRENT_TABULAR_RESOURCE is null"); + throw new TDGWTServiceException( + "CURRENT_TABULAR_RESOURCE is null"); + } + TRId trId = currentTR.getTrId(); + + AuthorizationProvider.instance.set(new AuthorizationToken( + aslSession.getUsername())); + TabularDataService service = TabularDataServiceFactory.getService(); + + TabularResourceId tabularResourceId=new TabularResourceId(Long.valueOf(trId.getId())); + TabularResource tabularResource=service.getTabularResource(tabularResourceId); + List history =tabularResource.getHistory(); + OperationDefinition lastOp=null; + if(history!=null && history.size()>0){ + HistoryStep lastStep=history.get(0); + if(lastStep!=null){ + lastOp=service.getCapability(lastStep.getOperationInvocation().getOperationId()); + } + + } + Operation op=null; + if(lastOp!=null){ + op=new Operation(lastOp.getName(),lastOp.getDescription()); + } + logger.debug("Last Operation Info :" + op); + return op; + + } catch (Throwable e) { + logger.debug("getLastOperationInfo(): " + e.getLocalizedMessage()); + e.printStackTrace(); + throw new TDGWTServiceException("Error retrieving last operation info: " + + e.getLocalizedMessage()); + } + + } + } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/ExpressionGenerator.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/ExpressionGenerator.java index adfc5ff..b751493 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/ExpressionGenerator.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/ExpressionGenerator.java @@ -218,10 +218,20 @@ public class ExpressionGenerator { new ColumnLocalId(columnLocalId)); listColumnReference.add(cr); } + if(listColumnReference.size()<=0){ + return null; + } else { + if(listColumnReference.size()==1){ + Not not=new Not(listColumnReference.get(0)); + return not; + } else { + And and = new And(listColumnReference); + Not not = new Not(and); + return not; + } + } - And and = new And(listColumnReference); - Not not = new Not(and); - return not; + } catch (Throwable e) { logger.debug("Error in genReplaceBatchOccurrencesFilter: " + e.getLocalizedMessage()); 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 36f25a2..3e698a8 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 @@ -3,6 +3,7 @@ package org.gcube.portlets.user.td.gwtservice.server.trservice; import java.util.ArrayList; import java.util.Arrays; +import org.gcube.data.analysis.tabulardata.expression.Expression; import org.gcube.data.analysis.tabulardata.model.column.ColumnLocalId; import org.gcube.data.analysis.tabulardata.model.table.TableId; import org.gcube.data.analysis.tabulardata.query.parameters.QueryFilter; @@ -87,14 +88,24 @@ public class QueryService { if (occurrencesSession.getShowType().compareTo( ShowOccurrencesType.ONLYERRORS) == 0) { if (occurrencesSession.isHasValidationColumns()) { - queryFilter = new QueryFilter( - ExpressionGenerator - .genReplaceBatchOccurrencesFilter(column)); + Expression exp=ExpressionGenerator + .genReplaceBatchOccurrencesFilter(column); + logger.debug("Expression: "+exp); + if(exp!=null){ + queryFilter = new QueryFilter( + exp); + } } else { return occurences; } } - + + logger.debug("Query on " + tableId.toString() + " queryPage:" + + queryPage + " queryFilter:" + queryFilter + + " querySelect:" + querySelect + " queryGroup:" + + queryGroup+" queryOrder:"+queryOrder); + logger.debug("Query Select Columns:"+querySelect.getColumns()); + logger.debug("Query Group Columns: "+queryGroup.getColumns()); String serviceJson = null; try { if (queryOrder == null) { @@ -148,7 +159,7 @@ public class QueryService { occurence = new Occurrences(currentRow.getString(0), currentRow.getInt(1)); } - // logger.debug(occurence.toString()); + //logger.debug(occurence.toString()); occurences.add(occurence); } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/operation/Operation.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/operation/Operation.java new file mode 100644 index 0000000..01fcfda --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/operation/Operation.java @@ -0,0 +1,45 @@ +package org.gcube.portlets.user.td.gwtservice.shared.operation; + +import java.io.Serializable; + +/** + * + * @author "Giancarlo Panichi" + * + */ +public class Operation implements Serializable { + + private static final long serialVersionUID = 7597236172277678816L; + String name; + String description; + + public Operation() { + } + + public Operation(String name, String description) { + this.name = name; + this.description = description; + } + + 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; + } + + @Override + public String toString() { + return "Operation [name=" + name + ", description=" + description + "]"; + } + +}