rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0);
if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN)) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); JPanel tt = new JPanel(new BorderLayout(12,12)); tt.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); tt.add(editPanel, BorderLayout.CENTER); tabbedPane.addTab("TableProperties",tt); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane (table tab) JPanel tt = new JPanel(new BorderLayout(12,12)); tt.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); tt.add(editPanel, BorderLayout.CENTER); tabbedPane.addTab("TableProperties",tt); // second tabbed Pane (mapping tab) JPanel mt = new JPanel(new BorderLayout(12,12)); mt.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mt.add(scrollpMap, BorderLayout.CENTER); tabbedPane.addTab("Column Mappings",mt); // ok/cancel buttons JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); // XXX: also apply changes on mapping tab d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); // XXX: also discard changes on mapping tab d.setVisible(false); } }); buttonPanel.add(cancelButton); d.getContentPane().add(buttonPanel, BorderLayout.SOUTH); d.getContentPane().add(tabbedPane, BorderLayout.CENTER); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
JTabbedPane tabbedPane = new JTabbedPane();
JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); d.getContentPane().add(buttonPanel, BorderLayout.SOUTH); d.getContentPane().add(tabbedPane, BorderLayout.CENTER); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); }
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane (table tab) JPanel tt = new JPanel(new BorderLayout(12,12)); tt.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); tt.add(editPanel, BorderLayout.CENTER); tabbedPane.addTab("TableProperties",tt); // second tabbed Pane (mapping tab) JPanel mt = new JPanel(new BorderLayout(12,12)); mt.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mt.add(scrollpMap, BorderLayout.CENTER); tabbedPane.addTab("Column Mappings",mt); // ok/cancel buttons JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); // XXX: also apply changes on mapping tab d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); // XXX: also discard changes on mapping tab d.setVisible(false); } }); buttonPanel.add(cancelButton); d.getContentPane().add(buttonPanel, BorderLayout.SOUTH); d.getContentPane().add(tabbedPane, BorderLayout.CENTER); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); JPanel tt = new JPanel(new BorderLayout(12,12)); tt.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); tt.add(editPanel, BorderLayout.CENTER); tabbedPane.addTab("TableProperties",tt); JPanel mt = new JPanel(new BorderLayout(12,12)); mt.setBorder(BorderFactory.createEmptyBorder(12,12,12,12));
} else if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE)) {
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane (table tab) JPanel tt = new JPanel(new BorderLayout(12,12)); tt.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); tt.add(editPanel, BorderLayout.CENTER); tabbedPane.addTab("TableProperties",tt); // second tabbed Pane (mapping tab) JPanel mt = new JPanel(new BorderLayout(12,12)); mt.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mt.add(scrollpMap, BorderLayout.CENTER); tabbedPane.addTab("Column Mappings",mt); // ok/cancel buttons JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); // XXX: also apply changes on mapping tab d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); // XXX: also discard changes on mapping tab d.setVisible(false); } }); buttonPanel.add(cancelButton); d.getContentPane().add(buttonPanel, BorderLayout.SOUTH); d.getContentPane().add(tabbedPane, BorderLayout.CENTER); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mt.add(scrollpMap, BorderLayout.CENTER); tabbedPane.addTab("Column Mappings",mt);
} else { }
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane (table tab) JPanel tt = new JPanel(new BorderLayout(12,12)); tt.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); tt.add(editPanel, BorderLayout.CENTER); tabbedPane.addTab("TableProperties",tt); // second tabbed Pane (mapping tab) JPanel mt = new JPanel(new BorderLayout(12,12)); mt.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mt.add(scrollpMap, BorderLayout.CENTER); tabbedPane.addTab("Column Mappings",mt); // ok/cancel buttons JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); // XXX: also apply changes on mapping tab d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); // XXX: also discard changes on mapping tab d.setVisible(false); } }); buttonPanel.add(cancelButton); d.getContentPane().add(buttonPanel, BorderLayout.SOUTH); d.getContentPane().add(tabbedPane, BorderLayout.CENTER); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); d.getContentPane().add(buttonPanel, BorderLayout.SOUTH); d.getContentPane().add(tabbedPane, BorderLayout.CENTER); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); }
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane (table tab) JPanel tt = new JPanel(new BorderLayout(12,12)); tt.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); tt.add(editPanel, BorderLayout.CENTER); tabbedPane.addTab("TableProperties",tt); // second tabbed Pane (mapping tab) JPanel mt = new JPanel(new BorderLayout(12,12)); mt.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mt.add(scrollpMap, BorderLayout.CENTER); tabbedPane.addTab("Column Mappings",mt); // ok/cancel buttons JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); // XXX: also apply changes on mapping tab d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); // XXX: also discard changes on mapping tab d.setVisible(false); } }); buttonPanel.add(cancelButton); d.getContentPane().add(buttonPanel, BorderLayout.SOUTH); d.getContentPane().add(tabbedPane, BorderLayout.CENTER); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } }
List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a column (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); try { int idx = tp.getSelectedColumnIndex(); if (editDialog != null) { columnEditPanel.setModel(tp.getModel()); columnEditPanel.selectColumn(idx); editDialog.setTitle("Edit columns of "+tp.getModel().getName()); editDialog.setVisible(true); editDialog.requestFocus(); } else { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout(12,12)); panel.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); columnEditPanel = new ColumnEditPanel(tp.getModel(), idx); panel.add(columnEditPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); okCancelListener = new OkCancelListener(); okButton = new JButton("Ok"); okButton.addActionListener(okCancelListener); buttonPanel.add(okButton); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(okCancelListener); buttonPanel.add(cancelButton); panel.add(buttonPanel, BorderLayout.SOUTH); editDialog = new JDialog(ArchitectFrame.getMainInstance(), "Edit columns of "+tp.getModel().getName()); panel.setOpaque(true); editDialog.setContentPane(panel); editDialog.pack(); editDialog.setLocationRelativeTo(ArchitectFrame.getMainInstance()); editDialog.setVisible(true);
if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN)) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a column (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); try { int idx = tp.getSelectedColumnIndex(); makeDialog(tp.getModel(),idx); } catch (ArchitectException e) { JOptionPane.showMessageDialog(tp, "Error finding the selected column"); logger.error("Error finding the selected column", e); cleanup();
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a column (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); try { int idx = tp.getSelectedColumnIndex(); if (editDialog != null) { columnEditPanel.setModel(tp.getModel()); columnEditPanel.selectColumn(idx); editDialog.setTitle("Edit columns of "+tp.getModel().getName()); editDialog.setVisible(true); editDialog.requestFocus(); } else { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout(12,12)); panel.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); columnEditPanel = new ColumnEditPanel(tp.getModel(), idx); panel.add(columnEditPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); okCancelListener = new OkCancelListener(); okButton = new JButton("Ok"); okButton.addActionListener(okCancelListener); buttonPanel.add(okButton); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(okCancelListener); buttonPanel.add(cancelButton); panel.add(buttonPanel, BorderLayout.SOUTH); editDialog = new JDialog(ArchitectFrame.getMainInstance(), "Edit columns of "+tp.getModel().getName()); panel.setOpaque(true); editDialog.setContentPane(panel); editDialog.pack(); editDialog.setLocationRelativeTo(ArchitectFrame.getMainInstance()); editDialog.setVisible(true); } } catch (ArchitectException e) { JOptionPane.showMessageDialog(tp, "Error finding the selected column"); logger.error("Error finding the selected column", e); cleanup(); } } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); cleanup(); } }
} catch (ArchitectException e) { JOptionPane.showMessageDialog(tp, "Error finding the selected column"); logger.error("Error finding the selected column", e);
} else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised");
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a column (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); try { int idx = tp.getSelectedColumnIndex(); if (editDialog != null) { columnEditPanel.setModel(tp.getModel()); columnEditPanel.selectColumn(idx); editDialog.setTitle("Edit columns of "+tp.getModel().getName()); editDialog.setVisible(true); editDialog.requestFocus(); } else { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout(12,12)); panel.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); columnEditPanel = new ColumnEditPanel(tp.getModel(), idx); panel.add(columnEditPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); okCancelListener = new OkCancelListener(); okButton = new JButton("Ok"); okButton.addActionListener(okCancelListener); buttonPanel.add(okButton); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(okCancelListener); buttonPanel.add(cancelButton); panel.add(buttonPanel, BorderLayout.SOUTH); editDialog = new JDialog(ArchitectFrame.getMainInstance(), "Edit columns of "+tp.getModel().getName()); panel.setOpaque(true); editDialog.setContentPane(panel); editDialog.pack(); editDialog.setLocationRelativeTo(ArchitectFrame.getMainInstance()); editDialog.setVisible(true); } } catch (ArchitectException e) { JOptionPane.showMessageDialog(tp, "Error finding the selected column"); logger.error("Error finding the selected column", e); cleanup(); } } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); cleanup(); } }
JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); cleanup(); }
}
public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a column (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); try { int idx = tp.getSelectedColumnIndex(); if (editDialog != null) { columnEditPanel.setModel(tp.getModel()); columnEditPanel.selectColumn(idx); editDialog.setTitle("Edit columns of "+tp.getModel().getName()); editDialog.setVisible(true); editDialog.requestFocus(); } else { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout(12,12)); panel.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); columnEditPanel = new ColumnEditPanel(tp.getModel(), idx); panel.add(columnEditPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); okCancelListener = new OkCancelListener(); okButton = new JButton("Ok"); okButton.addActionListener(okCancelListener); buttonPanel.add(okButton); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(okCancelListener); buttonPanel.add(cancelButton); panel.add(buttonPanel, BorderLayout.SOUTH); editDialog = new JDialog(ArchitectFrame.getMainInstance(), "Edit columns of "+tp.getModel().getName()); panel.setOpaque(true); editDialog.setContentPane(panel); editDialog.pack(); editDialog.setLocationRelativeTo(ArchitectFrame.getMainInstance()); editDialog.setVisible(true); } } catch (ArchitectException e) { JOptionPane.showMessageDialog(tp, "Error finding the selected column"); logger.error("Error finding the selected column", e); cleanup(); } } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); cleanup(); } }
public void inherit(int pos, SQLTable source) throws ArchitectException { SQLColumn c; boolean addToPK; int pkSize = pkSize(); int sourceSize = source.columnsFolder.children.size(); int originalSize = columnsFolder.children.size(); if (originalSize == 0 || pos < pkSize) { addToPK = true; normalizePrimaryKey(); for (int i = pos; i < pkSize; i++) { ((SQLColumn) columnsFolder.children.get(i)).primaryKeySeq = new Integer(i + sourceSize); } } else { addToPK = false; } Iterator it = source.getColumns().iterator(); while (it.hasNext()) { SQLColumn child = (SQLColumn) it.next(); c = SQLColumn.getDerivedInstance(child, this); if (originalSize > 0) { if (addToPK) { c.primaryKeySeq = new Integer(pos); } else { c.primaryKeySeq = null; } } columnsFolder.addChild(pos, c); pos += 1; }
public void inherit(SQLTable source) throws ArchitectException { inherit(columnsFolder.children.size(), source);
public void inherit(int pos, SQLTable source) throws ArchitectException { SQLColumn c; boolean addToPK; int pkSize = pkSize(); int sourceSize = source.columnsFolder.children.size(); int originalSize = columnsFolder.children.size(); if (originalSize == 0 || pos < pkSize) { addToPK = true; normalizePrimaryKey(); for (int i = pos; i < pkSize; i++) { ((SQLColumn) columnsFolder.children.get(i)).primaryKeySeq = new Integer(i + sourceSize); } } else { addToPK = false; } Iterator it = source.getColumns().iterator(); while (it.hasNext()) { SQLColumn child = (SQLColumn) it.next(); c = SQLColumn.getDerivedInstance(child, this); if (originalSize > 0) { if (addToPK) { c.primaryKeySeq = new Integer(pos); } else { c.primaryKeySeq = null; } } columnsFolder.addChild(pos, c); pos += 1; } }
public void removeColumn(SQLColumn col) throws LockedColumnException { columnsFolder.removeChild(col); normalizePrimaryKey();
public void removeColumn(int index) throws LockedColumnException { removeColumn((SQLColumn) columnsFolder.children.get(index));
public void removeColumn(SQLColumn col) throws LockedColumnException {// List keys = keysOfColumn(col);// if (keys.isEmpty()) {// columnsFolder.removeChild(col);// normalizePrimaryKey();// } else {// throw new LockedColumnException("This column can't be removed because it belongs to the "+keys.get(0)+" relationship");// } columnsFolder.removeChild(col); normalizePrimaryKey(); }
Database db = ODMG.getODMGDatabase();
public static PhotoInfo create() { PhotoInfo photo = new PhotoInfo(); ODMGXAWrapper txw = new ODMGXAWrapper(); Database db = ODMG.getODMGDatabase(); // db.makePersistent( photo ); txw.lock( photo, Transaction.WRITE ); txw.commit(); return photo; }
Implementation odmg = ODMG.getODMGImplementation();
ODMGXAWrapper txw = new ODMGXAWrapper();
public void delete() { Implementation odmg = ODMG.getODMGImplementation(); Database db = ODMG.getODMGDatabase(); ODMGXAWrapper txw = new ODMGXAWrapper(); // First delete all instances for ( int i = 0; i < instances.size(); i++ ) { ImageInstance f = (ImageInstance) instances.get( i ); f.delete(); } // Then delete the photo from all folders it belongs to if ( folders != null ) { Object[] foldersArray = folders.toArray(); for ( int n = 0; n < foldersArray.length; n++ ) { ((PhotoFolder)foldersArray[n]).removePhoto( this ); } } // Then delete the PhotoInfo itself db.deletePersistent( this ); txw.commit(); }
ODMGXAWrapper txw = new ODMGXAWrapper();
public void delete() { Implementation odmg = ODMG.getODMGImplementation(); Database db = ODMG.getODMGDatabase(); ODMGXAWrapper txw = new ODMGXAWrapper(); // First delete all instances for ( int i = 0; i < instances.size(); i++ ) { ImageInstance f = (ImageInstance) instances.get( i ); f.delete(); } // Then delete the photo from all folders it belongs to if ( folders != null ) { Object[] foldersArray = folders.toArray(); for ( int n = 0; n < foldersArray.length; n++ ) { ((PhotoFolder)foldersArray[n]).removePhoto( this ); } } // Then delete the PhotoInfo itself db.deletePersistent( this ); txw.commit(); }
if ( obj.getClass() != this.getClass() ) {
if ( obj == null || obj.getClass() != this.getClass() ) {
public boolean equals( Object obj ) { if ( obj.getClass() != this.getClass() ) { return false; } PhotoInfo p = (PhotoInfo)obj; ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.READ ); txw.lock( p, Transaction.READ ); txw.commit(); return ( isEqual( p.photographer, this.photographer ) && isEqual( p.shootingPlace, this.shootingPlace ) && isEqual( p.shootTime, this.shootTime ) && isEqual(p.description, this.description ) && isEqual( p.camera, this.camera ) && isEqual( p.lens, this.lens ) && isEqual( p.film, this.film ) && isEqual( p.techNotes, this.techNotes ) && isEqual( p.origFname, this.origFname ) && p.shutterSpeed == this.shutterSpeed && p.filmSpeed == this.filmSpeed && p.focalLength == this.focalLength && p.FStop == this.FStop && p.uid == this.uid && p.quality == this.quality ); }
return lastModified;
return lastModified != null ? (java.util.Date) lastModified.clone() : null;
public final java.util.Date getLastModified() { return lastModified; }
return shootTime;
return shootTime != null ? (java.util.Date) shootTime.clone() : null;
public java.util.Date getShootTime() { ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.READ ); txw.commit(); return shootTime; }
this.lastModified = newDate;
this.lastModified = (newDate != null) ? (java.util.Date) newDate.clone() : null;
public void setLastModified(final java.util.Date newDate) { ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); this.lastModified = newDate; modified(); txw.commit(); }
this.shootTime = v;
this.shootTime = (v != null) ? (java.util.Date) v.clone() : null;
public void setShootTime(java.util.Date v) { ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); this.shootTime = v; modified(); txw.commit(); }
public static ImageInstance create( VolumeBase volume, File imageFile, PhotoInfo photo ) { log.debug( "Creating instance, volume = " + volume.getName() + " photo = " + photo.getUid() + " image file = " + imageFile.getName() );
public static ImageInstance create ( VolumeBase vol, File imgFile ) {
public static ImageInstance create( VolumeBase volume, File imageFile, PhotoInfo photo ) { log.debug( "Creating instance, volume = " + volume.getName() + " photo = " + photo.getUid() + " image file = " + imageFile.getName() ); // Initialize transaction context ODMGXAWrapper txw = new ODMGXAWrapper(); ImageInstance f = new ImageInstance(); // Set up the primary key fields before locking the object f.volume = volume; f.volumeId = volume.getName(); f.imageFile = imageFile; f.fname = volume.mapFileToVolumeRelativeName( imageFile ); txw.lock( f, Transaction.WRITE ); log.debug( "locked instance" ); f.photoUid = photo.getUid(); // Read the rest of fields from the image file try { f.readImageFile(); } catch (IOException e ) { txw.abort(); log.warn( "Error opening image file: " + e.getMessage() ); // The image does not exist, so it cannot be read!!! return null; } f.calcHash(); txw.commit(); return f; }
ImageInstance f = new ImageInstance(); f.volume = volume; f.volumeId = volume.getName(); f.imageFile = imageFile; f.fname = volume.mapFileToVolumeRelativeName( imageFile ); txw.lock( f, Transaction.WRITE ); log.debug( "locked instance" ); f.photoUid = photo.getUid();
ImageInstance i = new ImageInstance(); i.volume = vol; i.volumeId = vol.getName(); i.imageFile = imgFile; i.fileSize = imgFile.length(); i.mtime = imgFile.lastModified(); i.fname = vol.mapFileToVolumeRelativeName( imgFile ); txw.lock( i, Transaction.WRITE ); i.calcHash();
public static ImageInstance create( VolumeBase volume, File imageFile, PhotoInfo photo ) { log.debug( "Creating instance, volume = " + volume.getName() + " photo = " + photo.getUid() + " image file = " + imageFile.getName() ); // Initialize transaction context ODMGXAWrapper txw = new ODMGXAWrapper(); ImageInstance f = new ImageInstance(); // Set up the primary key fields before locking the object f.volume = volume; f.volumeId = volume.getName(); f.imageFile = imageFile; f.fname = volume.mapFileToVolumeRelativeName( imageFile ); txw.lock( f, Transaction.WRITE ); log.debug( "locked instance" ); f.photoUid = photo.getUid(); // Read the rest of fields from the image file try { f.readImageFile(); } catch (IOException e ) { txw.abort(); log.warn( "Error opening image file: " + e.getMessage() ); // The image does not exist, so it cannot be read!!! return null; } f.calcHash(); txw.commit(); return f; }
f.readImageFile();
i.readImageFile();
public static ImageInstance create( VolumeBase volume, File imageFile, PhotoInfo photo ) { log.debug( "Creating instance, volume = " + volume.getName() + " photo = " + photo.getUid() + " image file = " + imageFile.getName() ); // Initialize transaction context ODMGXAWrapper txw = new ODMGXAWrapper(); ImageInstance f = new ImageInstance(); // Set up the primary key fields before locking the object f.volume = volume; f.volumeId = volume.getName(); f.imageFile = imageFile; f.fname = volume.mapFileToVolumeRelativeName( imageFile ); txw.lock( f, Transaction.WRITE ); log.debug( "locked instance" ); f.photoUid = photo.getUid(); // Read the rest of fields from the image file try { f.readImageFile(); } catch (IOException e ) { txw.abort(); log.warn( "Error opening image file: " + e.getMessage() ); // The image does not exist, so it cannot be read!!! return null; } f.calcHash(); txw.commit(); return f; }
f.calcHash(); txw.commit(); return f;
i.checkTime = new java.util.Date(); txw.commit(); return i;
public static ImageInstance create( VolumeBase volume, File imageFile, PhotoInfo photo ) { log.debug( "Creating instance, volume = " + volume.getName() + " photo = " + photo.getUid() + " image file = " + imageFile.getName() ); // Initialize transaction context ODMGXAWrapper txw = new ODMGXAWrapper(); ImageInstance f = new ImageInstance(); // Set up the primary key fields before locking the object f.volume = volume; f.volumeId = volume.getName(); f.imageFile = imageFile; f.fname = volume.mapFileToVolumeRelativeName( imageFile ); txw.lock( f, Transaction.WRITE ); log.debug( "locked instance" ); f.photoUid = photo.getUid(); // Read the rest of fields from the image file try { f.readImageFile(); } catch (IOException e ) { txw.abort(); log.warn( "Error opening image file: " + e.getMessage() ); // The image does not exist, so it cannot be read!!! return null; } f.calcHash(); txw.commit(); return f; }
if(args[i].equals("-n") || args[i].equals("-h") || args[i].equals("-help")) {
if(args[i].equals("-nogui") || args[i].equals("-n") || args[i].equals("-h") || args[i].equals("-help")) {
public static void main(String[] args) { boolean nogui = false; //HaploView window; for(int i = 0;i<args.length;i++) { if(args[i].equals("-n") || args[i].equals("-h") || args[i].equals("-help")) { nogui = true; } } if(nogui) { HaploText textOnly = new HaploText(args); } else { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } //System.setProperty("swing.disableFileChooserSpeedFix", "true"); window = new HaploView(); //setup view object window.setTitle(TITLE_STRING); window.setSize(800,600); //center the window on the screen Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); window.setLocation((screen.width - window.getWidth()) / 2, (screen.height - window.getHeight()) / 2); window.setVisible(true); //parse command line stuff for input files or prompt data dialog HaploText argParser = new HaploText(args); String[] inputArray = new String[2]; if (argParser.getHapsFileName() != null){ inputArray[0] = argParser.getHapsFileName(); inputArray[1] = argParser.getInfoFileName(); window.readGenotypes(inputArray, HAPS); }else if (argParser.getPedFileName() != null){ inputArray[0] = argParser.getPedFileName(); inputArray[1] = argParser.getInfoFileName(); window.readGenotypes(inputArray, PED); }else if (argParser.getHapmapFileName() != null){ inputArray[0] = argParser.getHapmapFileName(); inputArray[1] = ""; window.readGenotypes(inputArray, HMP); }else{ ReadDataDialog readDialog = new ReadDataDialog("Welcome to HaploView", window); readDialog.pack(); readDialog.setVisible(true); } } }
public Cell(GridBagConstraints constraints, Component component) { this.constraints = constraints; this.component = component;
public Cell() {
public Cell(GridBagConstraints constraints, Component component) { this.constraints = constraints; this.component = component; }
setDynaBean( new WrapDynaBean(task) );
setDynaBean( new ConvertingWrapDynaBean(task) );
public void setTask(Task task) { this.task = task; setDynaBean( new WrapDynaBean(task) ); }
public Iterator evaluateAsIterator(Context context);
public Iterator evaluateAsIterator(JellyContext context);
public Iterator evaluateAsIterator(Context context);
public BSFExpression(String text, BSFEngine engine, BSFManager manager, ContextRegistry registry) {
public BSFExpression(String text, BSFEngine engine, BSFManager manager, JellyContextRegistry registry) {
public BSFExpression(String text, BSFEngine engine, BSFManager manager, ContextRegistry registry) { this.text = text; this.engine = engine; this.manager = manager; this.registry = registry; }
if (e.getChildren() != null)
if (e.getChildren().length > 0)
public void createToolTip() { if (e.getChildren() != null) { if (e.getChildren()[0] instanceof SQLTable) { toolTip = "Add table"; } if (e.getChildren()[0] instanceof SQLColumn) { toolTip = "Add column"; } if (e.getChildren()[0] instanceof SQLRelationship) { toolTip = "Add relation"; } if (e.getChildren().length>1) { toolTip = toolTip+"s"; } } }
throw new IllegalStateException("could not create JVMResourceSamplerWorker");
throw new IllegalStateException("could not create JVMResourceSamplerWorker", e);
public JVMResourceSampler(String host, int port, PostageRunnerResult results) { Class workerClass; Constructor constructor; try { // the class is only present, when the package _was compiled_ with at least Java 5 (see build script) workerClass = Class.forName("org.apache.james.postage.jmx.JVMResourceSamplerWorker"); Constructor[] constructors = workerClass.getConstructors(); if (constructors.length != 1) throw new IllegalStateException("only constructor JVMResourceSamplerWorker(String host, int port, PostageRunnerResult results) is supported"); constructor = constructors[0]; } catch (ClassNotFoundException e) { return; // keep worker object NULL } try { jvmResourceSampleWorker = constructor.newInstance(new Object[]{host, new Integer(port), results}); } catch (Exception e) { throw new IllegalStateException("could not create JVMResourceSamplerWorker"); } try { m_connectMethod = workerClass.getMethod("connectRemoteJamesJMXServer", (Class)null); m_doSampleMethod = workerClass.getMethod("doSample", (Class)null); } catch (NoSuchMethodException e) { throw new IllegalStateException("could not access delegation methods"); } }
m_connectMethod = workerClass.getMethod("connectRemoteJamesJMXServer", (Class)null); m_doSampleMethod = workerClass.getMethod("doSample", (Class)null);
m_connectMethod = workerClass.getMethod("connectRemoteJamesJMXServer", VOID_ARGUMENT_LIST); m_doSampleMethod = workerClass.getMethod("doSample", VOID_ARGUMENT_LIST);
public JVMResourceSampler(String host, int port, PostageRunnerResult results) { Class workerClass; Constructor constructor; try { // the class is only present, when the package _was compiled_ with at least Java 5 (see build script) workerClass = Class.forName("org.apache.james.postage.jmx.JVMResourceSamplerWorker"); Constructor[] constructors = workerClass.getConstructors(); if (constructors.length != 1) throw new IllegalStateException("only constructor JVMResourceSamplerWorker(String host, int port, PostageRunnerResult results) is supported"); constructor = constructors[0]; } catch (ClassNotFoundException e) { return; // keep worker object NULL } try { jvmResourceSampleWorker = constructor.newInstance(new Object[]{host, new Integer(port), results}); } catch (Exception e) { throw new IllegalStateException("could not create JVMResourceSamplerWorker"); } try { m_connectMethod = workerClass.getMethod("connectRemoteJamesJMXServer", (Class)null); m_doSampleMethod = workerClass.getMethod("doSample", (Class)null); } catch (NoSuchMethodException e) { throw new IllegalStateException("could not access delegation methods"); } }
throw new IllegalStateException("could not access delegation methods");
throw new IllegalStateException("could not access delegation methods", e);
public JVMResourceSampler(String host, int port, PostageRunnerResult results) { Class workerClass; Constructor constructor; try { // the class is only present, when the package _was compiled_ with at least Java 5 (see build script) workerClass = Class.forName("org.apache.james.postage.jmx.JVMResourceSamplerWorker"); Constructor[] constructors = workerClass.getConstructors(); if (constructors.length != 1) throw new IllegalStateException("only constructor JVMResourceSamplerWorker(String host, int port, PostageRunnerResult results) is supported"); constructor = constructors[0]; } catch (ClassNotFoundException e) { return; // keep worker object NULL } try { jvmResourceSampleWorker = constructor.newInstance(new Object[]{host, new Integer(port), results}); } catch (Exception e) { throw new IllegalStateException("could not create JVMResourceSamplerWorker"); } try { m_connectMethod = workerClass.getMethod("connectRemoteJamesJMXServer", (Class)null); m_doSampleMethod = workerClass.getMethod("doSample", (Class)null); } catch (NoSuchMethodException e) { throw new IllegalStateException("could not access delegation methods"); } }
m_connectMethod.invoke(jvmResourceSampleWorker, (Class)null);
m_connectMethod.invoke(jvmResourceSampleWorker, VOID_ARGUMENT_LIST);
public void connectRemoteJamesJMXServer() throws SamplingException { if(jvmResourceSampleWorker == null) throw new SamplingException("JSE specific features not present. (compile the project with JSE 5)"); try { m_connectMethod.invoke(jvmResourceSampleWorker, (Class)null); } catch (Exception e) { throw new SamplingException("could not establish connection to remote James JMX. is James really configured for JMX and running under JSE5 or later?"); } }
m_doSampleMethod.invoke(jvmResourceSampleWorker, (Class)null);
m_doSampleMethod.invoke(jvmResourceSampleWorker, VOID_ARGUMENT_LIST);
public void doSample() throws SamplingException { if(jvmResourceSampleWorker == null) throw new SamplingException("JSE specific features not present. (compile the project with JSE 5)"); try { m_doSampleMethod.invoke(jvmResourceSampleWorker, (Class)null); } catch (Exception e) { throw new SamplingException(e); } }
model.removeSQLObjectListener(tableListModel);
model.getColumnsFolder().removeSQLObjectListener(tableListModel);
public void setModel(SQLTable newModel) { if (model != null) { model.removeSQLObjectListener(tableListModel); } model = newModel; tableListModel = new SQLTableListModel(model); model.addSQLObjectListener(tableListModel); try { for (int i = 0; i < model.getChildCount(); i++) { model.getChild(i).addSQLObjectListener(tableListModel); } } catch (ArchitectException e) { logger.error("Caught exception adding treemodel to column listener list"); } columns.setModel(tableListModel); }
model.addSQLObjectListener(tableListModel);
model.getColumnsFolder().addSQLObjectListener(tableListModel);
public void setModel(SQLTable newModel) { if (model != null) { model.removeSQLObjectListener(tableListModel); } model = newModel; tableListModel = new SQLTableListModel(model); model.addSQLObjectListener(tableListModel); try { for (int i = 0; i < model.getChildCount(); i++) { model.getChild(i).addSQLObjectListener(tableListModel); } } catch (ArchitectException e) { logger.error("Caught exception adding treemodel to column listener list"); } columns.setModel(tableListModel); }
for (int i = 0; i < model.getChildCount(); i++) { model.getChild(i).addSQLObjectListener(tableListModel);
for (int i = 0; i < model.getColumnsFolder().getChildCount(); i++) { model.getColumnsFolder().getChild(i).addSQLObjectListener(tableListModel);
public void setModel(SQLTable newModel) { if (model != null) { model.removeSQLObjectListener(tableListModel); } model = newModel; tableListModel = new SQLTableListModel(model); model.addSQLObjectListener(tableListModel); try { for (int i = 0; i < model.getChildCount(); i++) { model.getChild(i).addSQLObjectListener(tableListModel); } } catch (ArchitectException e) { logger.error("Caught exception adding treemodel to column listener list"); } columns.setModel(tableListModel); }
File file = new File(name); if (file.exists()) { return file.toURL();
URL url = this.getClass().getClassLoader().getResource(name); if (url != null) { return url;
protected URL resolveURL(String name) throws MalformedURLException { File file = new File(name); if (file.exists()) { return file.toURL(); } return new URL(name); }
return new URL(name);
else { File file = new File(name); if (file.exists()) { return file.toURL(); } return new URL(name); }
protected URL resolveURL(String name) throws MalformedURLException { File file = new File(name); if (file.exists()) { return file.toURL(); } return new URL(name); }
if (!(new File(scriptFile)).exists()) {
if (url == null && !(new File(scriptFile)).exists()) {
public void invokeCommandLineJelly(String[] args) throws JellyException { CommandLine cmdLine = null; try { cmdLine = parseCommandLineOptions(args); } catch (ParseException e) { throw new JellyException(e); } // get the -script option. If there isn't one then use args[0] String scriptFile = null; if (cmdLine.hasOption("script")) { scriptFile = cmdLine.getOptionValue("script"); } else { scriptFile = args[0]; } // check if the script file exists if (!(new File(scriptFile)).exists()) { throw new JellyException("Script file " + scriptFile + " not found"); } try { // extract the -o option for the output file to use final XMLOutput output = cmdLine.hasOption("o") ? XMLOutput.createXMLOutput(new FileWriter(cmdLine.getOptionValue("o"))) : XMLOutput.createXMLOutput(System.out); Jelly jelly = new Jelly(); jelly.setScript(scriptFile); Script script = jelly.compileScript(); // add the system properties and the command line arguments JellyContext context = jelly.getJellyContext(); context.setVariable("args", args); context.setVariable("commandLine", cmdLine); script.run(context, output); // now lets wait for all threads to close Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { output.close(); } catch (Exception e) { // ignore errors } } } ); } catch (Exception e) { throw new JellyException(e); } }
getBody().run(context, output);
invokeBody(output);
public void doTag(XMLOutput output) throws Exception { if (select != null) { Iterator iter = select.selectNodes( getXPathContext() ).iterator(); while (iter.hasNext()) { iterationValue = iter.next(); if (var != null) { context.setVariable(var, iterationValue); } getBody().run(context, output); } } }
broker = PersistenceBrokerFactory.createPersistenceBroker();
broker = PersistenceBrokerFactory.defaultPersistenceBroker();
public void doTag(XMLOutput output) throws Exception { if ( var == null ) { var = "org.apache.commons.jelly.ojb.Broker"; } if ( broker != null ) { context.setVariable(var, broker); invokeBody(output); } else { broker = PersistenceBrokerFactory.createPersistenceBroker(); context.setVariable(var, broker); try { invokeBody(output); } finally { broker.clearCache(); PersistenceBrokerFactory.releaseInstance(broker); broker = null; context.removeVariable(var); } } }
broker.clearCache(); PersistenceBrokerFactory.releaseInstance(broker);
broker.close();
public void doTag(XMLOutput output) throws Exception { if ( var == null ) { var = "org.apache.commons.jelly.ojb.Broker"; } if ( broker != null ) { context.setVariable(var, broker); invokeBody(output); } else { broker = PersistenceBrokerFactory.createPersistenceBroker(); context.setVariable(var, broker); try { invokeBody(output); } finally { broker.clearCache(); PersistenceBrokerFactory.releaseInstance(broker); broker = null; context.removeVariable(var); } } }
table.getColumnModel().getColumn(2).setMinWidth(60);
public CheckDataPanel(HaploData hd, boolean disp) throws IOException, PedFileException{ STATUS_COL = 8; setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); pedfile = hd.getPedFile(); theData = hd; Vector result = pedfile.getResults(); int numResults = result.size(); Vector tableColumnNames = new Vector(); tableColumnNames.add("#"); if (theData.infoKnown){ tableColumnNames.add("Name"); tableColumnNames.add("Position"); STATUS_COL += 2; } tableColumnNames.add("ObsHET"); tableColumnNames.add("PredHET"); tableColumnNames.add("HWpval"); tableColumnNames.add("%Geno"); tableColumnNames.add("FamTrio"); tableColumnNames.add("MendErr"); tableColumnNames.add("MAF"); tableColumnNames.add("Rating"); Vector tableData = new Vector(); int[] markerRatings = new int[numResults]; for (int i = 0; i < numResults; i++){ Vector tempVect = new Vector(); MarkerResult currentResult = (MarkerResult)result.get(i); tempVect.add(new Integer(i+1)); if (theData.infoKnown){ tempVect.add(Chromosome.getUnfilteredMarker(i).getName()); tempVect.add(new Long(Chromosome.getUnfilteredMarker(i).getPosition())); } tempVect.add(new Double(currentResult.getObsHet())); tempVect.add(new Double(currentResult.getPredHet())); tempVect.add(new Double(currentResult.getHWpvalue())); tempVect.add(new Double(currentResult.getGenoPercent())); tempVect.add(new Integer(currentResult.getFamTrioNum())); tempVect.add(new Integer(currentResult.getMendErrNum())); tempVect.add(new Double(currentResult.getMAF())); if (currentResult.getRating() > 0){ tempVect.add(new Boolean(true)); }else{ tempVect.add(new Boolean(false)); } //this value is never displayed, just kept for bookkeeping markerRatings[i] = currentResult.getRating(); tableData.add(tempVect.clone()); } tableModel = new CheckDataTableModel(tableColumnNames, tableData, markerRatings); tableModel.addTableModelListener(this); if (disp){ table = new JTable(tableModel); final CheckDataCellRenderer renderer = new CheckDataCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Long"), renderer); }catch (Exception e){ } table.getColumnModel().getColumn(0).setPreferredWidth(30); table.getColumnModel().getColumn(0).setMinWidth(30); if (theData.infoKnown){ table.getColumnModel().getColumn(1).setMinWidth(100); } JScrollPane tableScroller = new JScrollPane(table); tableScroller.setMaximumSize(new Dimension(600, tableScroller.getPreferredSize().height)); add(tableScroller); } }
JMenuItem exportItem = new JMenuItem( "Export image...", KeyEvent.VK_E ); exportItem.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { exportSelected(); } }); fileMenu.add( exportItem );
protected void createUI() { setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); tabPane = new JTabbedPane(); queryPane = new QueryPane(); treePane = new PhotoFolderTree(); tabPane.addTab( "Query", queryPane ); tabPane.addTab( "Folders", treePane ); // viewPane = new TableCollectionView(); viewPane = new PhotoCollectionThumbView(); viewPane.setCollection( queryPane.getResultCollection() ); // Set listeners to both query and folder tree panes /* If an actionEvent comes from queryPane & the viewed folder is no the query resouts, swich to it (the result folder will be nodified of changes to quert parameters directly */ queryPane.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { if ( viewPane.getCollection() != queryPane.getResultCollection() ) { viewPane.setCollection( queryPane.getResultCollection() ); } } } ); /* If the selected folder is changed in treePane, switch to that immediately */ treePane.addPhotoFolderTreeListener( new PhotoFolderTreeListener() { public void photoFolderTreeSelectionChanged( PhotoFolderTreeEvent e ) { PhotoFolder f = e.getSelected(); if ( f != null ) { viewPane.setCollection( f ); } } } ); // Create the split pane to display both of these components JScrollPane viewScroll = new JScrollPane( viewPane ); JSplitPane split = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, tabPane, viewScroll ); Container cp = getContentPane(); cp.setLayout( new BorderLayout() ); cp.add( split, BorderLayout.CENTER ); // Create the menu bar & menus JMenuBar menuBar = new JMenuBar(); setJMenuBar( menuBar ); JMenu fileMenu = new JMenu( "File" ); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add( fileMenu ); JMenuItem newWindowItem = new JMenuItem( "New window", KeyEvent.VK_N ); newWindowItem.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { BrowserWindow br = new BrowserWindow(); // br.setVisible( true ); } }); fileMenu.add( newWindowItem ); JMenuItem importItem = new JMenuItem( "Import image...", KeyEvent.VK_I ); importItem.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { importFile(); } }); fileMenu.add( importItem ); JMenuItem exitItem = new JMenuItem( "Exit", KeyEvent.VK_X ); exitItem.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { System.exit( 0 ); } }); fileMenu.add( exitItem ); pack(); setVisible( true ); }
System.exit( 0 );
exportSelected();
public void actionPerformed( ActionEvent e ) { System.exit( 0 ); }
attributes.put( "jelly.body", getBody() );
public void run(Context context, XMLOutput output) throws Exception { log.info( "Invoking dynamic tag with attributes: " + attributes ); // create new context based on current attributes Context newContext = context.newContext( attributes ); getTemplate().run( newContext, output ); }
propertiesToIgnore.add("ignoreReset");
propertiesToIgnore.add("playPenDatabase");
public void testSaveCoversAllDatabaseProperties() throws Exception { testLoad(); DBTree dbTree = project.getSourceDatabases(); DBTreeModel dbTreeModel = (DBTreeModel) dbTree.getModel(); ArchitectDataSource fakeDataSource = new ArchitectDataSource(); SQLDatabase db = new SQLDatabase() { @Override public Connection getConnection() throws ArchitectException { return null; } }; db.setDataSource(fakeDataSource); db.setPopulated(true); ((SQLObject) dbTreeModel.getRoot()).addChild(db); Set<String> propertiesToIgnore = new HashSet<String>(); propertiesToIgnore.add("SQLObjectListeners"); propertiesToIgnore.add("children"); propertiesToIgnore.add("tables"); propertiesToIgnore.add("parent"); propertiesToIgnore.add("parentDatabase"); propertiesToIgnore.add("class"); propertiesToIgnore.add("childCount"); propertiesToIgnore.add("connection"); propertiesToIgnore.add("populated"); propertiesToIgnore.add("secondaryChangeMode"); propertiesToIgnore.add("dataSource"); // we set this already! propertiesToIgnore.add("ignoreReset"); // only used (and set) by playpen code propertiesToIgnore.add("progressMonitor"); Map<String,Object> oldDescription = setAllInterestingProperties(db, propertiesToIgnore); File tmp = File.createTempFile("test", ".architect"); if (deleteOnExit) { tmp.deleteOnExit(); } PrintWriter out = new PrintWriter(tmp,ENCODING); assertNotNull(out); project.save(out,ENCODING); SwingUIProject project2 = new SwingUIProject("new test project"); project2.load(new BufferedInputStream(new FileInputStream(tmp))); // grab the second database in the dbtree's model (the first is the play pen) db = (SQLDatabase) project2.getSourceDatabases().getDatabaseList().get(1); Map<String, Object> newDescription = getAllInterestingProperties(db, propertiesToIgnore); assertEquals("loaded-in version of database doesn't match the original!", oldDescription.toString(), newDescription.toString()); }
propertiesToIgnore.add("zoomInAction"); propertiesToIgnore.add("zoomOutAction");
public void testSaveCoversAllDatabaseProperties() throws Exception { testLoad(); DBTree dbTree = project.getSourceDatabases(); DBTreeModel dbTreeModel = (DBTreeModel) dbTree.getModel(); ArchitectDataSource fakeDataSource = new ArchitectDataSource(); SQLDatabase db = new SQLDatabase() { @Override public Connection getConnection() throws ArchitectException { return null; } }; db.setDataSource(fakeDataSource); db.setPopulated(true); ((SQLObject) dbTreeModel.getRoot()).addChild(db); Set<String> propertiesToIgnore = new HashSet<String>(); propertiesToIgnore.add("SQLObjectListeners"); propertiesToIgnore.add("children"); propertiesToIgnore.add("tables"); propertiesToIgnore.add("parent"); propertiesToIgnore.add("parentDatabase"); propertiesToIgnore.add("class"); propertiesToIgnore.add("childCount"); propertiesToIgnore.add("connection"); propertiesToIgnore.add("populated"); propertiesToIgnore.add("secondaryChangeMode"); propertiesToIgnore.add("dataSource"); // we set this already! propertiesToIgnore.add("ignoreReset"); // only used (and set) by playpen code propertiesToIgnore.add("progressMonitor"); Map<String,Object> oldDescription = setAllInterestingProperties(db, propertiesToIgnore); File tmp = File.createTempFile("test", ".architect"); if (deleteOnExit) { tmp.deleteOnExit(); } PrintWriter out = new PrintWriter(tmp,ENCODING); assertNotNull(out); project.save(out,ENCODING); SwingUIProject project2 = new SwingUIProject("new test project"); project2.load(new BufferedInputStream(new FileInputStream(tmp))); // grab the second database in the dbtree's model (the first is the play pen) db = (SQLDatabase) project2.getSourceDatabases().getDatabaseList().get(1); Map<String, Object> newDescription = getAllInterestingProperties(db, propertiesToIgnore); assertEquals("loaded-in version of database doesn't match the original!", oldDescription.toString(), newDescription.toString()); }
put(PL_LOGICAL, argDisplayName);
putImpl(PL_LOGICAL, argDisplayName, "displayName");
public void setDisplayName(String argDisplayName){ put(PL_LOGICAL, argDisplayName); }
put(DBCS_DRIVER_CLASS, argDriverClass);
putImpl(DBCS_DRIVER_CLASS, argDriverClass, "driverClass");
public void setDriverClass(String argDriverClass){ put(DBCS_DRIVER_CLASS, argDriverClass); }
public void setUser(String argUser){ put(PL_UID, argUser);
public void setUser(String argUser) { putImpl(PL_UID, argUser, "user");
public void setUser(String argUser){ put(PL_UID, argUser); }
put(PL_PWD, argPass);
putImpl(PL_PWD, argPass, "pass");
public void setPass(String argPass){ put(PL_PWD, argPass); }
put(DBCS_URL, argUrl);
putImpl(DBCS_URL, argUrl, "url");
public void setUrl(String argUrl) { put(DBCS_URL, argUrl); }
public SQLCatalog(SQLDatabase parent, String name) { this.parent = parent; setName(name); this.children = new LinkedList(); this.nativeTerm = "catalog";
public SQLCatalog() { this(null, null);
public SQLCatalog(SQLDatabase parent, String name) { this.parent = parent; setName(name); this.children = new LinkedList(); this.nativeTerm = "catalog"; }
public void save(PrintWriter out, String encoding) throws IOException, ArchitectException { objectIdMap = new HashMap(); dbcsIdMap = new HashMap(); indent = 0;
public void save(ProgressMonitor pm) throws IOException, ArchitectException { if (file.exists() && !file.canWrite()) { throw new ArchitectException("problem saving project -- " + "cannot write to architect file: " + file.getAbsolutePath()); }
public void save(PrintWriter out, String encoding) throws IOException, ArchitectException { objectIdMap = new HashMap(); dbcsIdMap = new HashMap(); indent = 0; try { println(out, "<?xml version=\"1.0\" encoding=\""+encoding+"\"?>"); println(out, "<architect-project version=\"1.0\" appversion=\""+ArchitectUtils.APP_VERSION+"\">"); indent++; println(out, "<project-name>"+ArchitectUtils.escapeXML(name)+"</project-name>"); saveDataSources(out); saveSourceDatabases(out); saveTargetDatabase(out); saveDDLGenerator(out); saveCompareDMSettings(out); savePlayPen(out); saveProfiles(out); indent--; println(out, "</architect-project>"); setModified(false); } finally { if (out != null) out.close(); } }
println(out, "<?xml version=\"1.0\" encoding=\""+encoding+"\"?>"); println(out, "<architect-project version=\"1.0\" appversion=\""+ArchitectUtils.APP_VERSION+"\">"); indent++; println(out, "<project-name>"+ArchitectUtils.escapeXML(name)+"</project-name>"); saveDataSources(out); saveSourceDatabases(out); saveTargetDatabase(out); saveDDLGenerator(out); saveCompareDMSettings(out); savePlayPen(out); saveProfiles(out); indent--; println(out, "</architect-project>"); setModified(false); } finally { if (out != null) out.close();
out = new PrintWriter(tempFile,encoding); } catch (IOException e) { throw new ArchitectException("Unable to create output file for save operation, data NOT saved.\n" + e, e);
public void save(PrintWriter out, String encoding) throws IOException, ArchitectException { objectIdMap = new HashMap(); dbcsIdMap = new HashMap(); indent = 0; try { println(out, "<?xml version=\"1.0\" encoding=\""+encoding+"\"?>"); println(out, "<architect-project version=\"1.0\" appversion=\""+ArchitectUtils.APP_VERSION+"\">"); indent++; println(out, "<project-name>"+ArchitectUtils.escapeXML(name)+"</project-name>"); saveDataSources(out); saveSourceDatabases(out); saveTargetDatabase(out); saveDDLGenerator(out); saveCompareDMSettings(out); savePlayPen(out); saveProfiles(out); indent--; println(out, "</architect-project>"); setModified(false); } finally { if (out != null) out.close(); } }
progress = 0; this.pm = pm; if (pm != null) { int pmMax = 0; pm.setMinimum(0); if (savingEntireSource) { pmMax = ArchitectUtils.countTablesSnapshot((SQLObject) sourceDatabases.getModel().getRoot()); } else { pmMax = ArchitectUtils.countTables((SQLObject) sourceDatabases.getModel().getRoot()); } logger.error("Setting progress monitor maximum to "+pmMax); pm.setMaximum(pmMax); pm.setProgress(progress); pm.setMillisToDecideToPopup(0); } save(out,encoding); out = null; if (pm != null) pm.close(); pm = null; boolean fstatus = false; fstatus = backupFile.delete(); logger.debug("deleting backup~ file: " + fstatus); if (file.exists()) { fstatus = file.renameTo(backupFile); logger.debug("rename current file to backupFile: " + fstatus); if (!fstatus) { throw new ArchitectException(( "Could not rename current file to backup\nProject saved in " + tempFile + ": " + file + " still contains old project")); } } fstatus = tempFile.renameTo(file); if (!fstatus) { throw new ArchitectException(( "Could not rename temp file to current\nProject saved in " + tempFile + ": " + file + " still contains old project")); } logger.debug("rename tempFile to current file: " + fstatus);
public void save(PrintWriter out, String encoding) throws IOException, ArchitectException { objectIdMap = new HashMap(); dbcsIdMap = new HashMap(); indent = 0; try { println(out, "<?xml version=\"1.0\" encoding=\""+encoding+"\"?>"); println(out, "<architect-project version=\"1.0\" appversion=\""+ArchitectUtils.APP_VERSION+"\">"); indent++; println(out, "<project-name>"+ArchitectUtils.escapeXML(name)+"</project-name>"); saveDataSources(out); saveSourceDatabases(out); saveTargetDatabase(out); saveDDLGenerator(out); saveCompareDMSettings(out); savePlayPen(out); saveProfiles(out); indent--; println(out, "</architect-project>"); setModified(false); } finally { if (out != null) out.close(); } }
if (! loadedProperties) { loadedProperties = true; loadJellyProperties(); }
public Script compileScript() throws Exception { XMLParser parser = new XMLParser(); parser.setContext(getJellyContext()); Script script = parser.parse(getUrl().openStream()); script = script.compile(); if (log.isDebugEnabled()) { log.debug("Compiled script: " + getUrl()); } return script; }
public static XMLOutput createXMLOutput(Writer writer) { return createXMLOutput(writer, DEFAULT_ESCAPE_TEXT);
public static XMLOutput createXMLOutput(XMLReader xmlReader) { XMLOutput output = new XMLOutput(xmlReader.getContentHandler()); for (int i = 0; i < LEXICAL_HANDLER_NAMES.length; i++) { try { Object value = xmlReader.getProperty(LEXICAL_HANDLER_NAMES[i]); if (value instanceof LexicalHandler) { output.setLexicalHandler((LexicalHandler) value); break; } } catch (Exception e) { if (log.isDebugEnabled()) { log.debug("error setting lexical handler properties", e); } } } return output;
public static XMLOutput createXMLOutput(Writer writer) { return createXMLOutput(writer, DEFAULT_ESCAPE_TEXT); }
public Volume( String volName, String volBaseDir ) { super( volName, volBaseDir );
public Volume() {
public Volume( String volName, String volBaseDir ) { super( volName, volBaseDir ); }
SQLColumn col = (SQLColumn) columnsFolder.getChild(oldIdx); removeColumn(oldIdx); addColumn(newIdx, col);
SQLColumn col = (SQLColumn) columnsFolder.children.remove(oldIdx); columnsFolder.fireDbChildRemoved(oldIdx, col); columnsFolder.children.add(newIdx, col); if (newIdx == 0 || ((SQLColumn) columnsFolder.children.get(newIdx-1)).primaryKeySeq != null) { col.primaryKeySeq = new Integer(1); } normalizePrimaryKey(); columnsFolder.fireDbChildInserted(newIdx, col);
public void changeColumnIndex(int oldIdx, int newIdx) throws ArchitectException { // this old way didn't cause any events// SQLColumn col = (SQLColumn) columnsFolder.children.remove(oldIdx);// columnsFolder.children.add(newIdx, col);// if (newIdx == 0// || ((SQLColumn) columnsFolder.children.get(newIdx-1)).primaryKeySeq != null) {// col.primaryKeySeq = new Integer(1); // will get sane value when normalized// }// normalizePrimaryKey(); SQLColumn col = (SQLColumn) columnsFolder.getChild(oldIdx); removeColumn(oldIdx); addColumn(newIdx, col); }
public SQLSchema(SQLObject parent, String name) { this.parent = parent; this.schemaName = name; this.children = new LinkedList(); this.nativeTerm = "schema";
public SQLSchema() { this(null, null);
public SQLSchema(SQLObject parent, String name) { this.parent = parent; this.schemaName = name; this.children = new LinkedList(); this.nativeTerm = "schema"; }
/* TODO This is not used to be replace with an XML format later
/* TODO This is not used. To be replace with an XML format later
static void addColumnsToTable(SQLTable addTo, String catalog, String schema, String tableName) throws SQLException, DuplicateColumnException, ArchitectException { Connection con = null; ResultSet rs = null; try { con = addTo.getParentDatabase().getConnection(); DatabaseMetaData dbmd = con.getMetaData(); logger.debug("SQLColumn.addColumnsToTable: catalog="+catalog+"; schema="+schema+"; tableName="+tableName); rs = dbmd.getColumns(catalog, schema, tableName, "%"); while (rs.next()) { logger.debug("addColumnsToTable SQLColumn constructor invocation."); SQLColumn col = new SQLColumn(addTo, rs.getString(4), // col name rs.getInt(5), // data type (from java.sql.Types) rs.getString(6), // native type name rs.getInt(7), // column size (precision) rs.getInt(9), // decimal size (scale) rs.getInt(11), // nullable rs.getString(12) == null ? "" : rs.getString(12), // remarks rs.getString(13), // default value null, // primaryKeySeq false // isAutoIncrement ); // work around oracle 8i bug: when table names are long and similar, // getColumns() sometimes returns columns from multiple tables! String dbTableName = rs.getString(3); if (dbTableName != null) { if (!dbTableName.equalsIgnoreCase(tableName)) { logger.warn("Got column "+col.getName()+" from "+dbTableName +" in metadata for "+tableName+"; not adding this column."); continue; } } else { logger.warn("Table name not specified in metadata. Continuing anyway..."); } logger.debug("Adding column "+col.getName()); if (addTo.getColumnByName(col.getName(), false) != null) { throw new DuplicateColumnException(addTo, col.getName()); } // do any database specific transformations required for this column /* TODO This is not used to be replace with an XML format later if(TypeMap.getInstance().applyRules(col)) { logger.debug("Applied mapppings to column: " + col); } */ addTo.columnsFolder.children.add(col); // don't use addTo.columnsFolder.addColumn() (avoids multiple SQLObjectEvents) // XXX: need to find out if column is auto-increment } rs.close(); rs = null; rs = dbmd.getPrimaryKeys(catalog, schema, tableName); while (rs.next()) { SQLColumn col = addTo.getColumnByName(rs.getString(4), false); col.primaryKeySeq = new Integer(rs.getInt(5)); addTo.setPrimaryKeyName(rs.getString(6)); } rs.close(); rs = null; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't close result set", ex); } try { if (con != null) con.close(); } catch (SQLException ex) { logger.error("Couldn't close connection", ex); } } }
col.primaryKeySeq = new Integer(rs.getInt(5)); addTo.setPrimaryKeyName(rs.getString(6));
if (col != null ){ col.primaryKeySeq = new Integer(rs.getInt(5)); addTo.setPrimaryKeyName(rs.getString(6)); } else { SQLException exception = new SQLException("Column "+rs.getString(4)+ " not found in "+addTo); throw exception; }
static void addColumnsToTable(SQLTable addTo, String catalog, String schema, String tableName) throws SQLException, DuplicateColumnException, ArchitectException { Connection con = null; ResultSet rs = null; try { con = addTo.getParentDatabase().getConnection(); DatabaseMetaData dbmd = con.getMetaData(); logger.debug("SQLColumn.addColumnsToTable: catalog="+catalog+"; schema="+schema+"; tableName="+tableName); rs = dbmd.getColumns(catalog, schema, tableName, "%"); while (rs.next()) { logger.debug("addColumnsToTable SQLColumn constructor invocation."); SQLColumn col = new SQLColumn(addTo, rs.getString(4), // col name rs.getInt(5), // data type (from java.sql.Types) rs.getString(6), // native type name rs.getInt(7), // column size (precision) rs.getInt(9), // decimal size (scale) rs.getInt(11), // nullable rs.getString(12) == null ? "" : rs.getString(12), // remarks rs.getString(13), // default value null, // primaryKeySeq false // isAutoIncrement ); // work around oracle 8i bug: when table names are long and similar, // getColumns() sometimes returns columns from multiple tables! String dbTableName = rs.getString(3); if (dbTableName != null) { if (!dbTableName.equalsIgnoreCase(tableName)) { logger.warn("Got column "+col.getName()+" from "+dbTableName +" in metadata for "+tableName+"; not adding this column."); continue; } } else { logger.warn("Table name not specified in metadata. Continuing anyway..."); } logger.debug("Adding column "+col.getName()); if (addTo.getColumnByName(col.getName(), false) != null) { throw new DuplicateColumnException(addTo, col.getName()); } // do any database specific transformations required for this column /* TODO This is not used to be replace with an XML format later if(TypeMap.getInstance().applyRules(col)) { logger.debug("Applied mapppings to column: " + col); } */ addTo.columnsFolder.children.add(col); // don't use addTo.columnsFolder.addColumn() (avoids multiple SQLObjectEvents) // XXX: need to find out if column is auto-increment } rs.close(); rs = null; rs = dbmd.getPrimaryKeys(catalog, schema, tableName); while (rs.next()) { SQLColumn col = addTo.getColumnByName(rs.getString(4), false); col.primaryKeySeq = new Integer(rs.getInt(5)); addTo.setPrimaryKeyName(rs.getString(6)); } rs.close(); rs = null; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't close result set", ex); } try { if (con != null) con.close(); } catch (SQLException ex) { logger.error("Couldn't close connection", ex); } } }
public boolean removeChild(SQLObject child) { int childIdx = children.indexOf(child); if (childIdx >= 0) { children.remove(childIdx); fireDbChildRemoved(childIdx, child); } return childIdx >= 0;
public SQLObject removeChild(int index) { SQLObject removedChild = (SQLObject) children.remove(index); if (removedChild != null) fireDbChildRemoved(index, removedChild); return removedChild;
public boolean removeChild(SQLObject child) { int childIdx = children.indexOf(child); if (childIdx >= 0) { children.remove(childIdx); fireDbChildRemoved(childIdx, child); } return childIdx >= 0; }
public LockedColumnException(SQLRelationship lockingRelationship) {
public LockedColumnException(SQLRelationship lockingRelationship, SQLColumn col) {
public LockedColumnException(SQLRelationship lockingRelationship) { super("Locked column belongs to relationship "+lockingRelationship); this.lockingRelationship = lockingRelationship; }
this.col = col;
public LockedColumnException(SQLRelationship lockingRelationship) { super("Locked column belongs to relationship "+lockingRelationship); this.lockingRelationship = lockingRelationship; }
if (logger.isDebugEnabled()) { logger.debug("Sending dbObjectChanged event "+e+" to " +getSQLObjectListeners().size()+" listeners: " +getSQLObjectListeners()); }
protected void fireDbObjectChanged(String propertyName) { SQLObjectEvent e = new SQLObjectEvent(this, propertyName); Iterator it = getSQLObjectListeners().iterator(); while (it.hasNext()) { ((SQLObjectListener) it.next()).dbObjectChanged(e); } }
SQLDatabase mydb = new SQLDatabase(ds); Connection conn = null; Statement stmt = null; String lastSQL = null; try { conn = mydb.getConnection(); stmt = conn.createStatement(); try { stmt.executeUpdate("DROP TABLE PROFILE_TEST1"); stmt.executeUpdate("DROP TABLE PROFILE_TEST2"); stmt.executeUpdate("DROP TABLE PROFILE_TEST3"); } catch (SQLException sqle) { System.out.println("+++ TestProfile exception should be for dropping a non-existant table"); sqle.printStackTrace(); } lastSQL = "CREATE TABLE PROFILE_TEST1 (t1_c1 char(100), t1_c2 date, t1_c4 decimal, t1_c5 float, t1_c6 int, t1_c8 long, t1_c10 raw(300), t1_c11 number(12,2), t1_c13 numeric(10), t1_c14 real, t1_c15 smallint, t1_c16 varchar(200), t1_c17 varchar2(120))"; stmt.executeUpdate(lastSQL); lastSQL = "CREATE TABLE PROFILE_TEST2 (t2_c1 char(100), t2_c2 date, t2_c4 decimal, t2_c5 float, t2_c6 int, t2_c9 long raw, t2_c10 raw(400), t2_c11 number(12,2), t2_c13 numeric(10), t2_c14 real, t2_c15 smallint, t2_c16 varchar(200), t2_c17 varchar2(120))"; stmt.executeUpdate(lastSQL); lastSQL = "CREATE TABLE PROFILE_TEST3 (t3_c1 char(100), t3_c2 date, t3_c4 decimal, t3_c5 float, t3_c6 int, t3_c9 long raw, t3_c10 raw(500), t3_c11 number(12,2), t3_c13 numeric(10), t3_c14 real, t3_c15 smallint, t3_c16 varchar(200), t3_c17 varchar2(120))"; stmt.executeUpdate(lastSQL); lastSQL = "Insert into PROFILE_TEST1 values ('abc12345678901234567890a', to_date('26-jul-2006 11:22:33','dd-mon-yyyy hh24:mi:ss'), 12345.6789, 23456.789, 987654321, 1234567890, '5B5261775F446174615D', 1234567.89, 123456789, 567.89, 321, 'column of varchar 200 aaa', 'column of varchar2 200 xxx')"; stmt.executeUpdate(lastSQL); lastSQL = "Insert into PROFILE_TEST1 values ('abc12345678901234567890b', to_date('26-jul-2006 11:22:34','dd-mon-yyyy hh24:mi:ss'), 22345.6789, 33456.789, 987654322, 1234567891, '6B5261775F446174615D', 2234567.89, 1234567890, 667.89, 3212, 'column of varchar 200 bbb', 'column of varchar2 200 yyy')"; stmt.executeUpdate(lastSQL); lastSQL = "Insert into PROFILE_TEST1 values ('abc12345678901234567890c', to_date('26-jul-2006 11:22:35','dd-mon-yyyy hh24:mi:ss'), 32345.6789, 43456.789, 987654323, 1234567892, '8B526146174615D', 3234567.89, 1234567891, 767.89, 32123, 'column of varchar 200 ccc', 'column of varchar2 200 zzz')"; stmt.executeUpdate(lastSQL); lastSQL = "Insert into PROFILE_TEST1 values ('abc12345678901234567890d', to_date('26-jul-2006 11:22:36','dd-mon-yyyy hh24:mi:ss'), 42345.6789, 53456.789, 987654324, 1234567893, '8B526146174615D', 4234567.89, 1234567892, 867.89, 32124, 'column of varchar 200 ddd', 'column of varchar2 200 sss')"; stmt.executeUpdate(lastSQL); lastSQL = "Insert into PROFILE_TEST1 values ('abc12345678901234567890e', to_date('26-jul-2006 11:22:37','dd-mon-yyyy hh24:mi:ss'), 52345.6789, 63456.789, 987654325, 1234567894, '9B52616174615D',5234567.89, 1234567893, 967.89, 32125, 'column of varchar 200 eee', 'column of varchar2 200 ddd')"; stmt.executeUpdate(lastSQL); lastSQL = "Insert into PROFILE_TEST2 values ('abc12345678901234567890a', to_date('26-jul-2006 11:22:33','dd-mon-yyyy hh24:mi:ss'), 12345.6789, 23456.789, 987654321, '1234567890', '5B5261775F446174615D', 1234567.89, 123456789, 567.89, 321, 'column of varchar 200 aaa', 'column of varchar2 200 xxx')"; stmt.executeUpdate(lastSQL); lastSQL = "Insert into PROFILE_TEST2 values ('', to_date('26-jul-2006 11:22:34','dd-mon-yyyy hh24:mi:ss'), 22345.6789, 33456.789, 987654322, NULL, '6B5261775F446174615D', 2234567.89, 1234567890, 667.89, 3212, 'column of varchar 200 bbb', 'column of varchar2 200 yyy')"; stmt.executeUpdate(lastSQL); lastSQL = "Insert into PROFILE_TEST2 values (NULL, to_date('26-jul-2006 11:22:35','dd-mon-yyyy hh24:mi:ss'), 32345.6789, 43456.789, 987654323, '1234567892', '6B5261775F446174615D', 3234567.89, NULL, 767.89, 32123, NULL, 'column of varchar2 200 zzz')"; stmt.executeUpdate(lastSQL); lastSQL = "Insert into PROFILE_TEST2 values ('abcd', NULL, NULL, NULL, NULL, '1234567', '8B5261775F446174615D', 4234567.89, 1234567892, 867.89, 32124, 'column of var', 'column of varchar2 200 sss')"; stmt.executeUpdate(lastSQL); lastSQL = "Insert into PROFILE_TEST2 values ('1234567890', to_date('26-jul-2006 11:22:37','dd-mon-yyyy hh24:mi:ss'), 52345.6789, NULL, 987654325, NULL, null, 5234567.89, 1234567893, 967.89, NULL, 'col', 'column of varchar2 200 ddd')"; stmt.executeUpdate(lastSQL); conn.commit(); List tableList = new ArrayList(); for ( int i=1; i<4; i++ ) { SQLTable t = mydb.getTableByName("PROFILE_TEST"+i); tableList.add(t); } ProfileManager pm = new ProfileManager(); pm.setFindingAvg(true); pm.setFindingMin(true); pm.setFindingMax(true); pm.setFindingMinLength(true); pm.setFindingMaxLength(true); pm.setFindingAvgLength(true); pm.setFindingDistinctCount(true); pm.setFindingNullCount(true); pm.createProfiles(tableList); for ( int i=1; i<4; i++ ) { SQLTable t = mydb.getTableByName("PROFILE_TEST"+i); ProfileResult pr = pm.getResult(t); System.out.println(t.getName()+" "+pr.toString()); for ( SQLColumn c : t.getColumns() ) { pr = pm.getResult(c); System.out.println(c.getName()+"["+c.getSourceDataTypeName()+"] "+pr); } } } catch (ArchitectException e) { e.printStackTrace(); } catch (SQLException e) { System.out.println("Error in SQL query: "+lastSQL); e.printStackTrace(); } finally { try { if (stmt != null) stmt.close(); } catch (SQLException e) { System.out.println("Couldn't close statement"); } try { if (conn != null) conn.close(); } catch (SQLException e) { System.out.println("Couldn't close connection"); } mydb.disconnect(); }
public void testProfileManager() throws IOException { ArchitectFrame.getMainInstance(); // creates an ArchitectFrame, which loads settings //FIXME: a better approach would be to have an initialsation method // in the business model, which does not depend on the init routine in ArchitectFrame. PlDotIni plini = new PlDotIni(); plini.read(new File("pl.regression.ini")); ArchitectDataSource ds = plini.getDataSource("regression_test"); }
String tagName,
TagScript tagScript,
public Expression createExpression( ExpressionFactory factory, String tagName, String attributeName, String attributeValue) throws Exception { // #### may need to include some namespace URI information in the XPath instance? if (attributeName.equals("xpath")) { if ( log.isDebugEnabled() ) { log.debug( "Parsing XPath expression: " + attributeValue ); } try { XPath xpath = new Dom4jXPath(attributeValue); return new XPathExpression(xpath); } catch (JaxenException e) { throw new JellyException( "Could not parse XPath expression: \"" + attributeValue + "\" reason: " + e, e ); } } // will use the default expression instead return super.createExpression(factory, tagName, attributeName, attributeValue); }
return new XPathExpression(xpath);
return new XPathExpression(xpath, tagScript);
public Expression createExpression( ExpressionFactory factory, String tagName, String attributeName, String attributeValue) throws Exception { // #### may need to include some namespace URI information in the XPath instance? if (attributeName.equals("xpath")) { if ( log.isDebugEnabled() ) { log.debug( "Parsing XPath expression: " + attributeValue ); } try { XPath xpath = new Dom4jXPath(attributeValue); return new XPathExpression(xpath); } catch (JaxenException e) { throw new JellyException( "Could not parse XPath expression: \"" + attributeValue + "\" reason: " + e, e ); } } // will use the default expression instead return super.createExpression(factory, tagName, attributeName, attributeValue); }
return super.createExpression(factory, tagName, attributeName, attributeValue);
return super.createExpression(factory, tagScript, attributeName, attributeValue);
public Expression createExpression( ExpressionFactory factory, String tagName, String attributeName, String attributeValue) throws Exception { // #### may need to include some namespace URI information in the XPath instance? if (attributeName.equals("xpath")) { if ( log.isDebugEnabled() ) { log.debug( "Parsing XPath expression: " + attributeValue ); } try { XPath xpath = new Dom4jXPath(attributeValue); return new XPathExpression(xpath); } catch (JaxenException e) { throw new JellyException( "Could not parse XPath expression: \"" + attributeValue + "\" reason: " + e, e ); } } // will use the default expression instead return super.createExpression(factory, tagName, attributeName, attributeValue); }
System.out.println(TITLE_STRING + " command line options\n" + "-h, -help print this message\n" + "-n command line output only\n" + "-q quiet mode- doesnt print any warnings or information to screen\n" + "-p <pedfile> specify an input file in pedigree file format\n" + " pedfile specific options (nogui mode only): \n" + " --showcheck displays the results of the various pedigree integrity checks\n" + " --skipcheck skips the various pedfile checks\n" + "-a <hapmapfile> specify an input file in HapMap format\n" + "-l <hapsfile> specify an input file in .haps format\n" + "-i <infofile> specify a marker info file\n" + "-b <batchfile> batch mode. batchfile should contain a list of files either all genotype or alternating genotype/info\n" + "-k <blockfile> blocks file, one block per line, will force output for these blocks\n" + "-d outputs dprime to <inputfile>.DPRIME\n" + "-c outputs marker checks to <inputfile>.CHECK\n" + " note: -d and -c default to no blocks output. use -o to also output blocks\n" + "-o <GAB,GAM,SPI,ALL> output type. Gabriel, 4 gamete, spine output or all 3. default is Gabriel.\n" + "-m <distance> maximum comparison distance in kilobases (integer). default is 500");
System.out.println(HELP_OUTPUT);
private void argHandler(String[] args){ //TODO: -specify values from HaplotypeDisplayController (min hap percentage etc) // -want to be able to output haps file from pedfile boolean nogui = false; String batchMode = ""; String hapsFileName = ""; String pedFileName = ""; String infoFileName = ""; String hapmapFileName = ""; String blockFileName = ""; boolean showCheck = false; boolean skipCheck = false; Vector ignoreMarkers = new Vector(); int outputType = -1; int maxDistance = -1; boolean quietMode = false; boolean outputDprime=false; boolean outputCheck=false; for(int i =0; i < args.length; i++) { if(args[i].equals("-help") || args[i].equals("-h")) { System.out.println(TITLE_STRING + " command line options\n" + "-h, -help print this message\n" + "-n command line output only\n" + "-q quiet mode- doesnt print any warnings or information to screen\n" + "-p <pedfile> specify an input file in pedigree file format\n" + " pedfile specific options (nogui mode only): \n" + " --showcheck displays the results of the various pedigree integrity checks\n" + " --skipcheck skips the various pedfile checks\n" + //TODO: fix ignoremarkers //" --ignoremarkers <markers> ignores the specified markers.<markers> is a comma\n" + //" seperated list of markers. eg. 1,5,7,19,25\n" + "-a <hapmapfile> specify an input file in HapMap format\n" + "-l <hapsfile> specify an input file in .haps format\n" + "-i <infofile> specify a marker info file\n" + "-b <batchfile> batch mode. batchfile should contain a list of files either all genotype or alternating genotype/info\n" + "-k <blockfile> blocks file, one block per line, will force output for these blocks\n" + "-d outputs dprime to <inputfile>.DPRIME\n" + "-c outputs marker checks to <inputfile>.CHECK\n" + " note: -d and -c default to no blocks output. use -o to also output blocks\n" + "-o <GAB,GAM,SPI,ALL> output type. Gabriel, 4 gamete, spine output or all 3. default is Gabriel.\n" + "-m <distance> maximum comparison distance in kilobases (integer). default is 500"); System.exit(0); } else if(args[i].equals("-n")) { nogui = true; } else if(args[i].equals("-p")) { i++; if( i>=args.length || (args[i].charAt(0) == '-') || args[i].equals("showcheck") ){ System.out.println("-p requires a filename"); System.exit(1); } else{ if(!pedFileName.equals("")){ System.out.println("multiple -p arguments found. only last pedfile listed will be used"); } pedFileName = args[i]; } } else if (args[i].equals("--showcheck")){ showCheck = true; } else if (args[i].equals("--skipcheck")){ skipCheck = true; } /* else if (args[i].equals("--ignoremarkers")){ i++; if(i>=args.length || (args[i].charAt(0) == '-')){ System.out.println("--ignoremarkers requires a list of markers"); System.exit(1); } else { StringTokenizer str = new StringTokenizer(args[i],","); while(str.hasMoreTokens()) { ignoreMarkers.add(str.nextToken()); } } } */ else if(args[i].equals("-ha") || args[i].equals("-l")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-ha requires a filename"); System.exit(1); } else{ if(!hapsFileName.equals("")){ System.out.println("multiple -ha arguments found. only last haps file listed will be used"); } hapsFileName = args[i]; } } else if(args[i].equals("-i")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-i requires a filename"); System.exit(1); } else{ if(!infoFileName.equals("")){ System.out.println("multiple -i arguments found. only last info file listed will be used"); } infoFileName = args[i]; } } else if (args[i].equals("-a")){ i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-a requires a filename"); System.exit(1); } else{ if(!hapmapFileName.equals("")){ System.out.println("multiple -a arguments found. only last hapmap file listed will be used"); } hapmapFileName = args[i]; } } else if(args[i].equals("-k")) { i++; if (!(i>=args.length) && !((args[i].charAt(0)) == '-')){ blockFileName = args[i]; outputType = BLOX_CUSTOM; }else{ System.out.println("-k requires a filename"); System.exit(1); } } else if(args[i].equals("-o")) { i++; if(!(i>=args.length) && !((args[i].charAt(0)) == '-')){ if(outputType != -1){ System.out.println("only one output argument is allowed"); System.exit(1); } if(args[i].equals("SFS") || args[i].equals("GAB")){ outputType = BLOX_GABRIEL; } else if(args[i].equals("GAM")){ outputType = BLOX_4GAM; } else if(args[i].equals("MJD") || args[i].equals("SPI")){ outputType = BLOX_SPINE; } else if(args[i].equals("ALL")) { outputType = BLOX_ALL; } } else { //defaults to SFS output outputType = BLOX_GABRIEL; i--; } } else if(args[i].equals("-d") || args[i].equals("--dprime")) { outputDprime = true; } else if (args[i].equals("-c")){ outputCheck = true; } else if(args[i].equals("-m")) { i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-m requires an integer argument"); System.exit(1); } else { if(maxDistance != -1){ System.out.println("only one -m argument allowed"); System.exit(1); } maxDistance = Integer.parseInt(args[i]); if(maxDistance<0){ System.out.println("-m argument must be a positive integer"); System.exit(1); } } } else if(args[i].equals("-b")) { //batch mode i++; if(i>=args.length || ((args[i].charAt(0)) == '-')){ System.out.println("-b requires a filename"); System.exit(1); } else{ if(!batchMode.equals("")){ System.out.println("multiple -b arguments found. only last batch file listed will be used"); } batchMode = args[i]; } } else if(args[i].equals("-q")) { quietMode = true; } else { System.out.println("invalid parameter specified: " + args[i]); } } //mess with vars, set defaults, etc if( outputType == -1 && ( !pedFileName.equals("") || !hapsFileName.equals("") || !batchMode.equals("") || !hapmapFileName.equals("")) && !outputDprime && !outputCheck) { outputType = BLOX_GABRIEL; if(nogui && !quietMode) { System.out.println("No output type specified. Default of Gabriel will be used"); } } if(showCheck && !nogui && !quietMode) { System.out.println("pedfile showcheck option only applies in nogui mode. ignored."); } if(skipCheck && !quietMode) { System.out.println("Skipping pedigree file check"); } if(maxDistance == -1){ maxDistance = 500; } //set the global variables arg_nogui = nogui; arg_hapsfile = hapsFileName; arg_infoFileName = infoFileName; arg_pedfile = pedFileName; arg_hapmapfile = hapmapFileName; arg_blockfile = blockFileName; arg_showCheck = showCheck; arg_skipCheck = skipCheck; arg_ignoreMarkers = ignoreMarkers; arg_output = outputType; arg_distance = maxDistance; arg_batchMode = batchMode; arg_quiet = quietMode; arg_dprime = outputDprime; arg_check = outputCheck; }
textData.prepareMarkerInput(infoFile,maxDistance,textData.getPedFile().getHMInfo());
if (result != null){ textData.prepareMarkerInput(infoFile,maxDistance,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,maxDistance,null); }
private void processFile(String fileName,int fileType,String infoFileName){ System.out.println(TITLE_STRING); try { int outputType; long maxDistance; HaploData textData; File OutputFile; File inputFile; inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } maxDistance = this.arg_distance * 1000; outputType = this.arg_output; textData = new HaploData(0); Vector result = null; if(fileType == 0){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == 1) { //read in ped file /* if(this.arg_ignoreMarkers.size()>0) { for(int i=0;i<this.arg_ignoreMarkers.size();i++){ int index = Integer.parseInt((String)this.arg_ignoreMarkers.get(i)); if(index>0 && index<markerResultArray.length){ markerResultArray[index] = false; if(!this.arg_quiet) { System.out.println("Ignoring marker " + (index)); } } } }*/ result = textData.linkageToChrom(inputFile, 3, arg_skipCheck); }else{ //read in hapmapfile result = textData.linkageToChrom(inputFile,4,arg_skipCheck); } File infoFile; if(infoFileName.equals("")) { infoFile = null; }else{ infoFile = new File(infoFileName); } textData.prepareMarkerInput(infoFile,maxDistance,textData.getPedFile().getHMInfo()); if(!arg_quiet && infoFile != null){ System.out.println("Using marker file " + infoFile.getName()); } textData.infoKnown = true; if(this.arg_showCheck && result != null) { CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(null); } if(this.arg_check && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(new File (fileName + ".CHECK")); } Vector cust = new Vector(); if(outputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; switch(outputType){ case BLOX_GABRIEL: OutputFile = new File(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = new File(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = new File(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = new File(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(arg_blockfile); cust = textData.readBlocks(blocksFile); break; default: OutputFile = new File(fileName + ".GABRIELblocks"); break; } //this handles output type ALL int start = 0; int stop = Chromosome.getFilteredSize(); if(outputType == BLOX_ALL) { OutputFile = new File(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); OutputFile = new File(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); }else{ textData.guessBlocks(outputType, cust); haplos = textData.generateHaplotypes(textData.blocks, 1); textData.saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } } if(this.arg_dprime) { OutputFile = new File(fileName + ".DPRIME"); if (textData.filteredDPrimeTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getFilteredSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getFilteredSize()); } } //if(fileType){ //TDT.calcTrioTDT(textData.chromosomes); //TODO: Deal with this. why do we calc TDT? and make sure not to do it except when appropriate //} } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } }
for(int i=0;i<forceIncludeTags.size();i++) { if(snpsByName.containsKey(forceIncludeTags.get(i))) { whiteListedCustomMarkers.add(snpsByName.get(forceIncludeTags.get(i)));
if(forceIncludeTags != null) { for(int i=0;i<forceIncludeTags.size();i++) { if(snpsByName.containsKey(forceIncludeTags.get(i))) { whiteListedCustomMarkers.add(snpsByName.get(forceIncludeTags.get(i))); }
private void processFile(String fileName, int fileType, String infoFileName){ try { HaploData textData; File OutputFile; File inputFile; AssociationTestSet customAssocSet; if(!quietMode && fileName != null){ System.out.println("Using data file: " + fileName); } inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } textData = new HaploData(); //Vector result = null; if(fileType == HAPS_FILE){ //read in haps file textData.prepareHapsInput(inputFile); } else if (fileType == PED_FILE) { //read in ped file textData.linkageToChrom(inputFile, PED_FILE); if(textData.getPedFile().isBogusParents()) { System.out.println("Error: One or more individuals in the file reference non-existent parents.\nThese references have been ignored."); } }else{ //read in hapmapfile textData.linkageToChrom(inputFile,HMP_FILE); } File infoFile = null; if (infoFileName != null){ infoFile = new File(infoFileName); } if (fileType != HAPS_FILE){ textData.prepareMarkerInput(infoFile,textData.getPedFile().getHMInfo()); }else{ textData.prepareMarkerInput(infoFile,null); } HashSet whiteListedCustomMarkers = new HashSet(); if (customAssocTestsFileName != null){ customAssocSet = new AssociationTestSet(customAssocTestsFileName); whiteListedCustomMarkers = customAssocSet.getWhitelist(); }else{ customAssocSet = null; } Hashtable snpsByName = new Hashtable(); for(int i=0;i<Chromosome.getUnfilteredSize();i++) { SNP snp = Chromosome.getUnfilteredMarker(i); snpsByName.put(snp.getName(), snp); } for(int i=0;i<forceIncludeTags.size();i++) { if(snpsByName.containsKey(forceIncludeTags.get(i))) { whiteListedCustomMarkers.add(snpsByName.get(forceIncludeTags.get(i))); } } textData.setWhiteList(whiteListedCustomMarkers); boolean[] markerResults = new boolean[Chromosome.getUnfilteredSize()]; Vector result = null; if (fileType != HAPS_FILE){ result = textData.getPedFile().getResults(); //once check has been run we can filter the markers for (int i = 0; i < result.size(); i++){ if (((((MarkerResult)result.get(i)).getRating() > 0 || skipCheck) && Chromosome.getUnfilteredMarker(i).getDupStatus() != 2)){ markerResults[i] = true; }else{ markerResults[i] = false; } } }else{ //we haven't done the check (HAPS files) Arrays.fill(markerResults, true); } for (int i = 0; i < excludedMarkers.size(); i++){ int cur = ((Integer)excludedMarkers.elementAt(i)).intValue(); if (cur < 1 || cur > markerResults.length){ System.out.println("Excluded marker out of bounds has been ignored: " + cur + "\nMarkers must be between 1 and N, where N is the total number of markers."); System.exit(1); }else{ markerResults[cur-1] = false; } } for(int i=0;i<Chromosome.getUnfilteredSize();i++) { if(textData.isWhiteListed(Chromosome.getUnfilteredMarker(i))) { markerResults[i] = true; } } Chromosome.doFilter(markerResults); if(!quietMode && infoFile != null){ System.out.println("Using marker information file: " + infoFile.getName()); } if(outputCheck && result != null){ CheckDataPanel cp = new CheckDataPanel(textData); cp.printTable(validateOutputFile(fileName + ".CHECK")); } Vector cust = new Vector(); AssociationTestSet blockTestSet = null; if(blockOutputType != -1){ textData.generateDPrimeTable(); Haplotype[][] haplos; Haplotype[][] filtHaplos; switch(blockOutputType){ case BLOX_GABRIEL: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; case BLOX_4GAM: OutputFile = validateOutputFile(fileName + ".4GAMblocks"); break; case BLOX_SPINE: OutputFile = validateOutputFile(fileName + ".SPINEblocks"); break; case BLOX_CUSTOM: OutputFile = validateOutputFile(fileName + ".CUSTblocks"); //read in the blocks file File blocksFile = new File(blockFileName); if(!quietMode) { System.out.println("Using custom blocks file " + blockFileName); } cust = textData.readBlocks(blocksFile); break; case BLOX_ALL: //handled below, so we don't do anything here OutputFile = null; break; default: OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); break; } //this handles output type ALL if(blockOutputType == BLOX_ALL) { OutputFile = validateOutputFile(fileName + ".GABRIELblocks"); textData.guessBlocks(BLOX_GABRIEL); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid Gabriel blocks."); } OutputFile = validateOutputFile(fileName + ".4GAMblocks"); textData.guessBlocks(BLOX_4GAM); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile);; }else if (!quietMode){ System.out.println("Skipping block output: no valid 4 Gamete blocks."); } OutputFile = validateOutputFile(fileName + ".SPINEblocks"); textData.guessBlocks(BLOX_SPINE); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid LD Spine blocks."); } }else{ //guesses blocks based on output type determined above. textData.guessBlocks(blockOutputType, cust); haplos = textData.generateBlockHaplotypes(textData.blocks); if (haplos != null){ filtHaplos = filterHaplos(haplos); textData.pickTags(filtHaplos); textData.saveHapsToText(haplos, textData.computeMultiDprime(filtHaplos), OutputFile); }else if (!quietMode){ System.out.println("Skipping block output: no valid blocks."); } } if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC) { if (blockOutputType == BLOX_ALL){ System.out.println("Haplotype association results cannot be used with block output \"ALL\""); }else{ if (haplos != null){ blockTestSet = new AssociationTestSet(haplos,null); blockTestSet.saveHapsToText(validateOutputFile(fileName + ".HAPASSOC")); }else if (!quietMode){ System.out.println("Skipping block association output: no valid blocks."); } } } } if(outputDprime) { OutputFile = validateOutputFile(fileName + ".LD"); if (textData.dpTable != null){ textData.saveDprimeToText(OutputFile, TABLE_TYPE, 0, Chromosome.getSize()); }else{ textData.saveDprimeToText(OutputFile, LIVE_TYPE, 0, Chromosome.getSize()); } } if (outputPNG || outputCompressedPNG){ OutputFile = validateOutputFile(fileName + ".LD.PNG"); if (textData.dpTable == null){ textData.generateDPrimeTable(); textData.guessBlocks(BLOX_CUSTOM, new Vector()); } if (trackFileName != null){ textData.readAnalysisTrack(new File(trackFileName)); if(!quietMode) { System.out.println("Using analysis track file " + trackFileName); } } DPrimeDisplay dpd = new DPrimeDisplay(textData); BufferedImage i = dpd.export(0,Chromosome.getUnfilteredSize(),outputCompressedPNG); try{ Jimi.putImage("image/png", i, OutputFile.getName()); }catch(JimiException je){ System.out.println(je.getMessage()); } } AssociationTestSet markerTestSet =null; if(Options.getAssocTest() == ASSOC_TRIO || Options.getAssocTest() == ASSOC_CC){ markerTestSet = new AssociationTestSet(textData.getPedFile(),null,Chromosome.getAllMarkers()); markerTestSet.saveSNPsToText(validateOutputFile(fileName + ".ASSOC")); } if(customAssocSet != null) { if(!quietMode) { System.out.println("Using custom association test file " + customAssocTestsFileName); } try { customAssocSet.runFileTests(textData,markerTestSet.getMarkerAssociationResults()); customAssocSet.saveResultsToText(validateOutputFile(fileName + ".CUSTASSOC")); }catch(IOException ioe) { System.out.println("An error occured writing the custom association results file."); customAssocSet = null; } } if(doPermutationTest) { AssociationTestSet permTests = new AssociationTestSet(); permTests.cat(markerTestSet); permTests.cat(blockTestSet); final PermutationTestSet pts = new PermutationTestSet(permutationCount,textData.getPedFile(),customAssocSet,permTests); Thread permThread = new Thread(new Runnable() { public void run() { if (pts.isCustom()){ pts.doPermutations(PermutationTestSet.CUSTOM); }else{ pts.doPermutations(PermutationTestSet.SINGLE_PLUS_BLOCKS); } } }); permThread.start(); if(!quietMode) { System.out.println("Starting " + permutationCount + " permutation tests (each . printed represents 1% of tests completed)"); } int dotsPrinted =0; while(pts.getPermutationCount() - pts.getPermutationsPerformed() > 0) { while(( (double)pts.getPermutationsPerformed() / pts.getPermutationCount())*100 > dotsPrinted) { System.out.print("."); dotsPrinted++; } try{ Thread.sleep(100); }catch(InterruptedException ie) {} } System.out.println(); try { pts.writeResultsToFile(validateOutputFile(fileName + ".PERMUT")); } catch(IOException ioe) { System.out.println("An error occured while writing the permutation test results to file."); } } if(doTagging) { if(textData.dpTable == null) { textData.generateDPrimeTable(); } Vector snps = Chromosome.getAllMarkers(); HashSet names = new HashSet(); for (int i = 0; i < snps.size(); i++) { SNP snp = (SNP) snps.elementAt(i); names.add(snp.getName()); } HashSet filteredNames = new HashSet(); for(int i=0;i<Chromosome.getSize();i++) { filteredNames.add(Chromosome.getMarker(i).getName()); } Vector sitesToCapture = new Vector(); for(int i=0;i<Chromosome.getSize();i++) { sitesToCapture.add(Chromosome.getMarker(i)); } for (int i = 0; i < forceIncludeTags.size(); i++) { String s = (String) forceIncludeTags.elementAt(i); if(!names.contains(s)) { System.out.println("Marker " + s + " in the list of forced included tags does not appear in the marker info file."); System.exit(1); } } for (int i = 0; i < forceExcludeTags.size(); i++) { String s = (String) forceExcludeTags.elementAt(i); if(!names.contains(s)) { System.out.println("Marker " + s + " in the list of forced excluded tags does not appear in the marker info file."); System.exit(1); } } forceExcludeTags.retainAll(filteredNames); if(!quietMode) { System.out.println("Starting tagging."); } TaggerController tc = new TaggerController(textData,forceIncludeTags,forceExcludeTags,sitesToCapture, Tagger.AGGRESSIVE_TRIPLE); tc.runTagger(); while(!tc.isTaggingCompleted()) { try { Thread.sleep(100); }catch(InterruptedException ie) {} } tc.saveResultsToFile(validateOutputFile(fileName + ".TAGS")); tc.dumpTests(validateOutputFile(fileName + ".TESTS")); } } catch(IOException e){ System.err.println("An error has occured. This probably has to do with file input or output"); } catch(HaploViewException e){ System.err.println(e.getMessage()); } catch(PedFileException pfe) { System.err.println(pfe.getMessage()); } }
if ( place1 != null ) { res = place1.compareTo( place2 ); }
res = place1.compareTo( place2 );
public int compare( Object o1, Object o2 ) { PhotoInfo p1 = (PhotoInfo) o1; PhotoInfo p2 = (PhotoInfo) o2; String place1 = p1.getShootingPlace(); String place2 = p2.getShootingPlace(); if ( place1 == null ) { place1 = ""; } if ( place2 == null ) { place2 = ""; } int res = 0; if ( place1 != null ) { res = place1.compareTo( place2 ); } return res; }
subject.setPhysicalName(null);
public void setNewValue(Object newValue) { logger.debug("Setting logical name of "+subject+" to "+newValue); subject.setName(newValue == null ? null : newValue.toString()); }
dbDir.delete();
private void createDatabase() { File dbDir = null; try { dbDir = File.createTempFile("pv_junit_derby_instance", ""); } catch (IOException ex) { ex.printStackTrace(); } dbDir.delete(); PVDatabase pvd = new PVDatabase(); pvd.setInstanceType( PVDatabase.TYPE_EMBEDDED ); pvd.setEmbeddedDirectory( dbDir ); pvd.createDatabase( "", "", "junit_seed_data.xml" ); PhotovaultSettings settings = PhotovaultSettings.getSettings(); pvd.setName( "pv_junit" ); settings.addDatabase( pvd ); }
Finding the real cause of the error needs a bit of guesswork: first lets find the root cause
Finding the real reason for the error needs a bit of guesswork: first lets find the original exception
public static void initODMG( String user, String passwd, PVDatabase dbDesc ) throws PhotovaultException { getODMGImplementation(); // Find the connection repository info ConnectionRepository cr = MetadataManager.getInstance().connectionRepository(); PBKey connKey = cr.getStandardPBKeyForJcdAlias( "pv" ); JdbcConnectionDescriptor connDesc = cr.getDescriptor( connKey ); // Set up the OJB connection with parameters from photovault.properties if ( dbDesc.getInstanceType() == PVDatabase.TYPE_EMBEDDED ) { connDesc.setDriver( "org.apache.derby.jdbc.EmbeddedDriver" ); connDesc.setDbms( "derby" ); connDesc.setSubProtocol( "derby" ); connDesc.setDbAlias( "photovault" ); File derbyDir = new File( dbDesc.getEmbeddedDirectory(), "derby" ); System.setProperty( "derby.system.home", derbyDir.getAbsolutePath() ); } else { // This is a MySQL database String dbhost = dbDesc.getDbHost(); String dbname = dbDesc.getDbName(); connDesc.setDbAlias( "//" + dbhost + "/" + dbname ); connDesc.setUserName( user ); connDesc.setPassWord( passwd ); connDesc.setDriver( "com.mysql.jdbc.Driver" ); connDesc.setDbms( "MySQL" ); connDesc.setSubProtocol( "mysql" ); } // Open the database connection db = odmg.newDatabase(); boolean success = false; try { log.debug( "Opening database" ); db.open( "pv#" + user + "#" + passwd, Database.OPEN_READ_WRITE ); log.debug( "Success!!!" ); } catch ( Exception e ) { log.error( "Failed to get connection: " + e.getMessage() ); e.printStackTrace(); } // Check whether the database was opened correctly try { PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(connKey); broker.beginTransaction(); Connection con = broker.serviceConnectionManager().getConnection(); broker.commitTransaction(); broker.close(); } catch (Exception ex) { /* Finding the real cause of the error needs a bit of guesswork: first lets find the root cause */ Throwable rootCause = ex; while ( rootCause.getCause() != null ) { rootCause = rootCause.getCause(); } log.error( rootCause.getMessage() ); if ( rootCause instanceof SQLException ) { if ( rootCause instanceof EmbedSQLException ) { /* We are using Derby, the problem is likely that another instance of the database has been started */ throw new PhotovaultException( "Cannot start database.\n" + "Do you have another instance of Photovault running?", rootCause ); } if ( dbDesc.getInstanceType() == PVDatabase.TYPE_SERVER ) { throw new PhotovaultException( "Cannot log in to MySQL database", rootCause ); } } throw new PhotovaultException( "Unknown error while starting database:\n" + rootCause.getMessage(), rootCause ); } // Test the connection by fetching something try { PhotoFolder folder = PhotoFolder.getRoot(); if ( folder != null ) { success = true; } else { log.error( "Could not open database connection" ); try { db.close(); } catch (ODMGException e ) { log.error( "Error closing database" ); } throw new PhotovaultException( "Unknown error while starting database:\n" ); } } catch ( Exception t ) { log.error( "Could not open database connection" ); log.error( t.getMessage() ); t.printStackTrace(); try { db.close(); } catch (ODMGException e ) { log.error( "Error closing database" ); } throw new PhotovaultException( "Unknown error while starting database:\n" + t.getMessage(), t ); } }
System.out.println( platform.getAlterTablesSql( con, dbModel, false, true, true ) );
log.info( platform.getAlterTablesSql( con, dbModel, false, true, true ) );
public void upgradeDatabase() { fireStatusChangeEvent( new SchemaUpdateEvent( PHASE_ALTERING_SCHEMA, 0 ) ); int oldVersion = db.getSchemaVersion(); // Find needed information fr DdlUtils ConnectionRepository cr = MetadataManager.getInstance().connectionRepository(); PBKey connKey = cr.getStandardPBKeyForJcdAlias( "pv" ); JdbcConnectionDescriptor connDesc = cr.getDescriptor( connKey ); String jdbcDriver = connDesc.getDriver(); Platform platform = null; if ( jdbcDriver.equals( "org.apache.derby.jdbc.EmbeddedDriver" ) ) { platform = PlatformFactory.createNewPlatformInstance( "derby" ); } else if ( jdbcDriver.equals( "com.mysql.jdbc.Driver" ) ){ platform = PlatformFactory.createNewPlatformInstance( "mysql" ); } platform.getPlatformInfo().setDelimiterToken( "" ); // Get the database schema XML file InputStream schemaIS = getClass().getClassLoader().getResourceAsStream( "photovault_schema.xml" ); Database dbModel = new DatabaseIO().read( new InputStreamReader( schemaIS ) ); // Alter tables to match corrent schema PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker( connKey ); broker.beginTransaction(); try { Connection con = broker.serviceConnectionManager().getConnection(); /* TODO: Derby alter table statements created by DdlUtils have wrong syntax. Luckily we do not need to do such modifications for now. There is error report for DdlUtils (http://issues.apache.org/jira/browse/DDLUTILS-53), after it has been corrected the alterColumns flag should be set to true. */ System.out.println( platform.getAlterTablesSql( con, dbModel, false, true, true ) ); platform.alterTables( con, dbModel, false, true, true ); } catch (DynaSqlException ex) { ex.printStackTrace(); } catch ( LookupException ex ) { ex.printStackTrace(); } broker.commitTransaction(); broker.close(); if ( oldVersion < 4 ) { // In older version hashcolumn was not included in schema so we must fill it. createHashes(); } DbInfo info = DbInfo.getDbInfo(); info.setVersion( db.CURRENT_SCHEMA_VERSION ); fireStatusChangeEvent( new SchemaUpdateEvent( PHASE_COMPLETE, 100 ) ); }
public void addDatabase(PVDatabase db) {
public void addDatabase(PVDatabase db) throws PhotovaultException {
public void addDatabase(PVDatabase db) { databases.addDatabase( db ); }
public static Vector calcTrioTDT(PedFile pf){
public static Vector calcTrioTDT(PedFile pf) throws PedFileException{
public static Vector calcTrioTDT(PedFile pf){ Vector results = new Vector(); int numMarkers = Chromosome.getUnfilteredSize(); for (int i = 0; i < numMarkers; i++){ TDTResult thisResult = new TDTResult(Chromosome.getUnfilteredMarker(i)); Vector indList = pf.getOrder(); Individual currentInd; Family currentFam; for (int j = 0; j < indList.size(); j++){ currentInd = (Individual)indList.elementAt(j); currentFam = pf.getFamily(currentInd.getFamilyID()); if (currentInd.hasBothParents() && currentInd.getAffectedStatus() == 2){ //if he has both parents, and is affected, we can get a transmission Individual mom = null; Individual dad = null; try{ mom = currentFam.getMember(currentInd.getMomID()); dad = currentFam.getMember(currentInd.getDadID()); }catch (PedFileException pfe){ } byte[] thisMarker = currentInd.getMarker(i); byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; thisMarker = dad.getMarker(i); byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; thisMarker = mom.getMarker(i); byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; byte momT=0, momU=0, dadT=0, dadU=0; if (kid1 == 0 || kid2 == 0 || dad1 == 0 || dad2 == 0 || mom1 == 0 || mom2 == 0) { continue; } else if (kid1 == kid2) { //kid homozygous if (dad1 == kid1) { dadT = dad1; dadU = dad2; } else { dadT = dad2; dadU = dad1; } if (mom1 == kid1) { momT = mom1; momU = mom2; } else { momT = mom2; momU = mom1; } } else { if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadT = dad1; dadU = dad2; if (kid1 == dad1) { momT = kid2; momU = kid1; } else { momT = kid1; momU = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momT = mom1; momU = mom2; if (kid1 == mom1) { dadT = kid2; dadU = kid1; } else { dadT = kid1; dadU = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadT = dad1; dadU = dad1; momT = mom1; momU = mom1; } else { //everybody het dadT = (byte)(4+dad1); dadU = (byte)(4+dad2); momT = (byte)(4+mom1); momU = (byte)(4+mom2); } } thisResult.tallyTrioInd(dadT, dadU); thisResult.tallyTrioInd(momT, momU); } } results.add(thisResult); } return results; }
Individual mom = null; Individual dad = null; try{ mom = currentFam.getMember(currentInd.getMomID()); dad = currentFam.getMember(currentInd.getDadID()); }catch (PedFileException pfe){ }
Individual mom = currentFam.getMember(currentInd.getMomID()); Individual dad = currentFam.getMember(currentInd.getDadID());
public static Vector calcTrioTDT(PedFile pf){ Vector results = new Vector(); int numMarkers = Chromosome.getUnfilteredSize(); for (int i = 0; i < numMarkers; i++){ TDTResult thisResult = new TDTResult(Chromosome.getUnfilteredMarker(i)); Vector indList = pf.getOrder(); Individual currentInd; Family currentFam; for (int j = 0; j < indList.size(); j++){ currentInd = (Individual)indList.elementAt(j); currentFam = pf.getFamily(currentInd.getFamilyID()); if (currentInd.hasBothParents() && currentInd.getAffectedStatus() == 2){ //if he has both parents, and is affected, we can get a transmission Individual mom = null; Individual dad = null; try{ mom = currentFam.getMember(currentInd.getMomID()); dad = currentFam.getMember(currentInd.getDadID()); }catch (PedFileException pfe){ } byte[] thisMarker = currentInd.getMarker(i); byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; thisMarker = dad.getMarker(i); byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; thisMarker = mom.getMarker(i); byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1]; byte momT=0, momU=0, dadT=0, dadU=0; if (kid1 == 0 || kid2 == 0 || dad1 == 0 || dad2 == 0 || mom1 == 0 || mom2 == 0) { continue; } else if (kid1 == kid2) { //kid homozygous if (dad1 == kid1) { dadT = dad1; dadU = dad2; } else { dadT = dad2; dadU = dad1; } if (mom1 == kid1) { momT = mom1; momU = mom2; } else { momT = mom2; momU = mom1; } } else { if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadT = dad1; dadU = dad2; if (kid1 == dad1) { momT = kid2; momU = kid1; } else { momT = kid1; momU = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momT = mom1; momU = mom2; if (kid1 == mom1) { dadT = kid2; dadU = kid1; } else { dadT = kid1; dadU = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadT = dad1; dadU = dad1; momT = mom1; momU = mom1; } else { //everybody het dadT = (byte)(4+dad1); dadU = (byte)(4+dad2); momT = (byte)(4+mom1); momU = (byte)(4+mom2); } } thisResult.tallyTrioInd(dadT, dadU); thisResult.tallyTrioInd(momT, momU); } } results.add(thisResult); } return results; }
String input = args[0];
Jelly jelly = new Jelly(); jelly.setScript( args[0] );
public static void main(String[] args) throws Exception { if ( args.length <= 0 ) { System.out.println( "Usage: Jelly scriptFile [outputFile]" ); return; } String input = args[0]; /* // later we might wanna add some command line arguments // checking stuff using commons-cli to specify the output file // and input file via command line arguments Writer writer = ( args.length > 1 ) ? new FileWriter( args[1] ) : new OutputStreamWriter( System.out ); BufferedWriter output = new BufferedWriter( writer );*/ Writer writer = new BufferedWriter( new OutputStreamWriter( System.out ) ); // add the system properties and the command line arguments //Context context = new Context( System.getProperties() ); Context context = new Context(); context.setVariable( "args", args ); XMLParser parser = new XMLParser(); parser.setContext( context ); Script script = parser.parse( input ); script = script.compile(); if ( log.isDebugEnabled() ) { log.debug( "Compiled script: " + script ); } XMLOutput output = XMLOutput.createXMLOutput( writer ); script.run( context, output ); writer.close(); }
Context context = new Context(); context.setVariable( "args", args ); XMLParser parser = new XMLParser(); parser.setContext( context ); Script script = parser.parse( input ); script = script.compile(); if ( log.isDebugEnabled() ) { log.debug( "Compiled script: " + script ); }
Script script = jelly.compileScript();
public static void main(String[] args) throws Exception { if ( args.length <= 0 ) { System.out.println( "Usage: Jelly scriptFile [outputFile]" ); return; } String input = args[0]; /* // later we might wanna add some command line arguments // checking stuff using commons-cli to specify the output file // and input file via command line arguments Writer writer = ( args.length > 1 ) ? new FileWriter( args[1] ) : new OutputStreamWriter( System.out ); BufferedWriter output = new BufferedWriter( writer );*/ Writer writer = new BufferedWriter( new OutputStreamWriter( System.out ) ); // add the system properties and the command line arguments //Context context = new Context( System.getProperties() ); Context context = new Context(); context.setVariable( "args", args ); XMLParser parser = new XMLParser(); parser.setContext( context ); Script script = parser.parse( input ); script = script.compile(); if ( log.isDebugEnabled() ) { log.debug( "Compiled script: " + script ); } XMLOutput output = XMLOutput.createXMLOutput( writer ); script.run( context, output ); writer.close(); }
Context context = jelly.getContext(); context.setVariable( "args", args );
public static void main(String[] args) throws Exception { if ( args.length <= 0 ) { System.out.println( "Usage: Jelly scriptFile [outputFile]" ); return; } String input = args[0]; /* // later we might wanna add some command line arguments // checking stuff using commons-cli to specify the output file // and input file via command line arguments Writer writer = ( args.length > 1 ) ? new FileWriter( args[1] ) : new OutputStreamWriter( System.out ); BufferedWriter output = new BufferedWriter( writer );*/ Writer writer = new BufferedWriter( new OutputStreamWriter( System.out ) ); // add the system properties and the command line arguments //Context context = new Context( System.getProperties() ); Context context = new Context(); context.setVariable( "args", args ); XMLParser parser = new XMLParser(); parser.setContext( context ); Script script = parser.parse( input ); script = script.compile(); if ( log.isDebugEnabled() ) { log.debug( "Compiled script: " + script ); } XMLOutput output = XMLOutput.createXMLOutput( writer ); script.run( context, output ); writer.close(); }
String photoId = "02120108000000001";
int photoId = 1;
public void testRetrievalSuccess() { String photoId = "02120108000000001"; try { PhotoInfo photo = PhotoInfo.retrievePhotoInfo( photoId ); assertTrue(photo != null ); } catch (PhotoNotFoundException e) { fail( "Photo " + photoId + " not found" ); } // TODO: check some other properties of the object }
Thumbnail thumb = photo.getThumbnail(); assertNotNull( thumb ); assertFalse( "Thumbnail exists, should not return default thumbnail", thumb == Thumbnail.getDefaultThumbnail() ); assertEquals( "Thumbnail exists, getThumbnail should not create a new instance", instanceCount+1, photo.getNumInstances() );
public void testThumbnailCreate() { String testImgDir = "c:\\java\\photovault\\testfiles"; String fname = "test1.jpg"; File f = new File( testImgDir, fname ); PhotoInfo photo = null; try { photo = PhotoInfo.addToDB( f ); } catch ( PhotoNotFoundException e ) { fail( "Could not find photo: " + e.getMessage() ); } assertNotNull( photo ); int instanceCount = photo.getNumInstances(); photo.createThumbnail(); assertEquals( "InstanceNum should be 1 greater after adding thumbnail", instanceCount+1, photo.getNumInstances() ); // Try to find the new thumbnail boolean foundThumbnail = false; ImageInstance thumbnail = null; for ( int n = 0; n < instanceCount+1; n++ ) { ImageInstance instance = photo.getInstance( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_THUMBNAIL ) { foundThumbnail = true; thumbnail = instance; break; } } assertTrue( "Could not find the created thumbnail", foundThumbnail ); assertEquals( "Thumbnail width should be 100", 100, thumbnail.getWidth() ); File thumbnailFile = thumbnail.getImageFile(); assertTrue( "Image file does not exist", thumbnailFile.exists() ); photo.delete(); assertFalse( "Image file does exist after delete", thumbnailFile.exists() ); }
new File(CoreUtils.getLogDir()).mkdirs();
public static void main(String[] args) throws Exception{ Runtime.getRuntime().addShutdownHook(new Thread(){ public void run(){ logger.info("jManage shutting down..."); DBUtils.shutdownDB(); } }); if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } /* create logs dir */ new File(CoreUtils.getLogDir()).mkdirs(); UserManager userManager = UserManager.getInstance(); User user = null; char[] password = null; int invalidAttempts = 0; if(args.length == 1){ password = args[0].toCharArray(); user = userManager.verifyUsernamePassword( AuthConstants.USER_ADMIN, password); /* invalid password was tried */ if(user == null){ invalidAttempts ++; } } while(user == null){ if(invalidAttempts > 0){ System.out.println("Invalid Admin Password."); } /* get the password */ password = PasswordField.getPassword("Enter password:"); /* the password should match for the admin user */ user = userManager.verifyUsernamePassword( AuthConstants.USER_ADMIN, password); invalidAttempts ++; if(invalidAttempts >= 3){ break; } } /* exit if the admin password is still invalid */ if(user == null){ System.out.println("Number of invalid attempts exceeded. Exiting !"); return; } /* set admin password as the stop key */ final JettyStopKey stopKey = new JettyStopKey(new String(password)); System.setProperty("STOP.KEY", stopKey.toString()); /* set stop.port */ System.setProperty("STOP.PORT", JManageProperties.getStopPort()); /* initialize ServiceFactory */ ServiceFactory.init(ServiceFactory.MODE_LOCAL); /* initialize crypto */ Crypto.init(password); /* clear the password */ Arrays.fill(password, ' '); /* load ACLs */ ACLStore.getInstance(); /* start the AlertEngine */ AlertEngine.getInstance().start(); /* start the application downtime service */ ApplicationDowntimeService.getInstance().start(); /* load connectors */ ConnectorConfigRegistry.init(); ConnectorRegistry.load(); /* start the application */ start(); }
addApplication(appConfig);
if(!appConfig.isCluster()) addApplication(appConfig);
public void start() { for (ApplicationConfig appConfig : ApplicationConfigManager .getAllApplications()) { addApplication(appConfig); } // TODO: perfect dependency to be injected via Spring framework --rk EventSystem eventSystem = EventSystem.getInstance(); /* Add the recorder to record the downtimes to the DB */ eventSystem.addListener(recorder, ApplicationEvent.class); /* application event listener to add */ eventSystem.addListener(new EventListener(){ public void handleEvent(EventObject event) { if(!(event instanceof ApplicationEvent)){ throw new IllegalArgumentException("event must be of type ApplicationEvent"); } if(event instanceof NewApplicationEvent){ addApplication(((NewApplicationEvent)event).getApplicationConfig()); }else if(event instanceof ApplicationChangedEvent){ applicationChanged(((ApplicationChangedEvent)event).getApplicationConfig()); } } }, ApplicationEvent.class); logger.info("ApplicationDowntimeService started."); }
dPrimeDisplay.revalidate();
public void stateChanged(ChangeEvent e) { if (tabs.getSelectedIndex() != -1){ window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); String title = tabs.getTitleAt(tabs.getSelectedIndex()); if (title.equals(VIEW_DPRIME) || title.equals(VIEW_HAPLOTYPES)){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(true); }else if (title.equals(VIEW_ASSOC) || title.equals(VIEW_CHECK_PANEL) || title.equals(VIEW_TAGGER)){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(false); }else{ exportMenuItems[0].setEnabled(false); exportMenuItems[1].setEnabled(false); } //if we've adjusted the haps display thresh we need to change the haps ass panel if (title.equals(VIEW_ASSOC)){ JTabbedPane metaAssoc = ((JTabbedPane)((HaploviewTab)tabs.getSelectedComponent()).getComponent(0)); //this is the haps ass tab inside the assoc super-tab HaploAssocPanel htp = (HaploAssocPanel) metaAssoc.getComponent(1); if (htp.initialHaplotypeDisplayThreshold != Options.getHaplotypeDisplayThreshold()){ htp.makeTable(new AssociationTestSet(theData.getHaplotypes(), null)); permutationPanel.setBlocksChanged(); AssociationTestSet custSet = null; if (custAssocPanel != null){ custSet = custAssocPanel.getTestSet(); } AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet( new PermutationTestSet(0,theData.getPedFile(),custSet,permSet)); } } if (title.equals(VIEW_DPRIME)){ keyMenu.setEnabled(true); }else{ keyMenu.setEnabled(false); } viewMenuItems[tabs.getSelectedIndex()].setSelected(true); if (checkPanel != null && checkPanel.changed){ //first store up the current blocks Vector currentBlocks = new Vector(); for (int blocks = 0; blocks < theData.blocks.size(); blocks++){ int thisBlock[] = (int[]) theData.blocks.elementAt(blocks); int thisBlockReal[] = new int[thisBlock.length]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlockReal[marker] = Chromosome.realIndex[thisBlock[marker]]; } currentBlocks.add(thisBlockReal); } Chromosome.doFilter(checkPanel.getMarkerResults()); //after editing the filtered marker list, needs to be prodded into //resizing correctly dPrimeDisplay.computePreferredSize(); dPrimeDisplay.colorDPrime(); hapDisplay.theData = theData; if (currentBlockDef != BLOX_CUSTOM){ changeBlocks(currentBlockDef); }else{ //adjust the blocks Vector theBlocks = new Vector(); for (int x = 0; x < currentBlocks.size(); x++){ Vector goodies = new Vector(); int currentBlock[] = (int[])currentBlocks.elementAt(x); for (int marker = 0; marker < currentBlock.length; marker++){ for (int y = 0; y < Chromosome.realIndex.length; y++){ //we only keep markers from the input that are "good" from checkdata //we also realign the input file to the current "good" subset since input is //indexed of all possible markers in the dataset if (Chromosome.realIndex[y] == currentBlock[marker]){ goodies.add(new Integer(y)); } } } int thisBlock[] = new int[goodies.size()]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlock[marker] = ((Integer)goodies.elementAt(marker)).intValue(); } if (thisBlock.length > 1){ theBlocks.add(thisBlock); } } theData.guessBlocks(BLOX_CUSTOM, theBlocks); } if (tdtPanel != null){ tdtPanel.refreshTable(); } if (taggerConfigPanel != null){ taggerConfigPanel.refreshTable(); } if(permutationPanel != null) { permutationPanel.setBlocksChanged(); AssociationTestSet custSet = null; if (custAssocPanel != null){ custSet = custAssocPanel.getTestSet(); } AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet( new PermutationTestSet(0,theData.getPedFile(),custSet,permSet)); } checkPanel.changed=false; } if (hapDisplay != null && theData.blocksChanged){ try{ hapDisplay.getHaps(); if(Options.getAssocTest() != ASSOC_NONE) { //this is the haps ass tab inside the assoc super-tab hapAssocPanel.makeTable(new AssociationTestSet(theData.getHaplotypes(), null)); permutationPanel.setBlocksChanged(); AssociationTestSet custSet = null; if (custAssocPanel != null){ custSet = custAssocPanel.getTestSet(); } AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet( new PermutationTestSet(0,theData.getPedFile(),custSet,permSet)); } }catch(HaploViewException hv){ JOptionPane.showMessageDialog(window, hv.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); theData.blocksChanged = false; } if (theData.finished){ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }
bestObsPanel.setMaximumSize(bestObsPanel.getPreferredSize());
bestObsPanel.setMaximumSize(new Dimension(400,bestObsPanel.getPreferredSize().height));
public PermutationTestPanel(PermutationTestSet pts) { if(pts == null) { throw new NullPointerException(); } testSet = pts; this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); JPanel permCountPanel = new JPanel(); JPanel selectionPanel = new JPanel(); selectionGroup = new ButtonGroup(); selectionPanel.setLayout(new BoxLayout(selectionPanel, BoxLayout.Y_AXIS)); JRadioButton singleOnlyButton = new JRadioButton("Single Markers Only"); singleOnlyButton.setActionCommand(String.valueOf(PermutationTestSet.SINGLE_ONLY)); selectionPanel.add(singleOnlyButton); selectionGroup.add(singleOnlyButton); JRadioButton singlesPlusBlocksButton = new JRadioButton("Single Markers and Haplotypes in Blocks"); singlesPlusBlocksButton.setActionCommand(String.valueOf(PermutationTestSet.SINGLE_PLUS_BLOCKS)); selectionPanel.add(singlesPlusBlocksButton); selectionGroup.add(singlesPlusBlocksButton); singlesPlusBlocksButton.setSelected(true); if (testSet.isCustom()){ JRadioButton customFileButton = new JRadioButton("Custom Tests from File"); customFileButton.setActionCommand(String.valueOf(PermutationTestSet.CUSTOM)); selectionPanel.add(customFileButton); selectionGroup.add(customFileButton); customFileButton.setSelected(true); } permCountPanel.add(selectionPanel); JLabel permCountTextLabel = new JLabel("Number of Permutations To Perform: "); permCountField = new NumberTextField("", 10, false); permCountPanel.add(permCountTextLabel); permCountPanel.add(permCountField); permCountPanel.setMaximumSize(permCountPanel.getPreferredSize()); this.add(permCountPanel); JPanel buttonPanel = new JPanel(); doPermutationsButton = new JButton("Do Permutations"); doPermutationsButton.addActionListener(this); stopPermutationsButton = new JButton("Stop"); stopPermutationsButton.addActionListener(this); stopPermutationsButton.setEnabled(false); buttonPanel.add(doPermutationsButton); buttonPanel.add(stopPermutationsButton); buttonPanel.setMaximumSize(buttonPanel.getPreferredSize()); this.add(buttonPanel); bestObsPanel = new JPanel(); JLabel bestObsTextLabel = new JLabel("Best Observed Chi-Square: "); bestObsValueLabel = new JLabel(""); bestObsPanel.add(bestObsTextLabel); bestObsPanel.add(bestObsValueLabel); bestObsPanel.setMaximumSize(bestObsPanel.getPreferredSize()); this.add(bestObsPanel); bestPermPanel = new JPanel(); JLabel bestPermTextLabel = new JLabel("Best Permutation Chi-Square: "); bestPermutationValueLabel = new JLabel(""); bestPermPanel.add(bestPermTextLabel); bestPermPanel.add(bestPermutationValueLabel); bestPermPanel.setMaximumSize(bestPermPanel.getPreferredSize()); this.add(bestPermPanel); scoreBoardPanel = new JPanel(); scoreBoardNumPassLabel = new JLabel(); scoreBoardNumTotalLabel = new JLabel(); scoreBoardPanel.add(scoreBoardNumPassLabel); scoreBoardPanel.add(new JLabel("permutations out of")); scoreBoardPanel.add(scoreBoardNumTotalLabel); scoreBoardPanel.add(new JLabel("exceed highest observed chi square.")); scoreBoardPanel.setMaximumSize(new Dimension(500,60)); scoreBoardPanel.setVisible(false); add(scoreBoardPanel); colNames = new Vector(); colNames.add("Name"); colNames.add("Chi Square"); colNames.add("Permutation p-value"); blocksChangedLabel = new JLabel("The current blocks may have changed, so these values may not be accurate!"); blocksChangedLabel.setAlignmentX(Component.CENTER_ALIGNMENT); blocksChangedLabel.setFont(new Font("SansSerif", Font.BOLD, 14)); blocksChangedLabel.setForeground(Color.RED); }
bestPermPanel.setMaximumSize(bestPermPanel.getPreferredSize());
bestPermPanel.setMaximumSize(new Dimension(400,bestPermPanel.getPreferredSize().height));
public PermutationTestPanel(PermutationTestSet pts) { if(pts == null) { throw new NullPointerException(); } testSet = pts; this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); JPanel permCountPanel = new JPanel(); JPanel selectionPanel = new JPanel(); selectionGroup = new ButtonGroup(); selectionPanel.setLayout(new BoxLayout(selectionPanel, BoxLayout.Y_AXIS)); JRadioButton singleOnlyButton = new JRadioButton("Single Markers Only"); singleOnlyButton.setActionCommand(String.valueOf(PermutationTestSet.SINGLE_ONLY)); selectionPanel.add(singleOnlyButton); selectionGroup.add(singleOnlyButton); JRadioButton singlesPlusBlocksButton = new JRadioButton("Single Markers and Haplotypes in Blocks"); singlesPlusBlocksButton.setActionCommand(String.valueOf(PermutationTestSet.SINGLE_PLUS_BLOCKS)); selectionPanel.add(singlesPlusBlocksButton); selectionGroup.add(singlesPlusBlocksButton); singlesPlusBlocksButton.setSelected(true); if (testSet.isCustom()){ JRadioButton customFileButton = new JRadioButton("Custom Tests from File"); customFileButton.setActionCommand(String.valueOf(PermutationTestSet.CUSTOM)); selectionPanel.add(customFileButton); selectionGroup.add(customFileButton); customFileButton.setSelected(true); } permCountPanel.add(selectionPanel); JLabel permCountTextLabel = new JLabel("Number of Permutations To Perform: "); permCountField = new NumberTextField("", 10, false); permCountPanel.add(permCountTextLabel); permCountPanel.add(permCountField); permCountPanel.setMaximumSize(permCountPanel.getPreferredSize()); this.add(permCountPanel); JPanel buttonPanel = new JPanel(); doPermutationsButton = new JButton("Do Permutations"); doPermutationsButton.addActionListener(this); stopPermutationsButton = new JButton("Stop"); stopPermutationsButton.addActionListener(this); stopPermutationsButton.setEnabled(false); buttonPanel.add(doPermutationsButton); buttonPanel.add(stopPermutationsButton); buttonPanel.setMaximumSize(buttonPanel.getPreferredSize()); this.add(buttonPanel); bestObsPanel = new JPanel(); JLabel bestObsTextLabel = new JLabel("Best Observed Chi-Square: "); bestObsValueLabel = new JLabel(""); bestObsPanel.add(bestObsTextLabel); bestObsPanel.add(bestObsValueLabel); bestObsPanel.setMaximumSize(bestObsPanel.getPreferredSize()); this.add(bestObsPanel); bestPermPanel = new JPanel(); JLabel bestPermTextLabel = new JLabel("Best Permutation Chi-Square: "); bestPermutationValueLabel = new JLabel(""); bestPermPanel.add(bestPermTextLabel); bestPermPanel.add(bestPermutationValueLabel); bestPermPanel.setMaximumSize(bestPermPanel.getPreferredSize()); this.add(bestPermPanel); scoreBoardPanel = new JPanel(); scoreBoardNumPassLabel = new JLabel(); scoreBoardNumTotalLabel = new JLabel(); scoreBoardPanel.add(scoreBoardNumPassLabel); scoreBoardPanel.add(new JLabel("permutations out of")); scoreBoardPanel.add(scoreBoardNumTotalLabel); scoreBoardPanel.add(new JLabel("exceed highest observed chi square.")); scoreBoardPanel.setMaximumSize(new Dimension(500,60)); scoreBoardPanel.setVisible(false); add(scoreBoardPanel); colNames = new Vector(); colNames.add("Name"); colNames.add("Chi Square"); colNames.add("Permutation p-value"); blocksChangedLabel = new JLabel("The current blocks may have changed, so these values may not be accurate!"); blocksChangedLabel.setAlignmentX(Component.CENTER_ALIGNMENT); blocksChangedLabel.setFont(new Font("SansSerif", Font.BOLD, 14)); blocksChangedLabel.setForeground(Color.RED); }
if ( (parentTask == null || parentTask instanceof TaskContainer) && project.getTaskDefinitions().containsKey( tagName )) {
Object nested = null; if (parentObject != null && !( parentTask instanceof TaskContainer) ) { nested = createNestedObject( parentObject, tagName ); } if (nested == null) { task = createTask( tagName );
public void doTag(XMLOutput output) throws Exception { Project project = getAntProject(); String tagName = getTagName(); Object parentObject = findBeanAncestor(); Object parentTask = findParentTaskObject(); // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask // // also its possible to have a root Ant tag which isn't a task, such as when // defining <fileset id="...">...</fileset> if ( (parentTask == null || parentTask instanceof TaskContainer) && project.getTaskDefinitions().containsKey( tagName )) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { Object[] args = { body }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { if ( log.isDebugEnabled() ) { log.debug( "Creating a nested object name: " + tagName ); } Object nested = createNestedObject( parentObject, tagName ); if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { if (log.isDebugEnabled()) { log.debug("About to set the: " + tagName + " property on: " + parentObject + " to value: " + nested + " with type: " + nested.getClass() ); } ih.storeElement( project, parentObject, nested, tagName ); } catch (Exception e) { log.warn( "Caught exception setting nested: " + tagName, e ); } // now try to set the property for good measure // as the storeElement() method does not // seem to call any setter methods of non-String types try { BeanUtils.setProperty( parentObject, tagName, nested ); } catch (Exception e) { log.debug("Caught exception trying to set property: " + tagName + " on: " + parentObject); } } } else { // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } }
if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName );
if (task != null) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } task.init(); String body = getBodyText(); setBeanProperties(); Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { Object[] args = { body }; method.invoke(this.task, args); } task.perform();
public void doTag(XMLOutput output) throws Exception { Project project = getAntProject(); String tagName = getTagName(); Object parentObject = findBeanAncestor(); Object parentTask = findParentTaskObject(); // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask // // also its possible to have a root Ant tag which isn't a task, such as when // defining <fileset id="...">...</fileset> if ( (parentTask == null || parentTask instanceof TaskContainer) && project.getTaskDefinitions().containsKey( tagName )) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { Object[] args = { body }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { if ( log.isDebugEnabled() ) { log.debug( "Creating a nested object name: " + tagName ); } Object nested = createNestedObject( parentObject, tagName ); if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { if (log.isDebugEnabled()) { log.debug("About to set the: " + tagName + " property on: " + parentObject + " to value: " + nested + " with type: " + nested.getClass() ); } ih.storeElement( project, parentObject, nested, tagName ); } catch (Exception e) { log.warn( "Caught exception setting nested: " + tagName, e ); } // now try to set the property for good measure // as the storeElement() method does not // seem to call any setter methods of non-String types try { BeanUtils.setProperty( parentObject, tagName, nested ); } catch (Exception e) { log.debug("Caught exception trying to set property: " + tagName + " on: " + parentObject); } } } else { // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } }
task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() );
} if (task == null) { if (nested == null) { if ( log.isDebugEnabled() ) { log.debug( "Trying to create a data type for tag: " + tagName ); } nested = createDataType( tagName );
public void doTag(XMLOutput output) throws Exception { Project project = getAntProject(); String tagName = getTagName(); Object parentObject = findBeanAncestor(); Object parentTask = findParentTaskObject(); // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask // // also its possible to have a root Ant tag which isn't a task, such as when // defining <fileset id="...">...</fileset> if ( (parentTask == null || parentTask instanceof TaskContainer) && project.getTaskDefinitions().containsKey( tagName )) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { Object[] args = { body }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { if ( log.isDebugEnabled() ) { log.debug( "Creating a nested object name: " + tagName ); } Object nested = createNestedObject( parentObject, tagName ); if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { if (log.isDebugEnabled()) { log.debug("About to set the: " + tagName + " property on: " + parentObject + " to value: " + nested + " with type: " + nested.getClass() ); } ih.storeElement( project, parentObject, nested, tagName ); } catch (Exception e) { log.warn( "Caught exception setting nested: " + tagName, e ); } // now try to set the property for good measure // as the storeElement() method does not // seem to call any setter methods of non-String types try { BeanUtils.setProperty( parentObject, tagName, nested ); } catch (Exception e) { log.debug("Caught exception trying to set property: " + tagName + " on: " + parentObject); } } } else { // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } }
setObject( task ); } Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } task.init(); String body = getBodyText(); setBeanProperties(); Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { Object[] args = { body }; method.invoke(this.task, args); } task.perform(); } else { if ( log.isDebugEnabled() ) { log.debug( "Creating a nested object name: " + tagName ); } Object nested = createNestedObject( parentObject, tagName ); if ( nested == null ) { nested = createDataType( tagName );
if ( log.isDebugEnabled() ) { log.debug( "Created nested property tag: " + tagName ); }
public void doTag(XMLOutput output) throws Exception { Project project = getAntProject(); String tagName = getTagName(); Object parentObject = findBeanAncestor(); Object parentTask = findParentTaskObject(); // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask // // also its possible to have a root Ant tag which isn't a task, such as when // defining <fileset id="...">...</fileset> if ( (parentTask == null || parentTask instanceof TaskContainer) && project.getTaskDefinitions().containsKey( tagName )) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { Object[] args = { body }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { if ( log.isDebugEnabled() ) { log.debug( "Creating a nested object name: " + tagName ); } Object nested = createNestedObject( parentObject, tagName ); if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { if (log.isDebugEnabled()) { log.debug("About to set the: " + tagName + " property on: " + parentObject + " to value: " + nested + " with type: " + nested.getClass() ); } ih.storeElement( project, parentObject, nested, tagName ); } catch (Exception e) { log.warn( "Caught exception setting nested: " + tagName, e ); } // now try to set the property for good measure // as the storeElement() method does not // seem to call any setter methods of non-String types try { BeanUtils.setProperty( parentObject, tagName, nested ); } catch (Exception e) { log.debug("Caught exception trying to set property: " + tagName + " on: " + parentObject); } } } else { // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } }
log.warn("Could not convert tag: " + tagName + " into an Ant task, data type or property");
public void doTag(XMLOutput output) throws Exception { Project project = getAntProject(); String tagName = getTagName(); Object parentObject = findBeanAncestor(); Object parentTask = findParentTaskObject(); // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask // // also its possible to have a root Ant tag which isn't a task, such as when // defining <fileset id="...">...</fileset> if ( (parentTask == null || parentTask instanceof TaskContainer) && project.getTaskDefinitions().containsKey( tagName )) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { Object[] args = { body }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { if ( log.isDebugEnabled() ) { log.debug( "Creating a nested object name: " + tagName ); } Object nested = createNestedObject( parentObject, tagName ); if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { if (log.isDebugEnabled()) { log.debug("About to set the: " + tagName + " property on: " + parentObject + " to value: " + nested + " with type: " + nested.getClass() ); } ih.storeElement( project, parentObject, nested, tagName ); } catch (Exception e) { log.warn( "Caught exception setting nested: " + tagName, e ); } // now try to set the property for good measure // as the storeElement() method does not // seem to call any setter methods of non-String types try { BeanUtils.setProperty( parentObject, tagName, nested ); } catch (Exception e) { log.debug("Caught exception trying to set property: " + tagName + " on: " + parentObject); } } } else { // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } }
return AntTagLibrary.getProject(context);
Project project = AntTagLibrary.getProject(context); if (project == null) { throw new NullPointerException("No Ant Project object is available"); } return project;
public Project getAntProject() { return AntTagLibrary.getProject(context); }
tag.getBody().run(context, output);
tag.invokeBody(output);
public void doTag(XMLOutput output) throws Exception { // Try find find the body from the reserved 'org.apache.commons.jelly.body' variable Script script = (Script) context.getVariable("org.apache.commons.jelly.body"); if (script != null) { script.run(context, output); } else { // note this mechanism does not work properly for arbitrarily // nested dynamic tags. A better way is required. Tag tag = findAncestorWithClass(this, DynamicTag.class); if (tag == null) { throw new JellyException("Cannot invoke body, no dynamic tag is defined in this block"); } else { tag.getBody().run(context, output); } } }