예제 #1
0
  public EditAction generate(final Random random, FeatureModel model, OperationType operationType) {
    EditAction action = new EditAction();
    action.setEditObjectType(EditObjectType.FeatureGroup);

    if (operationType == OperationType.Random) {
      operationType = random.nextBoolean() ? OperationType.AllAdd : OperationType.AllRemove;
    }
    if (operationType == OperationType.AllAdd) {
      action.setEditType(EditType.Add);
      FeatureGroup group = new FeatureGroup();

      List<Feature> children = new ArrayList<Feature>();
      for (int i = 0; i < random.nextInt(3); i++) {
        children.add(new Feature(Utility.getNewFeatureName(false)));
      }
      group.setChildren(children);
      action.addParameter("group", group);

      action.addParameter("targetCompound", Utility.getRandomCompound(model, random, false));
    } else {
      action.setEditType(EditType.Remove);
    }

    return action;
  }
예제 #2
0
  public EditAction generate(final Random random, FeatureModel model, OperationType operationType) {
    EditAction action = new EditAction();
    action.setEditType(EditType.Set);
    action.setEditObjectType(EditObjectType.Name);

    action.addParameter("newName", Utility.getRandomString(5, random));
    action.addParameter("feature", Utility.getRandomFeature(model, random, false));

    return action;
  }
예제 #3
0
  public EditAction generate(final Random random, FeatureModel model, OperationType operationType) {
    EditAction action = new EditAction();
    action.setEditType(EditType.Set);
    action.setEditObjectType(EditObjectType.Optionality);

    action.addParameter("mandatory", Boolean.valueOf(random.nextBoolean()));
    action.addParameter("feature", Utility.getRandomFeature(model, random, false));
    return action;
  }
예제 #4
0
  public EditAction generate(final Random random, FeatureModel model, OperationType operationType) {
    EditAction action = new EditAction();
    action.setEditType(EditType.Set);
    action.setEditObjectType(EditObjectType.Cardinality);

    action.addParameter("minCard", random.nextInt(5));
    action.addParameter("maxCard", random.nextInt(5));
    action.addParameter("feature", Utility.getRandomFeature(model, random, false));
    return action;
  }
예제 #5
0
  public EditAction generate(final Random random, FeatureModel model, OperationType operationType) {
    EditAction action = new EditAction();

    if (operationType == OperationType.Random) {
      operationType = random.nextBoolean() ? OperationType.AllAdd : OperationType.AllRemove;
    }
    if (operationType == OperationType.AllAdd) {
      action.setEditType(EditType.Add);
      action.addParameter("featureA", Utility.getRandomFeature(model, random, false).getName());
      action.addParameter("featureB", Utility.getRandomFeature(model, random, false).getName());
    } else {
      action.setEditType(EditType.Remove);
      action.addParameter(
          "constraint", model.getConstraint(random.nextInt(model.getConstraintCount())));
    }
    action.setEditObjectType(EditObjectType.Require);

    return action;
  }
예제 #6
0
  public EditAction generate(final Random random, FeatureModel model, OperationType operationType) {
    EditAction action = new EditAction();
    action.setEditObjectType(EditObjectType.Compound);

    if (operationType == OperationType.Random) {
      operationType = random.nextBoolean() ? OperationType.AllAdd : OperationType.AllRemove;
    }
    if (operationType == OperationType.AllAdd) {
      action.setEditType(EditType.Add);
      action.addParameter("targetFeature", Utility.getRandomFeature(model, random, false));

      Feature newCompound = new Feature(Utility.getNewFeatureName(true));
      action.addParameter("newCompound", newCompound);
    } else {
      action.setEditType(EditType.Remove);
      action.addParameter("compound", Utility.getRandomCompound(model, random, false));
    }

    return action;
  }
예제 #7
0
  public EditAction generate(final Random random, FeatureModel model, OperationType operationType) {
    EditAction action = new EditAction();
    action.setEditType(EditType.Set);
    action.setEditObjectType(EditObjectType.GroupType);

    action.addParameter("feature", Utility.getRandomCompound(model, random, false));
    FeatureGroupType type;
    if (random.nextBoolean()) {
      type = FeatureGroupType.Alternative;
    } else {
      if (random.nextBoolean()) {
        type = FeatureGroupType.Or;
      } else {
        type = FeatureGroupType.And;
      }
    }
    action.addParameter("newGroupType", type);
    return action;
  }