Coverage Report - org.deri.wsmo4j.rule.UpdateRI
 
Classes in this File Line Coverage Branch Coverage Complexity
UpdateRI
0%
0/24
0%
0/4
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.rule;
 21  
 
 22  
 import org.deri.wsmo4j.io.serializer.wsml.*;
 23  
 import org.wsmo.common.*;
 24  
 import org.wsmo.common.exception.*;
 25  
 import org.wsmo.service.rule.*;
 26  
 
 27  
 /**
 28  
  * Reference implementation for the Update rule.
 29  
  * 
 30  
  * <pre>
 31  
  *        Created on Jul 26, 2005
 32  
  *       Committed by $Author: vassil_momtchev $
 33  
  *       $Source$
 34  
  * </pre>
 35  
  * 
 36  
  * @author Thomas Haselwanter
 37  
  * @author James Scicluna
 38  
  * 
 39  
  * @version $Revision: 1844 $ $Date: 2006-10-24 17:11:48 +0300 (Tue, 24 Oct 2006) $
 40  
  */
 41  
 public class UpdateRI extends AbstractUpdateRule implements Update {
 42  
 
 43  
     protected CompoundFact oldFact;
 44  
     
 45  0
     public UpdateRI(CompoundFact newFact){
 46  0
         this.fact = newFact;
 47  0
     }
 48  
 
 49  
     /**
 50  
      * @param newFact
 51  
      *            A CompoundFact object defining the new fact of the update
 52  
      *            rule.
 53  
      * 
 54  
      * @param oldFact
 55  
      *            A CompoundFact object defining the old fact of the update
 56  
      *            rule.
 57  
      */
 58  0
     public UpdateRI(CompoundFact newFact, CompoundFact oldFact) throws InvalidModelException {
 59  0
         if (oldFact == null) {
 60  0
             this.oldFact = null;
 61  0
             this.fact = newFact;
 62  0
         }else if (newFact.getClass() == oldFact.getClass()) {
 63  0
             this.fact = newFact;
 64  0
             this.oldFact = oldFact;
 65  
         }
 66  
         else {
 67  0
             throw new InvalidModelException("The old and new Fact must be of the Same type");
 68  
         }
 69  0
     }
 70  
 
 71  
     /*
 72  
      * (non-Javadoc)
 73  
      * 
 74  
      * @see org.wsmo.service.choreography.rule.Update#setOldFact(org.wsmo.service.choreography.rule.FactMolecule)
 75  
      */
 76  
     public void setOldFact(CompoundFact oldFact) {
 77  0
         this.oldFact = oldFact;
 78  0
     }
 79  
 
 80  
     /*
 81  
      * (non-Javadoc)
 82  
      * 
 83  
      * @see org.wsmo.service.choreography.rule.Update#getOldFact()
 84  
      */
 85  
     public CompoundFact getOldFact() {
 86  0
         return this.oldFact;
 87  
     }
 88  
 
 89  
     /*
 90  
      * (non-Javadoc)
 91  
      * 
 92  
      * @see org.wsmo.service.choreography.rule.Update#setNewFact(org.wsmo.service.choreography.rule.FactMolecule)
 93  
      */
 94  
     public void setNewFact(CompoundFact newFact) {
 95  0
         this.fact = newFact;
 96  0
     }
 97  
 
 98  
     /*
 99  
      * (non-Javadoc)
 100  
      * 
 101  
      * @see org.wsmo.service.choreography.rule.Update#getNewFact()
 102  
      */
 103  
     public CompoundFact getNewFact() {
 104  0
         return super.getFact();
 105  
     }
 106  
 
 107  
     /*
 108  
      * (non-Javadoc)
 109  
      * 
 110  
      * @see org.wsmo.service.choreography.rule.Rule#accept(org.wsmo.service.choreography.rule.Visitor)
 111  
      */
 112  
     public void accept(org.wsmo.service.rule.Visitor visitor) {
 113  0
         visitor.visitUpdate(this);
 114  0
     }
 115  
 
 116  
     /* (non-Javadoc)
 117  
      * @see org.wsmo.service.choreography.rule.Rule#toString(org.wsmo.common.TopEntity)
 118  
      */
 119  
     public String toString(TopEntity te) {
 120  0
         VisitorSerializeWSMLTransitionRules visitor = new VisitorSerializeWSMLTransitionRules(te);
 121  0
         visitor.visitUpdate(this);
 122  0
         return visitor.getSerializedObject();
 123  
     }
 124  
     
 125  
     @Override
 126  
     public String toString() {
 127  0
         return toString(null);
 128  
     }
 129  
 }
 130  
 
 131  
 /*
 132  
  * $Log$
 133  
  * Revision 1.1  2006/10/24 14:11:48  vassil_momtchev
 134  
  * choreography/orchestration rules refactored. different types where appropriate now supported
 135  
  *
 136  
  * Revision 1.12  2006/04/17 07:51:55  vassil_momtchev
 137  
  * method signature toString() changed to toString(TopEntity)
 138  
  *
 139  
  * Revision 1.11  2006/02/15 15:53:19  alex_simov
 140  
  * toString() did not check correctly for empty old fact
 141  
  *
 142  
  * Revision 1.10  2006/02/03 13:31:25  jamsci001
 143  
  * - Reference Implementation for MoleculeFact, PipedRules, RelationFat
 144  
  * - Modified UpdateRI to handle also RelationFacts
 145  
  * - Rules container is now initialized with an identifier
 146  
  * Revision 1.9 2006/01/31 10:25:42 vassil_momtchev
 147  
  * defineNewFactsOnly method removed - use getOldFact.isEmpty() instead;
 148  
  * implementation fixed according the new interface; log footer added;
 149  
  * 
 150  
  */