Package de.iritgo.aktera.model

Examples of de.iritgo.aktera.model.ModelResponse


    try
    {
      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


    /**
     * We don't fail on a ModelException, we just stuff it into the
     * model response and carry on, so that the client gets the
     * exception
     */
    ModelResponse res = null;
    ModelResponseMessage resMessage = new ModelResponseMessage();

    try
    {
      res = req.execute();
View Full Code Here

    /**
     * We don't fail on a ModelException, we just stuff it into the
     * model response and carry on, so that the client gets the
     * exception
     */
    ModelResponse res = null;
    ModelResponseMessage resMessage = new ModelResponseMessage();

    try
    {
      res = req.execute();
View Full Code Here

   * @return The model response.
   * @throws ModelException
   */
  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);
View Full Code Here

   * @param req The model request.
   * @return The model response.
   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    ModelResponse res = req.createResponse();

    Properties props = new Properties();

    for (Object entry : req.getParameters().entrySet())
    {
View Full Code Here

  {
    SaveFormContext context = new SaveFormContext();

    context.setRequest(req);

    ModelResponse res = req.createResponse();

    try
    {
      readConfig(req);
    }
    catch (ConfigurationException x)
    {
      throw new ModelException(x);
    }

    Object id = req.getParameter(keyName);

    if (StringTools.isTrimEmpty(id))
    {
      id = new Integer(- 1);
    }

    String persistentsId = FormTools.createContextKey(contextId, id);

    FormularDescriptor formular = (FormularDescriptor) UserTools.getContextObject(req, persistentsId);

    if (formular == null)
    {
      res.setAttribute("forward", "aktera.formular.save-without-edit");

      return res;
    }

    try
    {
      boolean modified = false;

      handler.adjustFormular(req, formular, formular.getPersistents());

      if (req.getParameter(NO_FORM_STORE) == null && ! NumberTools.toBool(req.getParameter(SYSTEM_EDIT), false))
      {
        try
        {
          modified = FormTools.storeInput(req, res, formular, formular.getPersistents(), log);
        }
        catch (Exception x)
        {
          System.out.println("[Save] Error while storing input: " + x);
          x.printStackTrace();
        }
      }

      if (req.getParameter("AKTERA_page") != null)
      {
        int page = NumberTools.toInt(req.getParameter("AKTERA_page"), formular.getPage());

        if (page >= 0)
        {
          formular.setPage(page);
        }
      }

      if (NumberTools.toBool(req.getParameter("AKTERA_auto"), false))
      {
        CommandInfo cmdInfo = (CommandInfo) (cmdPage != null && cmdPage.getModel() != null ? cmdPage.clone()
                : cmdEdit.clone());
        Command cmd = cmdInfo.createCommand(req, res, context);

        for (Iterator i = req.getParameters().keySet().iterator(); i.hasNext();)
        {
          String key = (String) i.next();

          if (! "model".equals(key) && ! "SEQUENCE_NAME".equals(key) && ! "SEQUENCE_NUMBER".equals(key))
          {
            cmd.setParameter(key, req.getParameters().get(key));
          }
        }

        cmd.setParameter(keyName, id);
        cmd.setParameter("reedit", "Y");

        if (req.getParameter("ajax") != null)
        {
          cmd.setParameter("ajax", "Y");
        }

        return cmd.execute(req, res);
      }

      handler.preStorePersistents(req, formular, formular.getPersistents(), new Boolean(modified));

      if (req.getParameter(NO_FORM_STORE) == null && validate
              && ! NumberTools.toBool(req.getParameter(SYSTEM_EDIT), false))
      {
        ValidationResult result = null;

        try
        {
          result = FormTools.validateInput(req, res, formular, formular.getPersistents());
          handler.validatePersistents(persistentConfig, req, res, formular, formular.getPersistents(),
                  NumberTools.toInt(id, - 1) == - 1, result);
        }
        catch (Exception x)
        {
          System.out.println("[Save] Error while validating input: " + x);
          x.printStackTrace();
        }

        if (result.hasErrors())
        {
          formular.setPage(Math.max(formular.getPageWithField(result.getFirstErrorField(formular).replaceAll(
                  "_", ".")), 0));
        }

        result.createResponseElements(res, formular);

        if (result.hasErrors())
        {
          CommandInfo cmdInfo = (CommandInfo) cmdEdit.clone();
          Command cmd = cmdInfo.createCommand(req, res, context);

          cmd.setParameter(keyName, id);
          cmd.setParameter("error", result.getFirstErrorField(formular));

          if (! NumberTools.toBool(req.getParameter(SYSTEM_EDIT), false))
          {
            return cmd.execute(req, res);
          }
          else
          {
            return res;
          }
        }
      }

      if (NumberTools.toInt(id, - 1) != - 1)
      {
        handler.updatePersistents(req, formular, formular.getPersistents(), persistentConfig, modified);

        if (! preserveContext)
        {
          UserTools.removeContextObject(req, persistentsId);
        }
      }
      else
      {
        id = new Integer(handler.createPersistents(req, formular, formular.getPersistents(), persistentConfig));

        if (NumberTools.toInt(id, - 1) != - 1)
        {
          if (! preserveContext)
          {
            UserTools.removeContextObject(req, FormTools.createContextKey(contextId, - 1));
          }
          else
          {
            UserTools.setContextObject(req, FormTools.createContextKey(contextId, id), formular);
          }
        }
      }

      if (! NumberTools.toBool(req.getParameter(SYSTEM_EDIT), false))
      {
        context.setSaveId(id);

        CommandInfo cmdInfo = (CommandInfo) cmdOk.clone();
        Command cmd = cmdInfo.createCommand(req, res, context);

        ModelRequest newReq = (ModelRequest) req.getService(ModelRequest.ROLE);
        ModelResponse cmdRes = cmd.execute(newReq, res);

        if (res.get("IRITGO_formMessages") != null)
        {
          cmdRes.add(res.get("IRITGO_formMessages"));
        }

        return cmdRes;
      }
      else
View Full Code Here

  /**
   * @see de.iritgo.aktera.model.Model#execute(de.iritgo.aktera.model.ModelRequest)
   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    ModelResponse res = req.createResponse();

    File iritgoDir = locateIritgoDir();

    if (iritgoDir == null)
    {
      log.error("Unable to find Iritgo system directory");

      return res;
    }

    String url = SystemConfigTools.getWebStartUrl(req);

    if (StringTools.isEmpty(url))
    {
      url = SystemConfigTools.getWebAppUrl(req);
    }

    res.addOutput("codebase", url + "aktario/");
    res.addOutput("href", url + "model.do?model=aktera.aktario.start-jnlp-client");

    AppInfo.Info appInfo = AppInfo.getAppInfo(AppInfo.SYSTEM);

    res.addOutput("title", appInfo.getName() + " Client");
    res.addOutput("version", appInfo.getVersion());
    res.addOutput("versionLong", appInfo.getVersionLong());
    res.addOutput("vendor", appInfo.getVendor());
    res.addOutput("copyright", appInfo.getCopyright());
    res.addOutput("description", appInfo.getName() + " Client");
    res.addOutput("iconUrl", url + "aktera/images/std/app-icon-64.gif");
    res.addOutput("fileName", appInfo.getFileName() + ".jnlp");

    res.addOutput("userName", UserTools.getCurrentUserName(req));
    res.addOutput("server", req.getServerName());

    FilenameFilter iritgoJarFileFilter = new FilenameFilter()
    {
      public boolean accept(File dir, String name)
      {
        return name.startsWith("iritgo-aktario-framework") && name.endsWith(".jar");
      }
    };

    FilenameFilter jarFileFilter = new FilenameFilter()
    {
      public boolean accept(File dir, String name)
      {
        return name.endsWith(".jar");
      }
    };

    Output libraries = res.createOutput("libraries");

    res.add(libraries);

    Output librariesLinux = res.createOutput("librariesLinux");

    res.add(librariesLinux);

    Output librariesWin32 = res.createOutput("librariesWin32");

    res.add(librariesWin32);

    StringBuffer plugins = new StringBuffer();

    int i = 0;

    for (String fileName : new File(iritgoDir, "lib").list(jarFileFilter))
    {
      if (fileName.contains("-linux-"))
      {
        librariesLinux.add(res.createOutput("" + ++i, "lib/" + fileName));
      }
      else if (fileName.contains("-win32-"))
      {
        librariesWin32.add(res.createOutput("" + ++i, "lib/" + fileName));
      }
      else if (fileName.startsWith("iritgo-aktario-framework-"))
      {
        Output aktarioFrameworkJar = res.createOutput("aktarioFramework");

        aktarioFrameworkJar.setContent("lib/" + fileName);
        res.add(aktarioFrameworkJar);
      }
      else
      {
        libraries.add(res.createOutput("" + ++i, "lib/" + fileName));
      }
    }

    for (String fileName : new File(iritgoDir, "plugins").list(jarFileFilter))
    {
      libraries.add(res.createOutput("" + ++i, "plugins/" + fileName));

      String pluginName = fileName.substring(0, fileName.lastIndexOf('-'));

      StringTools.appendWithDelimiter(plugins, pluginName, ",");
    }

    res.addOutput("plugins", plugins.toString());

    return res;
  }
View Full Code Here

   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    I18N i18n = (I18N) req.getSpringBean(I18N.ID);

    ModelResponse res = req.createResponse();

    String file = req.getParameterAsString("file");
    String bulkImport = req.getParameterAsString("bulkImport");
    String destination = req.getParameterAsString("destination");
    String handler = req.getParameterAsString("handler");
    String backModel = req.getParameterAsString("backModel");
    String importModel = req.getParameterAsString("importModel");

    res.setAttribute("forward", "aktera.import.analyse-report");

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

    res.add(report);

    String lastLine = null;

    try
    {
      StringBuffer reportBuf = new StringBuffer();
      File reportFile = FileTools.newAkteraFile("/var/tmp/iritgo/import-report.txt");
      BufferedReader in = new BufferedReader(new FileReader(reportFile));
      String line = null;

      while ((line = in.readLine()) != null)
      {
        reportBuf.append(line + "\n");
        lastLine = line;
      }

      report.setContent(reportBuf.toString());
    }
    catch (IOException x)
    {
    }

    if (i18n.msg(req, "Aktera", "reportFileResult", "OK").equals(lastLine))
    {
      Command cmdImport = res.createCommand(importModel);

      cmdImport.setName("cmdImport");
      cmdImport.setParameter("file", file);
      cmdImport.setParameter("bulkImport", bulkImport);
      cmdImport.setParameter("destination", destination);
      cmdImport.setParameter("mode", "import");
      cmdImport.setParameter("backModel", backModel);
      cmdImport.setParameter("handler", handler);
      res.add(cmdImport);

      Command cmdBack = res.createCommand(backModel);

      cmdBack.setName("cmdBack");
      res.add(cmdBack);
    }
    else if (i18n.msg(req, "Aktera", "reportFileResult", "ERROR").equals(lastLine))
    {
      Command cmdBack = res.createCommand(backModel);

      cmdBack.setName("cmdBack");
      res.add(cmdBack);

      res.add(res.createOutput("error", "Y"));
    }
    else
    {
      Command cmdReport = res.createCommand("aktera.import.analyse.report");

      cmdReport.setName("cmdReport");
      cmdReport.setParameter("file", file);
      cmdReport.setParameter("bulkImport", bulkImport);
      cmdReport.setParameter("destination", destination);
      cmdReport.setParameter("handler", handler);
      cmdReport.setParameter("backModel", backModel);
      cmdReport.setParameter("importModel", importModel);
      res.add(cmdReport);
    }

    return res;
  }
View Full Code Here

   * @param req The model request.
   * @return The model response.
   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    ModelResponse res = req.createResponse();

    try
    {
      readConfig(req);

View Full Code Here

   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    I18N i18n = (I18N) req.getSpringBean(I18N.ID);

    ModelResponse res = req.createResponse();

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

    res.setAttribute("forward", "aktera.import.import-report");

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

    res.add(report);

    String lastLine = null;

    try
    {
      StringBuffer reportBuf = new StringBuffer();
      File reportFile = FileTools.newAkteraFile("/var/tmp/iritgo/import-report.txt");
      BufferedReader in = new BufferedReader(new FileReader(reportFile));
      String line = null;

      while ((line = in.readLine()) != null)
      {
        reportBuf.append(line + "\n");
        lastLine = line;
      }

      report.setContent(reportBuf.toString());
    }
    catch (IOException x)
    {
    }

    if (i18n.msg(req, "Aktera", "reportFileResult", "OK").equals(lastLine))
    {
      Command cmdBack = res.createCommand(backModel);

      cmdBack.setName("cmdBack");
      res.add(cmdBack);
    }
    else if (i18n.msg(req, "Aktera", "reportFileResult", "ERROR").equals(lastLine))
    {
      Command cmdBack = res.createCommand(backModel);

      cmdBack.setName("cmdBack");
      res.add(cmdBack);

      res.add(res.createOutput("error", "Y"));
    }
    else
    {
      Command cmdReport = res.createCommand("aktera.import.report");

      cmdReport.setName("cmdReport");
      cmdReport.setParameter("backModel", backModel);
      res.add(cmdReport);
    }

    return res;
  }
View Full Code Here

TOP

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

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.