Coverage Report - net.wotonomy.control.EditingContext
 
Classes in this File Line Coverage Branch Coverage Complexity
EditingContext
0% 
N/A 
1
 
 1  
 /*
 2  
 Wotonomy: OpenStep design patterns for pure Java applications.
 3  
 Copyright (C) 2001 Michael Powers
 4  
 
 5  
 This library is free software; you can redistribute it and/or
 6  
 modify it under the terms of the GNU Lesser General Public
 7  
 License as published by the Free Software Foundation; either
 8  
 version 2.1 of the License, or (at your option) any later version.
 9  
 
 10  
 This library is distributed in the hope that it will be useful,
 11  
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
 Lesser General Public License for more details.
 14  
 
 15  
 You should have received a copy of the GNU Lesser General Public
 16  
 License along with this library; if not, see http://www.gnu.org
 17  
 */
 18  
 
 19  
 package net.wotonomy.control;
 20  
 
 21  
 import java.util.List;
 22  
 import java.util.Map;
 23  
 
 24  
 // swing dependency for undo manager
 25  
 //import javax.swing.undo.UndoManager;
 26  
 
 27  
 /**
 28  
 * EditingContext provides transactional support for 
 29  
 * fetching, editing, and committing changes made on a 
 30  
 * collection of objects to a parent object store.
 31  
 * This subclasses EOEditingContext to provide 
 32  
 * java-friendly conveniences.
 33  
 *
 34  
 * @author michael@mpowers.net
 35  
 * @author $Author: cgruber $
 36  
 * @version $Revision: 894 $
 37  
 */
 38  
 public class EditingContext extends EOEditingContext 
 39  
 {
 40  
     /**
 41  
     * Default constructor creates a new editing context
 42  
     * that uses the default object store.  If the default
 43  
     * object store has not been set, an exception is thrown.
 44  
     */ 
 45  
     public EditingContext()
 46  
     {
 47  0
         this( defaultParentObjectStore() );
 48  0
     }
 49  
 
 50  
     /**
 51  
     * Creates a new editing context that uses the specified
 52  
     * object store as its parent object store.
 53  
     */
 54  
     public EditingContext( EOObjectStore anObjectStore )
 55  
     {
 56  0
         super( anObjectStore );
 57  0
     }
 58  
 
 59  
     /**
 60  
     * Returns a List of objects associated with the object 
 61  
     * with the specified id for the specified property 
 62  
     * relationship, or may return a placeholder array that
 63  
     * will defer the fetch until needed (aka an array fault).
 64  
     * All objects must be registered in the specified editing context.
 65  
     * This implementation calls to its parent object store's
 66  
     * implementation if the requested source object is not 
 67  
     * registered in this editing context.
 68  
     * The specified relationship key must produce a result of
 69  
     * type Collection for the source object or an exception is thrown.
 70  
     */
 71  
     public List getArrayFaultWithSourceGlobalID ( 
 72  
         EOGlobalID aGlobalID,
 73  
         String aRelationshipKey,
 74  
         EOEditingContext aContext )
 75  
     {
 76  0
         return arrayFaultWithSourceGlobalID(
 77  0
             aGlobalID, aRelationshipKey, aContext );
 78  
     }
 79  
  
 80  
     /**
 81  
     * Returns a snapshot of the specified object as it
 82  
     * existed when it was last read or committed to the
 83  
     * parent object store.
 84  
     */
 85  
     public Map getCommittedSnapshotForObject ( 
 86  
         Object anObject )
 87  
     {
 88  0
         return committedSnapshotForObject( anObject );
 89  
     }
 90  
 
 91  
     /**
 92  
     * Returns a snapshot of the specified object as it
 93  
     * existed before the edits triggered by the current
 94  
     * event loop were processed.
 95  
     */
 96  
     public Map getCurrentEventSnapshotForObject ( 
 97  
         Object anObject )
 98  
     {
 99  0
         return currentEventSnapshotForObject( anObject );
 100  
     }
 101  
     
 102  
     /**
 103  
     * Returns the delegate for this editing context,
 104  
     * or null if no delegate has been set.
 105  
     */
 106  
     public Object getDelegate ()
 107  
     {
 108  0
         return delegate();
 109  
     }
 110  
 
 111  
     /**
 112  
     * Returns a List of all objects marked as deleted
 113  
     * in this editing context.
 114  
     */
 115  
     public List getDeletedObjects ()
 116  
     {
 117  0
         return deletedObjects();
 118  
     }
 119  
 
 120  
     /**
 121  
     * Returns a List of registered editors of this
 122  
     * editing context.
 123  
     */
 124  
     public List getEditors()
 125  
     {
 126  0
         return editors();
 127  
     }
 128  
     
 129  
     /**
 130  
     * Returns the object for the specified id.
 131  
     * If the object's data has not been fetched,
 132  
     * it will be fetched when needed.
 133  
     */
 134  
     public Object getFaultForGlobalID ( 
 135  
         EOGlobalID aGlobalID )
 136  
     {
 137  0
         return faultForGlobalID( aGlobalID, this );
 138  
     }
 139  
 
 140  
     /**
 141  
     * Returns a fault representing an object of 
 142  
     * the specified entity type with values from 
 143  
     * the specified dictionary.  
 144  
     */
 145  
     public Object getFaultForRawRow ( 
 146  
         Map aDictionary,
 147  
         String anEntityName )
 148  
     {
 149  0
         return faultForRawRow( aDictionary, anEntityName );
 150  
     }
 151  
 
 152  
     /**
 153  
     * Returns the fetch timestamp for this editing context.
 154  
     */
 155  
     public double getFetchTimestamp()
 156  
     {
 157  0
         return fetchTimestamp();
 158  
     }
 159  
 
 160  
     /**
 161  
     * Returns the id for the specified object, or null
 162  
     * if the object is not registered in this context.
 163  
     */
 164  
     public EOGlobalID getGlobalIDForObject ( 
 165  
         Object anObject )
 166  
     {
 167  0
         return globalIDForObject( anObject );
 168  
     }
 169  
     
 170  
     /**
 171  
     * Returns a List of the objects that have been 
 172  
     * inserted into this editing context.
 173  
     */
 174  
     public List getInsertedObjects ()
 175  
     {
 176  0
         return insertedObjects();
 177  
     }
 178  
 
 179  
     /**
 180  
     * Returns the message handler for this editing context,
 181  
     * or null if no message handler has been set.
 182  
     */
 183  
     public Object getMessageHandler ()
 184  
     {
 185  0
         return messageHandler();
 186  
     }
 187  
 
 188  
     /**
 189  
     * Returns the object registered in this editing context
 190  
     * for the specified id, or null if that id is not 
 191  
     * registered.
 192  
     */
 193  
     public Object getObjectForGlobalID ( 
 194  
         EOGlobalID aGlobalID )
 195  
     {
 196  0
         return objectForGlobalID( aGlobalID );
 197  
     }
 198  
 
 199  
     /**
 200  
     * Returns a List of objects the meet the criteria of
 201  
     * the supplied specification.  
 202  
     */
 203  
     public List getObjectsWithFetchSpecification ( 
 204  
         EOFetchSpecification aFetchSpec )
 205  
     {
 206  0
         return objectsWithFetchSpecification( aFetchSpec );
 207  
     }
 208  
 
 209  
     /**
 210  
     * Returns the parent object store for this editing context.
 211  
     * The result will not be null.
 212  
     */
 213  
     public EOObjectStore getParentObjectStore ()
 214  
     {
 215  0
         return parentObjectStore();
 216  
     }
 217  
 
 218  
     /**
 219  
     * Returns a List of all objects registered in this
 220  
     * editing context.
 221  
     */
 222  
     public List geRegisteredObjects ()
 223  
     {
 224  0
         return registeredObjects();
 225  
     }
 226  
 
 227  
     /**
 228  
     * Returns the root object store, which is the parent
 229  
     * of all parent object stores of this editing context.
 230  
     */
 231  
     public EOObjectStore getRootObjectStore ()
 232  
     {
 233  0
         return rootObjectStore();
 234  
     }
 235  
 
 236  
     /**
 237  
     * Returns a list of all objects marked as modified,
 238  
     * but not inserted or deleted, in this editing context.
 239  
     */
 240  
     public List getUpdatedObjects ()
 241  
     {
 242  0
         return updatedObjects();
 243  
     }
 244  
 
 245  
     // static methods
 246  
     
 247  
     public static double getDefaultFetchTimestampLag()
 248  
     {
 249  0
         return defaultFetchTimestampLag();
 250  
     }
 251  
 
 252  
     /**
 253  
     * Returns the default parent object store for all
 254  
     * object stores created with the parameterless 
 255  
     * constructor.
 256  
     */
 257  
     public static EOObjectStore getDefaultParentObjectStore()
 258  
     {
 259  0
         return defaultParentObjectStore();
 260  
     }
 261  
 
 262  
 }
 263  
 
 264  
 /*
 265  
  * $Log$
 266  
  * Revision 1.2  2006/02/16 16:47:14  cgruber
 267  
  * Move some classes in to "internal" packages and re-work imports, etc.
 268  
  *
 269  
  * Also use UnsupportedOperationExceptions where appropriate, instead of WotonomyExceptions.
 270  
  *
 271  
  * Revision 1.1  2006/02/16 13:19:57  cgruber
 272  
  * Check in all sources in eclipse-friendly maven-enabled packages.
 273  
  *
 274  
  * Revision 1.2  2003/08/06 23:07:52  chochos
 275  
  * general code cleanup (mostly, removing unused imports)
 276  
  *
 277  
  * Revision 1.1  2002/03/26 21:46:36  mpowers
 278  
  * Contributing EditingContext as a java-friendly convenience.
 279  
  *
 280  
  *
 281  
  */
 282  
     
 283