Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@90595 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
44ea1d308b
commit
9f3f7fbd7d
|
@ -174,6 +174,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
ArrayList<TRMetadata> trMetadatas = getTRMetadata(currentTR
|
ArrayList<TRMetadata> trMetadatas = getTRMetadata(currentTR
|
||||||
.getTrId());
|
.getTrId());
|
||||||
updateTabResourceInformation(currentTR, trMetadatas);
|
updateTabResourceInformation(currentTR, trMetadatas);
|
||||||
|
currentTR.setDate(getTRCreationDate(currentTR.getTrId()));
|
||||||
SessionUtil.setTabResource(session, currentTR);
|
SessionUtil.setTabResource(session, currentTR);
|
||||||
return currentTR;
|
return currentTR;
|
||||||
|
|
||||||
|
@ -196,13 +197,14 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
//ASLSession aslSession = SessionUtil.getAslSession(session);
|
// ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
|
|
||||||
TabResource currentTR = new TabResource();
|
TabResource currentTR = new TabResource();
|
||||||
currentTR.setTrId(trId);
|
currentTR.setTrId(trId);
|
||||||
ArrayList<TRMetadata> trMetadatas = getTRMetadata(currentTR
|
ArrayList<TRMetadata> trMetadatas = getTRMetadata(currentTR
|
||||||
.getTrId());
|
.getTrId());
|
||||||
updateTabResourceInformation(currentTR, trMetadatas);
|
updateTabResourceInformation(currentTR, trMetadatas);
|
||||||
|
currentTR.setDate(getTRCreationDate(trId));
|
||||||
return currentTR;
|
return currentTR;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -280,7 +282,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Column c : cols) {
|
for (Column c : cols) {
|
||||||
if (c.getColumnType() instanceof IdColumnType) {
|
if (c.getColumnType() instanceof IdColumnType) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ColumnData cData = new ColumnData();
|
ColumnData cData = new ColumnData();
|
||||||
cData.setId(Integer.toString(i));
|
cData.setId(Integer.toString(i));
|
||||||
|
@ -321,11 +323,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(
|
logger.error(
|
||||||
"Error retrieving Columns: "
|
"Error retrieving Columns: " + e.getLocalizedMessage(), e);
|
||||||
+ e.getLocalizedMessage(), e);
|
throw new TDGWTServiceException("Error retrieving Columns: "
|
||||||
throw new TDGWTServiceException(
|
+ e.getLocalizedMessage());
|
||||||
"Error retrieving Columns: "
|
|
||||||
+ e.getLocalizedMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +333,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
*
|
*
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public ArrayList<ColumnData> getColumns(TRId trId) throws TDGWTServiceException {
|
public ArrayList<ColumnData> getColumns(TRId trId)
|
||||||
|
throws TDGWTServiceException {
|
||||||
try {
|
try {
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
|
@ -342,8 +343,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
aslSession.getUsername()));
|
aslSession.getUsername()));
|
||||||
TabularDataService service = TabularDataServiceFactory.getService();
|
TabularDataService service = TabularDataServiceFactory.getService();
|
||||||
|
|
||||||
Table table = service.getTable(new TableId(Long
|
Table table = service.getTable(new TableId(Long.valueOf(trId
|
||||||
.valueOf(trId.getTableId())));
|
.getTableId())));
|
||||||
|
|
||||||
ArrayList<ColumnData> columns = new ArrayList<ColumnData>();
|
ArrayList<ColumnData> columns = new ArrayList<ColumnData>();
|
||||||
|
|
||||||
|
@ -351,7 +352,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Column c : cols) {
|
for (Column c : cols) {
|
||||||
if (c.getColumnType() instanceof IdColumnType) {
|
if (c.getColumnType() instanceof IdColumnType) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ColumnData cData = new ColumnData();
|
ColumnData cData = new ColumnData();
|
||||||
cData.setId(Integer.toString(i));
|
cData.setId(Integer.toString(i));
|
||||||
|
@ -392,19 +393,18 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(
|
logger.error(
|
||||||
"Error retrieving Columns: "
|
"Error retrieving Columns: " + e.getLocalizedMessage(), e);
|
||||||
+ e.getLocalizedMessage(), e);
|
throw new TDGWTServiceException("Error retrieving Columns: "
|
||||||
throw new TDGWTServiceException(
|
+ e.getLocalizedMessage());
|
||||||
"Error retrieving Columns: "
|
|
||||||
+ e.getLocalizedMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public ColumnData getColumn(TRId trId, String columnName) throws TDGWTServiceException {
|
public ColumnData getColumn(TRId trId, String columnName)
|
||||||
|
throws TDGWTServiceException {
|
||||||
try {
|
try {
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
|
@ -413,14 +413,14 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
aslSession.getUsername()));
|
aslSession.getUsername()));
|
||||||
TabularDataService service = TabularDataServiceFactory.getService();
|
TabularDataService service = TabularDataServiceFactory.getService();
|
||||||
|
|
||||||
Table table = service.getTable(new TableId(Long
|
Table table = service.getTable(new TableId(Long.valueOf(trId
|
||||||
.valueOf(trId.getTableId())));
|
.getTableId())));
|
||||||
|
|
||||||
ColumnData cData = new ColumnData();
|
ColumnData cData = new ColumnData();
|
||||||
|
|
||||||
Column c = table.getColumnByName(columnName);
|
Column c = table.getColumnByName(columnName);
|
||||||
if (c.getColumnType() instanceof IdColumnType) {
|
if (c.getColumnType() instanceof IdColumnType) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
cData.setId(Integer.toString(0));
|
cData.setId(Integer.toString(0));
|
||||||
cData.setColumnId(c.getLocalId().getValue());
|
cData.setColumnId(c.getLocalId().getValue());
|
||||||
|
@ -457,15 +457,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
return cData;
|
return cData;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(
|
logger.error("Error retrieving Column: " + e.getLocalizedMessage(),
|
||||||
"Error retrieving Column: "
|
e);
|
||||||
+ e.getLocalizedMessage(), e);
|
throw new TDGWTServiceException("Error retrieving Column: "
|
||||||
throw new TDGWTServiceException(
|
+ e.getLocalizedMessage());
|
||||||
"Error retrieving Column: "
|
|
||||||
+ e.getLocalizedMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
@ -544,11 +542,12 @@ 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();
|
||||||
logger.debug("TRservice [id:"+tr.getId()+" ,creationDate:"+tr.getCreationDate()+"]");
|
logger.debug("TRservice [id:" + tr.getId() + " ,creationDate:"
|
||||||
logger.debug("TabResource [name:"+tabResource.getName()+
|
+ tr.getCreationDate() + "]");
|
||||||
" ,description:"+tabResource.getDescription()+
|
logger.debug("TabResource [name:" + tabResource.getName()
|
||||||
" ,agency:"+tabResource.getAgency()+
|
+ " ,description:" + tabResource.getDescription() + " ,agency:"
|
||||||
" ,rights:"+tabResource.getRight()+"]");
|
+ tabResource.getAgency() + " ,rights:"
|
||||||
|
+ tabResource.getRight() + "]");
|
||||||
tabResource.setDate(sdf.format(tr.getCreationDate().getTime()));
|
tabResource.setDate(sdf.format(tr.getCreationDate().getTime()));
|
||||||
tr.setMetadata(new NameMetadata(tabResource.getName()));
|
tr.setMetadata(new NameMetadata(tabResource.getName()));
|
||||||
tr.setMetadata(new DescriptionMetadata(tabResource.getDescription()));
|
tr.setMetadata(new DescriptionMetadata(tabResource.getDescription()));
|
||||||
|
@ -834,7 +833,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
TabularResource serviceTR = trService.createTabularResource();
|
TabularResource serviceTR = trService.createTabularResource();
|
||||||
|
|
||||||
syncTRMetaData(serviceTR, importSDMXTabResource);
|
syncTRMetaData(serviceTR, importSDMXTabResource);
|
||||||
|
|
||||||
TRId trId = new TRId(String.valueOf(serviceTR.getId().getValue()));
|
TRId trId = new TRId(String.valueOf(serviceTR.getId().getValue()));
|
||||||
importSDMXTabResource.setTrId(trId);
|
importSDMXTabResource.setTrId(trId);
|
||||||
|
|
||||||
|
@ -1433,6 +1432,31 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
SessionUtil.setFileUploadSession(session, fileUploadSession);
|
SessionUtil.setFileUploadSession(session, fileUploadSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTRCreationDate(TRId trId) throws TDGWTServiceException {
|
||||||
|
try {
|
||||||
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
|
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
|
|
||||||
|
logger.debug("GetTRMetadata on " + trId.toString());
|
||||||
|
|
||||||
|
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||||
|
aslSession.getUsername()));
|
||||||
|
TabularDataService service = TabularDataServiceFactory.getService();
|
||||||
|
|
||||||
|
TabularResource tr = service
|
||||||
|
.getTabularResource(new TabularResourceId(Long.valueOf(trId
|
||||||
|
.getId())));
|
||||||
|
|
||||||
|
return sdf.format(tr.getCreationDate().getTime());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(
|
||||||
|
"Error in getTRCreationDate(): " + e.getLocalizedMessage(), e);
|
||||||
|
throw new TDGWTServiceException("Error in getTRCreationDate(): "
|
||||||
|
+ e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
@ -1442,9 +1466,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
try {
|
try {
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
|
|
||||||
logger.debug("GetTRMetadata on TRId:"+trId.toString());
|
logger.debug("GetTRMetadata on " + trId.toString());
|
||||||
|
|
||||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||||
aslSession.getUsername()));
|
aslSession.getUsername()));
|
||||||
TabularDataService service = TabularDataServiceFactory.getService();
|
TabularDataService service = TabularDataServiceFactory.getService();
|
||||||
|
@ -1454,8 +1478,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
.getId())));
|
.getId())));
|
||||||
|
|
||||||
Collection<TabularResourceMetadata> trMetas = tr.getAllMetadata();
|
Collection<TabularResourceMetadata> trMetas = tr.getAllMetadata();
|
||||||
|
|
||||||
logger.debug("GetTRMetadata size: "+trMetas.size());
|
logger.debug("GetTRMetadata size: " + trMetas.size());
|
||||||
ArrayList<TRMetadata> listTRMetadata = new ArrayList<TRMetadata>();
|
ArrayList<TRMetadata> listTRMetadata = new ArrayList<TRMetadata>();
|
||||||
|
|
||||||
for (TabularResourceMetadata trMetadata : trMetas) {
|
for (TabularResourceMetadata trMetadata : trMetas) {
|
||||||
|
@ -1494,8 +1518,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("GetTRMetadata retrived: "+listTRMetadata.size());
|
logger.debug("GetTRMetadata retrived: " + listTRMetadata.size());
|
||||||
return listTRMetadata;
|
return listTRMetadata;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -1515,8 +1539,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
try {
|
try {
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
|
|
||||||
logger.debug("GetTableMetadata on TRId:"+trId.toString());
|
logger.debug("GetTableMetadata on " + trId.toString());
|
||||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||||
aslSession.getUsername()));
|
aslSession.getUsername()));
|
||||||
TabularDataService service = TabularDataServiceFactory.getService();
|
TabularDataService service = TabularDataServiceFactory.getService();
|
||||||
|
@ -1527,7 +1551,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
Collection<TableMetadata> cMeta = table.getAllMetadata();
|
Collection<TableMetadata> cMeta = table.getAllMetadata();
|
||||||
|
|
||||||
ArrayList<TabMetadata> listTabMetadata = new ArrayList<TabMetadata>();
|
ArrayList<TabMetadata> listTabMetadata = new ArrayList<TabMetadata>();
|
||||||
logger.debug("Metadata size:"+cMeta.size());
|
logger.debug("Metadata size:" + cMeta.size());
|
||||||
for (TableMetadata tMetadata : cMeta) {
|
for (TableMetadata tMetadata : cMeta) {
|
||||||
if (tMetadata instanceof DescriptionsMetadata) {
|
if (tMetadata instanceof DescriptionsMetadata) {
|
||||||
TabDescriptionsMetadata trDescriptionsMetadata = new TabDescriptionsMetadata();
|
TabDescriptionsMetadata trDescriptionsMetadata = new TabDescriptionsMetadata();
|
||||||
|
|
Loading…
Reference in New Issue