Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@91402 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-02-11 15:52:40 +00:00
parent 1097b52459
commit 65bb6cdc22
7 changed files with 345 additions and 10 deletions

View File

@ -24,6 +24,8 @@ 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.column.DeleteColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRMetadata;
@ -394,6 +396,7 @@ public interface TDGWTService extends RemoteService {
/**
* Get Operation Monitor during the Delete Column operation
*
*
* @return
* @throws TDGWTServiceException
*/
@ -403,7 +406,8 @@ public interface TDGWTService extends RemoteService {
/**
* Start delete column
*
* @param changeColumnTypeSession
*
* @param deleteColumnSession
* @throws TDGWTServiceException
*/
public void startDeleteColumn(
@ -411,6 +415,27 @@ public interface TDGWTService extends RemoteService {
throws TDGWTServiceException;
/**
* Get Operation Monitor during the Change the Column Label operation
*
*
* @return
* @throws TDGWTServiceException
*/
public LabelColumnMonitor getLabelColumnMonitor()
throws TDGWTServiceException;
/**
* Start change the column label
*
* @param labelColumnSession
* @throws TDGWTServiceException
*/
public void startLabelColumn(
LabelColumnSession labelColumnSession)
throws TDGWTServiceException;
}

View File

@ -24,6 +24,8 @@ 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.column.DeleteColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRMetadata;
@ -135,5 +137,8 @@ public interface TDGWTServiceAsync {
void startChangeColumnType(ChangeColumnTypeSession changeColumnTypeSession,AsyncCallback<Void> callback);
void getDeleteColumnMonitor(AsyncCallback<DeleteColumnMonitor> callback);
void startDeleteColumn(DeleteColumnSession deleteColumnSession,AsyncCallback<Void> callback);
void getLabelColumnMonitor(AsyncCallback<LabelColumnMonitor> callback);
void startLabelColumn(LabelColumnSession labelColumnSession,AsyncCallback<Void> 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.tr.TabResource;
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;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession;
@ -78,6 +80,9 @@ public class SessionUtil {
protected static final String DELETE_COLUMN_MONITOR = "DELETE_COLUMN_MONITOR";
protected static final String DELETE_COLUMN_TASK = "DELETE_COLUMN_TASK";
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_TASK = "CHANGE_THE_COLUMN_LABEL_TASK";
protected static final String CODELISTS_PAGING_LOADED = "CODELISTS_PAGING_LOADED";
protected static final String CODELISTS_PAGING_LOADED_DIRECTION = "CODELISTS_PAGING_LOADED_DIRECTION";
@ -591,6 +596,76 @@ public class SessionUtil {
///
public static LabelColumnSession getLabelColumnSession(
HttpSession httpSession) {
LabelColumnSession labelColumnSession = (LabelColumnSession) httpSession
.getAttribute(CHANGE_THE_COLUMN_LABEL_SESSION);
if (labelColumnSession != null) {
return labelColumnSession;
} else {
labelColumnSession = new LabelColumnSession();
httpSession.setAttribute(CHANGE_THE_COLUMN_LABEL_SESSION,
labelColumnSession);
return labelColumnSession;
}
}
public static void setLabelColumnSession(HttpSession httpSession,
LabelColumnSession labelColumnSession) {
LabelColumnSession lc = (LabelColumnSession) httpSession
.getAttribute(CHANGE_THE_COLUMN_LABEL_SESSION);
if (lc != null) {
httpSession.removeAttribute(CHANGE_THE_COLUMN_LABEL_SESSION);
}
httpSession.setAttribute(CHANGE_THE_COLUMN_LABEL_SESSION,
labelColumnSession);
}
public static LabelColumnMonitor getLabelColumnMonitor(
HttpSession httpSession) {
LabelColumnMonitor labelColumnMonitor = (LabelColumnMonitor) httpSession
.getAttribute(CHANGE_THE_COLUMN_LABEL_MONITOR);
if (labelColumnMonitor != null) {
return labelColumnMonitor;
} else {
labelColumnMonitor = new LabelColumnMonitor();
httpSession.setAttribute(CHANGE_THE_COLUMN_LABEL_MONITOR,
labelColumnMonitor);
return labelColumnMonitor;
}
}
public static void setLabelColumnMonitor(HttpSession httpSession,
LabelColumnMonitor labelColumnMonitor) {
LabelColumnMonitor lc = (LabelColumnMonitor) httpSession
.getAttribute(CHANGE_THE_COLUMN_LABEL_MONITOR);
if (lc != null) {
httpSession.removeAttribute(CHANGE_THE_COLUMN_LABEL_MONITOR);
}
httpSession.setAttribute(CHANGE_THE_COLUMN_LABEL_MONITOR,
labelColumnMonitor);
}
public static Task getLabelColumnTask(HttpSession httpSession) {
Task monitor = (Task) httpSession.getAttribute(CHANGE_THE_COLUMN_LABEL_TASK);
if (monitor == null) {
logger.error("CHANGE_THE_COLUMN_LABEL_TASK was not acquired");
}
return monitor;
}
public static void setLabelColumnTask(HttpSession httpSession,
Task task) {
Task monitor = (Task) httpSession.getAttribute(CHANGE_THE_COLUMN_LABEL_TASK);
if (monitor != null)
httpSession.removeAttribute(CHANGE_THE_COLUMN_LABEL_TASK);
httpSession.setAttribute(CHANGE_THE_COLUMN_LABEL_TASK, task);
}
///
public static DeleteColumnSession getDeleteColumnSession(
HttpSession httpSession) {
DeleteColumnSession deleteColumnSession = (DeleteColumnSession) httpSession
@ -659,6 +734,10 @@ public class SessionUtil {
httpSession.setAttribute(DELETE_COLUMN_TASK, task);
}
///
public static ArrayList<TabResource> getCodelistsPagingLoaded(
HttpSession httpSession) {

View File

@ -3,6 +3,9 @@
*/
package org.gcube.portlets.user.td.gwtservice.server;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
@ -28,6 +31,7 @@ import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.Profile;
import org.gcube.common.resources.gcore.utils.Group;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationProvider;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.TaskStatus;
@ -51,11 +55,9 @@ import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.exception.InvalidTabularResourceException;
import org.gcube.data.analysis.tabulardata.service.exception.NoSuchTabularResourceException;
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
import org.gcube.data.analysis.tabulardata.service.operation.OperationInterface;
import org.gcube.data.analysis.tabulardata.service.operation.Task;
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId;
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceInterface;
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.AgencyMetadata;
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.DescriptionMetadata;
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.NameMetadata;
@ -94,6 +96,8 @@ 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.column.DeleteColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRAgencyMetadata;
@ -123,13 +127,8 @@ import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import org.gcube.common.resources.gcore.utils.Group;
/**
*
* @author "Giancarlo Panichi" <a
@ -2416,6 +2415,29 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
return invocation;
}
protected OperationExecution retriveOperationExecution(
TabularDataService service, LabelColumnSession labelColumnSession)
throws TDGWTServiceException {
OperationExecution invocation = null;
List<OperationDefinition> capabilities = service.getCapabilities();
logger.debug(labelColumnSession.toString());
OperationDefinition operationDefinition;
Map<String, Object> map = new HashMap<String, Object>();
operationDefinition = getOperationDescriptorWithId(
OperationsId.ChangeLabel.toString(), capabilities);
invocation = new OperationExecution(labelColumnSession
.getColumnData().getColumnId(),
operationDefinition.getOperationId(), map);
return invocation;
}
/**
*
@ -2626,7 +2648,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} else {
logger.debug("Task exception: Error In DeleteColumnMonitor");
deleteColumnMonitor.setError(new Throwable(
"Error In ChangeColumnType"));
"Error Deleting Column"));
}
deleteColumnMonitor.setProgress(task.getProgress());
break;
@ -2681,4 +2703,140 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
*
* {@inheritDoc}
*/
public void startLabelColumn(LabelColumnSession labelColumnSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setLabelColumnSession(session, labelColumnSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
OperationExecution invocation = retriveOperationExecution(service,
labelColumnSession);
if (invocation == null) {
throw new TDGWTServiceException(
"Error Changing the Column Label: Operation not supported for now!");
}
TabularResourceId serviceTR = new TabularResourceId(
Long.valueOf(labelColumnSession.getColumnData().getTrId()
.getId()));
logger.debug("OperationInvocation: \n" + invocation.toString());
Task trTask = service.execute(invocation, serviceTR);
logger.debug("Start Task on service: TaskId " + trTask.getId());
SessionUtil.setDeleteColumnTask(session, trTask);
return;
} catch (Exception e) {
e.printStackTrace();
throw new TDGWTServiceException("Error Changing The Column Label: "
+ e.getLocalizedMessage());
}
}
/**
* {@inheritDoc}
*/
public LabelColumnMonitor getLabelColumnMonitor()
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
LabelColumnSession labelColumnSession = SessionUtil
.getLabelColumnSession(session);
Task task = SessionUtil.getDeleteColumnTask(session);
LabelColumnMonitor labelColumnMonitor = new LabelColumnMonitor();
if (task == null) {
logger.debug("Task null");
throw new TDGWTServiceException(
"Error in LabelColumnMonitor task null");
} else {
TaskStatus status = task.getStatus();
if (status == null) {
logger.debug("Services TaskStatus : null");
throw new TDGWTServiceException(
"Error in LabelColumnMonitor Status null");
} else {
logger.debug("Services TaskStatus: " + task.getStatus());
labelColumnMonitor.setStatus(matchTaskState(task
.getStatus()));
switch (labelColumnMonitor.getStatus()) {
case FAILED:
if (task.getResult() != null) {
logger.debug("Task exception:"
+ task.getErrorCause());
labelColumnMonitor.setError(new Throwable(task
.getErrorCause()));
} else {
logger.debug("Task exception: Error In LabelColumnMonitor");
labelColumnMonitor.setError(new Throwable(
"Error Changing the Column Label"));
}
labelColumnMonitor.setProgress(task.getProgress());
break;
case SUCCEDED:
logger.debug("Task Result:" + task.getResult());
labelColumnMonitor.setProgress(task.getProgress());
Table table = task.getResult().getPrimaryTable();
logger.debug("Table retrived: " + table.toString());
TRId trId = new TRId();
trId.setId(labelColumnSession.getColumnData()
.getTrId().getId());
trId.setTableId(String
.valueOf(table.getId().getValue()));
trId.setTableType(table.getTableType().getName());
labelColumnMonitor.setTrId(trId);
TabResource tabResource = SessionUtil
.getTabResource(session);
tabResource.setTrId(trId);
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, trId);
break;
case IN_PROGRESS:
labelColumnMonitor.setProgress(task.getProgress());
break;
case VALIDATING_RULES:
labelColumnMonitor.setProgress(task.getProgress());
break;
case ABORTED:
break;
case STOPPED:
labelColumnMonitor.setError(new Throwable(
"Export Stopped on service"));
break;
case INITIALIZING:
break;
default:
break;
}
}
SessionUtil.setLabelColumnTask(session, task);
}
logger.info("LabelColumnMonitor(): " + labelColumnMonitor);
return labelColumnMonitor;
} catch (Exception e) {
e.printStackTrace();
throw new TDGWTServiceException(
"Error in delete column monitor LabelColumnMonitor: "
+ e.getLocalizedMessage());
}
}
}

View File

@ -23,6 +23,10 @@ public class DeleteColumnSession implements Serializable {
public void setColumnData(ColumnData columnData) {
this.columnData = columnData;
}
@Override
public String toString() {
return "DeleteColumnSession [columnData=" + columnData + "]";
}

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 LabelColumnMonitor extends OperationMonitor implements Serializable {
private static final long serialVersionUID = -7694151843138161474L;
}

View File

@ -0,0 +1,43 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.column;
import java.io.Serializable;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class LabelColumnSession implements Serializable {
private static final long serialVersionUID = -1896235499708614266L;
protected ColumnData columnData;
protected String label;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public ColumnData getColumnData() {
return columnData;
}
public void setColumnData(ColumnData columnData) {
this.columnData = columnData;
}
@Override
public String toString() {
return "LabelColumnSession [columnData=" + columnData + ", label="
+ label + "]";
}
}