Monday, January 8, 2018

How to work with Report in CQ / WEM

Use Case: You want to create custom report for any thing in CQ

Prerequisite: Please read very carefully


 What we are covering:

I will give one custom example and guide you how to create report within CQ for your custom requirement.

Q: Where I can find all CQ OOTB reports.
A: You can find them under /etc/reports. You can also navigate to CQ report using siteadmin -> tools-> /reports -> double click on any report

Q: Where is code for OOTB reporting templates and component
A: They can be found under /libs/cq/reporting and API http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/reporting/package-summary.html (I don't think you might have to use these API, Unless there is any specific requirement )

If you read above document very carefully, You will find that not all the reports comes with CQ uses CQ reporting framework. Specially Request log parser report and Disk Usage report.

We will cover CQ reporting example here using CQ reporting framework. For any other report please use example of disk usage or log parser report.

Requirement:

Create CQ report to get Geometrixx product page information. Report should include,

1) Title
2) Tags
3) URL
4) Overview Link
5) Feature Link

You should be able to group report based on Tags. You should also be able to see chart representation of report. You should also be able to export report outside CQ instance.


Solution:

First, Make sure that this can be done using CQ reporting framework. For that go through each field for report and make sure that those are available as properties within that page through "Fix" path and there is no complex logic involve to get that data.

Once you know that this can be done using CQ reports, Start developing report.

Step 1: Create template


  • Create a template for your report. See example under /libs/cq/reporting/templates. 
  • Create node called /apps/cq/reporting/templates
  • Easy is to copy existing report from /libs (I copied user report) to /apps and rename it. In our case I created a report called /apps/cq/reporting/templates/productReport
  • Go to /apps/cq/reporting/templates/productReport/jcr:content/report and assign resource type for your custom report. Also create a property called "rootPath" and assign value as "/content/geometrixx/en/products"
  • Template will look like this.
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:description="Geometrixx Product Report"
    jcr:primaryType="cq:Template"
    jcr:title="Geometrixx Product Report"
    allowedPaths="[/etc/reports(/.*)?]"
    ranking="{Long}100"
    shortTitle="Product Report">
    <jcr:content
        jcr:primaryType="cq:PageContent"
        sling:resourceType="cq/reporting/components/reportpage">
        <report
            jcr:primaryType="nt:unstructured"
            sling:resourceType="cq/reporting/components/productreport/productreport"
            repVersion="{Long}2"
            rootPath="/content/geometrixx/en/products"/>
    </jcr:content>
</jcr:root>


Step 2: Create Component

  • You can see example under /libs/cq/reporting/components/<I copied userreport>. Copy directory structure under /cq/reporting/components and rename it as productreport
  • Create / Rename (/libs/cq/reporting/components/userreport/userreport to cq/reporting/components/productreport/productreport)
  • Make sure that you have following nodes, /apps/cq/reporting/components/productreport/productreport/charting for creating chart data for grouped items. /apps/cq/reporting/components/productreport/productreport/dialog for existing report dialogs. /libs/cq/reporting/components/userreport/userreport/queryBuilder to specify query that needs to run against the report.
  • Change /libs/cq/reporting/components/userreport/userreport/queryBuilder, nodeType property to "cq:PageContent". Because your page jcr:content node has all those properties that we are looking for in our report.
  • Please see http://dev.day.com/docs/en/cq/current/developing/developing-reports.html#Query Definition if you want to add additional constraint in query. For example give me only those page whose cq:template value is "Something", In that case you would create something like this
N:queryBuilder
    N:propertyConstraints
    [
        N:N0 // array of nodes (name irrelevant), each with the following properties:
            P:cq:template
            P:something
    ]
    P:nodeTypes cq:PageContent
Step 3: Create all Column

  • Once we have query definition to get all pages, Now you can create column to show in your report.
  • For that see example under /libs/cq/reporting/components/userreport and see how each column is configured.
  • You can copy one column from /libs/cq/reporting/components/userreport under /apps/cq/reporting/components/productreport to start with
  • Description about field for a column can be found here http://dev.day.com/docs/en/cq/current/developing/developing-reports.html#Column Base Component
  • For example in our case, we want a Tag column. for that create /apps/cq/reporting/components/productreport/productreport/Tagcol with following definition
  • Now suppose you want overview page path, for that you have to nevigate to Overview node and then show it. In that case definition would look like this

14 comments:

  1. Get Packers and Movers Kolkata List of Top Reliable, 100% Affordable, Verified and Secured Service Provider. Get Free ###Packers and Movers Kolkata Price Quotation instantly and Save Cost and Time. ✔✔✔ Packers and Movers Kolkata Reviews and Compare Charges for household Shifting, Home/Office Relocation, ***Car Transportation, Pet Relocation, Bike SHifting @
    Packers and Movers Kolkata

    ReplyDelete
  2. Allassignmenthelp is a web portal where students get assignment help for all the subjects, with the help of our experts. You will get 100% plagiarism free assignment. Expert’s consultation is also available for students. If they have any query they can contact with our experts anytime.
    assignment help uk

    ReplyDelete
  3. WINNING303 - JUDI BOLA ONLINE | CASINO ONLINE | SLOT ONLINE | POKER ONLINE TERPERCAYA

    TOGEL POKER

    BO POKER

    TOGEL303

    CASINO303

    BOLA303

    * KUNJUNGI SITUS KAMI DI *

    www.winning303.com


    *NB : MENANG BERAPAPUN, PASTI KAMI BAYAR !!! *

    * Melayani LiveChat 7 x 24 Jam Nonstop :
    - WA : +6281717177303
    - BBM : WINNING303
    - LINE : WINNING303*

    ReplyDelete
  4. Excellent and nice post. It will beneficial for everyone. Thanks for sharing such a wonderful post. Avail No 1 Essay writing Services UK from certified PhD writers. It is extremely helpful for me. You can email us at info@ukdissertationhelp.co.uk or Phone Number - 020 8144 9988

    ReplyDelete
  5. Packers and Movers Pune Provide High Quality ***Household Shifting, Home/Office Relocation, Insurance, Packing, Loading, ###Car Transportation Service Pune and High experiences, Top Rated, Safe and Reliable, Best and Secure Packers and Movers Pune Team List. Get ✔✔✔ Affordable Rate Charts and Compare Quotation and Save Money and Time .
    Packers And Movers Pune

    ReplyDelete
  6. Hire Best Packers And Movers Mumbai for hassle-free Household Shifting, ***Office Relocation, ###Car Transporation, Loading Unloading, packing Unpacking at affordable ✔✔✔ Price Quotation. Top Rated, Safe and Secure Service Providers who can help you with 24x7 and make sure a Untroubled Relocation Services at Cheapest/Lowest Rate
    Packers And Movers Mumbai

    ReplyDelete
  7. Packers and Movers Chennai Give Safe and Reliable ***Household Shifting Services in Chennai with Reasonable ###Packers and Movers Price Quotation. We Provide Household Shifting, Office Relocation, ✔✔✔Local and Domestic Transportation Services, Affordable and Reliable Shifting Service Charges @
    Packers And Movers Chennai

    ReplyDelete
  8. Packers and Movers Bangalore as a Services providing company can make all the difference to your ###Home Relocation experience. Bangalore based Company which offers versatile solutions, Right team that easily reduce the stress associated with a ✔✔✔Household Shifting, ***Vehicle Transportation. we help things run smoothly and reduce breakages and offer you seamless, Affordable, Reliable Shifting Services, Compare Shifting Charges @
    Packers And Movers Bangalore

    ReplyDelete

  9. DAFTAR ID GRATIS SABUNG AYAM ONLINE


    * KUNJUNGI SITUS KAMI DI *

    WWW.ID303.INFO


    MENANG BERAPAPUN, PASTI KAMI BAYAR !!! *


    * Melayani LiveChat 7 x 24 Jam Nonstop :

    - WA : 08125522303
    - BBM : CSID303



    BONUS JACKPOT SABUNG AYAM ONLINE


    DEPOSIT VIA PULSA

    ReplyDelete
  10. AllAssignmenthelp reviews is best reviews site in US and Australia. We at Top Quality Assignment believe that there is no shortcut to success and to attain success, hard work, dedication, and commitment must be present.
    AllAssignmenthelp reviews
    All Assignment help reviews
    Assignment help reviews
    AllAssignmenthelp.com reviews

    ReplyDelete
  11. My Assignment Services is one such Online Assignment Help provider which provides a helping hand to all your academic related queries. They have a lot of professional experts who are skilful in giving you guidance and providing you with cheap assignment help services. You are free to contact their experts by visiting their website and get your pending presentations completed on the time. Given below are some of the steps that they follow while drafting your assignments. Many students see that Assignment Help UK experts are proficient in writing your assignments but no one wonders the reason behind it. However, students pursuing IT need to understand the concepts of Java because it holds down the concept of object oriented programming. The programming concepts are complex to understand and brings a havoc to students, that is why, My Assignment Services bring you our online assignment help services. Taking out some time to consider and contrast about what options that you have that you can include by writing them on a piece of paper. You can also contact some real time Deakin Referencing Generator experts to assist you with the following topics.

    ReplyDelete
  12. Packers and Movers Bangalore as a Services providing company can make all the difference to your ###Home Relocation experience. Bangalore based Company which offers versatile solutions, Right team that easily reduce the stress associated with a ✔✔✔Household Shifting, ***Vehicle Transportation. we help things run smoothly and reduce breakages and offer you seamless, Affordable, Reliable Shifting Services, Compare Shifting Charges. Packers And Movers Bangalore

    ReplyDelete