Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2011 the original author or authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package org.springframework.data.neo4j.support.mapping;
import  org.springframework.core.convert.ConversionService;

Author(s):
mh
Since:
08.10.11
public class Neo4jEntityFetchHandler {
    private final EntityStateHandler entityStateHandler;
    private final ConversionService conversionService;
    public Neo4jEntityFetchHandler(EntityStateHandler entityStateHandler, ConversionService conversionServiceSourceStateTransmitter<NodenodeStateTransmitterSourceStateTransmitter<RelationshiprelationshipStateTransmitter) {
        this. = conversionService;
        this. = entityStateHandler;
        this. = relationshipStateTransmitter;
        this. = nodeStateTransmitter;
    }
    // todo actually cascade !!
    public Object fetch(final Object valueNeo4jPersistentEntity<ObjectpersistentEntityNeo4jPersistentProperty propertyfinal MappingPolicy policyfinal Neo4jTemplate template) {
        if (value == nullreturn value;
        //MappingPolicy mappingPolicy = mappingPolicy.combineWith(property.getMappingPolicy());
        final MappingPolicy mappingPolicy = property.getMappingPolicy();
        if (!mappingPolicy.shouldLoad()) return value;
        if (property.getTypeInformation().isCollectionLike()) {
            List<Objectreplacement = new ArrayList<Object>();
            for (Object inner : ((Iterablevalue)) {
                final BeanWrapper<Neo4jPersistentEntity<Object>, ObjectinnerWrapper = BeanWrapper.<Neo4jPersistentEntity<Object>, Object>create(inner);
                final PropertyContainer state = .getPersistentState(inner);
                fetchValue(innerWrapperstatepersistentEntitymappingPolicytemplate);
                replacement.add(inner);
                //sourceStateTransmitter.copyPropertiesFrom(innerWrapper, entityStateHandler.<S>getPersistentState(inner), persistentEntity);
            }
            return replacement;
        } else {
            final BeanWrapper<Neo4jPersistentEntity<Object>, ObjectinnerWrapper = BeanWrapper.<Neo4jPersistentEntity<Object>, Object>create(value);
            final PropertyContainer state = .getPersistentState(value);
            fetchValue(innerWrapperstatepersistentEntitymappingPolicytemplate);
//                        sourceStateTransmitter.copyPropertiesFrom(innerWrapper, entityStateHandler.<S>getPersistentState(value), persistentEntity);
        }
        return value;
    }
    public  void fetchValue(final BeanWrapper<Neo4jPersistentEntity<Object>, ObjectwrapperPropertyContainer sourceNeo4jPersistentEntity<ObjectpersistentEntityfinal MappingPolicy mappingPolicyfinal Neo4jTemplate template) {
        if (persistentEntity.isNodeEntity()) {
            .copyPropertiesFrom(wrapper, (Nodesource,persistentEntitymappingPolicytemplate);
        }
        if (persistentEntity.isRelationshipEntity()) {
            .copyPropertiesFrom(wrapper, (RelationshipsourcepersistentEntitymappingPolicytemplate);
        }
    }
New to GrepCode? Check out our FAQ X