Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@96321 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-05-30 11:05:31 +00:00
parent 5c696b1227
commit a99b5a602d
9 changed files with 471 additions and 27 deletions

View File

@ -43,6 +43,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.OccurrencesForRepla
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.column.AddColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.AddColumnSession;
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.LabelColumnMonitor;
@ -712,6 +714,28 @@ public interface TDGWTService extends RemoteService {
ChangeColumnTypeSession changeColumnTypeSession)
throws TDGWTServiceException;
/**
* Get Operation Monitor during the Add Column operation
*
*
* @return
* @throws TDGWTServiceException
*/
public AddColumnMonitor getAddColumnMonitor()
throws TDGWTServiceException;
/**
* Start add column
*
*
* @param addColumnSession
* @throws TDGWTServiceException
*/
public void startAddColumn(AddColumnSession addColumnSession)
throws TDGWTServiceException;
/**
* Get Operation Monitor during the Delete Column operation
*

View File

@ -42,6 +42,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.OccurrencesForRepla
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.column.AddColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.AddColumnSession;
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.LabelColumnMonitor;
@ -205,6 +207,8 @@ public interface TDGWTServiceAsync {
//Column Operation
void getChangeColumnTypeMonitor(AsyncCallback<ChangeColumnTypeMonitor> callback);
void startChangeColumnType(ChangeColumnTypeSession changeColumnTypeSession,AsyncCallback<Void> callback);
void getAddColumnMonitor(AsyncCallback<AddColumnMonitor> callback);
void startAddColumn(AddColumnSession addColumnSession,AsyncCallback<Void> callback);
void getDeleteColumnMonitor(AsyncCallback<DeleteColumnMonitor> callback);
void startDeleteColumn(DeleteColumnSession deleteColumnSession,AsyncCallback<Void> callback);
void getLabelColumnMonitor(AsyncCallback<LabelColumnMonitor> callback);

View File

@ -34,10 +34,14 @@ public class SessionConstants {
protected static final String CHANGE_COLUMN_TYPE_MONITOR = "CHANGE_COLUMN_TYPE_MONITOR";
protected static final String CHANGE_COLUMN_TYPE_TASK = "CHANGE_COLUMN_TYPE_TASK";
protected static final String ADD_COLUMN_SESSION = "ADD_COLUMN_SESSION";
protected static final String ADD_COLUMN_MONITOR = "ADD_COLUMN_MONITOR";
protected static final String ADD_COLUMN_TASK = "ADD_COLUMN_TASK";
protected static final String DELETE_COLUMN_SESSION = "DELETE_COLUMN_SESSION";
protected static final String DELETE_COLUMN_MONITOR = "DELETE_COLUMN_MONITOR";
protected static final String DELETE_COLUMN_TASK = "DELETE_COLUMN_TASK";
protected static final String EDIT_ROW_SESSION = "EDIT_ROW_SESSION";
protected static final String EDIT_ROW_MONITOR = "EDIT_ROW_MONITOR";
protected static final String EDIT_ROW_TASK = "EDIT_ROW_TASK";

View File

@ -36,6 +36,8 @@ 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.column.AddColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.AddColumnSession;
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.LabelColumnMonitor;
@ -642,7 +644,75 @@ public class SessionUtil {
httpSession.removeAttribute(SessionConstants.CHANGE_THE_COLUMN_LABEL_TASK);
httpSession.setAttribute(SessionConstants.CHANGE_THE_COLUMN_LABEL_TASK, task);
}
//
public static AddColumnSession getAddColumnSession(
HttpSession httpSession) {
AddColumnSession addColumnSession = (AddColumnSession) httpSession
.getAttribute(SessionConstants.ADD_COLUMN_SESSION);
if (addColumnSession != null) {
return addColumnSession;
} else {
addColumnSession = new AddColumnSession();
httpSession
.setAttribute(SessionConstants.ADD_COLUMN_SESSION, addColumnSession);
return addColumnSession;
}
}
public static void setAddColumnSession(HttpSession httpSession,
AddColumnSession addColumnSession) {
AddColumnSession ac = (AddColumnSession) httpSession
.getAttribute(SessionConstants.ADD_COLUMN_SESSION);
if (ac != null) {
httpSession.removeAttribute(SessionConstants.ADD_COLUMN_SESSION);
}
httpSession.setAttribute(SessionConstants.ADD_COLUMN_SESSION, addColumnSession);
}
public static AddColumnMonitor getAddColumnMonitor(
HttpSession httpSession) {
AddColumnMonitor addColumnMonitor = (AddColumnMonitor) httpSession
.getAttribute(SessionConstants.ADD_COLUMN_MONITOR);
if (addColumnMonitor != null) {
return addColumnMonitor;
} else {
addColumnMonitor = new AddColumnMonitor();
httpSession
.setAttribute(SessionConstants.ADD_COLUMN_MONITOR, addColumnMonitor);
return addColumnMonitor;
}
}
public static void setAddColumnMonitor(HttpSession httpSession,
AddColumnMonitor addColumnMonitor) {
AddColumnMonitor cm = (AddColumnMonitor) httpSession
.getAttribute(SessionConstants.ADD_COLUMN_MONITOR);
if (cm != null) {
httpSession.removeAttribute(SessionConstants.ADD_COLUMN_MONITOR);
}
httpSession.setAttribute(SessionConstants.ADD_COLUMN_MONITOR, addColumnMonitor);
}
public static Task getAddColumnTask(HttpSession httpSession) {
Task monitor = (Task) httpSession.getAttribute(SessionConstants.ADD_COLUMN_TASK);
if (monitor == null) {
logger.error("ADD_COLUMN_TASK was not acquired");
}
return monitor;
}
public static void setAddColumnTask(HttpSession httpSession, Task task) {
Task monitor = (Task) httpSession.getAttribute(SessionConstants.ADD_COLUMN_TASK);
if (monitor != null)
httpSession.removeAttribute(SessionConstants.ADD_COLUMN_TASK);
httpSession.setAttribute(SessionConstants.ADD_COLUMN_TASK, task);
}
//
public static DeleteColumnSession getDeleteColumnSession(

View File

@ -150,6 +150,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.DefNewColumn;
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;
@ -160,6 +161,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnM
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.column.AddColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.AddColumnSession;
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.LabelColumnMonitor;
@ -4093,6 +4096,37 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
return invocations;
}
/**
*
* @param service
* @param deleteColumnSession
* @return
* @throws TDGWTServiceException
*/
//TODO
protected OperationExecution retrieveOperationExecution(
TabularDataService service, AddColumnSession addColumnSession)
throws TDGWTServiceException {
logger.debug(addColumnSession.toString());
OperationDefinition operationDefinition;
operationDefinition = OperationDefinitionMap.map(
OperationsId.AddColumn.toString(), service);
Map<String, Object> map = new HashMap<String, Object>();
DefNewColumn col = addColumnSession.getColumn();
OperationExecution invocation = null;
invocation = new OperationExecution(operationDefinition.getOperationId(), map);
return invocation;
}
/**
*
* @param service
@ -4435,7 +4469,161 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
*
* {@inheritDoc}
*/
//TODO
public void startAddColumn(AddColumnSession addColumnSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setAddColumnSession(session, addColumnSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
OperationExecution invocation = retrieveOperationExecution(
service, addColumnSession);
if (invocation == null) {
throw new TDGWTServiceException(
"Error Add Column: Operation not supported for now!");
}
TabularResourceId serviceTR = new TabularResourceId(
Long.valueOf(addColumnSession.getTrId().getId()));
logger.debug("OperationInvocation: \n" + invocation.toString());
Task trTask = service.execute(invocation, serviceTR);
logger.debug("Start Task on service: TaskId " + trTask.getId());
SessionUtil.setAddColumnTask(session, trTask);
return;
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException("Error in AddColumn: "
+ e.getLocalizedMessage());
}
}
/**
* {@inheritDoc}
*/
public AddColumnMonitor getAddColumnMonitor()
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
AddColumnSession addColumnSession = SessionUtil
.getAddColumnSession(session);
Task task = SessionUtil.getAddColumnTask(session);
AddColumnMonitor addColumnMonitor = new AddColumnMonitor();
if (task == null) {
logger.debug("Task null");
throw new TDGWTServiceException(
"Error in AddColumnMonitor task null");
} else {
TaskStatus status = task.getStatus();
if (status == null) {
logger.debug("Services TaskStatus : null");
throw new TDGWTServiceException(
"Error in AddColumnMonitor Status null");
} else {
logger.debug("Services TaskStatus: " + task.getStatus());
addColumnMonitor.setStatus(TaskStateMap.map(task
.getStatus()));
Table table;
TRId trId;
TabResource tabResource;
switch (addColumnMonitor.getStatus()) {
case FAILED:
if (task.getResult() != null) {
logger.debug("Task exception:"
+ task.getErrorCause());
task.getErrorCause().printStackTrace();
addColumnMonitor.setError(new Throwable(task
.getErrorCause()));
} else {
logger.debug("Task exception: Error In AddColumnMonitor");
addColumnMonitor.setError(new Throwable(
"Error Add Column"));
}
addColumnMonitor.setProgress(task.getProgress());
break;
case SUCCEDED:
logger.debug("Task Result:" + task.getResult());
addColumnMonitor.setProgress(task.getProgress());
table = task.getResult().getPrimaryTable();
logger.debug("Table retrieved: " + table.toString());
trId = new TRId();
trId.setId(addColumnSession.getTrId().getId());
trId = retrieveTabularResourceBasicData(trId);
addColumnMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
tabResource.setTrId(trId);
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, trId);
break;
case IN_PROGRESS:
addColumnMonitor.setProgress(task.getProgress());
break;
case VALIDATING_RULES:
addColumnMonitor.setProgress(task.getProgress());
break;
case GENERATING_VIEW:
break;
case ABORTED:
break;
case STOPPED:
logger.debug("Task Result:" + task.getResult());
addColumnMonitor.setProgress(task.getProgress());
table = task.getResult().getPrimaryTable();
logger.debug("Table retrieved: " + table.toString());
trId = new TRId();
trId.setId(addColumnSession.getTrId().getId());
trId = retrieveTabularResourceBasicData(trId);
addColumnMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
tabResource.setTrId(trId);
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, trId);
break;
case INITIALIZING:
break;
default:
break;
}
}
SessionUtil.setAddColumnTask(session, task);
}
logger.debug("AddColumnMonitor(): " + addColumnMonitor);
return addColumnMonitor;
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException(
"Error in add column monitor AddColumnMonitor: "
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}

View File

@ -78,7 +78,7 @@ public enum OperationsId {
ChangeTableType("1002"),
CreateDatasetView("1003"),
RemoveColumn("1004"),
AddsAColumn("1005"),
AddColumn("1005"),
ColumnNameAdd("1006"),
ColumnNameRemove("1007"),
TableNameAdd("1008"),

View File

@ -2,7 +2,9 @@ package org.gcube.portlets.user.td.gwtservice.shared.tr;
import java.io.Serializable;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.TimeDimensionType;
/**
*
@ -12,23 +14,89 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeC
public class DefNewColumn implements Serializable {
private static final long serialVersionUID = 7467523779864189492L;
protected String id; //Only for grid or combo
protected ColumnTypeCode columnType;
protected ColumnDataType columnDataType;
protected String defaultValue;
protected String label;
protected String localeName;
protected TimeDimensionType timeDimensionType;
protected ColumnData codelistColumnReference;
public DefNewColumn() {
}
public DefNewColumn(String id, String label,
ColumnTypeCode columnType, String localeName,String defaultValue) {
this.columnType=columnType;
this.defaultValue=defaultValue;
this.label=label;
this.localeName=localeName;
/**
* For Attribute Column
*
* @param label
* @param columnType
* @param localeName
* @param defaultValue
*/
public DefNewColumn(String label, ColumnTypeCode columnType,
ColumnDataType columnDataType, String defaultValue) {
this.label = label;
this.columnType = columnType;
this.columnDataType = columnDataType;
this.defaultValue = defaultValue;
}
/**
* For CodeName Column
*
* @param label
* @param columnType
* @param localeName
* @param defaultValue
*/
public DefNewColumn(String label, ColumnTypeCode columnType,
String localeName, String defaultValue) {
this.label = label;
this.columnType = columnType;
this.localeName = localeName;
this.defaultValue = defaultValue;
}
/**
* For Dimension
*
*
* @param label
* @param columnType
* @param timeDimensionType
* @param defaultValue
*/
public DefNewColumn(String label, ColumnTypeCode columnType,
ColumnData codelistColumnReference, String defaultValue) {
this.label = label;
this.columnType = columnType;
this.codelistColumnReference= codelistColumnReference;
this.defaultValue = defaultValue;
}
/**
* For TimeDimension
*
*
* @param label
* @param columnType
* @param timeDimensionType
* @param defaultValue
*/
public DefNewColumn(String label, ColumnTypeCode columnType,
TimeDimensionType timeDimensionType, String defaultValue) {
this.label = label;
this.columnType = columnType;
this.timeDimensionType=timeDimensionType;
this.defaultValue = defaultValue;
}
public String getLabel() {
@ -55,15 +123,6 @@ public class DefNewColumn implements Serializable {
this.defaultValue = defaultValue;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLocaleName() {
return localeName;
}
@ -72,16 +131,37 @@ public class DefNewColumn implements Serializable {
this.localeName = localeName;
}
@Override
public String toString() {
return "DefNewColumn [id=" + id + ", columnType=" + columnType
+ ", defaultValue=" + defaultValue + ", label=" + label
+ ", localeName=" + localeName + "]";
public ColumnDataType getColumnDataType() {
return columnDataType;
}
public void setColumnDataType(ColumnDataType columnDataType) {
this.columnDataType = columnDataType;
}
public TimeDimensionType getTimeDimensionType() {
return timeDimensionType;
}
public void setTimeDimensionType(TimeDimensionType timeDimensionType) {
this.timeDimensionType = timeDimensionType;
}
public ColumnData getCodelistColumnReference() {
return codelistColumnReference;
}
public void setCodelistColumnReference(ColumnData codelistColumnReference) {
this.codelistColumnReference = codelistColumnReference;
}
@Override
public String toString() {
return "DefNewColumn [columnType=" + columnType + ", columnDataType="
+ columnDataType + ", defaultValue=" + defaultValue
+ ", label=" + label + ", localeName=" + localeName
+ ", timeDimensionType=" + timeDimensionType
+ ", codelistColumnReference=" + codelistColumnReference + "]";
}
}

View File

@ -0,0 +1,21 @@
/**
*
*/
package org.gcube.portlets.user.td.gwtservice.shared.tr.column;
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 AddColumnMonitor extends OperationMonitor implements Serializable {
private static final long serialVersionUID = -7694151843138161474L;
}

View File

@ -0,0 +1,53 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.column;
import java.io.Serializable;
import org.gcube.portlets.user.td.gwtservice.shared.tr.DefNewColumn;
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 AddColumnSession implements Serializable {
private static final long serialVersionUID = -1896235499708614266L;
protected TRId trId;
protected DefNewColumn column;
public AddColumnSession(){
}
public AddColumnSession(TRId trId,DefNewColumn column){
this.trId=trId;
this.column=column;
}
public TRId getTrId() {
return trId;
}
public void setTrId(TRId trId) {
this.trId = trId;
}
public DefNewColumn getColumn() {
return column;
}
public void setColumn(DefNewColumn column) {
this.column = column;
}
@Override
public String toString() {
return "AddColumnSession [trId=" + trId + ", column=" + column + "]";
}
}