/** * {@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(); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.ChangeRequest#changes(java.lang.String, org.modeshape.graph.property.Path) */ @Override public boolean changes( String workspace, Path path ) { if (this.into() != null) { return this.workspaceName.equals(workspace) && (into.hasPath() && into.getPath().isAtOrBelow(path) || from.hasPath() && from.getPath().isAtOrBelow(path)); } // into or before must be non-null assert before() != null; return this.workspaceName.equals(workspace) && (before.hasPath() && before.getPath().getParent().isAtOrBelow(path) || from.hasPath() && from.getPath().isAtOrBelow(path)); }
@Test public void shouldCreateValidRequestWithValidFromLocationAndValidToLocationAndValidBeforeLocation() { Name newName = new BasicName("", "newName"); request = new MoveBranchRequest(validPathLocation1, validPathLocation2, validPathLocation, workspace1, newName, NodeConflictBehavior.DO_NOT_REPLACE); assertThat(request.from(), is(sameInstance(validPathLocation1))); assertThat(request.into(), is(sameInstance(validPathLocation2))); assertThat(request.before(), is(sameInstance(validPathLocation))); assertThat(request.inWorkspace(), is(sameInstance(workspace1))); assertThat(request.hasError(), is(false)); assertThat(request.getError(), is(nullValue())); }
ProjectedNode projectedBeforeNode = request.before() != null ? project(request.before(), request.inWorkspace(), request, ProxyNode beforeProxy = request.before() != null ? projectedBeforeNode.asProxy() : null; assert fromProxy.projection().getSourceName().equals(intoProxy.projection().getSourceName()); sameLocation = fromProxy.isSameLocationAsOriginal() && intoProxy.isSameLocationAsOriginal(); } else { ProxyNode fromProxy = projectedFromNode.asProxy(); ProxyNode beforeProxy = request.before() != null ? projectedBeforeNode.asProxy() : null; Location beforeProxyLocation = beforeProxy != null ? beforeProxy.location() : null; MoveBranchRequest pushDown = new MoveBranchRequest(fromProxy.location(), null, beforeProxyLocation,
Location before = move.before(); boolean isReorder = move.desiredName() == null; changeContext.move(workspace, original, location, before, isReorder);