2 Replies Latest reply on Jan 16, 2014 2:51 PM by leipeter

    How to load enumeration in to guvnors use glassfish?

    leipeter

      The current version I am using:

      Glassfish 3.1.2.2

      Guvnors 5.4Final

      Here is what I have:

      1. I have load a POJO which contains a class/database table CollectionType with fields/members code, value, id

      2. I create classes to simulate load enumerations for CollectionType.code: Please see below code.

      3. I put the enum jar file in GLASSFISH_HOME\glassfish\modules

      4. Create the new enumerations in Guvnor.

      5. In the Enum edit screen, wrote the statement:

            'CollectionType.Code' : CollectionTypeEnumLoad.loadSimpleCode

      6. Receive error:

      [EnumTest1] Unable to load enumeration data.
      [EnumTest1] [Error: unresolvable property or identifier: CollectionTypeEnumLoad] [Near : {... lectionType.Code' : CollectionTypeEnumLoad.loadSim ....}] ^ [Line: 1, Column: 27]
      [EnumTest1] Error type: org.mvel2.PropertyAccessException

       

      Question:

      Where should I put the enumeration jar file? or any other thing I did wrong?

       

      Thank you very in advance!

       

      Best Regards,

       

      Lei

       

      ================================== Code ================

      public class CollectionTypeEnumLoad

      {

       

               private enum valueString {

                     THIRTY ("THIRTY DAYS"), SIXTY("SIXTY DAYS"), NINETY("NINETY DAYS"), THREE("ONE HUNDER TWENTY DAYS");

            

                   private String numberStr;

            

                   valueString(String number) {

                       this.numberStr = number;

                   }

            

                   public String getEnumString() {

                       return numberStr;

                   }

               };

       

           public static List <String> loadSimpleCode () {

               List<String> returnList = new ArrayList<String>();

              for (int i=0; i < 4; i++) {

                  String tempString = null;

                  switch {

                      case 0:

                          tempString = valueString.THIRTY.getEnumString();

                          break;

                      case 1:

                          tempString = valueString.SIXTY.getEnumString();

                          break;

                      case 2:

                          tempString =valueString.NINETY.getEnumString();

                          break;

                      case 3:

                          tempString = valueString.THREE.getEnumString();                

                  }

                  returnList.add(tempString);

              }

              return returnList;

          }

                

      }

        • 1. Re: How to load enumeration in to guvnors use glassfish?
          leipeter

          I have tried to use = sign

          'CollectionType.Code'=CollectionTypeEnumLoad.loadSimpleCode (use '=' instead of ':').

          and I put the jar file in

          C: \glassfish-3.1.2.2\glassfish\modains\domain1\applications\guvnor\WEB-INF\lib.

          I can pass validation. I would assume that Guvnor able to find the class/method. But I am not able to get the drop down list for CollectionType.code from rule or test scenario.

           

          According to the menu:

          For the method return only a List <String> use ":" sign:  'CollectionType.Code':CollectionTypeEnumLoad.loadSimpleCode

          For the method return the Map <String, List<String>> with key is FactName.Field use" =" sign: 'CollectionType.Code'=CollectionTypeEnumLoad.loadSimpleCodeMap

           

          Therefore I add a new method return the map in CollectionTypeEnumLoad class:

          public static Map <String, List<String>> loadSimpleCodeMap() {

                 Map <String, List<String>> returnMap = new HashMap();

                

                 returnMap.put("CollectionType.code", loadSimpleCode());

                

                 return returnMap;

             }

           

           

          In the enum creation:

          If I use ":" I am not able to pass validation

           

          If I use "=" sign I am able to pass validation but not able to get drop down:

           

           

          In the test scenario, I select name the fact name as CollectionType and select code field. I should get a drop down list for the selection, but I did not.

          Now, I am not sure what should be used and how can I get my drop down list. It looks like the behavior between ":" and "=" is different.

          Please let me know where am I missing or any suggestions on how can I trouble shoot is greatly appreciated -- Thank you.

          • 2. Re: How to load enumeration in to guvnors use glassfish?
            leipeter

            I finally get the array list work for the drop down:

            1. After create the *.jar, needs load it to Guvnor

            2. in the enum, needs to put the full path of the method:

            3. In the rule you can see the drop down: