Coverage Report - org.deri.wsmo4j.io.serializer.wsml.VisitorSerializeWSMLTransitionRules
 
Classes in this File Line Coverage Branch Coverage Complexity
VisitorSerializeWSMLTransitionRules
0%
0/255
0%
0/118
0
 
 1  
 /*
 2  
  wsmo4j extension - a Choreography API and Reference Implementation
 3  
 
 4  
  Copyright (c) 2005, University of Innsbruck, Austria
 5  
  2006, Ontotext Lab. / SIRMA Group
 6  
 
 7  
  This library is free software; you can redistribute it and/or modify it under
 8  
  the terms of the GNU Lesser General Public License as published by the Free
 9  
  Software Foundation; either version 2.1 of the License, or (at your option)
 10  
  any later version.
 11  
  This library is distributed in the hope that it will be useful, but WITHOUT
 12  
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 13  
  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 14  
  details.
 15  
  You should have received a copy of the GNU Lesser General Public License along
 16  
  with this library; if not, write to the Free Software Foundation, Inc.,
 17  
  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 18  
  */
 19  
 
 20  
 package org.deri.wsmo4j.io.serializer.wsml;
 21  
 
 22  
 import java.util.*;
 23  
 
 24  
 import org.omwg.logicalexpression.*;
 25  
 import org.omwg.logicalexpression.terms.*;
 26  
 import org.omwg.ontology.*;
 27  
 import org.wsmo.common.*;
 28  
 import org.wsmo.common.exception.*;
 29  
 import org.wsmo.service.choreography.rule.*;
 30  
 import org.wsmo.service.orchestration.rule.*;
 31  
 import org.wsmo.service.rule.*;
 32  
 import org.wsmo.service.rule.Visitor;
 33  
 
 34  
 import com.ontotext.wsmo4j.parser.*;
 35  
 
 36  
 /**
 37  
  * Visitor Implementation Class for the Choreography Rules
 38  
  *
 39  
  * TODO: - FactMolecule - Update Rules
 40  
  *
 41  
  * <pre>
 42  
  *    Created on Sep 29, 2005
 43  
  *    Committed by $Author: morcen $
 44  
  *    $Source$
 45  
  * </pre>
 46  
  *
 47  
  * @author James Scicluna
 48  
  * @author Thomas Haselwanter
 49  
  * @author Vassil Momtchev
 50  
  *
 51  
  * @version $Revision: 1949 $ $Date: 2007-04-02 16:05:18 +0300 (Mon, 02 Apr 2007) $
 52  
  */
 53  0
 public class VisitorSerializeWSMLTransitionRules implements Visitor {
 54  
     private static final boolean USE_PREFFERED = true;
 55  
 
 56  
     private VisitorSerializeWSML logExpSer;
 57  
 
 58  
     private VisitorSerializeWSMLTerms termVisitor;
 59  
 
 60  
     private Stack<String> stack;
 61  
 
 62  0
     private int indentationLevel = 2;
 63  
 
 64  
     /**
 65  
      * Constructor for the Rules visitor.
 66  
      *
 67  
      * @param nsContainer
 68  
      *            A TopEntity object containing the namespace definitions
 69  
      */
 70  0
     public VisitorSerializeWSMLTransitionRules(TopEntity nsContainer) {
 71  0
         this.logExpSer = new VisitorSerializeWSML(nsContainer);
 72  0
         this.termVisitor = new VisitorSerializeWSMLTerms(nsContainer);
 73  0
         this.stack = new Stack<String>();
 74  0
     }
 75  
 
 76  
     /*
 77  
      * (non-Javadoc)
 78  
      *
 79  
      * @see org.wsmo.service.choreography.rule.Visitor#visitIfThen(org.wsmo.service.choreography.rule.IfThen)
 80  
      */
 81  
     public void visitChoreographyIfThen(ChoreographyIfThen rule) {
 82  0
         String sCond = this.helpCondition(rule.getCondition());
 83  0
         String sRules = this.helpNestedRules(rule.listNestedRules());
 84  0
         this.stack.push(getIndent() + "if " + sCond + " then\n" + sRules + getIndent() + "endIf\n");
 85  0
     }
 86  
     
 87  
     public void visitOrchestrationIfThen(OrchestrationIfThen rule) {
 88  0
         String sCond = this.helpCondition(rule.getCondition());
 89  0
         String sRules = this.helpNestedRules(rule.listNestedRules());
 90  0
         this.stack.push(getIndent() + "if " + sCond + " then\n" + sRules + getIndent() + "endIf\n");
 91  0
     }
 92  
 
 93  
     /*
 94  
      * (non-Javadoc)
 95  
      *
 96  
      * @see org.wsmo.service.choreography.rule.Visitor#visitForAll(org.wsmo.service.choreography.rule.ForAll)
 97  
      */
 98  
     public void visitChoreographyForAll(ChoreographyForAll rule) {
 99  0
         String sVars = this.helpVariableList(rule.listVariables());
 100  0
         String sCond = this.helpCondition(rule.getCondition());
 101  0
         String sRules = this.helpNestedRules(rule.listNestedRules());
 102  0
         this.stack.push(getIndent() + "forall " + sVars + " with " + sCond + " do \n" + sRules
 103  
                 + getIndent() + "endForall\n");
 104  0
     }
 105  
     
 106  
     public void visitOrchestrationForAll(OrchestrationForAll rule) {
 107  0
         String sVars = this.helpVariableList(rule.listVariables());
 108  0
         String sCond = this.helpCondition(rule.getCondition());
 109  0
         String sRules = this.helpNestedRules(rule.listNestedRules());
 110  0
         this.stack.push(getIndent() + "forall " + sVars + " with " + sCond + " do \n" + sRules
 111  
                 + getIndent() + "endForall\n");
 112  0
     }
 113  
 
 114  
     /*
 115  
      * (non-Javadoc)
 116  
      *
 117  
      * @see org.wsmo.service.choreography.rule.Visitor#visitChoose(org.wsmo.service.choreography.rule.Choose)
 118  
      */
 119  
     public void visitChoreographyChoose(ChoreographyChoose rule) {
 120  0
         String sVars = this.helpVariableList(rule.listVariables());
 121  0
         String sCond = this.helpCondition(rule.getCondition());
 122  0
         String sRules = this.helpNestedRules(rule.listNestedRules());
 123  0
         this.stack.push(getIndent() + "choose " + sVars + " with " + sCond + " do\n" + sRules
 124  
                 + getIndent() + "endChoose\n");
 125  0
     }
 126  
 
 127  
     public void visitOrchestrationChoose(OrchestrationChoose rule) {
 128  0
         String sVars = this.helpVariableList(rule.listVariables());
 129  0
         String sCond = this.helpCondition(rule.getCondition());
 130  0
         String sRules = this.helpNestedRules(rule.listNestedRules());
 131  0
         this.stack.push(getIndent() + "choose " + sVars + " with " + sCond + " do\n" + sRules
 132  
                 + getIndent() + "endChoose\n");
 133  0
     }
 134  
     
 135  
     /*
 136  
      * (non-Javadoc)
 137  
      *
 138  
      * @see org.wsmo.service.choreography.rule.Visitor#visitAdd(org.wsmo.service.choreography.rule.Add)
 139  
      */
 140  
     public void visitAdd(Add rule) {
 141  0
         this.stack.push(getIndent() + "add(" + this.helpCompoundFact(rule.getFact(), null) + ")\n");
 142  0
     }
 143  
 
 144  
     /*
 145  
      * (non-Javadoc)
 146  
      *
 147  
      * @see org.wsmo.service.choreography.rule.Visitor#visitDelete(org.wsmo.service.choreography.rule.Delete)
 148  
      */
 149  
     public void visitDelete(Delete rule) {
 150  0
         this.stack.push(getIndent() + "delete(" + this.helpCompoundFact(rule.getFact(), null)
 151  
                 + ")\n");
 152  0
     }
 153  
 
 154  
     /*
 155  
      * (non-Javadoc)
 156  
      *
 157  
      * @see org.wsmo.service.choreography.rule.Visitor#visitUpdate(org.wsmo.service.choreography.rule.Update)
 158  
      */
 159  
     public void visitUpdate(Update rule) {
 160  0
         this.stack.push(getIndent() + "update("
 161  
                 + this.helpCompoundFact(rule.getNewFact(), rule.getOldFact()) + ")\n");
 162  0
     }
 163  
     
 164  
     public void visitPerform(Perform rule) {
 165  
         
 166  0
     }
 167  
 
 168  
     /*
 169  
      * (non-Javadoc)
 170  
      *
 171  
      * @see org.wsmo.service.choreography.rule.Visitor#getSerializedObject()
 172  
      */
 173  
     public String getSerializedObject() {
 174  0
         return this.stack.pop();
 175  
     }
 176  
 
 177  
     private String helpCondition(Condition expr) {
 178  0
         expr.getRestrictedLogicalExpression().accept(this.logExpSer);
 179  0
         return "(" + this.logExpSer.getSerializedObject() + ")";
 180  
     }
 181  
 
 182  
     private String helpNestedRules(Set<? extends Rule> rules) {
 183  0
         String s = "";
 184  0
         indentationLevel++;
 185  0
         Iterator<? extends Rule> i = rules.iterator();
 186  0
         while (i.hasNext()) {
 187  0
             Rule r = i.next();
 188  0
             r.accept(this);
 189  0
             s += this.getSerializedObject();
 190  0
         }
 191  0
         indentationLevel--;
 192  0
         return s;
 193  
     }
 194  
 
 195  
     private String helpVariableList(Set<Variable> vars) {
 196  0
         String s = "{";
 197  0
         Iterator<Variable> i = vars.iterator();
 198  0
         while (i.hasNext()) {
 199  0
             Variable var = i.next();
 200  0
             var.accept(this.termVisitor);
 201  0
             s += this.termVisitor.getSerializedObject();
 202  0
             if (i.hasNext())
 203  0
                 s += ",";
 204  0
         }
 205  0
         return s + "}";
 206  
     }
 207  
 
 208  
     public String helpCompoundFact(CompoundFact newFact, CompoundFact oldFact) {
 209  0
         if (newFact == null) {
 210  0
             throw new IllegalArgumentException();
 211  
         }
 212  0
         StringBuffer buffer = new StringBuffer();
 213  0
         if (newFact instanceof MoleculeFact) {//deal with normal molecule facts
 214  0
             MoleculeFact newMolFact = (MoleculeFact) newFact;
 215  0
             MoleculeFact oldMolFact = null;
 216  0
             if (oldFact != null)
 217  0
                 if (oldFact instanceof MoleculeFact) {
 218  0
                     oldMolFact = (MoleculeFact) oldFact;
 219  
                 }
 220  
                 else {
 221  0
                     throw new WrappedInvalidModelException(new InvalidModelException(
 222  
                             "Both old and new Compound Facts must be of the same type "));
 223  
                 }
 224  0
             if (newMolFact.isEmpty()) {
 225  0
                 throw new WrappedInvalidModelException(new InvalidModelException(
 226  
                         "CompoundFact do not contains neither AttributeValueMolecule "
 227  
                                 + "nor MembershipMolecule!"));
 228  
             }
 229  0
             Term instanceId = null;
 230  0
             if (!newMolFact.listAttributeValueMolecules().isEmpty()) {
 231  0
                 instanceId = newMolFact.listAttributeValueMolecules().iterator().next()
 232  
                         .getLeftParameter();
 233  
             }
 234  
             else {
 235  0
                 instanceId = newMolFact.listMembershipMolecules().iterator().next()
 236  
                         .getLeftParameter();
 237  
             }
 238  0
             buffer.append(helpSerializeTerm(instanceId));
 239  
 
 240  
             if (USE_PREFFERED) {
 241  0
                 buffer.append(helpAttributeValues(newMolFact.listAttributeValueMolecules(),
 242  
                         oldMolFact == null ? new HashSet<AttributeValueMolecule>() : oldMolFact
 243  
                                 .listAttributeValueMolecules()));
 244  0
                 buffer.append(helpMembershipMolecules(newMolFact.listMembershipMolecules(),
 245  
                         oldMolFact == null ? new HashSet<MembershipMolecule>() : oldMolFact
 246  
                                 .listMembershipMolecules()));
 247  
             }
 248  
             else {
 249  
                 buffer.append(helpMembershipMolecules(newMolFact.listMembershipMolecules(),
 250  
                         oldMolFact == null ? new HashSet<MembershipMolecule>() : oldMolFact
 251  
                                 .listMembershipMolecules()));
 252  
                 buffer.append(helpAttributeValues(newMolFact.listAttributeValueMolecules(),
 253  
                         oldMolFact == null ? new HashSet<AttributeValueMolecule>() : oldMolFact
 254  
                                 .listAttributeValueMolecules()));
 255  
             }
 256  
 
 257  0
         }
 258  0
         else if (newFact instanceof RelationFact) {//deal with relation facts
 259  0
             if (oldFact != null) {
 260  0
                 buffer
 261  
                         .append(this.helpRelationFact((RelationFact) oldFact,
 262  
                                 (RelationFact) newFact));
 263  
             }
 264  
             else {
 265  0
                 buffer.append(this.helpRelationFact(null, (RelationFact) newFact));
 266  
             }
 267  
         }
 268  0
         return new String(buffer);
 269  
     }
 270  
 
 271  
     private String helpAttributeValues(Set<AttributeValueMolecule> newVals,
 272  
             Set<AttributeValueMolecule> oldVals) {
 273  0
         Set<Term> attributes = validateAttributeValues(newVals, oldVals);
 274  0
         if (attributes.size() == 0)
 275  0
             return "";
 276  
 
 277  0
         StringBuffer buffer = new StringBuffer(" [");
 278  0
         for (Iterator i = attributes.iterator(); i.hasNext();) {
 279  0
             Term attr = (Term) i.next();
 280  0
             buffer.append(helpSerializeTerm(attr));
 281  0
             buffer.append(" hasValue ");
 282  
 
 283  0
             Set<Term> replacedValues = new HashSet<Term>();
 284  0
             for (AttributeValueMolecule val : oldVals) {
 285  0
                 if (val.getAttribute().equals(attr))
 286  0
                     replacedValues.add(val.getRightParameter());
 287  
             }
 288  0
             Set<Term> replacingValues = new HashSet<Term>();
 289  0
             for (AttributeValueMolecule val : newVals) {
 290  0
                 if (val.getAttribute().equals(attr))
 291  0
                     replacingValues.add(val.getRightParameter());
 292  
             }
 293  
 
 294  0
             if (!replacedValues.isEmpty()) {
 295  0
                 buffer.append(helpTermList(replacedValues));
 296  0
                 buffer.append(" => ");
 297  
             }
 298  0
             buffer.append(helpTermList(replacingValues));
 299  0
             if (i.hasNext()) {
 300  0
                 buffer.append(", ");
 301  
             }
 302  0
         }
 303  
 
 304  0
         buffer.append("]");
 305  0
         return new String(buffer);
 306  
     }
 307  
 
 308  
     private String helpMembershipMolecules(Set<MembershipMolecule> newVals,
 309  
             Set<MembershipMolecule> oldVals) {
 310  0
         if (newVals.isEmpty()) {
 311  0
             return "";
 312  
         }
 313  0
         StringBuffer buffer = new StringBuffer(" memberOf ");
 314  0
         Term instance = newVals.iterator().next().getLeftParameter();
 315  
 
 316  0
         Set<Term> replacedValues = new HashSet<Term>();
 317  0
         for (MembershipMolecule val : oldVals) {
 318  0
             if (!val.getLeftParameter().equals(val.getLeftParameter())) {
 319  0
                 String msg = String.format("All AttributeValueMolecule of a CompoundFact "
 320  
                         + "hash to use the same left parameter. Expected %s but %s was found!",
 321  
                         new Object[] { instance, val.getLeftParameter() });
 322  0
                 throw new WrappedInvalidModelException(new InvalidModelException(msg));
 323  
             }
 324  0
             replacedValues.add(val.getRightParameter());
 325  
         }
 326  0
         Set<Term> replacingValues = new HashSet<Term>();
 327  0
         for (MembershipMolecule val : newVals) {
 328  0
             if (!val.getLeftParameter().equals(val.getLeftParameter())) {
 329  0
                 String msg = String.format("All AttributeValueMolecule of a CompoundFact "
 330  
                         + "hash to use the same left parameter. Expected %s but %s was found!",
 331  
                         new Object[] { instance, val.getLeftParameter() });
 332  0
                 throw new WrappedInvalidModelException(new InvalidModelException(msg));
 333  
             }
 334  0
             replacingValues.add(val.getRightParameter());
 335  
         }
 336  
 
 337  0
         if (!replacedValues.isEmpty()) {
 338  0
             buffer.append(helpTermList(replacedValues));
 339  0
             buffer.append(" => ");
 340  
         }
 341  0
         buffer.append(helpTermList(replacingValues));
 342  0
         return new String(buffer);
 343  
     }
 344  
 
 345  
     private Set<Term> validateAttributeValues(Set<AttributeValueMolecule> newVals,
 346  
             Set<AttributeValueMolecule> oldVals) {
 347  0
         if (newVals.isEmpty()) {
 348  0
             return new HashSet<Term>();
 349  
         }
 350  
 
 351  0
         Term instance = newVals.iterator().next().getLeftParameter();
 352  0
         HashSet<Term> attributes = new HashSet<Term>();
 353  
 
 354  0
         for (AttributeValueMolecule val : newVals) {
 355  0
             if (!val.getLeftParameter().equals(instance)) {
 356  0
                 String msg = String.format("All AttributeValueMolecule of a CompoundFact "
 357  
                         + "hash to use the same left parameter. Expected %s but %s was found!",
 358  
                         new Object[] { instance, val.getLeftParameter() });
 359  0
                 throw new WrappedInvalidModelException(new InvalidModelException(msg));
 360  
             }
 361  0
             attributes.add(val.getAttribute());
 362  
         }
 363  0
         for (AttributeValueMolecule val : oldVals) {
 364  0
             if (!val.getLeftParameter().equals(instance)) {
 365  0
                 String msg = String.format("All AttributeValueMolecule of a CompoundFact "
 366  
                         + "hash to use the same left parameter. Expected %s but %s was found!",
 367  
                         new Object[] { instance, val.getLeftParameter() });
 368  0
                 throw new WrappedInvalidModelException(new InvalidModelException(msg));
 369  
             }
 370  0
             if (!attributes.contains(val.getAttribute())) {
 371  0
                 String msg = String.format("The AttributeValueMolecule ? [%s hasValue ?] "
 372  
                         + "has no new valid to replace it! Specify AttributeValueMolecule "
 373  
                         + "in new CompoundFact ? [%s hasValue <newvalue>].", new Object[] {
 374  
                         val.getAttribute(), val.getAttribute() });
 375  0
                 throw new WrappedInvalidModelException(new InvalidModelException(msg));
 376  
             }
 377  
         }
 378  0
         return attributes;
 379  
     }
 380  
 
 381  
     private String helpSerializeTerm(Term term) {
 382  0
         term.accept(this.termVisitor);
 383  0
         return this.termVisitor.getSerializedObject();
 384  
     }
 385  
 
 386  
     private String helpTermList(Set<Term> terms) {
 387  0
         if (terms.size() == 1) {
 388  0
             return new String(helpSerializeTerm(terms.iterator().next()));
 389  
         }
 390  0
         else if (terms.size() > 1) {
 391  0
             StringBuffer buffer = new StringBuffer("{");
 392  0
             for (Iterator i = terms.iterator(); i.hasNext();) {
 393  0
                 buffer.append(helpSerializeTerm((Term) i.next()));
 394  0
                 if (i.hasNext()) {
 395  0
                     buffer.append(", ");
 396  
                 }
 397  
             }
 398  0
             buffer.append("}");
 399  0
             return new String(buffer);
 400  
         }
 401  
         else
 402  0
             throw new RuntimeException("Internal exception during serialization");
 403  
     }
 404  
 
 405  
     private String helpRelationFact(RelationFact oldFact, RelationFact newFact) {
 406  0
         StringBuffer buffer = new StringBuffer();
 407  0
         if (oldFact != null) {//deal with value updates
 408  0
             if (validIfSerializeableUpdateRelationFact(oldFact, newFact)) {
 409  0
                 assert newFact.getAtom().listParameters().size() > 0;
 410  0
                 assert oldFact.getAtom().listParameters().size() == 
 411  
                     newFact.getAtom().listParameters().size();
 412  
                 
 413  0
                 buffer.append("@" + helpSerializeTerm(newFact.getAtom().getIdentifier())+ "(");
 414  0
                 Iterator i1 = oldFact.getAtom().listParameters().iterator();
 415  0
                 Iterator i2 = newFact.getAtom().listParameters().iterator();
 416  
                 
 417  0
                 while (i1.hasNext()) {
 418  0
                     buffer.append(helpRelationFactTermUpdate((Term) i1.next(), (Term) i2.next()));
 419  0
                     if (i1.hasNext())
 420  0
                         buffer.append(",");
 421  
                 }
 422  0
                 buffer.append(")");
 423  0
             }
 424  
         }
 425  
         else {//deal with a normal relation fact
 426  0
             buffer.append("@");
 427  0
             this.logExpSer.visitAtom(newFact.getAtom());
 428  0
             buffer.append(this.logExpSer.getSerializedObject());
 429  
         }
 430  0
         return buffer.toString();
 431  
     }
 432  
 
 433  
     private String helpRelationFactTermUpdate(Term oldTerm, Term newTerm) {
 434  0
         String termUpdate = "";
 435  0
         if (oldTerm.equals(newTerm)) {
 436  0
             termUpdate = this.helpSerializeTerm(newTerm);
 437  
         }
 438  
         else {
 439  0
             termUpdate += this.helpSerializeTerm(oldTerm) + " => "
 440  
                     + this.helpSerializeTerm(newTerm);
 441  
         }
 442  0
         return termUpdate;
 443  
     }
 444  
 
 445  
     private boolean validIfSerializeableUpdateRelationFact(RelationFact oldFact, RelationFact newFact) {
 446  
         try {
 447  0
             if (oldFact.getAtom().listParameters().size() !=
 448  
                 newFact.getAtom().listParameters().size()) {
 449  0
                 throw new WrappedInvalidModelException(new InvalidModelException(
 450  
                         "The Atoms of the new and old RelationFact do not have the same" +
 451  
                         "size parameter lists!"));
 452  
             }
 453  
         }
 454  0
         catch (NullPointerException ex) {
 455  0
             throw new WrappedInvalidModelException(new InvalidModelException(
 456  
             "The Atom of the RelationFact is null!"));
 457  0
         }
 458  0
         if (oldFact != null && !oldFact.getAtom().getIdentifier().equals(
 459  
                 newFact.getAtom().getIdentifier())) {
 460  0
             throw new WrappedInvalidModelException(new InvalidModelException(
 461  
                     "The Identifier names of the relation updates are different"));
 462  
         }
 463  0
         return true;
 464  
     }
 465  
 
 466  
     public void visitChoreographyPipedRules(ChoreographyPipedRules rules) {
 467  0
         this.stack.push(this.helpPipedRules(rules));
 468  0
     }
 469  
     
 470  
     public void visitOrchestrationPipedRules(OrchestrationPipedRules rules) {
 471  0
         this.stack.push(this.helpPipedRules(rules));
 472  0
     }
 473  
 
 474  
     private String helpPipedRules(ChoreographyPipedRules rules) {
 475  0
         StringBuffer buffer = new StringBuffer();
 476  0
         Iterator i = rules.listPipedRules().iterator();
 477  
         ChoreographyRule r;
 478  0
         while (i.hasNext()) {
 479  0
             r = (ChoreographyRule) i.next();
 480  0
             r.accept(this);
 481  0
             buffer.append(this.getSerializedObject());
 482  0
             if (i.hasNext())
 483  0
                 buffer.append(" | ");
 484  
             else
 485  0
                 buffer.append("\n");
 486  
         }
 487  0
         return buffer.toString();
 488  
     }
 489  
     
 490  
     private String helpPipedRules(OrchestrationPipedRules rules) {
 491  0
         StringBuffer buffer = new StringBuffer();
 492  0
         Iterator i = rules.listPipedRules().iterator();
 493  
         Rule r;
 494  0
         while (i.hasNext()) {
 495  0
             r = (Rule) i.next();
 496  0
             r.accept(this);
 497  0
             buffer.append(this.getSerializedObject());
 498  0
             if (i.hasNext())
 499  0
                 buffer.append(" | ");
 500  
             else
 501  0
                 buffer.append("\n");
 502  
         }
 503  0
         return buffer.toString();
 504  
     }
 505  
 
 506  
     private String getIndent() {
 507  0
         StringBuffer buff = new StringBuffer();
 508  0
         for (int i = 0; i < indentationLevel; i++) {
 509  0
             buff.append("     ");
 510  
         }
 511  0
         return buff.toString();
 512  
     }
 513  
 
 514  
         public void visitOrchestrationAchieveGoal(OrchestrationAchieveGoal rule) {
 515  0
                 String s = getIndent() + "perform ";
 516  0
                 if (rule.getPerformIRI() != null)
 517  0
                         s = s + rule.getPerformIRI() + " ";
 518  0
                 s = s + " achieveGoal " + rule.getGoal().getIdentifier() + "\n";
 519  0
         this.stack.push(s);
 520  0
         }
 521  
 
 522  
         public void visitOrchestrationApplyMediation(OrchestrationApplyMediation rule) {
 523  0
                 String s = getIndent() + "perform ";
 524  0
                 if (rule.getPerformIRI() != null)
 525  0
                         s = s + rule.getPerformIRI() + " ";
 526  0
                 s = s + " mediate " + rule.getPpMediator().getIdentifier() + "\n";
 527  0
         this.stack.push(s);
 528  0
         }
 529  
 
 530  
         public void visitOrchestrationInvokeService(OrchestrationInvokeService rule) {
 531  0
                 String s = getIndent() + "perform ";
 532  0
                 if (rule.getPerformIRI() != null)
 533  0
                         s = s + rule.getPerformIRI() + " ";
 534  0
                 s = s + " invokeService " + rule.getService().getIdentifier() + "\n";
 535  0
         this.stack.push(s);
 536  0
         }
 537  
 
 538  
         public void visitReceive(Receive rule) {
 539  0
                 String s = getIndent() + "perform ";
 540  0
                 if (rule.getPerformIRI() != null)
 541  0
                         s = s + rule.getPerformIRI() + " ";
 542  0
                 s = s + " receive source " + rule.getSourceIRI() + "\n";
 543  0
         this.stack.push(s);
 544  0
         }
 545  
 
 546  
         public void visitSend(Send rule) {
 547  0
                 String s = getIndent() + "perform ";
 548  0
                 if (rule.getPerformIRI() != null)
 549  0
                         s = s + rule.getPerformIRI() + " ";
 550  0
                 s = s + " send target " + rule.getTargetIRI() + "\n";
 551  0
         this.stack.push(s);
 552  0
         }
 553  
 }
 554  
 
 555  
 /*
 556  
  * $Log$
 557  
  * Revision 1.17  2007/04/02 13:05:18  morcen
 558  
  * Generics support added to wsmo-ext
 559  
  *
 560  
  * Revision 1.16  2006/11/08 15:26:53  vassil_momtchev
 561  
  * support of ppMediator and orchestration perform rules added
 562  
  *
 563  
  * Revision 1.15  2006/11/03 13:44:19  haselwanter
 564  
  * Serialzer extension.
 565  
  *
 566  
  * Revision 1.14  2006/10/24 14:11:47  vassil_momtchev
 567  
  * choreography/orchestration rules refactored. different types where appropriate now supported
 568  
  *
 569  
  * Revision 1.13  2006/04/17 09:51:46  vassil_momtchev
 570  
  * condition.getLogicalExpression() method name changed to condition.getRestrictedLogicalExpression()
 571  
  *
 572  
  * Revision 1.12  2006/04/17 08:17:07  vassil_momtchev
 573  
  * bug fixed in serialization of RelationFact
 574  
  *
 575  
  * Revision 1.11  2006/03/24 15:37:29  vassil_momtchev
 576  
  * exception msg formatting problem fixed; wrong equals method used in validateAttributeValues method
 577  
  *
 578  
  * Revision 1.10  2006/03/13 12:40:39  alex_simov
 579  
  * identation for 'endIf' fixed
 580  
  *
 581  
  * Revision 1.9  2006/02/21 09:05:03  vassil_momtchev
 582  
  * serialization formatting improved
 583  
  *
 584  
  * Revision 1.8  2006/02/15 15:51:08  alex_simov
 585  
  * method helpCompoundFact() extra visibility added to be reused in MoleculeFact.toString()
 586  
  *
 587  
  * Revision 1.7  2006/02/08 15:30:15  jamsci001
 588  
  * - added "@" symbol for the serialization of relation fact
 589  
  *
 590  
  * Revision 1.6  2006/02/03 13:32:49  jamsci001
 591  
  * - Serializer reflects changes in API and implementation:
 592  
  *  - PipedRules
 593  
  *  - Relation Facts
 594  
  *  - Updates
 595  
  *
 596  
  * Revision 1.5  2006/01/31 10:35:06  vassil_momtchev
 597  
  * serialization of the fact modified according the new api; few bugs removed; log footer added
 598  
  *
 599  
  */