use of org.structr.common.error.IdNotFoundToken in project structr by structr.
the class AbstractRelationship method setSourceNodeId.
@Override
public final void setSourceNodeId(final String sourceNodeId) throws FrameworkException {
// Do nothing if new id equals old
if (getSourceNodeId().equals(sourceNodeId)) {
return;
}
final App app = StructrApp.getInstance(securityContext);
final NodeInterface newStartNode = app.getNodeById(sourceNodeId);
final NodeInterface endNode = getTargetNode();
final Class relationType = getClass();
final PropertyMap _props = getProperties();
final String type = this.getClass().getSimpleName();
if (newStartNode == null) {
throw new FrameworkException(404, "Node with ID " + sourceNodeId + " not found", new IdNotFoundToken(type, sourceNodeId));
}
// delete this as the new rel will be the container afterwards
app.delete(this);
// create new relationship
app.create(newStartNode, endNode, relationType, _props);
}
use of org.structr.common.error.IdNotFoundToken in project structr by structr.
the class AbstractRelationship method setTargetNodeId.
@Override
public final void setTargetNodeId(final String targetNodeId) throws FrameworkException {
// Do nothing if new id equals old
if (getTargetNodeId().equals(targetNodeId)) {
return;
}
final App app = StructrApp.getInstance(securityContext);
final NodeInterface newTargetNode = app.getNodeById(targetNodeId);
final NodeInterface startNode = getSourceNode();
final Class relationType = getClass();
final PropertyMap _props = getProperties();
final String type = this.getClass().getSimpleName();
if (newTargetNode == null) {
throw new FrameworkException(404, "Node with ID " + targetNodeId + " not found", new IdNotFoundToken(type, targetNodeId));
}
// delete this as the new rel will be the container afterwards
app.delete(this);
// create new relationship and store here
app.create(startNode, newTargetNode, relationType, _props);
}
Aggregations