Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@90601 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4f843a681f
commit
46d3e9b297
|
@ -0,0 +1,85 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.client;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationProvider;
|
||||
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken;
|
||||
import org.gcube.data.analysis.tabulardata.model.column.Column;
|
||||
import org.gcube.data.analysis.tabulardata.model.table.Table;
|
||||
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
|
||||
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.AgencyMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.DescriptionMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.NameMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.RightsMetadata;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class TestMetadata {
|
||||
|
||||
protected static SimpleDateFormat sdf = new SimpleDateFormat(
|
||||
"yyyy/MM/dd HH:mm");
|
||||
|
||||
@Test
|
||||
public void listTR() throws Exception {
|
||||
System.out.println("------------List TR--------------");
|
||||
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(Constants.DEFAULT_USER));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
List<TabularResource> trs = service.getTabularResources();
|
||||
Assert.assertTrue(trs.size() > 0);
|
||||
Table lastTable=null;
|
||||
for (TabularResource tr : trs) {
|
||||
lastTable=service.getLastTable(tr.getId());
|
||||
|
||||
if(lastTable!=null){
|
||||
System.out.println("TabularResource: [" + tr.getId()+", lastTable: "+lastTable.getTableType().getName()+"]");
|
||||
} else {
|
||||
System.out.println("TabularResource: [" + tr.getId()+", lastTable: "+lastTable+"]");
|
||||
|
||||
}
|
||||
}
|
||||
showMoreInformation(service);
|
||||
|
||||
TabularResource tr=service.createTabularResource();
|
||||
// Date date = Calendar.getInstance().getTime();
|
||||
System.out.println("TR date:"+sdf.format(tr.getCreationDate().getTime()));
|
||||
tr.setMetadata(new NameMetadata("TestNameOfTabularResource"));
|
||||
tr.setMetadata(new DescriptionMetadata("TestDescriptionOfTabularResource"));
|
||||
tr.setMetadata(new RightsMetadata("TestRights"));
|
||||
|
||||
showMoreInformation(service);
|
||||
|
||||
}
|
||||
|
||||
protected void showMoreInformation(TabularDataService service) throws Exception {
|
||||
List<TabularResource> trs = service.getTabularResources();
|
||||
Assert.assertTrue(trs.size() > 0);
|
||||
System.out.println("-----More Informations-----");
|
||||
Table lastTable=null;
|
||||
for(TabularResource tr:trs){
|
||||
lastTable=service.getLastTable(tr.getId());
|
||||
if(lastTable!=null){
|
||||
System.out.println("TabularResource: [" + tr.getId()+", lastTableId: "+lastTable.getId().getValue()+" lastTableType:"+lastTable.getTableType().getName()+"] Metadata:"+tr.getAllMetadata().toString());
|
||||
} else {
|
||||
System.out.println("TabularResource: [" + tr.getId()+", lastTable: "+lastTable+"] Metadata: "+tr.getAllMetadata().toString());
|
||||
|
||||
}
|
||||
System.out.println("-----------");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue