Minor Updated

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@92296 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-02-25 17:32:17 +00:00
parent 44595f7cf7
commit d8918ab8a7
7 changed files with 329 additions and 18 deletions

View File

@ -32,12 +32,15 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadConfig;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadResult;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.metadata.TabMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
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.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.RemoteServiceRelativePath;
@ -115,7 +118,7 @@ public interface TDGWTService extends RemoteService {
public TableData getLastTable(TRId trId) throws TDGWTServiceException;
/**
* Return Table
* Return Table
*
* @param trId
* @return
@ -123,7 +126,6 @@ public interface TDGWTService extends RemoteService {
*/
public TableData getTable(TRId trId) throws TDGWTServiceException;
/**
* Return Metadata of Table
*
@ -155,7 +157,6 @@ public interface TDGWTService extends RemoteService {
public ArrayList<TabResource> getTabularResources()
throws TDGWTServiceException;
/**
* Initialize Codelists Paging Loader
*
@ -164,7 +165,7 @@ public interface TDGWTService extends RemoteService {
public void setCodelistsPagingLoader() throws TDGWTServiceException;
/**
* Retrieves a portion of Codelists
* Retrieves a portion of Codelists
*
* @param codelistPagingLoadConfig
* @return
@ -381,7 +382,28 @@ public interface TDGWTService extends RemoteService {
public void startSDMXExport(SDMXExportSession exportSession)
throws TDGWTServiceException;
//Column Operation
// Change Table Type
/**
* Get Operation Monitor during the Change Table Type operation
*
*
* @return
* @throws TDGWTServiceException
*/
public ChangeTableTypeMonitor getChangeTableTypeMonitor()
throws TDGWTServiceException;
/**
* Start change table type
*
* @param labelColumnSession
* @throws TDGWTServiceException
*/
public void startChangeTableType(
ChangeTableTypeSession changeTableTypeSession)
throws TDGWTServiceException;
// Column Operation
/**
* Get Operation Monitor during the Change Column Type operation
@ -402,7 +424,6 @@ public interface TDGWTService extends RemoteService {
ChangeColumnTypeSession changeColumnTypeSession)
throws TDGWTServiceException;
/**
* Get Operation Monitor during the Delete Column operation
*
@ -414,17 +435,15 @@ public interface TDGWTService extends RemoteService {
throws TDGWTServiceException;
/**
* Start delete column
* Start delete column
*
*
* @param deleteColumnSession
* @throws TDGWTServiceException
*/
public void startDeleteColumn(
DeleteColumnSession deleteColumnSession)
public void startDeleteColumn(DeleteColumnSession deleteColumnSession)
throws TDGWTServiceException;
/**
* Get Operation Monitor during the Change the Column Label operation
*
@ -441,11 +460,7 @@ public interface TDGWTService extends RemoteService {
* @param labelColumnSession
* @throws TDGWTServiceException
*/
public void startLabelColumn(
LabelColumnSession labelColumnSession)
public void startLabelColumn(LabelColumnSession labelColumnSession)
throws TDGWTServiceException;
}

View File

@ -32,6 +32,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadConfig;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadResult;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.metadata.TabMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
@ -134,6 +136,11 @@ public interface TDGWTServiceAsync {
void startSDMXExport(SDMXExportSession exportSession, AsyncCallback<Void> callback);
//Change Table Type
void getChangeTableTypeMonitor(AsyncCallback<ChangeTableTypeMonitor> callback);
void startChangeTableType(ChangeTableTypeSession changeTableTypeSession,AsyncCallback<Void> callback);
//Column Operation
void getChangeColumnTypeMonitor(AsyncCallback<ChangeColumnTypeMonitor> callback);
void startChangeColumnType(ChangeColumnTypeSession changeColumnTypeSession,AsyncCallback<Void> callback);

View File

@ -30,6 +30,8 @@ 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;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset;
@ -84,14 +86,16 @@ public class SessionUtil {
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_TABLE_TYPE_SESSION = "CHANGE_TABLE_TYPE_SESSION";
protected static final String CHANGE_TABLE_TYPE_MONITOR = "CHANGE_TABLE_TYPE_MONITOR";
protected static final String CHANGE_TABLE_TYPE_TASK = "CHANGE_TABLE_TYPE_TASK";
protected static final String CODELISTS_PAGING_LOADED = "CODELISTS_PAGING_LOADED";
protected static final String CODELISTS_PAGING_LOADED_DIRECTION = "CODELISTS_PAGING_LOADED_DIRECTION";
protected static final String CODELISTS_PAGING_LOADED_FILTER = "CODELISTS_PAGING_LOADED_FILTER";
protected static Logger logger = LoggerFactory.getLogger(SessionUtil.class);
public static ASLSession getAslSession(HttpSession httpSession) {
@ -735,6 +739,77 @@ public class SessionUtil {
}
///
public static ChangeTableTypeSession getChangeTableTypeSession(
HttpSession httpSession) {
ChangeTableTypeSession changeTableTypeSession = (ChangeTableTypeSession) httpSession
.getAttribute(CHANGE_TABLE_TYPE_SESSION);
if (changeTableTypeSession != null) {
return changeTableTypeSession;
} else {
changeTableTypeSession = new ChangeTableTypeSession();
httpSession.setAttribute(CHANGE_TABLE_TYPE_SESSION,
changeTableTypeSession);
return changeTableTypeSession;
}
}
public static void setChangeTableTypeSession(HttpSession httpSession,
ChangeTableTypeSession changeTableTypeSession) {
ChangeTableTypeSession ctts = (ChangeTableTypeSession) httpSession
.getAttribute(CHANGE_TABLE_TYPE_SESSION);
if (ctts != null) {
httpSession.removeAttribute(CHANGE_TABLE_TYPE_SESSION);
}
httpSession.setAttribute(CHANGE_TABLE_TYPE_SESSION,
changeTableTypeSession);
}
public static ChangeTableTypeMonitor getChangeTableTypeMonitor(
HttpSession httpSession) {
ChangeTableTypeMonitor changeTableTypeMonitor = (ChangeTableTypeMonitor) httpSession
.getAttribute(CHANGE_TABLE_TYPE_MONITOR);
if (changeTableTypeMonitor != null) {
return changeTableTypeMonitor;
} else {
changeTableTypeMonitor = new ChangeTableTypeMonitor();
httpSession.setAttribute(CHANGE_TABLE_TYPE_MONITOR,
changeTableTypeMonitor);
return changeTableTypeMonitor;
}
}
public static void setChangeTableTypeMonitor(HttpSession httpSession,
ChangeTableTypeMonitor changeTableTypeMonitor) {
ChangeTableTypeMonitor ctt = (ChangeTableTypeMonitor) httpSession
.getAttribute(CHANGE_TABLE_TYPE_MONITOR);
if (ctt != null) {
httpSession.removeAttribute(CHANGE_TABLE_TYPE_MONITOR);
}
httpSession.setAttribute(CHANGE_TABLE_TYPE_MONITOR,
changeTableTypeMonitor);
}
public static Task getChangeTableTypeTask(HttpSession httpSession) {
Task monitor = (Task) httpSession.getAttribute(CHANGE_TABLE_TYPE_TASK);
if (monitor == null) {
logger.error("CHANGE_TABLE_TYPE_TASK was not acquired");
}
return monitor;
}
public static void setChangeTableTypeTask(HttpSession httpSession,
Task task) {
Task monitor = (Task) httpSession.getAttribute(CHANGE_TABLE_TYPE_TASK);
if (monitor != null)
httpSession.removeAttribute(CHANGE_TABLE_TYPE_TASK);
httpSession.setAttribute(CHANGE_TABLE_TYPE_TASK, task);
}

View File

@ -66,6 +66,7 @@ import org.gcube.data.analysis.tabulardata.service.tabular.metadata.TabularResou
import org.gcube.datapublishing.sdmx.api.model.SDMXRegistryDescriptor;
import org.gcube.datapublishing.sdmx.api.model.SDMXRegistryInterfaceType;
import org.gcube.datapublishing.sdmx.impl.model.GCubeSDMXRegistryDescriptor;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTService;
import org.gcube.portlets.user.td.gwtservice.server.file.FileUploadSession;
import org.gcube.portlets.user.td.gwtservice.server.file.FileUtil;
@ -111,6 +112,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRRightsMetadata
import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadConfig;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadResult;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.metadata.TabDescriptionsMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.metadata.TabExportMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.metadata.TabGenericMapMetadata;
@ -2451,6 +2454,29 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
return invocation;
}
protected OperationExecution retriveOperationExecution(
TabularDataService service, ChangeTableTypeSession changeTableTypeSession)
throws TDGWTServiceException {
OperationExecution invocation = null;
List<OperationDefinition> capabilities = service.getCapabilities();
logger.debug(changeTableTypeSession.toString());
OperationDefinition operationDefinition;
Map<String, Object> map = new HashMap<String, Object>();
operationDefinition = OperationDefinitionMap.map(
OperationsId.ChangeTableType.toString(), capabilities);
map.put(Constants.PARAMETER_TABLE_TYPE, changeTableTypeSession.getTableType().toString());
invocation = new OperationExecution(
operationDefinition.getOperationId(), map);
return invocation;
}
/**
*
@ -2849,6 +2875,142 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
*
* {@inheritDoc}
*/
@Override
public void startChangeTableType(
ChangeTableTypeSession changeTableTypeSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setChangeTableTypeSession(session, changeTableTypeSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
OperationExecution invocation = retriveOperationExecution(service,
changeTableTypeSession);
if (invocation == null) {
throw new TDGWTServiceException(
"Error Change Table Type invocation: Operation not supported");
}
TabularResourceId serviceTR = new TabularResourceId(
Long.valueOf(changeTableTypeSession.getTrId().getId()));
logger.debug("OperationInvocation: \n" + invocation.toString());
Task trTask = service.execute(invocation, serviceTR);
logger.debug("Start Task on service: TaskId " + trTask.getId());
SessionUtil.setChangeTableTypeTask(session, trTask);
return;
} catch (Exception e) {
e.printStackTrace();
throw new TDGWTServiceException("Error Changing Table Type: "
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}
*/
@Override
public ChangeTableTypeMonitor getChangeTableTypeMonitor()
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ChangeTableTypeSession changeTableTypeSession = SessionUtil
.getChangeTableTypeSession(session);
Task task = SessionUtil.getDeleteColumnTask(session);
ChangeTableTypeMonitor changeTableTypeMonitor = new ChangeTableTypeMonitor();
if (task == null) {
logger.debug("Task null");
throw new TDGWTServiceException(
"Error in ChangeTableTypeMonitor task null");
} else {
TaskStatus status = task.getStatus();
if (status == null) {
logger.debug("Services TaskStatus : null");
throw new TDGWTServiceException(
"Error in ChangeTableTypeMonitor Status null");
} else {
logger.debug("Services TaskStatus: " + task.getStatus());
changeTableTypeMonitor.setStatus(TaskStateMap.map(task
.getStatus()));
switch (changeTableTypeMonitor.getStatus()) {
case FAILED:
if (task.getResult() != null) {
logger.debug("Task exception:"
+ task.getErrorCause());
changeTableTypeMonitor.setError(new Throwable(task
.getErrorCause()));
} else {
logger.debug("Task exception: Error In ChangeTableTypeMonitor");
changeTableTypeMonitor.setError(new Throwable(
"Error Changing the Table Type"));
}
changeTableTypeMonitor.setProgress(task.getProgress());
break;
case SUCCEDED:
logger.debug("Task Result:" + task.getResult());
changeTableTypeMonitor.setProgress(task.getProgress());
Table table = task.getResult().getPrimaryTable();
logger.debug("Table retrived: " + table.toString());
TRId trId = new TRId();
trId.setId(changeTableTypeSession.getTrId().getId());
trId.setTableId(String
.valueOf(table.getId().getValue()));
trId.setTableType(table.getTableType().getName());
changeTableTypeMonitor.setTrId(trId);
TabResource tabResource = SessionUtil
.getTabResource(session);
tabResource.setTrId(trId);
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, trId);
break;
case IN_PROGRESS:
changeTableTypeMonitor.setProgress(task.getProgress());
break;
case VALIDATING_RULES:
changeTableTypeMonitor.setProgress(task.getProgress());
break;
case ABORTED:
break;
case STOPPED:
changeTableTypeMonitor.setError(new Throwable(
"Not passed validation task stopped"));
break;
case INITIALIZING:
break;
default:
break;
}
}
SessionUtil.setChangeTableTypeTask(session, task);
}
logger.info("ChangeTableTypeMonitor(): " + changeTableTypeMonitor);
return changeTableTypeMonitor;
} catch (Exception e) {
e.printStackTrace();
throw new TDGWTServiceException(
"Error in change table type monitor ChangeTableTypeMonitor: "
+ e.getLocalizedMessage());
}
}

View File

@ -32,5 +32,6 @@ public class Constants {
public static final String PARAMETER_EXPRESSION="expression";
public static final String PARAMETER_TABLE_TYPE="tableType";
}

View File

@ -0,0 +1,14 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.table;
import java.io.Serializable;
import org.gcube.portlets.user.td.gwtservice.shared.OperationMonitor;
public class ChangeTableTypeMonitor extends OperationMonitor implements Serializable {
private static final long serialVersionUID = 991656197616922469L;
}

View File

@ -0,0 +1,37 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.table;
import java.io.Serializable;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.TableType;
public class ChangeTableTypeSession implements Serializable {
private static final long serialVersionUID = -2634056887663230720L;
protected TRId trId;
protected TableType tableType;
public TRId getTrId() {
return trId;
}
public void setTrId(TRId trId) {
this.trId = trId;
}
public TableType getTableType() {
return tableType;
}
public void setTableType(TableType tableType) {
this.tableType = tableType;
}
@Override
public String toString() {
return "ChangeTableTypeSession [trId=" + trId + ", tableType="
+ tableType + "]";
}
}