/** * {@inheritDoc} * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("read ").append(printable(from())).append(" (in "); if (inWorkspace() != null) { sb.append('\'').append(inWorkspace()).append('\''); } else { sb.append("default"); } sb.append(" workspace) "); if (desiredName() != null) { sb.append("with name '").append(desiredName()).append("' "); } else { sb.append("into "); } if (into() != null) { sb.append("into ").append(printable(into())); } else { sb.append("before ").append(printable(before())); } return sb.toString(); }
/** * Determine whether this move request can be determined to have no effect. * <p> * A move is known to have no effect when all of the following conditions are true: * <ul> * <li>the {@link #into() into} location has a {@link Location#hasPath() path} but no {@link Location#hasIdProperties() * identification properties};</li> * <li>the {@link #from() from} location has a {@link Location#getPath() path}; and</li> * <li>the {@link #from() from} location's {@link Path#getParent() parent} is the same as the {@link #into() into} location's * path.</li> * </ul> * If all of these conditions are not true, this method returns false. * </p> * * @return true if this move request really doesn't change the parent of the node, or false if it cannot be determined */ public boolean hasNoEffect() { if (into != null && into.hasPath() && into.hasIdProperties() == false && from.hasPath()) { if (!from.getPath().getParent().equals(into.getPath())) return false; if (desiredName() != null && !desiredName().equals(from.getPath().getLastSegment().getName())) return false; if (before != null) return false; return true; } // Can't be determined for certain return false; }
/** * Sets the actual and complete location of the node being renamed and its new location. This method must be called when * processing the request, and the actual location must have a {@link Location#getPath() path}. * * @param oldLocation the actual location of the node before being moved * @param newLocation the actual new location of the node * @throws IllegalArgumentException if the either location is null, or if the either location does not have a path * @throws IllegalStateException if the request is frozen */ public void setActualLocations( Location oldLocation, Location newLocation ) { checkNotFrozen(); CheckArg.isNotNull(oldLocation, "oldLocation"); CheckArg.isNotNull(newLocation, "newLocation"); if (!oldLocation.hasPath()) { throw new IllegalArgumentException(GraphI18n.actualOldLocationMustHavePath.text(oldLocation)); } if (!newLocation.hasPath()) { throw new IllegalArgumentException(GraphI18n.actualNewLocationMustHavePath.text(newLocation)); } Name actualNewName = newLocation.getPath().getLastSegment().getName(); Name expectedNewName = desiredName() != null ? desiredName() : oldLocation.getPath().getLastSegment().getName(); if (!actualNewName.equals(expectedNewName)) { throw new IllegalArgumentException(GraphI18n.actualLocationNotEqualToInputLocation.text(newLocation, into)); } this.actualOldLocation = oldLocation; this.actualNewLocation = newLocation; }
if (request.into() != null) { newLocation = txn.addChild(workspace, newParent, node, null, request.desiredName()); } else { newLocation = txn.addChild(workspace, newParent, node, beforeNode, request.desiredName());
return; workspace.moveNode(getExecutionContext(), node, request.desiredName(), workspace, newParent, beforeNode); assert node.getParent().equals(newParent); Path newPath = getExecutionContext().getValueFactories().getPathFactory().create(newParentPath, node.getName());
original = move.getActualLocationBefore(); Location before = move.before(); boolean isReorder = move.desiredName() == null; changeContext.move(workspace, original, location, before, isReorder); break;
node = newWorkspace.moveNode(getExecutionContext(), node, request.desiredName(), newWorkspace, newParent, beforeNode); assert node.getPath().getParent().equals(newParent.getPath());
intoProxy.workspaceName(), request.desiredName(), request.conflictBehavior()); Location beforeProxyLocation = beforeProxy != null ? beforeProxy.location() : null; MoveBranchRequest pushDown = new MoveBranchRequest(fromProxy.location(), null, beforeProxyLocation, fromProxy.workspaceName(), request.desiredName(), request.conflictBehavior());
@Override public void process( MoveBranchRequest request ) { // Just update the actual location ... Name newName = request.desiredName(); if (newName == null && request.from().hasPath()) newName = request.from().getPath().getLastSegment().getName(); if (newName == null) newName = context.getValueFactories().getNameFactory().create("d"); // Figure out the new name and path (if needed)... Path newPath = null; if (request.into().hasPath()) { newPath = context.getValueFactories().getPathFactory().create(request.into().getPath(), newName); } else if (request.from().hasPath()) { newPath = context.getValueFactories().getPathFactory().create("/a/b/c"); newPath = context.getValueFactories().getPathFactory().create(newPath, newName); } else { newPath = context.getValueFactories().getPathFactory().create("/a/b/c"); newPath = context.getValueFactories().getPathFactory().create(newPath, newName); } // Figure out the old name and path ... Path oldPath = null; if (request.from().hasPath()) { oldPath = request.from().getPath(); } else { oldPath = context.getValueFactories().getPathFactory().create("/x/y/z"); oldPath = context.getValueFactories().getPathFactory().create(oldPath, newName); } Location fromLocation = request.from().hasIdProperties() ? Location.create(oldPath, request.from().getIdProperties()) : Location.create(oldPath); Location intoLocation = request.into().hasIdProperties() ? Location.create(newPath, request.into().getIdProperties()) : Location.create(newPath); request.setActualLocations(fromLocation, intoLocation); }