Added Change Column To Measure
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@90991 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ee648e046d
commit
e84711267e
|
@ -22,6 +22,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
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.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;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.metadata.TabMetadata;
|
||||
|
@ -30,6 +32,7 @@ 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;
|
||||
|
||||
|
@ -61,24 +64,23 @@ public interface TDGWTService extends RemoteService {
|
|||
*/
|
||||
public TabResource getTabResourceInformation() throws TDGWTServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* Get informations on tabular resource
|
||||
* Get informations on tabular resource
|
||||
*
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public TabResource getTabResourceInformation(TRId trId) throws TDGWTServiceException;
|
||||
public TabResource getTabResourceInformation(TRId trId)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* Get creation date on tabular resource
|
||||
* Get creation date on tabular resource
|
||||
*
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public String getTRCreationDate(TRId trId) throws TDGWTServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* Set current tabular resource
|
||||
*
|
||||
|
@ -161,7 +163,8 @@ public interface TDGWTService extends RemoteService {
|
|||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public ArrayList<ColumnData> getColumns(TRId trId) throws TDGWTServiceException;
|
||||
public ArrayList<ColumnData> getColumns(TRId trId)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Retrieves information about a specific column
|
||||
|
@ -169,7 +172,8 @@ public interface TDGWTService extends RemoteService {
|
|||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public ColumnData getColumn(TRId trId, String columnName) throws TDGWTServiceException;
|
||||
public ColumnData getColumn(TRId trId, String columnName)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Remove Tabular Resource From Service
|
||||
|
@ -214,7 +218,6 @@ public interface TDGWTService extends RemoteService {
|
|||
public void setSDMXRegistrySource(SDMXRegistrySource sdmxRegistrySource)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
// Import SDMX
|
||||
/**
|
||||
* Start SDMX Import and invokes the client library
|
||||
|
@ -344,4 +347,14 @@ public interface TDGWTService extends RemoteService {
|
|||
public void startSDMXExport(SDMXExportSession exportSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
// Change Column Type
|
||||
|
||||
// Monitor
|
||||
public ChangeColumnTypeMonitor getChangeColumnTypeMonitor()
|
||||
throws TDGWTServiceException;
|
||||
|
||||
// Change Column to Measure
|
||||
public void startChangeToMeasureColumn(
|
||||
ChangeColumnTypeSession changeColumnTypeSession) throws TDGWTServiceException;
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
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.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;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.metadata.TabMetadata;
|
||||
|
@ -113,5 +115,10 @@ public interface TDGWTServiceAsync {
|
|||
void getSDMXExportMonitor(AsyncCallback<SDMXExportMonitor> callback);
|
||||
|
||||
void startSDMXExport(SDMXExportSession exportSession, AsyncCallback<Void> callback);
|
||||
|
||||
|
||||
|
||||
//Change Column Type
|
||||
void getChangeToMeasureColumnMonitor(AsyncCallback<ChangeColumnTypeMonitor> callback);
|
||||
void startChangeToMeasureColumn(ChangeColumnTypeSession changeColumnTypeSession,AsyncCallback<Void> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession;
|
||||
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.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.type.Agencies;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
|
||||
|
@ -65,7 +67,11 @@ public class SessionUtil {
|
|||
protected static final String CSV_EXPORT_TASK = "CSV_EXPORT_TASK";
|
||||
protected static final String CSV_EXPORT_END = "CSV_EXPORT_END";
|
||||
protected static final String CSV_EXPORT_MONITOR = "CSV_EXPORT_MONITOR";
|
||||
|
||||
|
||||
protected static final String CHANGE_COLUMN_TYPE_SESSION="CHANGE_COLUMN_TYPE_SESSION";
|
||||
protected static final String CHANGE_COLUMN_TYPE_MONITOR="CHANGE_COLUMN_TYPE_MONITOR";
|
||||
protected static final String CHANGE_COLUMN_TYPE_TASK="CHANGE_COLUMN_TYPE_TASK";
|
||||
|
||||
|
||||
protected static Logger logger = LoggerFactory.getLogger(SessionUtil.class);
|
||||
|
||||
|
@ -502,5 +508,69 @@ public class SessionUtil {
|
|||
httpSession.setAttribute(TR_TASK_MANAGER, trTasksManager);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static ChangeColumnTypeSession getChangeColumnTypeSession(HttpSession httpSession) {
|
||||
ChangeColumnTypeSession changeColumnTypeSession = (ChangeColumnTypeSession) httpSession
|
||||
.getAttribute(CHANGE_COLUMN_TYPE_SESSION);
|
||||
if (changeColumnTypeSession != null) {
|
||||
return changeColumnTypeSession;
|
||||
} else {
|
||||
changeColumnTypeSession = new ChangeColumnTypeSession();
|
||||
httpSession.setAttribute(CHANGE_COLUMN_TYPE_SESSION, changeColumnTypeSession);
|
||||
return changeColumnTypeSession;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setChangeColumnTypeSession(HttpSession httpSession,
|
||||
ChangeColumnTypeSession changeColumnTypeSession) {
|
||||
ChangeColumnTypeSession ct = (ChangeColumnTypeSession) httpSession
|
||||
.getAttribute(CHANGE_COLUMN_TYPE_SESSION);
|
||||
if (ct != null) {
|
||||
httpSession.removeAttribute(CHANGE_COLUMN_TYPE_SESSION);
|
||||
}
|
||||
httpSession.setAttribute(CHANGE_COLUMN_TYPE_SESSION, changeColumnTypeSession);
|
||||
|
||||
}
|
||||
|
||||
public static ChangeColumnTypeMonitor getChangeColumnTypeMonitor(HttpSession httpSession) {
|
||||
ChangeColumnTypeMonitor changeColumnTypeMonitor = (ChangeColumnTypeMonitor) httpSession
|
||||
.getAttribute(CHANGE_COLUMN_TYPE_MONITOR);
|
||||
if (changeColumnTypeMonitor != null) {
|
||||
return changeColumnTypeMonitor;
|
||||
} else {
|
||||
changeColumnTypeMonitor = new ChangeColumnTypeMonitor();
|
||||
httpSession.setAttribute(CHANGE_COLUMN_TYPE_MONITOR, changeColumnTypeMonitor);
|
||||
return changeColumnTypeMonitor;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setChangeColumnTypeMonitor(HttpSession httpSession,
|
||||
ChangeColumnTypeMonitor changeColumnTypeMonitor) {
|
||||
ChangeColumnTypeMonitor cm = (ChangeColumnTypeMonitor) httpSession
|
||||
.getAttribute(CHANGE_COLUMN_TYPE_MONITOR);
|
||||
if (cm != null) {
|
||||
httpSession.removeAttribute(CHANGE_COLUMN_TYPE_MONITOR);
|
||||
}
|
||||
httpSession.setAttribute(CHANGE_COLUMN_TYPE_MONITOR, changeColumnTypeMonitor);
|
||||
|
||||
}
|
||||
|
||||
public static Task getChangeColumnTypeTask(HttpSession httpSession) {
|
||||
Task monitor = (Task) httpSession.getAttribute(CHANGE_COLUMN_TYPE_TASK);
|
||||
if (monitor == null) {
|
||||
logger.error("CHANGE_COLUMN_TYPE_TASK was not acquired");
|
||||
}
|
||||
return monitor;
|
||||
}
|
||||
|
||||
public static void setChangeColumnTypeTask(HttpSession httpSession, Task task) {
|
||||
Task monitor = (Task) httpSession.getAttribute(CHANGE_COLUMN_TYPE_TASK);
|
||||
if (monitor != null)
|
||||
httpSession.removeAttribute(CHANGE_COLUMN_TYPE_TASK);
|
||||
httpSession.setAttribute(CHANGE_COLUMN_TYPE_TASK, task);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ 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;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.storage.FilesStorage;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.trservice.ColumnDataTypeMap;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationsId;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.csv.AvailableCharsetList;
|
||||
|
@ -87,6 +88,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.task.State;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
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.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;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRCreationDateMetadata;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRDescriptionMetadata;
|
||||
|
@ -106,9 +109,11 @@ 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 org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
|
||||
/**
|
||||
|
@ -174,14 +179,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
"CURRENT_TABULAR_RESOURCE is null");
|
||||
}
|
||||
|
||||
logger.debug("GetTabResourceInformation():"+currentTR.toString());
|
||||
logger.debug("GetTabResourceInformation():" + currentTR.toString());
|
||||
|
||||
ArrayList<TRMetadata> trMetadatas = getTRMetadata(currentTR
|
||||
.getTrId());
|
||||
updateTabResourceInformation(currentTR, trMetadatas);
|
||||
currentTR.setDate(getTRCreationDate(currentTR.getTrId()));
|
||||
SessionUtil.setTabResource(session, currentTR);
|
||||
logger.debug("GetTabResourceInformation() updated information:"+currentTR.toString());
|
||||
logger.debug("GetTabResourceInformation() updated information:"
|
||||
+ currentTR.toString());
|
||||
return currentTR;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -204,14 +210,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
@SuppressWarnings("unused")
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
// ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
logger.debug("GetTabResourceInformation(TRId):"+trId.toString());
|
||||
logger.debug("GetTabResourceInformation(TRId):" + trId.toString());
|
||||
TabResource currentTR = new TabResource();
|
||||
currentTR.setTrId(trId);
|
||||
ArrayList<TRMetadata> trMetadatas = getTRMetadata(currentTR
|
||||
.getTrId());
|
||||
updateTabResourceInformation(currentTR, trMetadatas);
|
||||
currentTR.setDate(getTRCreationDate(trId));
|
||||
logger.debug("GetTabResourceInformation() updated information:"+currentTR.toString());
|
||||
logger.debug("GetTabResourceInformation() updated information:"
|
||||
+ currentTR.toString());
|
||||
return currentTR;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -345,13 +352,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
logger.debug("getColumns():"+trId.toString());
|
||||
|
||||
|
||||
logger.debug("getColumns():" + trId.toString());
|
||||
|
||||
Table table = service.getTable(new TableId(Long.valueOf(trId
|
||||
.getTableId())));
|
||||
|
||||
|
@ -846,7 +853,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TRId trId = new TRId(String.valueOf(serviceTR.getId().getValue()));
|
||||
sdmxImportTabResource.setTrId(trId);
|
||||
logger.debug(sdmxImportTabResource.toString());
|
||||
|
||||
|
||||
SessionUtil
|
||||
.setSDMXImportTabResource(session, sdmxImportTabResource);
|
||||
|
@ -973,7 +979,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
importMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case STOPPED:
|
||||
importMonitor.setError(new Throwable("Import Stopped on service"));
|
||||
importMonitor.setError(new Throwable(
|
||||
"Import Stopped on service"));
|
||||
break;
|
||||
case ABORTED:
|
||||
break;
|
||||
|
@ -982,7 +989,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
break;
|
||||
case VALIDATING_RULES:
|
||||
importMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
break;
|
||||
case INITIALIZING:
|
||||
break;
|
||||
default:
|
||||
|
@ -1226,23 +1233,30 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
FileUploadSession fileUploadSession,
|
||||
CSVImportSession csvImportSession) throws TDGWTServiceException {
|
||||
logger.debug("File Storage Access");
|
||||
|
||||
logger.debug("CSVImportSession skip:"+csvImportSession.isSkipInvalidLines());
|
||||
|
||||
if(csvImportSession.isSkipInvalidLines()){
|
||||
|
||||
logger.debug("CSVImportSession skip:"
|
||||
+ csvImportSession.isSkipInvalidLines());
|
||||
|
||||
if (csvImportSession.isSkipInvalidLines()) {
|
||||
try {
|
||||
fileUploadSession.setCsvFile(CSVFileUtil.skipError(fileUploadSession.getCsvFile(), fileUploadSession.getParserConfiguration()));
|
||||
fileUploadSession.setCsvFile(CSVFileUtil.skipError(
|
||||
fileUploadSession.getCsvFile(),
|
||||
fileUploadSession.getParserConfiguration()));
|
||||
} catch (ParseException e) {
|
||||
logger.debug("Error parsing file for skip:"+e.getMessage());
|
||||
throw new TDGWTServiceException("Error parsing file for skip: "+e.getMessage());
|
||||
logger.debug("Error parsing file for skip:" + e.getMessage());
|
||||
throw new TDGWTServiceException("Error parsing file for skip: "
|
||||
+ e.getMessage());
|
||||
|
||||
} catch (IOException e) {
|
||||
logger.debug("Error IOException skipping file error: "+e.getMessage());
|
||||
throw new TDGWTServiceException("Error IOException skipping file error: "+e.getMessage());
|
||||
logger.debug("Error IOException skipping file error: "
|
||||
+ e.getMessage());
|
||||
throw new TDGWTServiceException(
|
||||
"Error IOException skipping file error: "
|
||||
+ e.getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FilesStorage filesStorage = new FilesStorage();
|
||||
|
||||
String fileUrlOnStorage = filesStorage.storageCSVTempFile(user,
|
||||
|
@ -1346,20 +1360,22 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
csvImportTabResource.setTrId(trId);
|
||||
SessionUtil.setCSVImportTabResource(session,
|
||||
csvImportTabResource);
|
||||
logger.debug("Import CSV Succeded TabResource Set:"+csvImportTabResource);
|
||||
logger.debug("Import CSV Succeded TabResource Set:"
|
||||
+ csvImportTabResource);
|
||||
SessionUtil.setTabResource(session,
|
||||
csvImportTabResource);
|
||||
SessionUtil.setTRId(session, trId);
|
||||
break;
|
||||
case STOPPED:
|
||||
importMonitor.setError(new Throwable("Import Stopped on service"));
|
||||
importMonitor.setError(new Throwable(
|
||||
"Import Stopped on service"));
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
importMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case VALIDATING_RULES:
|
||||
importMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
break;
|
||||
case ABORTED:
|
||||
break;
|
||||
case INITIALIZING:
|
||||
|
@ -1450,11 +1466,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
"text/csv");
|
||||
} catch (Exception e) {
|
||||
fileUploadSession/**
|
||||
* Get informations on tabular resource
|
||||
* Get informations on tabular resource
|
||||
*
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/.getFileUploadMonitor().setFailed(
|
||||
*/
|
||||
.getFileUploadMonitor().setFailed(
|
||||
"An error occured elaborating the file",
|
||||
FileUtil.exceptionDetailMessage(e));
|
||||
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
|
||||
|
@ -1470,8 +1487,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
FileUploadState.COMPLETED);
|
||||
SessionUtil.setFileUploadSession(session, fileUploadSession);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
|
@ -1486,16 +1502,17 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
|
||||
TabularResource tr = service
|
||||
.getTabularResource(new TabularResourceId(Long.valueOf(trId
|
||||
.getId())));
|
||||
|
||||
|
||||
return sdf.format(tr.getCreationDate().getTime());
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
"Error in getTRCreationDate(): " + e.getLocalizedMessage(), e);
|
||||
"Error in getTRCreationDate(): " + e.getLocalizedMessage(),
|
||||
e);
|
||||
throw new TDGWTServiceException("Error in getTRCreationDate(): "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
@ -1855,11 +1872,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
exportMonitor.setTabExportMetadata(tabExportMetadata);
|
||||
break;
|
||||
case STOPPED:
|
||||
exportMonitor.setError(new Throwable("Export Stopped on service"));
|
||||
exportMonitor.setError(new Throwable(
|
||||
"Export Stopped on service"));
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
exportMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
break;
|
||||
case VALIDATING_RULES:
|
||||
exportMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
|
@ -2018,14 +2036,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
break;
|
||||
case IN_PROGRESS:
|
||||
exportMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
break;
|
||||
case VALIDATING_RULES:
|
||||
exportMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
break;
|
||||
case ABORTED:
|
||||
break;
|
||||
case STOPPED:
|
||||
exportMonitor.setError(new Throwable("Export Stopped on service"));
|
||||
exportMonitor.setError(new Throwable(
|
||||
"Export Stopped on service"));
|
||||
break;
|
||||
case INITIALIZING:
|
||||
break;
|
||||
|
@ -2052,10 +2071,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
ExportMetadata exportMetadata, CSVExportSession exportSession)
|
||||
throws TDGWTServiceException {
|
||||
logger.debug("Save Export In Destination");
|
||||
logger.debug("Destination: "+exportSession.getDestination().getId());
|
||||
logger.debug("Destination: " + exportSession.getDestination().getId());
|
||||
if (exportSession.getDestination().getId().compareTo("Workspace") == 0) {
|
||||
logger.debug("Save on Workspace");
|
||||
boolean end=SessionUtil.getCSVExportEnd(session);
|
||||
boolean end = SessionUtil.getCSVExportEnd(session);
|
||||
if (end == false) {
|
||||
SessionUtil.setCSVExportEnd(session, true);
|
||||
FilesStorage storage = new FilesStorage();
|
||||
|
@ -2070,7 +2089,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
exportSession.getFileName(),
|
||||
exportSession.getFileDescription(), "text/csv",
|
||||
exportSession.getItemId());
|
||||
|
||||
|
||||
} else {
|
||||
logger.debug("getCSVExportEnd(): true");
|
||||
}
|
||||
|
@ -2081,4 +2100,165 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrive parameters for change column type operation
|
||||
*
|
||||
* @param changeColumnTypeSession
|
||||
* @return
|
||||
*/
|
||||
protected Map<String, Object> retrieveChangeColumnTypeParameters(
|
||||
ChangeColumnTypeSession changeColumnTypeSession) {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
|
||||
ColumnTypeCode.MEASURE) == 0) {
|
||||
|
||||
map.put(Constants.PARAMETER_DATA_TYPE, ColumnDataTypeMap
|
||||
.map(changeColumnTypeSession.getColumnDataType()));
|
||||
map.put(Constants.PARAMETER_DATA_TYPE_TARGET, ColumnDataTypeMap
|
||||
.map(changeColumnTypeSession.getColumnDataTypeTarget()));
|
||||
|
||||
}
|
||||
return map;
|
||||
};
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void startChangeToMeasureColumn(
|
||||
ChangeColumnTypeSession changeColumnTypeSession)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setChangeColumnTypeSession(session,
|
||||
changeColumnTypeSession);
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
List<OperationDefinition> capabilities = service.getCapabilities();
|
||||
|
||||
OperationDefinition changeToMeasureColumnOperation = getOperationDescriptorWithId(
|
||||
OperationsId.ChangeToMeasureColumn.toString(), capabilities);
|
||||
|
||||
logger.debug(changeColumnTypeSession.toString());
|
||||
|
||||
Map<String, Object> parameterInstance = retrieveChangeColumnTypeParameters(changeColumnTypeSession);
|
||||
|
||||
OperationExecution invocation = new OperationExecution(
|
||||
changeColumnTypeSession.getColumnName(),
|
||||
changeToMeasureColumnOperation.getOperationId(),
|
||||
parameterInstance);
|
||||
|
||||
TabularResourceId serviceTR = new TabularResourceId(
|
||||
Long.valueOf(changeColumnTypeSession.getTrId().getId()));
|
||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||
Task trTask = service.execute(invocation, serviceTR);
|
||||
logger.debug("Start Task on service: TaskId " + trTask.getId());
|
||||
SessionUtil.setChangeColumnTypeTask(session, trTask);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error in ChangeToMeasureColumn: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public ChangeColumnTypeMonitor getChangeColumnTypeMonitor()
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
//ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
ChangeColumnTypeSession changeColumnTypeSession = SessionUtil
|
||||
.getChangeColumnTypeSession(session);
|
||||
|
||||
Task task = SessionUtil.getChangeColumnTypeTask(session);
|
||||
ChangeColumnTypeMonitor changeColumnTypeMonitor = new ChangeColumnTypeMonitor();
|
||||
|
||||
if (task == null) {
|
||||
logger.debug("Task null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in ChangeColumnType task null");
|
||||
} else {
|
||||
TaskStatus status = task.getStatus();
|
||||
if (status == null) {
|
||||
logger.debug("Services TaskStatus : null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in ChangeColumnType Status null");
|
||||
} else {
|
||||
logger.debug("Services TaskStatus: " + task.getStatus());
|
||||
|
||||
changeColumnTypeMonitor.setStatus(matchTaskState(task
|
||||
.getStatus()));
|
||||
switch (changeColumnTypeMonitor.getStatus()) {
|
||||
case FAILED:
|
||||
if (task.getResult() != null) {
|
||||
logger.debug("Task exception:"
|
||||
+ task.getErrorCause());
|
||||
changeColumnTypeMonitor.setError(new Throwable(task
|
||||
.getErrorCause()));
|
||||
} else {
|
||||
logger.debug("Task exception: Error In ChangeColumnType");
|
||||
changeColumnTypeMonitor.setError(new Throwable(
|
||||
"Error In ChangeColumnType"));
|
||||
}
|
||||
changeColumnTypeMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case SUCCEDED:
|
||||
logger.debug("Task Result:" + task.getResult());
|
||||
changeColumnTypeMonitor.setProgress(task.getProgress());
|
||||
Table table = task.getResult().getPrimaryTable();
|
||||
logger.debug("Table retrived: " + table.toString());
|
||||
TRId trId=new TRId();
|
||||
trId.setId(changeColumnTypeSession
|
||||
.getTrId().getId());
|
||||
trId.setTableId(String.valueOf(table.getId()
|
||||
.getValue()));
|
||||
trId.setTableType(table.getTableType().getName());
|
||||
changeColumnTypeMonitor.setTrId(trId);
|
||||
TabResource tabResource=SessionUtil.getTabResource(session);
|
||||
tabResource.setTrId(trId);
|
||||
SessionUtil.setTabResource(session, tabResource);
|
||||
SessionUtil.setTRId(session, trId);
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
changeColumnTypeMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case VALIDATING_RULES:
|
||||
changeColumnTypeMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case ABORTED:
|
||||
break;
|
||||
case STOPPED:
|
||||
changeColumnTypeMonitor.setError(new Throwable(
|
||||
"Export Stopped on service"));
|
||||
break;
|
||||
case INITIALIZING:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
SessionUtil.setChangeColumnTypeTask(session, task);
|
||||
}
|
||||
|
||||
logger.info("ChangeColumnTypeMonitor(): " + changeColumnTypeMonitor);
|
||||
return changeColumnTypeMonitor;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(
|
||||
"Error in change column type ChangeColumnTypeMonitor: "
|
||||
+ e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.server.trservice;
|
||||
import org.gcube.data.analysis.tabulardata.model.datatype.BooleanType;
|
||||
import org.gcube.data.analysis.tabulardata.model.datatype.DataType;
|
||||
import org.gcube.data.analysis.tabulardata.model.datatype.GeometryType;
|
||||
import org.gcube.data.analysis.tabulardata.model.datatype.IntegerType;
|
||||
import org.gcube.data.analysis.tabulardata.model.datatype.NumericType;
|
||||
import org.gcube.data.analysis.tabulardata.model.datatype.TextType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ColumnDataTypeMap {
|
||||
|
||||
public static DataType map(ColumnDataType columnDataType){
|
||||
if(columnDataType==ColumnDataType.Integer){
|
||||
return new IntegerType() ;
|
||||
} else {
|
||||
if(columnDataType==ColumnDataType.Numeric){
|
||||
return new NumericType();
|
||||
} else {
|
||||
if(columnDataType==ColumnDataType.Boolean){
|
||||
return new BooleanType();
|
||||
} else {
|
||||
if(columnDataType==ColumnDataType.Geometry){
|
||||
return new GeometryType();
|
||||
} else {
|
||||
if(columnDataType==ColumnDataType.Text){
|
||||
return new TextType();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -27,6 +27,10 @@ public class Constants {
|
|||
public static final String PARAMETER_ID ="id";
|
||||
public static final String PARAMETER_VERSION ="version";
|
||||
|
||||
public static final String PARAMETER_DATA_TYPE="dataType";
|
||||
public static final String PARAMETER_DATA_TYPE_TARGET="dataTypeTarget";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gwtservice.shared.tr.column.type;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.task.State;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ChangeColumnTypeMonitor implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 5378053063599667767L;
|
||||
|
||||
protected float progress;
|
||||
protected State status;
|
||||
protected String statusDescription;
|
||||
protected Throwable error;
|
||||
protected TRId trId;
|
||||
protected String columnName;
|
||||
|
||||
public float getProgress(){
|
||||
return progress;
|
||||
};
|
||||
|
||||
public State getStatus(){
|
||||
return status;
|
||||
}
|
||||
|
||||
public String getStatusDescription(){
|
||||
return statusDescription;
|
||||
}
|
||||
|
||||
public void setProgress(float progress) {
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
public void setStatus(State status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = State.values()[status];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setStatusDescription(String statusDescription) {
|
||||
this.statusDescription = statusDescription;
|
||||
}
|
||||
|
||||
public Throwable getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(Throwable error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public TRId getTrId() {
|
||||
return trId;
|
||||
}
|
||||
|
||||
public void setTrId(TRId trId) {
|
||||
this.trId = trId;
|
||||
}
|
||||
|
||||
public String getColumnName() {
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public void setColumnName(String columnName) {
|
||||
this.columnName = columnName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChangeColumnTypeMonitor [progress=" + progress + ", status="
|
||||
+ status + ", statusDescription=" + statusDescription
|
||||
+ ", error=" + error + ", trId=" + trId + ", columnName="
|
||||
+ columnName + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.shared.tr.column.type;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
|
||||
|
||||
public class ChangeColumnTypeSession implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7154832921853261421L;
|
||||
|
||||
protected TRId trId;
|
||||
protected String columnName;
|
||||
protected ColumnTypeCode columnTypeCode;
|
||||
protected ColumnDataType columnDataType;
|
||||
protected ColumnTypeCode columnTypeCodeTarget;
|
||||
protected ColumnDataType columnDataTypeTarget;
|
||||
|
||||
|
||||
public TRId getTrId() {
|
||||
return trId;
|
||||
}
|
||||
public void setTrId(TRId trId) {
|
||||
this.trId = trId;
|
||||
}
|
||||
public String getColumnName() {
|
||||
return columnName;
|
||||
}
|
||||
public void setColumnName(String columnName) {
|
||||
this.columnName = columnName;
|
||||
}
|
||||
public ColumnTypeCode getColumnTypeCode() {
|
||||
return columnTypeCode;
|
||||
}
|
||||
public void setColumnTypeCode(ColumnTypeCode columnTypeCode) {
|
||||
this.columnTypeCode = columnTypeCode;
|
||||
}
|
||||
public ColumnDataType getColumnDataType() {
|
||||
return columnDataType;
|
||||
}
|
||||
public void setColumnDataType(ColumnDataType columnDataType) {
|
||||
this.columnDataType = columnDataType;
|
||||
}
|
||||
public ColumnTypeCode getColumnTypeCodeTarget() {
|
||||
return columnTypeCodeTarget;
|
||||
}
|
||||
public void setColumnTypeCodeTarget(ColumnTypeCode columnTypeCodeTarget) {
|
||||
this.columnTypeCodeTarget = columnTypeCodeTarget;
|
||||
}
|
||||
public ColumnDataType getColumnDataTypeTarget() {
|
||||
return columnDataTypeTarget;
|
||||
}
|
||||
public void setColumnDataTypeTarget(ColumnDataType columnDataTypeTarget) {
|
||||
this.columnDataTypeTarget = columnDataTypeTarget;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChangeColumnTypeSession [trId=" + trId + ", columnName="
|
||||
+ columnName + ", columnTypeCode=" + columnTypeCode
|
||||
+ ", columnDataType=" + columnDataType
|
||||
+ ", columnTypeCodeTarget=" + columnTypeCodeTarget
|
||||
+ ", columnDataTypeTarget=" + columnDataTypeTarget + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue