예제 #1
0
  private NestedApplCond shiftNestedApplCondAlongEmbMorphism(
      final NestedApplCond cond, final OrdinaryMorphism embedding, final AttrContext ac) {

    if (cond.getSource() == embedding.getSource()) {
      final OrdinaryMorphism condIso = cond.getTarget().isomorphicCopy();
      if (condIso == null) return null;

      final NestedApplCond shiftCond =
          new NestedApplCond(embedding.getTarget(), condIso.getTarget(), ac);
      if (this.propagateMapping(cond, shiftCond, embedding, condIso)) {

        for (int i = 0; i < cond.getNestedACs().size(); i++) {
          NestedApplCond nc = cond.getNestedACAt(i);
          final NestedApplCond shiftnc =
              shiftNestedApplCondAlongEmbMorphism(nc, condIso, cond.getAttrContext());
          if (shiftnc != null) {
            shiftnc.setName(nc.getName());
            shiftnc.setEnabled(nc.isEnabled());
            shiftCond.addNestedAC(shiftnc);
          } else return null;
        }

        return shiftCond;
      }

      shiftCond.dispose();
      condIso.dispose();
    }
    return null;
  }
예제 #2
0
  /**
   * Shift the specified application condition (NAC / PAC / General AC) along the specified
   * embedding morphism. Required:<br>
   * cond.getSource() == embedding.getSource()<br>
   * Result morphism:<br>
   * embedding.getTarget() -> copy of cond.getSource()
   *
   * @param cond an application condition
   * @param morph an embedding morphism
   * @return shifted application condition, Returns null if shifting failed.
   */
  private OrdinaryMorphism shiftApplCondAlongMorph(
      final OrdinaryMorphism cond, final OrdinaryMorphism morph) {

    if (cond.getSource() == morph.getSource()) {
      final OrdinaryMorphism condIso = cond.getTarget().isomorphicCopy();
      if (condIso == null) return null;

      final OrdinaryMorphism shiftCond =
          (cond instanceof NestedApplCond)
              ? BaseFactory.theFactory()
                  .createGeneralMorphism(morph.getTarget(), condIso.getTarget())
              : BaseFactory.theFactory().createMorphism(morph.getTarget(), condIso.getTarget());

      final Enumeration<GraphObject> condDom = cond.getDomain();
      while (condDom.hasMoreElements()) {
        GraphObject go = condDom.nextElement();
        GraphObject condImg = cond.getImage(go);
        if (condImg != null) {
          GraphObject embedImg = morph.getImage(go);
          GraphObject isoImg = condIso.getImage(condImg);
          if (embedImg != null && isoImg != null) {
            try {
              shiftCond.addMapping(embedImg, isoImg);
            } catch (BadMappingException ex) {
              shiftCond.dispose();
              condIso.dispose(false, true);
              return null;
            }
          } else {
            shiftCond.dispose();
            condIso.dispose(false, true);
            return null;
          }
        }
      }
      return shiftCond;
    }
    return null;
  }
예제 #3
0
  public boolean doStep(Rule r) {
    Match match = gratra.createMatch(r);
    System.out.println("The match was: " + match.getRule().getName().toString());

    // olga
    while (match.nextCompletion()) {
      if (match.isValid()) {
        try {
          Morphism co = StaticStep.execute(match);
          System.out.println("Rule  " + match.getRule().getName() + " : step is done");
          didTransformation = true;
          Graph graph = co.getOriginal();
          Graph graph2 = co.getImage();
          System.out.println();
          //					System.out.println("The image parameters are: " + graph.toString());
          //					System.out.println("The OUTPUT parameters are: " + graph2.toString());

          // olga
          outPar = getOutputParameters(r, outPar);
          for (int i = 0; i < outPar.size(); i++) {
            VarMember p = outPar.get(i);
            String parVal = getValueOfOutputParameter(p, r, (OrdinaryMorphism) co);
            this.outParVal.put(p.getName(), parVal);
          }

          ((OrdinaryMorphism) co).dispose();
          return true;
        } catch (TypeException ex) {
          ex.printStackTrace();
          gragra.destroyMatch(match);
          System.out.println(
              "Rule  "
                  + match.getRule().getName()
                  + " : step of match failed : "
                  + ex.getMessage());
        }
      } else
        System.out.println(
            "Rule  "
                + match.getRule().getName()
                + " : a match completion is not valid; try to find the next ones");
    }
    System.out.println("Rule  " + match.getRule().getName() + " : match could not be found");
    return false;
    // gragra.destroyMatch(match);
    // match.clear();
  }