Ejemplo n.º 1
0
 // TODO delete - implemented in the vcml object creator
 public static Constraint mkConstraint(final String name, final Description description) {
   final Constraint object = VCML.createConstraint();
   object.setName(name);
   object.setDescription(description);
   object.setSource(mkConstraintSource());
   return object;
 }
  public void run(
      Constraint object,
      Resource resource,
      IProgressMonitor monitor,
      Map<String, VCObject> seenObjects,
      List<Option> globalOptions)
      throws JCoException {
    // determine name of containing dependencyNet
    // TODO implement finding containing dependency net with ECoreUtils
    DependencyNet dependencyNet = null;
    VcmlModel model = (VcmlModel) object.eContainer();
    for (Object o :
        EcoreUtil.getObjectsByType(model.getObjects(), VcmlPackage.Literals.DEPENDENCY_NET)) {
      DependencyNet depNet = (DependencyNet) o;
      if (depNet.getConstraints().contains(object)) {
        dependencyNet = depNet;
        break;
      }
    }

    beginTransaction();
    JCoFunction function = getJCoFunction("CAMA_CNET_CONSTRAINT_MAINTAIN", monitor);
    JCoParameterList ipl = function.getImportParameterList();

    handleOptions(object.getOptions(), globalOptions, ipl, "CHANGE_NO", null);

    ipl.setValue("CONSTRAINT", object.getName());
    if (dependencyNet != null) {
      ipl.setValue("CONSTRAINT_NET", dependencyNet.getName());
    }
    ipl.setValue("DELETE_FLAG", "X");
    try {
      execute(function, monitor, "DELETE " + object.getName());
      endTransaction();
    } catch (AbapException e) {
      handleAbapException(e);
    }
  }