ref 8033:Support for SDMX export from templates on tabman

https://support.d4science.org/issues/8033

Updated to support export of Dataset

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@146845 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-04-13 10:24:06 +00:00
parent 9876c66d37
commit 0f404c3cf6
12 changed files with 767 additions and 65 deletions

View File

@ -31,6 +31,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitorSession;
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.sdmx.SDMXTemplateExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.share.ShareRule;
import org.gcube.portlets.user.td.gwtservice.shared.share.ShareTabResource;
import org.gcube.portlets.user.td.gwtservice.shared.share.ShareTemplate;
@ -40,6 +41,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitSession;
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResumeSession;
import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsTasksMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.RefColumn;
@ -787,6 +789,20 @@ public interface TDGWTService extends RemoteService {
public String startSDMXExport(SDMXExportSession exportSession)
throws TDGWTServiceException;
// Export Template SDMX
/**
*
* Start SDMX Template Export and invokes the client library
*
* @param sdmxTemplateExportSession
* @return
* @throws TDGWTServiceException
*/
public String startSDMXTemplateExport(
SDMXTemplateExportSession sdmxTemplateExportSession)
throws TDGWTServiceException;
// Export JSON
/**
* Start JSON Export and invokes the client library
@ -994,6 +1010,30 @@ public interface TDGWTService extends RemoteService {
*/
public ArrayList<TemplateData> getTemplates() throws TDGWTServiceException;
/**
*
* Retrieves templates for export as DSD in SDMX registry.
* Template must have at least a measure column.
*
* @return
* @throws TDGWTServiceException
*/
public ArrayList<TemplateData> getTemplatesForDSDExport()
throws TDGWTServiceException;
/**
*
* Retrieves the columns of the specific template.
* Template must have at least a measure column.
*
* @return
* @throws TDGWTServiceException
*/
public ArrayList<TemplateColumnData> getTemplateColumnsData(String templateId)
throws TDGWTServiceException;
/**
* Start Apply Template
*
@ -1287,4 +1327,6 @@ public interface TDGWTService extends RemoteService {
GeometryCreatePointSession geometryCreatePointSession)
throws TDGWTServiceException;
}

View File

@ -30,6 +30,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitorSession;
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.sdmx.SDMXTemplateExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.share.ShareRule;
import org.gcube.portlets.user.td.gwtservice.shared.share.ShareTabResource;
import org.gcube.portlets.user.td.gwtservice.shared.share.ShareTemplate;
@ -39,6 +40,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitSession;
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResumeSession;
import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsTasksMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.RefColumn;
@ -295,6 +297,11 @@ public interface TDGWTServiceAsync {
void startSDMXExport(SDMXExportSession exportSession,
AsyncCallback<String> callback);
// Export Template SDMX
void startSDMXTemplateExport(
SDMXTemplateExportSession sdmxTemplateExportSession,
AsyncCallback<String> callback);
// Export JSON
void startJSONExport(JSONExportSession jsonExportSession,
AsyncCallback<String> callback);
@ -365,6 +372,12 @@ public interface TDGWTServiceAsync {
// Templates
void getTemplates(AsyncCallback<ArrayList<TemplateData>> callback);
void getTemplatesForDSDExport(
AsyncCallback<ArrayList<TemplateData>> callback);
void getTemplateColumnsData(String templateId,
AsyncCallback<ArrayList<TemplateColumnData>> callback);
void startTemplateApply(TemplateApplySession templateDeleteSession,
AsyncCallback<String> callback);
@ -442,7 +455,6 @@ public interface TDGWTServiceAsync {
void startMapCreation(MapCreationSession mapCreationSession,
AsyncCallback<String> callback);
// DataMiner
void startDataMinerOperation(
DataMinerOperationSession dataMinerOperationSession,

View File

@ -33,7 +33,8 @@ public class SessionConstants {
public static final String SDMX_IMPORT_TABULAR_RESOURCE = "SDMX_IMPORT_TABULAR_RESOURCE";
public static final String SDMX_EXPORT_SESSION = "SDMX_EXPORT_SESSION";
public static final String SDMX_TEMPLATE_EXPORT_SESSION = "SDMX_TEMPLATE_EXPORT_SESSION";
public static final String CSV_IMPORT_SESSION = "CSV_IMPORT";
public static final String CSV_IMPORT_FILE_UPLOAD_SESSION = "CSV_IMPORT_FILE_UPLOAD";
public static final String CSV_IMPORT_TABULAR_RESOURCE = "CSV_IMPORT_TABULAR_RESOURCE";

View File

@ -41,6 +41,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.rule.DetachColumnRulesSessio
import org.gcube.portlets.user.td.gwtservice.shared.rule.DetachTableRulesSession;
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.sdmx.SDMXTemplateExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
import org.gcube.portlets.user.td.gwtservice.shared.statistical.DataMinerOperationSession;
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitSession;
@ -125,19 +126,19 @@ public class SessionUtil {
logger.info("No credential found in session, use test user!");
InfoLocale infoLocale = getInfoLocale(httpServletRequest, null);
Locale locale = new Locale(infoLocale.getLanguage());
ResourceBundle messages = ResourceBundle.getBundle(
TDGWTServiceMessagesConstants.TDGWTServiceMessages, locale);
userName = Constants.DEFAULT_USER;
scope = Constants.DEFAULT_SCOPE;
token = Constants.DEFAULT_TOKEN;
logger.info("Set SecurityToken: "+token);
logger.info("Set SecurityToken: " + token);
SecurityTokenProvider.instance.set(token);
logger.info("Set ScopeProvider: "+scope);
logger.info("Set ScopeProvider: " + scope);
ScopeProvider.instance.set(scope);
sCredentials = new ServiceCredentials(userName, scope, token);
} else {
@ -157,7 +158,7 @@ public class SessionUtil {
} else {
scope = pContext.getCurrentScope(httpServletRequest);
}
if (scope == null || scope.isEmpty()) {
String error = "Error retrieving scope: " + scope;
logger.error(error);
@ -200,11 +201,11 @@ public class SessionUtil {
String email = gCubeUser.getEmail();
if (hasScopeGroupId) {
logger.info("Set SecurityToken: "+token);
logger.info("Set SecurityToken: " + token);
SecurityTokenProvider.instance.set(token);
logger.info("Set ScopeProvider: "+scope);
logger.info("Set ScopeProvider: " + scope);
ScopeProvider.instance.set(scope);
groupId = scopeGroupId;
long gId;
@ -379,7 +380,7 @@ public class SessionUtil {
SessionConstants.SCOPE_TO_CURRENT_TABULAR_RESOURCE_MAP,
tabResource);
}
//
/**
*
@ -605,7 +606,7 @@ public class SessionUtil {
// TODO check
// public static void retrieveResources(HttpServletRequest httpRequest,
// ServiceCredentials serviceCredentials) {
//
//
// return;
// }
@ -721,6 +722,27 @@ public class SessionUtil {
return sdmxExportSession;
}
//
public static void setSDMXTemplateExportSession(
HttpServletRequest httpRequest,
ServiceCredentials serviceCredentials,
SDMXTemplateExportSession sdmxTemplateExportSession) {
SessionOp<SDMXTemplateExportSession> sessionOp = new SessionOp<>();
sessionOp.set(httpRequest, serviceCredentials,
SessionConstants.SDMX_TEMPLATE_EXPORT_SESSION,
sdmxTemplateExportSession);
}
public static SDMXTemplateExportSession getSDMXTemplateExportSession(
HttpServletRequest httpRequest,
ServiceCredentials serviceCredentials) {
SessionOp<SDMXTemplateExportSession> sessionOp = new SessionOp<>();
SDMXTemplateExportSession sdmxTemplateExportSession = sessionOp.get(
httpRequest, serviceCredentials,
SessionConstants.SDMX_TEMPLATE_EXPORT_SESSION);
return sdmxTemplateExportSession;
}
//
public static void setJSONExportSession(HttpServletRequest httpRequest,
ServiceCredentials serviceCredentials,
@ -1677,10 +1699,10 @@ public class SessionUtil {
HttpServletRequest httpRequest,
ServiceCredentials serviceCredentials) throws TDGWTServiceException {
SessionOp<DataMinerOperationSession> sessionOp = new SessionOp<>();
DataMinerOperationSession dataMinerOperationSession = sessionOp
.get(httpRequest, serviceCredentials,
SessionConstants.DATAMINER_OPERATION_SESSION,
DataMinerOperationSession.class);
DataMinerOperationSession dataMinerOperationSession = sessionOp.get(
httpRequest, serviceCredentials,
SessionConstants.DATAMINER_OPERATION_SESSION,
DataMinerOperationSession.class);
return dataMinerOperationSession;
}
@ -1947,7 +1969,6 @@ public class SessionUtil {
public static void setAbortedTasks(HttpServletRequest httpRequest,
ServiceCredentials serviceCredentials, TaskWrapper taskWrapper) {
if (taskWrapper == null || taskWrapper.getTask() == null) {
logger.error("TaskWrapper is null");
return;
@ -1993,7 +2014,6 @@ public class SessionUtil {
HttpServletRequest httpRequest,
ServiceCredentials serviceCredentials) {
SessionOp<HashMap<String, TaskWrapper>> sessionOp = new SessionOp<>();
HashMap<String, TaskWrapper> tasksHidden = sessionOp.get(httpRequest,
serviceCredentials,
@ -2118,7 +2138,6 @@ public class SessionUtil {
public static void removeTaskInBackground(HttpServletRequest httpRequest,
ServiceCredentials serviceCredentials, TaskWrapper taskWrapper) {
if (taskWrapper == null) {
logger.error("TaskWrapper is null");
return;
@ -2180,7 +2199,6 @@ public class SessionUtil {
HttpServletRequest httpRequest,
ServiceCredentials serviceCredentials, TRId trId) {
if (trId == null) {
logger.error("TRId is null");
return;

View File

@ -33,6 +33,9 @@ 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.templates.model.TemplateCategory;
import org.gcube.data.analysis.tabulardata.commons.templates.model.columns.ColumnCategory;
import org.gcube.data.analysis.tabulardata.commons.templates.model.columns.TemplateColumn;
import org.gcube.data.analysis.tabulardata.commons.utils.Licence;
import org.gcube.data.analysis.tabulardata.commons.utils.SharingEntity;
import org.gcube.data.analysis.tabulardata.commons.webservice.exception.NoSuchTemplateException;
@ -141,6 +144,7 @@ import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Repl
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4SDMXCodelistExport;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4SDMXCodelistImport;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4SDMXDatasetExport;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4SDMXTemplateExport;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4SplitColumn;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4TimeAggregation;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Union;
@ -150,6 +154,7 @@ import org.gcube.portlets.user.td.gwtservice.server.resource.ResourceTypeMap;
import org.gcube.portlets.user.td.gwtservice.server.social.TDMNotifications;
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.ColumnTypeCodeMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.ExtractReferences;
import org.gcube.portlets.user.td.gwtservice.server.trservice.JobClassifierMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.LicenceMap;
@ -199,6 +204,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.rule.DetachColumnRulesSessio
import org.gcube.portlets.user.td.gwtservice.shared.rule.DetachTableRulesSession;
import org.gcube.portlets.user.td.gwtservice.shared.rule.description.RuleDescriptionData;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXTemplateExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.share.Contacts;
import org.gcube.portlets.user.td.gwtservice.shared.share.ShareRule;
@ -217,6 +223,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.task.TaskS;
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskWrapper;
import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsTasksMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ConditionCodeMap;
@ -5113,6 +5120,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
* @param exportSession
* @return
*/
@Override
public String startSDMXExport(SDMXExportSession exportSession)
throws TDGWTServiceException {
HttpServletRequest httpRequest = null;
@ -5214,6 +5222,85 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
*
* @param sdmxTemplateExportSession
* @return
*/
@Override
public String startSDMXTemplateExport(
SDMXTemplateExportSession sdmxTemplateExportSession)
throws TDGWTServiceException {
HttpServletRequest httpRequest = null;
try {
httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
logger.debug("Start SDMX Template Export");
if (sdmxTemplateExportSession == null) {
logger.error("Error in SDMX Template Export : templateExportSession is null!");
throw new TDGWTServiceException(
"Error in SDMX Template Export: templateExportSession is null!!");
}
SessionUtil.setSDMXTemplateExportSession(httpRequest,
serviceCredentials, sdmxTemplateExportSession);
TRId trId = SessionUtil.getTRId(httpRequest, serviceCredentials);
logger.debug("Tabular Data Service");
TabularDataService service = TabularDataServiceFactory.getService();
OpExecutionDirector director = new OpExecutionDirector();
// /
OpExecution4SDMXTemplateExport opExD = new OpExecution4SDMXTemplateExport(
service, sdmxTemplateExportSession);
director.setOperationExecutionBuilder(opExD);
director.constructOperationExecution();
OperationExecution invocation = director.getOperationExecution();
if (invocation == null) {
throw new TDGWTServiceException(
"Error in SDMX Template Export: Operation not supported for now!");
}
logger.debug("OperationInvocation: \n" + invocation.toString());
TabularResourceId tabularResourceId = new TabularResourceId(
Long.valueOf(trId.getId()));
Task trTask = service.execute(invocation, tabularResourceId);
logger.debug("Start Task on service: TaskId " + trTask.getId());
TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.SDMXTemplateExport, trId);
SessionUtil.setStartedTask(httpRequest, serviceCredentials,
taskWrapper);
return trTask.getId().getValue();
} catch (TDGWTServiceException e) {
throw e;
} catch (SecurityException e) {
logger.error(
"Error in SDMX Template Export: " + e.getLocalizedMessage(),
e);
ResourceBundle messages = getResourceBundle(httpRequest);
throw new TDGWTServiceException(
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
} catch (Throwable e) {
logger.error(
"Error in SDMX Template Export: " + e.getLocalizedMessage(),
e);
throw new TDGWTServiceException("Error in SDMX Template Export: "
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}
@ -6821,15 +6908,169 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException(
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
} catch (Throwable e) {
logger.debug("Error in GetTemplates: " + e.getLocalizedMessage());
logger.debug("Error in GetTemplates: " + e.getLocalizedMessage(), e);
throw new TDGWTServiceException("Error in GetTemplates: "
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}
*/
@Override
public ArrayList<TemplateData> getTemplatesForDSDExport()
throws TDGWTServiceException {
HttpServletRequest httpRequest = null;
try {
httpRequest = this.getThreadLocalRequest();
SessionUtil.getServiceCredentials(httpRequest);
logger.debug("GetTemplatesForDSDExport");
TabularDataService service = TabularDataServiceFactory.getService();
List<TemplateDescription> templateDescriptorList = service
.getTemplates();
ArrayList<TemplateData> templateDataList = new ArrayList<TemplateData>();
TemplateData templateData;
for (TemplateDescription desc : templateDescriptorList) {
if (desc.getTemplate().getCategory()
.compareTo(TemplateCategory.DATASET) == 0) {
List<TemplateColumn<?>> columns = desc.getTemplate()
.getColumns();
boolean hasMeasure = false;
for (TemplateColumn<?> col : columns) {
if (col.getColumnType() != null
&& col.getColumnType().compareTo(
ColumnCategory.MEASURE) == 0) {
hasMeasure = true;
break;
}
}
if (hasMeasure) {
templateData = new TemplateData();
templateData.setId(desc.getId());
templateData.setName(desc.getName());
templateData.setDescription(desc.getDescription());
templateData.setAgency(desc.getAgency());
switch (desc.getTemplate().getCategory()) {
case CODELIST:
templateData.setCategory("Codelist");
break;
case DATASET:
templateData.setCategory("Dataset");
break;
case GENERIC:
templateData.setCategory("Generic");
break;
default:
break;
}
Contacts owner = new Contacts("", desc.getOwner(),
false);
templateData.setOwner(owner);
templateData
.setContacts(retrieveTemplateShareInfo(desc));
if (desc.getCreationdDate() != null) {
templateData.setCreationDate(desc
.getCreationdDate().getTime());
} else {
templateData.setCreationDate(null);
}
templateDataList.add(templateData);
}
}
}
logger.debug("Retrieved TemplateData List");
return templateDataList;
} catch (TDGWTServiceException e) {
throw e;
} catch (SecurityException e) {
e.printStackTrace();
ResourceBundle messages = getResourceBundle(httpRequest);
throw new TDGWTServiceException(
"Error in GetOccurencesForBatchReplace: "
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
} catch (Throwable e) {
logger.debug(
"Error in GetTemplatesForDSDExport: "
+ e.getLocalizedMessage(), e);
throw new TDGWTServiceException(
"Error in GetTemplateForDSDExport: "
+ e.getLocalizedMessage());
}
}
@Override
public ArrayList<TemplateColumnData> getTemplateColumnsData(
String templateId) throws TDGWTServiceException {
HttpServletRequest httpRequest = null;
try {
httpRequest = this.getThreadLocalRequest();
SessionUtil.getServiceCredentials(httpRequest);
logger.debug("getTemplateColumnsData: TemplateId=" + templateId);
if (templateId == null || templateId.isEmpty()) {
logger.error("Error in GetTemplateColumnsData: invalid template id="
+ templateId);
throw new TDGWTServiceException(
"Error in GetTemplateColumnsData: invalid template id="
+ templateId);
}
TabularDataService service = TabularDataServiceFactory.getService();
TemplateDescription templateDescriptor = service
.getTemplate(new TemplateId(Long.valueOf(templateId)));
ArrayList<TemplateColumnData> templateColumnsDataList = new ArrayList<TemplateColumnData>();
List<TemplateColumn<?>> columns = templateDescriptor.getTemplate()
.getColumns();
int i = 1;
for (TemplateColumn<?> c : columns) {
TemplateColumnData templateColumnData = new TemplateColumnData(
Integer.toString(i),
c.getId(),
ColumnTypeCodeMap.getColumnType(c.getColumnType()),
ColumnDataTypeMap.mapFromDataTypeClass(c.getValueType()),
c.getLabel());
templateColumnsDataList.add(templateColumnData);
i++;
}
logger.debug("Retrieved TemplateColumnData List");
return templateColumnsDataList;
} catch (TDGWTServiceException e) {
throw e;
} catch (SecurityException e) {
logger.error("Security Exception: " + e.getLocalizedMessage(), e);
ResourceBundle messages = getResourceBundle(httpRequest);
throw new TDGWTServiceException(
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
} catch (Throwable e) {
logger.debug(
"Error in GetTemplateColumnsData: "
+ e.getLocalizedMessage(), e);
throw new TDGWTServiceException("Error in GetTemplateColumnsData: "
+ e.getLocalizedMessage());
}
}
private ArrayList<Contacts> retrieveTemplateShareInfo(
TemplateDescription templateDescription)
throws TDGWTServiceException {
@ -9020,9 +9261,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
@Override
public String startDataMinerOperation(
DataMinerOperationSession dataMinerOperationSession)
@ -9087,7 +9325,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
*

View File

@ -0,0 +1,134 @@
package org.gcube.portlets.user.td.gwtservice.server.opexecution;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.Profile;
import org.gcube.common.resources.gcore.utils.Group;
import org.gcube.data.analysis.tabulardata.commons.templates.model.Template;
import org.gcube.data.analysis.tabulardata.commons.webservice.exception.NoSuchTemplateException;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.TemplateDescription;
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.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.template.TemplateId;
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXTemplateExportSession;
import org.gcube.portlets.user.td.widgetcommonevent.shared.operations.OperationsId;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Operation Execution for sdmx Template export
*
* @author "Giancarlo Panichi" email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class OpExecution4SDMXTemplateExport extends OpExecutionBuilder {
private static Logger logger = LoggerFactory
.getLogger(OpExecution4SDMXTemplateExport.class);
private TabularDataService service;
private SDMXTemplateExportSession sdmxTemplateExportSession;
public OpExecution4SDMXTemplateExport(TabularDataService service,
SDMXTemplateExportSession sdmxTemplateExportSession) {
this.service = service;
this.sdmxTemplateExportSession = sdmxTemplateExportSession;
}
@Override
public void buildOpEx() throws TDGWTServiceException {
logger.debug(sdmxTemplateExportSession.toString());
boolean internalRegistry = false;
String destination = null;// Es:
// http://pc-fortunati.isti.cnr.it:8080/FusionRegistry/ws/rest/
if (sdmxTemplateExportSession != null) {
if (sdmxTemplateExportSession.getRegistryBaseUrl() != null
&& !sdmxTemplateExportSession.getRegistryBaseUrl()
.isEmpty()) {
destination = sdmxTemplateExportSession.getRegistryBaseUrl();
} else {
internalRegistry = true;
}
} else {
internalRegistry = true;
}
if (internalRegistry) {
SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Category/text() eq 'SDMX'")
.addCondition(
"$resource/Profile/Name/text() eq 'SDMXRegistry'");
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
List<ServiceEndpoint> listService = client.submit(query);
if (listService.size() > 0) {
ServiceEndpoint serviceEnd = listService.get(0);
if (serviceEnd != null) {
Profile prof = serviceEnd.profile();
Group<AccessPoint> groupA = prof.accessPoints();
for (AccessPoint acc : groupA) {
if (acc.description().compareTo("REST Interface v2.1") == 0) {
destination = acc.address();
break;
}
}
} else {
}
} else {
}
}
if (destination == null) {
logger.debug("Destination: " + destination);
throw new TDGWTServiceException("SDMX Service not discovered");
}
TemplateDescription templateDescriptor;
try {
templateDescriptor = service.getTemplate(new TemplateId(
sdmxTemplateExportSession.getTemplateData().getId()));
} catch (NoSuchTemplateException e) {
logger.debug(
"Error retrieving template: " + e.getLocalizedMessage(), e);
throw new TDGWTServiceException("Error retrieving template: "
+ e.getLocalizedMessage());
}
OperationDefinition operationDefinition = OperationDefinitionMap.map(
OperationsId.SDMXTemplateExport.toString(), service);
HashMap<String,Template> templateMap=new HashMap<String,Template>();
templateMap.put(Constants.PARAMETER_TEMPLATE,templateDescriptor.getTemplate());
Map<String, Object> map = new HashMap<String, Object>();
map.put(Constants.PARAMETER_REGISTRYBASEURL, destination);
map.put(Constants.PARAMETER_AGENCY,
sdmxTemplateExportSession.getAgencyId());
map.put(Constants.PARAMETER_ID, sdmxTemplateExportSession.getId());
map.put(Constants.PARAMETER_VERSION,
sdmxTemplateExportSession.getVersion());
map.put(Constants.PARAMETER_OBSVALUECOLUMN, sdmxTemplateExportSession
.getObsValueColumn().getColumnId());
map.put(Constants.PARAMETER_TEMPLATE, templateMap);
OperationExecution invocation = new OperationExecution(
operationDefinition.getOperationId(), map);
operationExecutionSpec.setOp(invocation);
}
}

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.td.gwtservice.server.trservice;
import org.gcube.data.analysis.tabulardata.commons.templates.model.columns.ColumnCategory;
import org.gcube.data.analysis.tabulardata.model.column.ColumnType;
import org.gcube.data.analysis.tabulardata.model.column.type.AnnotationColumnType;
import org.gcube.data.analysis.tabulardata.model.column.type.AttributeColumnType;
@ -43,4 +44,30 @@ public class ColumnTypeCodeMap {
}
}
public static ColumnTypeCode getColumnType(ColumnCategory columnType){
switch(columnType){
case ANNOTATION:
return ColumnTypeCode.ANNOTATION;
case ATTRIBUTE:
return ColumnTypeCode.ATTRIBUTE;
case CODE:
return ColumnTypeCode.CODE;
case CODEDESCRIPTION:
return ColumnTypeCode.CODEDESCRIPTION;
case CODENAME:
return ColumnTypeCode.CODENAME;
case DIMENSION:
return ColumnTypeCode.DIMENSION;
case MEASURE:
return ColumnTypeCode.MEASURE;
case TIMEDIMENSION:
return ColumnTypeCode.TIMEDIMENSION;
default:
return null;
}
}
}

View File

@ -12,32 +12,35 @@ package org.gcube.portlets.user.td.gwtservice.shared;
public class Constants {
public static final boolean DEBUG_MODE = false;
public static final boolean TEST_ENABLE = false;
public static final String CURR_GROUP_ID = "CURR_GROUP_ID";
//public static final String CURR_USER_ID = "CURR_USER_ID";
public static final String CURR_GROUP_ID = "CURR_GROUP_ID";
// public static final String CURR_USER_ID = "CURR_USER_ID";
public static final String DEFAULT_USER = "giancarlo.panichi";
public static final String DEFAULT_SCOPE = "/gcube/devNext/NextNext";
public static final String DEFAULT_TOKEN = "ae1208f0-210d-47c9-9b24-d3f2dfcce05f-98187548";
//public static final String DEFAULT_SCOPE = "/gcube/devNext";
//public static final String DEFAULT_TOKEN = "16e65d4f-11e0-4e4a-84b9-351688fccc12-98187548";
// public static final String DEFAULT_SCOPE = "/gcube/devNext";
// public static final String DEFAULT_TOKEN =
// "16e65d4f-11e0-4e4a-84b9-351688fccc12-98187548";
public static final String DEFAULT_ROLE = "OrganizationMember";
public final static String FILE_XML_MIMETYPE = "application/xml";
public final static String FILE_CSV_MIMETYPE = "text/csv";
public static final String SDMX_CODELIST_EXPORT_DEFAULT_ID = "NEW_CL_DIVISION";
public static final String SDMX_CODELIST_EXPORT_DEFAULT_AGENCY_ID = "SDMX";
public static final String SDMX_CODELIST_EXPORT_DEFAULT_VERSION = "1.0";
public static final String SDMX_DATASET_EXPORT_DEFAULT_ID = "NEW_DS_DIVISION";
public static final String SDMX_DATASET_EXPORT_DEFAULT_AGENCY_ID = "SDMX";
public static final String SDMX_DATASET_EXPORT_DEFAULT_VERSION = "1.0";
public static final String SDMX_TEMPLATE_EXPORT_DEFAULT_ID = "NEW_DSD_DIVISION_TEMPLATE";
public static final String SDMX_TEMPLATE_EXPORT_DEFAULT_AGENCY_ID = "SDMX";
public static final String SDMX_TEMPLATE_EXPORT_DEFAULT_VERSION = "1.0";
public static final String PARAMETER_ENCODING = "encoding";
public static final String PARAMETER_HASHEADER = "hasHeader";
public static final String PARAMETER_FIELDMASK = "fieldMask";
@ -52,6 +55,7 @@ public class Constants {
public static final String PARAMETER_AGENCY = "agency";
public static final String PARAMETER_VERSION = "version";
public static final String PARAMETER_OBSVALUECOLUMN = "obsValueColumn";
public static final String PARAMETER_TEMPLATE = "template";
public static final String PARAMETER_DATA_TYPE = "dataType";
public static final String PARAMETER_TARGET_DATA_TYPE = "targetDataType";
@ -72,7 +76,7 @@ public class Constants {
public static final String PARAMETER_STATISTICAL_OPERATION_PARAMETERS = "smEntries";
public static final String PARAMETER_STATISTICAL_OPERATION_DESCRIPTION = "description";
public static final String PARAMETER_STATISTICAL_OPERATION_TITLE = "title";
public static final String PARAMETER_DATAMINER_GCUBETOKEN = "gcubetoken";
public static final String PARAMETER_DATAMINER_OPERATOR = "operator";
@ -149,11 +153,10 @@ public class Constants {
public static final String PARAMETER_EXPRESSION_VALIDATION_TITLE = "title";
public static final String PARAMETER_CHANGE_COLUMN_POSITION_ORDER = "order";
public static final String PARAMETER_RESOURCE_NAME = "name";
public static final String PARAMETER_RESOURCE_DESCRIPTION = "description";
public static final String CODELIST_MAPPING_UPLOAD_SERVLET = "CodelistMappingUploadServlet";
public static final String LOCAL_UPLOAD_SERVLET = "LocalUploadServlet";
public static final String CSV_IMPORT_FILE_SERVLET = "CSVImportFileServlet";
@ -161,6 +164,5 @@ public class Constants {
public static final String RETRIEVE_FILE_AND_DISCOVER_MIME_TYPE_SERVLET = "RetrieveFileAndDiscoverMimeTypeServlet";
public static final String TD_RSTUDIO_SERVLET = "TDRStudioServlet";
public static final String TD_LOGS_SERVLET = "TDLogsServlet";
}

View File

@ -0,0 +1,126 @@
/**
*
*/
package org.gcube.portlets.user.td.gwtservice.shared.sdmx;
import java.io.Serializable;
import org.gcube.portlets.user.td.gwtservice.shared.source.Source;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class SDMXTemplateExportSession implements Serializable {
private static final long serialVersionUID = 4176034045408445284L;
private TemplateData templateData;
private Agencies agency;
private Source source;
private String id;
private String agencyId;
private String version;
private String registryBaseUrl;
private TemplateColumnData obsValueColumn;
public SDMXTemplateExportSession() {
super();
}
public SDMXTemplateExportSession(TemplateData templateData,
Agencies agency, Source source, String id, String agencyId,
String version, String registryBaseUrl,
TemplateColumnData obsValueColumn) {
super();
this.templateData = templateData;
this.agency = agency;
this.source = source;
this.id = id;
this.agencyId = agencyId;
this.version = version;
this.registryBaseUrl = registryBaseUrl;
this.obsValueColumn = obsValueColumn;
}
public TemplateData getTemplateData() {
return templateData;
}
public void setTemplateData(TemplateData templateData) {
this.templateData = templateData;
}
public Agencies getAgency() {
return agency;
}
public void setAgency(Agencies agency) {
this.agency = agency;
}
public Source getSource() {
return source;
}
public void setSource(Source source) {
this.source = source;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAgencyId() {
return agencyId;
}
public void setAgencyId(String agencyId) {
this.agencyId = agencyId;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getRegistryBaseUrl() {
return registryBaseUrl;
}
public void setRegistryBaseUrl(String registryBaseUrl) {
this.registryBaseUrl = registryBaseUrl;
}
public TemplateColumnData getObsValueColumn() {
return obsValueColumn;
}
public void setObsValueColumn(TemplateColumnData obsValueColumn) {
this.obsValueColumn = obsValueColumn;
}
@Override
public String toString() {
return "SDMXTemplateExportSession [templateData=" + templateData
+ ", agency=" + agency + ", source=" + source + ", id=" + id
+ ", agencyId=" + agencyId + ", version=" + version
+ ", registryBaseUrl=" + registryBaseUrl + ", obsValueColumn="
+ obsValueColumn + "]";
}
}

View File

@ -4,20 +4,30 @@ import java.io.Serializable;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
* Apply Template Session
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class TemplateApplySession implements Serializable {
private static final long serialVersionUID = -8834066207159106968L;
protected TemplateData templateData;
protected TRId trId;
private TemplateData templateData;
private TRId trId;
public TemplateApplySession() {
super();
}
public TemplateApplySession(TemplateData templateData, TRId trId) {
super();
this.templateData = templateData;
this.trId = trId;
}
public TRId getTrId() {
return trId;
}
@ -40,5 +50,4 @@ public class TemplateApplySession implements Serializable {
+ trId + "]";
}
}

View File

@ -0,0 +1,86 @@
package org.gcube.portlets.user.td.gwtservice.shared.template;
import java.io.Serializable;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
/**
*
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class TemplateColumnData implements Serializable {
private static final long serialVersionUID = -4747143287880727022L;
private String id; // For insert in table only
private String columnId; // Id of column on server
private ColumnTypeCode typeCode;
private ColumnDataType dataTypeName;
private String label;
public TemplateColumnData() {
super();
}
public TemplateColumnData(String id, String columnId,
ColumnTypeCode typeCode, ColumnDataType dataTypeName, String label) {
super();
this.id = id;
this.columnId = columnId;
this.typeCode = typeCode;
this.dataTypeName = dataTypeName;
this.label = label;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getColumnId() {
return columnId;
}
public void setColumnId(String columnId) {
this.columnId = columnId;
}
public ColumnTypeCode getTypeCode() {
return typeCode;
}
public void setTypeCode(ColumnTypeCode typeCode) {
this.typeCode = typeCode;
}
public ColumnDataType getDataTypeName() {
return dataTypeName;
}
public void setDataTypeName(ColumnDataType dataTypeName) {
this.dataTypeName = dataTypeName;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
@Override
public String toString() {
return "TemplateColumnData [id=" + id + ", columnId=" + columnId
+ ", typeCode=" + typeCode + ", dataTypeName=" + dataTypeName
+ ", label=" + label + "]";
}
}

View File

@ -16,24 +16,32 @@ import org.slf4j.LoggerFactory;
*
*/
public class TestServiceOperations {
private static Logger logger = LoggerFactory.getLogger(TestServiceOperations.class);
private static Logger logger = LoggerFactory
.getLogger(TestServiceOperations.class);
@Test
public void TestTROperation() {
TDService tdService=new TDService();
TabularDataService service = tdService.getService();
List<OperationDefinition> trOperations = service.getCapabilities();
Assert.assertTrue("No operations exists", trOperations.size() > 0);
logger.debug("------------Tabular Resource Operation--------------");
for (OperationDefinition operation : trOperations) {
logger.debug("Name: " + operation.getName());
// logger.debug("Scope: "+operation.getScope());
logger.debug("Desc: " + operation.toString());
try {
logger.debug("-----------------------------------");
TDService tdService = new TDService();
TabularDataService service = tdService.getService();
List<OperationDefinition> trOperations = service.getCapabilities();
Assert.assertTrue("No operations exists", trOperations.size() > 0);
logger.debug("------------Tabular Resource Operation--------------");
for (OperationDefinition operation : trOperations) {
logger.debug("Name: " + operation.getName());
// logger.debug("Scope: "+operation.getScope());
logger.debug("Desc: " + operation.toString());
logger.debug("-----------------------------------");
}
} catch (Throwable e) {
logger.error(
"Error retrieving operations: " + e.getLocalizedMessage(),
e);
}
}