use of com.extjs.gxt.ui.client.data.SortInfo in project activityinfo by bedatadriven.
the class ImportWithMultiClassRangeTest method testSimple.
@Test
public void testSimple() throws IOException {
setUser(3);
FormTree formTree = assertResolves(locator.getFormTree(NFI_DISTRIBUTION_FORM_CLASS));
FormTreePrettyPrinter.print(formTree);
importModel = new ImportModel(formTree);
importer = new Importer(locator, formTree, FieldImportStrategies.get(JvmConverterFactory.get()));
// Step 1: User pastes in data to import
PastedTable source = new PastedTable(Resources.toString(getResource(getClass(), "nfi.csv"), Charsets.UTF_8));
source.parseAllRows();
importModel.setSource(source);
dumpList("COLUMNS", source.getColumns());
importModel.setColumnAction(columnIndex("Date1"), target("Start Date"));
importModel.setColumnAction(columnIndex("Date2"), target("End Date"));
importModel.setColumnAction(columnIndex("Partner"), target("Partner Name"));
importModel.setColumnAction(columnIndex("Localité"), target("Localité Name"));
importModel.setColumnAction(columnIndex("Province"), target("Province Name"));
importModel.setColumnAction(columnIndex("District"), target("District Name"));
importModel.setColumnAction(columnIndex("Territoire"), target("Territoire Name"));
importModel.setColumnAction(columnIndex("Secteur"), target("Secteur Name"));
importModel.setColumnAction(columnIndex("Groupement"), target("Groupement Name"));
importModel.setColumnAction(columnIndex("Zone de Santé"), target("Zone de Santé Name"));
importModel.setColumnAction(columnIndex("Nombre de ménages ayant reçu une assistance en NFI"), target("Nombre de ménages ayant reçu une assistance en NFI"));
ValidatedRowTable validatedResult = assertResolves(importer.validateRows(importModel));
showValidationGrid(validatedResult);
assertResolves(importer.persist(importModel));
GetSites query = new GetSites(Filter.filter().onActivity(33));
query.setSortInfo(new SortInfo("date2", Style.SortDir.DESC));
SiteResult result = execute(query);
// 651 - 8 = 643 (8 records where start date is before end date)
assertThat(result.getTotalLength(), equalTo(643));
// assertThat(result.getTotalLength(), equalTo(313));
SiteDTO lastSite = result.getData().get(0);
// assertThat(lastSite.getDate2(), equalTo(new LocalDate(2013,4,26)));
assertThat(lastSite.getDate2(), equalTo(new LocalDate(2013, 4, 30)));
assertThat(lastSite.getLocationName(), equalTo("Kilimani Camp"));
assertThat(lastSite.getAdminEntity(PROVINCE_LEVEL).getName(), equalTo("Nord Kivu"));
assertThat(lastSite.getAdminEntity(DISTRICT_LEVEL).getName(), equalTo("Nord Kivu"));
assertThat(lastSite.getAdminEntity(TERRITOIRE_LEVEL).getName(), equalTo("Masisi"));
assertThat(lastSite.getAdminEntity(SECTEUR_LEVEL).getName(), equalTo("Masisi"));
assertThat((Double) lastSite.getIndicatorValue(NUMBER_MENAGES), equalTo(348.0));
assertThat(lastSite.getAttributeValue(ECHO), equalTo(false));
}
use of com.extjs.gxt.ui.client.data.SortInfo in project activityinfo by bedatadriven.
the class TableGenerator method generateData.
public TableData generateData(TableElement element, Filter filter) {
GetSites query = new GetSites(filter);
if (!element.getSortBy().isEmpty()) {
TableColumn sortBy = element.getSortBy().get(0);
query.setSortInfo(new SortInfo(sortBy.getSitePropertyName(), sortBy.isOrderAscending() ? SortDir.ASC : SortDir.DESC));
}
SiteResult sites = getDispatcher().execute(query);
return new TableData(element.getRootColumn(), sites.getData());
}
use of com.extjs.gxt.ui.client.data.SortInfo in project activityinfo by bedatadriven.
the class GetSitesTest method testGetPublicSites.
@Test
@OnDataSet("/dbunit/sites-public.db.xml")
public void testGetPublicSites() throws CommandException {
int anonnoymsUserID = 0;
setUser(anonnoymsUserID);
GetSites cmd = new GetSites();
cmd.filter().onActivity(1);
cmd.setSortInfo(new SortInfo("date2", SortDir.DESC));
PagingLoadResult<SiteDTO> result = execute(cmd);
Assert.assertEquals("totalLength", 3, result.getData().size());
Assert.assertEquals("totalLength", 3, result.getTotalLength());
Assert.assertEquals("offset", 0, result.getOffset());
// Assert.assertNull("row(0).activity",
// result.getData().get(0).getActivity());
// assure sorted
Assert.assertEquals("sorted", 2, result.getData().get(0).getId());
Assert.assertEquals("sorted", 1, result.getData().get(1).getId());
Assert.assertEquals("sorted", 3, result.getData().get(2).getId());
// assure indicators are present (site id=3)
SiteDTO s = result.getData().get(2);
Assert.assertEquals("entityName", "Ituri", s.getAdminEntity(1).getName());
Assert.assertNotNull("admin bounds", s.getAdminEntity(1).getBounds());
Assert.assertThat("indicator", (Double) s.getIndicatorValue(1), equalTo(10000.0));
Assert.assertNull("site x", s.getX());
// assure project is present
SiteDTO s1 = result.getData().get(1);
assertThat(s1.getId(), equalTo(1));
assertThat(s1.getProject().getId(), equalTo(1));
}
use of com.extjs.gxt.ui.client.data.SortInfo in project activityinfo by bedatadriven.
the class GetSitesTest method testActivityQueryPaged.
@Ignore
@Test
public void testActivityQueryPaged() throws CommandException {
setUser(DATABASE_OWNER);
GetSites cmd = new GetSites();
cmd.filter().onActivity(1);
cmd.setSortInfo(new SortInfo(IndicatorDTO.getPropertyName(1), SortDir.DESC));
cmd.setLimit(2);
cmd.setOffset(0);
PagingLoadResult<SiteDTO> result = execute(cmd);
assertThat("offset", result.getOffset(), equalTo(0));
cmd.setOffset(1);
cmd.setLimit(2);
result = execute(cmd);
assertThat(result.getOffset(), equalTo(1));
assertThat(result.getData().size(), equalTo(2));
assertThat("total length", result.getTotalLength(), equalTo(3));
cmd.setOffset(0);
cmd.setLimit(50);
result = execute(cmd);
assertThat(result.getOffset(), equalTo(0));
assertThat(result.getData().size(), equalTo(3));
assertThat("total length", result.getTotalLength(), equalTo(3));
}
use of com.extjs.gxt.ui.client.data.SortInfo in project activityinfo by bedatadriven.
the class GetSitesTest method linkedSites.
@Test
@OnDataSet("/dbunit/sites-linked.db.xml")
public void linkedSites() {
setUser(1);
GetSites cmd = new GetSites();
cmd.filter().addRestriction(DimensionType.Activity, 1);
cmd.setSortInfo(new SortInfo("locationName", SortDir.ASC));
SiteResult result = execute(cmd);
assertThat(result.getData().size(), equalTo(2));
SiteDTO site1 = result.getData().get(0);
SiteDTO site2 = result.getData().get(1);
System.out.println(site1.getProperties());
System.out.println(site2.getProperties());
assertThat(site1.getId(), equalTo(1));
assertThat(site1.getLocationName(), equalTo("Penekusu Kivu"));
assertThat(site1.getActivityId(), equalTo(1));
assertThat((Double) site1.getIndicatorValue(1), equalTo(1500d));
assertThat(site2.getId(), equalTo(2));
assertThat(site2.getLocationName(), equalTo("Penekusu Kivu 2"));
assertThat(site2.getActivityId(), equalTo(1));
assertThat((Double) site2.getIndicatorValue(1), equalTo(400d));
}
Aggregations