Package de.iritgo.aktera.model

Examples of de.iritgo.aktera.model.Output


      Configuration config = getConfiguration();
      java.util.List configPath = ModelTools.getDerivationPath(req, this);

      ModelResponse res = req.createResponse();
      ListingDescriptor listing = createListingFromConfig(config, configPath);
      Output output = res.createOutput("listing");

      output.setContent(listing);
      res.add(output);

      return res;
    }
    catch (ConfigurationException x)
View Full Code Here


  public static ListingDescriptor createListingFromModel(ModelRequest req, String modelName) throws ModelException
  {
    try
    {
      Model listingModel = (Model) req.getService(Model.ROLE, modelName);
      Output listingOutput = (Output) listingModel.execute(req).get("listing");

      if (listingOutput != null)
      {
        return (ListingDescriptor) listingOutput.getContent();
      }

      throw new ModelException("[Listing] Unable to find listing model '" + modelName + "'");
    }
    catch (Exception x)
View Full Code Here

   */
  public Output createOutput(String name)
  {
    assert StringTools.isNotTrimEmpty(name);

    Output output = new DefaultOutput();

    output.setName(name);

    return output;
  }
View Full Code Here

   * @see de.iritgo.aktera.ui.UIResponse#createOutput(java.lang.String,
   *      java.lang.String)
   */
  public Output createOutput(String name, String content)
  {
    Output output = createOutput(name);

    output.setContent(content);

    return output;
  }
View Full Code Here

  /**
   * @see de.iritgo.aktera.ui.UIResponse#addOutput(java.lang.String)
   */
  public Output addOutput(String name)
  {
    Output newOutput = createOutput(name);

    add(newOutput);

    return newOutput;
  }
View Full Code Here

   * @see de.iritgo.aktera.ui.UIResponse#addOutput(java.lang.String,
   *      java.lang.String)
   */
  public Output addOutput(String name, String content)
  {
    Output newOutput = addOutput(name);

    newOutput.setContent(content);

    return newOutput;
  }
View Full Code Here

   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    ModelResponse res = req.createResponse();

    Output outReport = res.createOutput("report");

    res.add(outReport);

    String backModel = req.getParameterAsString("backModel");

    if (! StringTools.isEmpty(backModel))
    {
      Command cmd = res.createCommand(backModel);

      cmd.setName("back");
      cmd.setLabel("back");
      res.add(cmd);
    }

    try
    {
      JasperPrint reportPrint = null;

      if (req.getParameter("page") != null)
      {
        reportPrint = (JasperPrint) UserTools.getUserEnvObject(req, "currentReport");
      }

      String reportFormat = req.getParameterAsString("format");

      if (reportPrint == null)
      {
        String reportName = req.getParameterAsString("report");

        reportPrint = ReportTools.createReport("keel-dbpool", reportName, reportFormat, req, getClass());

        UserTools.setUserEnvObject(req, "currentReport", reportPrint);
      }

      int page = NumberTools.toInt(req.getParameter("page"), 1);

      if ("pdf".equals(reportFormat))
      {
        res.addOutput("contentType", "application/pdf");
        res.addOutput("fileName", "Report.pdf");

        ByteArrayOutputStream buf = new ByteArrayOutputStream();
        JRExporter exporter = new JRPdfExporter();

        exporter.setParameter(JRExporterParameter.JASPER_PRINT, reportPrint);
        exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, buf);
        exporter.exportReport();
        outReport.setContent(buf.toByteArray());
      }
      else if ("csv".equals(reportFormat))
      {
        res.addOutput("contentType", "text/plain");
        res.addOutput("fileName", "Report.csv");

        ByteArrayOutputStream buf = new ByteArrayOutputStream();
        JRExporter exporter = new JRCsvExporter();

        exporter.setParameter(JRExporterParameter.JASPER_PRINT, reportPrint);
        exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, buf);
        exporter.exportReport();
        outReport.setContent(buf.toByteArray());
      }
      else if ("csv".equals(reportFormat))
      {
        res.addOutput("contentType", "text/xml");
        res.addOutput("fileName", "Report.xml");

        ByteArrayOutputStream buf = new ByteArrayOutputStream();
        JRExporter exporter = new JRXmlExporter();

        exporter.setParameter(JRExporterParameter.JASPER_PRINT, reportPrint);
        exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, buf);
        exporter.exportReport();
        outReport.setContent(buf.toByteArray());
      }
      else if ("xls".equals(reportFormat))
      {
        res.addOutput("contentType", "application/xls");
        res.addOutput("fileName", "Report.xls");

        ByteArrayOutputStream buf = new ByteArrayOutputStream();
        JRExporter exporter = new JRXlsExporter();

        exporter.setParameter(JRExporterParameter.JASPER_PRINT, reportPrint);
        exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, buf);
        exporter.exportReport();
        outReport.setContent(buf.toByteArray());
      }
      else
      {
        StringBuffer buf = new StringBuffer();
        JRExporter exporter = new JRHtmlExporter();

        exporter.setParameter(JRExporterParameter.JASPER_PRINT, reportPrint);
        exporter.setParameter(JRExporterParameter.OUTPUT_STRING_BUFFER, buf);
        exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER, "");
        exporter.setParameter(JRHtmlExporterParameter.HTML_FOOTER, "");
        exporter.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML, "");
        exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, new Boolean(true));
        exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(page - 1));
        exporter.exportReport();
        outReport.setContent(buf.toString());

        createPageNavigationControls(req, res, page, reportPrint.getPages().size(), backModel);
      }
    }
    catch (JRException x)
View Full Code Here

          String backModel) throws ModelException
  {
    int numPrevPages = 4;
    int numNextPages = 4;

    Output outPage = res.createOutput("page");

    outPage.setContent(new Integer(page));
    res.add(outPage);

    if (page > 1)
    {
      Command cmdPageStart = createPageCommand(req, res, "cmdPageStart", backModel);

      cmdPageStart.setParameter("page", "1");
      cmdPageStart.setLabel("$start");
      res.add(cmdPageStart);

      Command cmdPageBack = createPageCommand(req, res, "cmdPageBack", backModel);

      cmdPageBack.setParameter("page", String.valueOf(page - 1));
      cmdPageBack.setLabel("$back");
      res.add(cmdPageBack);

      Output outPrevPages = res.createOutput("prevPages");

      res.add(outPrevPages);

      int firstPrevPage = Math.max(1, page - numPrevPages);

      for (int i = page - 1; i >= firstPrevPage; --i)
      {
        Command cmdPage = createPageCommand(req, res, "cmdPage", backModel);

        cmdPage.setParameter("page", String.valueOf(page - i - 1 + firstPrevPage));
        cmdPage.setLabel(String.valueOf(page - i - 1 + firstPrevPage));
        outPrevPages.add(cmdPage);
      }
    }

    if (page < numPages)
    {
      Command cmdPageEnd = createPageCommand(req, res, "cmdPageEnd", backModel);

      cmdPageEnd.setParameter("page", String.valueOf(numPages));
      cmdPageEnd.setLabel("$end");
      res.add(cmdPageEnd);

      Command cmdPageNext = createPageCommand(req, res, "cmdPageNext", backModel);

      cmdPageNext.setParameter("page", String.valueOf(page + 1));
      cmdPageNext.setLabel("$next");
      res.add(cmdPageNext);

      Output outNextPages = res.createOutput("nextPages");

      res.add(outNextPages);

      int lastNextPage = Math.min(numPages, page + numNextPages);

      for (int i = page + 1; i <= lastNextPage; ++i)
      {
        Command cmdPage = createPageCommand(req, res, "cmdPage", backModel);

        cmdPage.setParameter("page", String.valueOf(i));
        cmdPage.setLabel(String.valueOf(i));
        outNextPages.add(cmdPage);
      }
    }
  }
View Full Code Here

        i.setValidValues(newMap);
      }
    }
    else if (re instanceof Output)
    {
      Output o = (Output) re;
      Object c = o.getContent();

      if (c instanceof String)
      {
        o.setContent(translateString((String) c, messages));
      }

      if (c instanceof Message)
      {
        o.setContent(translateMessage((Message) c, messages));
      }
    }
    else if (re instanceof Command)
    {
      Command c = (Command) re;
View Full Code Here

  {
    while (journalItem.hasNext())
    {
      journalItem.next();

      Output item = response.createOutput(journalItem.getJournalId());

      item.setAttribute("imageUrl", journalItem.getRawData());
      item.setAttribute("typeOfNews", journalItem.getSecondaryType());
      item.setAttribute("headerLine", journalItem.getShortMessage());
      item.setAttribute("message", journalItem.getMessage());
      item.setAttribute("date", journalItem.getOccurredAt());
      item.setAttribute("producer", journalItem.getMisc());
      item.setAttribute("renderInclude", journalItem.getRenderFile());
      currentGroupItems.add(item);
    }
  }
View Full Code Here

TOP

Related Classes of de.iritgo.aktera.model.Output

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.