You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@empire-db.apache.org by Tim Colson <ti...@yahoo.com> on 2013/09/20 20:35:55 UTC

Example of using Options?

Options seem like a really cool thing to use, especially for a field that is a "STATUS" that represents stages of workflow. 

I'm wondering how we would leverage Options in a Model object so that when for example we want to findAllObjectsByStatus(listOfStatus) that it ensures at compile time that we are looking only for valid status types?

-Tim

Re: Example of using Options?

Posted by Tim Colson <ti...@yahoo.com>.
I'm looking at the Tutorial example, where the GENDER column is assigned options, and thinking about how to leverage those values:

// Create Options for GENDER column
      Options genders = new Options();
      genders.set( "M", "Male");
      genders.set("F", "Female");
      GENDER.setOptions(genders);    

For example, when updating a record, seems like there is an opportunity to make sure the string is one of the valid options.
rec.setValue(db.EMPLOYEES.GENDER, "M");

And seems like a useful list to check when writing select constraints.
cmd.where(EMP.GENDER.is("M") );

Might look something like this:
cmd.where(EMP.GENDER.is(GENDER.OPTIONS.M) );

As I look at the Javadoc & source, seems this isn't how things are done, need to use the strings, so no compile time check, but I could do a run-time validation of an incoming value (g = "F") to verify g is one of the valid Options.

-Tim

On Sep 26, 2013, at 2:25 PM, Francis De Brabandere <fr...@gmail.com> wrote:

> Could you post some more code as I'm not really following on what you
> are trying to accomplish...
> 
> On 20 September 2013 20:35, Tim Colson <ti...@yahoo.com> wrote:
>> Options seem like a really cool thing to use, especially for a field that is a "STATUS" that represents stages of workflow.
>> 
>> I'm wondering how we would leverage Options in a Model object so that when for example we want to findAllObjectsByStatus(listOfStatus) that it ensures at compile time that we are looking only for valid status types?
>> 
>> -Tim


Re: Example of using Options?

Posted by Francis De Brabandere <fr...@gmail.com>.
Could you post some more code as I'm not really following on what you
are trying to accomplish...

On 20 September 2013 20:35, Tim Colson <ti...@yahoo.com> wrote:
> Options seem like a really cool thing to use, especially for a field that is a "STATUS" that represents stages of workflow.
>
> I'm wondering how we would leverage Options in a Model object so that when for example we want to findAllObjectsByStatus(listOfStatus) that it ensures at compile time that we are looking only for valid status types?
>
> -Tim