示例#1
0
  @Override
  public synchronized JasperReport loadReportFile() {
    try {
      SwingWorker<JasperReport, Void> worker =
          new SwingWorker<JasperReport, Void>() {

            @Override
            protected JasperReport doInBackground() throws Exception {
              try {
                String filename = "Expedition.jrxml";
                jasperReport = JasperCompileManager.compileReport("printing/" + filename);
              } catch (Exception ex) {
                Exceptions.printStackTrace(ex);
              }
              return jasperReport;
            }
          };
      worker.execute();
      jasperReport = worker.get();
    } catch (InterruptedException ex) {
      Exceptions.printStackTrace(ex);
    } catch (ExecutionException ex) {
      Exceptions.printStackTrace(ex);
    }
    return jasperReport;
  }
示例#2
0
    /* clean up or start the worker threads */
    @Override
    protected void done() {
      try {
        super.get(); // block and get all exceptions thrown while doInBackground()
      } catch (CancellationException e) {
        // task was cancelled
        handleInterruption(e);
      } catch (InterruptedException ex) {
        handleInterruption(ex);
      } catch (ExecutionException ex) {
        handleInterruption(ex);

      } catch (Exception ex) {
        handleInterruption(ex);

      } finally {
        // queing end
        if (this.isCancelled()) {
          // empty queues
          handleInterruption(new Exception());
        } else {
          // start ingest workers
          startAll();
        }
        progress.finish();
      }
    }
示例#3
0
  public void start(boolean return_when_done) {
    // TODO Auto-generated method stub
    SwingWorker worker =
        new SwingWorker() {

          final NodeDistances this$0;

          protected Object doInBackground() throws Exception {
            return new NodeDistancesTask();
          }

          {
            this$0 = NodeDistances.this;
            // super();
          }
        };
    worker.execute();
    if (return_when_done)
      try {
        worker.get();
      } catch (InterruptedException e) {
        e.printStackTrace();
      } catch (ExecutionException e) {
        e.printStackTrace();
      }
  }
示例#4
0
 // TODO: deprecate
 public boolean processTask(
     ProgressKeeper pk, ProgressDialog d, SwingWorker<Boolean, Boolean> sw) {
   sw.execute();
   d.setVisible(true);
   try {
     return sw.get();
   } catch (ExecutionException e) {
     handleConverterException("Exception during conversion", null, e.getCause());
     return false;
   } catch (InterruptedException e) {
     handleConverterException("Conversion was cancelled or interrupted", null, e);
     return false;
   }
 }
示例#5
0
    @Override
    protected void done() {
      try {
        super.get(); // block and get all exceptions thrown while doInBackground()
        // notify modules of completion
        if (!this.isCancelled()) {
          for (IngestModuleAbstractFile s : abstractFileModules) {
            s.complete();
            IngestManager.fireModuleEvent(IngestModuleEvent.COMPLETED.toString(), s.getName());
          }
        }

        logger.log(Level.INFO, PlatformUtil.getAllMemUsageInfo());
        logger.log(Level.INFO, "Freeing jvm heap resources post file pipeline run");
        System.gc();
        logger.log(Level.INFO, PlatformUtil.getAllMemUsageInfo());

      } catch (CancellationException e) {
        // task was cancelled
        handleInterruption();

      } catch (InterruptedException ex) {
        handleInterruption();
      } catch (ExecutionException ex) {
        handleInterruption();
        logger.log(Level.SEVERE, "Fatal error during ingest.", ex);

      } catch (Exception ex) {
        handleInterruption();
        logger.log(Level.SEVERE, "Fatal error during ingest.", ex);
      } finally {
        stats.end();
        progress.finish();

        if (!this.isCancelled()) {
          logger.log(Level.INFO, "Summary Report: " + stats.toString());
          logger.log(Level.INFO, "File module timings: " + stats.getFileModuleStats());
          if (ui != null) {
            logger.log(Level.INFO, "Ingest messages count: " + ui.getMessagesCount());
          }

          IngestManager.this.postMessage(
              IngestMessage.createManagerMessage("File Ingest Complete", stats.toHtmlString()));
        }
      }
    }
示例#6
0
  @Override
  public synchronized Map constructParameter() {
    try {
      SwingWorker<Map, Void> worker =
          new SwingWorker<Map, Void>() {

            @Override
            protected Map doInBackground() throws Exception {
              Map param = new HashMap();
              if (expedition != null) {
                Employee commander = expedition.getLetter().getCommander();
                commander.setStyled(false);
                Employee assinedEmployee = expedition.getAssignedEmployee();
                assinedEmployee.setStyled(false);

                StringBuilder position = new StringBuilder();
                if (assinedEmployee.getStrukturalAsString().equals("")) {
                  position.append(assinedEmployee.getFungsionalAsString());
                  position.append(" ");
                  position.append(assinedEmployee.getPositionNotes());
                } else {
                  position.append(assinedEmployee.getStrukturalAsString());
                  if (position.toString().equalsIgnoreCase(Employee.SEKRETARIS_DAERAH)) {
                    position
                        .append(" ")
                        .append(properties.getStateType())
                        .append(" ")
                        .append(properties.getState());
                  } else if (position.toString().equalsIgnoreCase(Employee.KEPALA_DINAS)
                      || position.toString().equalsIgnoreCase(Employee.KEPALA_BADAN)) {
                    position.append(" ").append(properties.getCompany());
                  }
                }

                StringBuilder pos = new StringBuilder();
                if (commander.getStrukturalAsString().equals("")) {
                  pos.append(commander.getFungsionalAsString())
                      .append(" ")
                      .append(commander.getPositionNotes());
                } else {
                  pos.append(commander.getStrukturalAsString());
                }

                DateTime startDate = new DateTime(expedition.getStartDate());
                DateTime endDate = new DateTime(expedition.getEndDate());
                Days day = Days.daysBetween(startDate, endDate);

                ExpeditionFollowerJasper fjp =
                    new ExpeditionFollowerJasper(
                        expedition.getFollower(), expedition.getStartDate());

                File file = properties.getLogo();

                if (!file.exists()) {
                  file = new File("./images/logo_daerah.jpg");
                }

                ImageIcon ico = new ImageIcon(file.getPath());

                param.put("subreport", fjp.loadReportFile());
                param.put("datasource", fjp.getDataSource());

                StringBuilder stateName = new StringBuilder();

                if (properties.getStateType().equals(ArchieveProperties.KABUPATEN)) {
                  stateName
                      .append(ArchieveProperties.KABUPATEN.toUpperCase())
                      .append(" ")
                      .append(properties.getState().toUpperCase());
                }

                param.put("statename", stateName.toString());
                param.put("governname", properties.getCompany().toUpperCase());
                param.put("governaddress", properties.getAddress().toUpperCase());
                param.put("capital", properties.getCapital().toUpperCase());

                param.put("logo", ico.getImage());

                param.put("docnumber", expedition.getDocumentNumber());
                param.put("commander", initCaps(commander.getStrukturalAsString()));
                param.put("assignedemployee", assinedEmployee.getName());
                param.put("grades", assinedEmployee.getGradeAsString());
                param.put("position", initCaps(position.toString()));
                param.put("departure", expedition.getDeparture());
                param.put("destination", expedition.getDestination());
                param.put("transportation", expedition.getTransportationAsString());
                param.put("duration", String.valueOf(day.getDays()));
                param.put("startdate", expedition.getStartDate());
                param.put("enddate", expedition.getEndDate());
                param.put("purpose", expedition.getLetter().getPurpose());
                param.put("notes", expedition.getNotes());
                param.put("approvalplace", expedition.getApprovalPlace());
                param.put("approvaldate", expedition.getApprovalDate());
                param.put("approvername", commander.getName());
                param.put("approverGrade", commander.getPangkatAsString());
                param.put("approverNIP", commander.getNip());
                param.put("approverTitle", pos.toString());

                param.put("charge", expedition.getCharge());
                StringBuilder builder = new StringBuilder();

                if (expedition.getProgram() != null) {
                  builder.append(expedition.getProgram().getProgramCode());
                }

                if (expedition.getActivity() != null) {
                  builder.append(".").append(expedition.getActivity().getChildCode());
                }

                if (expedition.getAccount() != null) {
                  builder.append(".").append(expedition.getAccount().getAccountCode());
                }

                param.put("chargebudget", builder.toString());
              }
              return param;
            }
          };
      worker.execute();
      params = worker.get();

    } catch (InterruptedException ex) {
      Exceptions.printStackTrace(ex);
    } catch (ExecutionException ex) {
      Exceptions.printStackTrace(ex);
    }
    return params;
  }