01: package org.dbbrowser.db.engine.model;
02:
03: import java.util.ArrayList;
04: import java.util.Iterator;
05: import java.util.List;
06:
07: /**
08: * This class represents a row in a table
09: * @author amangat
10: *
11: */
12: public class DBRow {
13: private List listOFDBTableCells = null;
14:
15: /**
16: * Constructer
17: * @param listOFDBTableCells
18: */
19: public DBRow(List listOFDBTableCells) {
20: this .listOFDBTableCells = listOFDBTableCells;
21: }
22:
23: /**
24: * Returns a list of cells in the table
25: * @return - a list of DBTableCell objects
26: */
27: public List getListOFDBTableCells() {
28: return this .listOFDBTableCells;
29: }
30:
31: /**
32: * Returns a list of primary key cells
33: * @return - a list of DBTableCells
34: */
35: public List getListOfPrimaryKeyDBTableCells() {
36: List listOfPrimaryKeyDBTableCells = new ArrayList();
37:
38: Iterator i = this .listOFDBTableCells.iterator();
39: while (i.hasNext()) {
40: DBTableCell dbTableCell = (DBTableCell) i.next();
41: boolean isPrimaryKeyColumn = dbTableCell.getColumnInfo()
42: .isPrimaryKeyColumn().booleanValue();
43: if (isPrimaryKeyColumn) {
44: listOfPrimaryKeyDBTableCells.add(dbTableCell);
45: }
46: }
47:
48: return listOfPrimaryKeyDBTableCells;
49: }
50:
51: /**
52: * Returns a list of non-primary key cells which have changed. Primary key values cant be changed
53: * @return - a list of DBTableCells
54: */
55: public List getListOfChangedNonPrimaryKeyCells() {
56: List listOfChangedNonPrimaryKeyDBTableCells = new ArrayList();
57:
58: Iterator i = this .listOFDBTableCells.iterator();
59: while (i.hasNext()) {
60: DBTableCell dbTableCell = (DBTableCell) i.next();
61: boolean isPrimaryKeyColumn = dbTableCell.getColumnInfo()
62: .isPrimaryKeyColumn().booleanValue();
63: boolean isChangedByUser = dbTableCell.isChangedByUser()
64: .booleanValue();
65:
66: if ((!isPrimaryKeyColumn) && isChangedByUser) {
67: listOfChangedNonPrimaryKeyDBTableCells.add(dbTableCell);
68: }
69: }
70:
71: return listOfChangedNonPrimaryKeyDBTableCells;
72: }
73: }
|