/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.oodt.cas.workflow.cli.action;

//JDK imports
import java.util.List;

//OODT imports
import org.apache.oodt.cas.cli.exception.CmdLineActionException;
import org.apache.oodt.cas.workflow.structs.Workflow;

/**
 * A {@link CmdLineAction} which get the current list of workflows by
 * event name
 *
 * @author bfoster (Brian Foster)
 */
public class GetWorkflowsByEventCliAction extends WorkflowCliAction {

   private String eventName;

   @Override
   public void execute(ActionMessagePrinter printer)
         throws CmdLineActionException {
      try {
         @SuppressWarnings("unchecked")
         List<Workflow> workflows = getClient().getWorkflowsByEvent(eventName);

         if (workflows == null) {
            throw new Exception("WorkflowManager returned null workflow list");
         }
         for (Workflow workflow : workflows) {
            printer.println("Workflow: [id=" + workflow.getId() + ", name="
                  + workflow.getName() + ", numTasks="
                  + workflow.getTasks().size() + "]");
         }
      } catch (Exception e) {
         throw new CmdLineActionException(
               "Failed to get workflows by event name '" + eventName + "' : "
                     + e.getMessage(), e);
      }
   }

   public void setEventName(String eventName) {
      this.eventName = eventName;
   }
}

@@ -1016,16 +1016,74 @@
 orkflow;
+%0Aimport org.apache.oodt.cas.workflow.structs.WorkflowTask;
 %0A%0A/**%0A *
@@ -1371,25 +1371,16 @@
 printer)
-%0A        
  throws 
@@ -1410,16 +1410,21 @@
 %7B%0A      
+%0A%09   
 try %7B%0A  
@@ -1663,24 +1663,34 @@
 %0A         %7D%0A
+         %0A
          for
@@ -1720,24 +1720,250 @@
 orkflows) %7B%0A
+        %09 %0A             String taskIds = %22%22;%0A             for (WorkflowTask wt : workflow.getTasks()) %7B%0A            %09 if (taskIds.length()%3E0) taskIds += %22, %22;%0A            %09 taskIds += wt.getTaskId();%0A             %7D%0A        %09 %0A
             
@@ -2129,16 +2129,39 @@
 size() +
+ %22, taskIds=%22+taskIds +
  %22%5D%22);%0A 
@@ -2166,24 +2166,34 @@
 %0A         %7D%0A
+         %0A
       %7D catc
@@ -2470,15 +2470,19 @@
 ntName;%0A
-
    %7D%0A
+   %0A
 %7D%0A

Printing out the workflow task ids (OODT-861), also when querying the workflows by event.