private CheckedFuture<Void, TransactionCommitFailedException> deleteDataViaTransaction( final DOMDataWriteTransaction writeTransaction, final LogicalDatastoreType datastore, final YangInstanceIdentifier path) { LOG.trace("Delete {} via Restconf: {}", datastore.name(), path); writeTransaction.delete(datastore, path); return writeTransaction.submit(); }
/** * This method stores the pushUpdate Notification data to MD-SAL * * @param sub_id * @param timeofeventupdate * @param domSource * @param data */ private void storeToMdSal( String sub_id, String timeofeventupdate, DOMSource domSource, String data) { NodeIdentifier subscriptionid = NodeIdentifier.create(QName.create(PushUpdates.QNAME, "subscription-id")); NodeIdentifier timeofupdate = NodeIdentifier.create(QName.create(PushUpdates.QNAME, "time-of-update")); NodeIdentifier datanode = NodeIdentifier.create(QName.create(PushUpdates.QNAME, "data")); YangInstanceIdentifier pid = YangInstanceIdentifier.builder() .node(PushUpdates.QNAME) .node( org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangpush.rev150105 .push.updates.PushUpdate.QNAME) .build(); NodeIdentifierWithPredicates p = new NodeIdentifierWithPredicates( QName.create(PushUpdates.QNAME, "push-update"), QName.create(PushUpdates.QNAME, "subscription-id"), sub_id); MapEntryNode men = ImmutableNodes.mapEntryBuilder() .withNodeIdentifier(p) .withChild(ImmutableNodes.leafNode(subscriptionid, sub_id)) .withChild(ImmutableNodes.leafNode(timeofupdate, timeofeventupdate)) .withChild(ImmutableNodes.leafNode(datanode, data)) .build(); DOMDataWriteTransaction tx = this.globalDomDataBroker.newWriteOnlyTransaction(); YangInstanceIdentifier yid = pid.node( new NodeIdentifierWithPredicates( org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangpush.rev150105 .push.updates.PushUpdate.QNAME, men.getIdentifier().getKeyValues())); tx.merge(LogicalDatastoreType.CONFIGURATION, yid, men); LOG.info("--DATA PATh: {}\n--DATA\n{}", yid, men); try { tx.submit().checkedGet(); } catch (TransactionCommitFailedException e) { e.printStackTrace(); } }