ISOMetadataStore implements MetadataStore<ISORecord> { public int getRecordCount( final MetadataQuery query ) throws MetadataStoreException { final String resultTypeName = "hits"; LOG.debug( Messages.getMessage( "INFO_EXEC", "do " + resultTypeName + " on getRecords" ) ); try { QueryService queryService = getReadOnlySqlService(); return queryService.executeCounting( query, getConnection() ); } catch ( Throwable t ) { LOG.debug( t.getMessage(), t ); String msg = Messages.getMessage( "ERROR_REQUEST_TYPE", ResultType.results.name(), t.getMessage() ); LOG.debug( msg ); throw new MetadataStoreException( msg ); } finally { } } ISOMetadataStore( ISOMetadataStoreConfig config, SQLDialect dialect,
                             ResourceMetadata<MetadataStore<? extends MetadataRecord>> metadata, Workspace workspace ); @Override void destroy(); @Override String getConnId(); @Override void init(); @Override MetadataResultSet<ISORecord> getRecords( final MetadataQuery query ); int getRecordCount( final MetadataQuery query ); @Override MetadataResultSet<ISORecord> getRecordById( final List<String> idList, final QName[] recordTypeNames ); @Override MetadataStoreTransaction acquireTransaction(); @Override String getType(); List<Queryable> getQueryables(); @Override ResourceMetadata<? extends Resource> getMetadata(); static final int DEFAULT_FETCH_SIZE; }
@Test public void testBBoxFilter() throws Exception { LOG.info( "START Test: testInsert" ); initStore( TstConstants.configURL ); Assume.assumeNotNull( store ); TstUtils.insertMetadata( store, TstConstants.tst_9, TstConstants.tst_10, TstConstants.tst_1 ); GeometryFactory gf = new GeometryFactory(); ValueReference pn = new ValueReference( "ows:BoundingBox", nsContext ); Operator op = new BBOX( pn, gf.createEnvelope( 7.30, 49.30, 10.70, 51.70, CRSUtils.EPSG_4326 ) ); Filter filter = new OperatorFilter( op ); MetadataQuery query = new MetadataQuery( null, null, filter, null, 1, 10 ); store.getRecordCount( query ); }
@Test public void testKeywordFilter() throws Exception { LOG.info( "START Test: testInsert" ); initStore( TstConstants.configURL ); Assume.assumeNotNull( store ); TstUtils.insertMetadata( store, TstConstants.tst_9, TstConstants.tst_10, TstConstants.tst_1 ); Literal<PrimitiveValue> lit1 = new Literal<PrimitiveValue>( "Hessen Wasser Analyser" ); Operator op1 = new PropertyIsEqualTo( new ValueReference( "Title", nsContext ), lit1, true, null ); Literal<PrimitiveValue> lit2 = new Literal<PrimitiveValue>( "%Karte%" ); Operator op2 = new PropertyIsLike( new ValueReference( "Subject", nsContext ), lit2, "%", "_", "?", true, null ); Operator op = new And( op1, op2 ); Filter filter = new OperatorFilter( op ); MetadataQuery query = new MetadataQuery( null, null, filter, null, 1, 10 ); store.getRecordCount( query ); }
@Test public void testEqualKeywordFilter() throws Exception { LOG.info( "START Test: testInsert" ); initStore( TstConstants.configURL ); Assume.assumeNotNull( store ); TstUtils.insertMetadata( store, TstConstants.tst_9, TstConstants.tst_10 ); Literal<PrimitiveValue> lit2 = new Literal<PrimitiveValue>( "SPOT 5" ); Operator op = new PropertyIsEqualTo( new ValueReference( "Subject", nsContext ), lit2, true, null ); Filter filter = new OperatorFilter( op ); MetadataQuery query = new MetadataQuery( null, null, filter, null, 1, 10 ); int recordCount = store.getRecordCount( query ); Assert.assertEquals( 1, recordCount ); }