@Override public int getRecordsCount(Query q, Transaction t) throws IOException { // simply delegate to the feature collection, we have no optimizations // available for the time being (even counting the files in case of no filtering // would be wrong as we have to return getRecords(q, t, null).size(); }
q.setProperties(Arrays.asList(translateProperty(rd, attributeName))); getRecords(q, Transaction.AUTO_COMMIT, rd.getOutputSchema()) .accepts( new FeatureVisitor() {
@Test public void testNamespaceSupport() throws IOException, URISyntaxException { AbstractCatalogStore store = new AbstractCatalogStore() { { support(CSWRecordDescriptor.getInstance()); support(GSRecordDescriptor.getInstance()); } @Override public FeatureCollection getRecordsInternal(RecordDescriptor rd, RecordDescriptor rdOutput, Query q, Transaction t) throws IOException { if(rd == GSRecordDescriptor.getInstance()) { return new MemoryFeatureCollection(GSRecordDescriptor.getInstance().getFeatureType()); } else { throw new RuntimeException("Was expecting the geoserver record descriptor"); } } }; RecordDescriptor[] descriptors = store.getRecordDescriptors(); assertEquals(2, descriptors.length); assertEquals(CSWRecordDescriptor.getInstance(), descriptors[0]); assertEquals(GSRecordDescriptor.getInstance(), descriptors[1]); Query query = new Query("Record"); query.setNamespace(new URI(GSRecordDescriptor.GS_NAMESPACE)); FeatureCollection records = store.getRecords(query, Transaction.AUTO_COMMIT, null); assertEquals(GSRecordDescriptor.getInstance().getFeatureType(), records.getSchema()); }
@Override public FeatureCollection getRecords(Query q, Transaction t, String outputSchema) throws IOException { RecordDescriptor rd; Name typeName = null; if (q.getTypeName() == null) { typeName = CSWRecordDescriptor.RECORD_DESCRIPTOR.getName(); } else if (q.getNamespace() != null) { typeName = new NameImpl(q.getNamespace().toString(), q.getTypeName()); } else { typeName = new NameImpl(q.getTypeName()); } rd = descriptorByType.get(typeName); RecordDescriptor rdOutput; if (outputSchema == null || "".equals(outputSchema)) { rdOutput = descriptorByOutputSchema.get( CSWRecordDescriptor.getInstance().getOutputSchema()); } else { rdOutput = descriptorByOutputSchema.get(outputSchema); } if (rd == null) { throw new IOException(q.getTypeName() + " is not a supported type"); } if (rdOutput == null) { throw new IOException(outputSchema + " is not a supported output schema"); } return getRecordsInternal(rd, rdOutput, q, t); }