Package uk.ac.bbsrc.tgac.miso.core.service.printing

Examples of uk.ac.bbsrc.tgac.miso.core.service.printing.MisoPrintService


  }

  public JSONObject addPrintService(HttpSession session, JSONObject json) {
    try {
      BarcodableSchema barcodableSchema = printManager.getBarcodableSchema(json.getString("schema"));
      MisoPrintService printService = new DefaultPrintService();
      if ("Custom".equals(json.getString("serviceFor"))) {
        printService = new CustomPrintService();
      }
      printService.setName(json.getString("serviceName"));
      PrintContext pc = printManager.getPrintContext(json.getString("contextName"));
      JSONObject contextFields = JSONObject.fromObject(json.getString("contextFields"));
      PrintServiceUtils.mapJSONToContextFields(contextFields, pc);
      printService.setPrintContext(pc);
      printService.setBarcodableSchema(barcodableSchema);
      printService.setEnabled(true);
      if ("Custom".equals(json.getString("serviceFor"))) {
        printService.setPrintServiceFor(JSONObject.class);
      }
      else {
        printService.setPrintServiceFor(Class.forName(json.getString("serviceFor")).asSubclass(Barcodable.class));
      }
      printManager.storePrintService(printService);
      return JSONUtils.JSONObjectResponse("html", "OK");
    }
    catch (ClassNotFoundException e) {
View Full Code Here


  public JSONObject disablePrintService(HttpSession session, JSONObject json) {
    if (json.has("printerName") && json.getString("printerName") != null && !"".equals(json.getString("printerName"))) {
      String printerName = json.getString("printerName");
      try {
        MisoPrintService bps = printManager.getPrintService(printerName);
        if (bps != null) {
          bps.setEnabled(false);
          printManager.storePrintService(bps);
        }
        return JSONUtils.SimpleJSONResponse("Printer disabled");
      }
      catch (IOException e) {
View Full Code Here

  public JSONObject enablePrintService(HttpSession session, JSONObject json) {
    if (json.has("printerName") && json.getString("printerName") != null && !"".equals(json.getString("printerName"))) {
      String printerName = json.getString("printerName");
      try {
        MisoPrintService bps = printManager.getPrintService(printerName);
        if (bps != null) {
          bps.setEnabled(true);
          printManager.storePrintService(bps);
        }
        return JSONUtils.SimpleJSONResponse("Printer enabled");
      }
      catch (IOException e) {
View Full Code Here

  public JSONObject changePrinterServiceRow(HttpSession session, JSONObject json) {
    try {
      JSONObject response = new JSONObject();
      String serviceName = json.getString("serviceName");

      MisoPrintService bps = printManager.getPrintService(serviceName);

      response.put("hostname", "<input type='text' id='newhost-" + serviceName + "' value='" + bps.getPrintContext().getHost() + "'/>");
      response.put("edit", "<a href='javascript:void(0);' onclick='Print.ui.editPrinterService(\"" + serviceName + "\");'>Save</a>");
      return response;
    }
    catch (Exception e) {
      log.error("Unable to edit this printer service: ", e);
View Full Code Here

  }

  public JSONObject editPrinterService(HttpSession session, JSONObject json) {
    try {
      if (json.has("serviceName") && !json.get("serviceName").equals("")) {
        MisoPrintService bps = printManager.getPrintService(json.getString("serviceName"));
        if (bps != null) {
          PrintContext pc = bps.getPrintContext();
          JSONObject contextFields = new JSONObject();
          contextFields.put("host", json.getString("host"));
          PrintServiceUtils.mapJSONToContextFields(contextFields, pc);
          bps.setPrintContext(pc);
          printManager.storePrintService(bps);
          return JSONUtils.SimpleJSONResponse("done");
        }
        else {
          return JSONUtils.SimpleJSONError("No printer service of name: " + json.getString("serviceName"));
View Full Code Here

    return printService.getServiceId();
  }

  public MisoPrintService get(long serviceId) throws IOException {
    List eResults = template.query(PRINT_SERVICE_SELECT_BY_SERVICE_ID, new Object[]{serviceId}, new MisoPrintServiceMapper());
    MisoPrintService e = eResults.size() > 0 ? (MisoPrintService) eResults.get(0) : null;
    return e;
  }
View Full Code Here

    return e;
  }

  public MisoPrintService getByName(String serviceName) throws IOException {
    List eResults = template.query(PRINT_SERVICE_SELECT_BY_SERVICE_NAME, new Object[]{serviceName}, new MisoPrintServiceMapper());
    MisoPrintService e = eResults.size() > 0 ? (MisoPrintService) eResults.get(0) : null;
    return e;
  }
View Full Code Here

  }

  public class MisoPrintServiceMapper implements RowMapper<MisoPrintService> {
    public MisoPrintService mapRow(ResultSet rs, int rowNum) throws SQLException {
      try {
        MisoPrintService printService;

        PrintContext pc = printManager.getPrintContext(rs.getString("contextName"));
        BarcodableSchema barcodableSchema = printManager.getBarcodableSchema(rs.getString("printSchema"));
        if (barcodableSchema !=null){
        barcodableSchema.getBarcodeLabelFactory().setFilesManager(misoFilesManager);
        barcodableSchema.getBarcodeLabelFactory().setSecurityManager(securityManager);
        }

        if ("net.sf.json.JSONObject".equals(rs.getString("printServiceFor"))) {
          printService = new CustomPrintService();
          printService.setBarcodableSchema(barcodableSchema);

          printService.setServiceId(rs.getLong("serviceId"));
          printService.setName(rs.getString("serviceName"));
          printService.setEnabled(rs.getBoolean("enabled"));
          printService.setPrintServiceFor(JSONObject.class);

          JSONObject contextFields = JSONObject.fromObject(rs.getString("contextFields"));
          PrintServiceUtils.mapJSONToContextFields(contextFields, pc);
        }
        else {
          printService = new DefaultPrintService();
          printService.setBarcodableSchema(barcodableSchema);

          printService.setServiceId(rs.getLong("serviceId"));
          printService.setName(rs.getString("serviceName"));
          printService.setEnabled(rs.getBoolean("enabled"));
          printService.setPrintServiceFor(Class.forName(rs.getString("printServiceFor")).asSubclass(Barcodable.class));

          JSONObject contextFields = JSONObject.fromObject(rs.getString("contextFields"));
          PrintServiceUtils.mapJSONToContextFields(contextFields, pc);
        }

        printService.setPrintContext(pc);

        return printService;
      }
      catch (ClassNotFoundException e) {
        e.printStackTrace();
View Full Code Here

  }

  @RequestMapping(value = "/admin/configuration/printers/barcode/{printerId}", method = RequestMethod.GET)
  public ModelAndView viewBarcodePrinter(@PathVariable(value = "printerId") String printerId, ModelMap model) throws IOException {
    try {
      MisoPrintService ps = printManager.getPrintService(printerId);
      model.put("barcodePrinter", ps);

      Collection<? extends PrintJob> jobs = printManager.listPrintJobsByPrintService(ps);
      model.put("printJobs", jobs);
    }
View Full Code Here

  }

  @Override
  public PrintJob print(Queue<File> barcodesToPrint, String printServiceName, User user) throws MisoPrintException {
    try {
      MisoPrintService mps = getPrintService(printServiceName);
      if (mps != null) {
        MisoPrintJob job = new MisoPrintJob();
        job.setPrintDate(new Date());
        job.setPrintService(mps);
        job.setPrintUser(user);
        job.setQueuedElements(barcodesToPrint);
        job.setStatus("QUEUED");
        try {
          long jobId = storePrintJob(job);
          job.setJobId(jobId);
        }
        catch (IOException e) {
          e.printStackTrace();
          log.debug("Could not store print job");
        }

        try {
          boolean jobOK = true;
          for (File barcodeFile : barcodesToPrint) {
            if (!mps.print(barcodeFile)) {
              jobOK = false;
            }
          }

          if (jobOK) {
View Full Code Here

TOP

Related Classes of uk.ac.bbsrc.tgac.miso.core.service.printing.MisoPrintService

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.