Package com.puppetlabs.geppetto.catalog

Examples of com.puppetlabs.geppetto.catalog.CatalogResourceParameter


   */
  protected Iterable<CatalogResourceParameter> getParameterIterable(CatalogResource r) {
    Iterable<CatalogResourceParameter> result = r.getParameters();
    if(r.isExported() || r.isVirtual()) {
      if(r.isExported()) {
        CatalogResourceParameter p = CatalogFactory.eINSTANCE.createCatalogResourceParameter();
        p.setName("exported");
        p.getValue().add("true");
        result = Iterables.concat(result, Collections.singleton(p));
      }
      if(r.isVirtual()) {
        CatalogResourceParameter p = CatalogFactory.eINSTANCE.createCatalogResourceParameter();
        p.setName("virtual");
        p.getValue().add("true");
        result = Iterables.concat(result, Collections.singleton(p));
      }
    }
    return result;
  }
View Full Code Here


    }

    @Override
    public CatalogResourceParameter deserialize(JsonElement json, java.lang.reflect.Type typeOfT,
        JsonDeserializationContext context) throws JsonParseException {
      final CatalogResourceParameter result = CatalogFactory.eINSTANCE.createCatalogResourceParameter();
      JsonObject jsonObj = json.getAsJsonObject();

      result.setName(getString(jsonObj, "name"));
      JsonObject valueObj = jsonObj.getAsJsonObject("value");
      if(valueObj.isJsonArray())
        deserializeInto(valueObj, result.getValue(), String.class, context);
      else
        result.getValue().add(valueObj.getAsString());

      return result;
    }
View Full Code Here

      // }
      if(json != null) {
        JsonObject parameterHash = json.getAsJsonObject();
        EList<CatalogResourceParameter> pList = result.getParameters();
        for(Map.Entry<String, JsonElement> entry : parameterHash.entrySet()) {
          CatalogResourceParameter rp = CatalogFactory.eINSTANCE.createCatalogResourceParameter();
          rp.setName(entry.getKey());
          if(entry.getValue().isJsonArray()) {
            deserializeInto(entry.getValue(), rp.getValue(), String.class, context);
            // StringBuilder values = new StringBuilder();
            // JsonArray multiValue = entry.getValue().getAsJsonArray();
            // for(JsonElement element : multiValue)
            // values.append(element.getAsString());
            // values.append(", ");
            // if(values.length() > 1)
            // values.setLength(values.length() - 2);
            // rp.setValue(values.toString());
          }
          else if(entry.getValue().isJsonPrimitive()) {
            rp.getValue().add(entry.getValue().getAsString());
          }
          else if(entry.getValue().isJsonNull())
            rp.getValue().add("(null)");
          else
            rp.getValue().add("DATA"); // don't know how to deserialize in this case, could be anything
          pList.add(rp);
        }

      }
View Full Code Here

TOP

Related Classes of com.puppetlabs.geppetto.catalog.CatalogResourceParameter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.