com.graphaware.tx.event.improved.entity.snapshot.NodeSnapshot Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tx-api Show documentation
Show all versions of tx-api Show documentation
Improved Transaction API with Graph Snapshotting
The newest version!
/*
* Copyright (c) 2013-2020 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* .
*/
package com.graphaware.tx.event.improved.entity.snapshot;
import com.graphaware.common.util.IterableUtils;
import com.graphaware.common.wrapper.NodeWrapper;
import com.graphaware.tx.event.improved.data.EntityTransactionData;
import com.graphaware.tx.event.improved.data.TransactionDataContainer;
import org.neo4j.graphdb.*;
import org.neo4j.internal.helpers.collection.Iterables;
import org.neo4j.logging.Log;
import com.graphaware.common.log.LoggerFactory;
/**
* A {@link EntitySnapshot} representing a {@link org.neo4j.graphdb.Node}.
*/
public class NodeSnapshot extends EntitySnapshot implements Node, NodeWrapper {
private static final Log LOG = LoggerFactory.getLogger(NodeSnapshot.class);
/**
* Construct a snapshot.
*
* @param wrapped node.
* @param transactionDataContainer transaction data container.
*/
public NodeSnapshot(Node wrapped, TransactionDataContainer transactionDataContainer) {
super(wrapped, transactionDataContainer);
}
@Override
protected EntityTransactionData transactionData() {
return transactionDataContainer.getNodeTransactionData();
}
@Override
protected Node self() {
return this;
}
@Override
public void delete() {
if (transactionDataContainer.getNodeTransactionData().hasBeenDeleted(wrapped)) {
LOG.warn("Node " + getId() + " has already been deleted in this transaction.");
} else {
super.delete();
}
}
@Override
public Relationship createRelationshipTo(Node otherNode, RelationshipType type) {
checkCanBeMutated();
return super.createRelationshipTo(otherNode, type);
}
@Override
protected Relationship wrapRelationship(Relationship relationship) {
return new RelationshipSnapshot(relationship, transactionDataContainer);
}
@Override
protected Iterable wrapRelationships(Iterable relationships, Direction direction, RelationshipType... relationshipTypes) {
return new RelationshipSnapshotIterator(this, relationships, transactionDataContainer, direction, relationshipTypes);
}
@Override
public boolean hasLabel(Label label) {
return IterableUtils.contains(getLabels(), label);
}
@Override
public Iterable
© 2015 - 2025 Weber Informatics LLC | Privacy Policy