/** * This method takes a hashtable of primitives and adds them to the commit list. * This count value provided is the number of instances that will need to be * inserted into the database once a remove has occured. This is only set * once for each object type */ public void setCommitAddition(Hashtable additions){ Enumeration enumtr = additions.keys(); while (enumtr.hasMoreElements()) { Object object = enumtr.nextElement(); getCommitAddMap().put(object, additions.get(object)); } }
/** * This method will iterate over the collection and store the database counts for * the objects within the collection, this is used for minimal updates */ public void storeDatabaseCounts(Object collection, ContainerPolicy containerPolicy, AbstractSession session){ Object iterator = containerPolicy.iteratorFor(collection); while (containerPolicy.hasNext(iterator)){ Object object = containerPolicy.next(iterator, session); if (getCommitAddMap().containsKey(object)){ int count = ((Integer)getCommitAddMap().get(object)).intValue(); getCommitAddMap().put(object, new Integer(++count)); }else{ getCommitAddMap().put(object, new Integer(1)); } } }
/** * This method takes a hastable of primitive objects and adds them to the add list. * the hashtable stores the number of times the object is in the list * @param objectChanges prototype.changeset.ObjectChangeSet */ public void addAdditionChange(HashMap additions, HashMap databaseCount) { Iterator enumtr = additions.keySet().iterator(); while (enumtr.hasNext()) { Object object = enumtr.next(); if (databaseCount.containsKey(object)){ getCommitAddMap().put(object, databaseCount.get(object)); } addAdditionChange(object, (Integer)additions.get(object)); } }
/** * This method takes a hashtable of primitive objects and adds them to the remove list. * Each reference in the hashtable lists the number of this object that needs to be removed from the * collection. * @param objectChanges prototype.changeset.ObjectChangeSet */ public void addRemoveChange(HashMap additions, HashMap databaseCount) { Iterator enumtr = additions.keySet().iterator(); while (enumtr.hasNext()) { Object object = enumtr.next(); if (databaseCount.containsKey(object)){ getCommitAddMap().put(object, databaseCount.get(object)); } addRemoveChange(object, (Integer)additions.get(object)); } }
/** * INTERNAL: * This method will be used to merge one record into another */ public void mergeRecord(ChangeRecord mergeFromRecord, UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet) { HashMap addMapToMerge = ((DirectCollectionChangeRecord)mergeFromRecord).getAddObjectMap(); HashMap removeMapToMerge = ((DirectCollectionChangeRecord)mergeFromRecord).getRemoveObjectMap(); //merge additions for (Iterator iterator = addMapToMerge.keySet().iterator(); iterator.hasNext();){ Object added = iterator.next(); if (!((DirectCollectionChangeRecord)mergeFromRecord).getCommitAddMap().containsKey(added)){ // we have not recorded a change of this type in this class before so add it this.getCommitAddMap().put(added, ((DirectCollectionChangeRecord)mergeFromRecord).getCommitAddMap().get(added)); } this.addAdditionChange(added, (Integer)addMapToMerge.get(added)); } //merge removals for (Iterator iterator = removeMapToMerge.keySet().iterator(); iterator.hasNext();){ Object removed = iterator.next(); if (!((DirectCollectionChangeRecord)mergeFromRecord).getCommitAddMap().containsKey(removed)){ // we have not recorded a change of this type in this class before so add it this.getCommitAddMap().put(removed, ((DirectCollectionChangeRecord)mergeFromRecord).getCommitAddMap().get(removed)); } this.addRemoveChange(removed, (Integer)addMapToMerge.get(removed)); } }
if (getCommitAddMap().containsKey(key)){ commitValue = ((Integer)getCommitAddMap().get(key)).intValue(); getCommitAddMap().put(key, new Integer(commitValue - removeValue));
if (getCommitAddMap().containsKey(key)){ commitValue = ((Integer)getCommitAddMap().get(key)).intValue(); getCommitAddMap().put(key, new Integer(addValue+commitValue));
((DirectCollectionChangeRecord)changeRecord).getCommitAddMap().put(DirectCollectionChangeRecord.Null, new Integer(databaseNullCount)); if (numberOfNewNulls > 0) { ((DirectCollectionChangeRecord)changeRecord).addAdditionChange(DirectCollectionChangeRecord.Null, new Integer(numberOfNewNulls));
event[2] = thisRow; writeQuery.getSession().getCommitManager().addDataModificationEvent(this, event); Integer count = (Integer)changeRecord.getCommitAddMap().get(object); if (count != null){ for (int counter = count.intValue(); counter > 0; --counter){