Proper recovery of informations
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@84121 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
fca3c40ac4
commit
7c566446d5
|
@ -37,7 +37,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
|||
@RemoteServiceRelativePath("TDGWTService")
|
||||
public interface TDGWTService extends RemoteService {
|
||||
|
||||
public TabResource getTabResource() throws TDGWTServiceException;
|
||||
public TabResource getTabResourceInformation() throws TDGWTServiceException;
|
||||
|
||||
public void setTabResource(TabResource tr) throws TDGWTServiceException;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public interface TDGWTServiceAsync {
|
|||
|
||||
void createTabularResource(TabResource tabResource,AsyncCallback<TabResource> callback);
|
||||
|
||||
void getTabResource(AsyncCallback<TabResource> callback);
|
||||
void getTabResourceInformation(AsyncCallback<TabResource> callback);
|
||||
|
||||
void setTabResource(TabResource tabResource, AsyncCallback<Void> callback);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ package org.gcube.portlets.user.td.gwtservice.server;
|
|||
import java.nio.charset.Charset;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -77,6 +78,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
protected HttpSession session;
|
||||
protected ASLSession aslSession;
|
||||
|
||||
|
||||
|
||||
|
||||
public void setTabResource(TabResource tabResource)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
|
@ -87,14 +91,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
"Error setting TabResource: null");
|
||||
}
|
||||
|
||||
if (tabResource.getTrId() == null) {
|
||||
logger.error("Error setting TabResource trId is null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error setting TabResource trId is null");
|
||||
}
|
||||
|
||||
SessionUtil.setTabResource(session, tabResource);
|
||||
SessionUtil.setTRId(session, tabResource.getTrId());
|
||||
return;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -111,10 +108,20 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public TabResource getTabResource() throws TDGWTServiceException {
|
||||
public TabResource getTabResourceInformation() throws TDGWTServiceException {
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
return SessionUtil.getTabResource(session);
|
||||
aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
TabResource currentTR=SessionUtil.getTabResource(session);
|
||||
if(currentTR==null){
|
||||
logger.error(
|
||||
"CURRENT_TABULAR_RESOURCE is null");
|
||||
throw new TDGWTServiceException(
|
||||
"CURRENT_TABULAR_RESOURCE is null");
|
||||
}
|
||||
|
||||
return currentTR;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
|
@ -187,9 +194,29 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
protected void syncTRMetaData(TabularResource tr,TabResource tabResource){
|
||||
Date date=Calendar.getInstance().getTime();
|
||||
tabResource.setDate(sdf.format(date));
|
||||
tr.setMetadata(new NameMetadata(tabResource.getName()));
|
||||
tr.setMetadata(new DescriptionMetadata(tabResource.getDescription()));
|
||||
tr.setMetadata(new CreationDateMetadata(date));
|
||||
tr.setMetadata(new AgencyMetadata(tabResource.getAgency()));
|
||||
tr.setMetadata(new RightsMetadata(tabResource.getRight()));
|
||||
|
||||
TRId trId = new TRId(String.valueOf(tr.getId().getValue()));
|
||||
tabResource.setTrId(trId);
|
||||
}
|
||||
|
||||
|
||||
protected void retriveTRMetadataFromService(TabularResource tr)
|
||||
throws TDGWTServiceException {
|
||||
retriveTRMetadataFromService(tr, 0);
|
||||
}
|
||||
|
||||
protected TabResource retriveTRMetadataFromService(TabularResource tr, int i)
|
||||
throws TDGWTServiceException {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
|
||||
|
||||
NameMetadata nameMeta;
|
||||
RightsMetadata rightsMeta;
|
||||
CreationDateMetadata creationDateMeta;
|
||||
|
@ -431,10 +458,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
.getTabResource();
|
||||
|
||||
TabularResource serviceTR = trService.createTabularResource();
|
||||
// Table table=trService.getLastTable(serviceTRId);
|
||||
|
||||
TRId trId = new TRId(String.valueOf(serviceTR.getId().getValue()));
|
||||
importSDMXTabResource.setTrId(trId);
|
||||
syncTRMetaData(serviceTR,importSDMXTabResource);
|
||||
|
||||
SessionUtil
|
||||
.setSDMXImportTabResource(session, importSDMXTabResource);
|
||||
|
||||
|
@ -520,6 +546,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
sdmxImportTabResource.setTrId(trId);
|
||||
SessionUtil.setSDMXImportTabResource(
|
||||
session, sdmxImportTabResource);
|
||||
SessionUtil
|
||||
.setTabResource(session, sdmxImportTabResource);
|
||||
|
||||
SessionUtil.setTRId(session, trId);
|
||||
|
||||
|
|
Loading…
Reference in New Issue