use of org.opendaylight.controller.config.facade.xml.mapping.IdentityMapping in project controller by opendaylight.
the class ConfigSubsystemFacade method transformIdentities.
private static Map<String, Map<Optional<Revision>, IdentityMapping>> transformIdentities(final Set<Module> modules) {
Map<String, Map<Optional<Revision>, IdentityMapping>> mappedIds = new HashMap<>();
for (Module module : modules) {
String namespace = module.getNamespace().toString();
Map<Optional<Revision>, IdentityMapping> revisionsByNamespace = mappedIds.computeIfAbsent(namespace, k -> new HashMap<>());
Optional<Revision> revision = Optional.fromJavaUtil(module.getRevision());
IdentityMapping identityMapping = revisionsByNamespace.computeIfAbsent(revision, k -> new IdentityMapping());
for (IdentitySchemaNode identitySchemaNode : module.getIdentities()) {
identityMapping.addIdSchemaNode(identitySchemaNode);
}
}
return mappedIds;
}
use of org.opendaylight.controller.config.facade.xml.mapping.IdentityMapping in project controller by opendaylight.
the class SimpleIdentityRefAttributeReadingStrategyTest method testReadIdRef.
@Test
public void testReadIdRef() throws Exception {
final Map<String, Map<Optional<Revision>, IdentityMapping>> identityMapping = Maps.newHashMap();
final IdentityMapping value = new IdentityMapping();
final Optional<Revision> rev = Optional.of(Revision.of("2017-10-10"));
identityMapping.put("namespace", Collections.singletonMap(rev, value));
identityMapping.put("inner", Collections.singletonMap(rev, value));
final SimpleIdentityRefAttributeReadingStrategy key = new SimpleIdentityRefAttributeReadingStrategy(null, "key", identityMapping);
String read = key.readElementContent(XmlElement.fromString("<el xmlns=\"namespace\">local</el>"));
assertEquals(QName.create(URI.create("namespace"), rev.toJavaUtil(), "local").toString(), read);
read = key.readElementContent(XmlElement.fromString("<el xmlns:a=\"inner\" xmlns=\"namespace\">a:local</el>"));
assertEquals(QName.create(URI.create("inner"), rev.toJavaUtil(), "local").toString(), read);
read = key.readElementContent(XmlElement.fromString("<top xmlns=\"namespace\"><el>local</el></top>").getOnlyChildElement());
assertEquals(QName.create(URI.create("namespace"), rev.toJavaUtil(), "local").toString(), read);
}
use of org.opendaylight.controller.config.facade.xml.mapping.IdentityMapping in project controller by opendaylight.
the class InstanceRuntimeRpc method fromXml.
public Map<String, AttributeConfigElement> fromXml(final XmlElement configRootNode) throws DocumentedException {
Map<String, AttributeConfigElement> retVal = Maps.newHashMap();
// FIXME add identity map to runtime data
Map<String, AttributeReadingStrategy> strats = new ObjectXmlReader().prepareReading(yangToAttrConfig, Collections.<String, Map<Optional<Revision>, IdentityMapping>>emptyMap());
for (Entry<String, AttributeReadingStrategy> readStratEntry : strats.entrySet()) {
List<XmlElement> configNodes = configRootNode.getChildElements(readStratEntry.getKey());
AttributeConfigElement readElement = readStratEntry.getValue().readElement(configNodes);
retVal.put(readStratEntry.getKey(), readElement);
}
resolveConfiguration(retVal);
return retVal;
}
Aggregations