Changed rpc parameter

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@84225 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2013-10-25 10:47:17 +00:00
parent 5cb1fd5762
commit b26c7fabf3
3 changed files with 24 additions and 30 deletions

View File

@ -75,6 +75,6 @@ public interface TDGWTService extends RemoteService {
public ArrayList<CSVRowError> checkCSV(long errorsLimit) throws TDGWTServiceException; public ArrayList<CSVRowError> checkCSV(long errorsLimit) throws TDGWTServiceException;
public void startCSVImport(boolean[] columnToImportMask) throws TDGWTServiceException; public void startCSVImport(CSVImportSession s) throws TDGWTServiceException;
} }

View File

@ -73,7 +73,7 @@ public interface TDGWTServiceAsync {
void checkCSV(long errorsLimit, AsyncCallback<ArrayList<CSVRowError> > callback); void checkCSV(long errorsLimit, AsyncCallback<ArrayList<CSVRowError> > callback);
void startCSVImport(boolean[] columnToImportMask, AsyncCallback<Void> callback); void startCSVImport(CSVImportSession s, AsyncCallback<Void> callback);
} }

View File

@ -77,10 +77,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
protected TabularDataService service; protected TabularDataService service;
protected HttpSession session; protected HttpSession session;
protected ASLSession aslSession; protected ASLSession aslSession;
public void setTabResource(TabResource tabResource) public void setTabResource(TabResource tabResource)
throws TDGWTServiceException { throws TDGWTServiceException {
try { try {
@ -113,14 +110,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
session = this.getThreadLocalRequest().getSession(); session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session); aslSession = SessionUtil.getAslSession(session);
TabResource currentTR=SessionUtil.getTabResource(session); TabResource currentTR = SessionUtil.getTabResource(session);
if(currentTR==null){ if (currentTR == null) {
logger.error( logger.error("CURRENT_TABULAR_RESOURCE is null");
"CURRENT_TABULAR_RESOURCE is null");
throw new TDGWTServiceException( throw new TDGWTServiceException(
"CURRENT_TABULAR_RESOURCE is null"); "CURRENT_TABULAR_RESOURCE is null");
} }
return currentTR; return currentTR;
} catch (Exception e) { } catch (Exception e) {
@ -194,29 +190,27 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} }
} }
protected void syncTRMetaData(TabularResource tr, TabResource tabResource) {
protected void syncTRMetaData(TabularResource tr,TabResource tabResource){ Date date = Calendar.getInstance().getTime();
Date date=Calendar.getInstance().getTime();
tabResource.setDate(sdf.format(date)); tabResource.setDate(sdf.format(date));
tr.setMetadata(new NameMetadata(tabResource.getName())); tr.setMetadata(new NameMetadata(tabResource.getName()));
tr.setMetadata(new DescriptionMetadata(tabResource.getDescription())); tr.setMetadata(new DescriptionMetadata(tabResource.getDescription()));
tr.setMetadata(new CreationDateMetadata(date)); tr.setMetadata(new CreationDateMetadata(date));
tr.setMetadata(new AgencyMetadata(tabResource.getAgency())); tr.setMetadata(new AgencyMetadata(tabResource.getAgency()));
tr.setMetadata(new RightsMetadata(tabResource.getRight())); tr.setMetadata(new RightsMetadata(tabResource.getRight()));
TRId trId = new TRId(String.valueOf(tr.getId().getValue())); TRId trId = new TRId(String.valueOf(tr.getId().getValue()));
tabResource.setTrId(trId); tabResource.setTrId(trId);
} }
protected void retriveTRMetadataFromService(TabularResource tr) protected void retriveTRMetadataFromService(TabularResource tr)
throws TDGWTServiceException { throws TDGWTServiceException {
retriveTRMetadataFromService(tr, 0); retriveTRMetadataFromService(tr, 0);
} }
protected TabResource retriveTRMetadataFromService(TabularResource tr, int i) protected TabResource retriveTRMetadataFromService(TabularResource tr, int i)
throws TDGWTServiceException { throws TDGWTServiceException {
NameMetadata nameMeta; NameMetadata nameMeta;
RightsMetadata rightsMeta; RightsMetadata rightsMeta;
CreationDateMetadata creationDateMeta; CreationDateMetadata creationDateMeta;
@ -458,9 +452,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
.getTabResource(); .getTabResource();
TabularResource serviceTR = trService.createTabularResource(); TabularResource serviceTR = trService.createTabularResource();
syncTRMetaData(serviceTR,importSDMXTabResource); syncTRMetaData(serviceTR, importSDMXTabResource);
SessionUtil SessionUtil
.setSDMXImportTabResource(session, importSDMXTabResource); .setSDMXImportTabResource(session, importSDMXTabResource);
@ -546,8 +540,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
sdmxImportTabResource.setTrId(trId); sdmxImportTabResource.setTrId(trId);
SessionUtil.setSDMXImportTabResource( SessionUtil.setSDMXImportTabResource(
session, sdmxImportTabResource); session, sdmxImportTabResource);
SessionUtil SessionUtil.setTabResource(session,
.setTabResource(session, sdmxImportTabResource); sdmxImportTabResource);
SessionUtil.setTRId(session, trId); SessionUtil.setTRId(session, trId);
@ -739,7 +733,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} }
@Override @Override
public void startCSVImport(boolean[] columnToImportMask) public void startCSVImport(CSVImportSession csvImportSession)
throws TDGWTServiceException { throws TDGWTServiceException {
session = this.getThreadLocalRequest().getSession(); session = this.getThreadLocalRequest().getSession();
if (session == null) { if (session == null) {
@ -763,18 +757,18 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
"Error retrieving the fileUploadSession: null"); "Error retrieving the fileUploadSession: null");
} }
importCSVFileOnService(user, fileUploadSession, columnToImportMask); importCSVFileOnService(user, fileUploadSession, csvImportSession);
} }
protected Map<String, Object> csvImportFileParameter( protected Map<String, Object> csvImportFileParameter(
String fileUrlOnStorage, FileUploadSession fileUploadSession, String fileUrlOnStorage, FileUploadSession fileUploadSession,
boolean[] columnToImportMask) { CSVImportSession csvImportSession) {
final String ENCODING = "encoding"; final String ENCODING = "encoding";
final String HASHEADER = "hasHeader"; final String HASHEADER = "hasHeader";
final String SEPARATOR = "separator"; final String SEPARATOR = "separator";
final String URL = "url"; final String URL = "url";
Map<String, Object> parameterInstances = new HashMap<String, Object>(); Map<String, Object> parameterInstances = new HashMap<String, Object>();
parameterInstances.put(URL, fileUrlOnStorage); parameterInstances.put(URL, fileUrlOnStorage);
parameterInstances.put(SEPARATOR, fileUploadSession parameterInstances.put(SEPARATOR, fileUploadSession
@ -790,7 +784,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} }
protected void importCSVFileOnService(String user, protected void importCSVFileOnService(String user,
FileUploadSession fileUploadSession, boolean[] columnToImportMask) FileUploadSession fileUploadSession, CSVImportSession csvImportSession)
throws TDGWTServiceException { throws TDGWTServiceException {
FilesStorage filesStorage = new FilesStorage(); FilesStorage filesStorage = new FilesStorage();
@ -798,7 +792,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
fileUploadSession.getCsvFile()); fileUploadSession.getCsvFile());
Map<String, Object> parameterInstance = csvImportFileParameter( Map<String, Object> parameterInstance = csvImportFileParameter(
fileUrlOnStorage, fileUploadSession, columnToImportMask); fileUrlOnStorage, fileUploadSession, csvImportSession);
service = new TabularDataServiceMock(); service = new TabularDataServiceMock();