use of org.onosproject.yang.model.ModelObjectData in project onos by opennetworkinglab.
the class DcsBasedTapiDataProducer method getResourceId.
private ResourceId getResourceId(ModelObjectId modelId) {
ModelObjectData data = DefaultModelObjectData.builder().identifier(modelId).build();
ResourceData rnode = modelConverter.createDataNode(data);
return rnode.resourceId();
}
use of org.onosproject.yang.model.ModelObjectData in project onos by opennetworkinglab.
the class DcsBasedTapiDataProducer method readContextModelObject.
/**
* Get Tapi context modelObject from Dcs.
*
* @return Tapi context modelObject in Dcs store
*/
// FIXME update this method using TapiContextHandler
private DefaultContext readContextModelObject() {
// read DataNode from DCS
ModelObjectId mid = ModelObjectId.builder().addChild(DefaultContext.class).build();
DataNode node = dcs.readNode(getResourceId(mid), Filter.builder().build());
// convert to ModelObject
ResourceData data = DefaultResourceData.builder().addDataNode(node).resourceId(ResourceId.builder().build()).build();
ModelObjectData modelData = modelConverter.createModel(data);
DefaultContext context = (DefaultContext) modelData.modelObjects().get(0);
return context;
}
use of org.onosproject.yang.model.ModelObjectData in project onos by opennetworkinglab.
the class TapiObjectHandler method toModelObject.
@SuppressWarnings("unchecked")
protected T toModelObject(DataNode rNode, ResourceId rId) {
dcsSetup();
ResourceData rData = toResourceData(rNode, rId);
ModelObjectData modelObjectData = modelConverter.createModel(rData);
if (modelObjectData.modelObjects().size() > 1) {
throw new IllegalStateException("Multiple modelObject found.");
}
if (modelObjectData.modelObjects().isEmpty()) {
throw new IllegalStateException("ModelObject must not be empty.");
}
return (T) modelObjectData.modelObjects().get(0);
}
use of org.onosproject.yang.model.ModelObjectData in project onos by opennetworkinglab.
the class OdtnDcsModelCheckCommand method getResourceId.
private ResourceId getResourceId(ModelObjectId modelId) {
ModelObjectData data = DefaultModelObjectData.builder().identifier(modelId).build();
ResourceData rnode = modelConverter.createDataNode(data);
return rnode.resourceId();
}
use of org.onosproject.yang.model.ModelObjectData in project onos by opennetworkinglab.
the class YangToolUtil method toDataNode.
/**
* Converts ModelObject into a DataNode.
*
* @param input ModelOject
* @return DataNode
*/
public static DataNode toDataNode(ModelObject input) {
// FIXME this converter will work with root-level nodes only.
initStaticContext();
ModelObjectData modelData = DefaultModelObjectData.builder().addModelObject(input).identifier(null).build();
ResourceData rnode = converter.createDataNode(modelData);
if (rnode.dataNodes().isEmpty()) {
log.error("input did not result in any datanode. {}", input);
return null;
}
return rnode.dataNodes().get(0);
}
Aggregations