Package com.puppetlabs.geppetto.pp

Examples of com.puppetlabs.geppetto.pp.AttributeOperations


        if(result == null)
          result = defaultCase(theEObject);
        return result;
      }
      case PPPackage.ATTRIBUTE_OPERATIONS: {
        AttributeOperations attributeOperations = (AttributeOperations) theEObject;
        T result = caseAttributeOperations(attributeOperations);
        if(result == null)
          result = defaultCase(theEObject);
        return result;
      }
View Full Code Here


      case 1:
        styles.add(o.getResourceData().get(0).getNameExpr() != null
            ? ResourceStyle.SINGLEBODY_TITLE
            : ResourceStyle.SINGLEBODY_NO_TITLE);
        // if there is more than 1 attribute operation, the resource can't be compacted
        AttributeOperations attributes = o.getResourceData().get(0).getAttributes();
        if(compactResource && (attributes == null || attributes.getAttributes().size() < 2))
          styles.add(ResourceStyle.COMPACTABLE);
        break;
      default:
        styles.add(ResourceStyle.MULTIPLE_BODIES);
        break;
View Full Code Here

   * <!-- end-user-doc -->
   *
   * @generated
   */
  public NotificationChain basicSetAttributes(AttributeOperations newAttributes, NotificationChain msgs) {
    AttributeOperations oldAttributes = attributes;
    attributes = newAttributes;
    if(eNotificationRequired()) {
      ENotificationImpl notification = new ENotificationImpl(
        this, Notification.SET, PPPackage.COLLECT_EXPRESSION__ATTRIBUTES, oldAttributes, newAttributes);
      if(msgs == null)
View Full Code Here

      }
    }
    // check for duplicate use of attribute/parameter
    Set<String> duplicates = Sets.newHashSet();
    Set<String> processed = Sets.newHashSet();
    AttributeOperations aos = o;

    // find duplicates
    for(AttributeOperation ao : aos.getAttributes()) {
      final String key = ao.getKey();
      if(processed.contains(key))
        duplicates.add(key);
      processed.add(key);
    }
    // mark all instances of duplicate name
    if(duplicates.size() > 0)
      for(AttributeOperation ao : aos.getAttributes())
        if(duplicates.contains(ao.getKey()))
          acceptor.acceptError(
            "Duplicate attribute: '" + ao.getKey() + "'", ao, PPPackage.Literals.ATTRIBUTE_OPERATION__KEY,
            IPPDiagnostics.ISSUE__RESOURCE_DUPLICATE_PARAMETER);
  }
View Full Code Here

    VirtualCollectQuery q = pf.createVirtualCollectQuery();
    q.setExpr(predicate);
    ce.setQuery(q);

    // -- add some attributes
    AttributeOperations aos = pf.createAttributeOperations();
    aos.getAttributes().add(createAttributeDefinition("role", "jedi"));
    aos.getAttributes().add(createAttributeAddition("tasks", "rakeleaves"));
    ce.setAttributes(aos);

    String s = serializeFormatted(pp);
    assertEquals("serialization should produce specified result", Sample_Collect, s);
View Full Code Here

    // -- test without attributes
    tester.validator().checkCollectExpression(ce);
    tester.diagnose().assertOK();

    // -- add some attributes
    AttributeOperations aos = pf.createAttributeOperations();
    aos.getAttributes().add(createAttributeDefinition("x", "b"));
    aos.getAttributes().add(createAttributeAddition("y", "b"));
    ce.setAttributes(aos);
    tester.validator().checkCollectExpression(ce);
    tester.diagnose().assertOK();

    // --test different class references
View Full Code Here

   * <!-- end-user-doc -->
   *
   * @generated
   */
  public NotificationChain basicSetAttributes(AttributeOperations newAttributes, NotificationChain msgs) {
    AttributeOperations oldAttributes = attributes;
    attributes = newAttributes;
    if(eNotificationRequired()) {
      ENotificationImpl notification = new ENotificationImpl(
        this, Notification.SET, PPPackage.RESOURCE_BODY__ATTRIBUTES, oldAttributes, newAttributes);
      if(msgs == null)
View Full Code Here

      issue, "Move ensure first.", "Moves the ensure first among the set attributes", null,
      new ISemanticModification() {

        @Override
        public void apply(EObject element, IModificationContext context) throws Exception {
          AttributeOperations aos = (AttributeOperations) element.eContainer();
          aos.getAttributes().move(0, (AttributeOperation) element);
        }
      });
  }
View Full Code Here

  }

  protected ResourceBody createResourceBody(boolean additive, Expression titleExpr, Object... keyValPairs) {
    ResourceBody rb = pf.createResourceBody();
    rb.setNameExpr(titleExpr);
    AttributeOperations aos = pf.createAttributeOperations();
    EList<AttributeOperation> aoList = aos.getAttributes();
    for(int i = 0; i < keyValPairs.length; i++) {
      AttributeOperation ao = pf.createAttributeOperation();
      ao.setOp(additive
          ? "+>"
          : "=>");
      if(!(keyValPairs[i] instanceof String))
        throw new IllegalArgumentException("Bad test spec, key not a String");
      ao.setKey((String) (keyValPairs[i++]));

      if(keyValPairs[i] instanceof String) {
        SingleQuotedString valueExpr = pf.createSingleQuotedString();
        valueExpr.setText((String) (keyValPairs[i]));
        ao.setValue(valueExpr);
      }
      else if(keyValPairs[i] instanceof Expression)
        ao.setValue((Expression) keyValPairs[i]);
      else
        throw new IllegalArgumentException("Bad test spec, keyValPair value neither String not expression");
      aoList.add(ao);
    }
    if(aos.getAttributes().size() > 0)
      rb.setAttributes(aos);
    return rb;
  }
View Full Code Here

TOP

Related Classes of com.puppetlabs.geppetto.pp.AttributeOperations

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.