private void ensureHasOnlyTheseProperties( PropertyContainer entity, Set<String> propertiesThatShouldExist ) { for ( String entityPropertyKey : entity.getPropertyKeys() ) { if ( !propertiesThatShouldExist.contains( entityPropertyKey ) ) { entity.removeProperty( entityPropertyKey ); } } }
@Override public void clearGraph() { GraphDatabaseServiceCleaner.cleanDatabaseContent( db ); try ( Transaction tx = db.beginTx() ) { PropertyContainer graphProperties = graphProperties(); for ( String key : graphProperties.getPropertyKeys() ) { graphProperties.removeProperty( key ); } tx.success(); } }
assertThat( graphProperties, inTx( db, hasProperty( "test" ).withValue( "yo" ) ) ); tx = db.beginTx(); assertNull( graphProperties.removeProperty( "something non existent" ) ); assertEquals( "yo", graphProperties.removeProperty( "test" ) ); assertNull( graphProperties.getProperty( "test", null ) ); graphProperties.setProperty( "other", 10 );
private <T extends PropertyContainer> void setProperty(T pc, String key, Object value) { if (value == null) pc.removeProperty(key); else pc.setProperty(key, toPropertyValue(value)); }
/** * Make properties boolean */ @Procedure(mode = Mode.WRITE) @Description("apoc.refactor.normalizeAsBoolean(entity, propertyKey, true_values, false_values) normalize/convert a property to be boolean") public void normalizeAsBoolean( @Name("entity") Object entity, @Name("propertyKey") String propertyKey, @Name("true_values") List<Object> trueValues, @Name("false_values") List<Object> falseValues) { if (entity instanceof PropertyContainer) { PropertyContainer pc = (PropertyContainer) entity; Object value = pc.getProperty(propertyKey, null); if (value != null) { boolean isTrue = trueValues.contains(value); boolean isFalse = falseValues.contains(value); if (isTrue && !isFalse) { pc.setProperty(propertyKey, true); } if (!isTrue && isFalse) { pc.setProperty(propertyKey, false); } if (!isTrue && !isFalse) { pc.removeProperty(propertyKey); } } } }
@Override public Object removeProperty(String key) { return delegate.removeProperty(key); }
/** * {@inheritDoc} */ @Override public Object removeProperty(String key) { return wrapped.removeProperty(key); }
public static void acquireWriteLock( PropertyContainer entity ) { // TODO At the moment this is the best way of doing it, if you don't want to use // the LockManager (and release the lock yourself) entity.removeProperty( "___dummy_property_for_locking___" ); } }
/** * {@inheritDoc} */ @Override public Object removeProperty(String key) { checkCanBeMutated(); return wrapped.removeProperty(key); }
private void ensureHasOnlyTheseProperties( PropertyContainer entity, Set<String> propertiesThatShouldExist ) { for ( String entityPropertyKey : entity.getPropertyKeys() ) { if ( !propertiesThatShouldExist.contains( entityPropertyKey ) ) { entity.removeProperty( entityPropertyKey ); } } }
public static void removeProperty( final String key, final PropertyContainer container ) { if ( container.hasProperty( key ) ) { container.removeProperty( key ); } }
public static void setMetadata( final Map<String, String> metadata, final PropertyContainer container ) { final Map<String, String> metadataMap = getMetadataMap( container ); if ( metadataMap != null ) { for ( final String key : metadataMap.keySet() ) { container.removeProperty( key ); } } for ( final Map.Entry<String, String> entry : metadata.entrySet() ) { container.setProperty( METADATA_PREFIX + entry.getKey(), entry.getValue() ); } }
public static String removeConfigProperty( final String key, final PropertyContainer container ) { final String pkey = CONFIG_PROPERTY_PREFIX + key; String old = null; if ( container.hasProperty( pkey ) ) { old = (String) container.getProperty( pkey ); container.removeProperty( pkey ); } return old; }
public <T> T removeProperty(final String key) { if (!this.rawElement.hasProperty(key)) return null; else { this.graph.autoStartTransaction(true); return (T) this.rawElement.removeProperty(key); } }
public void clear() { container().removeProperty( key() ); }
/** * {@inheritDoc} */ @Override public Object removeProperty(String key) { if (!hasProperty(key)) { return null; } return getPropertyContainer().removeProperty(key); }
@SuppressWarnings("unchecked") public T removeProperty(Vertex vertex) { return (T)vertex.getPropertyContainer().removeProperty(this.getName()); }
@SuppressWarnings("unchecked") public T removeProperty(Vertex vertex) { return (T)vertex.getPropertyContainer().removeProperty(this.getName()); }
private void acquireLock(LockType lockType, PropertyContainer element) { GraphDatabaseService graphDb = element.getGraphDatabase(); if ( lockType == LockType.READ) { Transaction tx = getCurrentTransaction(graphDb); tx.acquireReadLock(element); //graphDatabase.getLockManager().getReadLock( baseNode ); //graphDatabase.getLockReleaser().addLockToTransaction( baseNode, LockType.READ ); } else { // default to write lock if read locks unavailable element.removeProperty("___dummy_property_to_acquire_lock___"); } }
public Vertex removeProperty(Vertex vertex) { return getDb().getVertex(getDb().getNodeById((Long)vertex.getPropertyContainer().removeProperty(getName()))); }