Updated Collateral Table
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@111577 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c9e53e840f
commit
05bab63e7f
|
@ -105,15 +105,13 @@ public interface TDGWTService extends RemoteService {
|
|||
*/
|
||||
public UserInfo hello() throws TDGWTServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve pending Tasks and set them as background tasks
|
||||
*
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public Integer pendingTasksRetrieve() throws TDGWTServiceException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Restore UI session
|
||||
*
|
||||
|
@ -168,6 +166,14 @@ public interface TDGWTService extends RemoteService {
|
|||
public void setTabResourceInformation(TabResource tabResource)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Set tabular resource to final
|
||||
*
|
||||
* @param trId
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public void setTabResourceToFinal(TRId trId) throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Get informations on tabular resource
|
||||
*
|
||||
|
@ -454,7 +460,6 @@ public interface TDGWTService extends RemoteService {
|
|||
public void tdOpen(TDOpenSession tdOpenSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve Time Table Id
|
||||
*
|
||||
|
@ -462,9 +467,9 @@ public interface TDGWTService extends RemoteService {
|
|||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public Long getTimeTableId(PeriodDataType periodDataType)
|
||||
public Long getTimeTableId(PeriodDataType periodDataType)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the list of columns in the current table
|
||||
*
|
||||
|
@ -838,18 +843,17 @@ public interface TDGWTService extends RemoteService {
|
|||
public String startReplaceColumn(ReplaceColumnSession replaceColumnSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* Start replace column by external tabular resource
|
||||
* Start replace column by external tabular resource
|
||||
*
|
||||
* @param replaceByExternalSession
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public String startReplaceByExternal(ReplaceByExternalSession replaceByExternalSession)
|
||||
public String startReplaceByExternal(
|
||||
ReplaceByExternalSession replaceByExternalSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
// Templates
|
||||
/**
|
||||
* Retrieves templates of user
|
||||
|
@ -1061,17 +1065,15 @@ public interface TDGWTService extends RemoteService {
|
|||
*/
|
||||
public void removeResource(RemoveResourceSession removeResourceSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* Save resource on Workspace
|
||||
*
|
||||
* @param saveResourceSession
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public void saveResource(
|
||||
SaveResourceSession saveResourceSession)
|
||||
public void saveResource(SaveResourceSession saveResourceSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
// GIS MAP
|
||||
/**
|
||||
|
@ -1103,7 +1105,8 @@ public interface TDGWTService extends RemoteService {
|
|||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public String startChartTopRating(ChartTopRatingSession chartTopRatingSession)
|
||||
public String startChartTopRating(
|
||||
ChartTopRatingSession chartTopRatingSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -117,6 +117,8 @@ public interface TDGWTServiceAsync {
|
|||
void setTabResourceInformation(TabResource tabResource,
|
||||
AsyncCallback<Void> callback);
|
||||
|
||||
void setTabResourceToFinal(TRId trId, AsyncCallback<Void> callback);
|
||||
|
||||
void getTRCreationDate(TRId trId, AsyncCallback<String> callback);
|
||||
|
||||
void setTabResource(TabResource tabResource, AsyncCallback<Void> callback);
|
||||
|
|
|
@ -91,6 +91,7 @@ import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactor
|
|||
import org.gcube.data.analysis.tabulardata.service.operation.Job;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.Task;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.TaskId;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.TaskResult;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.HistoryStep;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.HistoryStepId;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
|
||||
|
@ -319,50 +320,53 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
@Override
|
||||
public Integer pendingTasksRetrieve() throws TDGWTServiceException {
|
||||
try {
|
||||
|
||||
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
logger.debug("pendingTasksRetrieve()");
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory
|
||||
.getService();
|
||||
|
||||
ArrayList<TabularResource> pendingTR=new ArrayList<TabularResource>();
|
||||
List<TabularResource> trs=service.getTabularResources();
|
||||
for(TabularResource tr:trs){
|
||||
if(tr.isLocked()){
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
ArrayList<TabularResource> pendingTR = new ArrayList<TabularResource>();
|
||||
List<TabularResource> trs = service.getTabularResources();
|
||||
for (TabularResource tr : trs) {
|
||||
if (tr.isLocked()) {
|
||||
pendingTR.add(tr);
|
||||
}
|
||||
}
|
||||
|
||||
Integer pendingNumber=0;
|
||||
|
||||
for(TabularResource tr:pendingTR){
|
||||
logger.debug("Pending Task:"+ tr.getId());
|
||||
List<Task> tasksInitializing=service.getTasks(tr.getId(), TaskStatus.INITIALIZING);
|
||||
List<Task> tasksInProgress=service.getTasks(tr.getId(), TaskStatus.IN_PROGRESS);
|
||||
List<Task> tasksValidatingRules=service.getTasks(tr.getId(), TaskStatus.VALIDATING_RULES);
|
||||
HashMap<String,Task> tasks=new HashMap<String,Task>();
|
||||
for(Task t:tasksInitializing){
|
||||
tasks.put(t.getId().getValue(),t);
|
||||
|
||||
Integer pendingNumber = 0;
|
||||
|
||||
for (TabularResource tr : pendingTR) {
|
||||
logger.debug("Pending Task:" + tr.getId());
|
||||
List<Task> tasksInitializing = service.getTasks(tr.getId(),
|
||||
TaskStatus.INITIALIZING);
|
||||
List<Task> tasksInProgress = service.getTasks(tr.getId(),
|
||||
TaskStatus.IN_PROGRESS);
|
||||
List<Task> tasksValidatingRules = service.getTasks(tr.getId(),
|
||||
TaskStatus.VALIDATING_RULES);
|
||||
HashMap<String, Task> tasks = new HashMap<String, Task>();
|
||||
for (Task t : tasksInitializing) {
|
||||
tasks.put(t.getId().getValue(), t);
|
||||
}
|
||||
for(Task t:tasksInProgress){
|
||||
tasks.put(t.getId().getValue(),t);
|
||||
for (Task t : tasksInProgress) {
|
||||
tasks.put(t.getId().getValue(), t);
|
||||
}
|
||||
for(Task t:tasksValidatingRules){
|
||||
tasks.put(t.getId().getValue(),t);
|
||||
for (Task t : tasksValidatingRules) {
|
||||
tasks.put(t.getId().getValue(), t);
|
||||
}
|
||||
|
||||
TRId trId=new TRId(String.valueOf(tr.getId().getValue()));
|
||||
for(String key:tasks.keySet()){
|
||||
TaskWrapper taskWrapper=new TaskWrapper(tasks.get(key),UIOperationsId.Pending, trId);
|
||||
|
||||
TRId trId = new TRId(String.valueOf(tr.getId().getValue()));
|
||||
for (String key : tasks.keySet()) {
|
||||
TaskWrapper taskWrapper = new TaskWrapper(tasks.get(key),
|
||||
UIOperationsId.Pending, trId);
|
||||
SessionUtil.setTaskInBackground(session, taskWrapper);
|
||||
pendingNumber++;
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug("Pending number: "+pendingNumber);
|
||||
|
||||
logger.debug("Pending number: " + pendingNumber);
|
||||
return pendingNumber;
|
||||
} catch (TDGWTServiceException e) {
|
||||
throw e;
|
||||
|
@ -5719,6 +5723,57 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setTabResourceToFinal(TRId trId) throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
logger.debug("SetTabResourceToFinal: " + trId);
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
checkTRId(trId);
|
||||
|
||||
TabularResourceId tabularResourceId = new TabularResourceId(
|
||||
Long.valueOf(trId.getId()));
|
||||
TabularResource tr = service.getTabularResource(tabularResourceId);
|
||||
|
||||
checkTabularResourceLocked(tr);
|
||||
checkTabularResourceIsFinal(tr);
|
||||
|
||||
logger.debug("setTabResourceToFinal: " + tr);
|
||||
|
||||
if (tr.isValid()) {
|
||||
if (!tr.isFinalized()) {
|
||||
tr.finalize();
|
||||
}
|
||||
} else {
|
||||
throw new TDGWTServiceException(
|
||||
"Only valid tabular resource can be finalized!");
|
||||
}
|
||||
|
||||
logger.debug("setTabResourceToFinal - new information:" + tr);
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
throw e;
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(SECURITY_EXCEPTION_RIGHTS);
|
||||
} catch (Throwable e) {
|
||||
logger.debug("Error in setTabResourceToFinal: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error in setTabResourceToFinal: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
|
@ -6525,6 +6580,28 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
private String retrieveTabularResourceIdFromTable(TabularDataService service,
|
||||
TableId tableId) throws TDGWTServiceException {
|
||||
try {
|
||||
|
||||
Table table = service.getTable(tableId);
|
||||
|
||||
if (table.contains(TableDescriptorMetadata.class)) {
|
||||
TableDescriptorMetadata tdm = table
|
||||
.getMetadata(TableDescriptorMetadata.class);
|
||||
return String.valueOf(tdm.getRefId());
|
||||
} else {
|
||||
throw new TDGWTServiceException(
|
||||
"No TableDescriptorMetadata present in tableId: "
|
||||
+ tableId);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new TDGWTServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValidationsTasksMetadata getValidationsTasksMetadata(TRId trId)
|
||||
throws TDGWTServiceException {
|
||||
|
@ -6590,11 +6667,25 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
j++;
|
||||
|
||||
}
|
||||
|
||||
ArrayList<TRId> collateralTRIds = new ArrayList<TRId>();
|
||||
TaskResult taskResult = task.getResult();
|
||||
if (taskResult != null) {
|
||||
List<TableId> collateral = taskResult.getCollateralTables();
|
||||
for (TableId tId : collateral) {
|
||||
String id=retrieveTabularResourceIdFromTable(service,tId);
|
||||
TRId tabularRId= new TRId(id);
|
||||
tabularRId.setTableId(String.valueOf(tId));
|
||||
collateralTRIds.add(tabularRId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
State state = TaskStateMap.map(task.getStatus());
|
||||
TaskS taskS = new TaskS(task.getId().getValue(),
|
||||
task.getProgress(), state, task.getErrorCause(),
|
||||
task.getSubmitter(), task.getStartTime(),
|
||||
task.getEndTime(), jobSList);
|
||||
task.getEndTime(), jobSList, collateralTRIds);
|
||||
taskSList.add(taskS);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,9 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
*
|
||||
* @author giancarlo
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ExtractCodelistOperationMap {
|
||||
protected static Logger logger = LoggerFactory
|
||||
|
|
|
@ -25,6 +25,7 @@ public class ExtractCodelistSession implements Serializable {
|
|||
private ArrayList<ColumnData> sourceColumns;
|
||||
private ArrayList<ExtractCodelistTargetColumn> targetColumns;
|
||||
private boolean automaticallyAttach;
|
||||
private ColumnData attachColumn;
|
||||
|
||||
public ExtractCodelistSession() {
|
||||
}
|
||||
|
@ -32,12 +33,13 @@ public class ExtractCodelistSession implements Serializable {
|
|||
public ExtractCodelistSession(TRId trId, TabResource tabResource,
|
||||
ArrayList<ColumnData> sourceColumns,
|
||||
ArrayList<ExtractCodelistTargetColumn> targetColumns,
|
||||
boolean automaticallyAttach) {
|
||||
boolean automaticallyAttach, ColumnData attachColumn) {
|
||||
this.trId = trId;
|
||||
this.tabResource = tabResource;
|
||||
this.sourceColumns = sourceColumns;
|
||||
this.targetColumns = targetColumns;
|
||||
this.automaticallyAttach = automaticallyAttach;
|
||||
this.attachColumn = attachColumn;
|
||||
}
|
||||
|
||||
public ArrayList<ColumnData> getSourceColumns() {
|
||||
|
@ -72,8 +74,7 @@ public class ExtractCodelistSession implements Serializable {
|
|||
public void setTrId(TRId trId) {
|
||||
this.trId = trId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isAutomaticallyAttach() {
|
||||
return automaticallyAttach;
|
||||
}
|
||||
|
@ -82,14 +83,20 @@ public class ExtractCodelistSession implements Serializable {
|
|||
this.automaticallyAttach = automaticallyAttach;
|
||||
}
|
||||
|
||||
public ColumnData getAttachColumn() {
|
||||
return attachColumn;
|
||||
}
|
||||
|
||||
public void setAttachColumn(ColumnData attachColumn) {
|
||||
this.attachColumn = attachColumn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ExtractCodelistSession [trId=" + trId + ", tabResource="
|
||||
+ tabResource + ", sourceColumns=" + sourceColumns
|
||||
+ ", targetColumns=" + targetColumns + ", automaticallyAttach="
|
||||
+ automaticallyAttach + "]";
|
||||
+ automaticallyAttach + ", attachColumn=" + attachColumn + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.portlets.user.td.gwtservice.shared.monitor;
|
|||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
|
@ -9,13 +10,16 @@ import org.gcube.application.framework.core.session.ASLSession;
|
|||
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;
|
||||
import org.gcube.data.analysis.tabulardata.model.metadata.common.TableDescriptorMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.model.metadata.table.DatasetViewTableMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.model.metadata.table.ExportMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.model.table.Table;
|
||||
import org.gcube.data.analysis.tabulardata.model.table.TableId;
|
||||
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
|
||||
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.Job;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.Task;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.TaskResult;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.ValidationJob;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId;
|
||||
|
@ -46,7 +50,7 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
public class BackgroundOperationMonitorCreator {
|
||||
private static final String SECURITY_EXCEPTION_RIGHTS = "Security exception, you don't have the required rights!";
|
||||
|
||||
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(BackgroundOperationMonitorCreator.class);
|
||||
|
||||
|
@ -54,8 +58,7 @@ public class BackgroundOperationMonitorCreator {
|
|||
"yyyy-MM-dd HH:mm");
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static SimpleDateFormat sdfDate = new SimpleDateFormat(
|
||||
"yyyy-MM-dd");
|
||||
private static SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
protected HttpSession session;
|
||||
protected TaskWrapper taskWrapper;
|
||||
|
@ -147,7 +150,7 @@ public class BackgroundOperationMonitorCreator {
|
|||
return operationMonitor;
|
||||
}
|
||||
|
||||
protected TaskS createTaskS() {
|
||||
protected TaskS createTaskS() throws TDGWTServiceException {
|
||||
TaskS taskS = new TaskS();
|
||||
|
||||
ArrayList<JobS> jobSList = new ArrayList<JobS>();
|
||||
|
@ -176,14 +179,40 @@ public class BackgroundOperationMonitorCreator {
|
|||
|
||||
}
|
||||
|
||||
taskS = new TaskS(taskWrapper.getTask().getId().getValue(), taskWrapper
|
||||
.getTask().getProgress(), TaskStateMap.map(taskWrapper
|
||||
.getTask().getStatus()), taskWrapper.getTask().getErrorCause(),
|
||||
taskWrapper.getTask().getSubmitter(), taskWrapper.getTask()
|
||||
.getStartTime(), taskWrapper.getTask().getEndTime(),
|
||||
jobSList);
|
||||
try {
|
||||
|
||||
ArrayList<TRId> collateralTRIds=new ArrayList<TRId>();
|
||||
TaskResult taskResult=taskWrapper.getTask().getResult();
|
||||
if(taskResult!=null){
|
||||
List<TableId> collaterals=taskResult.getCollateralTables();
|
||||
for(TableId tId:collaterals){
|
||||
String tabulRId=retrieveTabularResourceIdFromTable(tId);
|
||||
TRId tabularRId=new TRId(tabulRId);
|
||||
tabularRId.setTableId(String.valueOf(tId.getValue()));
|
||||
collateralTRIds.add(tabularRId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
taskS = new TaskS(taskWrapper.getTask().getId().getValue(),
|
||||
taskWrapper.getTask().getProgress(),
|
||||
TaskStateMap.map(taskWrapper.getTask().getStatus()),
|
||||
taskWrapper.getTask().getErrorCause(), taskWrapper
|
||||
.getTask().getSubmitter(), taskWrapper.getTask()
|
||||
.getStartTime(),
|
||||
taskWrapper.getTask().getEndTime(), jobSList,
|
||||
collateralTRIds);
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("error retrieving information about the task, "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(
|
||||
"error retrieving information about the task, "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
logger.debug("Retrieved task information");
|
||||
|
||||
return taskS;
|
||||
}
|
||||
|
||||
|
@ -228,7 +257,7 @@ public class BackgroundOperationMonitorCreator {
|
|||
protected void updateInformations(OperationMonitor operationMonitor)
|
||||
throws TDGWTServiceException {
|
||||
TRId trId;
|
||||
//TabResource tabResource;
|
||||
// TabResource tabResource;
|
||||
Table table;
|
||||
ExportMetadata exportMetadata;
|
||||
|
||||
|
@ -265,7 +294,7 @@ public class BackgroundOperationMonitorCreator {
|
|||
logger.debug("ExportMetadata: " + exportMetadata);
|
||||
|
||||
operationMonitor.setTrId(SessionUtil.getTRId(session));
|
||||
|
||||
|
||||
trExportMetadata = new TabExportMetadata();
|
||||
trExportMetadata.setUrl(exportMetadata.getUri());
|
||||
trExportMetadata.setDestinationType(exportMetadata
|
||||
|
@ -274,24 +303,22 @@ public class BackgroundOperationMonitorCreator {
|
|||
.getExportDate()));
|
||||
|
||||
saveJSONExportInDestination(exportMetadata);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
trId = new TRId();
|
||||
trId.setId(taskWrapper.getTrId().getId());
|
||||
trId = retrieveTabularResourceBasicData(trId);
|
||||
|
||||
operationMonitor.setTrId(trId);
|
||||
/*tabResource = SessionUtil.getTabResource(session);
|
||||
logger.debug("CurrentTabResource :" + tabResource);
|
||||
if (tabResource != null) {
|
||||
tabResource.setTrId(trId);
|
||||
SessionUtil.setTabResource(session, tabResource);
|
||||
} else {
|
||||
tabResource = new TabResource();
|
||||
tabResource.setTrId(trId);
|
||||
SessionUtil.setTabResource(session, tabResource);
|
||||
}
|
||||
SessionUtil.setTRId(session, trId);*/
|
||||
/*
|
||||
* tabResource = SessionUtil.getTabResource(session);
|
||||
* logger.debug("CurrentTabResource :" + tabResource); if
|
||||
* (tabResource != null) { tabResource.setTrId(trId);
|
||||
* SessionUtil.setTabResource(session, tabResource); } else {
|
||||
* tabResource = new TabResource(); tabResource.setTrId(trId);
|
||||
* SessionUtil.setTabResource(session, tabResource); }
|
||||
* SessionUtil.setTRId(session, trId);
|
||||
*/
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -327,14 +354,18 @@ public class BackgroundOperationMonitorCreator {
|
|||
|
||||
TRId newTRId;
|
||||
if (viewTable == null) {
|
||||
newTRId = new TRId(String.valueOf(tr.getId().getValue()),
|
||||
TabularResourceTypeMap.map(tr.getTabularResourceType()), tr.getTableType(), String.valueOf(table.getId()
|
||||
.getValue()), table.getTableType().getName());
|
||||
newTRId = new TRId(
|
||||
String.valueOf(tr.getId().getValue()),
|
||||
TabularResourceTypeMap.map(tr.getTabularResourceType()),
|
||||
tr.getTableType(), String.valueOf(table.getId()
|
||||
.getValue()), table.getTableType().getName());
|
||||
|
||||
} else {
|
||||
newTRId = new TRId(String.valueOf(tr.getId().getValue()),
|
||||
TabularResourceTypeMap.map(tr.getTabularResourceType()), tr.getTableType(), String.valueOf(viewTable.getId()
|
||||
.getValue()), viewTable.getTableType()
|
||||
newTRId = new TRId(
|
||||
String.valueOf(tr.getId().getValue()),
|
||||
TabularResourceTypeMap.map(tr.getTabularResourceType()),
|
||||
tr.getTableType(), String.valueOf(viewTable.getId()
|
||||
.getValue()), viewTable.getTableType()
|
||||
.getName(), String.valueOf(table.getId()
|
||||
.getValue()), true);
|
||||
|
||||
|
@ -347,8 +378,7 @@ public class BackgroundOperationMonitorCreator {
|
|||
throw e;
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(
|
||||
SECURITY_EXCEPTION_RIGHTS);
|
||||
throw new TDGWTServiceException(SECURITY_EXCEPTION_RIGHTS);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error on Service: "
|
||||
|
@ -448,4 +478,30 @@ public class BackgroundOperationMonitorCreator {
|
|||
}
|
||||
}
|
||||
|
||||
private String retrieveTabularResourceIdFromTable(
|
||||
TableId tableId) throws TDGWTServiceException {
|
||||
try {
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
Table table = service.getTable(tableId);
|
||||
|
||||
if (table.contains(TableDescriptorMetadata.class)) {
|
||||
TableDescriptorMetadata tdm = table
|
||||
.getMetadata(TableDescriptorMetadata.class);
|
||||
return String.valueOf(tdm.getRefId());
|
||||
} else {
|
||||
throw new TDGWTServiceException(
|
||||
"No TableDescriptorMetadata present in tableId: "
|
||||
+ tableId);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new TDGWTServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.shared.monitor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskS;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
@ -27,7 +26,6 @@ public class OperationMonitor implements Serializable {
|
|||
private boolean abort;
|
||||
private boolean hidden;
|
||||
private TRId trId;
|
||||
private ArrayList<String> collateralTableIds;
|
||||
|
||||
|
||||
public OperationMonitor() {
|
||||
|
@ -95,27 +93,14 @@ public class OperationMonitor implements Serializable {
|
|||
public void setHidden(boolean hidden) {
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<String> getCollateralTableIds() {
|
||||
return collateralTableIds;
|
||||
}
|
||||
|
||||
public void setCollateralTableIds(ArrayList<String> collateralTableIds) {
|
||||
this.collateralTableIds = collateralTableIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OperationMonitor [taskId=" + taskId + ", operationId="
|
||||
+ operationId + ", task=" + task + ", inBackground="
|
||||
+ inBackground + ", abort=" + abort + ", hidden=" + hidden
|
||||
+ ", trId=" + trId + ", collateralTableIds="
|
||||
+ collateralTableIds + "]";
|
||||
+ ", trId=" + trId + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.portlets.user.td.gwtservice.shared.monitor;
|
|||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
|
@ -9,13 +10,16 @@ import org.gcube.application.framework.core.session.ASLSession;
|
|||
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;
|
||||
import org.gcube.data.analysis.tabulardata.model.metadata.common.TableDescriptorMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.model.metadata.table.DatasetViewTableMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.model.metadata.table.ExportMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.model.table.Table;
|
||||
import org.gcube.data.analysis.tabulardata.model.table.TableId;
|
||||
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
|
||||
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.Job;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.Task;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.TaskResult;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.ValidationJob;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId;
|
||||
|
@ -58,10 +62,12 @@ public class OperationMonitorCreator {
|
|||
private static SimpleDateFormat sdfDate = new SimpleDateFormat(
|
||||
"yyyy-MM-dd");
|
||||
|
||||
protected HttpSession session;
|
||||
protected TaskWrapper taskWrapper;
|
||||
protected OperationMonitorSession operationMonitorSession;
|
||||
protected ASLSession aslSession;
|
||||
private HttpSession session;
|
||||
private TaskWrapper taskWrapper;
|
||||
private OperationMonitorSession operationMonitorSession;
|
||||
private ASLSession aslSession;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -76,7 +82,10 @@ public class OperationMonitorCreator {
|
|||
this.aslSession = aslSession;
|
||||
this.taskWrapper = taskWrapper;
|
||||
this.operationMonitorSession = operationMonitorSession;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -176,13 +185,27 @@ public class OperationMonitorCreator {
|
|||
}
|
||||
|
||||
try {
|
||||
|
||||
ArrayList<TRId> collateralTRIds=new ArrayList<TRId>();
|
||||
TaskResult taskResult=taskWrapper.getTask().getResult();
|
||||
if(taskResult!=null){
|
||||
List<TableId> collaterals=taskResult.getCollateralTables();
|
||||
for(TableId tId:collaterals){
|
||||
String tabulRId=retrieveTabularResourceIdFromTable(tId);
|
||||
TRId tabularRId=new TRId(tabulRId);
|
||||
tabularRId.setTableId(String.valueOf(tId.getValue()));
|
||||
collateralTRIds.add(tabularRId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
taskS = new TaskS(taskWrapper.getTask().getId().getValue(),
|
||||
taskWrapper.getTask().getProgress(),
|
||||
TaskStateMap.map(taskWrapper.getTask().getStatus()),
|
||||
taskWrapper.getTask().getErrorCause(), taskWrapper
|
||||
.getTask().getSubmitter(), taskWrapper.getTask()
|
||||
.getStartTime(),
|
||||
taskWrapper.getTask().getEndTime(), jobSList);
|
||||
taskWrapper.getTask().getEndTime(), jobSList, collateralTRIds);
|
||||
} catch (Throwable e) {
|
||||
logger.error("error retrieving information about the task, "+e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
|
@ -507,5 +530,31 @@ public class OperationMonitorCreator {
|
|||
"Error in export json: no destination present");
|
||||
}
|
||||
}
|
||||
|
||||
private String retrieveTabularResourceIdFromTable(
|
||||
TableId tableId) throws TDGWTServiceException {
|
||||
try {
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
Table table = service.getTable(tableId);
|
||||
|
||||
if (table.contains(TableDescriptorMetadata.class)) {
|
||||
TableDescriptorMetadata tdm = table
|
||||
.getMetadata(TableDescriptorMetadata.class);
|
||||
return String.valueOf(tdm.getRefId());
|
||||
} else {
|
||||
throw new TDGWTServiceException(
|
||||
"No TableDescriptorMetadata present in tableId: "
|
||||
+ tableId);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new TDGWTServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import java.io.Serializable;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
|
@ -21,11 +23,12 @@ public class TaskS implements Serializable {
|
|||
protected Date startTime;
|
||||
protected Date endTime;
|
||||
protected ArrayList<JobS> jobs;
|
||||
protected ArrayList<TRId> collateralTRIds;
|
||||
|
||||
public TaskS() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
|
@ -36,17 +39,21 @@ public class TaskS implements Serializable {
|
|||
* @param startTime
|
||||
* @param endTime
|
||||
* @param jobs
|
||||
* @param collateralTRIds
|
||||
*
|
||||
*/
|
||||
public TaskS(String id, float progress, State state, Throwable errorCause, String submitter,
|
||||
Date startTime, Date endTime, ArrayList<JobS> jobs) {
|
||||
public TaskS(String id, float progress, State state, Throwable errorCause,
|
||||
String submitter, Date startTime, Date endTime,
|
||||
ArrayList<JobS> jobs, ArrayList<TRId> collateralTRIds) {
|
||||
this.id = id;
|
||||
this.progress = progress;
|
||||
this.state = state;
|
||||
this.errorCause=errorCause;
|
||||
this.errorCause = errorCause;
|
||||
this.submitter = submitter;
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
this.jobs = jobs;
|
||||
this.collateralTRIds = collateralTRIds;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -113,14 +120,21 @@ public class TaskS implements Serializable {
|
|||
this.jobs = jobs;
|
||||
}
|
||||
|
||||
public ArrayList<TRId> getCollateralTRIds() {
|
||||
return collateralTRIds;
|
||||
}
|
||||
|
||||
public void setCollateralTRIds(ArrayList<TRId> collateralTRIds) {
|
||||
this.collateralTRIds = collateralTRIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TaskS [id=" + id + ", progress=" + progress + ", state="
|
||||
+ state + ", errorCause=" + errorCause + ", submitter="
|
||||
+ submitter + ", startTime=" + startTime + ", endTime="
|
||||
+ endTime + ", jobs=" + jobs + "]";
|
||||
+ endTime + ", jobs=" + jobs + ", collateralTRIds="
|
||||
+ collateralTRIds + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -18,36 +18,50 @@ public class ChangeColumnTypeSession implements Serializable {
|
|||
protected ColumnTypeCode columnTypeCodeTarget;
|
||||
protected ColumnDataType columnDataTypeTarget;
|
||||
protected String locale;
|
||||
|
||||
|
||||
protected TimeDimensionType timeDimensionType;
|
||||
protected ColumnData codelistColumnReference;
|
||||
|
||||
|
||||
protected ColumnMappingList columnMappingList;
|
||||
|
||||
public ChangeColumnTypeSession(){
|
||||
|
||||
|
||||
public ChangeColumnTypeSession() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* For change to Dimension
|
||||
*/
|
||||
public ChangeColumnTypeSession(ColumnData columnData,
|
||||
ColumnTypeCode columnTypeCode, ColumnDataType columnDataType,
|
||||
ColumnTypeCode columnTypeCodeTarget,
|
||||
ColumnDataType columnDataTypeTarget,
|
||||
ColumnData codelistColumnReference) {
|
||||
this.columnData = columnData;
|
||||
this.columnTypeCode = columnTypeCode;
|
||||
this.columnDataType = columnDataType;
|
||||
this.columnTypeCodeTarget = columnTypeCodeTarget;
|
||||
this.columnDataTypeTarget = columnDataTypeTarget;
|
||||
this.codelistColumnReference = codelistColumnReference;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* For change to Dimension with mapping
|
||||
*/
|
||||
public ChangeColumnTypeSession(ColumnData columnData,
|
||||
ColumnTypeCode columnTypeCode,
|
||||
ColumnDataType columnDataType,
|
||||
ColumnTypeCode columnTypeCode, ColumnDataType columnDataType,
|
||||
ColumnTypeCode columnTypeCodeTarget,
|
||||
ColumnDataType columnDataTypeTarget,
|
||||
ColumnData codelistColumnReference,
|
||||
ColumnMappingList columnMappingList){
|
||||
this.columnData=columnData;
|
||||
this.columnTypeCode=columnTypeCode;
|
||||
this.columnDataType=columnDataType;
|
||||
this.columnTypeCodeTarget=columnTypeCodeTarget;
|
||||
this.columnDataTypeTarget=columnDataTypeTarget;
|
||||
this.codelistColumnReference=codelistColumnReference;
|
||||
this.columnMappingList=columnMappingList;
|
||||
ColumnMappingList columnMappingList) {
|
||||
this.columnData = columnData;
|
||||
this.columnTypeCode = columnTypeCode;
|
||||
this.columnDataType = columnDataType;
|
||||
this.columnTypeCodeTarget = columnTypeCodeTarget;
|
||||
this.columnDataTypeTarget = columnDataTypeTarget;
|
||||
this.codelistColumnReference = codelistColumnReference;
|
||||
this.columnMappingList = columnMappingList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ColumnTypeCode getColumnTypeCode() {
|
||||
return columnTypeCode;
|
||||
|
@ -112,8 +126,6 @@ public class ChangeColumnTypeSession implements Serializable {
|
|||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ColumnMappingList getColumnMappingList() {
|
||||
return columnMappingList;
|
||||
|
@ -123,7 +135,6 @@ public class ChangeColumnTypeSession implements Serializable {
|
|||
this.columnMappingList = columnMappingList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChangeColumnTypeSession [columnData=" + columnData
|
||||
|
@ -136,6 +147,4 @@ public class ChangeColumnTypeSession implements Serializable {
|
|||
+ ", columnMappingList=" + columnMappingList + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue