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(); }
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(); }