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);
|
||||
|
@ -652,10 +659,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
CodelistTableType codType=new CodelistTableType();
|
||||
|
||||
List<TabularResource> trs = service.getTabularResourcesByType(codType.getName());
|
||||
|
||||
CodelistTableType codType = new CodelistTableType();
|
||||
|
||||
List<TabularResource> trs = service
|
||||
.getTabularResourcesByType(codType.getName());
|
||||
SessionUtil.setTabularResources(session, trs);
|
||||
|
||||
ArrayList<TabResource> ltr = new ArrayList<TabResource>();
|
||||
|
@ -675,100 +683,100 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
e.printStackTrace();
|
||||
logger.error("Error retrieving Codelist in setCodelistsPagingLoader(): "
|
||||
+ e.getLocalizedMessage());
|
||||
throw new TDGWTServiceException(
|
||||
"Error retrieving Codelist: "
|
||||
+ e.getLocalizedMessage());
|
||||
throw new TDGWTServiceException("Error retrieving Codelist: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* {@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);
|
||||
String filter=SessionUtil.getCodelistsPagingLoadedFilter(session);
|
||||
|
||||
if(ltr==null){
|
||||
|
||||
ArrayList<TabResource> ltr = SessionUtil
|
||||
.getCodelistsPagingLoaded(session);
|
||||
String direction = SessionUtil
|
||||
.getCodelistsPagingLoadedDirection(session);
|
||||
String filter = SessionUtil.getCodelistsPagingLoadedFilter(session);
|
||||
|
||||
if (ltr == null) {
|
||||
logger.error("Error no codelist present in session");
|
||||
throw new TDGWTServiceException(
|
||||
"Error no codelist present in session");
|
||||
}
|
||||
|
||||
if(direction==null){
|
||||
}
|
||||
|
||||
if (direction == null) {
|
||||
logger.error("Error no codelist direction present in session");
|
||||
throw new TDGWTServiceException(
|
||||
"Error no codelist direction present in session");
|
||||
}
|
||||
if(filter==null){
|
||||
}
|
||||
if (filter == null) {
|
||||
logger.error("Error no codelist filter present in session");
|
||||
throw new TDGWTServiceException(
|
||||
"Error no codelist filter present in session");
|
||||
}
|
||||
|
||||
if(plc.getOffset()<0 || plc.getOffset()>=ltr.size()){
|
||||
}
|
||||
|
||||
if (plc.getOffset() < 0 || plc.getOffset() >= ltr.size()) {
|
||||
logger.error("Error CodelistPagingLoadConfig no valid range request");
|
||||
throw new TDGWTServiceException(
|
||||
"Error CodelistPagingLoadConfig no valid range request");
|
||||
}
|
||||
|
||||
|
||||
int request_end=plc.getOffset()+plc.getLimit();
|
||||
if(request_end>ltr.size()){
|
||||
request_end=ltr.size();
|
||||
}
|
||||
|
||||
ArrayList<TabResource> ltrTemp=new ArrayList<TabResource>();
|
||||
|
||||
if(filter.compareTo(plc.getFilter())!=0){
|
||||
|
||||
|
||||
int request_end = plc.getOffset() + plc.getLimit();
|
||||
if (request_end > ltr.size()) {
|
||||
request_end = ltr.size();
|
||||
}
|
||||
|
||||
|
||||
if(direction.compareTo(plc.getDirection())!=0){
|
||||
|
||||
|
||||
ArrayList<TabResource> ltrTemp = new ArrayList<TabResource>();
|
||||
|
||||
if (filter.compareTo(plc.getFilter()) != 0) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (direction.compareTo(plc.getDirection()) != 0) {
|
||||
|
||||
}
|
||||
|
||||
for (int i = plc.getOffset(); i < request_end; i++) {
|
||||
try {
|
||||
ltr.get(i);
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
CodelistPagingLoadResult codelistPagingLoadResult=new CodelistPagingLoadResult();
|
||||
|
||||
CodelistPagingLoadResult codelistPagingLoadResult = new CodelistPagingLoadResult();
|
||||
codelistPagingLoadResult.setFilter(plc.getFilter());
|
||||
codelistPagingLoadResult.setDirection(plc.getDirection());
|
||||
codelistPagingLoadResult.setLimit(plc.getLimit());
|
||||
codelistPagingLoadResult.setOffset(plc.getOffset());
|
||||
codelistPagingLoadResult.setTotalLenght(ltr.size());
|
||||
codelistPagingLoadResult.setLtr(ltrTemp);
|
||||
|
||||
|
||||
logger.debug("Codelists retrieved: " + ltrTemp);
|
||||
return codelistPagingLoadResult;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error retrieving Codelist in getCodelistsPagingLoader(): "
|
||||
+ e.getLocalizedMessage());
|
||||
throw new TDGWTServiceException(
|
||||
"Error retrieving Codelist: "
|
||||
+ e.getLocalizedMessage());
|
||||
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");
|
||||
|
@ -2234,7 +2284,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieve OperationExecution for change column type
|
||||
* Retrieve OperationExecution for change column type
|
||||
*
|
||||
* @param changeColumnTypeSession
|
||||
* @return
|
||||
|
@ -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,50 +2326,64 @@ 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);
|
||||
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(),
|
||||
operationDefinition.getOperationId(),map);
|
||||
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(),
|
||||
operationDefinition.getOperationId(),map);
|
||||
OperationsId.ChangeToCodeDescription
|
||||
.toString(),
|
||||
capabilities);
|
||||
invocation = new OperationExecution(
|
||||
changeColumnTypeSession.getColumnData()
|
||||
.getColumnId(),
|
||||
operationDefinition.getOperationId(), map);
|
||||
} else {
|
||||
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
|
||||
ColumnTypeCode.ANNOTATION) == 0) {
|
||||
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(
|
||||
ColumnTypeCode.DIMENSION) == 0) {
|
||||
if (changeColumnTypeSession
|
||||
.getColumnTypeCodeTarget().compareTo(
|
||||
ColumnTypeCode.DIMENSION) == 0) {
|
||||
} else {
|
||||
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
|
||||
ColumnTypeCode.TIMEDIMENSION) == 0) {
|
||||
if (changeColumnTypeSession
|
||||
.getColumnTypeCodeTarget()
|
||||
.compareTo(
|
||||
ColumnTypeCode.TIMEDIMENSION) == 0) {
|
||||
} else {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2346,10 +2411,11 @@ 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!");
|
||||
if (invocation == null) {
|
||||
throw new TDGWTServiceException(
|
||||
"Error in ChangeColumnType: Operation not supported for now!");
|
||||
}
|
||||
|
||||
|
||||
TabularResourceId serviceTR = new TabularResourceId(
|
||||
Long.valueOf(changeColumnTypeSession.getColumnData()
|
||||
.getTrId().getId()));
|
||||
|
|
Loading…
Reference in New Issue