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;

Author(s):
mh
Since:
12.10.11
public class EntityRemover {
    private final GraphDatabase graphDatabase;
    public EntityRemover(EntityStateHandler entityStateHandlerTypeRepresentationStrategy<NodenodeTypeRepresentationStrategyTypeRepresentationStrategy<RelationshiprelationshipTypeRepresentationStrategyGraphDatabase graphDatabase) {
        this. = entityStateHandler;
        this. = nodeTypeRepresentationStrategy;
        this. = relationshipTypeRepresentationStrategy;
        this. = graphDatabase;
    }
    public void removeNodeEntity(Object entity) {
        Node node = .getPersistentState(entityNode.class);
        if (node == nullreturn;
        removeNode(node);
    }
    private void removeNode(Node node) {
        for (Relationship relationship : node.getRelationships()) {
            removeRelationship(relationship);
        }
        .remove(node);
    }
    public void removeRelationshipEntity(Object entity) {
        Relationship relationship = .getPersistentState(entityRelationship.class);
        if (relationship == nullreturn;
        removeRelationship(relationship);
    }
    private void removeRelationship(Relationship relationship) {
        .remove(relationship);
    }
    public void removeRelationshipBetween(Object startObject targetString type) {
        final RelationshipResult result = .removeRelationshipTo(starttargettype);
        if (result!=null && result.type == ..) {
            .preEntityRemoval(result.relationship);
        }
    }
    public void remove(Object entity) {
        if (entity instanceof Node) {
            removeNode((Node)entity);
            return;
        }
        if (entity instanceof Relationship) {
            removeRelationship((Relationship)entity);
            return;
        }
        final Class<?> type = entity.getClass();
        if (.isNodeEntity(type)) {
            removeNodeEntity(entity);
            return;
        }
        if (.isRelationshipEntity(type)) {
            removeRelationshipEntity(entity);
            return;
        }
        throw new IllegalArgumentException("@NodeEntity or @RelationshipEntity annotation required on domain class"+type);
    }
New to GrepCode? Check out our FAQ X