brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Support "externalised config" in ...
Date Thu, 07 Jan 2016 14:53:13 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/1130#discussion_r49079996
  
    --- Diff: brooklyn-server/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
---
    @@ -391,18 +396,61 @@ else for (String key: otherKeys) {
         }
     
         @SuppressWarnings("unchecked")
    -    private void collectCatalogItems(String sourceYaml, Map<?,?> itemMetadata,
List<CatalogItemDtoAbstract<?, ?>> result, Map<?,?> parentMetadata) {
    +    private void collectCatalogItems(String sourceYaml, Map<String,Object> itemMetadata,
List<CatalogItemDtoAbstract<?, ?>> result, Map<String,?> parentMetadata)
{
     
             if (sourceYaml==null) sourceYaml = new Yaml().dump(itemMetadata);
     
    -        Map<Object,Object> catalogMetadata = MutableMap.builder().putAll(parentMetadata).putAll(itemMetadata).build();
    -        
    +        Map<String, Object> itemEvaluatedMetadata = MutableMap.of();
    +
    +        itemEvaluatedMetadata.putAll(itemMetadata);
    +        itemEvaluatedMetadata.remove("item");
    +        itemEvaluatedMetadata.remove("items");
    +
    +        Object itemKey = null;
    +        Object itemsKey = null;
    +        if (itemMetadata.containsKey("item")) {
    +            itemKey = itemMetadata.get("item");
    +        }
    +        if (itemMetadata.containsKey("items")) {
    +            itemsKey = itemMetadata.get("items");
    +        }
    +
    +        itemMetadata = mgmt.getConfig().getConfig(CampYamlParser.YAML_PARSER_KEY).parse(itemEvaluatedMetadata);
    +
    +        ExecutionContext ec = mgmt.getServerExecutionContext();
    +        for (Map.Entry<String, Object> item: itemMetadata.entrySet()) {
    --- End diff --
    
    Can we use `ValueResolver.deep(true)` to get it to check if the value is a list/map, so
you just have to call something like (untested code below):
    
        ...  = Tasks.resolveDeepValue(itemMetadata, Object.class, ec)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message