Skip to content

Commit

Permalink
remove rueckgabedatum from table model
Browse files Browse the repository at this point in the history
fix wrong data shown in upper panel
  • Loading branch information
donald committed Oct 18, 2014
1 parent 3931683 commit 7ef98b9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 63 deletions.
8 changes: 4 additions & 4 deletions src/de/mpg/molgen/buczek/portifix/Gui.form
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jSplitPane1" alignment="1" pref="461" max="32767" attributes="0"/>
<Component id="jSplitPane1" alignment="1" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
Expand Down Expand Up @@ -105,10 +105,10 @@
</Group>
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="label_name" max="32767" attributes="0"/>
<Component id="label_abteilung" alignment="0" max="32767" attributes="0"/>
<Component id="label_name" pref="113" max="32767" attributes="0"/>
<Component id="label_abteilung" max="32767" attributes="0"/>
</Group>
<EmptySpace pref="66" max="32767" attributes="0"/>
<EmptySpace pref="22" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand Down
10 changes: 5 additions & 5 deletions src/de/mpg/molgen/buczek/portifix/Gui.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ private void updateForm() {
String[] name = new String[selected.length];
String[] exemplar = new String[selected.length];
for (int i = 0; i < name.length; i++) {
name[i] = join(" ", (String) tableModel.getValueAt(i, TableModel.COLUMN_VORNAME), (String) tableModel.getValueAt(i, TableModel.COLUMN_NACHNAME));
exemplar[i] = join(" # ", (String) tableModel.getValueAt(i, TableModel.COLUMN_SCHLUESSELNUMMER), (String) tableModel.getValueAt(i, TableModel.COLUMN_EXEMPLARNUMMER));
name[i] = join(" ", (String) tableModel.getValueAt(selected[i], TableModel.COLUMN_VORNAME), (String) tableModel.getValueAt(selected[i], TableModel.COLUMN_NACHNAME));
exemplar[i] = join(" # ", (String) tableModel.getValueAt(selected[i], TableModel.COLUMN_SCHLUESSELNUMMER), (String) tableModel.getValueAt(selected[i], TableModel.COLUMN_EXEMPLARNUMMER));
}

label_name.setText(singleColumnValueOfArray(name));
Expand Down Expand Up @@ -334,9 +334,9 @@ private void initComponents() {
.addComponent(jLabel3))
.addGap(19, 19, 19)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(label_name, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(label_name, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
.addComponent(label_abteilung, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(66, Short.MAX_VALUE))
.addContainerGap(22, Short.MAX_VALUE))
);

jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel3});
Expand Down Expand Up @@ -444,7 +444,7 @@ private void initComponents() {
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 461, Short.MAX_VALUE)
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
Expand Down
80 changes: 26 additions & 54 deletions src/de/mpg/molgen/buczek/portifix/TableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,25 @@ public class TableModel extends AbstractTableModel {

Connection con;

public final static int COLUMN_NACHNAME=0;
public final static int COLUMN_VORNAME=1;
public final static int COLUMN_ABTEILUNG=2;
public final static int COLUMN_ENDEDATUM=3;
public final static int COLUMN_SCHLUESSELNUMMER=4;
public final static int COLUMN_EXEMPLARNUMMER=5;
public final static int COLUMN_RUECKGABEDATUM=6;

public final static int COLUMN_VISIBLE_COUNT=7;

public final static int COLUMN_AUSAGBE_ID=7;
public final static int COLUMN_EXEMPLAR_ID=8;
public final static int COLUMN_PERSONAL_ID=9;

public final static int COLUMN_COUNT=10;


public final static int COLUMN_NACHNAME = 0;
public final static int COLUMN_VORNAME = 1;
public final static int COLUMN_ABTEILUNG = 2;
public final static int COLUMN_SCHLUESSELNUMMER = 3;
public final static int COLUMN_EXEMPLARNUMMER = 4;
public final static int COLUMN_RUECKGABEDATUM = 5;

public final static int COLUMN_VISIBLE_COUNT = 6;

public final static int COLUMN_AUSAGBE_ID = 6;
public final static int COLUMN_EXEMPLAR_ID = 7;
public final static int COLUMN_PERSONAL_ID = 8;

public final static int COLUMN_COUNT = 10;

private final String COLUMN_NAMES[] = {
"Nachname",
"Vorname",
"Abteilung",
"Ende Datum",
"Schlüsselnummer",
"Exemplarnummer",
"Rückgabedatum",
Expand All @@ -58,20 +55,15 @@ public class TableModel extends AbstractTableModel {
String.class,
String.class,
String.class,
MyDate.class,
String.class,
String.class,
MyDate.class,
String.class,
String.class,
String.class,
};




String.class,};

final private String SQL
= "select NAME_1,NAME_2,ABTEILUNG,ENDEDATUM,RUECKGABETERMINDATUM,AUSGABE.SCHLUESSELNUMMER,"
= "select NAME_1,NAME_2,ABTEILUNG,RUECKGABETERMINDATUM,AUSGABE.SCHLUESSELNUMMER,"
+ "EXEMPLARNUMMER,AUSGABE_ID,AUSGABE.EXEMPLAR_ID,AUSGABE.PERSONAL_ID"
+ " from AUSGABE,PERSONAL,EXEMPLAR"
+ " where AUSGABE.PERSONAL_ID=PERSONAL.PERSONAL_ID"
Expand All @@ -80,7 +72,7 @@ public class TableModel extends AbstractTableModel {
+ " order by rueckgabetermindatum";

final private String SQL_ALL
= "select NAME_1,NAME_2,ABTEILUNG,ENDEDATUM,RUECKGABETERMINDATUM,AUSGABE.SCHLUESSELNUMMER,"
= "select NAME_1,NAME_2,ABTEILUNG,RUECKGABETERMINDATUM,AUSGABE.SCHLUESSELNUMMER,"
+ "EXEMPLARNUMMER,AUSGABE_ID,AUSGABE.EXEMPLAR_ID,AUSGABE.PERSONAL_ID"
+ " from AUSGABE,PERSONAL,EXEMPLAR"
+ " where AUSGABE.PERSONAL_ID=PERSONAL.PERSONAL_ID"
Expand Down Expand Up @@ -131,20 +123,19 @@ void populate() throws SQLException {
row[COLUMN_NACHNAME] = resultSet.getString(1); // name_1 vorname
row[COLUMN_VORNAME] = resultSet.getString(2); // name_2 nachname
row[COLUMN_ABTEILUNG] = resultSet.getString(3); // abteilung
row[COLUMN_ENDEDATUM] = upgradeOptionalDate(resultSet.getDate(4)); // endedatum (person)
row[COLUMN_RUECKGABEDATUM] = upgradeOptionalDate(resultSet.getDate(5)); // rueckgabetermin (ausgabe)
row[COLUMN_SCHLUESSELNUMMER] = resultSet.getString(6); // schluesselnummer
row[COLUMN_EXEMPLARNUMMER] = resultSet.getString(7); // exemplarnummer
row[COLUMN_AUSAGBE_ID] = resultSet.getString(8); // ausgabeid
row[COLUMN_EXEMPLAR_ID] = resultSet.getString(9); // exemplarid
row[COLUMN_PERSONAL_ID] = resultSet.getString(10); // personalid
row[COLUMN_RUECKGABEDATUM] = upgradeOptionalDate(resultSet.getDate(4)); // rueckgabetermin (ausgabe)
row[COLUMN_SCHLUESSELNUMMER] = resultSet.getString(5); // schluesselnummer
row[COLUMN_EXEMPLARNUMMER] = resultSet.getString(6); // exemplarnummer
row[COLUMN_AUSAGBE_ID] = resultSet.getString(7); // ausgabeid
row[COLUMN_EXEMPLAR_ID] = resultSet.getString(8); // exemplarid
row[COLUMN_PERSONAL_ID] = resultSet.getString(9); // personalid
this.row.add(row);
}
this.fireTableDataChanged();
}

public boolean isCellEditable(int rowIndex, int columnIndex) {
return false;
return false;
}

private static final String UPDATE_STATEMENT
Expand All @@ -168,26 +159,7 @@ void setNewDateThis(int rowIndex, Date newDate) {
}
}

private static final String UPDATE_STATEMENT_PERSON
= "update PERSONAL "
+ " set ENDEDATUM=?"
+ " where PERSONAL_ID=?";
void setNewDatePerson(int rowIndex, Date newDate) {
PreparedStatement statement;
try {
statement = con.prepareStatement(UPDATE_STATEMENT_PERSON);
statement.setDate(1, new java.sql.Date(newDate.getTime()));
statement.setString(2, (String) getValueAt(rowIndex, COLUMN_PERSONAL_ID));
int i = statement.executeUpdate();
System.out.printf("%d rows updated\n", i);
populate();
} catch (SQLException ex) {
Logger.getLogger(TableModel.class.getName()).log(Level.SEVERE, null, ex);
}
}

public void setConnection(Connection c) {
this.con = c;
}

}

0 comments on commit 7ef98b9

Please sign in to comment.