Added Batch Replace

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@94270 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-04-03 16:36:35 +00:00
parent 701c43759f
commit b0cbe6e72b
11 changed files with 648 additions and 103 deletions

View File

@ -28,6 +28,8 @@ 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.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData; import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurences; import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurences;
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.clone.CloneTabularResourceSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.clone.CloneTabularResourceSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
@ -53,7 +55,6 @@ 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.gwtservice.shared.tr.type.Dataset;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@ -99,8 +100,8 @@ public interface TDGWTService extends RemoteService {
* @param tabResource * @param tabResource
* @throws TDGWTServiceException * @throws TDGWTServiceException
*/ */
public void setTabResourceInformation(TabResource tabResource) throws TDGWTServiceException; public void setTabResourceInformation(TabResource tabResource)
throws TDGWTServiceException;
/** /**
* Get informations on tabular resource * Get informations on tabular resource
@ -186,8 +187,7 @@ public interface TDGWTService extends RemoteService {
public Boolean isTabularResourceValid(TRId trId) public Boolean isTabularResourceValid(TRId trId)
throws TDGWTServiceException; throws TDGWTServiceException;
// Share
//Share
/** /**
* Retrieves information sharing on the tabular resource * Retrieves information sharing on the tabular resource
* *
@ -195,7 +195,7 @@ public interface TDGWTService extends RemoteService {
* @return * @return
* @throws TDGWTServiceException * @throws TDGWTServiceException
*/ */
public ShareInfo getShareInfo(TRId trId) throws TDGWTServiceException; public ShareInfo getShareInfo(TRId trId) throws TDGWTServiceException;
/** /**
* Share sabular resource * Share sabular resource
@ -204,7 +204,7 @@ public interface TDGWTService extends RemoteService {
* @return * @return
* @throws TDGWTServiceException * @throws TDGWTServiceException
*/ */
public void setShare(ShareInfo shareInfo) throws TDGWTServiceException; public void setShare(ShareInfo shareInfo) throws TDGWTServiceException;
// Open // Open
@ -226,17 +226,17 @@ public interface TDGWTService extends RemoteService {
public ArrayList<TabResource> getTabularResourcesAndLastTables() public ArrayList<TabResource> getTabularResourcesAndLastTables()
throws TDGWTServiceException; throws TDGWTServiceException;
//Clone // Clone
/** /**
* Start clone tabular resource * Start clone tabular resource
* *
* @param labelColumnSession * @param labelColumnSession
* @throws TDGWTServiceException * @throws TDGWTServiceException
*/ */
public TRId startCloneTabularResource(CloneTabularResourceSession cloneTabularResourceSession) public TRId startCloneTabularResource(
CloneTabularResourceSession cloneTabularResourceSession)
throws TDGWTServiceException; throws TDGWTServiceException;
// //
/** /**
* Initialize Codelists Paging Loader * Initialize Codelists Paging Loader
@ -282,10 +282,9 @@ public interface TDGWTService extends RemoteService {
public ArrayList<ColumnData> getColumns(TRId trId) public ArrayList<ColumnData> getColumns(TRId trId)
throws TDGWTServiceException; throws TDGWTServiceException;
/** /**
* Retrieves the list of columns in the table provided by trId * Retrieves the list of columns in the table provided by trId only CODE and
* only CODE and CODENAME types * CODENAME types
* *
* @return * @return
* @throws TDGWTServiceException * @throws TDGWTServiceException
@ -293,7 +292,6 @@ public interface TDGWTService extends RemoteService {
public ArrayList<ColumnData> getColumnsForDimension(TRId trId) public ArrayList<ColumnData> getColumnsForDimension(TRId trId)
throws TDGWTServiceException; throws TDGWTServiceException;
/** /**
* Retrieves information about a specific column * Retrieves information about a specific column
* *
@ -496,9 +494,7 @@ public interface TDGWTService extends RemoteService {
ChangeTableTypeSession changeTableTypeSession) ChangeTableTypeSession changeTableTypeSession)
throws TDGWTServiceException; throws TDGWTServiceException;
// Rows Operations
//Rows Operations
/** /**
* Get Operation Monitor during the Delete Rows operation * Get Operation Monitor during the Delete Rows operation
* *
@ -515,11 +511,9 @@ public interface TDGWTService extends RemoteService {
* @param labelColumnSession * @param labelColumnSession
* @throws TDGWTServiceException * @throws TDGWTServiceException
*/ */
public void startDeleteRows( public void startDeleteRows(DeleteRowsSession deleteRowsSession)
DeleteRowsSession deleteRowsSession)
throws TDGWTServiceException; throws TDGWTServiceException;
/** /**
* Get Operation Monitor during the operation on duplicates * Get Operation Monitor during the operation on duplicates
* *
@ -536,11 +530,9 @@ public interface TDGWTService extends RemoteService {
* @param labelColumnSession * @param labelColumnSession
* @throws TDGWTServiceException * @throws TDGWTServiceException
*/ */
public void startDuplicates( public void startDuplicates(DuplicatesSession duplicatesSession)
DuplicatesSession duplicatesSession)
throws TDGWTServiceException; throws TDGWTServiceException;
// Column Operation // Column Operation
/** /**
@ -601,8 +593,7 @@ public interface TDGWTService extends RemoteService {
public void startLabelColumn(LabelColumnSession labelColumnSession) public void startLabelColumn(LabelColumnSession labelColumnSession)
throws TDGWTServiceException; throws TDGWTServiceException;
// BatchReplace Operations
//BatchReplace Operations
/** /**
* Retrieves the values in a column grouped by number of occurrences * Retrieves the values in a column grouped by number of occurrences
* *
@ -610,10 +601,29 @@ public interface TDGWTService extends RemoteService {
* @return * @return
*/ */
public ArrayList<Occurences> getOccurencesForBatchReplace(ColumnData column) public ArrayList<Occurences> getOccurencesForBatchReplace(ColumnData column)
throws TDGWTServiceException; throws TDGWTServiceException;
/**
* Get Operation Monitor during the batch replace on column
*
*
* @return
* @throws TDGWTServiceException
*/
public ReplaceBatchColumnMonitor getReplaceBatchColumnMonitor()
throws TDGWTServiceException;
//Replace Operation /**
* Start batch replace on column
*
* @param replaceBatchColumnSession
* @throws TDGWTServiceException
*/
public void startReplaceBatchColumn(
ReplaceBatchColumnSession replaceBatchColumnSession)
throws TDGWTServiceException;
// Replace Operation
/** /**
* Get Operation Monitor during the replace the Column Value operation * Get Operation Monitor during the replace the Column Value operation
* *
@ -633,11 +643,9 @@ public interface TDGWTService extends RemoteService {
public void startReplaceColumn(ReplaceColumnSession replaceColumnSession) public void startReplaceColumn(ReplaceColumnSession replaceColumnSession)
throws TDGWTServiceException; throws TDGWTServiceException;
// Templates
//Templates
/** /**
* Retrieves templates of user * Retrieves templates of user
* *
* @return * @return
*/ */
@ -649,7 +657,8 @@ public interface TDGWTService extends RemoteService {
* @param callback * @param callback
*/ */
public TemplateApplyMonitor getTemplateApplyMonitor() throws TDGWTServiceException; public TemplateApplyMonitor getTemplateApplyMonitor()
throws TDGWTServiceException;
/** /**
* Start Apply Template * Start Apply Template
@ -657,8 +666,8 @@ public interface TDGWTService extends RemoteService {
* @param applyTemplateSession * @param applyTemplateSession
* *
*/ */
void startTemplateApply(TemplateApplySession templateApplySession) throws TDGWTServiceException; void startTemplateApply(TemplateApplySession templateApplySession)
throws TDGWTServiceException;
/** /**
* Start Delete Template * Start Delete Template
@ -666,8 +675,7 @@ public interface TDGWTService extends RemoteService {
* @param applyTemplateSession * @param applyTemplateSession
* *
*/ */
void startTemplateDelete(TemplateDeleteSession templateDeleteSession) throws TDGWTServiceException; void startTemplateDelete(TemplateDeleteSession templateDeleteSession)
throws TDGWTServiceException;
} }

View File

@ -27,6 +27,8 @@ 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.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData; import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurences; import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurences;
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.clone.CloneTabularResourceSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.clone.CloneTabularResourceSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
@ -188,6 +190,8 @@ public interface TDGWTServiceAsync {
//BatchReplace Operation //BatchReplace Operation
void getOccurencesForBatchReplace(ColumnData column, AsyncCallback<ArrayList<Occurences>> callback); void getOccurencesForBatchReplace(ColumnData column, AsyncCallback<ArrayList<Occurences>> callback);
void getReplaceBatchColumnMonitor(AsyncCallback<ReplaceBatchColumnMonitor> callback);
void startReplaceBatchColumn(ReplaceBatchColumnSession replaceBatchColumnSession,AsyncCallback<Void> callback);
//Replace Operation //Replace Operation
void getReplaceColumnMonitor(AsyncCallback<ReplaceColumnMonitor> callback); void getReplaceColumnMonitor(AsyncCallback<ReplaceColumnMonitor> callback);

View File

@ -25,6 +25,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplyMonitor; import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplyMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession; import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
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.clone.CloneTabularResourceSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.clone.CloneTabularResourceSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
@ -97,6 +99,10 @@ public class SessionUtil {
protected static final String REPLACE_COLUMN_MONITOR = "REPLACE_COLUMN_MONITOR"; protected static final String REPLACE_COLUMN_MONITOR = "REPLACE_COLUMN_MONITOR";
protected static final String REPLACE_COLUMN_TASK = "REPLACE_COLUMN_TASK"; protected static final String REPLACE_COLUMN_TASK = "REPLACE_COLUMN_TASK";
protected static final String REPLACE_BATCH_COLUMN_SESSION = "REPLACE_BATCH_COLUMN_SESSION";
protected static final String REPLACE_BATCH_COLUMN_MONITOR = "REPLACE_BATCH_COLUMN_MONITOR";
protected static final String REPLACE_BATCH_COLUMN_TASK = "REPLACE_BATCH_COLUMN_TASK";
protected static final String CHANGE_THE_COLUMN_LABEL_SESSION = "CHANGE_THE_COLUMN_LABEL_SESSION"; protected static final String CHANGE_THE_COLUMN_LABEL_SESSION = "CHANGE_THE_COLUMN_LABEL_SESSION";
protected static final String CHANGE_THE_COLUMN_LABEL_MONITOR = "CHANGE_THE_COLUMN_LABEL_MONITOR"; protected static final String CHANGE_THE_COLUMN_LABEL_MONITOR = "CHANGE_THE_COLUMN_LABEL_MONITOR";
protected static final String CHANGE_THE_COLUMN_LABEL_TASK = "CHANGE_THE_COLUMN_LABEL_TASK"; protected static final String CHANGE_THE_COLUMN_LABEL_TASK = "CHANGE_THE_COLUMN_LABEL_TASK";
@ -803,7 +809,7 @@ public class SessionUtil {
} }
public static void setReplaceColumnMonitor(HttpSession httpSession, public static void setReplaceColumnMonitor(HttpSession httpSession,
DeleteColumnMonitor replaceColumnMonitor) { ReplaceColumnMonitor replaceColumnMonitor) {
ReplaceColumnMonitor rc = (ReplaceColumnMonitor) httpSession ReplaceColumnMonitor rc = (ReplaceColumnMonitor) httpSession
.getAttribute(REPLACE_COLUMN_MONITOR); .getAttribute(REPLACE_COLUMN_MONITOR);
if (rc != null) { if (rc != null) {
@ -828,6 +834,74 @@ public class SessionUtil {
httpSession.setAttribute(REPLACE_COLUMN_TASK, task); httpSession.setAttribute(REPLACE_COLUMN_TASK, task);
} }
//
public static ReplaceBatchColumnSession getReplaceBatchColumnSession(
HttpSession httpSession) {
ReplaceBatchColumnSession replaceBatchColumnSession = (ReplaceBatchColumnSession) httpSession
.getAttribute(REPLACE_BATCH_COLUMN_SESSION);
if (replaceBatchColumnSession != null) {
return replaceBatchColumnSession;
} else {
replaceBatchColumnSession = new ReplaceBatchColumnSession();
httpSession.setAttribute(REPLACE_BATCH_COLUMN_SESSION,
replaceBatchColumnSession);
return replaceBatchColumnSession;
}
}
public static void setReplaceBatchColumnSession(HttpSession httpSession,
ReplaceBatchColumnSession replaceBatchColumnSession) {
ReplaceBatchColumnSession rbc = (ReplaceBatchColumnSession) httpSession
.getAttribute(REPLACE_BATCH_COLUMN_SESSION);
if (rbc != null) {
httpSession.removeAttribute(REPLACE_BATCH_COLUMN_SESSION);
}
httpSession.setAttribute(REPLACE_BATCH_COLUMN_SESSION, replaceBatchColumnSession);
}
public static ReplaceBatchColumnMonitor getReplaceBatchColumnMonitor(
HttpSession httpSession) {
ReplaceBatchColumnMonitor replaceBatchColumnMonitor = (ReplaceBatchColumnMonitor) httpSession
.getAttribute(REPLACE_BATCH_COLUMN_MONITOR);
if (replaceBatchColumnMonitor != null) {
return replaceBatchColumnMonitor;
} else {
replaceBatchColumnMonitor = new ReplaceBatchColumnMonitor();
httpSession.setAttribute(REPLACE_BATCH_COLUMN_MONITOR,
replaceBatchColumnMonitor);
return replaceBatchColumnMonitor;
}
}
public static void setReplaceBatchColumnMonitor(HttpSession httpSession,
ReplaceBatchColumnMonitor replaceBatchColumnMonitor) {
ReplaceBatchColumnMonitor rbc = (ReplaceBatchColumnMonitor) httpSession
.getAttribute(REPLACE_BATCH_COLUMN_MONITOR);
if (rbc != null) {
httpSession.removeAttribute(REPLACE_BATCH_COLUMN_MONITOR);
}
httpSession.setAttribute(REPLACE_BATCH_COLUMN_MONITOR, replaceBatchColumnMonitor);
}
public static Task getReplaceBatchColumnTask(HttpSession httpSession) {
Task monitor = (Task) httpSession.getAttribute(REPLACE_BATCH_COLUMN_TASK);
if (monitor == null) {
logger.error("REPLACE_BATCH_COLUMN_TASK was not acquired");
}
return monitor;
}
public static void setReplaceBatchColumnTask(HttpSession httpSession, Task task) {
Task monitor = (Task) httpSession.getAttribute(REPLACE_BATCH_COLUMN_TASK);
if (monitor != null)
httpSession.removeAttribute(REPLACE_BATCH_COLUMN_TASK);
httpSession.setAttribute(REPLACE_BATCH_COLUMN_TASK, task);
}
// //
public static ChangeTableTypeSession getChangeTableTypeSession( public static ChangeTableTypeSession getChangeTableTypeSession(

View File

@ -120,6 +120,9 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnViewData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData; import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurences; import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurences;
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.clone.CloneTabularResourceSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
@ -1120,7 +1123,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TabResource t = retrieveTRMetadataFromService(service, tr, TabResource t = retrieveTRMetadataFromService(service, tr,
i); i);
if (t.getTrId() != null && t.isValid()) { if (t.getTrId() != null && t.isValid()) {
ltr.add(t); ltr.add(t);
} }
} catch (Throwable e) { } catch (Throwable e) {
@ -1590,8 +1593,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
logger.error( logger.error(
"Error deleting the tabular resource: " "Error deleting the tabular resource: "
+ e.getLocalizedMessage(), e); + e.getLocalizedMessage(), e);
throw new TDGWTServiceException("Error deleting the tabular resource: " throw new TDGWTServiceException(
+ e.getLocalizedMessage()); "Error deleting the tabular resource: "
+ e.getLocalizedMessage());
} }
} }
@ -2444,14 +2448,14 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} }
} }
/** /**
* *
* @param trId * @param trId
* @return * @return
* @throws TDGWTServiceException * @throws TDGWTServiceException
*/ */
public Boolean isTabularResourceValid(TRId trId) throws TDGWTServiceException { public Boolean isTabularResourceValid(TRId trId)
throws TDGWTServiceException {
try { try {
HttpSession session = this.getThreadLocalRequest().getSession(); HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session); ASLSession aslSession = SessionUtil.getAslSession(session);
@ -2469,11 +2473,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
return tr.isValid(); return tr.isValid();
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("Error checking if it is a valid tabular resource: "
"Error checking if it is a valid tabular resource: " + e.getLocalizedMessage(), + e.getLocalizedMessage(), e);
e); throw new TDGWTServiceException(
throw new TDGWTServiceException("Error checking if it is a valid tabular resource: " "Error checking if it is a valid tabular resource: "
+ e.getLocalizedMessage()); + e.getLocalizedMessage());
} }
} }
@ -3326,6 +3330,74 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
return invocation; return invocation;
} }
/**
* Retrieve OperationExecution for change column type
*
* @param replaceColumnSession
* @return
*/
protected List<OperationExecution> retrieveOperationExecution(
TabularDataService service,
ReplaceBatchColumnSession replaceBatchColumnSession)
throws TDGWTServiceException {
ArrayList<OperationExecution> invocations = new ArrayList<OperationExecution>();
for (ReplaceEntry re : replaceBatchColumnSession.getReplaceEntryList()) {
OperationExecution invocation = null;
List<OperationDefinition> capabilities = service.getCapabilities();
logger.debug(replaceBatchColumnSession.toString());
OperationDefinition operationDefinition;
Map<String, Object> map = new HashMap<String, Object>();
if (replaceBatchColumnSession.isReplaceDimension()) {
logger.debug("Is a Replace of view column");
operationDefinition = OperationDefinitionMap.map(
OperationsId.ReplaceColumnByExpression.toString(),
capabilities);
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(),
capabilities);
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 service
@ -5051,4 +5123,54 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} }
/**
*
* {@inheritDoc}
*/
@Override
public void startReplaceBatchColumn(
ReplaceBatchColumnSession replaceBatchColumnSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setReplaceBatchColumnSession(session,
replaceBatchColumnSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
List<OperationExecution> invocations = retrieveOperationExecution(
service, replaceBatchColumnSession);
if (invocations == null) {
throw new TDGWTServiceException("Operation not supported");
}
TabularResourceId serviceTRId = new TabularResourceId(
Long.valueOf(replaceBatchColumnSession.getTrId().getId()));
logger.debug("OperationInvocation: \n" + invocations.toString());
Task trTask = service.executeBatch(invocations, serviceTRId);
logger.debug("Start Task on service: TaskId " + trTask.getId());
SessionUtil.setReplaceBatchColumnTask(session, trTask);
return;
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException(
"Error in operation for batch replace on column: "
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}
*/
@Override
public ReplaceBatchColumnMonitor getReplaceBatchColumnMonitor()
throws TDGWTServiceException {
// TODO Auto-generated method stub
return null;
}
} }

View File

@ -8,27 +8,29 @@ import org.gcube.data.analysis.tabulardata.model.datatype.value.TDInteger;
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDTypeValue; import org.gcube.data.analysis.tabulardata.model.datatype.value.TDTypeValue;
import org.gcube.data.analysis.tabulardata.model.table.TableId; import org.gcube.data.analysis.tabulardata.model.table.TableId;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
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.column.ReplaceColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession;
/** /**
* *
* @author "Giancarlo Panichi" * @author "Giancarlo Panichi" <a
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public class ExpressionGenerator { public class ExpressionGenerator {
public static Expression genReplaceValueParameterCondition( public static Expression genReplaceValueParameterCondition(
ReplaceColumnSession replaceColumnSession) throws TDGWTServiceException { ReplaceColumnSession replaceColumnSession)
throws TDGWTServiceException {
if (replaceColumnSession.isReplaceDimension()) { if (replaceColumnSession.isReplaceDimension()) {
// Dimension // Dimension
TableId tableId; TableId tableId;
if(replaceColumnSession if (replaceColumnSession.getColumnData().getTrId().isViewTable()) {
.getColumnData().getTrId().isViewTable()){
tableId = new TableId(Long.valueOf(replaceColumnSession tableId = new TableId(Long.valueOf(replaceColumnSession
.getColumnData().getTrId().getReferenceTargetTableId())); .getColumnData().getTrId().getReferenceTargetTableId()));
} else { } else {
tableId = new TableId(Long.valueOf(replaceColumnSession tableId = new TableId(Long.valueOf(replaceColumnSession
.getColumnData().getTrId().getTableId())); .getColumnData().getTrId().getTableId()));
} }
ColumnReference cr = new ColumnReference(tableId, ColumnReference cr = new ColumnReference(tableId,
new ColumnLocalId(replaceColumnSession.getColumnData() new ColumnLocalId(replaceColumnSession.getColumnData()
@ -42,9 +44,8 @@ public class ExpressionGenerator {
} else { } else {
// Simple // Simple
TableId tableId; TableId tableId;
if(replaceColumnSession if (replaceColumnSession.getColumnData().getTrId().isViewTable()) {
.getColumnData().getTrId().isViewTable()){ tableId = new TableId(Long.valueOf(replaceColumnSession
tableId = new TableId(Long.valueOf(replaceColumnSession
.getColumnData().getTrId().getReferenceTargetTableId())); .getColumnData().getTrId().getReferenceTargetTableId()));
} else { } else {
@ -57,8 +58,9 @@ public class ExpressionGenerator {
new ColumnLocalId(replaceColumnSession.getColumnData() new ColumnLocalId(replaceColumnSession.getColumnData()
.getColumnId())); .getColumnId()));
TDTypeValue td=TDTypeValueMap.map(replaceColumnSession.getColumnData() TDTypeValue td = TDTypeValueMap.map(replaceColumnSession
.getDataTypeName(), replaceColumnSession.getValue()); .getColumnData().getDataTypeName(), replaceColumnSession
.getValue());
Equals eq = new Equals(cr, td); Equals eq = new Equals(cr, td);
return eq; return eq;
@ -66,14 +68,81 @@ public class ExpressionGenerator {
} }
public static Expression genReplaceValueParameterValue( public static Expression genReplaceValueParameterValue(
ReplaceColumnSession replaceColumnSession) throws TDGWTServiceException { ReplaceColumnSession replaceColumnSession)
throws TDGWTServiceException {
if (replaceColumnSession.isReplaceDimension()) { if (replaceColumnSession.isReplaceDimension()) {
TDInteger value = new TDInteger(Integer.parseInt(replaceColumnSession TDInteger value = new TDInteger(
.getReplaceValue())); Integer.parseInt(replaceColumnSession.getReplaceValue()));
return value; return value;
} else { } else {
TDTypeValue td=TDTypeValueMap.map(replaceColumnSession.getColumnData() TDTypeValue td = TDTypeValueMap.map(replaceColumnSession
.getDataTypeName(), replaceColumnSession.getReplaceValue()); .getColumnData().getDataTypeName(), replaceColumnSession
.getReplaceValue());
return td;
}
}
public static Expression genReplaceValueParameterCondition(
ReplaceBatchColumnSession replaceBatchColumnSession, ReplaceEntry re)
throws TDGWTServiceException {
if (replaceBatchColumnSession.isReplaceDimension()) {
// Dimension
TableId tableId;
if (replaceBatchColumnSession.getColumnData().getTrId()
.isViewTable()) {
tableId = new TableId(Long.valueOf(replaceBatchColumnSession
.getColumnData().getTrId().getReferenceTargetTableId()));
} else {
tableId = new TableId(Long.valueOf(replaceBatchColumnSession
.getColumnData().getTrId().getTableId()));
}
ColumnReference cr = new ColumnReference(tableId,
new ColumnLocalId(replaceBatchColumnSession.getColumnData()
.getColumnViewData()
.getSourceTableDimensionColumnId()));
Equals eq = new Equals(cr, new TDInteger(
Integer.parseInt(re.getRowId())));
return eq;
} else {
// Simple
TableId tableId;
if (replaceBatchColumnSession.getColumnData().getTrId()
.isViewTable()) {
tableId = new TableId(Long.valueOf(replaceBatchColumnSession
.getColumnData().getTrId().getReferenceTargetTableId()));
} else {
tableId = new TableId(Long.valueOf(replaceBatchColumnSession
.getColumnData().getTrId().getTableId()));
}
ColumnReference cr = new ColumnReference(tableId,
new ColumnLocalId(replaceBatchColumnSession.getColumnData()
.getColumnId()));
TDTypeValue td = TDTypeValueMap.map(replaceBatchColumnSession
.getColumnData().getDataTypeName(),
re.getValue());
Equals eq = new Equals(cr, td);
return eq;
}
}
public static Expression genReplaceBatchValueParameterValue(
ReplaceBatchColumnSession replaceBatchColumnSession, ReplaceEntry re)
throws TDGWTServiceException {
if (replaceBatchColumnSession.isReplaceDimension()) {
TDInteger value = new TDInteger(Integer.parseInt(re
.getReplacementDimensionRow().getRowId()));
return value;
} else {
TDTypeValue td = TDTypeValueMap.map(replaceBatchColumnSession
.getColumnData().getDataTypeName(),
re.getReplacementValue());
return td; return td;
} }
} }

View File

@ -41,20 +41,20 @@ public class QueryService {
TableId tableId = new TableId(new Long(column.getTrId().getTableId())); TableId tableId = new TableId(new Long(column.getTrId().getTableId()));
ColumnLocalId columnId = new ColumnLocalId(column.getColumnId()); ColumnLocalId columnId = new ColumnLocalId(column.getColumnId());
QuerySelect querySelect; QuerySelect querySelect;
QueryGroup queryGroup; QueryGroup queryGroup;
if (column.isViewColumn()) { if (column.isViewColumn()) {
querySelect = new QuerySelect(Arrays.asList( ColumnLocalId sourceColumnId = new ColumnLocalId(column
new QueryColumn(columnId), new QueryColumn(columnId, .getColumnViewData().getSourceTableDimensionColumnId());
Function.COUNT))); querySelect = new QuerySelect(Arrays.asList(new QueryColumn(
columnId), new QueryColumn(sourceColumnId),
new QueryColumn(columnId, Function.COUNT)));
logger.debug("Occurences querySelect:" + querySelect.toString()); logger.debug("Occurences querySelect:" + querySelect.toString());
queryGroup = new QueryGroup(Arrays.asList(columnId)); queryGroup = new QueryGroup(Arrays.asList(columnId, sourceColumnId));
logger.debug("Occurences queryGroup:" + queryGroup.toString()); logger.debug("Occurences queryGroup:" + queryGroup.toString());
} else { } else {
querySelect = new QuerySelect(Arrays.asList( querySelect = new QuerySelect(Arrays.asList(new QueryColumn(
new QueryColumn(columnId), new QueryColumn(columnId, columnId), new QueryColumn(columnId, Function.COUNT)));
Function.COUNT)));
logger.debug("Occurences querySelect:" + querySelect.toString()); logger.debug("Occurences querySelect:" + querySelect.toString());
queryGroup = new QueryGroup(Arrays.asList(columnId)); queryGroup = new QueryGroup(Arrays.asList(columnId));
logger.debug("Occurences queryGroup:" + queryGroup.toString()); logger.debug("Occurences queryGroup:" + queryGroup.toString());
@ -113,8 +113,13 @@ public class QueryService {
for (i = 0; i < totalRows; i++) { for (i = 0; i < totalRows; i++) {
currentRow = rows.getJSONArray(i); currentRow = rows.getJSONArray(i);
occurence = new Occurences(currentRow.getString(0), if (column.isViewColumn()) {
currentRow.getInt(1)); occurence = new Occurences(currentRow.getString(0),
currentRow.getString(1),currentRow.getInt(2));
} else {
occurence = new Occurences(currentRow.getString(0),
currentRow.getInt(1));
}
occurences.add(occurence); occurences.add(occurence);
} }

View File

@ -0,0 +1,51 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr;
import java.io.Serializable;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DimensionRow implements Serializable {
private static final long serialVersionUID = -4220185160420435932L;
protected String rowId;
protected String value;
public DimensionRow(){
}
public DimensionRow(String rowId, String value){
this.rowId=rowId;
this.value=value;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getRowId() {
return rowId;
}
public void setRowId(String rowId) {
this.rowId = rowId;
}
@Override
public String toString() {
return "DimensionRow [rowId=" + rowId + ", value=" + value + "]";
}
}

View File

@ -14,14 +14,22 @@ public class Occurences implements Serializable {
protected String value; protected String value;
protected int number; protected int number;
protected String rowId;//For view column, contains the value of the associated dimension column
public Occurences(){ public Occurences(){
} }
public Occurences(String value, int numnber){ public Occurences(String value, int number){
this.value=value; this.value=value;
this.number=numnber; this.number=number;
this.rowId=null;
}
public Occurences(String value, String rowId,int number){
this.value=value;
this.number=number;
this.rowId=rowId;
} }
@ -42,11 +50,21 @@ public class Occurences implements Serializable {
this.number = number; this.number = number;
} }
public String getRowId() {
return rowId;
}
public void setRowId(String rowId) {
this.rowId = rowId;
}
@Override @Override
public String toString() { public String toString() {
return "Occurence [value=" + value + ", number=" + number + "]"; return "Occurences [value=" + value + ", number=" + number + ", rowId="
+ rowId + "]";
} }
} }

View File

@ -0,0 +1,21 @@
/**
*
*/
package org.gcube.portlets.user.td.gwtservice.shared.tr.batch;
import java.io.Serializable;
import org.gcube.portlets.user.td.gwtservice.shared.OperationMonitor;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ReplaceBatchColumnMonitor extends OperationMonitor implements Serializable {
private static final long serialVersionUID = -7694151843138161474L;
}

View File

@ -0,0 +1,63 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.batch;
import java.io.Serializable;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
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 ReplaceBatchColumnSession implements Serializable {
private static final long serialVersionUID = -1896235499708614266L;
protected TRId trId;
protected ColumnData columnData;
protected ArrayList<ReplaceEntry> replaceEntryList;
protected boolean replaceDimension;
public TRId getTrId() {
return trId;
}
public void setTrId(TRId trId) {
this.trId = trId;
}
public ColumnData getColumnData() {
return columnData;
}
public void setColumnData(ColumnData columnData) {
this.columnData = columnData;
}
public ArrayList<ReplaceEntry> getReplaceEntryList() {
return replaceEntryList;
}
public void setReplaceEntryList(ArrayList<ReplaceEntry> replaceEntryList) {
this.replaceEntryList = replaceEntryList;
}
public boolean isReplaceDimension() {
return replaceDimension;
}
public void setReplaceDimension(boolean replaceDimension) {
this.replaceDimension = replaceDimension;
}
@Override
public String toString() {
return "ReplaceBatchColumnSession [trId=" + trId + ", columnData="
+ columnData + ", replaceEntryList=" + replaceEntryList
+ ", replaceDimension=" + replaceDimension + "]";
}
}

View File

@ -0,0 +1,110 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.batch;
import java.io.Serializable;
import org.gcube.portlets.user.td.gwtservice.shared.tr.DimensionRow;
public class ReplaceEntry implements Serializable {
private static final long serialVersionUID = 1630393311734647924L;
protected String value;
protected String rowId;//For view column, contains the value of the associated dimension column
protected Integer number;
protected String replacementValue;
protected DimensionRow replacementDimensionRow;
public ReplaceEntry(){
}
/**
* Create a ReplaceEntry for normal column type
*
* @param value
* @param number
* @param replacementValue
* @param replacementDimensionRow
*/
public ReplaceEntry(String value, Integer number, String replacementValue, DimensionRow replacementDimensionRow) {
this.value = value;
this.rowId = null;
this.number = number;
this.replacementValue = replacementValue;
this.replacementDimensionRow = replacementDimensionRow;
}
/**
* Create a ReplaceEntry for view column type
*
* @param value
* @param number
* @param replacementValue
* @param replacementDimensionRow
*/
public ReplaceEntry(String value, String rowId, Integer number, String replacementValue, DimensionRow replacementDimensionRow) {
this.value = value;
this.rowId = rowId;
this.number = number;
this.replacementValue = replacementValue;
this.replacementDimensionRow = replacementDimensionRow;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public Integer getNumber() {
return number;
}
public void setNumber(Integer number) {
this.number = number;
}
public String getReplacementValue() {
return replacementValue;
}
public void setReplacementValue(String replacementValue) {
this.replacementValue = replacementValue;
}
public DimensionRow getReplacementDimensionRow() {
return replacementDimensionRow;
}
public void setReplacementDimensionRow(DimensionRow replacementDimensionRow) {
this.replacementDimensionRow = replacementDimensionRow;
}
public String getRowId() {
return rowId;
}
public void setRowId(String rowId) {
this.rowId = rowId;
}
@Override
public String toString() {
return "ReplaceEntry [value=" + value + ", rowId=" + rowId
+ ", number=" + number + ", replacementValue="
+ replacementValue + ", replacementDimensionRow="
+ replacementDimensionRow + "]";
}
}