Package org.neo4j.graphdb

Examples of org.neo4j.graphdb.PropertyContainer


    }

    public <T extends Element> Set<String> getInternalIndexKeys(final Class<T> elementClass) {
        final String propertyName = elementClass.getSimpleName() + INDEXED_KEYS_POSTFIX;
        if (rawGraph instanceof GraphDatabaseAPI) {
            final PropertyContainer pc = getGraphProperties();
            try {
                final String[] keys = (String[]) pc.getProperty(propertyName);
                return new HashSet<String>(Arrays.asList(keys));
            } catch (Exception e) {
                // no indexed_keys kernel data property
            }
        } else {
View Full Code Here



        final Set<String> properties = rawAutoIndexer.getAutoIndexedProperties();
        Transaction tx = rawGraphDB.beginTx();

        final PropertyContainer kernel = ((GraphDatabaseAPI) rawGraphDB).getNodeManager().getGraphProperties();
        kernel.setProperty(elementClass.getSimpleName() + INDEXED_KEYS_POSTFIX, properties.toArray(new String[properties.size()]));

        int count = 0;
        for (final PropertyContainer pc : rawElements) {
            for (final String property : properties) {
                if (!pc.hasProperty(property)) continue;
View Full Code Here

            this.field = field;
        }

        @Override
        public Object setValue(final GraphBacked<PropertyContainer> entity, final Object newVal) {
          final PropertyContainer propertyContainer = entity.getPersistentState();
          PrefixedDynamicProperties dynamicProperties;
            if (newVal instanceof ManagedPrefixedDynamicProperties) {
                // newVal is already a managed container
                dynamicProperties = (ManagedPrefixedDynamicProperties<?>) newVal;
            }
            else {
                // newVal is not a managed prefixed container and therefore contains
                // pure key/values that must be converted to a prefixed form
            dynamicProperties = new PrefixedDynamicProperties(propertyNamePrefix);
            DynamicProperties newPropertiesVal = (DynamicProperties)newVal;
            for(String key : newPropertiesVal.getPropertyKeys()) {
              dynamicProperties.setProperty(key, newPropertiesVal.getProperty(key));
            }
          }


            Set<String> dynamicProps = dynamicProperties.getPrefixedPropertyKeys();
            Set<String> nodeProps = new HashSet<String>();
            IteratorUtil.addToCollection(propertyContainer.getPropertyKeys(), nodeProps);

            // Get the properties that are not present in the DynamicProperties container anymore
            // by removing all present keys from the actual node properties.
            for (String prop : dynamicProps) {
              nodeProps.remove(prop);
            }
           
            // nodeProps now contains the properties that are present on the node, but not in the DynamicProperties -
            // in other words: properties that have been removed. Remove them from the node as well.
      for(String removedKey : nodeProps) {
        if (dynamicProperties.isPrefixedKey(removedKey)) {
          propertyContainer.removeProperty(removedKey);
        }
      }
           
      // Add all properties to the propertyContainer
            for (String key : dynamicProps) {
                propertyContainer.setProperty(key, dynamicProperties.getPrefixedProperty(key));
            }
            return newVal;
        }
View Full Code Here

            return newVal;
        }

        @Override
        public Object getValue(final GraphBacked<PropertyContainer> entity) {
            PropertyContainer element = entity.getPersistentState();
            ManagedPrefixedDynamicProperties<?> props = ManagedPrefixedDynamicProperties.create(propertyNamePrefix,
                    field, entity);
            for (String key : element.getPropertyKeys()) {
                props.setPropertyIfPrefixed(key, element.getProperty(key));
            }
            return DoReturn.doReturn(props);
        }
View Full Code Here

            return true;
        }

        @Override
        public Object setValue(final GraphBacked<PropertyContainer> graphBacked, final Object newVal) {
            final PropertyContainer propertyContainer = graphBacked.getPersistentState();
            if (newVal==null) {
                propertyContainer.removeProperty(propertyName);
            } else {
                propertyContainer.setProperty(propertyName, newVal);
            }
            return newVal;
        }
View Full Code Here

        public final Object getValue(final GraphBacked<PropertyContainer> graphBacked) {
            return doReturn(doGetValue(graphBacked));
        }

        protected Object doGetValue(final GraphBacked<PropertyContainer> graphBacked) {
            PropertyContainer element = graphBacked.getPersistentState();
            if (element.hasProperty(propertyName)) {
                Object value = element.getProperty(propertyName);
                if (value == null || fieldType.isInstance(value)) return value;
                if (conversionService!=null) {
                    return conversionService.convert(value, fieldType);
                }
                return value;
View Full Code Here

    public void testConvertEnumsAccordingToAnnotation() throws Exception {
        Word word = template.save(new Word(Letter.C, Vowel.A, Consonant.B));
        assertEquals(Letter.C, word.letter);
        assertEquals(Vowel.A, word.vowel);
        assertEquals(Consonant.B, word.consonant);
        PropertyContainer node = template.getPersistentState(word);
        assertEquals(Letter.C.name(),node.getProperty("letter"));
        assertEquals(Vowel.A.name(),node.getProperty("vowel"));
        assertEquals(Consonant.B.ordinal(),node.getProperty("consonant"));
    }
View Full Code Here

    @Test public void testUserAddRemove() {
        service.setPermissionForUser("user1", RO);

        NodeManager nodeManager = graphDatabase.getDependencyResolver().resolveDependency(NodeManager.class);
        PropertyContainer properties = nodeManager.getGraphProperties();
        Transaction transaction = graphDatabase.beginTx();
        properties.setProperty("any other property", "should be ignored");
        transaction.success();
        transaction.finish();

        assertEquals(genericMap("user1", RO), service.getUsers());
View Full Code Here

    }

    private String getCredentials(String cred) {
        Transaction tx = graph.beginTx();
        try {
            PropertyContainer properties = getGraphProperties();
            String userKey = getUserKey(cred);
            Object result = properties.getProperty(userKey, "");
            String credentials = (result instanceof Boolean) ? "" : (String) result;
            tx.success();
            return credentials;
        } finally {
            tx.finish();
View Full Code Here

    public Map<String, Permission> getUsers() {
        try (Transaction tx = graph.beginTx()) {
            final Map<String, Permission> result = new HashMap<String, Permission>();

            PropertyContainer properties = getGraphProperties();
            for (String key : properties.getPropertyKeys()) {
                Matcher matcher = USER_PATTERN.matcher(key);
                if (matcher.matches()) {
                    String value = (String) properties.getProperty(key);
                    result.put(matcher.group(1), Permission.valueOf(value));
                }
            }
            tx.success();
            return result;
View Full Code Here

TOP

Related Classes of org.neo4j.graphdb.PropertyContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.