public static <E extends PropertyContainer> E set( E entity, Property... properties ) { for ( Property property : properties ) { entity.setProperty( property.key, property.value ); } return entity; }
private <E extends PropertyContainer> E properties( E entity ) { entity.setProperty( "short thing", "short" ); entity.setProperty( "long thing", "this is quite a long string, don't you think, it sure is long enough at least" ); entity.setProperty( "string array", new String[]{"these are a few", "cool strings", "for your viewing pleasure"} ); return entity; }
private WorkerCommand<Void, Object> setProperty( final PropertyContainer entity, final String key, final String value ) { return state -> { entity.setProperty( key, value ); return null; }; }
@Override Void perform( GraphDatabaseService graphDb ) { entity.setProperty( key, value ); return null; } };
private void setProperties( PropertyContainer entity, Map<String, Object> properties ) { for ( Map.Entry<String, Object> property : properties.entrySet() ) { entity.setProperty( property.getKey(), property.getValue() ); } }
Future<Void> setProperty( final String key, final Object value ) { return executeDontWait( state -> { state.properties.setProperty( key, value ); return null; } ); } }
private static void setProperties( PropertyContainer entity, Object... properties ) { for ( Map.Entry<String, Object> entry : MapUtil.map( properties ).entrySet() ) { entity.setProperty( entry.getKey(), entry.getValue() ); } }
entity.setProperty( key, value ); tx.success();
container.setProperty( entry.getKey(), entry.getValue() );
graphProperties.setProperty( "a", new String[]{"A", "B", "C", "D", "E"} ); graphProperties.setProperty( "b", true ); graphProperties.setProperty( "c", "C" ); tx.success(); graphProperties.setProperty( "d", new String[]{"A", "F"} ); graphProperties.setProperty( "e", true ); graphProperties.setProperty( "f", "F" ); tx.success(); graphProperties.setProperty( "g", new String[]{"F"} ); graphProperties.setProperty( "h", false ); graphProperties.setProperty( "i", "I" ); tx.success();
private static <T extends PropertyContainer> T init( T entity, String name, PROP[] properties, AutoIndexer<T> autoindex, boolean auto ) { autoindex.setEnabled( auto ); for ( PROP prop : properties ) { if ( auto ) { autoindex.startAutoIndexingProperty( prop.key() ); } PropType tpe = prop.type(); switch ( tpe ) { case ARRAY: entity.setProperty( prop.key(), tpe.convert( prop.componentType(), prop.value() ) ); break; default: entity.setProperty( prop.key(), prop.type().convert( prop.value() ) ); } } if ( name != null ) { if ( auto ) { autoindex.startAutoIndexingProperty( "name" ); } entity.setProperty( "name", name ); } return entity; }
private void setDefaults(Map<String, Key> keys, PropertyContainer pc) { if (keys.isEmpty()) return; for (Key key : keys.values()) { if (key.defaultValue!=null) pc.setProperty(key.name,key.defaultValue); } }
private <T extends PropertyContainer> T copyProperties(Map<String, Object> source, T target) { for (Map.Entry<String, Object> prop : source.entrySet()) target.setProperty(prop.getKey(), prop.getValue()); return target; }
graphProperties.setProperty( "test", "yo" ); assertEquals( "yo", graphProperties.getProperty( "test" ) ); tx.success(); assertEquals( "yo", graphProperties.removeProperty( "test" ) ); assertNull( graphProperties.getProperty( "test", null ) ); graphProperties.setProperty( "other", 10 ); assertEquals( 10, graphProperties.getProperty( "other" ) ); graphProperties.setProperty( "new", "third" ); tx.success(); tx.close(); graphProperties.setProperty( "rollback", true ); assertEquals( true, graphProperties.getProperty( "rollback" ) ); tx.close();
private EphemeralFileSystemAbstraction produceUncleanStore( EphemeralFileSystemAbstraction fileSystem, File storeDir ) { GraphDatabaseService db = new TestGraphDatabaseFactory().setFileSystem( fileSystem ).newImpermanentDatabase( storeDir ); Transaction tx = db.beginTx(); Node node = db.createNode(); node.setProperty( "name", "Something" ); properties( (GraphDatabaseAPI) db ).setProperty( "prop", "Some value" ); tx.success(); tx.close(); EphemeralFileSystemAbstraction snapshot = fileSystem.snapshot(); db.shutdown(); return snapshot; } }
@Test public void testEquals() { GraphDatabaseAPI db = (GraphDatabaseAPI) factory.newImpermanentDatabase(); PropertyContainer graphProperties = properties( db ); try ( Transaction tx = db.beginTx() ) { graphProperties.setProperty( "test", "test" ); tx.success(); } assertEquals( graphProperties, properties( db ) ); db.shutdown(); db = (GraphDatabaseAPI) factory.newImpermanentDatabase(); assertNotEquals( graphProperties, properties( db ) ); db.shutdown(); }
private <T extends PropertyContainer> void setProperty(T pc, String key, Object value) { if (value == null) pc.removeProperty(key); else pc.setProperty(key, toPropertyValue(value)); }
@Test public void setManyGraphProperties() { GraphDatabaseAPI db = (GraphDatabaseAPI) factory.newImpermanentDatabase(); Transaction tx = db.beginTx(); Object[] values = new Object[]{10, "A string value", new float[]{1234.567F, 7654.321F}, "A rather longer string which wouldn't fit inlined #!)(&¤"}; int count = 200; for ( int i = 0; i < count; i++ ) { properties( db ).setProperty( "key" + i, values[i % values.length] ); } tx.success(); tx.close(); for ( int i = 0; i < count; i++ ) { assertThat( properties( db ), inTx( db, hasProperty( "key" + i ).withValue( values[i % values.length] ) ) ); } for ( int i = 0; i < count; i++ ) { assertThat( properties( db ), inTx( db, hasProperty( "key" + i ).withValue( values[i % values.length] ) ) ); } db.shutdown(); }
@Test public void setBigArrayGraphProperty() { GraphDatabaseAPI db = (GraphDatabaseAPI) factory.newImpermanentDatabase(); long[] array = new long[1000]; for ( int i = 0; i < 10; i++ ) { array[array.length / 10 * i] = i; } String key = "big long array"; Transaction tx = db.beginTx(); properties( db ).setProperty( key, array ); assertThat( properties( db ), hasProperty( key ).withValue( array ) ); tx.success(); tx.close(); assertThat( properties( db ), inTx( db, hasProperty( key ).withValue( array ) ) ); assertThat( properties( db ), inTx( db, hasProperty( key ).withValue( array ) ) ); db.shutdown(); }
@Test public void firstRecordOtherThanZeroIfNotFirst() { File storeDir = testDirectory.databaseDir(); GraphDatabaseAPI db = (GraphDatabaseAPI) factory.newImpermanentDatabase( storeDir ); Transaction tx = db.beginTx(); Node node = db.createNode(); node.setProperty( "name", "Yo" ); tx.success(); tx.close(); db.shutdown(); db = (GraphDatabaseAPI) factory.newImpermanentDatabase( storeDir ); tx = db.beginTx(); properties( db ).setProperty( "test", "something" ); tx.success(); tx.close(); db.shutdown(); Config config = Config.defaults(); StoreFactory storeFactory = new StoreFactory( testDirectory.databaseLayout(), config, new DefaultIdGeneratorFactory( fs.get() ), pageCacheRule.getPageCache( fs.get() ), fs.get(), NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ); NeoStores neoStores = storeFactory.openAllNeoStores(); long prop = neoStores.getMetaDataStore().getGraphNextProp(); assertTrue( prop != 0 ); neoStores.close(); }