Cleaned and restored the project
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-sdmx-export-widget@84561 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5bf9132f3d
commit
75bee4cedf
|
@ -1,30 +0,0 @@
|
|||
package org.gcube.portlets.user.sdmxexportwizardtd.client.dataresource;
|
||||
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.resources.client.ClientBundle;
|
||||
import com.google.gwt.resources.client.ImageResource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface ResourceBundle extends ClientBundle {
|
||||
|
||||
public static final ResourceBundle IMPL=GWT.create(ResourceBundle.class);
|
||||
|
||||
@Source("resources/SDMXExportWizardTD.css")
|
||||
SDMXExportCSS sdmxExportCss();
|
||||
|
||||
@Source("resources/arrow-refresh.png")
|
||||
ImageResource refresh();
|
||||
|
||||
@Source("resources/arrow-refresh_16.png")
|
||||
ImageResource refresh_16();
|
||||
|
||||
@Source("resources/arrow-refresh_32.png")
|
||||
ImageResource refresh32();
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.sdmxexportwizardtd.client.dataresource;
|
||||
|
||||
import com.google.gwt.resources.client.CssResource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface SDMXExportCSS extends CssResource {
|
||||
|
||||
@ClassName("wizard-title")
|
||||
public String getWizardTitle();
|
||||
|
||||
@ClassName("wizard-footer")
|
||||
public String getWizardFooter();
|
||||
|
||||
@ClassName("source-selection-hover")
|
||||
public String getSourceSelectionHover();
|
||||
|
||||
// @ClassName("column-excluded")
|
||||
// public String getColumnExcluded();
|
||||
|
||||
@ClassName("exportSelection-sources")
|
||||
public String getExportSelectionSources();
|
||||
|
||||
@ClassName("exportSelection-source")
|
||||
public String getExportSelectionSource();
|
||||
|
||||
@ClassName("sdmxRegistryUrlStyle")
|
||||
public String getSDMXRegistryUrlStyle();
|
||||
|
||||
@ClassName("sdmxRegistryUrlInputStyle")
|
||||
public String getSDMXRegistryUrlInputStyle();
|
||||
|
||||
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.sdmxexportwizardtd.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.datapublishing.sdmx.api.model.SDMXRegistryDescriptor;
|
||||
import org.gcube.datapublishing.sdmx.api.model.SDMXRegistryInterfaceType;
|
||||
import org.gcube.datapublishing.sdmx.api.registry.SDMXRegistryClient;
|
||||
import org.gcube.datapublishing.sdmx.api.registry.SDMXRegistryClient.Detail;
|
||||
import org.gcube.datapublishing.sdmx.api.registry.SDMXRegistryClient.References;
|
||||
import org.gcube.datapublishing.sdmx.impl.model.GCubeSDMXRegistryDescriptor;
|
||||
import org.gcube.datapublishing.sdmx.impl.model.SDMXRegistryDescriptorImpl;
|
||||
import org.gcube.datapublishing.sdmx.impl.registry.FusionRegistryClient;
|
||||
import org.gcube.portlets.user.sdmxexportwizardtd.shared.Agencies;
|
||||
import org.gcube.portlets.user.sdmxexportwizardtd.shared.Codelist;
|
||||
import org.gcube.portlets.user.sdmxexportwizardtd.shared.Dataset;
|
||||
import org.sdmxsource.sdmx.api.model.beans.SdmxBeans;
|
||||
import org.sdmxsource.sdmx.api.model.beans.base.AgencyBean;
|
||||
import org.sdmxsource.sdmx.api.model.beans.codelist.CodelistBean;
|
||||
import org.sdmxsource.sdmx.api.model.beans.datastructure.DataflowBean;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SDMXClient {
|
||||
|
||||
public static enum TYPE {
|
||||
INTERNAL, ANOTHER
|
||||
}
|
||||
|
||||
protected static Logger logger = LoggerFactory.getLogger(SDMXClient.class);
|
||||
|
||||
protected SDMXRegistryClient client;
|
||||
protected TYPE type;
|
||||
protected String url;
|
||||
|
||||
public SDMXClient() {
|
||||
type = TYPE.INTERNAL;
|
||||
url = null;
|
||||
SDMXRegistryDescriptor descriptor = new GCubeSDMXRegistryDescriptor();
|
||||
client = new FusionRegistryClient(descriptor);
|
||||
|
||||
}
|
||||
|
||||
public SDMXClient(String url) {
|
||||
type = TYPE.ANOTHER;
|
||||
this.url = url;
|
||||
SDMXRegistryDescriptorImpl descriptor = new SDMXRegistryDescriptorImpl();
|
||||
descriptor.setUrl(SDMXRegistryInterfaceType.RESTV2_1, url);
|
||||
client = new FusionRegistryClient(descriptor);
|
||||
}
|
||||
|
||||
public List<Codelist> getAllCodelists() throws Exception {
|
||||
SdmxBeans beans = client.getCodelist("all", "all", "all",
|
||||
Detail.allstubs, References.none);
|
||||
List<Codelist> codelists = new ArrayList<Codelist>();
|
||||
for (CodelistBean codelist : beans.getCodelists())
|
||||
codelists.add(new Codelist(codelist.getId(), codelist.getName(),
|
||||
codelist.getAgencyId(), codelist.getVersion(), codelist
|
||||
.getDescription()));
|
||||
logger.debug("codelists: " + codelists);
|
||||
return codelists;
|
||||
}
|
||||
|
||||
public List<Dataset> getAllDatasets() throws Exception {
|
||||
SdmxBeans beans = client.getProvisionAgreement("all", "all", "latest",
|
||||
Detail.full, References.children);
|
||||
List<Dataset> datasets = new ArrayList<Dataset>();
|
||||
for (DataflowBean dataflowBean : beans.getDataflows()) {
|
||||
datasets.add(new Dataset(dataflowBean.getId(), dataflowBean
|
||||
.getName(), dataflowBean.getAgencyId(), dataflowBean
|
||||
.getVersion(), dataflowBean.getDescription()));
|
||||
}
|
||||
logger.debug("datasets: " + datasets);
|
||||
return datasets;
|
||||
}
|
||||
|
||||
public List<Agencies> getAllAgencies() throws Exception {
|
||||
List<Agencies> agenciesList = new ArrayList<Agencies>();
|
||||
if (client == null) {
|
||||
logger.error("getAllAgencies() Error: client is null");
|
||||
} else {
|
||||
SdmxBeans beans = client.getAgencyScheme("SDMX", "AGENCIES", "1.0",
|
||||
Detail.full, References.none);
|
||||
if (beans == null) {
|
||||
logger.error("getAllAgencies() Error: SdmxBeans is null");
|
||||
} else {
|
||||
for (AgencyBean agency : beans.getAgencies())
|
||||
agenciesList.add(new Agencies(agency.getId(), agency
|
||||
.getName(), agency.getDescription()));
|
||||
|
||||
}
|
||||
}
|
||||
logger.debug("agencies: " + agenciesList);
|
||||
return agenciesList;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,279 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.sdmxexportwizardtd.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.data.analysis.tabulardata.operation.worker.ActivityStatus;
|
||||
import org.gcube.data.analysis.tabulardata.operation.worker.EligibleOperation;
|
||||
import org.gcube.data.analysis.tabulardata.operation.worker.JobResult;
|
||||
import org.gcube.data.analysis.tabulardata.operation.worker.OperationInvocation;
|
||||
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
|
||||
import org.gcube.data.analysis.tabulardata.service.TabularDataServiceMock;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.OperationInterface;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.Task;
|
||||
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.TabularResourceMetadata;
|
||||
import org.gcube.portlets.user.sdmxexportwizardtd.client.rpc.SDMXExportWizardService;
|
||||
import org.gcube.portlets.user.sdmxexportwizardtd.shared.Agencies;
|
||||
import org.gcube.portlets.user.sdmxexportwizardtd.shared.Codelist;
|
||||
import org.gcube.portlets.user.sdmxexportwizardtd.shared.Dataset;
|
||||
import org.gcube.portlets.user.sdmxexportwizardtd.shared.ExportMonitor;
|
||||
import org.gcube.portlets.user.sdmxexportwizardtd.shared.SDMXExportSession;
|
||||
import org.gcube.portlets.user.sdmxexportwizardtd.shared.SDMXExportWizardException;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TRId;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
|
||||
//import org.gcube.portlets.user.sdmximportwizardtd.server.cl.ReadOnlyGroupMock;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SDMXExportWizardServiceImpl extends RemoteServiceServlet implements
|
||||
SDMXExportWizardService {
|
||||
|
||||
private static final long serialVersionUID = -5707400086333186368L;
|
||||
|
||||
protected static Logger logger = LoggerFactory.getLogger(SDMXExportWizardServiceImpl.class);
|
||||
|
||||
protected TabularDataService service;
|
||||
protected org.gcube.data.analysis.tabulardata.model.table.TableId serviceTableId;
|
||||
protected org.gcube.data.analysis.tabulardata.model.table.Table serviceTable;
|
||||
|
||||
public void setSDMXSession(SDMXExportSession s)
|
||||
throws SDMXExportWizardException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setSDMXExportSession(session, s);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new SDMXExportWizardException(
|
||||
"Error setting SDMXSession parameter: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* jar {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Codelist> getCodelists() throws SDMXExportWizardException {
|
||||
try {
|
||||
logger.info("getCodelists()");
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
return SessionUtil.retrieveCodelists(session);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new SDMXExportWizardException("Error retrieving codelists: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Dataset> getDatasets() throws SDMXExportWizardException {
|
||||
try {
|
||||
logger.info("getDatasets()");
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
return SessionUtil.retrieveDatasets(session);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new SDMXExportWizardException("Error retrieving datasets: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Agencies> getAgencies() throws SDMXExportWizardException {
|
||||
try {
|
||||
logger.info("getAgencies()");
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
return SessionUtil.retrieveAgencies(session);
|
||||
} catch (Exception e) {
|
||||
throw new SDMXExportWizardException("Error retrieving agencies: "
|
||||
+ e.getMessage());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected EligibleOperation getEligibleOperationWithId(String id,
|
||||
List<EligibleOperation> capabilities) {
|
||||
for (EligibleOperation eligibleOperation : capabilities) {
|
||||
if (eligibleOperation.getOperationDescriptor().getOperationId()
|
||||
.getValue() == Long.parseLong(id)) {
|
||||
return eligibleOperation;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Map<String, Object> setAgenciesParameters(
|
||||
SDMXExportSession sdmxExportSession) {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Agencies agency = sdmxExportSession.getAgency();
|
||||
|
||||
map.put("id", agency.getId());
|
||||
map.put("name", agency.getName());
|
||||
map.put("description",agency.getDescription());
|
||||
|
||||
return map;
|
||||
|
||||
}
|
||||
|
||||
protected void setTabularResourceParameters(TabularResource tr,
|
||||
SDMXExportSession sdmxImportSession) {
|
||||
TabularResourceMetadata name = new NameMetadata(sdmxImportSession
|
||||
.getTableDetail().getName());
|
||||
TabularResourceMetadata createdAt = new CreationDateMetadata(new Date());
|
||||
TabularResourceMetadata agencyMeta = new AgencyMetadata(
|
||||
sdmxImportSession.getTableDetail().getAgency());
|
||||
TabularResourceMetadata description = new DescriptionMetadata(
|
||||
sdmxImportSession.getTableDetail().getAgency());
|
||||
TabularResourceMetadata right = new DescriptionMetadata(
|
||||
sdmxImportSession.getTableDetail().getRight());
|
||||
|
||||
List<TabularResourceMetadata> metas = new ArrayList<TabularResourceMetadata>();
|
||||
metas.add(name);
|
||||
metas.add(createdAt);
|
||||
metas.add(agencyMeta);
|
||||
metas.add(description);
|
||||
metas.add(right);
|
||||
tr.setAllMetadata(metas);
|
||||
}
|
||||
|
||||
public void exportSDMXClientLibraryRequest(
|
||||
SDMXExportSession sdmxImportSession)
|
||||
throws SDMXExportWizardException {
|
||||
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setSDMXExportSession(session, sdmxImportSession);
|
||||
|
||||
service = new TabularDataServiceMock();
|
||||
OperationInterface oService = service;
|
||||
TabularResourceInterface trService = service;
|
||||
|
||||
List<EligibleOperation> capabilities = service.getCapabilities();
|
||||
|
||||
// Import SDMX Codelist takes id 200
|
||||
EligibleOperation exportSDMXCodelistOperation = getEligibleOperationWithId(
|
||||
"200", capabilities);
|
||||
|
||||
Map<String, Object> parameterInstances = setAgenciesParameters(sdmxImportSession);
|
||||
|
||||
OperationInvocation invocation = exportSDMXCodelistOperation
|
||||
.createOperationInvocation(parameterInstances);
|
||||
|
||||
TabularResource newTR = trService.createTabularResource();
|
||||
|
||||
/*setTabularResourceParameters(newTR, sdmxImportSession);
|
||||
|
||||
Task trTask = oService.execute(invocation, newTR.getId());
|
||||
*/
|
||||
TRId trId=new TRId();
|
||||
//trId.setId(String.valueOf(newTR.getId().getValue()));
|
||||
|
||||
SessionUtil.setTRId(session, trId);
|
||||
//SessionUtil.setTRTask(session, trTask);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new SDMXExportWizardException(
|
||||
"Error in Client Library Request: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public ExportMonitor getExportMonitor() throws SDMXExportWizardException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
Task task = SessionUtil.getTRTask(session);
|
||||
TRId trId = SessionUtil.getTRId(session);
|
||||
ExportMonitor exportMonitor = new ExportMonitor();
|
||||
if (trId == null) {
|
||||
throw new SDMXExportWizardException(
|
||||
"Error in exportSDMX TabularResource Id null ");
|
||||
} else {
|
||||
if (task == null) {
|
||||
throw new SDMXExportWizardException(
|
||||
"Error in exportSDMX Task null ");
|
||||
} else {
|
||||
ActivityStatus status = task.getStatus();
|
||||
if (status == null) {
|
||||
throw new SDMXExportWizardException(
|
||||
"Error in exportSDMX Status null");
|
||||
} else {
|
||||
exportMonitor.setStatus(task.getStatus().ordinal());
|
||||
exportMonitor.setProgress(task.getProgress());
|
||||
JobResult result = task.getResult();
|
||||
if (result == null) {
|
||||
logger.info("Task Result: "+task.getResult());
|
||||
} else {
|
||||
exportMonitor.setError(task.getResult()
|
||||
.getException());
|
||||
if (task.getResult().getOutput() == null){
|
||||
logger.info("Task Result Output: "+task.getResult()
|
||||
.getOutput());
|
||||
} else {
|
||||
if(task.getResult().getOutput().getId() == null) {
|
||||
logger.info("Task Result Output Id: "+task.getResult()
|
||||
.getOutput().getId());
|
||||
} else {
|
||||
logger.info("Task TableId: "+task.getResult()
|
||||
.getOutput().getId().getValue());
|
||||
trId.setTableId(String.valueOf(task.getResult()
|
||||
.getOutput().getId().getValue()));
|
||||
SessionUtil.setTRId(session, trId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
SessionUtil.setTRTask(session, task);
|
||||
}
|
||||
|
||||
exportMonitor.setTrId(trId);
|
||||
}
|
||||
logger.info("getImportMonitor(): "+exportMonitor);
|
||||
return exportMonitor;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new SDMXExportWizardException(
|
||||
"Error in exportSDMX ExportMonitor: "
|
||||
+ e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,166 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.sdmxexportwizardtd.server;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.application.framework.core.session.SessionManager;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.Task;
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
import org.gcube.portlets.user.sdmxexportwizardtd.shared.Agencies;
|
||||
import org.gcube.portlets.user.sdmxexportwizardtd.shared.Codelist;
|
||||
import org.gcube.portlets.user.sdmxexportwizardtd.shared.Constants;
|
||||
import org.gcube.portlets.user.sdmxexportwizardtd.shared.Dataset;
|
||||
import org.gcube.portlets.user.sdmxexportwizardtd.shared.SDMXExportSession;
|
||||
import org.gcube.portlets.user.td.gxtservice.shared.TRId;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SessionUtil {
|
||||
|
||||
protected static final String SDMX_CLIENT_ATTRIBUTE = "SDMX_CLIENT";
|
||||
protected static final String SDMX_EXPORT_SESSION = "SDMX_EXPORT";
|
||||
protected static final String SDMX_TR_TASK = "SDMX_TR_TASK";
|
||||
protected static final String SDMX_TR_ID = "SDMX_TR_ID";
|
||||
|
||||
|
||||
protected static Logger logger = LoggerFactory.getLogger(SessionUtil.class);
|
||||
|
||||
public static void setSDMXExportSession(HttpSession httpSession, SDMXExportSession s){
|
||||
|
||||
SDMXExportSession session=(SDMXExportSession)httpSession.getAttribute(SDMX_EXPORT_SESSION);
|
||||
if(session!=null) httpSession.removeAttribute(SDMX_EXPORT_SESSION);
|
||||
httpSession.setAttribute(SDMX_EXPORT_SESSION, s);
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
}
|
||||
|
||||
public static SDMXExportSession getSDMXExportSession(HttpSession httpSession){
|
||||
SDMXExportSession sdmxExportSession = (SDMXExportSession) httpSession.getAttribute(SDMX_EXPORT_SESSION);
|
||||
if(sdmxExportSession==null){
|
||||
logger.error("SDMXImportSession was not acquired");
|
||||
}
|
||||
return sdmxExportSession;
|
||||
}
|
||||
|
||||
|
||||
public static List<Codelist> retrieveCodelists(HttpSession httpSession)
|
||||
throws Exception {
|
||||
logger.info("SessionUtil retriveCodelists");
|
||||
SDMXClient client = getSdmxClient(httpSession);
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
return client.getAllCodelists();
|
||||
}
|
||||
|
||||
public static List<Dataset> retrieveDatasets(HttpSession httpSession)
|
||||
throws Exception {
|
||||
logger.info("SessionUtil retriveDatasets");
|
||||
SDMXClient client = getSdmxClient(httpSession);
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
return client.getAllDatasets();
|
||||
}
|
||||
|
||||
public static List<Agencies> retrieveAgencies(HttpSession httpSession)
|
||||
throws Exception {
|
||||
logger.info("SessionUtil retriveAgencies");
|
||||
SDMXClient client = getSdmxClient(httpSession);
|
||||
if(client==null){
|
||||
logger.error("SessionUtil retriveAgencies client null");
|
||||
throw new Exception("SessionUtil retriveAgencies client null");
|
||||
|
||||
} else {
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
return client.getAllAgencies();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static SDMXClient getSdmxClient(HttpSession httpSession){
|
||||
SDMXClient sdmxClient = (SDMXClient) httpSession.getAttribute(SDMX_CLIENT_ATTRIBUTE);
|
||||
SDMXExportSession sdmxExportSession=(SDMXExportSession) httpSession.getAttribute(SDMX_EXPORT_SESSION);
|
||||
if(sdmxExportSession==null){
|
||||
logger.error("SDMXExportSession was not acquired");
|
||||
} else {
|
||||
if (sdmxClient == null) {
|
||||
sdmxClient = new SDMXClient();
|
||||
} else {
|
||||
if(sdmxClient.type.compareTo(SDMXClient.TYPE.ANOTHER)==0){
|
||||
sdmxClient = new SDMXClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sdmxClient;
|
||||
}
|
||||
|
||||
protected static ASLSession getAslSession(HttpSession httpSession) {
|
||||
String username = (String) httpSession
|
||||
.getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
|
||||
|
||||
if (username == null) {
|
||||
logger.warn("no user found in session, using test one");
|
||||
username = Constants.DEFAULT_USER;
|
||||
String scope = Constants.DEFAULT_SCOPE;
|
||||
|
||||
httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, username);
|
||||
ASLSession session = SessionManager.getInstance().getASLSession(
|
||||
httpSession.getId(), username);
|
||||
session.setScope(scope);
|
||||
|
||||
return session;
|
||||
} else {
|
||||
return SessionManager.getInstance().getASLSession(
|
||||
httpSession.getId(), username);
|
||||
}
|
||||
}
|
||||
|
||||
public static Task getTRTask(HttpSession httpSession){
|
||||
Task task = (Task) httpSession.getAttribute(SDMX_TR_TASK);
|
||||
if(task==null){
|
||||
logger.error("SDMX_TR_TASK was not acquired");
|
||||
}
|
||||
return task;
|
||||
}
|
||||
|
||||
public static void setTRTask(HttpSession httpSession, Task task){
|
||||
Task t = (Task) httpSession.getAttribute(SDMX_TR_TASK);
|
||||
if(t!=null) httpSession.removeAttribute(SDMX_TR_TASK);
|
||||
httpSession.setAttribute(SDMX_TR_TASK, task);
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
}
|
||||
|
||||
public static TRId getTRId(HttpSession httpSession){
|
||||
TRId id = (TRId) httpSession.getAttribute(SDMX_TR_ID);
|
||||
if(id==null){
|
||||
logger.error("SDMX_TR_ID was not acquired");
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public static void setTRId(HttpSession httpSession, TRId trId){
|
||||
TRId id = (TRId) httpSession.getAttribute(SDMX_TR_ID);
|
||||
if(id!=null) httpSession.removeAttribute(SDMX_TR_ID);
|
||||
httpSession.setAttribute(SDMX_TR_ID, trId);
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue