use of org.opendaylight.yangtools.yang.common.Revision 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.yangtools.yang.common.Revision in project controller by opendaylight.
the class ConfigSubsystemFacade method getConfigMapping.
public Config getConfigMapping() {
final YangStoreContext snapshot = yangStoreService.getCurrentSnapshot();
Map<String, Map<String, ModuleConfig>> factories = transformMbeToModuleConfigs(snapshot.getModuleMXBeanEntryMap());
Map<String, Map<Optional<Revision>, IdentityMapping>> identitiesMap = transformIdentities(snapshot.getModules());
return new Config(factories, identitiesMap, snapshot.getEnumResolver());
}
use of org.opendaylight.yangtools.yang.common.Revision 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);
}
Aggregations