private ElementClassifier loadClassifierModel(Extractor extractor) {
   Connection con = null;
   PreparedStatement pstmt = null;
   ResultSet rs = null;
   try {
     con = Application.getDataSource().getConnection();
     pstmt = con.prepareStatement("SELECT cmodel FROM extractors WHERE id = ?");
     pstmt.setInt(1, extractor.getId());
     rs = pstmt.executeQuery();
     if (rs.next()) {
       byte[] buf = rs.getBytes(1);
       if (buf != null) {
         ElementClassifier c =
             ElementClassifier.readElementClassifier(new ByteArrayInputStream(buf));
         System.out.println(c);
         return c;
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     try {
       rs.close();
       pstmt.close();
       con.close();
     } catch (Exception e) {
     }
   }
   return null;
 }
Exemple #2
0
  private void jTableUsersMouseClicked(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_jTableUsersMouseClicked
    if (evt.getClickCount() >= 2) {
      // Double clicked!

      int response =
          JOptionPane.showConfirmDialog(
              null,
              "Weet je zeker dat je deze deelnemer wilt uitschrijven?",
              "Deelnemer uitschrijven",
              JOptionPane.YES_NO_OPTION);

      if (response == 0) {
        // Get the currently selected subscription
        int rowNumber = jTableUsers.getSelectedRow();
        int user_id = (Integer) model.getValueAt(rowNumber, 0);

        Enrollment enrollment = new Enrollment();
        enrollment.unsubscribe(this.subscription.getId(), user_id);

        this.model.removeRow(rowNumber);

        Application.getInstance()
            .showPopup(new SuccessPopup("De deelnemer is succesvol uitgeschreven."));
      }
    }
  } // GEN-LAST:event_jTableUsersMouseClicked
  private void showInvoice() {
    // Get the currently selected subscription
    int rowNumber = jTable1.convertRowIndexToModel(jTable1.getSelectedRow());
    String invoiceId = (String) model.getValueAt(rowNumber, 0);
    Invoice invoice = new Invoice();
    invoice.readInvoice(Integer.parseInt(invoiceId));

    // Show popup
    Application.getInstance().showPopup(new InvoicePopup(invoice));
  }
Exemple #4
0
  private void jBtnSubmitActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jBtnSubmitActionPerformed
    Enrollment enrollment = new Enrollment();

    enrollment.readEnrollmentBySubscriptionIdAndUserId(this.subscription.getId(), this.userId);

    if (enrollment.isEnrolled() == false) {
      enrollment.subscribe(this.subscription.getId(), this.userId);

      User user = new User();
      user.readUser(this.userId);

      this.model.insertRow(0, new Object[] {user.getId(), user.getFullName()});

      Application.getInstance()
          .showPopup(new SuccessPopup("Deelnemer " + user.getFullName() + " is ingeschreven."));
    } else {
      Application.getInstance().showPopup(new ErrorPopup("De deelnemer is al ingeschreven."));
    }
  } // GEN-LAST:event_jBtnSubmitActionPerformed
  /**
   * Instantiates a new <code>MapPreviewPanel</code>. This constructor is used when we open <code>
   * AddMapDialog</code> in <code>AddMapDialogMode.EDIT</code> mode.
   *
   * @param map <code>RoomMap</code> object
   * @param parent <code>AddMapDialog</code> parent object
   * @see AddMapDialog
   * @see gui.enumeration.AddMapDialogMode
   */
  public MapPreviewPanel(RoomMap map, AddMapDialog parent) {

    receiverViews = new ArrayList<ReceiverView>();
    scalingRatioToFitContainer = 1.0;
    this.map = map;
    // TODO: added code
    Application.getApplication().setRoomMap(this.map);
    this.originalBackgroundImage = Utilities.deepCopy((BufferedImage) map.getImage());
    this.backgroundImage = Utilities.deepCopy((BufferedImage) map.getImage());
    this.parent = parent;
    initializeGui();
  }
Exemple #6
0
  private void jBtnEdit1ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jBtnEdit1ActionPerformed
    int response =
        JOptionPane.showConfirmDialog(
            null,
            "Weet je zeker dat je de cursus wilt verwijderen?",
            "Cursus verwijderen",
            JOptionPane.YES_NO_OPTION);

    if (response == 0) {
      // Get the currently selected subscription
      this.subscription.delete();

      Application.getInstance().showPanel(new view.medewerker.CoursesOverview());
    }
  } // GEN-LAST:event_jBtnEdit1ActionPerformed
  public static void main(String[] args) {
    Application.loadSettings();
    Extractor extractor = DataAccess.retrieveExtractor(31);

    FallbackScrape fbs = new FallbackScrape(extractor);
    try {
      extractor.setUrls(
          fbs.queryRunner.query(
              "SELECT url FROM pages WHERE extractor_id = ?",
              ScrapeHelper.arrayRSHandler,
              extractor.getId()));
      List<Annotation> annotations =
          fbs.queryRunner.query(
              "SELECT id,xpath FROM annotations WHERE extractor_id = ?",
              ScrapeHelper.annotationListHandler,
              extractor.getId());
      extractor.setAnnotations(annotations.toArray(new Annotation[annotations.size()]));

    } catch (SQLException e) {
      e.printStackTrace();
    }
    fbs.run();
  }
  private void jButtonCreateInvoicesActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonCreateInvoicesActionPerformed

    // Create all invoices
    int count = InvoiceCreator.createAllInvoices();

    // Reload the table
    updateTable();

    // Show a popup
    String message;
    switch (count) {
      case 0:
        message = "Er hoeven geen facturen te worden aangemaakt";
        break;
      case 1:
        message = "Er is 1 factuur aangemaakt";
        break;
      default:
        message = String.format("Er zijn %d facturen aangemaakt.", count);
        break;
    }
    Application.getInstance().showPopup(new SuccessPopup(message));
  } // GEN-LAST:event_jButtonCreateInvoicesActionPerformed
 public FallbackScrape(Extractor extractor) {
   this.extractor = extractor;
   this.classifier = loadClassifierModel(extractor);
   this.queryRunner = Application.getQueryRunner();
 }
Exemple #10
0
  /**
   * Getter for <code>RoomMap</code> object with all its properties, including <code>Receiver</code>
   * s and <code>CoordinateZeroMarkerView</code>s .
   *
   * @return the map
   * @see Receiver
   * @see ReceiverView
   * @see CoordinateZeroMarkerView
   */
  public RoomMap getMap() {

    // set zero coordinate marker positions
    int lowerLeftMarkerOffsetXInPixels =
        (int) (lowerLeftMarker.getLocation().getX() / scalingRatioToFitContainer);
    int lowerLeftMarkerOffsetYInPixels =
        (int) (lowerLeftMarker.getLocation().getY() / scalingRatioToFitContainer)
            + (CoordinateZeroMarkerView.ZERO_COORDINATE_MARKER_VIEW_HEIGHT);
    map.setLowerLeftMarkerOffsetXInPixels(lowerLeftMarkerOffsetXInPixels);
    map.setLowerLeftMarkerOffsetYInPixels(lowerLeftMarkerOffsetYInPixels);

    int upperRightMarkerOffsetXInPixels =
        (int) (upperRightMarker.getLocation().getX() / scalingRatioToFitContainer)
            + (CoordinateZeroMarkerView.ZERO_COORDINATE_MARKER_VIEW_WIDTH);
    int upperRightMarkerOffsetYInPixels =
        (int) (upperRightMarker.getLocation().getY() / scalingRatioToFitContainer);
    map.setUpperRightMarkerOffsetXInPixels(upperRightMarkerOffsetXInPixels);
    map.setUpperRightMarkerOffsetYInPixels(upperRightMarkerOffsetYInPixels);

    // set room width and height in meters
    double roomWidthInMeters = parent.getRoomWidthInMeters();
    double roomHeightInMeters = parent.getRoomHeightInMeters();
    map.setWidthInMeters(roomWidthInMeters);
    map.setHeightInMeters(roomHeightInMeters);

    // set width and height ratios
    int mapWidthInPixels = upperRightMarkerOffsetXInPixels - lowerLeftMarkerOffsetXInPixels;
    int mapHeightInPixels = lowerLeftMarkerOffsetYInPixels - upperRightMarkerOffsetYInPixels;

    double mapWidthRatio = (mapWidthInPixels) / roomWidthInMeters;
    double mapHeightRatio = (mapHeightInPixels) / roomHeightInMeters;

    map.setRatioWidth(mapWidthRatio);
    map.setRatioHeight(mapHeightRatio);

    // set receiver positions in meters
    map.getReceivers().clear(); // first we remove all present receivers
    for (ReceiverView receiverView : receiverViews) {

      int receiverViewXInPixels =
          ((int) (receiverView.getLocation().getX() / scalingRatioToFitContainer))
              + (ReceiverView.RECEIVER_ITEM_WIDTH / 2);
      int receiverViewYInPixels =
          ((int) (receiverView.getLocation().getY() / scalingRatioToFitContainer))
              + (ReceiverView.RECEIVER_ITEM_HEIGHT / 2);

      double receiverPositionInMetersX =
          calculateReceiverPositionInMetersX(
              lowerLeftMarkerOffsetXInPixels, receiverViewXInPixels, mapWidthRatio);
      double receiverPositionInMetersY =
          calculateReceiverPositionInMetersY(
              lowerLeftMarkerOffsetYInPixels, receiverViewYInPixels, mapHeightRatio);

      receiverView.getReceiver().setxPos(receiverPositionInMetersX);
      receiverView.getReceiver().setyPos(receiverPositionInMetersY);

      map.addReceiver(receiverView.getReceiver());
    }

    // set map title
    String titleFromInput = parent.getRoomTitle();
    map.setTitle(titleFromInput.equals("") ? "Unkown" : titleFromInput);

    // set map xFrom, xTo, yFrom and yTo values
    map.setxFrom(0);
    map.setxTo(map.getWidthInMeters());
    map.setyFrom(0);
    map.setyTo(map.getHeightInMeters());

    Application.getApplication().setRoomMap(map);

    return map;
  }
Exemple #11
0
 private void jLabelLogoutMouseClicked(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_jLabelLogoutMouseClicked
   Session.get().logOut();
   Application.getInstance().showPanel(new view.Login());
 } // GEN-LAST:event_jLabelLogoutMouseClicked
Exemple #12
0
 private void jBtnEditActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jBtnEditActionPerformed
   Application.getInstance().showPanel(new view.admin.CourseEdit(this.subscription.getId()));
 } // GEN-LAST:event_jBtnEditActionPerformed