Examples of Neo4jPersistentProperty


Examples of org.springframework.data.neo4j.mapping.Neo4JPersistentProperty

            listener.valueChanged(entity, null, result); // todo oldValue
        }
    }

    protected Object getIdFromEntity() {
        final Neo4JPersistentProperty idProperty = fieldAccessorFactoryProviders.getIdProperty();
        if (idProperty==null) return null;
        try {
            return idProperty.getValue(entity);
        } catch (IllegalAccessException e) {
            log.warn("Error accessing id field "+idProperty);
            return null;
        }
    }
View Full Code Here

Examples of org.springframework.data.neo4j.mapping.Neo4JPersistentProperty

                }
            });
            type.doWithAssociations(new AssociationHandler<Neo4JPersistentProperty>() {
                @Override
                public void doWithAssociation(Association<Neo4JPersistentProperty> association) {
                    final Neo4JPersistentProperty property = association.getInverse();
                    final FieldAccessorFactory<?> factory = factoryForField(property);
                    final List<FieldAccessorListenerFactory> listenerFactories = (List<FieldAccessorListenerFactory>) getFieldAccessListenerFactories(property);
                    newFieldAccessorFactories.add(property, factory, listenerFactories);
                }
            });
View Full Code Here

Examples of org.springframework.data.neo4j.mapping.Neo4jPersistentProperty

        personType = mappingContext.getPersistentEntity(Person.class);
    }

    @Test
    public void checkGraphIdProperty() {
        final Neo4jPersistentProperty idProperty = personType.getIdProperty();
        assertEquals("graphId", idProperty.getName());
    }
View Full Code Here

Examples of org.springframework.data.neo4j.mapping.Neo4jPersistentProperty

        final Neo4jPersistentProperty idProperty = personType.getIdProperty();
        assertEquals("graphId", idProperty.getName());
    }

    @Test public void checkNameProperty() {
        final Neo4jPersistentProperty nameProperty = personType.getPersistentProperty("name");
        assertEquals("name",nameProperty.getName());
        assertEquals(String.class,nameProperty.getType());
        assertEquals(true,nameProperty.isIndexed());
        assertEquals(Person.NAME_INDEX,nameProperty.getIndexInfo().getIndexName());
        assertEquals(IndexType.SIMPLE,nameProperty.getIndexInfo().getIndexType());
        assertEquals(false,nameProperty.isRelationship());
    }
View Full Code Here

Examples of org.springframework.data.neo4j.mapping.Neo4jPersistentProperty

        Map<PartInfo, Object> result = new LinkedHashMap<PartInfo, Object>();
        for (Map.Entry<Parameter, PartInfo> entry : myParameters.entrySet()) {
            Object value = parameters.get(entry.getKey());
            PartInfo partInfo = entry.getValue();

            Neo4jPersistentProperty property = partInfo.getLeafProperty();
            result.put(partInfo,convertIfNecessary(template, value, property));
        }
        return result;
    }
View Full Code Here

Examples of org.springframework.data.neo4j.mapping.Neo4jPersistentProperty

    public WhereClause(PartInfo partInfo, Neo4jTemplate template) {
        Assert.notNull(partInfo.getType());
        this.partInfo = partInfo;
        this.type = this.partInfo.getType();
        Neo4jPersistentProperty property = partInfo.getLeafProperty();
        if (!property.isNeo4jPropertyType()) {
            propertyConverter = new PropertyConverter(template.getConversionService(), property);
        }
    }
View Full Code Here

Examples of org.springframework.data.neo4j.mapping.Neo4jPersistentProperty

    private <S extends PropertyContainer> S createNode(Neo4jPersistentEntityImpl<?> persistentEntity) {
        return (S) graphDatabase.createNode(null,persistentEntity.getAllLabels());
    }

    private Node createUniqueNode(Neo4jPersistentEntityImpl<?> persistentEntity, Object entity) {
        Neo4jPersistentProperty uniqueProperty = persistentEntity.getUniqueProperty();
        final Object value = getSerializedUniqueValue(entity, uniqueProperty);
        if (value==null) throw new MappingException("Error creating "+uniqueProperty.getOwner().getName()+" with "+entity+" unique property "+uniqueProperty.getName()+" has null value");
        final IndexInfo indexInfo = uniqueProperty.getIndexInfo();
        if (indexInfo.isLabelBased()) {
            return (indexInfo.isFailOnDuplicate())
                    ? graphDatabase.createNode(map(uniqueProperty.getName(),value),persistentEntity.getAllLabels())
                    : graphDatabase.merge(indexInfo.getIndexName(), indexInfo.getIndexKey(), value, Collections.<String,Object>emptyMap(), persistentEntity.getAllLabels());
        } else {
            return graphDatabase.getOrCreateNode(indexInfo.getIndexName(), indexInfo.getIndexKey(), value, Collections.<String,Object>emptyMap(),persistentEntity.getAllLabels());
        }
    }
View Full Code Here

Examples of org.springframework.data.neo4j.mapping.Neo4jPersistentProperty

    }

    @SuppressWarnings("unchecked")
    private <S extends PropertyContainer> S getOrCreateRelationship( Object entity, Neo4jPersistentEntity<?> persistentEntity, RelationshipType annotationProvidedRelationshipType ) {
        final RelationshipProperties relationshipProperties = persistentEntity.getRelationshipProperties();
        final Neo4jPersistentProperty startNodeProperty = relationshipProperties.getStartNodeProperty();
        Node startNode = (Node) getPersistentState(startNodeProperty.getValue(entity, startNodeProperty.getMappingPolicy()));
        final Neo4jPersistentProperty endNodeProperty = relationshipProperties.getEndNodeProperty();
        Node endNode = (Node) getPersistentState(endNodeProperty.getValue(entity, endNodeProperty.getMappingPolicy()));
        RelationshipType relationshipType = getRelationshipType(persistentEntity,entity, annotationProvidedRelationshipType );
        if (persistentEntity.isUnique()) {
            final Neo4jPersistentProperty uniqueProperty = persistentEntity.getUniqueProperty();
            final IndexInfo indexInfo = uniqueProperty.getIndexInfo();
            final Object value = uniqueProperty.getValueFromEntity(entity, MappingPolicy.MAP_FIELD_DIRECT_POLICY);
            if (value == null) {
                throw new MappingException("Error creating "+uniqueProperty.getOwner().getName()+" with "+entity+" unique property "+uniqueProperty.getName()+" has null value");
            }
            return (S) graphDatabase.getOrCreateRelationship(indexInfo.getIndexName(),indexInfo.getIndexKey(), value, startNode,endNode,relationshipType.name(), Collections.<String,Object>emptyMap());
        }
        return (S) graphDatabase.createRelationship(startNode, endNode, relationshipType, Collections.<String,Object>emptyMap());
    }
View Full Code Here

Examples of org.springframework.data.neo4j.mapping.Neo4jPersistentProperty

    private RelationshipType getRelationshipType( Neo4jPersistentEntity persistentEntity, Object entity,
                                                  RelationshipType annotationProvidedRelationshipType )
    {
        final RelationshipProperties relationshipProperties = persistentEntity.getRelationshipProperties();
        final Neo4jPersistentProperty typeProperty = relationshipProperties.getTypeProperty();

        if ( typeProperty != null )
        {
            Object value = typeProperty.getValue( entity, typeProperty.getMappingPolicy() );

            if ( value != null )
            {
                return value instanceof RelationshipType ? (RelationshipType) value : DynamicRelationshipType
                        .withName( value.toString() );
View Full Code Here

Examples of org.springframework.data.neo4j.mapping.Neo4jPersistentProperty

                    return new FullTextIndexBasedStartClause(partInfo);
                return new ExactIndexBasedStartClause(partInfo);
            }
        }

        Neo4jPersistentProperty leafProperty = partInfo.getLeafProperty();
        if (leafProperty.isRelationship() || leafProperty.isIdProperty()) {
            return new GraphIdStartClause(partInfo);
        }

        throw new IllegalArgumentException("Cannot determine an appropriate Start Clause for partInfo=" + partInfo );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.