Coverage Report - ar.com.fdvs.dj.domain.ExpressionHelper
 
Classes in this File Line Coverage Branch Coverage Complexity
ExpressionHelper
0%
0/15
N/A
1
ExpressionHelper$1
0%
0/2
0%
0/2
1
ExpressionHelper$PrintInFirstPage
0%
0/2
0%
0/2
1
ExpressionHelper$PrintNotInFirstPage
0%
0/2
0%
0/2
1
 
 1  
 package ar.com.fdvs.dj.domain;
 2  
 
 3  
 import java.util.Map;
 4  
 
 5  
 import ar.com.fdvs.dj.domain.entities.Entity;
 6  
 import ar.com.fdvs.dj.util.customexpression.PageNumberCustomExpression;
 7  
 import ar.com.fdvs.dj.util.customexpression.RecordsInPageCustomExpression;
 8  
 import ar.com.fdvs.dj.util.customexpression.RecordsInReportCustomExpression;
 9  
 
 10  0
 public class ExpressionHelper {
 11  0
         private static final BooleanExpression printInFirstPage = new PrintInFirstPage();
 12  0
         private static final BooleanExpression printNotInFirstPage = new PrintNotInFirstPage();
 13  0
         private static final CustomExpression pageNumber = new PageNumberCustomExpression();
 14  0
         private static final CustomExpression recordsInPage = new RecordsInPageCustomExpression();
 15  0
         private static final CustomExpression recordsInReport = new RecordsInReportCustomExpression();
 16  
         
 17  
         public static BooleanExpression printInFirstPage() {
 18  0
                 return printInFirstPage;
 19  
         }
 20  
         
 21  
         public static BooleanExpression printNotInFirstPage() {
 22  0
                 return printNotInFirstPage;
 23  
         }
 24  
 
 25  
         /**
 26  
          * Convenient CustomExpression that returns page number
 27  
          */
 28  
         public static CustomExpression getPageNumber() {
 29  0
                 return pageNumber;
 30  
         }
 31  
         
 32  
         /**
 33  
          * Convenient CustomExpression that returns the record number for the current page
 34  
          */
 35  
         public static CustomExpression getRecordsInPage() {
 36  0
                 return recordsInPage;
 37  
         }
 38  
         
 39  
         /**
 40  
          * Convenient CustomExpression that returns the record number for whole report
 41  
          */
 42  
         public static CustomExpression getRecordsInReport() {
 43  0
                 return recordsInReport;
 44  
         }
 45  
         
 46  
         public static BooleanExpression printWhenGroupHasMoreThanOneRecord(final String groupName) {                
 47  0
                 return new BooleanExpression() {
 48  
                         private static final long serialVersionUID = Entity.SERIAL_VERSION_UID;
 49  
                         
 50  0
                         public Object evaluate(Map fields, Map variables, Map parameters) {
 51  0
                                 return new Boolean(getGroupCount(groupName, variables) > 1);
 52  
                         }
 53  
                 };
 54  
         }
 55  
         
 56  
         public static int getPageNumber(Map variables) {
 57  0
                 return ((Integer) variables.get("PAGE_NUMBER")).intValue(); 
 58  
         }
 59  
 
 60  
         public static int getGroupCount(String groupName, Map variables) {
 61  0
                 return ((Integer) variables.get(groupName + "_COUNT")).intValue(); 
 62  
         }
 63  
         
 64  0
         private static class PrintInFirstPage extends BooleanExpression {
 65  
                 private static final long serialVersionUID = Entity.SERIAL_VERSION_UID;
 66  
                 
 67  
                 public Object evaluate(Map fields, Map variables, Map parameters) {
 68  0
                         return new Boolean(getPageNumber(variables) == 1);
 69  
                 }
 70  
         }
 71  
         
 72  0
         private static class PrintNotInFirstPage extends BooleanExpression {
 73  
                 private static final long serialVersionUID = Entity.SERIAL_VERSION_UID;
 74  
                 
 75  
                 public Object evaluate(Map fields, Map variables, Map parameters) {
 76  0
                         return new Boolean(getPageNumber(variables) > 1);
 77  
                 }
 78  
         }
 79  
 }