private InstanceIdentifierContext<?> createContext(final YangInstanceIdentifier instance, final DataSchemaNode dataSchemaNode, final DOMMountPoint mountPoint, final SchemaContext schemaContext) { final YangInstanceIdentifier instanceIdentifier = new DataNormalizer(schemaContext).toNormalized(instance); return new InstanceIdentifierContext<>(instanceIdentifier, dataSchemaNode, mountPoint,schemaContext); }
public DataNormalizationOperation<?> getRootOperation() { return dataNormalizer.getRootOperation(); }
public void setGlobalSchema(final SchemaContext globalSchema) { this.globalSchema = globalSchema; dataNormalizer = new DataNormalizer(globalSchema); }
public YangInstanceIdentifier toNormalized(final YangInstanceIdentifier legacy) { try { return dataNormalizer.toNormalized(legacy); } catch (final NullPointerException e) { throw new RestconfDocumentedException("Data normalizer isn't set. Normalization isn't possible", e); } }
public boolean isNodeMixin(final YangInstanceIdentifier path) { final DataNormalizationOperation<?> operation; try { operation = dataNormalizer.getOperation(path); } catch (final DataNormalizationException e) { throw new RestconfDocumentedException("Data normalizer failed. Normalization isn't possible", e); } return operation.isMixin(); }
public YangInstanceIdentifier toXpathRepresentation(final YangInstanceIdentifier instanceIdentifier) { try { return dataNormalizer.toLegacy(instanceIdentifier); } catch (final NullPointerException e) { throw new RestconfDocumentedException("Data normalizer isn't set. Normalization isn't possible", e); } catch (final DataNormalizationException e) { throw new RestconfDocumentedException("Data normalizer failed. Normalization isn't possible", e); } }
public void setGlobalSchema(final SchemaContext globalSchema) { this.globalSchema = globalSchema; dataNormalizer = new DataNormalizer(globalSchema); }
final YangInstanceIdentifier partialPath = dataNormalizer.toNormalized(builder.build()); final Optional<DOMMountPoint> mountOpt = mountService.getMountPoint(partialPath); if (!mountOpt.isPresent()) {
@Override public void onGlobalContextUpdated(final SchemaContext schemaContext) { legacyToNormalized = new DataNormalizer(schemaContext); BindingRuntimeContext runtimeContext = BindingRuntimeContext.create(classLoadingStrategy, schemaContext); codecRegistry.onBindingRuntimeContextUpdated(runtimeContext); futureSchema.onRuntimeContextUpdated(runtimeContext); }
/** * Returns an default object according to YANG schema for supplied path. * * @param path DOM Path * @return Node with defaults set on. */ public NormalizedNode<?, ?> getDefaultNodeFor(final YangInstanceIdentifier path) { final Iterator<PathArgument> iterator = path.getPathArguments().iterator(); DataNormalizationOperation<?> currentOp = legacyToNormalized.getRootOperation(); while (iterator.hasNext()) { final PathArgument currentArg = iterator.next(); try { currentOp = currentOp.getChild(currentArg); } catch (final DataNormalizationException e) { throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e); } } return currentOp.createDefault(path.getLastPathArgument()); }
@Override protected void ensureParentsByMerge(final LogicalDatastoreType store, final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalizedPath, final InstanceIdentifier<?> path) { List<PathArgument> currentArguments = new ArrayList<>(); DataNormalizationOperation<?> currentOp = getCodec().getDataNormalizer().getRootOperation(); Iterator<PathArgument> iterator = normalizedPath.getPathArguments().iterator(); while (iterator.hasNext()) { PathArgument currentArg = iterator.next(); try { currentOp = currentOp.getChild(currentArg); } catch (DataNormalizationException e) { throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e); } currentArguments.add(currentArg); org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier currentPath = org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.create( currentArguments); getDelegate().merge(store, currentPath, currentOp.createDefault(currentArg)); } }
@Override protected final void ensureParentsByMerge(final LogicalDatastoreType store, final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalizedPath, final InstanceIdentifier<?> path) { List<PathArgument> currentArguments = new ArrayList<>(); DataNormalizationOperation<?> currentOp = getCodec().getDataNormalizer().getRootOperation(); Iterator<PathArgument> iterator = normalizedPath.getPathArguments().iterator(); while (iterator.hasNext()) { PathArgument currentArg = iterator.next(); try { currentOp = currentOp.getChild(currentArg); } catch (DataNormalizationException e) { throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e); } currentArguments.add(currentArg); org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier currentPath = org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.create( currentArguments); final Boolean exists; try { exists = getDelegate().exists(store, currentPath).checkedGet(); } catch (ReadFailedException e) { LOG.error("Failed to read pre-existing data from store {} path {}", store, currentPath, e); throw new IllegalStateException("Failed to read pre-existing data", e); } if (!exists && iterator.hasNext()) { getDelegate().merge(store, currentPath, currentOp.createDefault(currentArg)); } } }