7 Replies Latest reply on Mar 27, 2014 9:12 AM by jocelyn.duc

    Identify variables, create triples and store them through a custom marshaling strategy

    jocelyn.duc

      Hello,

       

      Last days I was trying to store my variables to an external triplestore database, for a semantic usage. The following explanations helped me and I think this is the best way to accomplish my goal:

      jBPM 6 - store your process variables anywhere | Accelerate your business | Planet JBoss Community

      jBPM and semantic web

       

      Using a triplestore database is meaning that I have to deal with triples formatted variables. So, for example, to save a firstname, I have to provide a similar triple:

      • Subject: a person with a certain ID
      • Predicate: hasFirstname
      • Object: the litteral "Mary"

       

      In reference to the links above, I have to extend jBPM by creating a new ResolverStrategy which will be able to marshall/unmarshall triple. A ResolverStrategy starts with an accept(Object o) method which determinates if the given object will be marshalled/unmarshalled by the strategy. If not, the default strategy will do it. In this case, if I set objects of custom type "Triple" as process variables in my BPM, my custom strategy will catch them thanks to the "instance of" keyword. So, for now, all Triple objects in my BPM can be handled.

       

      The problem with this method is that I have to use several custom type objects in my diagram. I would like to use the standard primitives jBPM types. I would my form to output a String and not a Triple.I would like to keep something as generic as possible, Where the end user won't have to create special type to get it working. But the solution will have to create and save triple as background. In other words, the modelling of the diagram should not be dependent of the triplestore and the user should be able to design using standard types.

       

      So, I need your advice. A value arrive into the accept method... and what next? How to determine this is a firstname and that is has to be saved as predicate "hasFirstname"? How to determine who has this firstname, since values arrives ones after the others in the accept method? My problem is kindly how to identify the given values...? Passing a Person object is easy, but how to do it with standard types?

       

      Any idea will be useful!

       

      Thank you!

        • 1. Re: Identify variables, create triples and store them through a custom marshaling strategy
          jocelyn.duc

          For example,

           

          If I output objects passing through the acceptor, I have this:

           

          value: krisv
          type: String
          value: My comment
          type: String
          value: Input
          type: String
          value: HR
          type: String
          ...
          

           

          How does the system may know that HR is the actor group, save it and then read it as the actor group? I need a short course about jBPM marshalling and persistence...

          • 2. Re: Identify variables, create triples and store them through a custom marshaling strategy
            swiderski.maciej

            currently identification is based on types so it's rather difficult to do so on simple types like string. One way you could do is to actually store everything using that strategy which ultimately makes it default one.Other than that you need to use custom types to encapsulate the value so the strategy will have all required information to make a decision on what to do with given variable.

             

            HTH

            • 3. Re: Identify variables, create triples and store them through a custom marshaling strategy
              jocelyn.duc

              Yes, for now, custom type method works well. Based on your Document example, I have implemented a generic solution for all my custom types. I use RDFBeans, which translate a java object to RDF tree for my external database. To give you more explanations, my boss want me to use only primitive types to make my solution usable by lambda users. It means that if the user want to design a BPM about specific things, he doesn't need to create custom types... IMHO, if you offer the possibility to use custom types, to create them through a user-friendly data modeler, we have to use it and take advantage of all the capacities of the system!

               

              As you say, I think the solution is to encapsulate my outputs in a generic object containing data and descriptions, in an additional step, to be able to clearly identify what is inside. In this case, the end-user will design a user task with primitives strings firstname and lastname variable and tells the system thoses fields are a Person (how? where?) then the RDF marshaller will know this is a Person and will be able to create a correct Person graph. But, once more, someone will have to write how the marshaller should save a Person and any other entity. In all case, an experimented user will have to describe how the RDF marshaller should works.

              • 4. Re: Identify variables, create triples and store them through a custom marshaling strategy
                jocelyn.duc

                We have just had a meeting. We decided to encapsulate the data to add it the metadata we need for the RDF serialization.

                 

                Knowing that we wish to use only the jbpm-console, is it possible to extend it to get form values on submit and put them into an EncapsluatedData object? Where to find the human tasks action controllers?

                • 5. Re: Identify variables, create triples and store them through a custom marshaling strategy
                  swiderski.maciej

                  that looks like a perfect fit for transformation of data input and output that was added post 6.0.1 and is currently available in master. That allows you to use various script languages to transform incoming data to different formats. Either by using one of existing one that are based on javax.scripting or creating and registering your own. You might want to look at few examples we have in code base to see if that would fit your need.

                  - custom transformation

                  - default scripting lang from java 6

                  - mvel transformation

                   

                  Note: tooling support is still missing for it, so manual editing of bpmn2 is required.

                   

                  HTH

                  • 6. Re: Identify variables, create triples and store them through a custom marshaling strategy
                    jocelyn.duc

                    Thank you for the tip. I didn't know transformations. But for now, I have to work with 6.0.1.

                     

                    Working with CustomFieldTypes is possible too, right? I would like to create an EncapsulatedDataCustomFieldType, for my user to be able to set the EncapsulatedData value thank to a standard input field. From what I read, this is a good alternative. Is it a nice way to register a new CustomFieldType? The online documentation describe the implementation (file example) and the usage, but not the installation.

                    • 7. Re: Re: Identify variables, create triples and store them through a custom marshaling strategy
                      jocelyn.duc

                      Basically a Custom Field Type is a Java class that implements the org.jbpm.formModeler.core.fieldTypes.CustomFieldType interface and is packaged inside inside a jar file that is placed on the Application Server classpath or inside the application War.

                       

                      Implementing CustomFieldType, done.

                       

                      But for the installation, is it possible to add it into JBoss AS classpath? With AS 7.1.1, I have to use the modules system, isn't it? I don't know if I do it correctly, but I can't get it working. How to be sure my module is loaded? By the way, I can't see the File Input field (example) in my modeler...