Browse Source

HPCC-13532 Set reschedule flag based on WU state

The EventSchedule flag in ECL WUInfo response is used to
decide whether a Reschedule button should be shown on the
ECL WU Details page or not. Since the schedule is not
allowed for WUStateFailed, WUStateArchived, WUStateAborting,
WUStateAborted, and WUStateScheduled, the EventSchedule flag
should be set based on WU state.

This fix also removes the duplicated code in getWorkflow().

Signed-off-by: wangkx <kevin.wang@lexisnexis.com>
wangkx 10 years ago
parent
commit
23b9163c5b
1 changed files with 4 additions and 15 deletions
  1. 4 15
      esp/services/ws_workunits/ws_workunitsHelpers.cpp

+ 4 - 15
esp/services/ws_workunits/ws_workunitsHelpers.cpp

@@ -911,7 +911,10 @@ void WsWuInfo::getEventScheduleFlag(IEspECLWorkunit &info)
                 if (!wfevent)
                 if (!wfevent)
                     continue;
                     continue;
 
 
-                if (!r->hasScheduleCount() || (r->queryScheduleCountRemaining() > 0))
+                if ((!r->hasScheduleCount() || (r->queryScheduleCountRemaining() > 0))
+                    && info.getState() && !strieq(info.getState(), "scheduled")
+                    && !strieq(info.getState(), "aborting") && !strieq(info.getState(), "aborted")
+                    && !strieq(info.getState(), "failed") && !strieq(info.getState(), "archived"))
                 {
                 {
                     info.setEventSchedule(1); //Can reschedule
                     info.setEventSchedule(1); //Can reschedule
                     break;
                     break;
@@ -1287,11 +1290,8 @@ bool WsWuInfo::getClusterInfo(IEspECLWorkunit &info, unsigned flags)
 
 
 void WsWuInfo::getWorkflow(IEspECLWorkunit &info, unsigned flags)
 void WsWuInfo::getWorkflow(IEspECLWorkunit &info, unsigned flags)
 {
 {
-    bool eventCountRemaining = false;
-    bool eventCountUnlimited = false;
     try
     try
     {
     {
-        info.setEventSchedule(0);
         unsigned workflowsCount = 0;
         unsigned workflowsCount = 0;
         IArrayOf<IConstECLWorkflow> workflows;
         IArrayOf<IConstECLWorkflow> workflows;
         Owned<IConstWorkflowItemIterator> it = cw->getWorkflowItems();
         Owned<IConstWorkflowItemIterator> it = cw->getWorkflowItems();
@@ -1316,18 +1316,12 @@ void WsWuInfo::getWorkflow(IEspECLWorkunit &info, unsigned flags)
                         }
                         }
                         if (r->hasScheduleCount())
                         if (r->hasScheduleCount())
                         {
                         {
-                            if (r->queryScheduleCountRemaining() > 0)
-                                eventCountRemaining = true;
                             if (flags & WUINFO_IncludeWorkflows)
                             if (flags & WUINFO_IncludeWorkflows)
                             {
                             {
                                 g->setCount(r->queryScheduleCount());
                                 g->setCount(r->queryScheduleCount());
                                 g->setCountRemaining(r->queryScheduleCountRemaining());
                                 g->setCountRemaining(r->queryScheduleCountRemaining());
                             }
                             }
                         }
                         }
-                        else
-                        {
-                            eventCountUnlimited = true;
-                        }
                         workflowsCount++;
                         workflowsCount++;
                         if (flags & WUINFO_IncludeWorkflows)
                         if (flags & WUINFO_IncludeWorkflows)
                             workflows.append(*g.getLink());
                             workflows.append(*g.getLink());
@@ -1348,11 +1342,6 @@ void WsWuInfo::getWorkflow(IEspECLWorkunit &info, unsigned flags)
         info.setWorkflowsDesc(eMsg.str());
         info.setWorkflowsDesc(eMsg.str());
         e->Release();
         e->Release();
     }
     }
-
-    if (info.getState() && !stricmp(info.getState(), "wait"))
-        info.setEventSchedule(2); //Can deschedule
-    else if (eventCountUnlimited || eventCountRemaining)
-        info.setEventSchedule(1); //Can reschedule
 }
 }
 
 
 IDistributedFile* WsWuInfo::getLogicalFileData(IEspContext& context, const char* logicalName, bool& showFileContent)
 IDistributedFile* WsWuInfo::getLogicalFileData(IEspContext& context, const char* logicalName, bool& showFileContent)