Added Replace By External TR
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@101386 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
467f0d717e
commit
969f1341e8
|
@ -53,6 +53,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.normalization.Normalizati
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadConfig;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadResult;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.replacebyexternal.ReplaceByExternalSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.RemoveResourceSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDDescriptor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDType;
|
||||
|
@ -281,9 +282,10 @@ public interface TDGWTService extends RemoteService {
|
|||
*
|
||||
*
|
||||
* @param activeTRId
|
||||
* @return TODO
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public void setActiveTabularResource(TRId activeTRId)
|
||||
public TRId setActiveTabularResource(TRId activeTRId)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
// Task
|
||||
|
@ -813,6 +815,18 @@ public interface TDGWTService extends RemoteService {
|
|||
public String startReplaceColumn(ReplaceColumnSession replaceColumnSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* Start replace column by external tabular resource
|
||||
*
|
||||
* @param replaceByExternalSession
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public String startReplaceByExternal(ReplaceByExternalSession replaceByExternalSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
// Templates
|
||||
/**
|
||||
* Retrieves templates of user
|
||||
|
|
|
@ -52,6 +52,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.normalization.Normalizati
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadConfig;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadResult;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.replacebyexternal.ReplaceByExternalSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.RemoveResourceSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDDescriptor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDType;
|
||||
|
@ -157,7 +158,7 @@ public interface TDGWTServiceAsync {
|
|||
|
||||
void closeTabularResource(TRId closeTRId, AsyncCallback<Void> callback);
|
||||
|
||||
void setActiveTabularResource(TRId activeTRId, AsyncCallback<Void> callback);
|
||||
void setActiveTabularResource(TRId activeTRId, AsyncCallback<TRId> callback);
|
||||
|
||||
// Task
|
||||
void startTaskResubmit(TaskResubmitSession taskResubmitSession,
|
||||
|
@ -302,6 +303,9 @@ public interface TDGWTServiceAsync {
|
|||
// Replace Operation
|
||||
void startReplaceColumn(ReplaceColumnSession replaceColumnSession,
|
||||
AsyncCallback<String> callback);
|
||||
|
||||
void startReplaceByExternal(ReplaceByExternalSession replaceByExternalSession,
|
||||
AsyncCallback<String> callback);
|
||||
|
||||
// Templates
|
||||
void getTemplates(AsyncCallback<ArrayList<TemplateData>> callback);
|
||||
|
|
|
@ -66,6 +66,8 @@ public class SessionConstants {
|
|||
|
||||
protected static final String UNION_SESSION = "UNION_SESSION";
|
||||
|
||||
protected static final String REPLACE_BY_EXTERNAL_SESSION = "REPLACE_BY_EXTERNAL_SESSION";
|
||||
|
||||
protected static final String STATISTICAL_OPERATION_SESSION = "STATISTICAL_OPERATION_SESSION";
|
||||
|
||||
protected static final String NORMALIZATION_SESSION = "NORMALIZATION_SESSION";
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.groupby.TimeAggregationSe
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.tr.normalization.DenormalizationSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.normalization.NormalizationSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.replacebyexternal.ReplaceByExternalSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DuplicatesSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.EditRowSession;
|
||||
|
@ -1452,6 +1453,31 @@ public class SessionUtil {
|
|||
httpSession.setAttribute(SessionConstants.UNION_SESSION, unionSession);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
public static ReplaceByExternalSession getReplaceByExternalSession(HttpSession httpSession) {
|
||||
ReplaceByExternalSession replaceByExternalSession = (ReplaceByExternalSession) httpSession
|
||||
.getAttribute(SessionConstants.REPLACE_BY_EXTERNAL_SESSION);
|
||||
if (replaceByExternalSession != null) {
|
||||
return replaceByExternalSession;
|
||||
} else {
|
||||
replaceByExternalSession = new ReplaceByExternalSession();
|
||||
httpSession.setAttribute(SessionConstants.REPLACE_BY_EXTERNAL_SESSION,
|
||||
replaceByExternalSession);
|
||||
return replaceByExternalSession;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setReplaceByExternalSession(HttpSession httpSession,
|
||||
ReplaceByExternalSession replaceByExternalSession) {
|
||||
ReplaceByExternalSession re = (ReplaceByExternalSession) httpSession
|
||||
.getAttribute(SessionConstants.REPLACE_BY_EXTERNAL_SESSION);
|
||||
if (re != null) {
|
||||
httpSession.removeAttribute(SessionConstants.REPLACE_BY_EXTERNAL_SESSION);
|
||||
}
|
||||
httpSession.setAttribute(SessionConstants.REPLACE_BY_EXTERNAL_SESSION, replaceByExternalSession);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
|
|
|
@ -127,6 +127,7 @@ import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4MapC
|
|||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4MergeColumn;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Normalization;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ReplaceBatch;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ReplaceByExternal;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ReplaceColumn;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ReplaceColumnByExpression;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4SDMXCodelistImport;
|
||||
|
@ -232,6 +233,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoad
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadResult;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.Direction;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.OrderInfo;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.replacebyexternal.ReplaceByExternalSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.RemoveResourceSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDDescriptor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDType;
|
||||
|
@ -521,24 +523,107 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setActiveTabularResource(TRId activeTRId)
|
||||
public TRId setActiveTabularResource(TRId activeTRId)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
logger.debug("setActiveTabularResource(): " + activeTRId);
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getAslSession(session);
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
TabResource tabResource = SessionUtil
|
||||
.getFromCurrentTabularResourcesOpen(session, activeTRId);
|
||||
if (tabResource != null) {
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory
|
||||
.getService();
|
||||
|
||||
Table table = service.getLastTable(new TabularResourceId(Long
|
||||
.valueOf(tabResource.getTrId().getId())));
|
||||
logger.debug("Table retrieved: " + table);
|
||||
if (table == null) {
|
||||
logger.error("Last Table is Null: "
|
||||
+ Long.valueOf(tabResource.getTrId().getId()));
|
||||
new TDGWTServiceException("Last table is null");
|
||||
}
|
||||
|
||||
Table viewTable = null;
|
||||
if (table.contains(DatasetViewTableMetadata.class)) {
|
||||
DatasetViewTableMetadata dwm = table
|
||||
.getMetadata(DatasetViewTableMetadata.class);
|
||||
logger.debug("DatasetViewTableMetadata: " + dwm);
|
||||
try {
|
||||
viewTable = service.getTable(dwm
|
||||
.getTargetDatasetViewTableId());
|
||||
} catch (Exception e) {
|
||||
logger.error("View table not found: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
} else {
|
||||
logger.debug("Table not contains DataseViewTableMetadata");
|
||||
}
|
||||
TRId trIdNew=tabResource.getTrId();
|
||||
if (viewTable == null) {
|
||||
logger.debug("ViewTable is null");
|
||||
String tableId=String.valueOf(table.getId().getValue());
|
||||
|
||||
if (tabResource
|
||||
.getTrId()
|
||||
.getTableId()
|
||||
.compareTo(tableId) == 0) {
|
||||
trIdNew.setTableId(
|
||||
tableId);
|
||||
trIdNew.setTableType(
|
||||
table.getTableType().getName());
|
||||
trIdNew.setViewTable(false);
|
||||
tabResource.setTrId(trIdNew);
|
||||
} else {
|
||||
trIdNew.setTableId(
|
||||
tableId);
|
||||
trIdNew.setTableType(
|
||||
table.getTableType().getName());
|
||||
trIdNew.setViewTable(false);
|
||||
tabResource.setTrId(trIdNew);
|
||||
SessionUtil.addToCurrentTabularResourcesOpen(session, tabResource);
|
||||
|
||||
}
|
||||
} else {
|
||||
String tableId=String.valueOf(viewTable.getId().getValue());
|
||||
if (tabResource
|
||||
.getTrId()
|
||||
.getTableId()
|
||||
.compareTo(tableId) == 0) {
|
||||
trIdNew.setTableId(
|
||||
tableId);
|
||||
trIdNew.setTableType(
|
||||
viewTable.getTableType().getName());
|
||||
trIdNew.setReferenceTargetTableId(
|
||||
String.valueOf(table.getId().getValue()));
|
||||
trIdNew.setViewTable(true);
|
||||
tabResource.setTrId(trIdNew);
|
||||
} else {
|
||||
trIdNew.setTableId(
|
||||
tableId);
|
||||
trIdNew.setTableType(
|
||||
viewTable.getTableType().getName());
|
||||
trIdNew.setReferenceTargetTableId(
|
||||
String.valueOf(table.getId().getValue()));
|
||||
trIdNew.setViewTable(true);
|
||||
tabResource.setTrId(trIdNew);
|
||||
SessionUtil.addToCurrentTabularResourcesOpen(session, tabResource);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
SessionUtil.setTabResource(session, tabResource);
|
||||
SessionUtil.setTRId(session, tabResource.getTrId());
|
||||
logger.debug("New Active: "+tabResource.getTrId());
|
||||
} else {
|
||||
logger.error("Set Active Tabular Resource failed, no valid id!: "
|
||||
+ activeTRId);
|
||||
throw new TDGWTServiceException(
|
||||
"Set Active Tabular Resource failed, no valid id!");
|
||||
}
|
||||
return;
|
||||
return tabResource.getTrId();
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
throw e;
|
||||
|
@ -2052,12 +2137,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
tabResource.setValid(tr.isValid());
|
||||
tabResource.setFinalized(tr.isFinalized());
|
||||
tabResource.setLocked(tr.isLocked());
|
||||
ArrayList<TabularResourceMetadata<?>> meta=new ArrayList<TabularResourceMetadata<?>>();
|
||||
|
||||
|
||||
ArrayList<TabularResourceMetadata<?>> meta = new ArrayList<TabularResourceMetadata<?>>();
|
||||
|
||||
meta.add(new NameMetadata(tabResource.getName()));
|
||||
meta.add(new DescriptionMetadata(tabResource.getDescription()));
|
||||
|
||||
|
||||
if (tabResource.getAgency() != null
|
||||
&& !tabResource.getAgency().isEmpty()) {
|
||||
meta.add(new AgencyMetadata(tabResource.getAgency()));
|
||||
|
@ -2105,9 +2189,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
tr.setAllMetadata(meta);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -5459,10 +5542,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
checkTabularResourceIsFinal(tr);
|
||||
|
||||
logger.debug("setTabResourceInformation - old information:" + tr);
|
||||
|
||||
ArrayList<TabularResourceMetadata<?>> meta=new ArrayList<TabularResourceMetadata<?>>();
|
||||
|
||||
|
||||
|
||||
ArrayList<TabularResourceMetadata<?>> meta = new ArrayList<TabularResourceMetadata<?>>();
|
||||
|
||||
if (tabResource.getName() != null) {
|
||||
NameMetadata name = new NameMetadata(tabResource.getName());
|
||||
meta.add(name);
|
||||
|
@ -5472,7 +5554,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
DescriptionMetadata description = new DescriptionMetadata(
|
||||
tabResource.getDescription());
|
||||
meta.add(description);
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (tabResource.getAgency() != null) {
|
||||
|
@ -5495,7 +5577,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
validFromC.setTime(dateF);
|
||||
ValidSinceMetadata validSince = new ValidSinceMetadata();
|
||||
validSince.setValue(validFromC);
|
||||
meta.add(validSince);
|
||||
meta.add(validSince);
|
||||
} catch (ParseException e) {
|
||||
logger.info("ValidFromMetadata is not set, no valid calendar present");
|
||||
}
|
||||
|
@ -5528,9 +5610,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
tr.setAllMetadata(meta);
|
||||
|
||||
|
||||
if (tabResource.isFinalized()) {
|
||||
if (tr.isValid()) {
|
||||
if (!tr.isFinalized()) {
|
||||
|
@ -7533,6 +7615,69 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String startReplaceByExternal(ReplaceByExternalSession replaceByExternalSession)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setReplaceByExternalSession(session, replaceByExternalSession);
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
checkTRId(replaceByExternalSession.getTrId());
|
||||
|
||||
TabularResourceId tabularResourceId = new TabularResourceId(
|
||||
Long.valueOf(replaceByExternalSession.getTrId().getId()));
|
||||
TabularResource tabularResource = service
|
||||
.getTabularResource(tabularResourceId);
|
||||
|
||||
checkTabularResourceIsFlow(tabularResource);
|
||||
checkTabularResourceLocked(tabularResource);
|
||||
checkTabularResourceIsFinal(tabularResource);
|
||||
|
||||
OpExecution4ReplaceByExternal opEx = new OpExecution4ReplaceByExternal(service,
|
||||
replaceByExternalSession);
|
||||
OpExecutionDirector director = new OpExecutionDirector();
|
||||
director.setOperationExecutionBuilder(opEx);
|
||||
director.constructOperationExecution();
|
||||
OperationExecution invocation = director.getOperationExecution();
|
||||
|
||||
if (invocation == null) {
|
||||
throw new TDGWTServiceException(
|
||||
"Error replace by external invocation: Operation not supported");
|
||||
}
|
||||
|
||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||
Task trTask = service.execute(invocation, tabularResourceId);
|
||||
logger.debug("Start Task on service: TaskId " + trTask.getId());
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.ReplaceByExternal, replaceByExternalSession.getTrId());
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
return trTask.getId().getValue();
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
throw e;
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(
|
||||
"Security exception, you haven't rights!");
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error in replace by external: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -7948,8 +8093,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
logger.debug("Get uri from resolver: "+uriResolverSession);
|
||||
|
||||
logger.debug("Get uri from resolver: " + uriResolverSession);
|
||||
|
||||
UriResolverManager resolver;
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
|
||||
|
@ -7959,7 +8104,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
.getApplicationType().toString());
|
||||
params.put("gis-UUID", uriResolverSession.getUuid());
|
||||
params.put("scope", aslSession.getScope());
|
||||
logger.debug("Uri Resolver params: "+params);
|
||||
logger.debug("Uri Resolver params: " + params);
|
||||
link = resolver.getLink(params, true); // true, link is shorted
|
||||
// otherwise none
|
||||
break;
|
||||
|
@ -7967,8 +8112,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
break;
|
||||
|
||||
}
|
||||
|
||||
logger.debug("Retrieved Link: "+link);
|
||||
|
||||
logger.debug("Retrieved Link: " + link);
|
||||
return link;
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.server.opexecution;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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.expression.Expression;
|
||||
import org.gcube.data.analysis.tabulardata.expression.composite.comparable.Equals;
|
||||
import org.gcube.data.analysis.tabulardata.expression.logical.And;
|
||||
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.table.TableId;
|
||||
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap;
|
||||
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.exception.TDGWTServiceException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.replacebyexternal.ReplaceByExternalColumnsMapping;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.replacebyexternal.ReplaceByExternalSession;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Operation Execution for replace by external tabular resource
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class OpExecution4ReplaceByExternal extends OpExecutionBuilder {
|
||||
protected static Logger logger = LoggerFactory
|
||||
.getLogger(OpExecution4ReplaceByExternal.class);
|
||||
|
||||
private TabularDataService service;
|
||||
private ReplaceByExternalSession replaceByExternalSession;
|
||||
|
||||
public OpExecution4ReplaceByExternal(
|
||||
TabularDataService service,
|
||||
ReplaceByExternalSession replaceByExternalSession) {
|
||||
this.service = service;
|
||||
this.replaceByExternalSession = replaceByExternalSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildOpEx() throws TDGWTServiceException {
|
||||
OperationExecution invocation = null;
|
||||
|
||||
logger.debug(replaceByExternalSession.toString());
|
||||
OperationDefinition operationDefinition;
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
operationDefinition = OperationDefinitionMap.map(
|
||||
OperationsId.ReplaceColumnByExpression.toString(), service);
|
||||
|
||||
TableId currentTableId=null;
|
||||
if(replaceByExternalSession.getCurrentTabularResource().getTrId().isViewTable()){
|
||||
currentTableId=new TableId(Long.valueOf(replaceByExternalSession.getCurrentTabularResource().getTrId().getReferenceTargetTableId()));
|
||||
} else {
|
||||
currentTableId=new TableId(Long.valueOf(replaceByExternalSession.getCurrentTabularResource().getTrId().getTableId()));
|
||||
}
|
||||
|
||||
TableId externalTableId=null;
|
||||
if(replaceByExternalSession.getExternalTabularResource().getTrId().isViewTable()){
|
||||
externalTableId=new TableId(Long.valueOf(replaceByExternalSession.getExternalTabularResource().getTrId().getReferenceTargetTableId()));
|
||||
} else {
|
||||
externalTableId=new TableId(Long.valueOf(replaceByExternalSession.getExternalTabularResource().getTrId().getTableId()));
|
||||
}
|
||||
|
||||
ArrayList<Expression> conditions=new ArrayList<Expression>();
|
||||
for(ReplaceByExternalColumnsMapping colMapping:replaceByExternalSession.getColumnsMatch()){
|
||||
ColumnReference currentColumn=new ColumnReference(currentTableId, new ColumnLocalId(colMapping.getCurrentColumn().getColumnId()));
|
||||
ColumnReference externalColumn=new ColumnReference(externalTableId, new ColumnLocalId(colMapping.getExternalColumn().getColumnId()));
|
||||
Equals eq=new Equals(currentColumn, externalColumn);
|
||||
conditions.add(eq);
|
||||
}
|
||||
|
||||
Expression condition=null;
|
||||
if(conditions.size()<=0){
|
||||
logger.error("No columns selected");
|
||||
throw new TDGWTServiceException("No columns selected");
|
||||
} else {
|
||||
if(conditions.size()==1){
|
||||
condition=conditions.get(0);
|
||||
} else {
|
||||
And andCond=new And(conditions);
|
||||
condition=andCond;
|
||||
}
|
||||
}
|
||||
|
||||
ColumnReference replaceColumn=new ColumnReference(externalTableId, new ColumnLocalId(replaceByExternalSession.getReplaceColumn().getColumnId()));
|
||||
|
||||
map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_CONDITION,
|
||||
condition);
|
||||
map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_VALUE,
|
||||
replaceColumn);
|
||||
|
||||
invocation = new OperationExecution(
|
||||
operationDefinition.getOperationId(), map);
|
||||
|
||||
|
||||
operationExecutionSpec.setOp(invocation);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -106,5 +106,8 @@ public class ColumnMap {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ public enum UIOperationsId {
|
|||
TimeAggregation("Time Aggregation"),
|
||||
ReplaceValue("Replace Value"),
|
||||
ReplaceByExpression("Replace By Expression"),
|
||||
ReplaceByExternal("Replace By External"),
|
||||
ReplaceBatch("Replace Batch"),
|
||||
FilterColumn("Filter Column"),
|
||||
Union("Union"),
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.shared.tr.replacebyexternal;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ReplaceByExternalColumnsMapping implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2795844498148679703L;
|
||||
|
||||
protected String columnLabel;
|
||||
protected ColumnData currentColumn;
|
||||
protected ColumnData externalColumn;
|
||||
|
||||
public ReplaceByExternalColumnsMapping() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnLabel
|
||||
* @param currentColumn
|
||||
* @param externalColumn
|
||||
*/
|
||||
public ReplaceByExternalColumnsMapping(String columnLabel,
|
||||
ColumnData currentColumn, ColumnData externalColumn) {
|
||||
super();
|
||||
this.columnLabel = columnLabel;
|
||||
this.currentColumn = currentColumn;
|
||||
this.externalColumn = externalColumn;
|
||||
}
|
||||
|
||||
public String getColumnLabel() {
|
||||
return columnLabel;
|
||||
}
|
||||
|
||||
public void setColumnLabel(String columnLabel) {
|
||||
this.columnLabel = columnLabel;
|
||||
}
|
||||
|
||||
public ColumnData getCurrentColumn() {
|
||||
return currentColumn;
|
||||
}
|
||||
|
||||
public void setCurrentColumn(ColumnData currentColumn) {
|
||||
this.currentColumn = currentColumn;
|
||||
}
|
||||
|
||||
public ColumnData getExternalColumn() {
|
||||
return externalColumn;
|
||||
}
|
||||
|
||||
public void setExternalColumn(ColumnData externalColumn) {
|
||||
this.externalColumn = externalColumn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReplaceByExternalColumnsMapping [columnLabel=" + columnLabel
|
||||
+ ", currentColumn=" + currentColumn + ", externalColumn="
|
||||
+ externalColumn + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.shared.tr.replacebyexternal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ReplaceByExternalSession implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 3791535835292213831L;
|
||||
protected TRId trId;
|
||||
protected TabResource currentTabularResource;
|
||||
protected TabResource externalTabularResource;
|
||||
protected ColumnData replaceColumn;
|
||||
protected ArrayList<ReplaceByExternalColumnsMapping> columnsMatch;
|
||||
|
||||
public ReplaceByExternalSession() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param trId
|
||||
* @param currentTabularResource
|
||||
* @param externalTabularResource
|
||||
* @param replaceColumn
|
||||
* @param columnsMatch
|
||||
*/
|
||||
public ReplaceByExternalSession(TRId trId,
|
||||
TabResource currentTabularResource,
|
||||
TabResource externalTabularResource, ColumnData replaceColumn,
|
||||
ArrayList<ReplaceByExternalColumnsMapping> columnsMatch) {
|
||||
super();
|
||||
this.trId = trId;
|
||||
this.currentTabularResource = currentTabularResource;
|
||||
this.externalTabularResource = externalTabularResource;
|
||||
this.replaceColumn = replaceColumn;
|
||||
this.columnsMatch = columnsMatch;
|
||||
}
|
||||
|
||||
public TRId getTrId() {
|
||||
return trId;
|
||||
}
|
||||
|
||||
public void setTrId(TRId trId) {
|
||||
this.trId = trId;
|
||||
}
|
||||
|
||||
public TabResource getCurrentTabularResource() {
|
||||
return currentTabularResource;
|
||||
}
|
||||
|
||||
public void setCurrentTabularResource(TabResource currentTabularResource) {
|
||||
this.currentTabularResource = currentTabularResource;
|
||||
}
|
||||
|
||||
public TabResource getExternalTabularResource() {
|
||||
return externalTabularResource;
|
||||
}
|
||||
|
||||
public void setExternalTabularResource(TabResource externalTabularResource) {
|
||||
this.externalTabularResource = externalTabularResource;
|
||||
}
|
||||
|
||||
public ColumnData getReplaceColumn() {
|
||||
return replaceColumn;
|
||||
}
|
||||
|
||||
public void setReplaceColumn(ColumnData replaceColumn) {
|
||||
this.replaceColumn = replaceColumn;
|
||||
}
|
||||
|
||||
public ArrayList<ReplaceByExternalColumnsMapping> getColumnsMatch() {
|
||||
return columnsMatch;
|
||||
}
|
||||
|
||||
public void setColumnsMatch(
|
||||
ArrayList<ReplaceByExternalColumnsMapping> columnsMatch) {
|
||||
this.columnsMatch = columnsMatch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReplaceByExternalSession [trId=" + trId
|
||||
+ ", currentTabularResource=" + currentTabularResource
|
||||
+ ", externalTabularResource=" + externalTabularResource
|
||||
+ ", replaceColumn=" + replaceColumn + ", columnsMatch="
|
||||
+ columnsMatch + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue