Product Idea

Expand all | Collapse all

How to integrate own java code in velocity reports

  • 1.  How to integrate own java code in velocity reports

    Posted 09-10-2015 08:48
    In case you need a query or some special logic in velocity it would be fine to have the ability to add that easily in Java.

    In velocity it is possible to access all logic being accessible in beans and some objects that are handed over by the caller.

    To integrate own logic, it must get accessible in a bean.

    To achieve that the contour-service-helper.xml can be patched the following way, insert:

    <bean id="frequentisJamaUtils" class="com.jamasoftware.contour.plugin.jama.FrequentisJamaUtils">
    </bean>

    Where FrequentisJamaUtils is the java class, we have placed that in the plugin package.

    In velocity you must add the following:
    #set($fju = $applicationContext.getBean("frequentisJamaUtils"))

    A call would look like the following:
    #set($reviews = $fju.getReviewsForGlobalId($vDoc.document.globalId))

    Here a query is called providing all reviews also reviews done in other projects on synched items.

    The query looks like:

    public List<Review> getReviewsForGlobalId( final String globalId )   {

          @SuppressWarnings("unchecked")
          final List<Review> reviews =
                this.getSession()
                      .createQuery(
                            "select rw from Review rw where rw.id in (select rev.review.id from Revision rev inner join rev.revisionItems ri where ri.version.originDocument.id in (select doc.id from Document doc where doc.globalId = :globalId))" )
                      .setParameter( "globalId", globalId ).list();
          return reviews;
       }


    In case you make your own trials, don't forget the "@Autowired" at the class declaration.

    Harald


  • 2.  Re: How to integrate own java code in velocity reports

    Posted 09-10-2015 14:14
    Thanks for sharing this, Harald. You are full of surprises.


  • 3.  Re: How to integrate own java code in velocity reports

    Posted 09-10-2015 17:06
    Hi Harald, this is so impressive and over my head I cannot even say I "like" it. How come in the Community there is no option for clicking on "wow?" :-) I will save this in the back of my head. If I ever need to do this, I know whom to beg and bribe :-) swoo


  • 4.  RE: How to integrate own java code in velocity reports

    Posted 03-31-2020 09:49
    Just a note that with Jama Connect 8.49 this will no longer be possible.

    ------------------------------
    Chloe Elliott
    Jama Software
    Portland OR
    ------------------------------