Package ar.com.fdvs.dj.domain

Examples of ar.com.fdvs.dj.domain.DynamicJasperDesign


  private static final Log log = LogFactory.getLog(DJJRDesignHelper.class);

  public static DynamicJasperDesign getNewDesign(DynamicReport dr) {
    log.info("obtaining DynamicJasperDesign instance");
    DynamicJasperDesign des = new DynamicJasperDesign();
    DynamicReportOptions options = dr.getOptions();
    Page page = options.getPage();

    des.setColumnCount(options.getColumnsPerPage().intValue());
    des.setPrintOrder(JasperDesign.PRINT_ORDER_VERTICAL);

    byte orientation = page.isOrientationPortrait() ? JasperReport.ORIENTATION_PORTRAIT : JasperReport.ORIENTATION_LANDSCAPE;
    des.setOrientation(orientation);

    des.setPageWidth(page.getWidth());
    des.setPageHeight(page.getHeight());

    des.setColumnWidth(options.getColumnWidth());
    des.setColumnSpacing(options.getColumnSpace().intValue());
    des.setLeftMargin(options.getLeftMargin().intValue());
    des.setRightMargin(options.getRightMargin().intValue());
    des.setTopMargin(options.getTopMargin().intValue());
    des.setBottomMargin(options.getBottomMargin().intValue());

    des.setWhenNoDataType(dr.getWhenNoDataType());
    des.setWhenResourceMissingType(dr.getWhenResourceMissing());

    des.setTitleNewPage(false);
    des.setSummaryNewPage(false);

    des.setDetail(new JRDesignBand());

    des.getDetail().setSplitAllowed(dr.isAllowDetailSplit());

    des.setPageHeader(new JRDesignBand());
    des.setPageFooter(new JRDesignBand());
    des.setSummary(new JRDesignBand());

    des.setTitleNewPage(options.isTitleNewPage());

    des.setIgnorePagination(options.isIgnorePagination());

    if (dr.getQuery() != null){
      JRDesignQuery query = getJRDesignQuery(dr);
      des.setQuery(query);
    }

    for (Iterator iterator = dr.getProperties().keySet().iterator(); iterator.hasNext();) {
      String name = (String) iterator.next();
      des.setProperty(name, (String) dr.getProperties().get(name));
    }

    des.setName(dr.getReportName() != null ? dr.getReportName() : "DynamicReport");
    return des;
  }
View Full Code Here


    return query;
  }


  public static DynamicJasperDesign downCast(JasperDesign jd, DynamicReport dr) throws CoreException {
    DynamicJasperDesign djd = new DynamicJasperDesign();
    log.info("downcasting JasperDesign");
    try {
      BeanUtils.copyProperties(djd, jd);

      //BeanUtils.copyProperties does not perform deep copy,
      //adding original parameter definitions manually
      if (dr.isTemplateImportParameters()){
        for (Iterator iter = jd.getParametersList().iterator(); iter.hasNext();) {
          JRParameter element = (JRParameter) iter.next();
          try {
            djd.addParameter(element);
          } catch (JRException e) {
            if (log.isDebugEnabled()){
              log.warn(e.getMessage());
            }
          }
        }
      }

      //BeanUtils.copyProperties does not perform deep copy,
      //adding original fields definitions manually
      if (dr.isTemplateImportFields()){
        for (Iterator iter = jd.getFieldsList().iterator(); iter.hasNext();) {
          JRField element = (JRField) iter.next();
          try {
            djd.addField(element);
          } catch (JRException e) {
            if (log.isDebugEnabled()){
              log.warn(e.getMessage());
            }
          }
        }
      }

      //BeanUtils.copyProperties does not perform deep copy,
      //adding original variables definitions manually
      if (dr.isTemplateImportVariables()){
        for (Iterator iter = jd.getVariablesList().iterator(); iter.hasNext();) {
          JRVariable element = (JRVariable) iter.next();
          try {
            if (element instanceof JRDesignVariable){
              djd.addVariable((JRDesignVariable) element);
            }
          } catch (JRException e) {
            if (log.isDebugEnabled()){
              log.warn(e.getMessage());
            }
          }
        }
      }

        //BeanUtils.copyProperties does not perform deep copy,
      //adding original dataset definitions manually
      if (dr.isTemplateImportDatasets()) {
        // also copy query
        JRQuery query = jd.getQuery();
        if (query instanceof JRDesignQuery) {
          djd.setQuery((JRDesignQuery) query);
          dr.setQuery(new DJQuery(query.getText(), query
              .getLanguage()));
        }

        for (Iterator iter = jd.getDatasetsList().iterator(); iter.hasNext();) {
          JRDesignDataset dataset = (JRDesignDataset) iter.next();
          try {
            djd.addDataset(dataset);
          } catch (JRException e) {
            if (log.isDebugEnabled()) {
              log.warn(e.getMessage());
            }
          }
        }
      }

      //BeanUtils.copyProperties does not perform deep copy,
      //adding original properties definitions manually
      String[] properties = jd.getPropertyNames();
      for (int i = 0; i < properties.length; i++) {
        String propName = properties[i];
        String propValue = jd.getProperty(propName);
        djd.setProperty(propName, propValue);
      }


      //Add all existing styles in the design to the new one
      for (Iterator iterator = jd.getStylesList().iterator(); iterator.hasNext();) {
        JRStyle style = (JRStyle) iterator.next();
        try {
          djd.addStyle(style);
        } catch (JRException e) {
          if (log.isDebugEnabled()){
            log.warn("Duplicated style (style name \""+ style.getName()+"\") when loading design: " + e.getMessage(), e);
          }
        }
View Full Code Here

  }


  protected static DynamicJasperDesign generateJasperDesign(DynamicReport dr) throws CoreException {
    DynamicJasperDesign jd = null;
    try {
      if (dr.getTemplateFileName() != null) {
        log.info("loading template file: "+dr.getTemplateFileName());
        log.info("Attemping to find the file directly in the file system...");
        File file = new File(dr.getTemplateFileName());
        if (file.exists()){
          JasperDesign jdesign = JRXmlLoader.load(file);
          jd = DJJRDesignHelper.downCast(jdesign,dr);
        } else {
          log.info("Not found: Attemping to find the file in the classpath...");
          URL url = DynamicJasperHelper.class.getClassLoader().getResource(dr.getTemplateFileName());
          JasperDesign jdesign = JRXmlLoader.load(url.openStream());
          jd = DJJRDesignHelper.downCast(jdesign,dr);
        }
        DJJRDesignHelper.populateReportOptionsFromDesign(jd,dr);

      } else {
        //Create new JasperDesign from the scratch
        jd = DJJRDesignHelper.getNewDesign(dr);
      }
      jd.setScriptletClass(DJDefaultScriptlet.class.getName()); //XXX this is new, for testing
      registerParameters(jd,dr);
    } catch (JRException e) {
      throw new CoreException(e.getMessage(),e);
    } catch (IOException e) {
      throw new CoreException(e.getMessage(),e);
View Full Code Here

        _parameters = new HashMap();

      visitSubreports(dr, _parameters);
      compileOrLoadSubreports(dr, _parameters);

      DynamicJasperDesign jd = generateJasperDesign(dr);
      Map params = new HashMap();
      if (!_parameters.isEmpty()){
        registerParams(jd,_parameters);
        params.putAll(_parameters);
      }
      registerEntities(jd, dr);
      layoutManager.applyLayout(jd, dr);
      JRProperties.setProperty(JRProperties.COMPILER_CLASS, DJCompilerFactory.getCompilerClassName());
      JasperReport jr = JasperCompileManager.compileReport(jd);
      params.putAll(jd.getParametersWithValues());
      jp = JasperFillManager.fillReport(jr, params, con);

      return jp;
    }
View Full Code Here

        _parameters = new HashMap();

      visitSubreports(dr, _parameters);
      compileOrLoadSubreports(dr, _parameters);

      DynamicJasperDesign jd = generateJasperDesign(dr);
      Map params = new HashMap();
      if (!_parameters.isEmpty()){
        registerParams(jd,_parameters);
        params.putAll(_parameters);
      }
      registerEntities(jd, dr);
      layoutManager.applyLayout(jd, dr);
      JRProperties.setProperty(JRProperties.COMPILER_CLASS, DJCompilerFactory.getCompilerClassName());
      JasperReport jr = JasperCompileManager.compileReport(jd);
      params.putAll(jd.getParametersWithValues());
      jp = JasperFillManager.fillReport(jr, params);

      return jp;
    }
View Full Code Here

        generatedParams = new HashMap();

      visitSubreports(dr, generatedParams);
      compileOrLoadSubreports(dr, generatedParams);

      DynamicJasperDesign jd = generateJasperDesign(dr);
      registerEntities(jd, dr);

      registerParams(jd, generatedParams); //if we have parameters from the outside, we register them

      layoutManager.applyLayout(jd, dr);
      JRProperties.setProperty(JRProperties.COMPILER_CLASS, "ar.com.fdvs.dj.util.DJJRJdtCompiler");
      jr = JasperCompileManager.compileReport(jd);
      generatedParams.putAll(jd.getParametersWithValues());
    return jr;
  }
View Full Code Here

  }

  protected static DynamicJasperDesign getNewDesign(DynamicReport dr) {
    log.info("obtaining DynamicJasperDesign instance");
    DynamicJasperDesign des = new DynamicJasperDesign();
    DynamicReportOptions options = dr.getOptions();
    Page page = options.getPage();

    des.setColumnCount(options.getColumnsPerPage().intValue());
    des.setPrintOrder(JasperDesign.PRINT_ORDER_VERTICAL);

    des.setPageWidth(page.getWidth());
    des.setPageHeight(page.getHeight());

    des.setColumnWidth(options.getColumnWidth());
    des.setColumnSpacing(options.getColumnSpace().intValue());
    des.setLeftMargin(options.getLeftMargin().intValue());
    des.setRightMargin(options.getRightMargin().intValue());
    des.setTopMargin(options.getTopMargin().intValue());
    des.setBottomMargin(options.getBottomMargin().intValue());

    des.setWhenNoDataType(dr.getWhenNoDataType());
    des.setWhenResourceMissingType(dr.getWhenResourceMissing());
   
    des.setTitleNewPage(false);
    des.setSummaryNewPage(false);

    des.setDetail(new JRDesignBand());
   
    des.getDetail().setSplitAllowed(dr.isAllowDetailSplit());
   
    des.setPageHeader(new JRDesignBand());
    des.setPageFooter(new JRDesignBand());
    des.setSummary(new JRDesignBand());

    des.setTitleNewPage(options.isTitleNewPage());

    des.setIgnorePagination(options.isIgnorePagination());
   
    if (dr.getQuery() != null){
      JRDesignQuery query = getJRDesignQuery(dr);
      des.setQuery(query);
    }

    des.setName("DynamicReport");
    return des;
  }
View Full Code Here

    des.setName("DynamicReport");
    return des;
  }

  protected static DynamicJasperDesign generateJasperDesign(DynamicReport dr) throws CoreException {
    DynamicJasperDesign jd = null;
    try {
      if (dr.getTemplateFileName() != null) {
        log.info("loading template file: "+dr.getTemplateFileName());
        log.info("Attemping to find the file directly in the file system...");
        File file = new File(dr.getTemplateFileName());
View Full Code Here

    query.setLanguage(dr.getQuery().getLanguage());
    return query;
  }

  protected static DynamicJasperDesign downCast(JasperDesign jd) throws CoreException {
    DynamicJasperDesign djd = new DynamicJasperDesign();
    log.info("downcasting JasperDesign");
    try {
      BeanUtils.copyProperties(djd, jd);

      //BeanUtils.copyProperties does not perform deep copy,
      //adding original parameter definitions manually
      for (Iterator iter = jd.getParametersList().iterator(); iter.hasNext();) {
        JRParameter element = (JRParameter) iter.next();
        try {
          djd.addParameter(element);
        } catch (JRException e) {  }

      }

      //Add all existing styles in the design to the new one
      for (Iterator iterator = jd.getStylesList().iterator(); iterator.hasNext();) {
        JRStyle style = (JRStyle) iterator.next();
        try {
          djd.addStyle(style);
        } catch (JRException e) {
          log.warn("Duplicated style (style name \""+ style.getName()+"\") when loading design: " + e.getMessage(), e);
        }
      }
View Full Code Here

      if (_parameters == null)
        _parameters = new HashMap();

      compileOrLoadSubreports(dr, _parameters);

      DynamicJasperDesign jd = generateJasperDesign(dr);
      Map params = new HashMap();
      if (!_parameters.isEmpty()){
        registerParams(jd,_parameters);
        params.putAll(_parameters);
      }
     
      registerEntities(jd, dr);
      layoutManager.applyLayout(jd, dr);
            JRProperties.setProperty(JRProperties.COMPILER_CLASS, DJCompilerFactory.getCompilerClassName());
           
//            JRDesignReportFont reportFont = new JRDesignReportFont();
//            reportFont.setName("Cocaine Sans Normal");
//            reportFont.setFontSize(28);           
//      jd.addFont(reportFont);
           
            JasperReport jr = JasperCompileManager.compileReport(jd);
            params.putAll(jd.getParametersWithValues());
            jp = JasperFillManager.fillReport(jr, params, ds);

            return jp;
  }
View Full Code Here

TOP

Related Classes of ar.com.fdvs.dj.domain.DynamicJasperDesign

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.