Thanks Sharon!  You're awesome. :)
-T

On Wed, Jan 2, 2013 at 10:06 AM, Sharon Lucas <luc...@us.ibm.com> wrote:

> Hi Tennis,
>
> Yes, you can do this if you submit this STAF service request via a program
> using a STAF API for Java, C/C++, Python, Perl, or Tcl instead of using the
> STAF command line executable which just returns a string containing the
> result because then you can access the individual fields (such as jobID and
> status) in the unmarshalled result object directly.  For examples, see the
> following documents accessible via the STAF Documentation web page at
> http://staf.sourceforge.net/docs.php for the programming language of your
> choice:
> - STAFJava User's Guide - This document describes STAF's V3 support for
> the Java language.  It includes information on the core STAF Java APIs.
> - STAF Python User's Guide - This document describes STAF's V3 support for
> the Python language.  It includes information on the core STAF Python APIs.
> - STAF Perl User's Guide - This document describes STAF's V3 support for
> the Perl language.  It includes information on the core STAF Perl APIs.
> - STAF Tcl User's Guide - This document describes STAF's V3 support for
> the Tcl language.  It includes information on the core STAF Tcl APIs.
> - STAF User's Guide sections "6.2 C" and "6.3 C++" - These sections
> document STAF's support for C/C++.
>
> The STAX Users's Guide describes the result format returned by a STAX
> "EXECUTE FILE <FileName> WAIT RETURNRESULT" request in section "EXECUTE",
> sub-section "Results" at
> http://staf.sourceforge.net/current/STAX/staxug.html#Header_Execute.  See
> where it talks about when this request is successful and the WAIT option
> and RETURNRESULT option are specified (but not the DETAILS option) and says
> the result will contain a marshalled <Map:STAF/Service/STAX/JobResult>
> representing the job result and it defines this map and its fields
> (including "jobID" and "status").
>
> For example, here's a Java program that submits an "EXECUTE FILE
> <FileName> WAIT RETURNRESULT" request to the STAX service on the local
> machine and accesses the fields named "jobID" and "status" in the result:
>
> import com.ibm.staf.*;
> import java.util.Map;
>
> public class RunSTAXJob
> {
>     public static void main (String[] args)
>     {
>         new RunSTAXJob();
>     }
>
>     public RunSTAXJob()
>     {
>         STAFHandle stafHandle = null;
>
>         try
>         {
>             stafHandle = new STAFHandle("MyTest");
>             String machine = "local";
>             String service = "STAX";
>             String xmlFileName = "C:/stax/test1.xml"; // XXX: Change this
> to your STAX xml job name
>             STAFResult result = null;
>
>             // You should use helper method STAFUtil.wrapData() for any
> values
>             // that may contain spaces
>
>             String request = "EXECUTE FILE " +
> STAFUtil.wrapData(xmlFileName) +
>                 " WAIT RETURNRESULT";
>
>             result = stafHandle.submit2(machine, service, request);
>
>             if (result.rc != STAFResult.Ok)
>             {
>                 System.out.println(
>                     "Error submitting request STAF " + machine + " " +
>                     service + " " + request + "\nRC: " + result.rc +
>                     "  Result: " + result.result);
>                 System.exit(1);
>             }
>
>             // Pretty print the result (if desired)
>             System.out.println(result.resultContext);
>
>             // The result from the STAX EXECUTE WAIT RETURNRESULT is a
>             // marshalled map.  Access the data from the map (e.g. jobID,
>             // status, result) in the root object of the result.
>
>             Map jobResultMap = (Map)result.resultObj;
>             String jobID = (String)jobResultMap.get("jobID");
>             String jobStatus = (String)jobResultMap.get("status");
>
>             if (!jobStatus.equals("Normal"))
>             {
>                 System.out.println(
>                      "STAX Job ID " + jobID + " failed with a " +
>                      jobStatus + " status.");
>                 System.exit(1);
>             }
>
>             String jobResult = (String)jobResultMap.get("result");
>
>             System.out.println(
>                 "STAX Job ID " + jobID +
>                 " completed successfully returning: " + jobResult);
>
>             stafHandle.unRegister();
>         }
>         catch (STAFException e)
>         {
>            System.out.println("STAFException creating handle: " +
> e.getMessage());
>         }
>     }
> }
>
> --------------------------------------------------------------
> Sharon Lucas
> IBM Austin,   luc...@us.ibm.com
> (512) 286-7313 or Tieline 363-7313
>
>
>
>
> From:        Tennis Smith <tennis_sm...@yahoo.com>
> To:        staf-users@lists.sourceforge.net,
> Date:        12/26/2012 09:26 PM
> Subject:        [staf-users] Getting Key/Values From Results Data
> ------------------------------
>
>
>
> Hi,
>
> I'm confused about the best way to access the contents of results when I
> run a stax job.  For example,  when this is the output:
> {
>   Job ID         : 3
>   Start Date-Time: 20101028-14:35:01
>   Stop Date-Time : 20101028-14:39:19
>   Status         : Normal
>   Job Log Errors : []
>   Result         : None
>   Testcase Totals: {
>     Tests : 1
>     Passes: 1
>     Fails : 0
>   }
> }
>
> How can i get the value for "Job ID" without grep or some other utility?
>  Is there a "native" way to access the jobid key/value pairs?
>
> Hope this makes sense.
>
> --
> Tks,
> -Tennis
> ------------------------------------------------------------------------------
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122712
> _______________________________________________
> staf-users mailing list
> staf-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/staf-users
>
>


-- 
Tks,
-Tennis
------------------------------------------------------------------------------
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to