private List<CatalogEntry> queryCountries() throws SQLException { List<CatalogEntry> entries = new ArrayList<>(); try(ResultSet rs = executor.query("SELECT iso2, name FROM country ORDER BY name")) { while(rs.next()) { entries.add(new CatalogEntry( countryId(rs.getString(1)), rs.getString(2), CatalogEntryType.FOLDER)); } } return entries; }
@Override public CatalogEntry apply(AnalysisEntity analysisEntity) { return new CatalogEntry(analysisEntity.getId(), analysisEntity.getLabel(), CatalogEntryType.ANALYSIS); } });
public CatalogEntry getRootEntry() { return new CatalogEntry(GEODB_ID.asString(), I18N.CONSTANTS.geography(), CatalogEntryType.FOLDER); }
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 " + "dateDeleted 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; }
public static CatalogEntry fromJson(JsonValue jsonElement) { JsonValue jsonObject = jsonElement; CatalogEntry model = new CatalogEntry(); model.id = jsonObject.get("id").asString(); model.type = CatalogEntryType.valueOf(jsonObject.get("type").asString().toUpperCase()); model.label = jsonObject.get("label").asString(); model.leaf = jsonObject.getBoolean("leaf"); return model; }
private static CatalogEntry buildCatalogEntry(Resource.Node node) { CatalogEntry entry = new CatalogEntry(node.getResource().getId().asString(), node.getResource().getLabel(), catalogType(node.getResource().getType())); entry.setLeaf(node.isLeaf()); return entry; }