break; case UPDATE: create.orUpdate(); break; case DO_NOT_REPLACE:
/** * {@inheritDoc} * * @see org.modeshape.graph.io.Destination#create(org.modeshape.graph.property.Path, Iterable) */ public void create( Path path, Iterable<Property> properties ) { assert properties != null; Create<Batch> create = batch.create(path, properties); assert create != null; NodeConflictBehavior behavior = createBehaviorFor(path); if (behavior != null) { switch (behavior) { case APPEND: create.byAppending(); break; case REPLACE: create.orReplace(); break; case UPDATE: create.orUpdate(); break; case DO_NOT_REPLACE: create.ifAbsent(); break; } } create.and(); }
/** * Create the node at the supplied path under the current path, and return the Create operation for the last node created. * The caller <i>must</i> call {@link Graph.Create#and()} to complete the operation. * * @param path the path to the node * @param segments the segments in the remainder of the path * @return the newly-created but incomplete operation */ protected Graph.Create<Graph.Batch> createIfMissing( Path path, Name... segments ) { Path nodePath = path; Graph.Create<Graph.Batch> result = null; for (Name name : segments) { if (result != null) result.and(); nodePath = context.getValueFactories().getPathFactory().create(nodePath, name); result = batch.create(nodePath).orUpdate(); } return result; }
/** * Create the node at the supplied path under the current path, and return the Create operation for the last node created. * The caller <i>must</i> call {@link Graph.Create#and()} to complete the operation. * * @param child the name of the child * @param segments the segments in the remainder of the path * @return the newly-created but incomplete operation */ protected Graph.Create<Graph.Batch> createIfMissing( Name child, String... segments ) { Path nodePath = context.getValueFactories().getPathFactory().create(path, child); Graph.Create<Graph.Batch> result = batch.create(nodePath).orUpdate(); for (String name : segments) { result.and(); nodePath = context.getValueFactories().getPathFactory().create(nodePath, name); result = batch.create(nodePath).orUpdate(); } return result; }
/** * Create the node at the supplied path under the current path, and return the Create operation for the last node created. * The caller <i>must</i> call {@link Graph.Create#and()} to complete the operation. * * @param segment the name segment for the child * @return the newly-created but incomplete operation */ protected Graph.Create<Graph.Batch> createIfMissing( Name segment ) { Path nodePath = context.getValueFactories().getPathFactory().create(path, segment); Graph.Create<Graph.Batch> result = batch.create(nodePath).orUpdate(); return result; }