@Override @Nonnull public final PathArgument getIdentifier() { return data.getIdentifier(); }
@Override @Nonnull public final PathArgument getIdentifier() { return data.getIdentifier(); }
@Override void verifyStructure(final NormalizedNode<?, ?> writtenValue, final boolean verifyChildren) { checkArgument(nodeClass.isInstance(writtenValue), "Node %s is not of type %s", writtenValue, nodeClass); checkArgument(writtenValue instanceof NormalizedNodeContainer); if (verifyChildrenStructure && verifyChildren) { final NormalizedNodeContainer<?, ?, ?> container = (NormalizedNodeContainer<?, ?, ?>) writtenValue; for (final Object child : container.getValue()) { checkArgument(child instanceof NormalizedNode); final NormalizedNode<?, ?> castedChild = (NormalizedNode<?, ?>) child; final Optional<ModificationApplyOperation> childOp = getChild(castedChild.getIdentifier()); if (childOp.isPresent()) { childOp.get().verifyStructure(castedChild, verifyChildren); } else { throw new SchemaValidationFailedException(String.format( "Node %s is not a valid child of %s according to the schema.", castedChild.getIdentifier(), container.getIdentifier())); } } } }
@Override void verifyStructure(final NormalizedNode<?, ?> writtenValue, final boolean verifyChildren) { checkArgument(nodeClass.isInstance(writtenValue), "Node %s is not of type %s", writtenValue, nodeClass); checkArgument(writtenValue instanceof NormalizedNodeContainer); if (verifyChildrenStructure && verifyChildren) { final NormalizedNodeContainer<?, ?, ?> container = (NormalizedNodeContainer<?, ?, ?>) writtenValue; for (final Object child : container.getValue()) { checkArgument(child instanceof NormalizedNode); final NormalizedNode<?, ?> castedChild = (NormalizedNode<?, ?>) child; final Optional<ModificationApplyOperation> childOp = getChild(castedChild.getIdentifier()); if (childOp.isPresent()) { childOp.get().verifyStructure(castedChild, verifyChildren); } else { throw new SchemaValidationFailedException(String.format( "Node %s is not a valid child of %s according to the schema.", castedChild.getIdentifier(), container.getIdentifier())); } } } }
private void navigateNormalizedNodeContainerMixin(int level, final String parentPath, NormalizedNodeContainer<?, ?, ?> node) { visitor.visitNode(level, parentPath, node); String newParentPath = parentPath + "/" + node.getIdentifier().toString(); final Iterable<? extends NormalizedNode<?, ?>> value = node.getValue(); for(NormalizedNode<?, ?> normalizedNode : value){ if(normalizedNode instanceof MixinNode && normalizedNode instanceof NormalizedNodeContainer){ navigateNormalizedNodeContainerMixin(level + 1, newParentPath, (NormalizedNodeContainer) normalizedNode); } else { navigateNormalizedNode(level, newParentPath, normalizedNode); } } }
@Override @SuppressWarnings("rawtypes") public final void writeToCurrent(final NormalizedNodeContainer<?, ?, ?> data) { // write the entire thing into the cursor write(data.getIdentifier(), data); // write the children with subshard check and subshard write if we are going into subshard cursor.enter(data.getIdentifier()); for (NormalizedNode<?, ?> writtenChild : data.getValue()) { write(writtenChild.getIdentifier(), writtenChild); } // Delete step - remove subshard data that was written into current shard // delete from current node.getChildrenWithSubshards().entrySet() .stream().filter(entry -> entry.getValue() instanceof WriteableSubshardBoundaryNode).forEach(entry -> { @SuppressWarnings("unchecked") Optional<NormalizedNode<?, ?>> writtenValue = ((NormalizedNodeContainer) data).getChild(entry.getKey()); if (writtenValue.isPresent()) { // delete from current cursor.delete(entry.getKey()); } }); cursor.exit(); } }
@Override protected void recursivelyVerifyStructure(final NormalizedNode<?, ?> value) { final NormalizedNodeContainer<?, ?, ?> container = (NormalizedNodeContainer<?, ?, ?>) value; for (final Object child : container.getValue()) { checkArgument(child instanceof NormalizedNode); final NormalizedNode<?, ?> castedChild = (NormalizedNode<?, ?>) child; final Optional<ModificationApplyOperation> childOp = getChild(castedChild.getIdentifier()); if (childOp.isPresent()) { childOp.get().recursivelyVerifyStructure(castedChild); } else { throw new SchemaValidationFailedException( String.format("Node %s is not a valid child of %s according to the schema.", castedChild.getIdentifier(), container.getIdentifier())); } } }
@Override protected void recursivelyVerifyStructure(final NormalizedNode<?, ?> value) { final NormalizedNodeContainer<?, ?, ?> container = (NormalizedNodeContainer<?, ?, ?>) value; for (final Object child : container.getValue()) { checkArgument(child instanceof NormalizedNode); final NormalizedNode<?, ?> castedChild = (NormalizedNode<?, ?>) child; final Optional<ModificationApplyOperation> childOp = getChild(castedChild.getIdentifier()); if (childOp.isPresent()) { childOp.get().recursivelyVerifyStructure(castedChild); } else { throw new SchemaValidationFailedException( String.format("Node %s is not a valid child of %s according to the schema.", castedChild.getIdentifier(), container.getIdentifier())); } } }
private void navigateNormalizedNodeContainerMixin(int level, final String parentPath, NormalizedNodeContainer<?, ?, ?> node) { visitor.visitNode(level, parentPath, node); String newParentPath = parentPath + "/" + node.getIdentifier().toString(); final Iterable<? extends NormalizedNode<?, ?>> value = node.getValue(); for (NormalizedNode<?, ?> normalizedNode : value) { if (normalizedNode instanceof MixinNode && normalizedNode instanceof NormalizedNodeContainer) { navigateNormalizedNodeContainerMixin(level + 1, newParentPath, (NormalizedNodeContainer<?, ?, ?>) normalizedNode); } else { navigateNormalizedNode(level, newParentPath, normalizedNode); } } }