Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@95802 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-05-16 15:27:14 +00:00
parent 6321051e95
commit 342f1b3178
3 changed files with 290 additions and 237 deletions

View File

@ -127,6 +127,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.share.Contacts;
import org.gcube.portlets.user.td.gwtservice.shared.share.ShareInfo;
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
import org.gcube.portlets.user.td.gwtservice.shared.task.InvocationS;
import org.gcube.portlets.user.td.gwtservice.shared.task.JobS;
import org.gcube.portlets.user.td.gwtservice.shared.task.State;
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskS;
@ -194,7 +195,6 @@ import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
*
* @author "Giancarlo Panichi" <a
@ -420,7 +420,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
TabResource currentTR = SessionUtil.getTabResource(session);
if (currentTR == null) {
logger.error("CURRENT_TABULAR_RESOURCE is null");
@ -460,9 +459,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
cData.setDataTypeName(c.getDataType().getName());
ColumnRelationship rel = c.getRelationship();
if (rel != null) {
RelationshipData relData=new RelationshipData(
rel.getTargetTableId().getValue(),
rel.getTargetColumnId().getValue());
RelationshipData relData = new RelationshipData(rel
.getTargetTableId().getValue(), rel
.getTargetColumnId().getValue());
cData.setRelationship(relData);
}
@ -543,7 +542,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
@ -574,9 +572,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
cData.setDataTypeName(c.getDataType().getName());
ColumnRelationship rel = c.getRelationship();
if (rel != null) {
RelationshipData relData=new RelationshipData(
rel.getTargetTableId().getValue(),
rel.getTargetColumnId().getValue());
RelationshipData relData = new RelationshipData(rel
.getTargetTableId().getValue(), rel
.getTargetColumnId().getValue());
cData.setRelationship(relData);
}
@ -698,9 +696,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
cData.setDataTypeName(c.getDataType().getName());
ColumnRelationship rel = c.getRelationship();
if (rel != null) {
RelationshipData relData=new RelationshipData(
rel.getTargetTableId().getValue(),
rel.getTargetColumnId().getValue());
RelationshipData relData = new RelationshipData(rel
.getTargetTableId().getValue(), rel
.getTargetColumnId().getValue());
cData.setRelationship(relData);
}
@ -816,9 +814,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
cData.setDataTypeName(c.getDataType().getName());
ColumnRelationship rel = c.getRelationship();
if (rel != null) {
RelationshipData relData=new RelationshipData(
rel.getTargetTableId().getValue(),
rel.getTargetColumnId().getValue());
RelationshipData relData = new RelationshipData(rel
.getTargetTableId().getValue(), rel
.getTargetColumnId().getValue());
cData.setRelationship(relData);
}
@ -979,7 +977,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
logger.debug("Validation Column: " + columns.size());
return columns;
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (Throwable e) {
@ -1051,9 +1048,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
colData.setTrId(newTRId);
ColumnRelationship rel = column.getRelationship();
if (rel != null) {
RelationshipData relData=new RelationshipData(
rel.getTargetTableId().getValue(),
rel.getTargetColumnId().getValue());
RelationshipData relData = new RelationshipData(rel
.getTargetTableId().getValue(), rel
.getTargetColumnId().getValue());
colData.setRelationship(relData);
}
@ -1113,9 +1110,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
colData.setTrId(newTRId);
ColumnRelationship rel = column.getRelationship();
if (rel != null) {
RelationshipData relData=new RelationshipData(
rel.getTargetTableId().getValue(),
rel.getTargetColumnId().getValue());
RelationshipData relData = new RelationshipData(rel
.getTargetTableId().getValue(), rel
.getTargetColumnId().getValue());
colData.setRelationship(relData);
}
if (column.contains(ViewColumnMetadata.class)) {
@ -1150,7 +1147,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
logger.debug("getLastTable: " + tData);
return tData;
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (Throwable e) {
@ -1219,9 +1215,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
colData.setTrId(newTRId);
ColumnRelationship rel = column.getRelationship();
if (rel != null) {
RelationshipData relData=new RelationshipData(
rel.getTargetTableId().getValue(),
rel.getTargetColumnId().getValue());
RelationshipData relData = new RelationshipData(rel
.getTargetTableId().getValue(), rel
.getTargetColumnId().getValue());
colData.setRelationship(relData);
}
@ -1282,9 +1278,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
colData.setTrId(newTRId);
ColumnRelationship rel = column.getRelationship();
if (rel != null) {
RelationshipData relData=new RelationshipData(
rel.getTargetTableId().getValue(),
rel.getTargetColumnId().getValue());
RelationshipData relData = new RelationshipData(rel
.getTargetTableId().getValue(), rel
.getTargetColumnId().getValue());
colData.setRelationship(relData);
}
@ -1435,7 +1431,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
// logger.debug("TabResource: "+t);
return t;
} catch (Throwable e) {
logger.error("Error retrieving tabular resources metadata in retrieveTRMetadataFromService(): "
+ e.getLocalizedMessage());
@ -2179,11 +2174,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
// Import SDMX Codelist takes id 200
OperationDefinition importSDMXCodelistOperation = OperationDefinitionMap
.map(OperationsId.SDMXCodelistImport.toString(),
service);
.map(OperationsId.SDMXCodelistImport.toString(), service);
TabResource sdmxImportTabResource = sdmxImportSession
.getTabResource();
@ -2657,7 +2650,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
"Tabular Data Service error loading file on storage");
}
Map<String, Object> parameterInstance = csvImportFileParameter(
fileUrlOnStorage, fileUploadSession, csvImportSession);
@ -2667,7 +2659,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
// Import CSV file
OperationDefinition importCSVFileOperation = OperationDefinitionMap
@ -3067,8 +3058,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
ArrayList<Validations> vList = new ArrayList<Validations>();
int i = 0;
for (Validation v : vals) {
valid = new Validations(String.valueOf(i), v.getDescription(),
v.isValid());
valid = new Validations(String.valueOf(i),
v.getDescription(), v.isValid());
vList.add(valid);
i++;
}
@ -3517,7 +3508,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
// Export CSV file
OperationDefinition exportCSVFileOperation = OperationDefinitionMap
.map(OperationsId.CSVExport.toString(), service);
@ -3717,7 +3707,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
OperationExecution invocation = null;
logger.debug(changeColumnTypeSession.toString());
OperationDefinition operationDefinition;
Map<String, Object> map = new HashMap<String, Object>();
@ -3727,16 +3716,14 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
switch (type) {
case ANNOTATION:
operationDefinition = OperationDefinitionMap.map(
OperationsId.ChangeToAnnotationColumn.toString(),
service);
OperationsId.ChangeToAnnotationColumn.toString(), service);
invocation = new OperationExecution(changeColumnTypeSession
.getColumnData().getColumnId(),
operationDefinition.getOperationId(), map);
break;
case ATTRIBUTE:
operationDefinition = OperationDefinitionMap.map(
OperationsId.ChangeToAttributeColumn.toString(),
service);
OperationsId.ChangeToAttributeColumn.toString(), service);
map.put(Constants.PARAMETER_TARGET_DATA_TYPE, ColumnDataTypeMap
.map(changeColumnTypeSession.getColumnDataTypeTarget()));
@ -3753,8 +3740,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
break;
case CODEDESCRIPTION:
operationDefinition = OperationDefinitionMap.map(
OperationsId.ChangeToCodeDescription.toString(),
service);
OperationsId.ChangeToCodeDescription.toString(), service);
invocation = new OperationExecution(changeColumnTypeSession
.getColumnData().getColumnId(),
operationDefinition.getOperationId(), map);
@ -3771,8 +3757,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
break;
case DIMENSION:
operationDefinition = OperationDefinitionMap.map(
OperationsId.ChangeToDimensionColumn.toString(),
service);
OperationsId.ChangeToDimensionColumn.toString(), service);
ColumnData col = changeColumnTypeSession
.getCodelistColumnReference();
logger.debug("ReferenceColumn To Set: " + col);
@ -3789,9 +3774,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
operationDefinition.getOperationId(), map);
break;
case MEASURE:
operationDefinition = OperationDefinitionMap
.map(OperationsId.ChangeToMeasureColumn.toString(),
service);
operationDefinition = OperationDefinitionMap.map(
OperationsId.ChangeToMeasureColumn.toString(), service);
map.put(Constants.PARAMETER_TARGET_DATA_TYPE, ColumnDataTypeMap
.map(changeColumnTypeSession.getColumnDataTypeTarget()));
@ -3838,8 +3822,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
if (replaceColumnSession.isReplaceDimension()) {
logger.debug("Is a Replace of view column");
operationDefinition = OperationDefinitionMap.map(
OperationsId.ReplaceColumnByExpression.toString(),
service);
OperationsId.ReplaceColumnByExpression.toString(), service);
Expression condition = ExpressionGenerator
.genReplaceValueParameterCondition(replaceColumnSession);
@ -3860,8 +3843,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
logger.debug("Is a Replace of basic column");
operationDefinition = OperationDefinitionMap.map(
OperationsId.ReplaceColumnByExpression.toString(),
service);
OperationsId.ReplaceColumnByExpression.toString(), service);
Expression condition = ExpressionGenerator
.genReplaceValueParameterCondition(replaceColumnSession);
@ -3881,7 +3863,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
return invocation;
}
/**
* Retrieve OperationExecution for change column type
*
@ -3890,8 +3871,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
*/
// TODO Check this operation
protected OperationExecution retrieveOperationExecution(
TabularDataService service,
EditRowSession editRowSession)
TabularDataService service, EditRowSession editRowSession)
throws TDGWTServiceException {
OperationExecution invocation = null;
@ -3901,18 +3881,18 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Map<String, Object> map = new HashMap<String, Object>();
ValueMap valueMap = new ValueMap();
ArrayList<Map<String,Object>> compositeValue=valueMap.genValueMap(editRowSession);
ArrayList<Map<String, Object>> compositeValue = valueMap
.genValueMap(editRowSession);
if (editRowSession.isNewRow()) {
logger.debug("Is a add row");
operationDefinition = OperationDefinitionMap.map(
OperationsId.AddRow.toString(),
service);
OperationsId.AddRow.toString(), service);
map.put(Constants.PARAMETER_ADD_ROW_COMPOSITE,
compositeValue);
map.put(Constants.PARAMETER_ADD_ROW_COMPOSITE, compositeValue);
invocation = new OperationExecution(operationDefinition.getOperationId(), map);
invocation = new OperationExecution(
operationDefinition.getOperationId(), map);
} else {
logger.debug("Is a edit row");
@ -3921,16 +3901,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
OperationsId.ModifyTuplesValuesByExpression.toString(),
service);
map.put(Constants.PARAMETER_ADD_ROW_COMPOSITE,
compositeValue);
map.put(Constants.PARAMETER_ADD_ROW_COMPOSITE, compositeValue);
invocation = new OperationExecution(operationDefinition.getOperationId(), map);
invocation = new OperationExecution(
operationDefinition.getOperationId(), map);
}
return invocation;
}
/**
* Retrieve OperationExecution for change column type
*
@ -3947,7 +3926,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
OperationExecution invocation = null;
logger.debug(replaceBatchColumnSession.toString());
OperationDefinition operationDefinition;
Map<String, Object> map = new HashMap<String, Object>();
@ -4068,8 +4046,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
switch (duplicatesSession.getDuplicateOp()) {
case VALIDATE:
operationDefinition = OperationDefinitionMap.map(
OperationsId.DuplicateTupleValidation.toString(),
service);
OperationsId.DuplicateTupleValidation.toString(), service);
map.put(Constants.PARAMETER_KEY, columnReferences);
@ -4078,9 +4055,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
break;
case DELETE:
operationDefinition = OperationDefinitionMap
.map(OperationsId.RemoveDuplicateTuples.toString(),
service);
operationDefinition = OperationDefinitionMap.map(
OperationsId.RemoveDuplicateTuples.toString(), service);
map.put(Constants.PARAMETER_KEY, columnReferences);
@ -4332,7 +4308,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setChangeColumnTypeTask(session, task);
}
logger.debug("ChangeColumnTypeMonitor(): " + changeColumnTypeMonitor);
logger.debug("ChangeColumnTypeMonitor(): "
+ changeColumnTypeMonitor);
return changeColumnTypeMonitor;
} catch (TDGWTSessionExpiredException e) {
@ -6265,7 +6242,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
*
* {@inheritDoc}
@ -6499,14 +6475,23 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
int i = 1;
ArrayList<Validations> validations = new ArrayList<Validations>();
for (ValidationDescriptor val : job.getValidations()) {
Validations validation = new Validations(String.valueOf(i),
val.getDescription(), val.isValid());
Validations validation = new Validations(
String.valueOf(i), val.getDescription(),
val.isValid());
validations.add(validation);
i++;
}
InvocationS invocationS=null;
if (job.getInvocation() != null) {
invocationS = new InvocationS(job.getInvocation()
.getColumnId(), job.getInvocation()
.getIdentifier(), job.getInvocation()
.getOperationId(), job.getInvocation()
.getParameters());
}
JobS jobS = new JobS(String.valueOf(j), job.getProgress(),
job.getHumaReadableStatus(), job.getDescription(),
validations);
validations,invocationS);
jobSList.add(jobS);
j++;
@ -6536,7 +6521,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
@Override
public void startEditRow(EditRowSession editRowSession)
throws TDGWTServiceException {
@ -6557,13 +6541,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
Long id;
if (editRowSession.getTrId().isViewTable()) {
id=Long.valueOf(editRowSession.getTrId().getReferenceTargetTableId());
id = Long.valueOf(editRowSession.getTrId()
.getReferenceTargetTableId());
} else {
id = Long.valueOf(editRowSession.getTrId().getId());
}
TabularResourceId serviceTR = new TabularResourceId(
id);
TabularResourceId serviceTR = new TabularResourceId(id);
logger.debug("OperationInvocation: \n" + invocation.toString());
Task trTask = service.execute(invocation, serviceTR);
logger.debug("Start Task on service: TaskId " + trTask.getId());
@ -6574,8 +6558,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw e;
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException(
"Error in operation: "
throw new TDGWTServiceException("Error in operation: "
+ e.getLocalizedMessage());
}
@ -6673,15 +6656,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (Throwable e) {
logger.debug("Error in EditRowMonitor: "
+ e.getLocalizedMessage());
logger.debug("Error in EditRowMonitor: " + e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException("Error: "
+ e.getLocalizedMessage());
throw new TDGWTServiceException("Error: " + e.getLocalizedMessage());
}
}
}

View File

@ -0,0 +1,71 @@
package org.gcube.portlets.user.td.gwtservice.shared.task;
import java.io.Serializable;
import java.util.Map;
/**
*
* @author "Giancarlo Panichi"
*
*/
public class InvocationS implements Serializable {
private static final long serialVersionUID = -7112348181058962879L;
protected String columnId;
protected long operationId;
protected Long identifier;
protected Map<String, Object> parameters;
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 String getColumnId() {
return columnId;
}
public void setColumnId(String columnId) {
this.columnId = columnId;
}
public long getOperationId() {
return operationId;
}
public void setOperationId(long operationId) {
this.operationId = operationId;
}
public Long getIdentifier() {
return identifier;
}
public void setIdentifier(Long identifier) {
this.identifier = identifier;
}
public Map<String, Object> getParameters() {
return parameters;
}
public void setParameters(Map<String, Object> parameters) {
this.parameters = parameters;
}
@Override
public String toString() {
return "InvocationS [columnId=" + columnId + ", operationId="
+ operationId + ", identifier=" + identifier + ", parameters="
+ parameters + "]";
}
}

View File

@ -19,18 +19,20 @@ public class JobS implements Serializable {
protected String humaReadableStatus;
protected String description;
protected ArrayList<Validations> validations;
protected InvocationS invocation;
public JobS() {
}
public JobS(String id, float progress, String humaReadableStatus, String description,
ArrayList<Validations> validations) {
ArrayList<Validations> validations, InvocationS invocation) {
this.id=id;
this.progress=progress;
this.humaReadableStatus=humaReadableStatus;
this.description=description;
this.validations=validations;
this.invocation=invocation;
}
public String getId() {