Bug 4294 - Batch status should be an enum
Batch status should be an enum
Product: jbatch
Classification: Unclassified
Component: source
PC Linux
: P5 normal
: ---
Assigned To: cvignola
Depends on:
  Show dependency treegraph
Reported: 2012-11-12 14:46 UTC by geofjamg
Modified: 2013-01-17 14:39 UTC (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description geofjamg 2012-11-12 14:46:24 UTC
Batch status has a finite number of state, so why is it implemented as a string and not as an enum (see JobExecution, StepExecution, etc)?
Comment 1 cvignola 2012-11-19 11:03:40 UTC
It is implemented as string for consistency with exit status, which is user defined and a string for readability on Job XML elements such as end, stop, and fail.
Comment 2 geofjamg 2013-01-16 21:37:08 UTC
Why is it needed to have consistency between batch status and exit status? They are quite different, one is user defined and is implemented as a string and the other is a predefined status and would logically be implemented as an enum.

I also think that the batch status has to be defined as an enum is the job xml XSD (with a restriction on the xsd:string type).
Comment 3 ScottKurz 2013-01-16 22:50:23 UTC
I think we need the spec to define the String values for batch status.    That's because the default value of exit status is batch status, and because we can transition using pattern matching.

But that doesn't prevent us from defining an enum for Java code, along with the corresponding String values.   That does seem to be the more typical thing to expect.. in fact the difference in type could even be a nice reminder to someone first learning JSR 352 that the batch statuses are predefined while the exit status is user-defined.


As far as the XSD, though... we're currently using all xsd:string types because of the need to allow for JSL property substitution.   Any JSL value which logically is constrained to be an enum, int, or boolean value after substitution must still use the xsd:string type.. or else the JSL document can't be validated when authored and when initially parsed.
Comment 4 cvignola 2013-01-17 13:32:03 UTC
We will add a Java enum only.  This will appear in v1.1 of the proposed final draft.
Comment 5 cvignola 2013-01-17 14:39:19 UTC
Changes are:


	 * BatchStatus enum defines the batch status values
	 * possible for a job.

All occurrences of method signature:   

String getBatchStatus();

change to: 

BatchStatus getBatchStatus(); 

These interfaces are affected:  

JobExecution (note:  change method name from getStatus to getBatchStatus for consistency)
StepExecution (note:  change method name from getStatus to getBatchStatus for consistency)