/** * Checks whether its kernel rule is applicable at the specified graph by the specified matching * strategy or not. */ public boolean isApplicable( final Graph g, final MorphCompletionStrategy strategy, final boolean doCheckIfReadyToTransform) { boolean result = this.enabled; if (result && doCheckIfReadyToTransform) { result = this.isReadyToTransform(); } if (result) { result = false; Match m = BaseFactory.theFactory().createMatch(this.kernelRule, g); if (m != null) { m.setCompletionStrategy(strategy, true); m.enableInputParameter(false); // ((VarTuple) this.getAttrContext().getVariables()).showVariables(); // ((VarTuple) m.getAttrContext().getVariables()).showVariables(); if (m.nextCompletion()) { result = true; } m.dispose(); } } return result; }
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(); }