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:
Giancarlo Panichi 2015-01-30 17:34:51 +00:00
parent c9e53e840f
commit 05bab63e7f
10 changed files with 354 additions and 137 deletions

View File

@ -105,15 +105,13 @@ public interface TDGWTService extends RemoteService {
*/ */
public UserInfo hello() throws TDGWTServiceException; public UserInfo hello() throws TDGWTServiceException;
/** /**
* Retrieve pending Tasks and set them as background tasks * Retrieve pending Tasks and set them as background tasks
* *
* @throws TDGWTServiceException * @throws TDGWTServiceException
*/ */
public Integer pendingTasksRetrieve() throws TDGWTServiceException; public Integer pendingTasksRetrieve() throws TDGWTServiceException;
/** /**
* Restore UI session * Restore UI session
* *
@ -168,6 +166,14 @@ public interface TDGWTService extends RemoteService {
public void setTabResourceInformation(TabResource tabResource) public void setTabResourceInformation(TabResource tabResource)
throws TDGWTServiceException; throws TDGWTServiceException;
/**
* Set tabular resource to final
*
* @param trId
* @throws TDGWTServiceException
*/
public void setTabResourceToFinal(TRId trId) throws TDGWTServiceException;
/** /**
* Get informations on tabular resource * Get informations on tabular resource
* *
@ -454,7 +460,6 @@ public interface TDGWTService extends RemoteService {
public void tdOpen(TDOpenSession tdOpenSession) public void tdOpen(TDOpenSession tdOpenSession)
throws TDGWTServiceException; throws TDGWTServiceException;
/** /**
* Retrieve Time Table Id * Retrieve Time Table Id
* *
@ -462,9 +467,9 @@ public interface TDGWTService extends RemoteService {
* @return * @return
* @throws TDGWTServiceException * @throws TDGWTServiceException
*/ */
public Long getTimeTableId(PeriodDataType periodDataType) public Long getTimeTableId(PeriodDataType periodDataType)
throws TDGWTServiceException; throws TDGWTServiceException;
/** /**
* Retrieves the list of columns in the current table * Retrieves the list of columns in the current table
* *
@ -838,18 +843,17 @@ public interface TDGWTService extends RemoteService {
public String startReplaceColumn(ReplaceColumnSession replaceColumnSession) public String startReplaceColumn(ReplaceColumnSession replaceColumnSession)
throws TDGWTServiceException; throws TDGWTServiceException;
/** /**
* Start replace column by external tabular resource * Start replace column by external tabular resource
* *
* @param replaceByExternalSession * @param replaceByExternalSession
* @return * @return
* @throws TDGWTServiceException * @throws TDGWTServiceException
*/ */
public String startReplaceByExternal(ReplaceByExternalSession replaceByExternalSession) public String startReplaceByExternal(
ReplaceByExternalSession replaceByExternalSession)
throws TDGWTServiceException; throws TDGWTServiceException;
// Templates // Templates
/** /**
* Retrieves templates of user * Retrieves templates of user
@ -1061,17 +1065,15 @@ public interface TDGWTService extends RemoteService {
*/ */
public void removeResource(RemoveResourceSession removeResourceSession) public void removeResource(RemoveResourceSession removeResourceSession)
throws TDGWTServiceException; throws TDGWTServiceException;
/** /**
* Save resource on Workspace * Save resource on Workspace
* *
* @param saveResourceSession * @param saveResourceSession
* @throws TDGWTServiceException * @throws TDGWTServiceException
*/ */
public void saveResource( public void saveResource(SaveResourceSession saveResourceSession)
SaveResourceSession saveResourceSession)
throws TDGWTServiceException; throws TDGWTServiceException;
// GIS MAP // GIS MAP
/** /**
@ -1103,7 +1105,8 @@ public interface TDGWTService extends RemoteService {
* @return * @return
* @throws TDGWTServiceException * @throws TDGWTServiceException
*/ */
public String startChartTopRating(ChartTopRatingSession chartTopRatingSession) public String startChartTopRating(
ChartTopRatingSession chartTopRatingSession)
throws TDGWTServiceException; throws TDGWTServiceException;
} }

View File

@ -117,6 +117,8 @@ public interface TDGWTServiceAsync {
void setTabResourceInformation(TabResource tabResource, void setTabResourceInformation(TabResource tabResource,
AsyncCallback<Void> callback); AsyncCallback<Void> callback);
void setTabResourceToFinal(TRId trId, AsyncCallback<Void> callback);
void getTRCreationDate(TRId trId, AsyncCallback<String> callback); void getTRCreationDate(TRId trId, AsyncCallback<String> callback);
void setTabResource(TabResource tabResource, AsyncCallback<Void> callback); void setTabResource(TabResource tabResource, AsyncCallback<Void> callback);

View File

@ -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.Job;
import org.gcube.data.analysis.tabulardata.service.operation.Task; 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.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.HistoryStep;
import org.gcube.data.analysis.tabulardata.service.tabular.HistoryStepId; import org.gcube.data.analysis.tabulardata.service.tabular.HistoryStepId;
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource; import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
@ -319,50 +320,53 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
@Override @Override
public Integer pendingTasksRetrieve() throws TDGWTServiceException { public Integer pendingTasksRetrieve() throws TDGWTServiceException {
try { try {
HttpSession session = this.getThreadLocalRequest().getSession(); HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session); ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("pendingTasksRetrieve()"); logger.debug("pendingTasksRetrieve()");
AuthorizationProvider.instance.set(new AuthorizationToken( AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope())); aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory TabularDataService service = TabularDataServiceFactory.getService();
.getService();
ArrayList<TabularResource> pendingTR = new ArrayList<TabularResource>();
ArrayList<TabularResource> pendingTR=new ArrayList<TabularResource>(); List<TabularResource> trs = service.getTabularResources();
List<TabularResource> trs=service.getTabularResources(); for (TabularResource tr : trs) {
for(TabularResource tr:trs){ if (tr.isLocked()) {
if(tr.isLocked()){
pendingTR.add(tr); pendingTR.add(tr);
} }
} }
Integer pendingNumber=0; Integer pendingNumber = 0;
for(TabularResource tr:pendingTR){ for (TabularResource tr : pendingTR) {
logger.debug("Pending Task:"+ tr.getId()); logger.debug("Pending Task:" + tr.getId());
List<Task> tasksInitializing=service.getTasks(tr.getId(), TaskStatus.INITIALIZING); List<Task> tasksInitializing = service.getTasks(tr.getId(),
List<Task> tasksInProgress=service.getTasks(tr.getId(), TaskStatus.IN_PROGRESS); TaskStatus.INITIALIZING);
List<Task> tasksValidatingRules=service.getTasks(tr.getId(), TaskStatus.VALIDATING_RULES); List<Task> tasksInProgress = service.getTasks(tr.getId(),
HashMap<String,Task> tasks=new HashMap<String,Task>(); TaskStatus.IN_PROGRESS);
for(Task t:tasksInitializing){ List<Task> tasksValidatingRules = service.getTasks(tr.getId(),
tasks.put(t.getId().getValue(),t); 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){ for (Task t : tasksInProgress) {
tasks.put(t.getId().getValue(),t); tasks.put(t.getId().getValue(), t);
} }
for(Task t:tasksValidatingRules){ for (Task t : tasksValidatingRules) {
tasks.put(t.getId().getValue(),t); tasks.put(t.getId().getValue(), t);
} }
TRId trId=new TRId(String.valueOf(tr.getId().getValue())); TRId trId = new TRId(String.valueOf(tr.getId().getValue()));
for(String key:tasks.keySet()){ for (String key : tasks.keySet()) {
TaskWrapper taskWrapper=new TaskWrapper(tasks.get(key),UIOperationsId.Pending, trId); TaskWrapper taskWrapper = new TaskWrapper(tasks.get(key),
UIOperationsId.Pending, trId);
SessionUtil.setTaskInBackground(session, taskWrapper); SessionUtil.setTaskInBackground(session, taskWrapper);
pendingNumber++; pendingNumber++;
} }
} }
logger.debug("Pending number: "+pendingNumber); logger.debug("Pending number: " + pendingNumber);
return pendingNumber; return pendingNumber;
} catch (TDGWTServiceException e) { } catch (TDGWTServiceException e) {
throw 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} * {@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 @Override
public ValidationsTasksMetadata getValidationsTasksMetadata(TRId trId) public ValidationsTasksMetadata getValidationsTasksMetadata(TRId trId)
throws TDGWTServiceException { throws TDGWTServiceException {
@ -6590,11 +6667,25 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
j++; 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()); State state = TaskStateMap.map(task.getStatus());
TaskS taskS = new TaskS(task.getId().getValue(), TaskS taskS = new TaskS(task.getId().getValue(),
task.getProgress(), state, task.getErrorCause(), task.getProgress(), state, task.getErrorCause(),
task.getSubmitter(), task.getStartTime(), task.getSubmitter(), task.getStartTime(),
task.getEndTime(), jobSList); task.getEndTime(), jobSList, collateralTRIds);
taskSList.add(taskS); taskSList.add(taskS);
} }

View File

@ -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 { public class ExtractCodelistOperationMap {
protected static Logger logger = LoggerFactory protected static Logger logger = LoggerFactory

View File

@ -25,6 +25,7 @@ public class ExtractCodelistSession implements Serializable {
private ArrayList<ColumnData> sourceColumns; private ArrayList<ColumnData> sourceColumns;
private ArrayList<ExtractCodelistTargetColumn> targetColumns; private ArrayList<ExtractCodelistTargetColumn> targetColumns;
private boolean automaticallyAttach; private boolean automaticallyAttach;
private ColumnData attachColumn;
public ExtractCodelistSession() { public ExtractCodelistSession() {
} }
@ -32,12 +33,13 @@ public class ExtractCodelistSession implements Serializable {
public ExtractCodelistSession(TRId trId, TabResource tabResource, public ExtractCodelistSession(TRId trId, TabResource tabResource,
ArrayList<ColumnData> sourceColumns, ArrayList<ColumnData> sourceColumns,
ArrayList<ExtractCodelistTargetColumn> targetColumns, ArrayList<ExtractCodelistTargetColumn> targetColumns,
boolean automaticallyAttach) { boolean automaticallyAttach, ColumnData attachColumn) {
this.trId = trId; this.trId = trId;
this.tabResource = tabResource; this.tabResource = tabResource;
this.sourceColumns = sourceColumns; this.sourceColumns = sourceColumns;
this.targetColumns = targetColumns; this.targetColumns = targetColumns;
this.automaticallyAttach = automaticallyAttach; this.automaticallyAttach = automaticallyAttach;
this.attachColumn = attachColumn;
} }
public ArrayList<ColumnData> getSourceColumns() { public ArrayList<ColumnData> getSourceColumns() {
@ -72,8 +74,7 @@ public class ExtractCodelistSession implements Serializable {
public void setTrId(TRId trId) { public void setTrId(TRId trId) {
this.trId = trId; this.trId = trId;
} }
public boolean isAutomaticallyAttach() { public boolean isAutomaticallyAttach() {
return automaticallyAttach; return automaticallyAttach;
} }
@ -82,14 +83,20 @@ public class ExtractCodelistSession implements Serializable {
this.automaticallyAttach = automaticallyAttach; this.automaticallyAttach = automaticallyAttach;
} }
public ColumnData getAttachColumn() {
return attachColumn;
}
public void setAttachColumn(ColumnData attachColumn) {
this.attachColumn = attachColumn;
}
@Override @Override
public String toString() { public String toString() {
return "ExtractCodelistSession [trId=" + trId + ", tabResource=" return "ExtractCodelistSession [trId=" + trId + ", tabResource="
+ tabResource + ", sourceColumns=" + sourceColumns + tabResource + ", sourceColumns=" + sourceColumns
+ ", targetColumns=" + targetColumns + ", automaticallyAttach=" + ", targetColumns=" + targetColumns + ", automaticallyAttach="
+ automaticallyAttach + "]"; + automaticallyAttach + ", attachColumn=" + attachColumn + "]";
} }
} }

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.td.gwtservice.shared.monitor;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpSession; 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.AuthorizationProvider;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken; 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.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.DatasetViewTableMetadata;
import org.gcube.data.analysis.tabulardata.model.metadata.table.ExportMetadata; 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.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.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory; 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.Job;
import org.gcube.data.analysis.tabulardata.service.operation.Task; 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.operation.ValidationJob;
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource; 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.TabularResourceId;
@ -46,7 +50,7 @@ import org.slf4j.LoggerFactory;
*/ */
public class BackgroundOperationMonitorCreator { public class BackgroundOperationMonitorCreator {
private static final String SECURITY_EXCEPTION_RIGHTS = "Security exception, you don't have the required rights!"; private static final String SECURITY_EXCEPTION_RIGHTS = "Security exception, you don't have the required rights!";
private static Logger logger = LoggerFactory private static Logger logger = LoggerFactory
.getLogger(BackgroundOperationMonitorCreator.class); .getLogger(BackgroundOperationMonitorCreator.class);
@ -54,8 +58,7 @@ public class BackgroundOperationMonitorCreator {
"yyyy-MM-dd HH:mm"); "yyyy-MM-dd HH:mm");
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static SimpleDateFormat sdfDate = new SimpleDateFormat( private static SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
"yyyy-MM-dd");
protected HttpSession session; protected HttpSession session;
protected TaskWrapper taskWrapper; protected TaskWrapper taskWrapper;
@ -147,7 +150,7 @@ public class BackgroundOperationMonitorCreator {
return operationMonitor; return operationMonitor;
} }
protected TaskS createTaskS() { protected TaskS createTaskS() throws TDGWTServiceException {
TaskS taskS = new TaskS(); TaskS taskS = new TaskS();
ArrayList<JobS> jobSList = new ArrayList<JobS>(); ArrayList<JobS> jobSList = new ArrayList<JobS>();
@ -176,14 +179,40 @@ public class BackgroundOperationMonitorCreator {
} }
taskS = new TaskS(taskWrapper.getTask().getId().getValue(), taskWrapper try {
.getTask().getProgress(), TaskStateMap.map(taskWrapper
.getTask().getStatus()), taskWrapper.getTask().getErrorCause(),
taskWrapper.getTask().getSubmitter(), taskWrapper.getTask()
.getStartTime(), taskWrapper.getTask().getEndTime(),
jobSList);
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"); logger.debug("Retrieved task information");
return taskS; return taskS;
} }
@ -228,7 +257,7 @@ public class BackgroundOperationMonitorCreator {
protected void updateInformations(OperationMonitor operationMonitor) protected void updateInformations(OperationMonitor operationMonitor)
throws TDGWTServiceException { throws TDGWTServiceException {
TRId trId; TRId trId;
//TabResource tabResource; // TabResource tabResource;
Table table; Table table;
ExportMetadata exportMetadata; ExportMetadata exportMetadata;
@ -265,7 +294,7 @@ public class BackgroundOperationMonitorCreator {
logger.debug("ExportMetadata: " + exportMetadata); logger.debug("ExportMetadata: " + exportMetadata);
operationMonitor.setTrId(SessionUtil.getTRId(session)); operationMonitor.setTrId(SessionUtil.getTRId(session));
trExportMetadata = new TabExportMetadata(); trExportMetadata = new TabExportMetadata();
trExportMetadata.setUrl(exportMetadata.getUri()); trExportMetadata.setUrl(exportMetadata.getUri());
trExportMetadata.setDestinationType(exportMetadata trExportMetadata.setDestinationType(exportMetadata
@ -274,24 +303,22 @@ public class BackgroundOperationMonitorCreator {
.getExportDate())); .getExportDate()));
saveJSONExportInDestination(exportMetadata); saveJSONExportInDestination(exportMetadata);
break; break;
default: default:
trId = new TRId(); trId = new TRId();
trId.setId(taskWrapper.getTrId().getId()); trId.setId(taskWrapper.getTrId().getId());
trId = retrieveTabularResourceBasicData(trId); trId = retrieveTabularResourceBasicData(trId);
operationMonitor.setTrId(trId); operationMonitor.setTrId(trId);
/*tabResource = SessionUtil.getTabResource(session); /*
logger.debug("CurrentTabResource :" + tabResource); * tabResource = SessionUtil.getTabResource(session);
if (tabResource != null) { * logger.debug("CurrentTabResource :" + tabResource); if
tabResource.setTrId(trId); * (tabResource != null) { tabResource.setTrId(trId);
SessionUtil.setTabResource(session, tabResource); * SessionUtil.setTabResource(session, tabResource); } else {
} else { * tabResource = new TabResource(); tabResource.setTrId(trId);
tabResource = new TabResource(); * SessionUtil.setTabResource(session, tabResource); }
tabResource.setTrId(trId); * SessionUtil.setTRId(session, trId);
SessionUtil.setTabResource(session, tabResource); */
}
SessionUtil.setTRId(session, trId);*/
break; break;
} }
@ -327,14 +354,18 @@ public class BackgroundOperationMonitorCreator {
TRId newTRId; TRId newTRId;
if (viewTable == null) { if (viewTable == null) {
newTRId = new TRId(String.valueOf(tr.getId().getValue()), newTRId = new TRId(
TabularResourceTypeMap.map(tr.getTabularResourceType()), tr.getTableType(), String.valueOf(table.getId() String.valueOf(tr.getId().getValue()),
.getValue()), table.getTableType().getName()); TabularResourceTypeMap.map(tr.getTabularResourceType()),
tr.getTableType(), String.valueOf(table.getId()
.getValue()), table.getTableType().getName());
} else { } else {
newTRId = new TRId(String.valueOf(tr.getId().getValue()), newTRId = new TRId(
TabularResourceTypeMap.map(tr.getTabularResourceType()), tr.getTableType(), String.valueOf(viewTable.getId() String.valueOf(tr.getId().getValue()),
.getValue()), viewTable.getTableType() TabularResourceTypeMap.map(tr.getTabularResourceType()),
tr.getTableType(), String.valueOf(viewTable.getId()
.getValue()), viewTable.getTableType()
.getName(), String.valueOf(table.getId() .getName(), String.valueOf(table.getId()
.getValue()), true); .getValue()), true);
@ -347,8 +378,7 @@ public class BackgroundOperationMonitorCreator {
throw e; throw e;
} catch (SecurityException e) { } catch (SecurityException e) {
e.printStackTrace(); e.printStackTrace();
throw new TDGWTServiceException( throw new TDGWTServiceException(SECURITY_EXCEPTION_RIGHTS);
SECURITY_EXCEPTION_RIGHTS);
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
throw new TDGWTServiceException("Error on Service: " 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());
}
}
} }

View File

@ -4,7 +4,6 @@
package org.gcube.portlets.user.td.gwtservice.shared.monitor; package org.gcube.portlets.user.td.gwtservice.shared.monitor;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskS; import org.gcube.portlets.user.td.gwtservice.shared.task.TaskS;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
@ -27,7 +26,6 @@ public class OperationMonitor implements Serializable {
private boolean abort; private boolean abort;
private boolean hidden; private boolean hidden;
private TRId trId; private TRId trId;
private ArrayList<String> collateralTableIds;
public OperationMonitor() { public OperationMonitor() {
@ -95,27 +93,14 @@ public class OperationMonitor implements Serializable {
public void setHidden(boolean hidden) { public void setHidden(boolean hidden) {
this.hidden = hidden; this.hidden = hidden;
} }
public ArrayList<String> getCollateralTableIds() {
return collateralTableIds;
}
public void setCollateralTableIds(ArrayList<String> collateralTableIds) {
this.collateralTableIds = collateralTableIds;
}
@Override @Override
public String toString() { public String toString() {
return "OperationMonitor [taskId=" + taskId + ", operationId=" return "OperationMonitor [taskId=" + taskId + ", operationId="
+ operationId + ", task=" + task + ", inBackground=" + operationId + ", task=" + task + ", inBackground="
+ inBackground + ", abort=" + abort + ", hidden=" + hidden + inBackground + ", abort=" + abort + ", hidden=" + hidden
+ ", trId=" + trId + ", collateralTableIds=" + ", trId=" + trId + "]";
+ collateralTableIds + "]";
} }
} }

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.td.gwtservice.shared.monitor;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpSession; 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.AuthorizationProvider;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken; 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.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.DatasetViewTableMetadata;
import org.gcube.data.analysis.tabulardata.model.metadata.table.ExportMetadata; 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.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.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory; 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.Job;
import org.gcube.data.analysis.tabulardata.service.operation.Task; 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.operation.ValidationJob;
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource; 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.TabularResourceId;
@ -58,10 +62,12 @@ public class OperationMonitorCreator {
private static SimpleDateFormat sdfDate = new SimpleDateFormat( private static SimpleDateFormat sdfDate = new SimpleDateFormat(
"yyyy-MM-dd"); "yyyy-MM-dd");
protected HttpSession session; private HttpSession session;
protected TaskWrapper taskWrapper; private TaskWrapper taskWrapper;
protected OperationMonitorSession operationMonitorSession; private OperationMonitorSession operationMonitorSession;
protected ASLSession aslSession; private ASLSession aslSession;
/** /**
* *
@ -76,7 +82,10 @@ public class OperationMonitorCreator {
this.aslSession = aslSession; this.aslSession = aslSession;
this.taskWrapper = taskWrapper; this.taskWrapper = taskWrapper;
this.operationMonitorSession = operationMonitorSession; this.operationMonitorSession = operationMonitorSession;
} }
/** /**
@ -176,13 +185,27 @@ public class OperationMonitorCreator {
} }
try { 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(), taskS = new TaskS(taskWrapper.getTask().getId().getValue(),
taskWrapper.getTask().getProgress(), taskWrapper.getTask().getProgress(),
TaskStateMap.map(taskWrapper.getTask().getStatus()), TaskStateMap.map(taskWrapper.getTask().getStatus()),
taskWrapper.getTask().getErrorCause(), taskWrapper taskWrapper.getTask().getErrorCause(), taskWrapper
.getTask().getSubmitter(), taskWrapper.getTask() .getTask().getSubmitter(), taskWrapper.getTask()
.getStartTime(), .getStartTime(),
taskWrapper.getTask().getEndTime(), jobSList); taskWrapper.getTask().getEndTime(), jobSList, collateralTRIds);
} catch (Throwable e) { } catch (Throwable e) {
logger.error("error retrieving information about the task, "+e.getLocalizedMessage()); logger.error("error retrieving information about the task, "+e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
@ -507,5 +530,31 @@ public class OperationMonitorCreator {
"Error in export json: no destination present"); "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());
}
}
} }

View File

@ -4,6 +4,8 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/** /**
* *
* @author "Giancarlo Panichi" * @author "Giancarlo Panichi"
@ -21,11 +23,12 @@ public class TaskS implements Serializable {
protected Date startTime; protected Date startTime;
protected Date endTime; protected Date endTime;
protected ArrayList<JobS> jobs; protected ArrayList<JobS> jobs;
protected ArrayList<TRId> collateralTRIds;
public TaskS() { public TaskS() {
} }
/** /**
* *
* @param id * @param id
@ -36,17 +39,21 @@ public class TaskS implements Serializable {
* @param startTime * @param startTime
* @param endTime * @param endTime
* @param jobs * @param jobs
* @param collateralTRIds
*
*/ */
public TaskS(String id, float progress, State state, Throwable errorCause, String submitter, public TaskS(String id, float progress, State state, Throwable errorCause,
Date startTime, Date endTime, ArrayList<JobS> jobs) { String submitter, Date startTime, Date endTime,
ArrayList<JobS> jobs, ArrayList<TRId> collateralTRIds) {
this.id = id; this.id = id;
this.progress = progress; this.progress = progress;
this.state = state; this.state = state;
this.errorCause=errorCause; this.errorCause = errorCause;
this.submitter = submitter; this.submitter = submitter;
this.startTime = startTime; this.startTime = startTime;
this.endTime = endTime; this.endTime = endTime;
this.jobs = jobs; this.jobs = jobs;
this.collateralTRIds = collateralTRIds;
} }
public String getId() { public String getId() {
@ -113,14 +120,21 @@ public class TaskS implements Serializable {
this.jobs = jobs; this.jobs = jobs;
} }
public ArrayList<TRId> getCollateralTRIds() {
return collateralTRIds;
}
public void setCollateralTRIds(ArrayList<TRId> collateralTRIds) {
this.collateralTRIds = collateralTRIds;
}
@Override @Override
public String toString() { public String toString() {
return "TaskS [id=" + id + ", progress=" + progress + ", state=" return "TaskS [id=" + id + ", progress=" + progress + ", state="
+ state + ", errorCause=" + errorCause + ", submitter=" + state + ", errorCause=" + errorCause + ", submitter="
+ submitter + ", startTime=" + startTime + ", endTime=" + submitter + ", startTime=" + startTime + ", endTime="
+ endTime + ", jobs=" + jobs + "]"; + endTime + ", jobs=" + jobs + ", collateralTRIds="
+ collateralTRIds + "]";
} }
} }

View File

@ -18,36 +18,50 @@ public class ChangeColumnTypeSession implements Serializable {
protected ColumnTypeCode columnTypeCodeTarget; protected ColumnTypeCode columnTypeCodeTarget;
protected ColumnDataType columnDataTypeTarget; protected ColumnDataType columnDataTypeTarget;
protected String locale; protected String locale;
protected TimeDimensionType timeDimensionType; protected TimeDimensionType timeDimensionType;
protected ColumnData codelistColumnReference; protected ColumnData codelistColumnReference;
protected ColumnMappingList columnMappingList; 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 * For change to Dimension with mapping
*/ */
public ChangeColumnTypeSession(ColumnData columnData, public ChangeColumnTypeSession(ColumnData columnData,
ColumnTypeCode columnTypeCode, ColumnTypeCode columnTypeCode, ColumnDataType columnDataType,
ColumnDataType columnDataType,
ColumnTypeCode columnTypeCodeTarget, ColumnTypeCode columnTypeCodeTarget,
ColumnDataType columnDataTypeTarget, ColumnDataType columnDataTypeTarget,
ColumnData codelistColumnReference, ColumnData codelistColumnReference,
ColumnMappingList columnMappingList){ ColumnMappingList columnMappingList) {
this.columnData=columnData; this.columnData = columnData;
this.columnTypeCode=columnTypeCode; this.columnTypeCode = columnTypeCode;
this.columnDataType=columnDataType; this.columnDataType = columnDataType;
this.columnTypeCodeTarget=columnTypeCodeTarget; this.columnTypeCodeTarget = columnTypeCodeTarget;
this.columnDataTypeTarget=columnDataTypeTarget; this.columnDataTypeTarget = columnDataTypeTarget;
this.codelistColumnReference=codelistColumnReference; this.codelistColumnReference = codelistColumnReference;
this.columnMappingList=columnMappingList; this.columnMappingList = columnMappingList;
} }
public ColumnTypeCode getColumnTypeCode() { public ColumnTypeCode getColumnTypeCode() {
return columnTypeCode; return columnTypeCode;
@ -112,8 +126,6 @@ public class ChangeColumnTypeSession implements Serializable {
public void setLocale(String locale) { public void setLocale(String locale) {
this.locale = locale; this.locale = locale;
} }
public ColumnMappingList getColumnMappingList() { public ColumnMappingList getColumnMappingList() {
return columnMappingList; return columnMappingList;
@ -123,7 +135,6 @@ public class ChangeColumnTypeSession implements Serializable {
this.columnMappingList = columnMappingList; this.columnMappingList = columnMappingList;
} }
@Override @Override
public String toString() { public String toString() {
return "ChangeColumnTypeSession [columnData=" + columnData return "ChangeColumnTypeSession [columnData=" + columnData
@ -136,6 +147,4 @@ public class ChangeColumnTypeSession implements Serializable {
+ ", columnMappingList=" + columnMappingList + "]"; + ", columnMappingList=" + columnMappingList + "]";
} }
} }