示例#1
0
  private void tabbedPaneStateChanged(
      javax.swing.event.ChangeEvent evt) { // GEN-FIRST:event_tabbedPaneStateChanged
    // Add your handling code here:
    try {
      AbstractPage newPage = (AbstractPage) tabbedPane.getSelectedComponent();

      Log.print(
          "AdminFrame.stateChanged: currentPage: "
              + (currentPage == null ? "null" : currentPage.getClass().getName()));

      // ignore if we aren't changing tabs
      // presumably, we failed to change tabs and are now resetting
      // also ignore first time -- we do at window opening
      if (currentPage == newPage || currentPage == null) {
        return;
      }

      // Log.print("AdminFrame.stateChanged: newPage: " + newPage.getClass().getName());

      // tab doesn't get focus before switch, so we need to check here that
      // this tab switch is acceptable
      // Also, initial tab setting could happen before window is visible,
      // so we do the initial call in the WindowOpening event

      if (currentPage.exitPageCheck()) {
        // open the page
        openNewPage(newPage);
      } else {
        // page did not permit exit (e.g., failed save check)
        tabbedPane.setSelectedComponent(currentPage);
      }
    } catch (Throwable t) {
      Log.quit(t);
    }
  } // GEN-LAST:event_tabbedPaneStateChanged
示例#2
0
 /**
  * Create a <code>ManagedTable</code> instance and add it to the static ArrayList of instances.
  *
  * @param name the table name of this instance
  */
 private ManagedTable(String name) {
   this.tableName = name;
   tableList.add(this);
   tableNumber = tableList.size() - 1;
   Log.print(this.toString());
   if (tableNumber > 127) {
     Log.quit("Too many managed tables");
   }
 }
示例#3
0
  private static int chooseQAChildrenForCoder(ServerTask task, int percent, int usersId)
      throws SQLException, IOException {

    Statement st = task.getStatement();

    ResultSet rs =
        st.executeQuery(
            "select count(*)"
                + " from child C"
                + "   inner join batch B using (batch_id)"
                + "   left join batchuser BU using (batch_id)"
                + "   left join childcoded CC"
                + "     on C.child_id=CC.child_id and CC.round=0"
                + " where B.volume_id="
                + task.getLockVolumeId()
                + "   and B.status='QA'"
                + "   and BU.coder_id="
                + usersId
                + "   and CC.child_id is null");
    rs.next();
    int availableCount = rs.getInt(1);
    rs.close();

    int selectCount = (availableCount * percent + 99) / 100;
    int count =
        st.executeUpdate(
            "insert into childcoded (child_id, status)"
                + " select C.child_id, 'QA'"
                + " from child C"
                + "   inner join batch B using (batch_id)"
                + "   left join batchuser BU using (batch_id)"
                + "   left join childcoded CC"
                + "     on C.child_id=CC.child_id and CC.round=0"
                + " where B.volume_id="
                + task.getLockVolumeId()
                + "   and B.status='QA'"
                + "   and CC.child_id is null"
                + "   and BU.coder_id="
                + usersId
                + " order by rand()"
                + " limit "
                + selectCount);

    Log.print(
        "chooseQAChildrenForCoder: volume="
            + task.getLockVolumeId()
            + " count="
            + count
            + " usersId="
            + usersId);

    return count;
  }
示例#4
0
  /** Write the message with attributes and set the result. */
  @Override
  public void run() throws IOException {
    MessageWriter writer = scon.startMessage(T_BINDER_UPDATE);
    writer.writeAttribute(A_PAGE_ID, pageId);
    if (isToRemovePage) {
      writer.writeAttribute(A_REMOVE, "YES");
    }
    addStandardAttributes(writer);
    writer.endElement();
    writer.close();
    Log.print("(TaskBinderUpdate.run) page=" + pageId + " isToRemovePage=" + isToRemovePage);

    Element reply = scon.receiveMessage();

    String ok = reply.getNodeName();

    if (!T_OK.equals(ok) && !T_FAIL.equals(ok)) {
      Log.quit("BatchBoundary unexpected message type: " + ok);
    }
  }
示例#5
0
 /** Exit the Application. Note: This may be called from the various tab pages. */
 public void exitForm(java.awt.event.WindowEvent evt) { // GEN-FIRST:event_exitForm
   try {
     // close the server and image server connections gently
     // TBD: really should be in a client task
     Log.print("AdminFrame.exitForm");
     try {
       client.Global.theServerConnection.shutdown();
       closeSession(evt);
     } catch (Exception e) {
     }
     try {
       synchronized (ImageThread.class) {
         if (Global.theImageConnection != null) {
           Global.theImageConnection.shutdown();
         }
       }
     } catch (Exception e) {
     }
     System.exit(0);
   } catch (Throwable th) {
     Log.quit(th);
   }
   System.exit(0);
 } // GEN-LAST:event_exitForm
示例#6
0
  public void run(ServerTask task, Element action) throws SQLException, IOException {

    int volumeId = task.getLockVolumeId();
    assert volumeId != 0;
    assert task.getLockBatchId() == 0;

    int percent = Integer.parseInt(action.getAttribute(A_PERCENT));
    String usersIdString = action.getAttribute(A_USERS_ID);
    String teamsIdString = action.getAttribute(A_TEAMS_ID);
    boolean newSample = "YES".equals(action.getAttribute(A_NEW_SAMPLE));
    Log.print(
        "in Handler_sample_qa.run vol="
            + volumeId
            + " pct="
            + percent
            + " user: "******" team: "
            + teamsIdString
            + " new_sample: "
            + newSample);

    Statement st = null;
    int count;
    if (newSample) {
      // save batches around choose code
      st = task.getStatement();
      st.executeUpdate(
          "update batch"
              + " set status =''"
              + " where volume_id="
              + volumeId
              + "   and status = 'QA'");
    }
    if (usersIdString.length() > 0) {
      assert teamsIdString.length() == 0;
      if (newSample) {
        // move QCComplete batches to QA (managed)
        task.executeUpdate(
            "update batch B"
                + "   inner join batchuser BU using (batch_id)"
                + " set B.status ='QA'"
                + " where B.volume_id="
                + volumeId
                + "   and B.status = 'QCComplete'"
                + "   and BU.coder_id="
                + usersIdString);
      }
      count = chooseQAChildrenForCoder(task, percent, Integer.parseInt(usersIdString));
    } else if (teamsIdString.length() > 0) {
      if (newSample) {
        // move QCComplete batches to QA (managed)
        task.executeUpdate(
            "update batch B"
                + "   inner join batchuser BU using (batch_id)"
                + "   inner join users U on BU.coder_id=U.users_id"
                + " set B.status ='QA'"
                + " where B.volume_id="
                + volumeId
                + "   and B.status = 'QCComplete'"
                + "   and U.teams_id="
                + teamsIdString);
      }
      count = chooseQAChildrenForTeam(task, percent, Integer.parseInt(teamsIdString));
    } else {
      if (newSample) {
        // move QCComplete batches to QA (managed)
        task.executeUpdate(
            "update batch"
                + " set status ='QA'"
                + " where volume_id="
                + volumeId
                + "   and status = 'QCComplete'");
      }
      count = chooseQAChildren(task, percent);
    }
    if (newSample) {
      // restore old QA batches
      st.executeUpdate(
          "update batch"
              + " set status ='QA'"
              + " where volume_id="
              + volumeId
              + "   and status = ''");
    }

    // send back info
    MessageWriter writer = task.getMessageWriter();
    writer.startElement(T_UPDATE_COUNT);
    writer.writeAttribute(A_COUNT, count);
    writer.endElement();
  }
示例#7
0
  private static int chooseQAChildrenForTeam(ServerTask task, int percent, int teamsId)
      throws SQLException, IOException {

    Statement st = task.getStatement();

    ResultSet rs =
        st.executeQuery(
            "select count(*)"
                + " from child C"
                + "   inner join batch B using (batch_id)"
                + "   left join batchuser BU using (batch_id)"
                + "   left join users U on U.users_id = BU.coder_id"
                + "   left join childcoded CC"
                + "     on C.child_id=CC.child_id and CC.round=0"
                + " where B.volume_id="
                + task.getLockVolumeId()
                + "   and B.status='QA'"
                + "   and U.teams_id="
                + teamsId
                + "   and CC.child_id is null"
                + " group by U.teams_id");
    int availableCount = (rs.next() ? rs.getInt(1) : 0);
    rs.close();

    int count = 0;
    if (availableCount > 0) {
      int selectCount = (availableCount * percent + 99) / 100;
      // Note: this SQL is the same as in chooseQAChildren
      count =
          st.executeUpdate(
              "insert into childcoded (child_id, status)"
                  + " select C.child_id, 'QA'"
                  + " from child C"
                  + "   inner join batch B using (batch_id)"
                  + "   left join batchuser BU using (batch_id)"
                  + "   left join users U on U.users_id = BU.coder_id"
                  + "   left join childcoded CC"
                  + "     on C.child_id=CC.child_id and CC.round=0"
                  + " where B.volume_id="
                  + task.getLockVolumeId()
                  + "   and B.status='QA'"
                  + "   and CC.child_id is null"
                  + "   and (teams_id="
                  + teamsId
                  + " or teams_id is null and "
                  + teamsId
                  + "=0)"
                  + " order by rand()"
                  + " limit "
                  + selectCount);
    }

    Log.print(
        "chooseQAChildrenForTeam: volume="
            + task.getLockVolumeId()
            + " count="
            + count
            + " teamsId="
            + teamsId);

    return count;
  }
示例#8
0
  /**
   * Choose given percentage of children in QA status from all teams from the volume open for QA by
   * the current user. Selecton is done on a team-by-team basis, so each team has at least the given
   * percentage. A batch is assumed to belong to the team indicated by the last coder to open it.
   * Selection is also made for a "null" team, for users who have no team assigned.
   *
   * @param task current ServerTask to handle the connection from the client to the coding server
   * @param percent the percentage of children to sample
   * @return the number of children chosen
   */
  public static int chooseQAChildren(ServerTask task, int percent)
      throws SQLException, IOException {

    Statement st = task.getStatement();

    ResultSet rs =
        st.executeQuery(
            "select teams_id, count(*)"
                + " from child C"
                + "   inner join batch B using (batch_id)"
                + "   left join batchuser BU using (batch_id)"
                + "   left join users U on U.users_id = BU.coder_id"
                + "   left join childcoded CC"
                + "     on C.child_id=CC.child_id and CC.round=0" //  and CC.users_id=0"
                + " where B.volume_id="
                + task.getLockVolumeId()
                + "   and B.status='QA'"
                + "   and CC.child_id is null"
                + " group by U.teams_id");
    ArrayList teams = new ArrayList();
    ArrayList counts = new ArrayList();
    while (rs.next()) {
      teams.add(new Integer(rs.getInt(1)));
      counts.add(new Integer(rs.getInt(2)));
    }
    rs.close();

    int count = 0;
    for (int i = 0; i < teams.size(); i++) {
      int availableCount = ((Integer) counts.get(i)).intValue();
      int teamsId = ((Integer) teams.get(i)).intValue();
      int selectCount = (availableCount * percent + 99) / 100;

      count +=
          st.executeUpdate(
              "insert into childcoded (child_id, status)"
                  + " select C.child_id, 'QA'"
                  + " from child C"
                  + "   inner join batch B using (batch_id)"
                  + "   left join batchuser BU using (batch_id)"
                  + "   left join users U on U.users_id = BU.coder_id"
                  + "   left join childcoded CC"
                  + "     on C.child_id=CC.child_id and CC.round=0" //  and CC.users_id=0"
                  + " where B.volume_id="
                  + task.getLockVolumeId()
                  + "   and B.status='QA'"
                  + "   and CC.child_id is null"
                  + "   and (teams_id="
                  + teamsId
                  + "        or teams_id is null and "
                  + teamsId
                  + "=0)"
                  + " order by rand()"
                  + " limit "
                  + selectCount);
      System.out.println("... team=" + teamsId + " selectCount=" + selectCount + " count=" + count);
    }

    Log.print("chooseQAChildren: volume=" + task.getLockVolumeId() + " count=" + count);

    return count;
  }
示例#9
0
 private void saveDelimiterData(ServerTask task, DelimiterData data) throws java.io.IOException {
   try {
     Log.print("(Handler_delimiter_data.save) '" + data.value_separator + "'");
     Connection con = task.getConnection();
     Statement st = task.getStatement();
     PreparedStatement pst = null;
     if (data.force.equals("")) {
       // delete
       pst = con.prepareStatement("delete from export" + " where export_name = ?");
       pst.setString(1, data.delimiter_set_name);
       pst.executeUpdate();
     } else {
       // see if the export_name exists
       pst = con.prepareStatement("select export_name" + " from export" + " where export_name=?");
       pst.setString(1, data.delimiter_set_name);
       ResultSet rs = pst.executeQuery();
       if (rs.next()) {
         // Log.print("(Handler_export_data.saveExportData) update " + data.delimiter_set_name);
         // update
         rs.close();
         pst =
             con.prepareStatement(
                 "update export set"
                     + " force_export = ?,"
                     + " uppercase = ?,"
                     + " uppercase_names = ?,"
                     + " field_delimiter = ?,"
                     + " text_qualifier = ?,"
                     + " value_separator = ?,"
                     + " date_format = ?,"
                     + " missing_date = ?,"
                     + " missing_year = ?,"
                     + " missing_month = ?,"
                     + " missing_day = ?,"
                     + " missing_date_character = ?,"
                     + " name_mask1 = ?,"
                     + " name_mask2 = ?,"
                     + " name_mask3 = ?,"
                     + " name_mask4 = ?,"
                     + " brs_format = ?"
                     + " where export_name = ?");
         pst.setString(1, data.force);
         pst.setString(2, data.uppercase);
         pst.setString(3, data.uppercase_names);
         pst.setString(4, data.field_delimiter);
         pst.setString(5, data.text_qualifier);
         pst.setString(6, data.value_separator);
         pst.setString(7, data.date_format);
         pst.setString(8, data.missing_date);
         pst.setString(9, data.missing_year);
         pst.setString(10, data.missing_month);
         pst.setString(11, data.missing_day);
         pst.setString(12, data.missing_date_character);
         pst.setString(13, data.name_mask1);
         pst.setString(14, data.name_mask2);
         pst.setString(15, data.name_mask3);
         pst.setString(16, data.name_mask4);
         pst.setString(17, data.brs_format);
         pst.setString(18, data.delimiter_set_name);
         pst.executeUpdate();
         pst.close();
       } else {
         // insert
         // Log.print("(Handler_export_data.saveExportData) insert " + data.delimiter_set_name);
         rs.close();
         pst =
             con.prepareStatement(
                 "insert into export set"
                     + " force_export = ?,"
                     + " uppercase = ?,"
                     + " uppercase_names = ?,"
                     + " field_delimiter = ?,"
                     + " text_qualifier = ?,"
                     + " value_separator = ?,"
                     + " date_format = ?,"
                     + " missing_date = ?,"
                     + " missing_year = ?,"
                     + " missing_month = ?,"
                     + " missing_day = ?,"
                     + " missing_date_character = ?,"
                     + " export_name = ?,"
                     + " name_mask1 = ?,"
                     + " name_mask2 = ?,"
                     + " name_mask3 = ?,"
                     + " name_mask4 = ?,"
                     + " brs_format = ?");
         pst.setString(1, data.force);
         pst.setString(2, data.uppercase);
         pst.setString(3, data.uppercase_names);
         pst.setString(4, data.field_delimiter);
         pst.setString(5, data.text_qualifier);
         pst.setString(6, data.value_separator);
         pst.setString(7, data.date_format);
         pst.setString(8, data.missing_date);
         pst.setString(9, data.missing_year);
         pst.setString(10, data.missing_month);
         pst.setString(11, data.missing_day);
         pst.setString(12, data.missing_date_character);
         pst.setString(13, data.delimiter_set_name);
         pst.setString(14, data.name_mask1);
         pst.setString(15, data.name_mask2);
         pst.setString(16, data.name_mask3);
         pst.setString(17, data.name_mask4);
         pst.setString(18, data.brs_format);
         pst.executeUpdate();
         pst.close();
       }
     }
     pst.close();
   } catch (Throwable t) {
     Log.quit(t);
   }
   MessageWriter writer = task.getMessageWriter();
   writer.startElement(T_OK);
   writer.endElement();
 }
示例#10
0
 /**
  * Add a dependency, where this table has a field pointing to a target table. A change to this
  * table causes a change to the target table. Must be explicitly called from Tables.
  */
 public void addDependency(ManagedTable targetTable, String columnName) {
   String targetName = targetTable.tableName;
   targetTables.add(targetTable);
   targetIdColumn.add(columnName);
   Log.print(tableName + " added dependency: " + targetName);
 }