Updated for curation on validations

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@95873 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-05-20 16:54:43 +00:00
parent 8df18051ef
commit 6fbe320733
9 changed files with 227 additions and 55 deletions

View File

@ -29,6 +29,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySessio
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.RefColumn;
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.batch.Occurrences;
@ -96,14 +97,13 @@ public interface TDGWTService extends RemoteService {
// TabularResource
/**
* Get current TRId
* Get current TRId
*
* @return
* @throws TDGWTServiceException
*/
public TRId getCurrentTRId() throws TDGWTServiceException;
/**
* Get informations on the current tabular resource
*
@ -204,11 +204,18 @@ public interface TDGWTService extends RemoteService {
*/
public ArrayList<TRMetadata> getTRMetadata(TRId trId)
throws TDGWTServiceException;
//Validations
/**
* Retreive a ColumnData that is a connection to external table
*
* @param refColumn
* @return
* @throws TDGWTServiceException
*/
public ColumnData getConnection(RefColumn refColumn)
throws TDGWTServiceException;
// Validations
/**
* Returns validations contained in the tasks
*
@ -216,9 +223,9 @@ public interface TDGWTService extends RemoteService {
* @return
* @throws TDGWTServiceException
*/
public ValidationsTasksMetadata getValidationsTasksMetadata(TRId trId)
throws TDGWTServiceException;
public ValidationsTasksMetadata getValidationsTasksMetadata(TRId trId)
throws TDGWTServiceException;
/**
* Return Validations Metadata of Table
*
@ -226,10 +233,9 @@ public interface TDGWTService extends RemoteService {
* @return
* @throws TDGWTServiceException
*/
public TabValidationsMetadata getTableValidationsMetadata(TRId trId)
public TabValidationsMetadata getTableValidationsMetadata(TRId trId)
throws TDGWTServiceException;
/**
* Returns ArrayList<ColumnData> that contains all the validation columns of
* columnName
@ -241,37 +247,34 @@ public interface TDGWTService extends RemoteService {
*/
public ArrayList<ColumnData> getValidationColumns(TRId trId,
String columnName) throws TDGWTServiceException;
//RollBack
// RollBack
/**
* Call rollback on tabular resource
*
* @param rollBackSession
* @throws TDGWTServiceException
*/
public void rollBack(RollBackSession rollBackSession)
public void rollBack(RollBackSession rollBackSession)
throws TDGWTServiceException;
/**
* Get Operation Monitor during the rollback
* Get Operation Monitor during the rollback
*
* @return
* @throws TDGWTServiceException
*/
public RollBackSessionMonitor getRollBackMonitor()
throws TDGWTServiceException;
/**
* Call discard operation on tabular resource
*
* @param trId
* @throws TDGWTServiceException
*/
public RollBackSession discard(TRId trId)
throws TDGWTServiceException;
public RollBackSession discard(TRId trId) throws TDGWTServiceException;
// Share
/**
* Retrieves information sharing on the tabular resource
@ -596,11 +599,10 @@ public interface TDGWTService extends RemoteService {
* @return
* @throws TDGWTServiceException
*/
public EditRowMonitor getEditRowMonitor()
throws TDGWTServiceException;
public EditRowMonitor getEditRowMonitor() throws TDGWTServiceException;
/**
* Start edit row or add row
* Start edit row or add row
*
* @param labelColumnSession
* @throws TDGWTServiceException
@ -608,7 +610,6 @@ public interface TDGWTService extends RemoteService {
public void startEditRow(EditRowSession editRowSession)
throws TDGWTServiceException;
/**
* Get Operation Monitor during the Delete Rows operation
*
@ -805,8 +806,8 @@ public interface TDGWTService extends RemoteService {
* @throws TDGWTServiceException
*/
ArrayList<String> getLocales() throws TDGWTServiceException;
//History
// History
/**
* Retrieve History
*
@ -814,7 +815,7 @@ public interface TDGWTService extends RemoteService {
* @throws TDGWTServiceException
*/
ArrayList<OpHistory> getHistory() throws TDGWTServiceException;
/**
* Retrieve History for specific tabular resource
*
@ -823,14 +824,14 @@ public interface TDGWTService extends RemoteService {
* @throws TDGWTServiceException
*/
ArrayList<OpHistory> getHistory(TRId trId) throws TDGWTServiceException;
/**
*
* @return
* @throws TDGWTServiceException
*/
OpHistory getLastOperationInfo() throws TDGWTServiceException;
/**
*
* @param trId
@ -838,6 +839,5 @@ public interface TDGWTService extends RemoteService {
* @throws TDGWTServiceException
*/
OpHistory getLastOperationInfo(TRId trId) throws TDGWTServiceException;
}

View File

@ -28,6 +28,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySessio
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.RefColumn;
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.batch.Occurrences;
@ -100,6 +101,7 @@ public interface TDGWTServiceAsync {
void getColumnsForDimension(TRId trId, AsyncCallback<ArrayList<ColumnData>> callback);
void getColumn(TRId trId, String columnName, AsyncCallback<ColumnData> callback);
void getColumn(String columnLocalId,TRId trId, AsyncCallback<ColumnData> callback);
void getConnection(RefColumn refColumn, AsyncCallback<ColumnData> callback);
//Validations
void getValidationsTasksMetadata(TRId trId,AsyncCallback<ValidationsTasksMetadata> callback);

View File

@ -16,6 +16,7 @@ import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.user.td.gwtservice.server.file.FileUploadSession;
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.csv.CSVExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
@ -73,15 +74,15 @@ 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!");*/
/*username = Constants.DEFAULT_USER;
username = Constants.DEFAULT_USER;
String scope = Constants.DEFAULT_SCOPE;
httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, username);
session = SessionManager.getInstance().getASLSession(
httpSession.getId(), username);
session.setScope(scope);*/
session.setScope(scope);
} else {
session = SessionManager.getInstance().getASLSession(

View File

@ -64,6 +64,7 @@ import org.gcube.data.analysis.tabulardata.model.metadata.common.DescriptionsMet
import org.gcube.data.analysis.tabulardata.model.metadata.common.ImmutableLocalizedText;
import org.gcube.data.analysis.tabulardata.model.metadata.common.LocalizedText;
import org.gcube.data.analysis.tabulardata.model.metadata.common.NamesMetadata;
import org.gcube.data.analysis.tabulardata.model.metadata.common.TableDescriptorMetadata;
import org.gcube.data.analysis.tabulardata.model.metadata.common.Validation;
import org.gcube.data.analysis.tabulardata.model.metadata.common.ValidationsMetadata;
import org.gcube.data.analysis.tabulardata.model.metadata.table.DatasetViewTableMetadata;
@ -100,12 +101,13 @@ import org.gcube.portlets.user.td.gwtservice.server.file.FileUtil;
import org.gcube.portlets.user.td.gwtservice.server.storage.FilesStorage;
import org.gcube.portlets.user.td.gwtservice.server.trservice.ColumnDataTypeMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.ExpressionGenerator;
import org.gcube.portlets.user.td.gwtservice.server.trservice.ExtractReferences;
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationsId;
import org.gcube.portlets.user.td.gwtservice.server.trservice.QueryService;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TaskStateMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.ValueMap;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.OperationsId;
import org.gcube.portlets.user.td.gwtservice.shared.csv.AvailableCharsetList;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
@ -140,6 +142,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnViewData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.RefColumn;
import org.gcube.portlets.user.td.gwtservice.shared.tr.RelationshipData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
@ -3871,7 +3874,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
* @param replaceColumnSession
* @return
*/
// TODO Check this operation
protected OperationExecution retrieveOperationExecution(
TabularDataService service, EditRowSession editRowSession)
throws TDGWTServiceException {
@ -6487,6 +6490,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
validations.add(validation);
i++;
}
//TODO Fix refColumn
InvocationS invocationS=null;
if (job.getInvocation() != null) {
Map<String,Object> mapSent=new HashMap<String,Object>();
@ -6499,10 +6504,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
mapSent.put(key, o.toString());
}
RefColumn refColumn=ExtractReferences.extract(job.getInvocation());
invocationS = new InvocationS(job.getInvocation()
.getColumnId(), job.getInvocation()
.getIdentifier(), job.getInvocation()
.getOperationId(), mapSent);
.getOperationId(), mapSent, refColumn);
}
JobS jobS = new JobS(String.valueOf(j), job.getProgress(),
job.getHumaReadableStatus(), job.getDescription(),
@ -6678,5 +6685,44 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
//TODO Connect
@Override
public ColumnData getConnection(RefColumn refColumn)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("GetConnection on " + refColumn.toString());
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
TableId tableId = new TableId(
new Long(refColumn.getTableId()));
Table table=service.getTable(tableId);
TableDescriptorMetadata tableDesc=table.getMetadata(TableDescriptorMetadata.class);
if(tableDesc==null){
logger.error("Error in getConnection(): No TableDescriptorMetadata found for table "+table);
throw new TDGWTServiceException("Error in getConnection(): No TableDescriptorMetadata found for table "+table);
}
logger.debug("Table connect to tabular resource: "+tableDesc.getRefId());
TRId tId=new TRId(String.valueOf(tableDesc.getRefId()));
TRId trId=retrieveTabularResourceBasicData(tId);
ColumnData columnData=getColumn(refColumn.getColumnId(), trId);
return columnData;
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (Throwable e) {
logger.debug("Error in getConnection(): " + e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException("Error: " + e.getLocalizedMessage());
}
}
}

View File

@ -0,0 +1,52 @@
package org.gcube.portlets.user.td.gwtservice.server.trservice;
import java.util.Map;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution;
import org.gcube.data.analysis.tabulardata.model.column.ColumnReference;
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.tr.RefColumn;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author "Giancarlo Panichi"
*
*/
public class ExtractReferences {
protected static Logger logger = LoggerFactory
.getLogger(ExtractReferences.class);
public static RefColumn extract(OperationExecution op) {
logger.debug("ExtractReferences OperationExecution: "+op);
RefColumn refColumn = null;
Long opId = op.getOperationId();
if (opId.compareTo(OperationsId.ChangeToDimensionColumn.toLong())==0) {
refColumn = retrieveRefColumn(op);
}
logger.debug("ExtractReferences: " + refColumn);
return refColumn;
}
protected static RefColumn retrieveRefColumn(OperationExecution op) {
RefColumn refColumn = null;
Map<String, Object> parameters = op.getParameters();
ColumnReference columnReference = (ColumnReference) parameters
.get(Constants.PARAMETER_REFERENCE_COLUMN);
logger.debug("Parameter " + Constants.PARAMETER_REFERENCE_COLUMN + ": "
+ columnReference);
if (columnReference != null && columnReference.getColumnId() != null
&& columnReference.getTableId() != null) {
refColumn = new RefColumn(String.valueOf(columnReference
.getTableId().getValue()), columnReference.getColumnId()
.getValue());
}
return refColumn;
}
}

View File

@ -48,6 +48,7 @@ public class Constants {
public static final String NAME_PARAMETER_ID="NAME_PARAMETER_ID";
public static final String PARAMETER_KEY="key";
public static final String PARAMETER_REFERENCE_COLUMN="refColumn";
public static final String PARAMETER_PERIOD_FORMAT="periodFormat";
public static final String PARAMETER_EXPRESSION="expression";
@ -55,4 +56,8 @@ public class Constants {
public static final String PARAMETER_ROW_ID="rowId";
public static final String REQUEST_PROPERTIES_REFCOLUMN="RefColumn";
public static final String REQUEST_PROPERTIES_COLUMNID="ColumnId";
}

View File

@ -1,4 +1,4 @@
package org.gcube.portlets.user.td.gwtservice.server.trservice;
package org.gcube.portlets.user.td.gwtservice.shared;
/**
@ -129,6 +129,11 @@ public enum OperationsId {
public String toString() {
return id;
}
public Long toLong(){
return Long.valueOf(id);
}
}

View File

@ -3,6 +3,8 @@ package org.gcube.portlets.user.td.gwtservice.shared.task;
import java.io.Serializable;
import java.util.Map;
import org.gcube.portlets.user.td.gwtservice.shared.tr.RefColumn;
/**
*
* @author "Giancarlo Panichi"
@ -16,19 +18,21 @@ public class InvocationS implements Serializable {
protected long operationId;
protected Long identifier;
protected Map<String, Object> parameters;
public InvocationS(){
protected RefColumn refColumn;
public InvocationS() {
}
public InvocationS(String columnId,long operationId,Long identifier,Map<String, Object> parameters){
this.columnId=columnId;
this.operationId=operationId;
this.identifier=identifier;
this.parameters=parameters;
public InvocationS(String columnId, long operationId, Long identifier,
Map<String, Object> parameters, RefColumn refColumn) {
this.columnId = columnId;
this.operationId = operationId;
this.identifier = identifier;
this.parameters = parameters;
this.refColumn=refColumn;
}
public String getColumnId() {
return columnId;
}
@ -60,12 +64,22 @@ public class InvocationS implements Serializable {
public void setParameters(Map<String, Object> parameters) {
this.parameters = parameters;
}
public RefColumn getRefColumn() {
return refColumn;
}
public void setRefColumn(RefColumn refColumn) {
this.refColumn = refColumn;
}
@Override
public String toString() {
return "InvocationS [columnId=" + columnId + ", operationId="
+ operationId + ", identifier=" + identifier + ", parameters="
+ parameters + "]";
+ parameters + ", refColumn=" + refColumn + "]";
}
}

View File

@ -0,0 +1,47 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr;
import java.io.Serializable;
/**
*
* @author "Giancarlo Panichi"
*
*/
public class RefColumn implements Serializable {
private static final long serialVersionUID = -5400296839423693397L;
protected String tableId;
protected String columnId;
public RefColumn(){
}
public RefColumn(String tableId, String columnId){
this.tableId=tableId;
this.columnId=columnId;
}
public String getTableId() {
return tableId;
}
public void setTableId(String tableId) {
this.tableId = tableId;
}
public String getColumnId() {
return columnId;
}
public void setColumnId(String columnId) {
this.columnId = columnId;
}
@Override
public String toString() {
return "RefColumn [tableId=" + tableId + ", columnId=" + columnId + "]";
}
}