Search in sources :

Example 6 with CatalogEntry

use of org.activityinfo.model.form.CatalogEntry in project activityinfo by bedatadriven.

the class GeodbFolder method queryCountryForms.

private List<CatalogEntry> queryCountryForms(String countryId) throws SQLException {
    List<CatalogEntry> entries = new ArrayList<>();
    // Query Admin Levels
    try (ResultSet rs = executor.query("SELECT adminlevelid, name FROM adminlevel WHERE countryId IN " + " (SELECT countryId FROM country WHERE iso2 = ?) ", countryId)) {
        while (rs.next()) {
            String formId = CuidAdapter.adminLevelFormClass(rs.getInt(1)).asString();
            String label = rs.getString(2);
            entries.add(new CatalogEntry(formId, label, CatalogEntryType.FORM));
        }
    }
    // Query Location Types
    try (ResultSet rs = executor.query("SELECT locationTypeId, name FROM locationtype WHERE " + "boundAdminLevelId IS NULL AND " + "databaseId IS NULL AND " + "countryId IN (SELECT countryId FROM country WHERE iso2 = ?)  ", countryId)) {
        while (rs.next()) {
            String formId = CuidAdapter.locationFormClass(rs.getInt(1)).asString();
            String label = rs.getString(2);
            entries.add(new CatalogEntry(formId, label, CatalogEntryType.FORM));
        }
    }
    return entries;
}
Also used : CatalogEntry(org.activityinfo.model.form.CatalogEntry) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet)

Example 7 with CatalogEntry

use of org.activityinfo.model.form.CatalogEntry in project activityinfo by bedatadriven.

the class CatalogView method openTable.

private void openTable(SelectEvent event) {
    if (treeView.getSelectedEntry().isLoaded() && treeView.getSelectedEntry().get().isPresent()) {
        CatalogEntry catalogEntry = treeView.getSelectedEntry().get().get();
        if (catalogEntry.getType() == CatalogEntryType.FORM) {
            String url = Window.Location.createUrlBuilder().setHash("table/" + catalogEntry.getId()).buildString();
            Window.open(url, null, null);
        } else if (catalogEntry.getType() == CatalogEntryType.ANALYSIS) {
            String url = Window.Location.createUrlBuilder().setHash("analysis/" + catalogEntry.getId()).buildString();
            Window.open(url, null, null);
        }
    }
}
Also used : CatalogEntry(org.activityinfo.model.form.CatalogEntry)

Aggregations

CatalogEntry (org.activityinfo.model.form.CatalogEntry)7 ArrayList (java.util.ArrayList)5 ResultSet (java.sql.ResultSet)4 FormClass (org.activityinfo.model.form.FormClass)1 FormField (org.activityinfo.model.form.FormField)1 ResourceId (org.activityinfo.model.resource.ResourceId)1 SubFormReferenceType (org.activityinfo.model.type.subform.SubFormReferenceType)1 FormStorage (org.activityinfo.store.spi.FormStorage)1