Search in sources :

Example 1 with EditStrategyType

use of org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType in project controller by opendaylight.

the class InstanceConfigElementResolved method parseStrategy.

static EditStrategyType parseStrategy(final String currentStrategy, final EditStrategyType defaultStrategy) throws OperationNotPermittedException {
    EditStrategyType parsedStrategy = EditStrategyType.valueOf(currentStrategy);
    EditStrategyType.compareParsedStrategyToDefaultEnforcing(parsedStrategy, defaultStrategy);
    return parsedStrategy;
}
Also used : EditStrategyType(org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType)

Example 2 with EditStrategyType

use of org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType in project controller by opendaylight.

the class Config method fromXmlModulesResolved.

// TODO refactor, replace string representing namespace with namespace class
// TODO refactor, replace Map->Multimap with e.g. ConfigElementResolved
// class
public Map<String, Multimap<String, ModuleElementResolved>> fromXmlModulesResolved(final XmlElement xml, final EditStrategyType defaultEditStrategyType, final ServiceRegistryWrapper serviceTracker) throws DocumentedException {
    Optional<XmlElement> modulesElement = getModulesElement(xml);
    List<XmlElement> moduleElements = getModulesElementList(modulesElement);
    Map<String, Multimap<String, ModuleElementResolved>> retVal = Maps.newHashMap();
    ResolvingStrategy<ModuleElementResolved> resolvingStrategy = (moduleMapping, moduleElement, serviceTracker1, instanceName, moduleNamespace, defaultStrategy) -> moduleMapping.fromXml(moduleElement, serviceTracker1, instanceName, moduleNamespace, defaultStrategy, identityMap, enumResolver);
    for (XmlElement moduleElement : moduleElements) {
        resolveModule(retVal, serviceTracker, moduleElement, defaultEditStrategyType, resolvingStrategy);
    }
    return retVal;
}
Also used : XmlUtil(org.opendaylight.controller.config.util.xml.XmlUtil) Multimap(com.google.common.collect.Multimap) EditStrategyType(org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType) HashMultimap(com.google.common.collect.HashMultimap) Lists(com.google.common.collect.Lists) Optional(com.google.common.base.Optional) Document(org.w3c.dom.Document) Map(java.util.Map) EnumResolver(org.opendaylight.controller.config.facade.xml.osgi.EnumResolver) DocumentedException(org.opendaylight.controller.config.util.xml.DocumentedException) IdentityMapping(org.opendaylight.controller.config.facade.xml.mapping.IdentityMapping) Collection(java.util.Collection) Set(java.util.Set) ObjectName(javax.management.ObjectName) Maps(com.google.common.collect.Maps) Preconditions.checkState(com.google.common.base.Preconditions.checkState) List(java.util.List) Revision(org.opendaylight.yangtools.yang.common.Revision) Element(org.w3c.dom.Element) Entry(java.util.Map.Entry) Preconditions(com.google.common.base.Preconditions) XmlElement(org.opendaylight.controller.config.util.xml.XmlElement) ObjectNameUtil(org.opendaylight.controller.config.api.jmx.ObjectNameUtil) Collections(java.util.Collections) XmlMappingConstants(org.opendaylight.controller.config.util.xml.XmlMappingConstants) Multimap(com.google.common.collect.Multimap) HashMultimap(com.google.common.collect.HashMultimap) XmlElement(org.opendaylight.controller.config.util.xml.XmlElement)

Example 3 with EditStrategyType

use of org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType in project controller by opendaylight.

the class Config method fromXmlModulesMap.

/**
 * return a map containing namespace -&gt; moduleName -&gt; instanceName map.
 * Attribute parsing is omitted.
 */
public Map<String, Multimap<String, ModuleElementDefinition>> fromXmlModulesMap(final XmlElement xml, final EditStrategyType defaultEditStrategyType, final ServiceRegistryWrapper serviceTracker) throws DocumentedException {
    Optional<XmlElement> modulesElement = getModulesElement(xml);
    List<XmlElement> moduleElements = getModulesElementList(modulesElement);
    Map<String, Multimap<String, ModuleElementDefinition>> retVal = Maps.newHashMap();
    ResolvingStrategy<ModuleElementDefinition> resolvingStrategy = (moduleMapping, moduleElement, serviceTracker1, instanceName, moduleNamespace, defaultStrategy) -> {
        // TODO: add check for conflicts between global and local edit
        // strategy
        String perInstanceEditStrategy = moduleElement.getAttribute(XmlMappingConstants.OPERATION_ATTR_KEY, XmlMappingConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
        return new ModuleElementDefinition(instanceName, perInstanceEditStrategy, defaultStrategy);
    };
    for (XmlElement moduleElement : moduleElements) {
        resolveModule(retVal, serviceTracker, moduleElement, defaultEditStrategyType, resolvingStrategy);
    }
    return retVal;
}
Also used : XmlUtil(org.opendaylight.controller.config.util.xml.XmlUtil) Multimap(com.google.common.collect.Multimap) EditStrategyType(org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType) HashMultimap(com.google.common.collect.HashMultimap) Lists(com.google.common.collect.Lists) Optional(com.google.common.base.Optional) Document(org.w3c.dom.Document) Map(java.util.Map) EnumResolver(org.opendaylight.controller.config.facade.xml.osgi.EnumResolver) DocumentedException(org.opendaylight.controller.config.util.xml.DocumentedException) IdentityMapping(org.opendaylight.controller.config.facade.xml.mapping.IdentityMapping) Collection(java.util.Collection) Set(java.util.Set) ObjectName(javax.management.ObjectName) Maps(com.google.common.collect.Maps) Preconditions.checkState(com.google.common.base.Preconditions.checkState) List(java.util.List) Revision(org.opendaylight.yangtools.yang.common.Revision) Element(org.w3c.dom.Element) Entry(java.util.Map.Entry) Preconditions(com.google.common.base.Preconditions) XmlElement(org.opendaylight.controller.config.util.xml.XmlElement) ObjectNameUtil(org.opendaylight.controller.config.api.jmx.ObjectNameUtil) Collections(java.util.Collections) XmlMappingConstants(org.opendaylight.controller.config.util.xml.XmlMappingConstants) Multimap(com.google.common.collect.Multimap) HashMultimap(com.google.common.collect.HashMultimap) XmlElement(org.opendaylight.controller.config.util.xml.XmlElement)

Example 4 with EditStrategyType

use of org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType in project controller by opendaylight.

the class ArrayAttributeReadingStrategy method readElementHook.

@Override
AttributeConfigElement readElementHook(final List<XmlElement> configNodes) throws DocumentedException {
    List<Object> innerList = Lists.newArrayList();
    EditStrategyType innerEditStrategy = null;
    for (XmlElement configNode : configNodes) {
        final AttributeConfigElement attributeConfigElement = innerStrategy.readElement(Lists.newArrayList(configNode));
        if (attributeConfigElement.getEditStrategy().isPresent()) {
            // TODO this sets the last operation for the entire array
            innerEditStrategy = attributeConfigElement.getEditStrategy().get();
        }
        innerList.add(attributeConfigElement.getValue());
    }
    return innerEditStrategy == null ? AttributeConfigElement.create(getNullableDefault(), innerList) : AttributeConfigElement.create(getNullableDefault(), innerList, innerEditStrategy);
}
Also used : XmlElement(org.opendaylight.controller.config.util.xml.XmlElement) EditStrategyType(org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType)

Aggregations

EditStrategyType (org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType)4 XmlElement (org.opendaylight.controller.config.util.xml.XmlElement)3 Optional (com.google.common.base.Optional)2 Preconditions (com.google.common.base.Preconditions)2 Preconditions.checkState (com.google.common.base.Preconditions.checkState)2 HashMultimap (com.google.common.collect.HashMultimap)2 Lists (com.google.common.collect.Lists)2 Maps (com.google.common.collect.Maps)2 Multimap (com.google.common.collect.Multimap)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 List (java.util.List)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 Set (java.util.Set)2 ObjectName (javax.management.ObjectName)2 ObjectNameUtil (org.opendaylight.controller.config.api.jmx.ObjectNameUtil)2 IdentityMapping (org.opendaylight.controller.config.facade.xml.mapping.IdentityMapping)2 EnumResolver (org.opendaylight.controller.config.facade.xml.osgi.EnumResolver)2 DocumentedException (org.opendaylight.controller.config.util.xml.DocumentedException)2