Beispiel #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;
  }
Beispiel #2
0
  private boolean nacIsUsingVariable(
      final VarMember var, final AttrConditionTuple act, final List<OrdinaryMorphism> nacs) {

    for (int l = 0; l < nacs.size(); l++) {
      final OrdinaryMorphism nac = nacs.get(l);
      if (nac.getTarget().isUsingVariable(var)) {
        return true;
      }
      Vector<String> nacVars = nac.getTarget().getVariableNamesOfAttributes();
      for (int j = 0; j < nacVars.size(); j++) {
        String varName = nacVars.get(j);
        for (int k = 0; k < act.getNumberOfEntries(); k++) {
          CondMember cond = (CondMember) act.getMemberAt(k);
          Vector<String> condVars = cond.getAllVariables();
          if (condVars.contains(varName) && condVars.contains(var.getName())) {
            return true;
          }
        }
      }
    }
    return false;
  }
Beispiel #3
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;
  }