Package de.iritgo.aktera.model

Examples of de.iritgo.aktera.model.Output


    System.out.println("\nModel Request:");

    System.out.println("  Source: " + req.getSource());

    Output source = res.createOutput("source", req.getSource());

    res.add(source);

    System.out.println("  Headers:");

    Output headerList = res.createOutput("headers");

    res.add(headerList);

    int num = 1;

    for (Iterator i = req.getHeaders().entrySet().iterator(); i.hasNext();)
    {
      Map.Entry entry = (Map.Entry) i.next();

      System.out.println("   " + (String) entry.getKey() + ": " + req.getHeader((String) entry.getKey()));

      Output header = res.createOutput("header" + num++, (String) entry.getKey());

      header.setAttribute("value", req.getHeader((String) entry.getKey()));
      headerList.add(header);
    }

    System.out.println("  Parameters:");

    Output parameterList = res.createOutput("parameters");

    res.add(parameterList);

    num = 1;

    for (Iterator i = req.getParameters().entrySet().iterator(); i.hasNext();)
    {
      Map.Entry entry = (Map.Entry) i.next();

      System.out.println("   " + (String) entry.getKey() + " = " + req.getParameter((String) entry.getKey()));

      Output parameter = res.createOutput("parameter" + num++, (String) entry.getKey());

      parameter.setAttribute("value", req.getParameter((String) entry.getKey()));
      parameterList.add(parameter);
    }

    System.out.println("  Attributes:");

    Output attributeList = res.createOutput("attributes");

    res.add(attributeList);

    num = 1;

    for (Iterator i = req.getAttributes().entrySet().iterator(); i.hasNext();)
    {
      Map.Entry entry = (Map.Entry) i.next();

      System.out.println("   " + (String) entry.getKey() + " = " + req.getAttribute((String) entry.getKey()));

      Output attribute = res.createOutput("attribute" + num++, (String) entry.getKey());

      attribute.setAttribute("value", req.getAttribute((String) entry.getKey()));
      attributeList.add(attribute);
    }

    return res;
  }
View Full Code Here


    {
      log.error("No URL base specified");
      throw new ModelException("No URL base specified");
    }

    Output player = response.createOutput("player");

    player.setAttribute("playerUrl", getConfiguration().getChild("playerUrl").getValue(null));
    player.setAttribute("urlBase", urlBase);
    player.setAttribute("server", request.getServerName());

    response.add(player);

    Output outList = response.createOutput("list");

    response.add(outList);

    List<File> files = new LinkedList(FileUtils.listFiles(FileTools.newAkteraFile(downloadDir), new IOFileFilter()
    {
      public boolean accept(File file)
      {
        return file.getName().endsWith(filetype);
      }

      public boolean accept(File arg0, String arg1)
      {
        return false;
      }
    }, null));

    Collections.sort(files, new Comparator<File>()
    {
      public int compare(File o1, File o2)
      {
        return o1.getName().compareToIgnoreCase(o2.getName());
      }
    });

    for (File file : files)
    {
      Output outFile = response.createOutput("file" + file.hashCode());

      try
      {
        outFile.setContent(file.getName());
        outFile.setAttribute("extension", FilenameUtils.getExtension(file.getName()));
        outFile.setAttribute("url", urlBase + "/" + file.getName());
        outFile.setAttribute("filename", file.getName());

        String videoNameFile = FilenameUtils.removeExtension(file.getName()) + ".name";
        String descriptionFile = FilenameUtils.removeExtension(file.getName()) + ".description";

        outFile.setAttribute("videoName", FileUtils
                .readFileToString(new File(downloadDir + "/" + videoNameFile)));
        outFile.setAttribute("description", FileUtils.readFileToString(new File(downloadDir + "/"
                + descriptionFile)));
      }
      catch (IOException x)
      {
      }
View Full Code Here

    ModelResponse res = req.createResponse();

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

      res.add(report);

      String reportFileName = getConfiguration().getChild("fileName").getValue(null);

      if (! StringTools.isTrimEmpty(reportFileName))
      {
        StringBuilder reportBuf = new StringBuilder();
        File reportFile = FileTools.newAkteraFile(reportFileName);
        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());
      }
      else
      {
        String beanName = getConfiguration().getChild("bean").getValue(null);
        String methodName = getConfiguration().getChild("method").getValue(null);

        if (! StringTools.isTrimEmpty(beanName) && ! StringTools.isTrimEmpty(methodName))
        {
          Object bean = req.getSpringBean(beanName);

          lastLine = (String) MethodUtils.invokeExactMethod(bean, methodName, null);
          report.setContent(lastLine);
        }
      }

      if (lastLine != null && lastLine.indexOf("Result: OK") != - 1)
      {
View Full Code Here

   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    ModelResponse res = req.createResponse();
    Locale locale = req.getLocale();
    Output outDate = res.createOutput("currentDate");
    SimpleDateFormat simpleDate = new SimpleDateFormat("EEE, dd. MMM yyyy - HH:mm", locale);

    outDate.setContent(simpleDate.format(new Date(System.currentTimeMillis())));
    res.add(outDate);

    return res;
  }
View Full Code Here

      ByteArrayOutputStream os = new ByteArrayOutputStream();

      ImageIO.write(image, "jpg", os);

      Output out = res.createOutput("data");

      out.setContent(os.toByteArray());
      res.add(out);
      os.close();

      res.addOutput("contentType", "image/png");
      res.addOutput("diagram", "diagram.png");
View Full Code Here

    ModelResponse res = req.createResponse();

    try
    {
      Configuration sysConfig = (Configuration) context.get("keel.config.system");
      Output sysOutput = res.createOutput("system");

      addChildren(res, sysOutput, sysConfig);
      res.add(sysOutput);

      Configuration logConfig = (Configuration) context.get("keel.config.log");
      Output logOutput = res.createOutput("log");

      addChildren(res, logOutput, logConfig);
      res.add(logOutput);

      Configuration roleConfig = (Configuration) context.get("keel.config.roles");
      Output roleOutput = res.createOutput("role");

      addChildren(res, roleOutput, roleConfig);
      res.add(roleOutput);

      Configuration instrConfig = (Configuration) context.get("keel.config.instr");
      Output instrOutput = res.createOutput("instrument");

      addChildren(res, instrOutput, instrConfig);
      res.add(instrOutput);
    }
    catch (ConfigurationException ce)
View Full Code Here

    for (int i = 0; i < children.length; i++)
    {
      oneChild = children[i];

      Output o = res.createOutput(oneChild.getName());

      parent.add(o);

      String[] attrs = oneChild.getAttributeNames();
      String oneAttrName = null;

      for (int j = 0; j < attrs.length; j++)
      {
        oneAttrName = attrs[j];
        o.setAttribute(oneAttrName, oneChild.getAttribute(oneAttrName));
        o.setContent(oneChild.getValue(null));
      }

      addChildren(res, o, oneChild);
    }
  }
View Full Code Here

      });
      cmdPageBack.setParameter(outListName + "Page", String.valueOf(currentPage - 1));
      cmdPageBack.setLabel("$back");
      outList.setAttribute("cmdPageBack", cmdPageBack);

      Output outPrevPages = response.createOutput("prevPages");
      outList.setAttribute("prevPages", outPrevPages);
      int firstPrevPage = Math.max(minPage, currentPage - context.getNumPrevPages());
      for (int i = currentPage - 1; i >= firstPrevPage; --i)
      {
        Command cmdPage = createPageCommand(request, response, listing, "cmdPage", new String[]
        {
          "~listSort"
        });
        cmdPage.setParameter(outListName + "Page", String.valueOf(currentPage - i - 1 + firstPrevPage));
        cmdPage.setLabel(String.valueOf(currentPage - i - 1 + firstPrevPage));
        outPrevPages.add(cmdPage);
      }
    }

    if (currentPage < maxPage)
    {
      Command cmdPageEnd = createPageCommand(request, response, listing, "cmdPageEnd", new String[]
      {
        "~listSort"
      });
      cmdPageEnd.setParameter(outListName + "Page", String.valueOf(maxPage));
      cmdPageEnd.setLabel("$end");
      outList.setAttribute("cmdPageEnd", cmdPageEnd);

      Command cmdPageNext = createPageCommand(request, response, listing, "cmdPageNext", new String[]
      {
        "~listSort"
      });
      cmdPageNext.setParameter(outListName + "Page", String.valueOf(currentPage + 1));
      cmdPageNext.setLabel("$next");
      outList.setAttribute("cmdPageNext", cmdPageNext);

      Output outNextPages = response.createOutput("nextPages");
      outList.setAttribute("nextPages", outNextPages);
      int lastNextPage = Math.min(maxPage, currentPage + context.getNumNextPages());
      for (int i = currentPage + 1; i <= lastNextPage; ++i)
      {
        Command cmdPage = createPageCommand(request, response, listing, "page", new String[]
        {
          "~listSort"
        });
        cmdPage.setParameter(outListName + "Page", String.valueOf(i));
        cmdPage.setLabel(String.valueOf(i));
        outNextPages.add(cmdPage);
      }
    }

    if (listing.getListCommands() != null)
    {
      Output outCommands = response.createOutput("commands");
      outList.setAttribute("commands", outCommands);
      for (Iterator i = listing.getListCommands().iterator(); i.hasNext();)
      {
        CommandInfo descriptor = (CommandInfo) i.next();
        Command command = descriptor.createCommand(request, response, context);
        outCommands.add(command);
      }
    }

    if (listing.getItemCommands() != null)
    {
      Output outItemCommands = response.createOutput("itemCommands");
      CommandInfo viewCmd = listing.getCommand(ListingDescriptor.COMMAND_VIEW);
      if (viewCmd != null && viewCmd.checkPermission(request))
      {
        Command cmd = viewCmd.createCommand(request, response, context);
        outItemCommands.add(cmd);
      }
      outItemCommands.setAttribute("label", listing.getItemCommands().getLabel());
      outList.setAttribute("itemCommands", outItemCommands);
      for (Iterator i = listing.getItemCommands().iterator(); i.hasNext();)
      {
        CommandInfo descriptor = (CommandInfo) i.next();
        if (viewCmd == null || ! descriptor.getName().equals(viewCmd.getName()))
        {
          Command command = descriptor.createCommand(request, response, context);
          outItemCommands.add(command);
        }
      }

      Command cmdExecute;
      if (listing.getCommand(ListingDescriptor.COMMAND_EXECUTE) == null)
View Full Code Here

   * @throws ModelException.
   */
  private static Output createHeaderElements(ModelRequest req, ModelResponse res, ListingDescriptor listing,
          ListContext context) throws ModelException
  {
    Output outList = res.createOutput(context.getListName());

    res.add(outList);

    if (listing.isSelectable())
    {
      outList.setAttribute("selectable", "Y");
    }
    outList.setAttribute("columnCount", new Integer(listing.getVisibleColumnCount()
            + (listing.getItemCommands() != null ? 1 : 0)));

    Output outHeader = res.createOutput("header");

    outList.setAttribute("header", outHeader);

    int colNum = 0;

    for (Iterator i = listing.columnIterator(); i.hasNext();)
    {
      ColumnDescriptor column = (ColumnDescriptor) i.next();

      Output outColumn = res.createOutput(String.valueOf(colNum++));

      outColumn.setContent(column.getAs());
      outColumn.setAttribute("label", column.getLabel());
      outColumn.setAttribute("bundle", column.getBundle() != null ? column.getBundle() : listing.getBundle());
      outColumn.setAttribute("width", new Integer(column.getWidth()));

      if (column.getSort() != SortOrder.NONE)
      {
        outColumn.setAttribute("sort", column.getSort() == SortOrder.ASCENDING ? "U" : "D");
      }

      if (! column.isVisible())
      {
        outColumn.setAttribute("hide", "Y");
      }

      if (column.isSortable() && ! "custom".equals(column.getViewer()) && ! column.getViewer().startsWith("js:"))
      {
        Command sortCommand = createPageCommand(req, res, listing, "sort" + colNum);

        sortCommand.setParameter(context.getListName() + "Sort", column.getName());
        outColumn.setAttribute("sortCommand", sortCommand);
      }

      outHeader.add(outColumn);
    }

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.