private void transformFeature(Feature feature) {
    createFeatureConstraint(feature);
    EList<Group> groups = feature.getGroups();
    for (Group group : groups) {
      transformGroup(group);
    }

    EList<Attribute> attributes = feature.getAttributes();
    for (Attribute attribute : attributes) {
      transformAttribute(attribute);
      // createAbstractAttributeConstraint(attribute);
    }
  }
  private IntegerVariable createFeatureVariable(Feature feature) {
    String id = feature.getId();
    // an unbound feature has cardinality [0..1],
    // a selected feature has cardinality [1..1],
    // a deselected feature has cardinality [0..0]
    int minCardinality = (FeatureState.SELECTED.equals(feature.getConfigurationState())) ? 1 : 0;
    int maxCardinality = (FeatureState.DESELECTED.equals(feature.getConfigurationState())) ? 0 : 1;

    log.debug(
        "Create IntegerVariable for '" + id + "' [" + minCardinality + "," + maxCardinality + "].");
    IntegerVariable intNodeVariable = Choco.makeIntVar(id, minCardinality, maxCardinality);
    getModel().addVariable(intNodeVariable);
    nodeVariables.put(id, intNodeVariable);
    return intNodeVariable;
  }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 public Feature getFeature() {
   if (feature != null && feature.eIsProxy()) {
     InternalEObject oldFeature = (InternalEObject) feature;
     feature = (Feature) eResolveProxy(oldFeature);
     if (feature != oldFeature) {
       if (eNotificationRequired())
         eNotify(
             new ENotificationImpl(
                 this,
                 Notification.RESOLVE,
                 TermPackage.FEATURE_REF__FEATURE,
                 oldFeature,
                 feature));
     }
   }
   return feature;
 }
  private void createFeatureConstraint(Feature feature) {
    IntegerVariable childVariable = getOrCreateVariable(feature);

    int minCardinality = 0;
    int maxCardinality = 1;

    Constraint greaterThan = Choco.geq(childVariable, minCardinality);
    Constraint smallerThan = Choco.leq(childVariable, maxCardinality);
    Constraint thenConstraint = Choco.and(greaterThan, smallerThan);

    EObject featureContainer = feature.eContainer();
    if (featureContainer instanceof Group) {
      Group parentGroup = (Group) featureContainer;

      EObject groupContainer = parentGroup.eContainer();
      if (groupContainer instanceof Feature) {
        Feature parentFeature = (Feature) groupContainer;

        IntegerVariable parentVariable = getOrCreateVariable(parentFeature);

        // feature value must be in feature cardinality boundaries
        Constraint parentSelected = Choco.gt(parentVariable, 0);
        Constraint parentSelectedAndChildCardinality =
            Choco.implies(parentSelected, thenConstraint);
        getModel().addConstraint(parentSelectedAndChildCardinality);

        Constraint childSelected = Choco.gt(childVariable, 0);
        Constraint impliesConstraint = Choco.implies(childSelected, parentSelected);
        getModel().addConstraint(impliesConstraint);
      }

    } else {
      // handle rootgroup
      Constraint greater = Choco.gt(childVariable, minCardinality);
      getModel().addConstraint(greater);
    }
  }