/** Create mapping pairs of objects of the embedding morphisms. */ private void mapKernel2MultiObject(final MultiRule multiRule) { final OrdinaryMorphism embLeft = multiRule.getEmbeddingLeft(); final Enumeration<GraphObject> domLeft = embLeft.getDomain(); while (domLeft.hasMoreElements()) { final GraphObject kern = domLeft.nextElement(); multiRule.mapKernel2MultiObject(kern, embLeft.getImage(kern)); } // final Enumeration<GraphObject> enLeft = multiRule.getLeft().getElements(); // while (enLeft.hasMoreElements()) { // final GraphObject obj = enLeft.nextElement(); // if (embLeft.getInverseImage(obj).hasMoreElements()){ // multiRule.mapKernel2MultiObject(embLeft.getInverseImage(obj).nextElement(), obj); // } // } final OrdinaryMorphism embRight = multiRule.getEmbeddingRight(); final Enumeration<GraphObject> domRight = embRight.getDomain(); while (domRight.hasMoreElements()) { final GraphObject kern = domRight.nextElement(); multiRule.mapKernel2MultiObject(kern, embRight.getImage(kern)); } // final Enumeration<GraphObject> enRight = multiRule.getRight().getElements(); // while (enRight.hasMoreElements()) { // final GraphObject obj = enRight.nextElement(); // if (embRight.getInverseImage(obj).hasMoreElements()) { // multiRule.mapKernel2MultiObject(embRight.getInverseImage(obj).nextElement(), obj); // } // } }
private boolean propagateMapping( final OrdinaryMorphism from, final OrdinaryMorphism to, final OrdinaryMorphism above1, final OrdinaryMorphism above2) { final Enumeration<GraphObject> condDom = from.getDomain(); while (condDom.hasMoreElements()) { GraphObject go = condDom.nextElement(); GraphObject condImg = from.getImage(go); if (condImg != null) { GraphObject embedImg = above1.getImage(go); GraphObject isoImg = above2.getImage(condImg); if (embedImg != null && isoImg != null) { try { to.addMapping(embedImg, isoImg); } catch (BadMappingException ex) { return false; } } // else // return false; } } return true; }
// olga: use comatch after step ia done to get values of OUTPUT parameters of a rule String getValueOfOutputParameter(VarMember p, Rule r, OrdinaryMorphism comatch) { if (p != null && r != null && comatch != null) { Enumeration<GraphObject> rightObjs = comatch.getDomain(); while (rightObjs.hasMoreElements()) { GraphObject obj = rightObjs.nextElement(); if (obj.getAttribute() != null) { ValueTuple vt = (ValueTuple) obj.getAttribute(); for (int i = 0; i < vt.getNumberOfEntries(); i++) { ValueMember vm = vt.getEntryAt(i); if (vm.isSet() && vm.getExpr().isVariable() && vm.getExprAsText().equals(p.getName())) { // we found an object obj inside of the RHS which uses the output parameter p, // now we will find an appropriate graph object // and to get the value of the output parameter GraphObject go = comatch.getImage(obj); ValueTuple vt_go = (ValueTuple) go.getAttribute(); ValueMember vm_go = vt_go.getEntryAt(vm.getName()); String parVal = vm_go.getExprAsText(); System.out.println( parVal + " is value of OUTPUT parameter: --" + p.getName() + "-- of rule: " + r.getName()); return parVal; } } } } } return null; }
/** * 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; }