Updated to new Service version
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@87217 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
47e448760a
commit
a007f8142d
6
pom.xml
6
pom.xml
|
@ -116,7 +116,11 @@
|
|||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>custom-portal-handler</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Apache Common Library -->
|
||||
<dependency>
|
||||
|
|
|
@ -7,9 +7,7 @@ import java.io.InputStream;
|
|||
import java.nio.charset.Charset;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -24,6 +22,10 @@ import org.gcube.common.homelibrary.home.HomeManagerFactory;
|
|||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
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.operations.OperationDefinition;
|
||||
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution;
|
||||
import org.gcube.data.analysis.tabulardata.metadata.NoSuchMetadataException;
|
||||
import org.gcube.data.analysis.tabulardata.model.column.Column;
|
||||
import org.gcube.data.analysis.tabulardata.model.column.type.IdColumnType;
|
||||
|
@ -37,9 +39,6 @@ import org.gcube.data.analysis.tabulardata.model.metadata.table.TableMetadata;
|
|||
import org.gcube.data.analysis.tabulardata.model.metadata.table.VersionMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.model.table.Table;
|
||||
import org.gcube.data.analysis.tabulardata.model.table.TableId;
|
||||
import org.gcube.data.analysis.tabulardata.operation.OperationDescriptor;
|
||||
import org.gcube.data.analysis.tabulardata.operation.invocation.InvocationCreator;
|
||||
import org.gcube.data.analysis.tabulardata.operation.invocation.OperationInvocation;
|
||||
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
|
||||
import org.gcube.data.analysis.tabulardata.service.exception.InvalidTabularResourceException;
|
||||
import org.gcube.data.analysis.tabulardata.service.exception.NoSuchTabularResourceException;
|
||||
|
@ -51,7 +50,6 @@ import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
|
|||
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceInterface;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.AgencyMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.CreationDateMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.DescriptionMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.NameMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.RightsMetadata;
|
||||
|
@ -116,19 +114,23 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
|||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTService {
|
||||
public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||
TDGWTService {
|
||||
|
||||
private static final long serialVersionUID = -5707400086333186368L;
|
||||
protected static Logger logger = LoggerFactory.getLogger(TDGWTServiceImpl.class);
|
||||
protected static Logger logger = LoggerFactory
|
||||
.getLogger(TDGWTServiceImpl.class);
|
||||
|
||||
protected static SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
|
||||
protected static SimpleDateFormat sdf = new SimpleDateFormat(
|
||||
"yyyy/MM/dd HH:mm");
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
public void setTabResource(TabResource tabResource) throws TDGWTServiceException {
|
||||
|
||||
public void setTabResource(TabResource tabResource)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
if (tabResource == null) {
|
||||
|
@ -159,8 +161,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
public TabResource getTabResourceInformation() throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
|
||||
//ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
// ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
TabResource currentTR = SessionUtil.getTabResource(session);
|
||||
if (currentTR == null) {
|
||||
|
@ -169,14 +171,19 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
"CURRENT_TABULAR_RESOURCE is null");
|
||||
}
|
||||
|
||||
ArrayList<TRMetadata> trMetadatas = getTRMetadata(currentTR.getTrId());
|
||||
ArrayList<TRMetadata> trMetadatas = getTRMetadata(currentTR
|
||||
.getTrId());
|
||||
updateTabResourceInformation(currentTR, trMetadatas);
|
||||
SessionUtil.setTabResource(session, currentTR);
|
||||
return currentTR;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error setting TabResource parameter: "+ e.getLocalizedMessage(), e);
|
||||
throw new TDGWTServiceException("Error setting TabResource parameter: "+ e.getLocalizedMessage());
|
||||
logger.error(
|
||||
"Error setting TabResource parameter: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
throw new TDGWTServiceException(
|
||||
"Error setting TabResource parameter: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,7 +195,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
//ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
// ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
TabResource currentTR = new TabResource();
|
||||
currentTR.setTrId(trId);
|
||||
|
@ -260,8 +267,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
}
|
||||
TRId trId = currentTR.getTrId();
|
||||
|
||||
TabularDataService service = TabularDataServiceFactory.getService(aslSession
|
||||
.getUsername());
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
Table table = service.getLastTable(new TabularResourceId(Long
|
||||
.valueOf(trId.getId())));
|
||||
|
@ -328,8 +336,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
TabularDataService service = TabularDataServiceFactory.getService(aslSession
|
||||
.getUsername());
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
Table table = service.getLastTable(new TabularResourceId(Long
|
||||
.valueOf(trId.getId())));
|
||||
|
@ -366,7 +375,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
}
|
||||
|
||||
/**
|
||||
* Not used now, but it will be necessary in the future to retrieve task pending
|
||||
* Not used now, but it will be necessary in the future to retrieve task
|
||||
* pending
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -392,11 +402,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
* @param tabResource
|
||||
*/
|
||||
protected void syncTRMetaData(TabularResource tr, TabResource tabResource) {
|
||||
Date date = Calendar.getInstance().getTime();
|
||||
tabResource.setDate(sdf.format(date));
|
||||
// Date date = Calendar.getInstance().getTime();
|
||||
tabResource.setDate(sdf.format(tr.getCreationDate()));
|
||||
tr.setMetadata(new NameMetadata(tabResource.getName()));
|
||||
tr.setMetadata(new DescriptionMetadata(tabResource.getDescription()));
|
||||
tr.setMetadata(new CreationDateMetadata(date));
|
||||
// tr.setMetadata(new CreationDateMetadata(date));
|
||||
if (tabResource.getAgency() != null
|
||||
&& !tabResource.getAgency().isEmpty()) {
|
||||
tr.setMetadata(new AgencyMetadata(tabResource.getAgency()));
|
||||
|
@ -410,9 +420,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
* @param tr
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
protected void retriveTRMetadataFromService(TabularDataService service,TabularResource tr)
|
||||
throws TDGWTServiceException {
|
||||
retriveTRMetadataFromService(service,tr, 0);
|
||||
protected void retriveTRMetadataFromService(TabularDataService service,
|
||||
TabularResource tr) throws TDGWTServiceException {
|
||||
retriveTRMetadataFromService(service, tr, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -425,10 +435,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
* @return TabResource for Grid
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
protected TabResource retriveTRMetadataFromService(TabularDataService service,
|
||||
TabularResource tr, int i)
|
||||
protected TabResource retriveTRMetadataFromService(
|
||||
TabularDataService service, TabularResource tr, int i)
|
||||
throws TDGWTServiceException {
|
||||
|
||||
|
||||
Table table = null;
|
||||
try {
|
||||
table = service.getLastTable(tr.getId());
|
||||
|
@ -451,23 +461,20 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
if (tableId == null) {
|
||||
logger.info("Tabular Resource " + tr.getId()
|
||||
+ " has last table with id null.");
|
||||
t=new TabResource();
|
||||
t = new TabResource();
|
||||
t.setTrId(null);
|
||||
} else {
|
||||
trId = new TRId(String.valueOf(tr.getId().getValue()),
|
||||
String.valueOf(tableId.getValue()),table.getTableType().getName());
|
||||
t=getTabResourceInformation(trId);
|
||||
|
||||
String.valueOf(tableId.getValue()), table.getTableType()
|
||||
.getName());
|
||||
t = getTabResourceInformation(trId);
|
||||
|
||||
}
|
||||
t.setId(String.valueOf(i));
|
||||
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
|
@ -477,8 +484,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
TabularDataService service = TabularDataServiceFactory.getService(aslSession
|
||||
.getUsername());
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
List<TabularResource> trs = service.getTabularResources();
|
||||
SessionUtil.setTabularResources(session, trs);
|
||||
|
@ -522,8 +531,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
throw new TDGWTServiceException(
|
||||
"Error removing TabularResource no parameters set");
|
||||
}
|
||||
TabularDataService service = TabularDataServiceFactory.getService(aslSession
|
||||
.getUsername());
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
TabularResourceId id = new TabularResourceId(Long.valueOf(trId
|
||||
.getId()));
|
||||
service.removeTabularResource(id);
|
||||
|
@ -552,14 +563,17 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
throw new TDGWTServiceException(
|
||||
"Error creating new TabularResource no parameters set");
|
||||
}
|
||||
TabularDataService service = TabularDataServiceFactory.getService(aslSession
|
||||
.getUsername());
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
TabularResource serviceTR = service.createTabularResource();
|
||||
Table table = service.getLastTable(serviceTR.getId());
|
||||
syncTRMetaData(serviceTR, tabResource);
|
||||
TRId trId = new TRId(String.valueOf(serviceTR.getId().getValue()),
|
||||
String.valueOf(table.getId().getValue()),
|
||||
table.getTableType().getName());
|
||||
String.valueOf(table.getId().getValue()), table
|
||||
.getTableType().getName());
|
||||
tabResource.setTrId(trId);
|
||||
return tabResource;
|
||||
} catch (Exception e) {
|
||||
|
@ -655,15 +669,17 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
SessionUtil.setSDMXImportSession(session, sdmxImportSession);
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
TabularDataService service = TabularDataServiceFactory.getService(aslSession
|
||||
.getUsername());
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
OperationInterface oService = service;
|
||||
TabularResourceInterface trService = service;
|
||||
|
||||
List<OperationDescriptor> capabilities = service.getCapabilities();
|
||||
List<OperationDefinition> capabilities = service.getCapabilities();
|
||||
|
||||
// Import SDMX Codelist takes id 200
|
||||
OperationDescriptor importSDMXCodelistOperation = getOperationDescriptorWithId(
|
||||
OperationDefinition importSDMXCodelistOperation = getOperationDescriptorWithId(
|
||||
OperationsId.SDMXCodelistImport.toString(), capabilities);
|
||||
|
||||
TabResource importSDMXTabResource = sdmxImportSession
|
||||
|
@ -680,10 +696,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
|
||||
Map<String, Object> parameterInstance = retrieveOperationParameters(sdmxImportSession);
|
||||
|
||||
InvocationCreator ic = InvocationCreator
|
||||
.getCreator(importSDMXCodelistOperation);
|
||||
OperationInvocation invocation = ic
|
||||
.setParameters(parameterInstance).create();
|
||||
OperationExecution invocation = new OperationExecution(
|
||||
importSDMXCodelistOperation.getOperationId(),
|
||||
parameterInstance);
|
||||
|
||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||
Task trTask = oService.execute(invocation, serviceTR.getId());
|
||||
|
@ -704,11 +719,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
protected OperationDescriptor getOperationDescriptorWithId(String op,
|
||||
List<OperationDescriptor> capabilities)
|
||||
protected OperationDefinition getOperationDescriptorWithId(String op,
|
||||
List<OperationDefinition> capabilities)
|
||||
throws TDGWTServiceException {
|
||||
for (OperationDescriptor operation : capabilities) {
|
||||
if (Long.valueOf(op) == operation.getOperationId().getValue()) {
|
||||
for (OperationDefinition operation : capabilities) {
|
||||
if (Long.valueOf(op) == operation.getOperationId()) {
|
||||
return operation;
|
||||
}
|
||||
|
||||
|
@ -743,7 +758,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
//ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
// ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
Task task = SessionUtil.getSDMXImportTask(session);
|
||||
TabResource sdmxImportTabResource = SessionUtil
|
||||
.getSDMXImportTabResource(session);
|
||||
|
@ -774,8 +789,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
case SUCCEDED:
|
||||
importMonitor.setProgress(task.getProgress());
|
||||
logger.debug("Task Result: " + task.getResult());
|
||||
Table table=task.getResult().getPrimaryTable();
|
||||
trId.setTableId(String.valueOf(table.getId().getValue()));
|
||||
Table table = task.getResult().getPrimaryTable();
|
||||
trId.setTableId(String.valueOf(table.getId()
|
||||
.getValue()));
|
||||
trId.setTableType(table.getTableType().getName());
|
||||
sdmxImportTabResource.setTrId(trId);
|
||||
SessionUtil.setSDMXImportTabResource(session,
|
||||
|
@ -1005,7 +1021,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
"Error retrieving the fileUploadSession: null");
|
||||
}
|
||||
|
||||
importCSVFileOnService(session,aslSession,user, fileUploadSession, csvImportSession);
|
||||
importCSVFileOnService(session, aslSession, user, fileUploadSession,
|
||||
csvImportSession);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1041,7 +1058,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
* @param csvImportSession
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
protected void importCSVFileOnService(HttpSession session,ASLSession aslSession,String user,
|
||||
protected void importCSVFileOnService(HttpSession session,
|
||||
ASLSession aslSession, String user,
|
||||
FileUploadSession fileUploadSession,
|
||||
CSVImportSession csvImportSession) throws TDGWTServiceException {
|
||||
logger.debug("File Storage Access");
|
||||
|
@ -1056,19 +1074,20 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
fileUrlOnStorage, fileUploadSession, csvImportSession);
|
||||
|
||||
logger.debug("Tabular Data Service");
|
||||
TabularDataService service = TabularDataServiceFactory
|
||||
.getService(aslSession.getUsername());
|
||||
List<OperationDescriptor> capabilities = service.getCapabilities();
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(aslSession
|
||||
.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
List<OperationDefinition> capabilities = service.getCapabilities();
|
||||
|
||||
// Import CSV file
|
||||
|
||||
OperationDescriptor importCSVFileOperation = getOperationDescriptorWithId(
|
||||
OperationDefinition importCSVFileOperation = getOperationDescriptorWithId(
|
||||
OperationsId.CSVImport.toString(), capabilities);
|
||||
|
||||
InvocationCreator ic = InvocationCreator
|
||||
.getCreator(importCSVFileOperation);
|
||||
OperationInvocation invocation = ic.setParameters(parameterInstance)
|
||||
.create();
|
||||
OperationExecution invocation = new OperationExecution(
|
||||
importCSVFileOperation.getOperationId(), parameterInstance);
|
||||
|
||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||
TabularResource tabularResource = service.createTabularResource();
|
||||
|
@ -1098,7 +1117,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
public CSVImportMonitor getCSVImportMonitor() throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
//ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
// ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
Task task = SessionUtil.getCSVImportFileTask(session);
|
||||
TabResource csvImportTabResource = SessionUtil
|
||||
.getCSVImportTabResource(session);
|
||||
|
@ -1272,8 +1291,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
TabularDataService service = TabularDataServiceFactory.getService(aslSession
|
||||
.getUsername());
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
TabularResource tr = service
|
||||
.getTabularResource(new TabularResourceId(Long.valueOf(trId
|
||||
.getId())));
|
||||
|
@ -1304,24 +1325,16 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
.getValue());
|
||||
listTRMetadata.add(trAgencyMetadata);
|
||||
} else {
|
||||
if (trMetadata instanceof CreationDateMetadata) {
|
||||
TRCreationDateMetadata trCreationDateMetadata = new TRCreationDateMetadata();
|
||||
trCreationDateMetadata
|
||||
.setDate(sdf
|
||||
.format(((CreationDateMetadata) trMetadata)
|
||||
.getValue()));
|
||||
listTRMetadata.add(trCreationDateMetadata);
|
||||
if (trMetadata instanceof RightsMetadata) {
|
||||
TRRightsMetadata trRightsMetadata = new TRRightsMetadata();
|
||||
trRightsMetadata
|
||||
.setValue(((RightsMetadata) trMetadata)
|
||||
.getValue());
|
||||
listTRMetadata.add(trRightsMetadata);
|
||||
} else {
|
||||
if (trMetadata instanceof RightsMetadata) {
|
||||
TRRightsMetadata trRightsMetadata = new TRRightsMetadata();
|
||||
trRightsMetadata
|
||||
.setValue(((RightsMetadata) trMetadata)
|
||||
.getValue());
|
||||
listTRMetadata.add(trRightsMetadata);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1347,8 +1360,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
TabularDataService service = TabularDataServiceFactory.getService(aslSession
|
||||
.getUsername());
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
Table table = service.getTable(new TableId(Long.valueOf(trId
|
||||
.getTableId())));
|
||||
|
||||
|
@ -1529,20 +1544,19 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
Map<String, Object> parameterInstance = sdmxExportParameter(exportSession);
|
||||
|
||||
logger.debug("Tabular Data Service");
|
||||
TabularDataService service = TabularDataServiceFactory
|
||||
.getService(aslSession.getUsername());
|
||||
|
||||
List<OperationDescriptor> capabilities = service.getCapabilities();
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(aslSession
|
||||
.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
List<OperationDefinition> capabilities = service.getCapabilities();
|
||||
|
||||
// Export SDMX Codelist
|
||||
OperationDescriptor exportSDMXOperation = getOperationDescriptorWithId(
|
||||
OperationDefinition exportSDMXOperation = getOperationDescriptorWithId(
|
||||
OperationsId.SDMXCodelistExport.toString(), capabilities);
|
||||
|
||||
InvocationCreator ic = InvocationCreator
|
||||
.getCreator(exportSDMXOperation);
|
||||
OperationInvocation invocation = ic
|
||||
.setTargetTable(new TableId(Long.valueOf(trId.getTableId())))
|
||||
.setParameters(parameterInstance).create();
|
||||
OperationExecution invocation = new OperationExecution(
|
||||
exportSDMXOperation.getOperationId(), parameterInstance);
|
||||
|
||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||
|
||||
|
@ -1568,7 +1582,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
//ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
// ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
Task task = SessionUtil.getSDMXExportTask(session);
|
||||
SDMXExportMonitor exportMonitor = new SDMXExportMonitor();
|
||||
|
||||
|
@ -1589,8 +1603,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
if (task.getResult() != null) {
|
||||
logger.debug("Task exception:"
|
||||
+ task.getErrorCause());
|
||||
exportMonitor.setError(task
|
||||
.getErrorCause());
|
||||
exportMonitor.setError(task.getErrorCause());
|
||||
} else {
|
||||
logger.debug("Task exception: Error In Export");
|
||||
exportMonitor.setError(new Throwable(
|
||||
|
@ -1681,20 +1694,19 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
Map<String, Object> parameterInstance = csvExportFileParameter(exportSession);
|
||||
|
||||
logger.debug("Tabular Data Service");
|
||||
TabularDataService service = TabularDataServiceFactory
|
||||
.getService(aslSession.getUsername());
|
||||
|
||||
List<OperationDescriptor> capabilities = service.getCapabilities();
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(aslSession
|
||||
.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
List<OperationDefinition> capabilities = service.getCapabilities();
|
||||
|
||||
// Export CSV file
|
||||
OperationDescriptor exportCSVFileOperation = getOperationDescriptorWithId(
|
||||
OperationDefinition exportCSVFileOperation = getOperationDescriptorWithId(
|
||||
OperationsId.CSVExport.toString(), capabilities);
|
||||
|
||||
InvocationCreator ic = InvocationCreator
|
||||
.getCreator(exportCSVFileOperation);
|
||||
OperationInvocation invocation = ic
|
||||
.setTargetTable(new TableId(Long.valueOf(trId.getTableId())))
|
||||
.setParameters(parameterInstance).create();
|
||||
OperationExecution invocation = new OperationExecution(
|
||||
exportCSVFileOperation.getOperationId(), parameterInstance);
|
||||
|
||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||
|
||||
|
@ -1712,7 +1724,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
logger.debug("Start Task on service: TaskId " + trTask.getId());
|
||||
SessionUtil.setCSVExportEnd(session, false);
|
||||
SessionUtil.setCSVExportTask(session, trTask);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1771,7 +1783,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
trExportMetadata.setExportDate(sdf
|
||||
.format(exportMetadata.getExportDate()));
|
||||
exportMonitor.setTrExportMetadata(trExportMetadata);
|
||||
saveInDestination(session,aslSession.getUsername(),
|
||||
saveInDestination(session, aslSession.getUsername(),
|
||||
exportMetadata, exportSession);
|
||||
|
||||
break;
|
||||
|
@ -1803,7 +1815,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
|
|||
|
||||
}
|
||||
|
||||
protected void saveInDestination(HttpSession session,String user,
|
||||
protected void saveInDestination(HttpSession session, String user,
|
||||
ExportMetadata exportMetadata, CSVExportSession exportSession)
|
||||
throws TDGWTServiceException {
|
||||
if (exportSession.getDestination().getId().compareTo("Workspace") == 0) {
|
||||
|
|
|
@ -5,11 +5,11 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
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.operations.OperationDefinition;
|
||||
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution;
|
||||
import org.gcube.data.analysis.tabulardata.model.table.Table;
|
||||
import org.gcube.data.analysis.tabulardata.operation.OperationDescriptor;
|
||||
import org.gcube.data.analysis.tabulardata.operation.invocation.InvocationCreator;
|
||||
import org.gcube.data.analysis.tabulardata.operation.invocation.OperationInvocation;
|
||||
|
||||
import org.gcube.data.analysis.tabulardata.query.parameters.QueryPage;
|
||||
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
|
||||
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
|
||||
|
@ -45,8 +45,10 @@ public class TestService {
|
|||
public void createSDMX() throws Exception {
|
||||
|
||||
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
|
||||
TabularDataService service = TabularDataServiceFactory
|
||||
.getService(Constants.DEFAULT_USER);
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(Constants.DEFAULT_USER));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
TabularResource resource = service.createTabularResource();
|
||||
System.out.println("after createTabResource "
|
||||
+ ScopeProvider.instance.get());
|
||||
|
@ -59,9 +61,9 @@ public class TestService {
|
|||
|
||||
System.out.println("------------List Operations------------");
|
||||
|
||||
List<OperationDescriptor> ops = service.getCapabilities();
|
||||
OperationDescriptor csvop = null;
|
||||
for (OperationDescriptor op : ops) {
|
||||
List<OperationDefinition> ops = service.getCapabilities();
|
||||
OperationDefinition csvop = null;
|
||||
for (OperationDefinition op : ops) {
|
||||
System.out.println(op.getName());
|
||||
if (op.getName().compareTo("SDMX Codelist import")==0)
|
||||
{
|
||||
|
@ -72,16 +74,13 @@ public class TestService {
|
|||
}
|
||||
//
|
||||
System.out.println("------------Invocation------------");
|
||||
|
||||
OperationExecution invocation = new OperationExecution(csvop.getOperationId(), getParameterInvocationSDMX());
|
||||
|
||||
|
||||
InvocationCreator ic = InvocationCreator.getCreator(csvop);
|
||||
|
||||
OperationInvocation opInvocation = ic.setParameters(
|
||||
getParameterInvocationSDMX()).create();
|
||||
|
||||
//
|
||||
System.out.println("------------Execute------------");
|
||||
Task task = service.execute(opInvocation, resource.getId());
|
||||
Task task = service.execute(invocation, resource.getId());
|
||||
System.out.println("------------Check Task------------");
|
||||
while (task.getStatus() != TaskStatus.FAILED
|
||||
&& task.getStatus() != TaskStatus.SUCCEDED) {
|
||||
|
@ -131,7 +130,9 @@ public class TestService {
|
|||
public void createCSV() throws Exception{
|
||||
try{
|
||||
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
|
||||
TabularDataService service = TabularDataServiceFactory.getService(Constants.DEFAULT_USER);
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(Constants.DEFAULT_USER));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
TabularResource resource = service.createTabularResource();
|
||||
System.out.println("after createTabResource "+ScopeProvider.instance.get());
|
||||
System.out.println("name: "+((NameMetadata)resource.getMetadata(NameMetadata.class)).getValue());
|
||||
|
@ -140,17 +141,19 @@ public class TestService {
|
|||
System.out.println("tabular data id: "+resource.getId().getValue());
|
||||
TabularResourceId resourceId = resource.getId();
|
||||
|
||||
List<OperationDescriptor> ops =service.getCapabilities();
|
||||
OperationDescriptor csvop = null;
|
||||
for (OperationDescriptor op : ops ){
|
||||
List<OperationDefinition> ops =service.getCapabilities();
|
||||
OperationDefinition csvop = null;
|
||||
for (OperationDefinition op : ops ){
|
||||
System.out.println(op.getName());
|
||||
if (op.getName().equals("CSV Import"))
|
||||
csvop = op;
|
||||
}
|
||||
|
||||
OperationInvocation invocation = InvocationCreator.getCreator(csvop)
|
||||
.setParameters(getParameterInvocationCSV())
|
||||
.create();
|
||||
|
||||
|
||||
OperationExecution invocation = new OperationExecution(csvop.getOperationId(), getParameterInvocationCSV());
|
||||
|
||||
|
||||
Task task = service.execute(invocation, resource.getId());
|
||||
|
||||
while (task.getStatus()!= TaskStatus.FAILED && task.getStatus()!= TaskStatus.SUCCEDED){
|
||||
|
@ -191,8 +194,9 @@ public class TestService {
|
|||
@Test
|
||||
public void listTR() throws Exception {
|
||||
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
|
||||
TabularDataService service = TabularDataServiceFactory
|
||||
.getService(Constants.DEFAULT_USER);
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(Constants.DEFAULT_USER));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
List<TabularResource> trs = service.getTabularResources();
|
||||
Assert.assertTrue(trs.size() > 0);
|
||||
System.out.println("------------Tabular Resource--------------");
|
||||
|
|
|
@ -3,7 +3,9 @@ package org.gcube.portlets.user.td.gwtservice.client;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.data.analysis.tabulardata.operation.OperationDescriptor;
|
||||
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.operations.OperationDefinition;
|
||||
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
|
||||
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||
|
@ -21,15 +23,17 @@ public class TestServiceOperations {
|
|||
@Test
|
||||
public void TestTROperation() {
|
||||
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
|
||||
TabularDataService service = TabularDataServiceFactory
|
||||
.getService(Constants.DEFAULT_USER);
|
||||
List<OperationDescriptor> trOperations = service.getCapabilities();
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(Constants.DEFAULT_USER));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
List<OperationDefinition> trOperations = service.getCapabilities();
|
||||
Assert.assertTrue(trOperations.size() > 0);
|
||||
System.out
|
||||
.println("------------Tabular Resource Operation--------------");
|
||||
for (OperationDescriptor operation : trOperations) {
|
||||
for (OperationDefinition operation : trOperations) {
|
||||
System.out.println("Name: "+operation.getName());
|
||||
System.out.println("Scope: "+operation.getScope());
|
||||
//System.out.println("Scope: "+operation.getScope());
|
||||
System.out.println("Desc: "+operation.toString());
|
||||
System.out.println("-----------------------------------");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue