48 lines
1.6 KiB
Java
48 lines
1.6 KiB
Java
package org.gcube.data.access.accounting.summary.access.test;
|
|
|
|
import java.sql.SQLException;
|
|
import java.util.Date;
|
|
import java.util.GregorianCalendar;
|
|
|
|
import org.gcube.data.access.accounting.summary.access.AccountingDao;
|
|
import org.gcube.data.access.accounting.summary.access.ParameterException;
|
|
import org.gcube.data.access.accounting.summary.access.impl.AccountingDaoImpl;
|
|
import org.gcube.data.access.accounting.summary.access.impl.Queries;
|
|
import org.gcube.data.access.accounting.summary.access.model.MeasureResolution;
|
|
import org.gcube.data.access.accounting.summary.access.model.Report;
|
|
import org.gcube.data.access.accounting.summary.access.model.ScopeDescriptor;
|
|
|
|
public class SimpleTest {
|
|
|
|
public static void main(String[] args) throws ParameterException, Exception {
|
|
TokenSetter.set("/d4science.research-infrastructures.eu/gCubeApps");
|
|
AccountingDao dao=AccountingDao.get(new DummyContextTreeProvider());
|
|
|
|
ScopeDescriptor desc=dao.getTree(null);
|
|
|
|
|
|
System.out.println(desc);
|
|
|
|
Date from=new GregorianCalendar(2015,1,1).getTime();
|
|
Date to=new Date(System.currentTimeMillis());
|
|
|
|
scan(desc,from,to,dao);
|
|
|
|
|
|
System.out.println(Queries.asIDSet(desc));
|
|
|
|
}
|
|
|
|
private static void scan(ScopeDescriptor desc, Date from, Date to, AccountingDao dao) throws ParameterException, SQLException {
|
|
System.out.println("**********************************************************************************************************");
|
|
System.out.println(desc);
|
|
System.out.println(dao.getReportByScope(desc, from, to, MeasureResolution.MONTHLY));
|
|
if(desc.hasChildren()) {
|
|
for(ScopeDescriptor child:desc.getChildren())
|
|
scan(child,from,to,dao);
|
|
}
|
|
}
|
|
|
|
|
|
}
|