Package org.opentides.bean

Examples of org.opentides.bean.ReportDefinition


           *
           *  :[paramName] - where paramName will be replaced by the value passed as parameter to the jasper
           *    report with the same name as [paramName]
           */
          // add to missingParameter
          ReportDefinition missed = new ReportDefinition();
          // set the name
          missed.setName(name.getValue());
          // set the class
          Attribute clazz = elem.attribute("class");
          missed.setClazz(clazz.getValue());
          List<Element> props =elem.elements("property");
          Properties property = new SortedProperties();
          for (Element prop:props) {
            String propName = prop.attributeValue("name");
            String propValue = prop.attributeValue("value");
            if ("prompt.type".equals(propName)) {
              missed.setType(propValue);
            } else if ("prompt.query".equals(propName)) {
              // extract the native query to database             
              String queryName = propValue;
              if(!StringUtil.isEmpty(queryName)){
                //try to match :[paramName]
                Matcher matcher = Pattern.compile(":(\\w+)").matcher(queryName);
                while (matcher.find()) {
                  String paramName = matcher.group(0).substring(1);
                  if (!StringUtil.isEmpty(paramName) && requestParams.get(paramName)!=null){
                    String[] paramValueArr = requestParams.get(paramName);
                    String paramValue = StringUtil.explode(',', paramValueArr);
                    queryName = queryName.replaceAll(":" + paramName, paramValue);
                  }
                }
              }
             
              List<Object[]> rs = ((ReportDAO) getDao()).getParamOptionResults(queryName);
              for (Object[] option : rs) {
                property.put(Long.valueOf(option[1].toString()), option[0].toString());
              }
            }else if("prompt.command".equals(propName)){
              missed.setType(propName);
              property.put(propValue, dynamicParameters.get(propValue));
            }else
              property.put(propName, propValue);
          }
          missed.setProperties(property);
          missing.add(missed);
        }
      }
      if (!requestParams.containsKey(DynamicReport.REPORT_FORMAT)) {
        ReportDefinition missed = new ReportDefinition();
        missed.setName("reportFormat");
        missed.setClazz("java.lang.String");
        missed.setType("dropdown");
        Properties props = new Properties();
        props.put(DynamicReport.FORMAT_EXCEL, "Excel");
        props.put(DynamicReport.FORMAT_HTML, "Html");
        props.put(DynamicReport.FORMAT_IMAGE, "Graph Image");
        props.put(DynamicReport.FORMAT_PDF, "PDF");
        missed.setProperties(props);
        missing.add(missed);
      }
    } catch (DocumentException e) {
      _log.error(e,e);
    }
View Full Code Here


//    Assert.assertTrue(reportParam.containsKey("raffleId"));
//    Assert.assertTrue(reportParam.containsKey("branch"));
//    Assert.assertTrue(reportParam.containsKey("imageStream"));
//    Assert.assertTrue(reportParam.containsKey("reportDate"));
    // check raffle_id
    ReportDefinition raffleId= reportParam.get(0);
    Assert.assertEquals("raffleId",raffleId.getName());
    Assert.assertEquals("java.lang.Long",raffleId.getClazz());
    // check branch
    ReportDefinition branch= reportParam.get(1);
    Assert.assertEquals("branch",branch.getName());
    Assert.assertEquals("java.lang.String",branch.getClazz());
    Assert.assertEquals("dropdown",branch.getType());
    Assert.assertTrue(branch.getProperties().containsKey("value.one"));
    Assert.assertTrue(branch.getProperties().containsKey("value.two"));
    // check report date
    ReportDefinition reportDate= reportParam.get(3);
    Assert.assertEquals("reportDate",reportDate.getName());
    Assert.assertEquals("java.util.Date",reportDate.getClazz());
    Assert.assertEquals("Report Date",reportDate.getLabel());
  }
View Full Code Here

TOP

Related Classes of org.opentides.bean.ReportDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.