Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@91251 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
009ab1315b
commit
1a118ecbe3
|
@ -25,6 +25,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.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.Profile;
|
||||
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.TaskStatus;
|
||||
|
@ -113,11 +116,17 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
|
||||
import org.gcube.common.resources.gcore.utils.Group;
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
|
@ -638,13 +647,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
return t;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setCodelistsPagingLoader()
|
||||
throws TDGWTServiceException {
|
||||
public void setCodelistsPagingLoader() throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
@ -655,7 +662,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
CodelistTableType codType = new CodelistTableType();
|
||||
|
||||
List<TabularResource> trs = service.getTabularResourcesByType(codType.getName());
|
||||
List<TabularResource> trs = service
|
||||
.getTabularResourcesByType(codType.getName());
|
||||
SessionUtil.setTabularResources(session, trs);
|
||||
|
||||
ArrayList<TabResource> ltr = new ArrayList<TabResource>();
|
||||
|
@ -675,8 +683,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
e.printStackTrace();
|
||||
logger.error("Error retrieving Codelist in setCodelistsPagingLoader(): "
|
||||
+ e.getLocalizedMessage());
|
||||
throw new TDGWTServiceException(
|
||||
"Error retrieving Codelist: "
|
||||
throw new TDGWTServiceException("Error retrieving Codelist: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
|
@ -686,13 +693,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public CodelistPagingLoadResult getCodelistsPagingLoader(CodelistPagingLoadConfig plc)
|
||||
throws TDGWTServiceException {
|
||||
public CodelistPagingLoadResult getCodelistsPagingLoader(
|
||||
CodelistPagingLoadConfig plc) throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
|
||||
ArrayList<TabResource> ltr = SessionUtil.getCodelistsPagingLoaded(session);
|
||||
String direction=SessionUtil.getCodelistsPagingLoadedDirection(session);
|
||||
ArrayList<TabResource> ltr = SessionUtil
|
||||
.getCodelistsPagingLoaded(session);
|
||||
String direction = SessionUtil
|
||||
.getCodelistsPagingLoadedDirection(session);
|
||||
String filter = SessionUtil.getCodelistsPagingLoadedFilter(session);
|
||||
|
||||
if (ltr == null) {
|
||||
|
@ -718,7 +727,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
"Error CodelistPagingLoadConfig no valid range request");
|
||||
}
|
||||
|
||||
|
||||
int request_end = plc.getOffset() + plc.getLimit();
|
||||
if (request_end > ltr.size()) {
|
||||
request_end = ltr.size();
|
||||
|
@ -730,7 +738,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
|
||||
if (direction.compareTo(plc.getDirection()) != 0) {
|
||||
|
||||
}
|
||||
|
@ -741,8 +748,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
ltrTemp.add(ltr.get(i));
|
||||
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
logger.debug("OutOfBounds in getCodelistsPagingLoader() size:" + ltr.size() + " index: " + i
|
||||
+ " Error:" + e.getMessage() + "\n");
|
||||
logger.debug("OutOfBounds in getCodelistsPagingLoader() size:"
|
||||
+ ltr.size()
|
||||
+ " index: "
|
||||
+ i
|
||||
+ " Error:"
|
||||
+ e.getMessage() + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -760,15 +771,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
e.printStackTrace();
|
||||
logger.error("Error retrieving Codelist in getCodelistsPagingLoader(): "
|
||||
+ e.getLocalizedMessage());
|
||||
throw new TDGWTServiceException(
|
||||
"Error retrieving Codelist: "
|
||||
throw new TDGWTServiceException("Error retrieving Codelist: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
|
@ -1871,10 +1879,52 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
* @return
|
||||
*/
|
||||
protected Map<String, Object> sdmxExportParameter(
|
||||
SDMXExportSession exportSession) {
|
||||
SDMXExportSession exportSession) throws TDGWTServiceException {
|
||||
boolean internalRegistry = false;
|
||||
String destination=null;//Es: http://pc-fortunati.isti.cnr.it:8080/FusionRegistry/ws/rest/
|
||||
|
||||
if (exportSession != null) {
|
||||
if (exportSession.getRegistryBaseUrl() != null
|
||||
&& !exportSession.getRegistryBaseUrl().isEmpty()) {
|
||||
destination= exportSession.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");
|
||||
}
|
||||
|
||||
Map<String, Object> parameterInstances = new HashMap<String, Object>();
|
||||
parameterInstances.put(Constants.PARAMETER_REGISTRYBASEURL,
|
||||
"http://pc-fortunati.isti.cnr.it:8080/FusionRegistry/ws/rest/");
|
||||
destination);
|
||||
parameterInstances.put(Constants.PARAMETER_AGENCY, "SDMX");
|
||||
parameterInstances.put(Constants.PARAMETER_ID, "NEW_CL_DIVISION");
|
||||
parameterInstances.put(Constants.PARAMETER_VERSION, "2.0");
|
||||
|
@ -2267,7 +2317,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
|
||||
ColumnTypeCode.ATTRIBUTE) == 0) {
|
||||
operationDefinition = getOperationDescriptorWithId(
|
||||
OperationsId.ChangeToAttributeColumn.toString(), capabilities);
|
||||
OperationsId.ChangeToAttributeColumn.toString(),
|
||||
capabilities);
|
||||
|
||||
map.put(Constants.PARAMETER_DATA_TYPE, ColumnDataTypeMap
|
||||
.map(changeColumnTypeSession.getColumnDataType()));
|
||||
|
@ -2275,42 +2326,56 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
.getColumnData().getColumnId(),
|
||||
operationDefinition.getOperationId(), map);
|
||||
} else {
|
||||
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
|
||||
ColumnTypeCode.CODE) == 0) {
|
||||
if (changeColumnTypeSession.getColumnTypeCodeTarget()
|
||||
.compareTo(ColumnTypeCode.CODE) == 0) {
|
||||
operationDefinition = getOperationDescriptorWithId(
|
||||
OperationsId.ChangeToCodeColumn.toString(), capabilities);
|
||||
OperationsId.ChangeToCodeColumn.toString(),
|
||||
capabilities);
|
||||
invocation = new OperationExecution(changeColumnTypeSession
|
||||
.getColumnData().getColumnId(),
|
||||
operationDefinition.getOperationId(), map);
|
||||
} else {
|
||||
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
|
||||
ColumnTypeCode.CODENAME) == 0) {
|
||||
if (changeColumnTypeSession.getColumnTypeCodeTarget()
|
||||
.compareTo(ColumnTypeCode.CODENAME) == 0) {
|
||||
operationDefinition = getOperationDescriptorWithId(
|
||||
OperationsId.ChangeToCodeName.toString(), capabilities);
|
||||
invocation = new OperationExecution(changeColumnTypeSession
|
||||
.getColumnData().getColumnId(),
|
||||
OperationsId.ChangeToCodeName.toString(),
|
||||
capabilities);
|
||||
invocation = new OperationExecution(
|
||||
changeColumnTypeSession.getColumnData()
|
||||
.getColumnId(),
|
||||
operationDefinition.getOperationId(), map);
|
||||
} else {
|
||||
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
|
||||
ColumnTypeCode.CODEDESCRIPTION) == 0) {
|
||||
if (changeColumnTypeSession.getColumnTypeCodeTarget()
|
||||
.compareTo(ColumnTypeCode.CODEDESCRIPTION) == 0) {
|
||||
operationDefinition = getOperationDescriptorWithId(
|
||||
OperationsId.ChangeToCodeDescription.toString(), capabilities);
|
||||
invocation = new OperationExecution(changeColumnTypeSession
|
||||
.getColumnData().getColumnId(),
|
||||
OperationsId.ChangeToCodeDescription
|
||||
.toString(),
|
||||
capabilities);
|
||||
invocation = new OperationExecution(
|
||||
changeColumnTypeSession.getColumnData()
|
||||
.getColumnId(),
|
||||
operationDefinition.getOperationId(), map);
|
||||
} else {
|
||||
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
|
||||
if (changeColumnTypeSession
|
||||
.getColumnTypeCodeTarget().compareTo(
|
||||
ColumnTypeCode.ANNOTATION) == 0) {
|
||||
operationDefinition = getOperationDescriptorWithId(
|
||||
OperationsId.ChangeToAnnotationColumn.toString(), capabilities);
|
||||
invocation = new OperationExecution(changeColumnTypeSession
|
||||
.getColumnData().getColumnId(),
|
||||
operationDefinition.getOperationId(),map);
|
||||
OperationsId.ChangeToAnnotationColumn
|
||||
.toString(),
|
||||
capabilities);
|
||||
invocation = new OperationExecution(
|
||||
changeColumnTypeSession.getColumnData()
|
||||
.getColumnId(),
|
||||
operationDefinition.getOperationId(),
|
||||
map);
|
||||
} else {
|
||||
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
|
||||
if (changeColumnTypeSession
|
||||
.getColumnTypeCodeTarget().compareTo(
|
||||
ColumnTypeCode.DIMENSION) == 0) {
|
||||
} else {
|
||||
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
|
||||
if (changeColumnTypeSession
|
||||
.getColumnTypeCodeTarget()
|
||||
.compareTo(
|
||||
ColumnTypeCode.TIMEDIMENSION) == 0) {
|
||||
} else {
|
||||
|
||||
|
@ -2347,7 +2412,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
OperationExecution invocation = retriveOperationExecution(service,
|
||||
changeColumnTypeSession);
|
||||
if (invocation == null) {
|
||||
throw new TDGWTServiceException("Error in ChangeColumnType: Operation not supported for now!");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in ChangeColumnType: Operation not supported for now!");
|
||||
}
|
||||
|
||||
TabularResourceId serviceTR = new TabularResourceId(
|
||||
|
|
Loading…
Reference in New Issue