Update of /cvsroot/sandboss/sand/apps/TaskHeap/src/org/sandev/TaskHeap/UpdateManager
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14501
Modified Files:
UpdateManagerNode.java
Log Message:
More smarts around when to update containing plans.
Index: UpdateManagerNode.java
===================================================================
RCS file: /cvsroot/sandboss/sand/apps/TaskHeap/src/org/sandev/TaskHeap/UpdateManager/UpdateManagerNode.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** UpdateManagerNode.java 14 Jul 2004 23:02:47 -0000 1.17
--- UpdateManagerNode.java 7 Aug 2004 16:24:34 -0000 1.18
***************
*** 31,35 ****
import org.sandev.basics.util.ArrayUtils;
import org.sandev.basics.util.CSVTransforms;
- import org.sandev.basics.util.AuthUser;
import org.sandev.basics.util.IDLookup;
import org.sandev.basics.util.AuthUser;
--- 31,34 ----
***************
*** 61,65 ****
*/
public class UpdateManagerNode extends UpdateManagerNodeBase
! implements IDLookup
{
////////////////////////////////////////
--- 60,64 ----
*/
public class UpdateManagerNode extends UpdateManagerNodeBase
! implements IDLookup, AuthUserLookup
{
////////////////////////////////////////
***************
*** 92,96 ****
/**
! * Given a userID, return the AuthUser for it.
*/
public AuthUser getUserForID(long id)
--- 91,95 ----
/**
! * Convenience passthrough call to our configured AuthUserLookup.
*/
public AuthUser getUserForID(long id)
***************
*** 101,104 ****
--- 100,114 ----
+ /**
+ * Convenience passthrough call to our configured AuthUserLookup.
+ * Defined for AuthUserLookup interface signature completion.
+ */
+ public AuthUser getUserFromLogin(String username,String password)
+ throws SandException
+ {
+ return getUserLookup().getUserFromLogin(username,password);
+ }
+
+
////////////////////////////////////////
// IDLookup implementation
***************
*** 302,318 ****
* Task and a PlanUpdate to associate the Task. The base actions are: <ul>
* <li>TaskUpdate: <ul>
! * <li>delete: update the containing Plan to remove the reference.
* <li>add: nothing to do. Associating the new Task is an explicit
* separate action.
! * <li>update: recalc the containing Plan(s) recursively upward if the
! * timeEstimate changed
* </ul>
* <li>ExternalPlanUpdate (analagous to TaskUpdate)
* <li>PlanUpdate: <ul>
* <li>delete: remove parent refs for all contained tasks, update
! * the containing Plan to remove the reference.
* <li>add/update: recalc timeEstimate from contained references,
* recalc the containing Plan(s) recursively upward if the
! * timeEstimate changed
* </ul>
* </ul>
--- 312,332 ----
* Task and a PlanUpdate to associate the Task. The base actions are: <ul>
* <li>TaskUpdate: <ul>
! * <li>delete: update the containing Plan to remove the reference,
! * recalc the containing Plan(s) recursively upward to reflect
! * the change in remaining time.
* <li>add: nothing to do. Associating the new Task is an explicit
* separate action.
! * <li>update: recalc the containing Plan(s) recursively upward if
! * the timeEstimate changed.
* </ul>
* <li>ExternalPlanUpdate (analagous to TaskUpdate)
* <li>PlanUpdate: <ul>
* <li>delete: remove parent refs for all contained tasks, update
! * the containing Plan to remove the reference, recalc the
! * containing Plan(s) recursively upward to reflect the change
! * in remaining time.
* <li>add/update: recalc timeEstimate from contained references,
* recalc the containing Plan(s) recursively upward if the
! * timeEstimate changed.
* </ul>
* </ul>
***************
*** 326,329 ****
--- 340,344 ----
*
* <p>Implementation notes: <ol>
+ * <li>We only want one PlanUpdate added per action. So recalc
* <li>There is some possibility that the bookkeeping done here could
* potentially conflict with an advanced UI function trying to handle
***************
*** 357,363 ****
removeReferenceToChild(sum.getInstance(),user,al); }
else if(sum.getAction()==SandUpdateMessage.ACTION_UPDATE) {
confirmChildReferences((PlanUpdate)sum,al,au);
recalcPlan(plan,userID,al);
- long parentID=getParentForUpdate(sum);
if((parentID>0)&&(timeEstimateChanged(sum))) {
recalcParents(parentID,userID,al); } } } }
--- 372,378 ----
removeReferenceToChild(sum.getInstance(),user,al); }
else if(sum.getAction()==SandUpdateMessage.ACTION_UPDATE) {
+ long parentID=getParentForUpdate(sum);
confirmChildReferences((PlanUpdate)sum,al,au);
recalcPlan(plan,userID,al);
if((parentID>0)&&(timeEstimateChanged(sum))) {
recalcParents(parentID,userID,al); } } } }
***************
*** 407,410 ****
--- 422,428 ----
* given a TaskUpdate for a Task 5032 with parent Plan 1034, append
* a PlanUpdate removing the reference to Task 5032 from Plan 1034.
+ *
+ * <p>We recalculate the parent as part of this processing, to avoid
+ * requiring two separate update actions for the same parent Plan. </p>
*/
protected void removeReferenceToChild(SandInstanceMessage child,
***************
*** 437,445 ****
if((plan!=null)&&
(plan.removeComponentsValue(childID))) {
PlanUpdate pu=new PlanUpdate();
pu.setSandTransmitAuthID(user.getUniqueID());
pu.setAction(SandUpdateMessage.ACTION_UPDATE);
pu.setPlan(plan);
! al.add(pu); }
}
--- 455,468 ----
if((plan!=null)&&
(plan.removeComponentsValue(childID))) {
+ recalcPlan(plan,user.getUniqueID(),al);
+ plan.setLastModifiedReason("removed reference to child " + childID);
PlanUpdate pu=new PlanUpdate();
pu.setSandTransmitAuthID(user.getUniqueID());
pu.setAction(SandUpdateMessage.ACTION_UPDATE);
pu.setPlan(plan);
! log(LOGDEBUG,"removeReferenceToChild updating Plan " + plan.getUniqueID());
! al.add(pu);
! if(plan.getParent()>0) {
! recalcParents(plan.getParent(),user.getUniqueID(),al); } }
}
***************
*** 468,471 ****
--- 491,497 ----
/**
* Return true if the timeEstimate for the given update has changed.
+ * The timeEstimate is considered to have changed if the recordStatus
+ * has changed, since deleting something effectively means its
+ * timeEstimate is now zero. Likewise for closed or finished tasks.
*/
protected boolean timeEstimateChanged(SandUpdateMessage sum)
***************
*** 478,482 ****
Task oldTask=(Task)getInstance("Task",task.getUniqueID(),user);
if((oldTask==null)||
! (!oldTask.getLastModifiedTime().equals(task.getLastModifiedTime()))) {
return true; } }
else if(sim instanceof ExternalPlan) {
--- 504,511 ----
Task oldTask=(Task)getInstance("Task",task.getUniqueID(),user);
if((oldTask==null)||
! (oldTask.getTimeEstimate()!=task.getTimeEstimate())||
! (task.getTaskPhaseID()==1002)|| //finished
! (task.getTaskPhaseID()==1003)|| //closed
! (oldTask.getRecordStatus()!=task.getRecordStatus())) {
return true; } }
else if(sim instanceof ExternalPlan) {
***************
*** 485,489 ****
getInstance("ExternalPlan",ep.getUniqueID(),user);
if((oldep==null)||
! (!oldep.getLastModifiedTime().equals(ep.getLastModifiedTime()))) {
return true; } }
else if(sim instanceof Plan) {
--- 514,519 ----
getInstance("ExternalPlan",ep.getUniqueID(),user);
if((oldep==null)||
! (oldep.getTimeEstimate()!=ep.getTimeEstimate())||
! (oldep.getRecordStatus()!=ep.getRecordStatus())) {
return true; } }
else if(sim instanceof Plan) {
***************
*** 491,495 ****
Plan oldPlan=(Plan)getInstance("Plan",plan.getUniqueID(),user);
if((oldPlan==null)||
! (!oldPlan.getLastModifiedTime().equals(plan.getLastModifiedTime()))) {
return true; } }
return false;
--- 521,526 ----
Plan oldPlan=(Plan)getInstance("Plan",plan.getUniqueID(),user);
if((oldPlan==null)||
! (oldPlan.getTimeEstimate()!=plan.getTimeEstimate())||
! (oldPlan.getRecordStatus()!=plan.getRecordStatus())) {
return true; } }
return false;
***************
*** 558,565 ****
--- 589,598 ----
if(task.getParent()!=parentID) {
task.setParent(parentID);
+ task.setLastModifiedReason("set parent to " + parentID);
TaskUpdate tu=new TaskUpdate();
tu.setSandTransmitAuthID(user.getUniqueID());
tu.setAction(SandUpdateMessage.ACTION_UPDATE);
tu.setTask(task);
+ log(LOGDEBUG,"updateParentRef for Task " + task.getUniqueID());
al.add(tu); } }
else if(spm instanceof ExternalPlan) {
***************
*** 567,574 ****
--- 600,609 ----
if(ep.getParent()!=parentID) {
ep.setParent(parentID);
+ ep.setLastModifiedReason("set parent to " + parentID);
ExternalPlanUpdate epu=new ExternalPlanUpdate();
epu.setSandTransmitAuthID(user.getUniqueID());
epu.setAction(SandUpdateMessage.ACTION_UPDATE);
epu.setExternalPlan(ep);
+ log(LOGDEBUG,"updateParentRef for ExternalPlan " + ep.getUniqueID());
al.add(epu); } }
else if(spm instanceof Plan) {
***************
*** 576,583 ****
--- 611,620 ----
if(plan.getParent()!=parentID) {
plan.setParent(parentID);
+ plan.setLastModifiedReason("set parent to " + parentID);
PlanUpdate pu=new PlanUpdate();
pu.setSandTransmitAuthID(user.getUniqueID());
pu.setAction(SandUpdateMessage.ACTION_UPDATE);
pu.setPlan(plan);
+ log(LOGDEBUG,"updateParentRef for Plan " + plan.getUniqueID());
al.add(pu); } }
else if(spm instanceof PlanComponent) {
***************
*** 585,592 ****
--- 622,631 ----
if(pc.getParent()!=parentID) {
pc.setParent(parentID);
+ pc.setLastModifiedReason("set parent to " + parentID);
PlanComponentUpdate pcu=new PlanComponentUpdate();
pcu.setSandTransmitAuthID(user.getUniqueID());
pcu.setAction(SandUpdateMessage.ACTION_UPDATE);
pcu.setPlanComponent(pc);
+ log(LOGDEBUG,"updateParentRef for PlanComponent " + pc.getUniqueID());
al.add(pcu); } }
else {
***************
*** 605,609 ****
--- 644,650 ----
AuthUser user=getUserForID(userID);
Plan plan=(Plan)getInstance("Plan",parentID,user);
+ log(LOGDEBUG,"recalculating Plan " + parentID);
recalcPlan(plan,userID,al);
+ plan.setLastModifiedReason("recalc");
PlanUpdate pu=new PlanUpdate();
pu.setSandTransmitAuthID(user.getUniqueID());
***************
*** 611,614 ****
--- 652,656 ----
pu.setPlan(plan);
al.add(pu);
+ log(LOGDEBUG,"recalcParents adding update to Plan " + parentID);
long nextParent=plan.getParent();
if(nextParent>0) {
|