org.geotools.data.Transaction Java Examples
The following examples show how to use
org.geotools.data.Transaction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IFeatureShape.java From hortonmachine with GNU General Public License v3.0 | 7 votes |
/** * Add a feature to the store. * * @param feature the feature to add. */ default public void addFeature( SimpleFeature feature) { FeatureStoreInfo featureStoreInfo = getFeatureStoreInfo(); SimpleFeatureStore featureStore = featureStoreInfo.getFeatureStore(); if (featureStore != null) { Transaction transaction = new DefaultTransaction("add"); featureStore.setTransaction(transaction); try { DefaultFeatureCollection fc = new DefaultFeatureCollection(); fc.add(feature); featureStore.addFeatures(fc); transaction.commit(); } catch (Exception eek) { try { transaction.rollback(); } catch (IOException e) { e.printStackTrace(); } } } }
Example #2
Source File: GeoWaveFeatureReaderTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void testLike() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException { final Query query = new Query( "GeoWaveFeatureReaderTest", ECQL.toFilter("pid like '" + pids.get( 0).substring( 0, 1) + "%'"), new String[] { "geometry", "pid" }); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int count = 0; while (reader.hasNext()) { final SimpleFeature feature = reader.next(); assertTrue(fids.contains(feature.getID())); count++; } assertEquals(1, count); }
Example #3
Source File: MemoryLockManagerTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testLockReleaseOfBulkAuthLock() throws InterruptedException, IOException { final LockingManagement memoryLockManager = new MemoryLockManager("default"); final Transaction t1 = Transaction.AUTO_COMMIT; final DefaultTransaction t2 = new DefaultTransaction(); t2.addAuthorization("auth1"); final FeatureLock lock = new FeatureLock("auth1", 1 /* minute */); memoryLockManager.lockFeatureID("sometime", "f4", t1, lock); memoryLockManager.lock(t2, "f4"); t2.commit(); // commit should not take away the lock assertTrue(memoryLockManager.exists("auth1")); memoryLockManager.release("auth1", t1); assertFalse(memoryLockManager.exists("auth1")); t1.close(); }
Example #4
Source File: GeoWaveFeatureReaderTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testLike() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException { System.out.println(pids); final Query query = new Query( "GeoWaveFeatureReaderTest", ECQL.toFilter("pid like '" + pids.get(0).substring(0, 1) + "%'"), new String[] {"geometry", "pid"}); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int count = 0; while (reader.hasNext()) { final SimpleFeature feature = reader.next(); assertTrue(fids.contains(feature.getID())); count++; } assertEquals(1, count); }
Example #5
Source File: GeoWaveEmptyTransaction.java From geowave with Apache License 2.0 | 6 votes |
/** * Record a modification to the indicated fid * * @param fid * @param original the original feature(prior state) * @param updated the update feature replacement feature; null to indicate remove */ @Override public void modify(final String fid, final SimpleFeature original, final SimpleFeature updated) throws IOException { // point move? if (!updated.getBounds().equals(original.getBounds())) { components.remove(original, this); components.writeCommit(updated, new GeoWaveEmptyTransaction(components)); } else { components.writeCommit(updated, new GeoWaveEmptyTransaction(components)); } final ReferencedEnvelope bounds = new ReferencedEnvelope(); bounds.include(updated.getBounds()); bounds.include(original.getBounds()); components.getGTstore().getListenerManager().fireFeaturesChanged( updated.getFeatureType().getTypeName(), Transaction.AUTO_COMMIT, bounds, true); }
Example #6
Source File: GeoWaveFeatureReaderTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testBBOX() throws IllegalArgumentException, NoSuchElementException, IOException { final FilterFactoryImpl factory = new FilterFactoryImpl(); final Query query = new Query( "GeoWaveFeatureReaderTest", factory.bbox("geometry", -180, -90, 180, 90, "EPSG:4326"), new String[] {"geometry", "pid"}); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int count = 0; while (reader.hasNext()) { final SimpleFeature feature = reader.next(); assertTrue(fids.contains(feature.getID())); count++; } assertTrue(count > 0); }
Example #7
Source File: GeoWaveGTDataStore.java From geowave with Apache License 2.0 | 6 votes |
/** * Used to retrieve the TransactionStateDiff for this transaction. * * <p> * * @param transaction * @return GeoWaveTransactionState or null if subclass is handling differences * @throws IOException */ protected GeoWaveTransactionState getMyTransactionState( final Transaction transaction, final GeoWaveFeatureSource source) throws IOException { synchronized (transaction) { GeoWaveTransactionState state = null; if (transaction == Transaction.AUTO_COMMIT) { state = new GeoWaveAutoCommitTransactionState(source); } else { state = (GeoWaveTransactionState) transaction.getState(this); if (state == null) { state = new GeoWaveTransactionManagementState( transactionBufferSize, source.getComponents(), transaction, (LockingManagement) lockingManager); transaction.putState(this, state); } } return state; } }
Example #8
Source File: GeoWaveFeatureReaderTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testSmallBBOX() throws IllegalArgumentException, NoSuchElementException, IOException { final FilterFactoryImpl factory = new FilterFactoryImpl(); final Query query = new Query( "GeoWaveFeatureReaderTest", factory.bbox("geometry", 28, 41, 28.5, 41.5, "EPSG:4326"), new String[] {"geometry", "pid"}); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int count = 0; while (reader.hasNext()) { final SimpleFeature feature = reader.next(); assertTrue(fids.contains(feature.getID())); count++; } assertEquals(1, count); }
Example #9
Source File: GeoToolsAttributesSubsetTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testSubsetAttributes() throws CQLException, IOException { final Query query = new Query( typeName, CQL.toFilter(cqlPredicate), new String[] {geometry_attribute, string_attribute}); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = geotoolsDataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int count = 0; while (reader.hasNext()) { final SimpleFeature feature = reader.next(); count++; Assert.assertTrue(feature.getAttribute(geometry_attribute) != null); Assert.assertTrue(feature.getAttribute(long_attribute) == null); Assert.assertTrue(feature.getAttribute(string_attribute) != null); } Assert.assertTrue(count == 3); }
Example #10
Source File: GeoWaveEmptyTransaction.java From geowave with Apache License 2.0 | 6 votes |
@Override public void add(final String fid, final SimpleFeature feature) throws IOException { feature.getUserData().put(Hints.USE_PROVIDED_FID, true); if (feature.getUserData().containsKey(Hints.PROVIDED_FID)) { final String providedFid = (String) feature.getUserData().get(Hints.PROVIDED_FID); feature.getUserData().put(Hints.PROVIDED_FID, providedFid); } else { feature.getUserData().put(Hints.PROVIDED_FID, feature.getID()); } components.writeCommit(feature, this); components.getGTstore().getListenerManager().fireFeaturesAdded( components.getAdapter().getFeatureType().getTypeName(), Transaction.AUTO_COMMIT, ReferencedEnvelope.reference(feature.getBounds()), true); }
Example #11
Source File: WFSTemporalQueryTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testTemporal() throws CQLException, IOException, ParseException { populate(); final Transaction transaction2 = new DefaultTransaction(); final Query query = new Query( "geostuff", CQL.toFilter( "BBOX(geometry,44,27,42,30) and start during 2005-05-16T20:32:56Z/2005-05-20T21:32:56Z and end during 2005-05-18T20:32:56Z/2005-05-22T21:32:56Z"), new String[] {"geometry", "start", "end", "pid"}); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, transaction2); int c = 0; while (reader.hasNext()) { reader.next(); c++; } reader.close(); transaction2.commit(); transaction2.close(); assertEquals(2, c); }
Example #12
Source File: GeoWaveFeatureReaderTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void testPidFilterQuery() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException { // Filter it so that it only queries for everything but the first pid. // There's only 2 pids total so it should just return the second one. final String pidsString = pids.subList(1, pids.size()).stream().collect(Collectors.joining("','", "'", "'")); final Filter filter = ECQL.toFilter("pid IN (" + pidsString + ")"); final Query query = new Query( "GeoWaveFeatureReaderTest", filter, new String[] { "geometry", "pid" }); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int count = 0; while (reader.hasNext()) { final SimpleFeature feature = reader.next(); assertTrue(fids.contains(feature.getID())); count++; } assertTrue(count == pids.size() - 1); }
Example #13
Source File: GeoWaveFeatureReaderTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void testFidFilterQuery() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException { final String fidsString = fids.stream().collect(Collectors.joining("','", "'", "'")); final Filter filter = ECQL.toFilter("IN (" + fidsString + ")"); final Query query = new Query( "GeoWaveFeatureReaderTest", filter, new String[] { "geometry", "pid" }); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int count = 0; while (reader.hasNext()) { final SimpleFeature feature = reader.next(); assertTrue(fids.contains(feature.getID())); count++; } assertTrue(count == fids.size()); }
Example #14
Source File: GeoWaveTransactionManagement.java From geowave with Apache License 2.0 | 6 votes |
/** * Create an empty Diff * * @throws IOException */ public GeoWaveTransactionManagement( final int maxAdditionBufferSize, final GeoWaveDataStoreComponents components, final String typeName, final Transaction transaction, final LockingManagement lockingManager, final String txID) throws IOException { super(components); this.maxAdditionBufferSize = maxAdditionBufferSize; mutex = this; this.typeName = typeName; this.transaction = transaction; this.lockingManager = lockingManager; this.txID = txID; }
Example #15
Source File: GeoWaveTransactionManagementState.java From geowave with Apache License 2.0 | 6 votes |
@Override public synchronized void setTransaction(final Transaction transaction) { if (transaction != null) { // configure this.transaction = transaction; } else { this.transaction = null; if (typeNameDiff != null) { for (final Iterator<GeoWaveTransactionManagement> i = typeNameDiff.values().iterator(); i.hasNext();) { final GeoWaveTransactionManagement diff = i.next(); diff.clear(); } typeNameDiff.clear(); } } }
Example #16
Source File: ShapeFile.java From tutorials with MIT License | 5 votes |
private static void writeToFile(ShapefileDataStore dataStore, DefaultFeatureCollection collection) throws Exception { // If you decide to use the TYPE type and create a Data Store with it, // You will need to uncomment this line to set the Coordinate Reference System // newDataStore.forceSchemaCRS(DefaultGeographicCRS.WGS84); Transaction transaction = new DefaultTransaction("create"); String typeName = dataStore.getTypeNames()[0]; SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeName); if (featureSource instanceof SimpleFeatureStore) { SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource; featureStore.setTransaction(transaction); try { featureStore.addFeatures(collection); transaction.commit(); } catch (Exception problem) { problem.printStackTrace(); transaction.rollback(); } finally { transaction.close(); } System.exit(0); // success! } else { System.out.println(typeName + " does not support read/write access"); System.exit(1); } }
Example #17
Source File: WFSSpatialTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void test() throws IOException, CQLException, ParseException { final Transaction transaction1 = new DefaultTransaction(); final FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore.getFeatureWriter(type.getTypeName(), transaction1); assertFalse(writer.hasNext()); SimpleFeature newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(100)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("when", DateUtilities.parseISO("2005-05-19T18:33:55Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(27.25, 41.25))); newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(100)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("when", DateUtilities.parseISO("2005-05-19T20:33:55Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(27.25, 41.25))); writer.write(); writer.close(); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, transaction1); assertTrue(reader.hasNext()); final SimpleFeature priorFeature = reader.next(); assertEquals(newFeature.getAttribute("pid"), priorFeature.getAttribute("pid")); assertFalse(reader.hasNext()); reader.close(); transaction1.commit(); transaction1.close(); }
Example #18
Source File: ShpParser.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
public void write(SimpleFeatureCollection obj, OutputStream output, SimpleFeatureType sft, String layerId) throws IOException { File shpFile = File.createTempFile("shpFile", ".shp"); ShapefileDataStoreFactory fact = new ShapefileDataStoreFactory(); Map<String, Serializable> params = new HashMap<String, Serializable>(); params.put(ShapefileDataStoreFactory.URLP.key, shpFile.toURI().toURL()); params.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key, Boolean.TRUE); ShapefileDataStore shpDataStore = (ShapefileDataStore) fact.createNewDataStore(params); shpDataStore.createSchema(sft); SimpleFeatureStore store = (SimpleFeatureStore) shpDataStore.getFeatureSource(shpDataStore.getTypeNames()[0]); Transaction transaction = new DefaultTransaction("create"); store.setTransaction(transaction); store.addFeatures(obj); transaction.commit(); ZipOutputStream os = new ZipOutputStream(output); final String fileName = shpFile.getName().substring(0, shpFile.getName().lastIndexOf(".")); File[] shpFiles = new File(shpFile.getParent()).listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.contains(fileName); } }); for (File file : shpFiles) { os.putNextEntry(new ZipEntry(layerId + file.getName().substring(file.getName().lastIndexOf(".")))); IOUtils.copy(new FileInputStream(file), os); file.delete(); } os.close(); output.flush(); }
Example #19
Source File: TemporalRangeTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void test() throws ParseException, IOException { final Calendar gmt = Calendar.getInstance(TimeZone.getTimeZone("GMT")); final Calendar local = Calendar.getInstance(TimeZone.getTimeZone("EDT")); local.setTimeInMillis(gmt.getTimeInMillis()); final TemporalRange rGmt = new TemporalRange(gmt.getTime(), gmt.getTime()); final TemporalRange rLocal = new TemporalRange(local.getTime(), local.getTime()); rGmt.fromBinary(rGmt.toBinary()); assertEquals(gmt.getTime(), rGmt.getEndTime()); assertEquals(rLocal.getEndTime(), rGmt.getEndTime()); assertEquals(rLocal.getEndTime().getTime(), rGmt.getEndTime().getTime()); final Transaction transaction1 = new DefaultTransaction(); final FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore.getFeatureWriter(type.getTypeName(), transaction1); final SimpleFeature newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(77)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("when", DateUtilities.parseISO("2005-05-19T19:32:56-04:00")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 28.232))); final FeatureTimeRangeStatistics stats = new FeatureTimeRangeStatistics(null, "when"); stats.entryIngested(newFeature); assertEquals( DateUtilities.parseISO("2005-05-19T23:32:56Z"), stats.asTemporalRange().getStartTime()); }
Example #20
Source File: WFSTemporalQueryTest.java From geowave with Apache License 2.0 | 5 votes |
public void populate() throws IOException, CQLException, ParseException { final Transaction transaction1 = new DefaultTransaction(); final FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore.getFeatureWriter(type.getTypeName(), transaction1); assertFalse(writer.hasNext()); SimpleFeature newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(100)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("start", DateUtilities.parseISO("2005-05-17T20:32:56Z")); newFeature.setAttribute("end", DateUtilities.parseISO("2005-05-19T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 28.232))); writer.write(); newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(100)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("start", DateUtilities.parseISO("2005-05-18T20:32:56Z")); newFeature.setAttribute("end", DateUtilities.parseISO("2005-05-20T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 27.232))); writer.write(); newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(100)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("start", DateUtilities.parseISO("2005-05-21T20:32:56Z")); newFeature.setAttribute("end", DateUtilities.parseISO("2005-05-22T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 28.232))); writer.write(); writer.close(); transaction1.commit(); transaction1.close(); }
Example #21
Source File: GeoToolsAttributesSubsetTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void testAllAttributes() throws CQLException, IOException { final Query query = new Query(typeName, CQL.toFilter(cqlPredicate), Query.ALL_PROPERTIES); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = geotoolsDataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int count = 0; while (reader.hasNext()) { final SimpleFeature feature = reader.next(); count++; Assert.assertTrue(feature.getAttribute(geometry_attribute) != null); Assert.assertTrue(feature.getAttribute(long_attribute) != null); Assert.assertTrue(feature.getAttribute(string_attribute) != null); } Assert.assertTrue(count == 3); }
Example #22
Source File: GeoWaveFeatureSourceTest.java From geowave with Apache License 2.0 | 5 votes |
@Override public void populate(final SimpleFeatureType type, final DataStore dataStore) throws IOException, CQLException, ParseException { dataStore.createSchema(type); final Transaction transaction1 = new DefaultTransaction(); final FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore.getFeatureWriter(type.getTypeName(), transaction1); assertFalse(writer.hasNext()); SimpleFeature newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(77)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("when", DateUtilities.parseISO("2005-05-19T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 28.232))); writer.write(); newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(66)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("when", DateUtilities.parseISO("2005-05-18T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 27.232))); writer.write(); newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(100)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("when", DateUtilities.parseISO("2005-05-17T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 28.242))); writer.write(); writer.close(); transaction1.commit(); transaction1.close(); }
Example #23
Source File: AbstractLockingManagement.java From geowave with Apache License 2.0 | 5 votes |
@Override public boolean release(final String authID, final Transaction transaction) throws IOException { AuthorizedLock lock = transaction == Transaction.AUTO_COMMIT ? null : (AuthorizedLock) transaction.getState(this); if (lock == null) { lock = new AuthorizedLock(this, authID, 1 /* minutes */); } releaseAll(lock); return true; }
Example #24
Source File: GeoToolsAttributesSubsetTest.java From geowave with Apache License 2.0 | 5 votes |
@Before public void setup() throws IOException, GeoWavePluginException, SchemaException { geotoolsDataStore = createDataStore(); type = DataUtilities.createType(typeName, typeSpec); geotoolsDataStore.createSchema(type); final Transaction transaction = new DefaultTransaction(); final FeatureWriter<SimpleFeatureType, SimpleFeature> writer = geotoolsDataStore.getFeatureWriter(type.getTypeName(), transaction); assertFalse(writer.hasNext()); SimpleFeature newFeature = writer.next(); newFeature.setAttribute( geometry_attribute, GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(41.25, 41.25))); newFeature.setAttribute(long_attribute, 1l); newFeature.setAttribute(string_attribute, "string1"); writer.write(); newFeature = writer.next(); newFeature.setAttribute( geometry_attribute, GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(41.5, 41.5))); newFeature.setAttribute(long_attribute, 2l); newFeature.setAttribute(string_attribute, "string2"); writer.write(); newFeature = writer.next(); newFeature.setAttribute( geometry_attribute, GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(41.75, 41.75))); newFeature.setAttribute(long_attribute, 3l); newFeature.setAttribute(string_attribute, "string3"); writer.write(); writer.close(); transaction.commit(); transaction.close(); }
Example #25
Source File: GeoWaveFeatureReaderTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void testMax() throws IllegalArgumentException, NoSuchElementException, IOException { final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); final MaxVisitor visitor = new MaxVisitor("start", type); unwrapDelegatingFeatureReader(reader).getFeatureCollection().accepts(visitor, null); assertTrue(visitor.getMax().equals(mtime)); }
Example #26
Source File: GeoWaveFeatureReaderTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void testRangeIndex() throws IllegalArgumentException, NoSuchElementException, IOException { final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int count = 0; while (reader.hasNext()) { final SimpleFeature feature = reader.next(); assertTrue(fids.contains(feature.getID())); count++; } assertEquals(1, count); }
Example #27
Source File: GeoWaveFeatureReaderTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void testFID() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException { final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int count = 0; while (reader.hasNext()) { final SimpleFeature feature = reader.next(); assertTrue(fids.contains(feature.getID())); count++; } assertTrue(count > 0); }
Example #28
Source File: WFSBoundedSpatialQueryTest.java From geowave with Apache License 2.0 | 5 votes |
public void populate() throws IOException, CQLException, ParseException { final Transaction transaction1 = new DefaultTransaction(); final FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore.getFeatureWriter(type.getTypeName(), transaction1); assertFalse(writer.hasNext()); SimpleFeature newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(100)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("when", DateUtilities.parseISO("2005-05-19T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 28.232))); writer.write(); newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(100)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("when", DateUtilities.parseISO("2005-05-18T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 27.232))); writer.write(); newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(100)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("when", DateUtilities.parseISO("2005-05-17T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 28.232))); writer.write(); writer.close(); transaction1.commit(); transaction1.close(); }
Example #29
Source File: AbstractLockingManagement.java From geowave with Apache License 2.0 | 5 votes |
@Override public boolean refresh(final String authID, final Transaction transaction) throws IOException { AuthorizedLock lock = transaction == Transaction.AUTO_COMMIT ? null : (AuthorizedLock) transaction.getState(this); if (lock == null) { lock = new AuthorizedLock(this, authID, 1 /* minutes */); } resetAll(lock); return true; }
Example #30
Source File: AbstractLockingManagement.java From geowave with Apache License 2.0 | 5 votes |
private void unlock( final Transaction transaction, final String featureID, final Set<String> authorizations, final long expiryInMinutes) { AuthorizedLock lock = transaction == Transaction.AUTO_COMMIT ? null : (AuthorizedLock) transaction.getState(this); if (lock == null) { lock = new AuthorizedLock(this, authorizations, expiryInMinutes); if (transaction != Transaction.AUTO_COMMIT) { transaction.putState(this, lock); } } unlock(lock, featureID); }