bugged
stringlengths 6
599k
| fixed
stringlengths 10
599k
| __index_level_0__
int64 0
1.13M
|
|---|---|---|
protected TagScript createStaticTag( String namespaceURI, String localName, String qName, Attributes list) throws SAXException { try { StaticTag tag = new StaticTag( namespaceURI, localName, qName); StaticTagScript script = new StaticTagScript(tag); // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeName = list.getLocalName(i); String attributeValue = list.getValue(i); Expression expression = CompositeExpression.parse( attributeValue, getExpressionFactory() ); script.addAttribute(attributeName, expression); } return script; } catch (Exception e) { log.warn( "Could not create static tag for URI: " + namespaceURI + " tag name: " + localName, e); throw createSAXException(e); } }
|
protected TagScript createStaticTag( String namespaceURI, String localName, String qName, Attributes list) throws SAXException { try { StaticTag tag = new StaticTag( namespaceURI, localName, qName); StaticTagScript script = new StaticTagScript(tag); // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeName = list.getLocalName(i); String attributeValue = list.getValue(i); Expression expression = CompositeExpression.parse( attributeValue, getExpressionFactory() ); script.addAttribute(attributeName, expression); } return script; } catch (Exception e) { log.warn( "Could not create static tag for URI: " + namespaceURI + " tag name: " + localName, e); throw createSAXException(e); } }
| 1,111,758
|
public void endElement(String namespaceURI, String localName, String qName) throws SAXException { try { tagScript = (TagScript) tagScriptStack.remove(tagScriptStack.size() - 1); if (tagScript != null) { if (textBuffer.length() > 0) { addTextScript(textBuffer.toString()); textBuffer.setLength(0); } script = (ScriptBlock) scriptStack.pop(); } else { textBuffer.append("</"); textBuffer.append(qName); textBuffer.append(">"); } int size = tagStack.size(); if ( size <= 0 ) { parentTag = null; } else { parentTag = (Tag) tagStack.remove( size - 1 ); } } catch (SAXException e) { throw e; } catch (Exception e) { log.error( "Caught exception: " + e, e ); throw new SAXException( "Runtime Exception: " + e, e ); } }
|
public void endElement(String namespaceURI, String localName, String qName) throws SAXException { try { tagScript = (TagScript) tagScriptStack.remove(tagScriptStack.size() - 1); if (tagScript != null) { if (textBuffer.length() > 0) { addTextScript(textBuffer.toString()); textBuffer.setLength(0); } script = (ScriptBlock) scriptStack.pop(); } else { textBuffer.append("</"); textBuffer.append(qName); textBuffer.append(">"); } int size = tagStack.size(); if ( size <= 0 ) { parentTag = null; } else { parentTag = (Tag) tagStack.remove( size - 1 ); } } catch (SAXException e) { throw e; } catch (Exception e) { log.error( "Caught exception: " + e, e ); throw new SAXException( "Runtime Exception: " + e, e ); } }
| 1,111,759
|
public void startDocument() throws SAXException { script = new ScriptBlock(); textBuffer = new StringBuffer(); tagScript = null; parentTag = null; scriptStack.clear(); tagScriptStack.clear(); }
|
public void startDocument() throws SAXException { script = new ScriptBlock(); textBuffer = new StringBuffer(); tagScript = null; scriptStack.clear(); tagScriptStack.clear(); }
| 1,111,760
|
public void startElement( String namespaceURI, String localName, String qName, Attributes list) throws SAXException { try { // add check to ensure namespace URI is "" for no namespace if ( namespaceURI == null ) { namespaceURI = ""; } // if this is a tag then create a script to run it // otherwise pass the text to the current body tagScript = createTag(namespaceURI, localName, list); if (tagScript == null) { tagScript = createStaticTag(namespaceURI, localName, qName, list); } tagScriptStack.add(tagScript); if (tagScript != null) { // set parent relationship... Tag tag = tagScript.getTag(); tag.setParent(parentTag); // set the namespace Map if ( elementNamespaces != null ) { tagScript.setNamespacesMap( elementNamespaces ); elementNamespaces = null; } // set the line number details if ( locator != null ) { tagScript.setLocator(locator); } // sets the file name element names tagScript.setFileName(fileName); tagScript.setElementName(qName); // pop another tag onto the stack if ( parentTag != null ) { tagStack.add( parentTag ); } parentTag = tag; if (textBuffer.length() > 0) { addTextScript(textBuffer.toString()); textBuffer.setLength(0); } script.addScript(tagScript); // start a new body scriptStack.push(script); script = new ScriptBlock(); tag.setBody(script); } else { // XXXX: might wanna handle empty elements later... textBuffer.append("<"); textBuffer.append(qName); int size = list.getLength(); for (int i = 0; i < size; i++) { textBuffer.append(" "); textBuffer.append(list.getQName(i)); textBuffer.append("="); textBuffer.append("\""); textBuffer.append(list.getValue(i)); textBuffer.append("\""); } textBuffer.append(">"); } } catch (SAXException e) { throw e; } catch (Exception e) { log.error( "Caught exception: " + e, e ); throw new SAXException( "Runtime Exception: " + e, e ); } }
|
public void startElement( String namespaceURI, String localName, String qName, Attributes list) throws SAXException { try { // add check to ensure namespace URI is "" for no namespace if ( namespaceURI == null ) { namespaceURI = ""; } // if this is a tag then create a script to run it // otherwise pass the text to the current body tagScript = createTag(namespaceURI, localName, list); if (tagScript == null) { tagScript = createStaticTag(namespaceURI, localName, qName, list); } tagScriptStack.add(tagScript); if (tagScript != null) { // set parent relationship... Tag tag = tagScript.getTag(); tag.setParent(parentTag); // set the namespace Map if ( elementNamespaces != null ) { tagScript.setNamespacesMap( elementNamespaces ); elementNamespaces = null; } // set the line number details if ( locator != null ) { tagScript.setLocator(locator); } // sets the file name element names tagScript.setFileName(fileName); tagScript.setElementName(qName); // pop another tag onto the stack if ( parentTag != null ) { tagStack.add( parentTag ); } parentTag = tag; if (textBuffer.length() > 0) { addTextScript(textBuffer.toString()); textBuffer.setLength(0); } script.addScript(tagScript); // start a new body scriptStack.push(script); script = new ScriptBlock(); tag.setBody(script); } else { // XXXX: might wanna handle empty elements later... textBuffer.append("<"); textBuffer.append(qName); int size = list.getLength(); for (int i = 0; i < size; i++) { textBuffer.append(" "); textBuffer.append(list.getQName(i)); textBuffer.append("="); textBuffer.append("\""); textBuffer.append(list.getValue(i)); textBuffer.append("\""); } textBuffer.append(">"); } } catch (SAXException e) { throw e; } catch (Exception e) { log.error( "Caught exception: " + e, e ); throw new SAXException( "Runtime Exception: " + e, e ); } }
| 1,111,761
|
public void startElement( String namespaceURI, String localName, String qName, Attributes list) throws SAXException { try { // add check to ensure namespace URI is "" for no namespace if ( namespaceURI == null ) { namespaceURI = ""; } // if this is a tag then create a script to run it // otherwise pass the text to the current body tagScript = createTag(namespaceURI, localName, list); if (tagScript == null) { tagScript = createStaticTag(namespaceURI, localName, qName, list); } tagScriptStack.add(tagScript); if (tagScript != null) { // set parent relationship... Tag tag = tagScript.getTag(); tag.setParent(parentTag); // set the namespace Map if ( elementNamespaces != null ) { tagScript.setNamespacesMap( elementNamespaces ); elementNamespaces = null; } // set the line number details if ( locator != null ) { tagScript.setLocator(locator); } // sets the file name element names tagScript.setFileName(fileName); tagScript.setElementName(qName); // pop another tag onto the stack if ( parentTag != null ) { tagStack.add( parentTag ); } parentTag = tag; if (textBuffer.length() > 0) { addTextScript(textBuffer.toString()); textBuffer.setLength(0); } script.addScript(tagScript); // start a new body scriptStack.push(script); script = new ScriptBlock(); tag.setBody(script); } else { // XXXX: might wanna handle empty elements later... textBuffer.append("<"); textBuffer.append(qName); int size = list.getLength(); for (int i = 0; i < size; i++) { textBuffer.append(" "); textBuffer.append(list.getQName(i)); textBuffer.append("="); textBuffer.append("\""); textBuffer.append(list.getValue(i)); textBuffer.append("\""); } textBuffer.append(">"); } } catch (SAXException e) { throw e; } catch (Exception e) { log.error( "Caught exception: " + e, e ); throw new SAXException( "Runtime Exception: " + e, e ); } }
|
public void startElement( String namespaceURI, String localName, String qName, Attributes list) throws SAXException { try { // add check to ensure namespace URI is "" for no namespace if ( namespaceURI == null ) { namespaceURI = ""; } // if this is a tag then create a script to run it // otherwise pass the text to the current body tagScript = createTag(namespaceURI, localName, list); if (tagScript == null) { tagScript = createStaticTag(namespaceURI, localName, qName, list); } tagScriptStack.add(tagScript); if (tagScript != null) { // set parent relationship... Tag tag = tagScript.getTag(); tag.setParent(parentTag); // set the namespace Map if ( elementNamespaces != null ) { tagScript.setNamespacesMap( elementNamespaces ); elementNamespaces = null; } // set the line number details if ( locator != null ) { tagScript.setLocator(locator); } // sets the file name element names tagScript.setFileName(fileName); tagScript.setElementName(qName); // pop another tag onto the stack if ( parentTag != null ) { tagStack.add( parentTag ); } parentTag = tag; if (textBuffer.length() > 0) { addTextScript(textBuffer.toString()); textBuffer.setLength(0); } script.addScript(tagScript); // start a new body scriptStack.push(script); script = new ScriptBlock(); tag.setBody(script); } else { // XXXX: might wanna handle empty elements later... textBuffer.append("<"); textBuffer.append(qName); int size = list.getLength(); for (int i = 0; i < size; i++) { textBuffer.append(" "); textBuffer.append(list.getQName(i)); textBuffer.append("="); textBuffer.append("\""); textBuffer.append(list.getValue(i)); textBuffer.append("\""); } textBuffer.append(">"); } } catch (SAXException e) { throw e; } catch (Exception e) { log.error( "Caught exception: " + e, e ); throw new SAXException( "Runtime Exception: " + e, e ); } }
| 1,111,762
|
public void startElement( String namespaceURI, String localName, String qName, Attributes list) throws SAXException { try { // add check to ensure namespace URI is "" for no namespace if ( namespaceURI == null ) { namespaceURI = ""; } // if this is a tag then create a script to run it // otherwise pass the text to the current body tagScript = createTag(namespaceURI, localName, list); if (tagScript == null) { tagScript = createStaticTag(namespaceURI, localName, qName, list); } tagScriptStack.add(tagScript); if (tagScript != null) { // set parent relationship... Tag tag = tagScript.getTag(); tag.setParent(parentTag); // set the namespace Map if ( elementNamespaces != null ) { tagScript.setNamespacesMap( elementNamespaces ); elementNamespaces = null; } // set the line number details if ( locator != null ) { tagScript.setLocator(locator); } // sets the file name element names tagScript.setFileName(fileName); tagScript.setElementName(qName); // pop another tag onto the stack if ( parentTag != null ) { tagStack.add( parentTag ); } parentTag = tag; if (textBuffer.length() > 0) { addTextScript(textBuffer.toString()); textBuffer.setLength(0); } script.addScript(tagScript); // start a new body scriptStack.push(script); script = new ScriptBlock(); tag.setBody(script); } else { // XXXX: might wanna handle empty elements later... textBuffer.append("<"); textBuffer.append(qName); int size = list.getLength(); for (int i = 0; i < size; i++) { textBuffer.append(" "); textBuffer.append(list.getQName(i)); textBuffer.append("="); textBuffer.append("\""); textBuffer.append(list.getValue(i)); textBuffer.append("\""); } textBuffer.append(">"); } } catch (SAXException e) { throw e; } catch (Exception e) { log.error( "Caught exception: " + e, e ); throw new SAXException( "Runtime Exception: " + e, e ); } }
|
public void startElement( String namespaceURI, String localName, String qName, Attributes list) throws SAXException { try { // add check to ensure namespace URI is "" for no namespace if ( namespaceURI == null ) { namespaceURI = ""; } // if this is a tag then create a script to run it // otherwise pass the text to the current body tagScript = createTag(namespaceURI, localName, list); if (tagScript == null) { tagScript = createStaticTag(namespaceURI, localName, qName, list); } tagScriptStack.add(tagScript); if (tagScript != null) { // set parent relationship... Tag tag = tagScript.getTag(); tag.setParent(parentTag); // set the namespace Map if ( elementNamespaces != null ) { tagScript.setNamespacesMap( elementNamespaces ); elementNamespaces = null; } // set the line number details if ( locator != null ) { tagScript.setLocator(locator); } // sets the file name element names tagScript.setFileName(fileName); tagScript.setElementName(qName); // pop another tag onto the stack if ( parentTag != null ) { tagStack.add( parentTag ); } parentTag = tag; if (textBuffer.length() > 0) { addTextScript(textBuffer.toString()); textBuffer.setLength(0); } script.addScript(tagScript); // start a new body scriptStack.push(script); script = new ScriptBlock(); tagScript.setTagBody(script); } else { // XXXX: might wanna handle empty elements later... textBuffer.append("<"); textBuffer.append(qName); int size = list.getLength(); for (int i = 0; i < size; i++) { textBuffer.append(" "); textBuffer.append(list.getQName(i)); textBuffer.append("="); textBuffer.append("\""); textBuffer.append(list.getValue(i)); textBuffer.append("\""); } textBuffer.append(">"); } } catch (SAXException e) { throw e; } catch (Exception e) { log.error( "Caught exception: " + e, e ); throw new SAXException( "Runtime Exception: " + e, e ); } }
| 1,111,763
|
protected void processBean(String var, Object bean) throws Exception { super.processBean(var, bean); List list = getList(); System.out.println( "Created list: " + list + " with items: " + items ); // if the items variable is specified lets append all the items if (items != null) { Iterator iter = items.evaluateAsIterator(context); while (iter.hasNext()) { list.add( iter.next() ); } } }
|
protected void processBean(String var, Object bean) throws Exception { super.processBean(var, bean); List list = getList(); // if the items variable is specified lets append all the items if (items != null) { Iterator iter = items.evaluateAsIterator(context); while (iter.hasNext()) { list.add( iter.next() ); } } }
| 1,111,764
|
protected void setBeanProperties(Object bean, Map attributes) throws Exception { Object value = attributes.remove("items"); System.out.println( "value: " + value ); super.setBeanProperties(bean, attributes); // #### @todo use same algorithm as evaluateAsIterator() List list = getList(); if (value instanceof Iterator) { Iterator iter = (Iterator) value; while (iter.hasNext()) { list.add( iter.next() ); } } }
|
protected void setBeanProperties(Object bean, Map attributes) throws Exception { Object value = attributes.remove("items"); System.out.println( "value: " + value ); super.setBeanProperties(bean, attributes); // #### @todo use same algorithm as evaluateAsIterator() List list = getList(); if (value instanceof Iterator) { Iterator iter = (Iterator) value; while (iter.hasNext()) { list.add( iter.next() ); } } }
| 1,111,765
|
protected void setBeanProperties(Object bean, Map attributes) throws Exception { Object value = attributes.remove("items"); System.out.println( "value: " + value ); super.setBeanProperties(bean, attributes); // #### @todo use same algorithm as evaluateAsIterator() List list = getList(); if (value instanceof Iterator) { Iterator iter = (Iterator) value; while (iter.hasNext()) { list.add( iter.next() ); } } }
|
protected void setBeanProperties(Object bean, Map attributes) throws Exception { Object value = attributes.remove("items"); System.out.println( "value: " + value ); super.setBeanProperties(bean, attributes); // #### @todo use same algorithm as evaluateAsIterator() List list = getList(); if (value instanceof Iterator) { Iterator iter = (Iterator) value; while (iter.hasNext()) { list.add( iter.next() ); } } }
| 1,111,766
|
protected void registerFactories() { registerBeanFactory( "button", JButton.class ); registerBeanFactory( "checkBox", JCheckBox.class ); registerBeanFactory( "checkBoxMenuItem", JCheckBoxMenuItem.class ); registerBeanFactory( "comboBox", JComboBox.class ); // how to add content there ? // Have a ComboBoxModel (just one should have a Table or Tree Model objects) ? // can the element control it's children ? // but children should also be able to be any component (as Swing comps. are all container) registerBeanFactory( "desktopPane", JDesktopPane.class ); registerBeanFactory( "dialog", JDesktopPane.class ); registerBeanFactory( "frame", JFrame.class ); registerBeanFactory( "internalFrame", JInternalFrame.class ); registerBeanFactory( "label", JLabel.class ); registerBeanFactory( "list", JList.class ); registerBeanFactory( "menu", JMenu.class ); registerBeanFactory( "menuBar", JMenuBar.class ); registerBeanFactory( "menuItem", JMenuItem.class ); registerBeanFactory( "panel", JPanel.class ); registerBeanFactory( "passwordField", JPasswordField.class ); registerBeanFactory( "popupMenu", JPopupMenu.class ); registerBeanFactory( "radioButton", JRadioButton.class ); registerBeanFactory( "radioButtonMenuItem", JRadioButtonMenuItem.class ); registerBeanFactory( "optionPane", JOptionPane.class ); registerBeanFactory( "scrollPane", JScrollPane.class ); registerBeanFactory( "separator", JSeparator.class ); registerFactory( "splitPane", new Factory() { public Object newInstance() { JSplitPane answer = new JSplitPane(); answer.setLeftComponent(null); answer.setRightComponent(null); answer.setTopComponent(null); answer.setBottomComponent(null); return answer; } } ); registerBeanFactory( "tabbedPane", JTabbedPane.class ); registerBeanFactory( "table", JTable.class ); registerBeanFactory( "textArea", JTextArea.class ); registerBeanFactory( "textField", JTextField.class ); registerBeanFactory( "toggleButton", JToggleButton.class ); registerBeanFactory( "tree", JTree.class ); registerBeanFactory( "toolBar", JToolBar.class ); }
|
protected void registerFactories() { registerBeanFactory( "button", JButton.class ); registerBeanFactory( "checkBox", JCheckBox.class ); registerBeanFactory( "checkBoxMenuItem", JCheckBoxMenuItem.class ); registerBeanFactory( "comboBox", JComboBox.class ); // how to add content there ? // Have a ComboBoxModel (just one should have a Table or Tree Model objects) ? // can the element control it's children ? // but children should also be able to be any component (as Swing comps. are all container) registerBeanFactory( "desktopPane", JDesktopPane.class ); registerBeanFactory( "dialog", JDialog.class ); registerBeanFactory( "fileChooser", JFileChooser.class ); registerBeanFactory( "frame", JFrame.class ); registerBeanFactory( "internalFrame", JInternalFrame.class ); registerBeanFactory( "label", JLabel.class ); registerBeanFactory( "list", JList.class ); registerBeanFactory( "menu", JMenu.class ); registerBeanFactory( "menuBar", JMenuBar.class ); registerBeanFactory( "menuItem", JMenuItem.class ); registerBeanFactory( "panel", JPanel.class ); registerBeanFactory( "passwordField", JPasswordField.class ); registerBeanFactory( "popupMenu", JPopupMenu.class ); registerBeanFactory( "radioButton", JRadioButton.class ); registerBeanFactory( "radioButtonMenuItem", JRadioButtonMenuItem.class ); registerBeanFactory( "optionPane", JOptionPane.class ); registerBeanFactory( "scrollPane", JScrollPane.class ); registerBeanFactory( "separator", JSeparator.class ); registerFactory( "splitPane", new Factory() { public Object newInstance() { JSplitPane answer = new JSplitPane(); answer.setLeftComponent(null); answer.setRightComponent(null); answer.setTopComponent(null); answer.setBottomComponent(null); return answer; } } ); registerBeanFactory( "tabbedPane", JTabbedPane.class ); registerBeanFactory( "table", JTable.class ); registerBeanFactory( "textArea", JTextArea.class ); registerBeanFactory( "textField", JTextField.class ); registerBeanFactory( "toggleButton", JToggleButton.class ); registerBeanFactory( "tree", JTree.class ); registerBeanFactory( "toolBar", JToolBar.class ); }
| 1,111,767
|
public void actionPerformed(ActionEvent e) { SQLObject root = (SQLObject) getModel().getRoot(); try { root.addChild(root.getChildCount(), new SQLDatabase(dbcs)); } catch (ArchitectException ex) { logger.warn("Couldn't add new database to tree", ex); JOptionPane.showMessageDialog(DBTree.this, "Couldn't add new connection:\n"+ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } }
|
public void actionPerformed(ActionEvent e) { SQLObject root = (SQLObject) getModel().getRoot(); try { if (dbcsAlreadyExists(dbcs)) { logger.warn("database already exists in this project."); JOptionPane.showMessageDialog(DBTree.this, "Can't add connection, connection already exists in this project.", "Warning", JOptionPane.WARNING_MESSAGE); } else { root.addChild(root.getChildCount(), new SQLDatabase(dbcs)); } } catch (ArchitectException ex) { logger.warn("Couldn't add new database to tree", ex); JOptionPane.showMessageDialog(DBTree.this, "Couldn't add new connection:\n"+ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } }
| 1,111,768
|
private void maybeShowPopup(MouseEvent e) { if (e.isPopupTrigger()) { refreshDBCSMenu(); TreePath p = getPathForLocation(e.getX(), e.getY()); if (p == null) { popup.getComponent(0).setVisible(true); popup.getComponent(1).setVisible(false); popup.getComponent(2).setVisible(false); } else { //SQLObject so = (SQLObject) p.getLastPathComponent(); popup.getComponent(0).setVisible(true); popup.getComponent(1).setVisible(true); popup.getComponent(2).setVisible(true); } setSelectionPath(p); popup.show(e.getComponent(), e.getX(), e.getY()); } }
|
private void maybeShowPopup(MouseEvent e) { if (e.isPopupTrigger()) { refreshDBCSMenu(); TreePath p = getPathForLocation(e.getX(), e.getY()); if (p == null) { popup.getComponent(0).setVisible(true); popup.getComponent(1).setVisible(false); popup.getComponent(2).setVisible(false); } else { //SQLObject so = (SQLObject) p.getLastPathComponent(); popup.getComponent(0).setVisible(true); popup.getComponent(1).setVisible(true); popup.getComponent(2).setVisible(true); } setSelectionPath(p); popup.show(e.getComponent(), e.getX(), e.getY()); } }
| 1,111,769
|
private void maybeShowPopup(MouseEvent e) { if (e.isPopupTrigger()) { refreshDBCSMenu(); TreePath p = getPathForLocation(e.getX(), e.getY()); if (p == null) { popup.getComponent(0).setVisible(true); popup.getComponent(1).setVisible(false); popup.getComponent(2).setVisible(false); } else { //SQLObject so = (SQLObject) p.getLastPathComponent(); popup.getComponent(0).setVisible(true); popup.getComponent(1).setVisible(true); popup.getComponent(2).setVisible(true); } setSelectionPath(p); popup.show(e.getComponent(), e.getX(), e.getY()); } }
|
private void maybeShowPopup(MouseEvent e) { if (e.isPopupTrigger()) { refreshDBCSMenu(); TreePath p = getPathForLocation(e.getX(), e.getY()); if (p == null) { popup.getComponent(0).setVisible(true); popup.getComponent(1).setVisible(false); popup.getComponent(2).setVisible(false); } else { //SQLObject so = (SQLObject) p.getLastPathComponent(); popup.getComponent(0).setVisible(true); popup.getComponent(1).setVisible(true); popup.getComponent(2).setVisible(true); } setSelectionPath(p); popup.show(e.getComponent(), e.getX(), e.getY()); } }
| 1,111,770
|
private void maybeShowPopup(MouseEvent e) { if (e.isPopupTrigger()) { refreshDBCSMenu(); TreePath p = getPathForLocation(e.getX(), e.getY()); if (p == null) { popup.getComponent(0).setVisible(true); popup.getComponent(1).setVisible(false); popup.getComponent(2).setVisible(false); } else { //SQLObject so = (SQLObject) p.getLastPathComponent(); popup.getComponent(0).setVisible(true); popup.getComponent(1).setVisible(true); popup.getComponent(2).setVisible(true); } setSelectionPath(p); popup.show(e.getComponent(), e.getX(), e.getY()); } }
|
private void maybeShowPopup(MouseEvent e) { if (e.isPopupTrigger()) { refreshDBCSMenu(); TreePath p = getPathForLocation(e.getX(), e.getY()); if (p == null) { popup.getComponent(0).setVisible(true); popup.getComponent(1).setVisible(false); popup.getComponent(2).setVisible(false); } else { //SQLObject so = (SQLObject) p.getLastPathComponent(); popup.getComponent(0).setVisible(true); popup.getComponent(1).setVisible(true); popup.getComponent(2).setVisible(true); } setSelectionPath(p); popup.show(e.getComponent(), e.getX(), e.getY()); } }
| 1,111,771
|
protected void refreshDBCSMenu() { popupDBCSMenu.removeAll(); popupDBCSMenu.add(new JMenuItem(newDBCSAction)); popupDBCSMenu.addSeparator(); Iterator it = ArchitectFrame.getMainInstance().getUserSettings().getConnections().iterator(); while(it.hasNext()) { DBConnectionSpec dbcs = (DBConnectionSpec) it.next(); popupDBCSMenu.add(new JMenuItem(new AddDBCSAction(dbcs))); } }
|
protected void refreshDBCSMenu() { popupDBCSMenu.removeAll(); popupDBCSMenu.add(new JMenuItem(newDBCSAction)); popupDBCSMenu.addSeparator(); Iterator it = ArchitectFrame.getMainInstance().getUserSettings().getConnections().iterator(); while(it.hasNext()) { DBConnectionSpec dbcs = (DBConnectionSpec) it.next(); popupDBCSMenu.add(new JMenuItem(new AddDBCSAction(dbcs))); } }
| 1,111,772
|
protected void refreshDBCSMenu() { popupDBCSMenu.removeAll(); popupDBCSMenu.add(new JMenuItem(newDBCSAction)); popupDBCSMenu.addSeparator(); Iterator it = ArchitectFrame.getMainInstance().getUserSettings().getConnections().iterator(); while(it.hasNext()) { DBConnectionSpec dbcs = (DBConnectionSpec) it.next(); popupDBCSMenu.add(new JMenuItem(new AddDBCSAction(dbcs))); } }
|
protected void refreshDBCSMenu() { popupDBCSMenu.removeAll(); popupDBCSMenu.add(new JMenuItem(newDBCSAction)); popupDBCSMenu.addSeparator(); Iterator it = ArchitectFrame.getMainInstance().getUserSettings().getConnections().iterator(); while(it.hasNext()) { DBConnectionSpec dbcs = (DBConnectionSpec) it.next(); if (!suppressNew) { popupDBCSMenu.setText("Add Connection"); popupDBCSMenu.add(new JMenuItem(new AddDBCSAction(dbcs))); } else { popupDBCSMenu.setText("Set Target Database"); popupDBCSMenu.add(new JMenuItem(new setTargetDBCSAction(dbcs))); } } }
| 1,111,773
|
protected JPopupMenu setupPopupMenu() { JPopupMenu newMenu = new JPopupMenu(); newMenu.add(popupDBCSMenu = new JMenu("Add Connection")); newMenu.addSeparator(); // index 1 JMenuItem popupProperties = new JMenuItem(new DBCSPropertiesAction()); newMenu.add(popupProperties); // index 2 if (logger.isDebugEnabled()) { newMenu.addSeparator(); JMenuItem showListeners = new JMenuItem("Show Listeners"); showListeners.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SQLObject so = (SQLObject) getLastSelectedPathComponent(); if (so != null) { JOptionPane.showMessageDialog(DBTree.this, new JScrollPane(new JList(new java.util.Vector(so.getSQLObjectListeners())))); } } }); newMenu.add(showListeners); } return newMenu; }
|
protected JPopupMenu setupPopupMenu() { JPopupMenu newMenu = new JPopupMenu(); newMenu.add(popupDBCSMenu = new JMenu("Add Connection")); newMenu.addSeparator(); // index 1 JMenuItem popupProperties = new JMenuItem(new DBCSPropertiesAction()); newMenu.add(popupProperties); // index 2 if (logger.isDebugEnabled()) { newMenu.addSeparator(); JMenuItem showListeners = new JMenuItem("Show Listeners"); showListeners.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SQLObject so = (SQLObject) getLastSelectedPathComponent(); if (so != null) { JOptionPane.showMessageDialog(DBTree.this, new JScrollPane(new JList(new java.util.Vector(so.getSQLObjectListeners())))); } } }); newMenu.add(showListeners); } return newMenu; }
| 1,111,774
|
public void testDisableSourceDatabaseComponents() { JFrame frame = new JFrame(); frame.setContentPane(panel); frame.pack(); frame.setVisible(true); assertFalse(sourceDatabaseDropdown.isEnabled()); assertFalse(sourceNewConnButton.isEnabled()); assertFalse(sourceCatalogDropdown.isEnabled()); assertFalse(sourceSchemaDropdown.isEnabled()); assertFalse(sourceLoadRadio.isEnabled()); assertFalse(sourceLoadFilePath.isEnabled()); assertFalse(sourceLoadFileButton.isEnabled()); flushAWT(); // Select the database drop down // This is not the point of the test but has to be done Point p = sourcePhysicalRadio.getLocationOnScreen(); robot.mouseMove(p.x, p.y); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); flushAWT(); assertTrue(sourceDatabaseDropdown.isEnabled()); assertTrue(sourceNewConnButton.isEnabled()); assertFalse(sourceCatalogDropdown.isEnabled()); assertFalse(sourceSchemaDropdown.isEnabled()); p = sourcePlayPenRadio.getLocationOnScreen(); robot.mouseMove(p.x, p.y); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); flushAWT(); assertFalse(sourceDatabaseDropdown.isEnabled()); assertFalse(sourceNewConnButton.isEnabled()); assertFalse(sourceCatalogDropdown.isEnabled()); assertFalse(sourceSchemaDropdown.isEnabled()); frame.dispose(); }
|
public void testDisableSourceDatabaseComponents() { JFrame frame = new JFrame(); frame.setContentPane(panel); frame.pack(); frame.setVisible(true); assertFalse(sourceDatabaseDropdown.isEnabled()); assertFalse(sourceNewConnButton.isEnabled()); assertFalse(sourceCatalogDropdown.isEnabled()); assertFalse(sourceSchemaDropdown.isEnabled()); assertFalse(sourceLoadFilePath.isEnabled()); assertFalse(sourceLoadFileButton.isEnabled()); flushAWT(); // Select the database drop down // This is not the point of the test but has to be done Point p = sourcePhysicalRadio.getLocationOnScreen(); robot.mouseMove(p.x, p.y); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); flushAWT(); assertTrue(sourceDatabaseDropdown.isEnabled()); assertTrue(sourceNewConnButton.isEnabled()); assertFalse(sourceCatalogDropdown.isEnabled()); assertFalse(sourceSchemaDropdown.isEnabled()); p = sourcePlayPenRadio.getLocationOnScreen(); robot.mouseMove(p.x, p.y); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); flushAWT(); assertFalse(sourceDatabaseDropdown.isEnabled()); assertFalse(sourceNewConnButton.isEnabled()); assertFalse(sourceCatalogDropdown.isEnabled()); assertFalse(sourceSchemaDropdown.isEnabled()); frame.dispose(); }
| 1,111,775
|
private void doBatch() { Vector files; File batchFile; File dataFile; String line; StringTokenizer tok; String infoMaybe =""; files = new Vector(); if(batchFileName == null) { return; } batchFile = new File(this.batchFileName); if(!batchFile.exists()) { System.out.println("batch file " + batchFileName + " does not exist"); System.exit(1); } if (!quietMode) System.out.println("Processing batch input file: " + batchFile); try { BufferedReader br = new BufferedReader(new FileReader(batchFile)); while( (line = br.readLine()) != null ) { files.add(line); } br.close(); for(int i = 0;i<files.size();i++){ line = (String)files.get(i); tok = new StringTokenizer(line); infoMaybe = ""; if(tok.hasMoreTokens()){ dataFile = new File(tok.nextToken()); if(tok.hasMoreTokens()){ infoMaybe = tok.nextToken(); } if(dataFile.exists()) { String name = dataFile.getName(); if( name.substring(name.length()-4,name.length()).equalsIgnoreCase(".ped") ) { processFile(name,PED_FILE,infoMaybe); } else if(name.substring(name.length()-5,name.length()).equalsIgnoreCase(".haps")) { processFile(name,HAPS_FILE,infoMaybe); } else if(name.substring(name.length()-4,name.length()).equalsIgnoreCase(".hmp")){ processFile(name,HMP_FILE,""); } else{ if (!quietMode){ System.out.println("Filenames in batch file must end in .ped, .haps or .hmp\n" + name + " is not properly formatted."); } } } else { if(!quietMode){ System.out.println("file " + dataFile.getName() + " listed in the batch file could not be found"); } } } } } catch(FileNotFoundException e){ System.out.println("the following error has occured:\n" + e.toString()); } catch(IOException e){ System.out.println("the following error has occured:\n" + e.toString()); } }
|
private void doBatch() { Vector files; File batchFile; File dataFile; String line; StringTokenizer tok; String infoMaybe =null; files = new Vector(); if(batchFileName == null) { return; } batchFile = new File(this.batchFileName); if(!batchFile.exists()) { System.out.println("batch file " + batchFileName + " does not exist"); System.exit(1); } if (!quietMode) System.out.println("Processing batch input file: " + batchFile); try { BufferedReader br = new BufferedReader(new FileReader(batchFile)); while( (line = br.readLine()) != null ) { files.add(line); } br.close(); for(int i = 0;i<files.size();i++){ line = (String)files.get(i); tok = new StringTokenizer(line); infoMaybe = ""; if(tok.hasMoreTokens()){ dataFile = new File(tok.nextToken()); if(tok.hasMoreTokens()){ infoMaybe = tok.nextToken(); } if(dataFile.exists()) { String name = dataFile.getName(); if( name.substring(name.length()-4,name.length()).equalsIgnoreCase(".ped") ) { processFile(name,PED_FILE,infoMaybe); } else if(name.substring(name.length()-5,name.length()).equalsIgnoreCase(".haps")) { processFile(name,HAPS_FILE,infoMaybe); } else if(name.substring(name.length()-4,name.length()).equalsIgnoreCase(".hmp")){ processFile(name,HMP_FILE,""); } else{ if (!quietMode){ System.out.println("Filenames in batch file must end in .ped, .haps or .hmp\n" + name + " is not properly formatted."); } } } else { if(!quietMode){ System.out.println("file " + dataFile.getName() + " listed in the batch file could not be found"); } } } } } catch(FileNotFoundException e){ System.out.println("the following error has occured:\n" + e.toString()); } catch(IOException e){ System.out.println("the following error has occured:\n" + e.toString()); } }
| 1,111,776
|
private void doBatch() { Vector files; File batchFile; File dataFile; String line; StringTokenizer tok; String infoMaybe =""; files = new Vector(); if(batchFileName == null) { return; } batchFile = new File(this.batchFileName); if(!batchFile.exists()) { System.out.println("batch file " + batchFileName + " does not exist"); System.exit(1); } if (!quietMode) System.out.println("Processing batch input file: " + batchFile); try { BufferedReader br = new BufferedReader(new FileReader(batchFile)); while( (line = br.readLine()) != null ) { files.add(line); } br.close(); for(int i = 0;i<files.size();i++){ line = (String)files.get(i); tok = new StringTokenizer(line); infoMaybe = ""; if(tok.hasMoreTokens()){ dataFile = new File(tok.nextToken()); if(tok.hasMoreTokens()){ infoMaybe = tok.nextToken(); } if(dataFile.exists()) { String name = dataFile.getName(); if( name.substring(name.length()-4,name.length()).equalsIgnoreCase(".ped") ) { processFile(name,PED_FILE,infoMaybe); } else if(name.substring(name.length()-5,name.length()).equalsIgnoreCase(".haps")) { processFile(name,HAPS_FILE,infoMaybe); } else if(name.substring(name.length()-4,name.length()).equalsIgnoreCase(".hmp")){ processFile(name,HMP_FILE,""); } else{ if (!quietMode){ System.out.println("Filenames in batch file must end in .ped, .haps or .hmp\n" + name + " is not properly formatted."); } } } else { if(!quietMode){ System.out.println("file " + dataFile.getName() + " listed in the batch file could not be found"); } } } } } catch(FileNotFoundException e){ System.out.println("the following error has occured:\n" + e.toString()); } catch(IOException e){ System.out.println("the following error has occured:\n" + e.toString()); } }
|
private void doBatch() { Vector files; File batchFile; File dataFile; String line; StringTokenizer tok; String infoMaybe =""; files = new Vector(); if(batchFileName == null) { return; } batchFile = new File(this.batchFileName); if(!batchFile.exists()) { System.out.println("batch file " + batchFileName + " does not exist"); System.exit(1); } if (!quietMode) System.out.println("Processing batch input file: " + batchFile); try { BufferedReader br = new BufferedReader(new FileReader(batchFile)); while( (line = br.readLine()) != null ) { files.add(line); } br.close(); for(int i = 0;i<files.size();i++){ line = (String)files.get(i); tok = new StringTokenizer(line); infoMaybe = null; if(tok.hasMoreTokens()){ dataFile = new File(tok.nextToken()); if(tok.hasMoreTokens()){ infoMaybe = tok.nextToken(); } if(dataFile.exists()) { String name = dataFile.getName(); if( name.substring(name.length()-4,name.length()).equalsIgnoreCase(".ped") ) { processFile(name,PED_FILE,infoMaybe); } else if(name.substring(name.length()-5,name.length()).equalsIgnoreCase(".haps")) { processFile(name,HAPS_FILE,infoMaybe); } else if(name.substring(name.length()-4,name.length()).equalsIgnoreCase(".hmp")){ processFile(name,HMP_FILE,""); } else{ if (!quietMode){ System.out.println("Filenames in batch file must end in .ped, .haps or .hmp\n" + name + " is not properly formatted."); } } } else { if(!quietMode){ System.out.println("file " + dataFile.getName() + " listed in the batch file could not be found"); } } } } } catch(FileNotFoundException e){ System.out.println("the following error has occured:\n" + e.toString()); } catch(IOException e){ System.out.println("the following error has occured:\n" + e.toString()); } }
| 1,111,777
|
public Object findVariable(String name) { Object answer = variables.get(name); if ( answer == null && parent != null ) { answer = parent.findVariable(name); // ### this is a hack - remove this when we have support for pluggable Scopes if ( answer == null ) { try { answer = System.getProperty(name); } catch (Throwable t) { // ignore security exceptions } } } return answer; }
|
public Object findVariable(String name) { Object answer = variables.get(name); if ( answer == null && parent != null ) { answer = parent.findVariable(name); // ### this is a hack - remove this when we have support for pluggable Scopes if ( answer == null ) { try { answer = System.getProperty(name); } catch (Throwable t) { // ignore security exceptions } } } return answer; }
| 1,111,778
|
public JUnitTagLibrary() { registerTag("assert", AssertTag.class); registerTag("assertEquals", AssertEqualsTag.class); registerTag("fail", FailTag.class); registerTag("run", RunTestTag.class ); registerTag("case", TestCaseTag.class ); registerTag("suite", TestSuiteTag.class ); }
|
public JUnitTagLibrary() { registerTag("assert", AssertTag.class); registerTag("assertEquals", AssertEqualsTag.class); registerTag("fail", FailTag.class); registerTag("run", RunTestTag.class ); registerTag("case", TestCaseTag.class ); registerTag("suite", TestSuiteTag.class ); }
| 1,111,779
|
private void generateClass() throws SupportException { // Declare some types. final TypeDesc storableType = TypeDesc.forClass(Storable.class); final TypeDesc triggerSupportType = TypeDesc.forClass(TriggerSupport.class); final TypeDesc masterSupportType = TypeDesc.forClass(MasterSupport.class); final TypeDesc transactionType = TypeDesc.forClass(Transaction.class); final TypeDesc optimisticLockType = TypeDesc.forClass(OptimisticLockException.class); final TypeDesc persistExceptionType = TypeDesc.forClass(PersistException.class); // Add constructor that accepts a MasterSupport. { TypeDesc[] params = {masterSupportType}; MethodInfo mi = mClassFile.addConstructor(Modifiers.PUBLIC, params); CodeBuilder b = new CodeBuilder(mi); b.loadThis(); b.loadLocal(b.getParameter(0)); b.invokeSuperConstructor(new TypeDesc[] {triggerSupportType}); b.returnVoid(); } // Declare protected abstract methods. { MethodInfo mi = mClassFile.addMethod (Modifiers.PROTECTED.toAbstract(true), DO_TRY_INSERT_MASTER_METHOD_NAME, TypeDesc.BOOLEAN, null); mi.addException(persistExceptionType); mi = mClassFile.addMethod (Modifiers.PROTECTED.toAbstract(true), DO_TRY_UPDATE_MASTER_METHOD_NAME, TypeDesc.BOOLEAN, null); mi.addException(persistExceptionType); mi = mClassFile.addMethod (Modifiers.PROTECTED.toAbstract(true), DO_TRY_DELETE_MASTER_METHOD_NAME, TypeDesc.BOOLEAN, null); mi.addException(persistExceptionType); } // Add required protected doTryInsert method. { // If sequence support requested, implement special insert hook to // call sequences for properties which are UNINITIALIZED. User may // provide explicit values for properties with sequences. if (mFeatures.contains(MasterFeature.INSERT_SEQUENCES)) { MethodInfo mi = mClassFile.addMethod (Modifiers.PROTECTED, StorableGenerator.CHECK_PK_FOR_INSERT_METHOD_NAME, null, null); CodeBuilder b = new CodeBuilder(mi); int ordinal = 0; for (StorableProperty<S> property : mAllProperties.values()) { if (property.getSequenceName() != null) { // Check the state of this property, to see if it is // uninitialized. Uninitialized state has value zero. String stateFieldName = StorableGenerator.PROPERTY_STATE_FIELD_NAME + (ordinal >> 4); b.loadThis(); b.loadField(stateFieldName, TypeDesc.INT); int shift = (ordinal & 0xf) * 2; b.loadConstant(StorableGenerator.PROPERTY_STATE_MASK << shift); b.math(Opcode.IAND); Label isInitialized = b.createLabel(); b.ifZeroComparisonBranch(isInitialized, "!="); // Load this in preparation for storing value to property. b.loadThis(); // Call MasterSupport.getSequenceValueProducer(String). TypeDesc seqValueProdType = TypeDesc.forClass(SequenceValueProducer.class); b.loadThis(); b.loadField(StorableGenerator.SUPPORT_FIELD_NAME, triggerSupportType); b.checkCast(masterSupportType); b.loadConstant(property.getSequenceName()); b.invokeInterface (masterSupportType, "getSequenceValueProducer", seqValueProdType, new TypeDesc[] {TypeDesc.STRING}); // Find appropriate method to call for getting next sequence value. TypeDesc propertyType = TypeDesc.forClass(property.getType()); TypeDesc propertyObjType = propertyType.toObjectType(); Method method; try { if (propertyObjType == TypeDesc.LONG.toObjectType()) { method = SequenceValueProducer.class .getMethod("nextLongValue", (Class[]) null); } else if (propertyObjType == TypeDesc.INT.toObjectType()) { method = SequenceValueProducer.class .getMethod("nextIntValue", (Class[]) null); } else if (propertyObjType == TypeDesc.STRING) { method = SequenceValueProducer.class .getMethod("nextDecimalValue", (Class[]) null); } else { throw new SupportException ("Unable to support sequence of type \"" + property.getType().getName() + "\" for property: " + property.getName()); } } catch (NoSuchMethodException e) { Error err = new NoSuchMethodError(); err.initCause(e); throw err; } b.invoke(method); b.convert(TypeDesc.forClass(method.getReturnType()), propertyType); // Store property b.storeField(property.getName(), propertyType); // Set state to dirty. b.loadThis(); b.loadThis(); b.loadField(stateFieldName, TypeDesc.INT); b.loadConstant(StorableGenerator.PROPERTY_STATE_DIRTY << shift); b.math(Opcode.IOR); b.storeField(stateFieldName, TypeDesc.INT); isInitialized.setLocation(); } ordinal++; } // We've tried our best to fill in missing values, now run the // original check method. b.loadThis(); b.invokeSuper(mClassFile.getSuperClassName(), StorableGenerator.CHECK_PK_FOR_INSERT_METHOD_NAME, null, null); b.returnVoid(); } MethodInfo mi = mClassFile.addMethod (Modifiers.PROTECTED.toFinal(true), StorableGenerator.DO_TRY_INSERT_METHOD_NAME, TypeDesc.BOOLEAN, null); mi.addException(persistExceptionType); CodeBuilder b = new CodeBuilder(mi); LocalVariable txnVar = b.createLocalVariable(null, transactionType); Label tryStart = addEnterTransaction(b, INSERT_OP, txnVar); if (mFeatures.contains(MasterFeature.VERSIONING)) { // Only set if uninitialized. b.loadThis(); b.invokeVirtual(StorableGenerator.IS_VERSION_INITIALIZED_METHOD_NAME, TypeDesc.BOOLEAN, null); Label isInitialized = b.createLabel(); b.ifZeroComparisonBranch(isInitialized, "!="); addAdjustVersionProperty(b, null, 1); isInitialized.setLocation(); } if (mFeatures.contains(MasterFeature.INSERT_CHECK_REQUIRED)) { // Ensure that required properties have been set. b.loadThis(); b.invokeVirtual(StorableGenerator.IS_REQUIRED_DATA_INITIALIZED_METHOD_NAME, TypeDesc.BOOLEAN, null); Label isInitialized = b.createLabel(); b.ifZeroComparisonBranch(isInitialized, "!="); // Throw a ConstraintException. TypeDesc exType = TypeDesc.forClass(ConstraintException.class); b.newObject(exType); b.dup(); // Append all the uninitialized property names to the exception message. LocalVariable countVar = b.createLocalVariable(null, TypeDesc.INT); b.loadConstant(0); b.storeLocal(countVar); TypeDesc sbType = TypeDesc.forClass(StringBuilder.class); b.newObject(sbType); b.dup(); b.loadConstant("Not all required properties have been set: "); TypeDesc[] stringParam = {TypeDesc.STRING}; b.invokeConstructor(sbType, stringParam); LocalVariable sbVar = b.createLocalVariable(null, sbType); b.storeLocal(sbVar); int ordinal = -1; HashSet<Integer> stateAppendMethods = new HashSet<Integer>(); // Parameters are: StringBuilder, count, mask, property name TypeDesc[] appendParams = {sbType, TypeDesc.INT, TypeDesc.INT, TypeDesc.STRING}; for (StorableProperty<S> property : mAllProperties.values()) { ordinal++; if (property.isJoin() || property.isPrimaryKeyMember() || property.isNullable()) { continue; } int stateField = ordinal >> 4; String stateAppendMethodName = APPEND_UNINIT_PROPERTY + stateField; if (!stateAppendMethods.contains(stateField)) { stateAppendMethods.add(stateField); MethodInfo mi2 = mClassFile.addMethod (Modifiers.PRIVATE, stateAppendMethodName, TypeDesc.INT, appendParams); CodeBuilder b2 = new CodeBuilder(mi2); // Load the StringBuilder parameter. b2.loadLocal(b2.getParameter(0)); String stateFieldName = StorableGenerator.PROPERTY_STATE_FIELD_NAME + (ordinal >> 4); b2.loadThis(); b2.loadField(stateFieldName, TypeDesc.INT); // Load the mask parameter. b2.loadLocal(b2.getParameter(2)); b2.math(Opcode.IAND); Label propIsInitialized = b2.createLabel(); b2.ifZeroComparisonBranch(propIsInitialized, "!="); // Load the count parameter. b2.loadLocal(b2.getParameter(1)); Label noComma = b2.createLabel(); b2.ifZeroComparisonBranch(noComma, "=="); b2.loadConstant(", "); b2.invokeVirtual(sbType, "append", sbType, stringParam); noComma.setLocation(); // Load the property name parameter. b2.loadLocal(b2.getParameter(3)); b2.invokeVirtual(sbType, "append", sbType, stringParam); // Increment the count parameter. b2.integerIncrement(b2.getParameter(1), 1); propIsInitialized.setLocation(); // Return the possibly updated count. b2.loadLocal(b2.getParameter(1)); b2.returnValue(TypeDesc.INT); } b.loadThis(); // Parameters are: StringBuilder, count, mask, property name b.loadLocal(sbVar); b.loadLocal(countVar); b.loadConstant(StorableGenerator.PROPERTY_STATE_MASK << ((ordinal & 0xf) * 2)); b.loadConstant(property.getName()); b.invokePrivate(stateAppendMethodName, TypeDesc.INT, appendParams); b.storeLocal(countVar); } b.loadLocal(sbVar); b.invokeVirtual(sbType, "toString", TypeDesc.STRING, null); b.invokeConstructor(exType, new TypeDesc[] {TypeDesc.STRING}); b.throwObject(); isInitialized.setLocation(); } b.loadThis(); b.invokeVirtual(DO_TRY_INSERT_MASTER_METHOD_NAME, TypeDesc.BOOLEAN, null); if (tryStart == null) { b.returnValue(TypeDesc.BOOLEAN); } else { Label failed = b.createLabel(); b.ifZeroComparisonBranch(failed, "=="); addCommitAndExitTransaction(b, INSERT_OP, txnVar); b.loadConstant(true); b.returnValue(TypeDesc.BOOLEAN); failed.setLocation(); addExitTransaction(b, INSERT_OP, txnVar); b.loadConstant(false); b.returnValue(TypeDesc.BOOLEAN); addExitTransaction(b, INSERT_OP, txnVar, tryStart); } } // Add required protected doTryUpdate method. addDoTryUpdate: { MethodInfo mi = mClassFile.addMethod (Modifiers.PROTECTED.toFinal(true), StorableGenerator.DO_TRY_UPDATE_METHOD_NAME, TypeDesc.BOOLEAN, null); mi.addException(persistExceptionType); CodeBuilder b = new CodeBuilder(mi); if ((!mFeatures.contains(MasterFeature.VERSIONING)) && (!mFeatures.contains(MasterFeature.UPDATE_FULL))) { // Nothing special needs to be done, so just delegate and return. b.loadThis(); b.invokeVirtual(DO_TRY_UPDATE_MASTER_METHOD_NAME, TypeDesc.BOOLEAN, null); b.returnValue(TypeDesc.BOOLEAN); break addDoTryUpdate; } LocalVariable txnVar = b.createLocalVariable(null, transactionType); LocalVariable savedVar = null; Label tryStart = addEnterTransaction(b, UPDATE_OP, txnVar); Label failed = b.createLabel(); if (mFeatures.contains(MasterFeature.UPDATE_FULL)) { // Storable saved = copy(); b.loadThis(); b.invokeVirtual(COPY_METHOD_NAME, storableType, null); b.checkCast(mClassFile.getType()); savedVar = b.createLocalVariable(null, mClassFile.getType()); b.storeLocal(savedVar); // if (!saved.tryLoad()) { // goto failed; // } b.loadLocal(savedVar); b.invokeInterface(storableType, TRY_LOAD_METHOD_NAME, TypeDesc.BOOLEAN, null); b.ifZeroComparisonBranch(failed, "=="); // if (version support enabled) { // if (this.getVersionNumber() != saved.getVersionNumber()) { // throw new OptimisticLockException // (this.getVersionNumber(), saved.getVersionNumber(), this); // } // } if (mFeatures.contains(MasterFeature.VERSIONING)) { TypeDesc versionType = TypeDesc.forClass(mInfo.getVersionProperty().getType()); b.loadThis(); b.invoke(mInfo.getVersionProperty().getReadMethod()); b.loadLocal(savedVar); b.invoke(mInfo.getVersionProperty().getReadMethod()); Label sameVersion = b.createLabel(); CodeBuilderUtil.addValuesEqualCall(b, versionType, true, sameVersion, true); b.newObject(optimisticLockType); b.dup(); b.loadThis(); b.invoke(mInfo.getVersionProperty().getReadMethod()); b.convert(versionType, TypeDesc.OBJECT); b.loadLocal(savedVar); b.invoke(mInfo.getVersionProperty().getReadMethod()); b.convert(versionType, TypeDesc.OBJECT); b.loadThis(); b.invokeConstructor (optimisticLockType, new TypeDesc[] {TypeDesc.OBJECT, TypeDesc.OBJECT, storableType}); b.throwObject(); sameVersion.setLocation(); } // this.copyDirtyProperties(saved); // if (version support enabled) { // saved.setVersionNumber(saved.getVersionNumber() + 1); // } b.loadThis(); b.loadLocal(savedVar); b.invokeVirtual(COPY_DIRTY_PROPERTIES, null, new TypeDesc[] {storableType}); if (mFeatures.contains(MasterFeature.VERSIONING)) { addAdjustVersionProperty(b, savedVar, -1); } // if (!saved.doTryUpdateMaster()) { // goto failed; // } b.loadLocal(savedVar); b.invokeVirtual(DO_TRY_UPDATE_MASTER_METHOD_NAME, TypeDesc.BOOLEAN, null); b.ifZeroComparisonBranch(failed, "=="); // saved.copyUnequalProperties(this); b.loadLocal(savedVar); b.loadThis(); b.invokeInterface (storableType, COPY_UNEQUAL_PROPERTIES, null, new TypeDesc[] {storableType}); } else { // if (!this.doTryUpdateMaster()) { // goto failed; // } b.loadThis(); b.invokeVirtual(DO_TRY_UPDATE_MASTER_METHOD_NAME, TypeDesc.BOOLEAN, null); b.ifZeroComparisonBranch(failed, "=="); } // txn.commit(); // txn.exit(); // return true; addCommitAndExitTransaction(b, UPDATE_OP, txnVar); b.loadConstant(true); b.returnValue(TypeDesc.BOOLEAN); // failed: // txn.exit(); failed.setLocation(); addExitTransaction(b, UPDATE_OP, txnVar); // return false; b.loadConstant(false); b.returnValue(TypeDesc.BOOLEAN); addExitTransaction(b, UPDATE_OP, txnVar, tryStart); } // Add required protected doTryDelete method. { MethodInfo mi = mClassFile.addMethod (Modifiers.PROTECTED.toFinal(true), StorableGenerator.DO_TRY_DELETE_METHOD_NAME, TypeDesc.BOOLEAN, null); mi.addException(persistExceptionType); CodeBuilder b = new CodeBuilder(mi); LocalVariable txnVar = b.createLocalVariable(null, transactionType); Label tryStart = addEnterTransaction(b, DELETE_OP, txnVar); b.loadThis(); b.invokeVirtual(DO_TRY_DELETE_MASTER_METHOD_NAME, TypeDesc.BOOLEAN, null); if (tryStart == null) { b.returnValue(TypeDesc.BOOLEAN); } else { Label failed = b.createLabel(); b.ifZeroComparisonBranch(failed, "=="); addCommitAndExitTransaction(b, DELETE_OP, txnVar); b.loadConstant(true); b.returnValue(TypeDesc.BOOLEAN); failed.setLocation(); addExitTransaction(b, DELETE_OP, txnVar); b.loadConstant(false); b.returnValue(TypeDesc.BOOLEAN); addExitTransaction(b, DELETE_OP, txnVar, tryStart); } } }
|
private void generateClass() throws SupportException { // Declare some types. final TypeDesc storableType = TypeDesc.forClass(Storable.class); final TypeDesc triggerSupportType = TypeDesc.forClass(TriggerSupport.class); final TypeDesc masterSupportType = TypeDesc.forClass(MasterSupport.class); final TypeDesc transactionType = TypeDesc.forClass(Transaction.class); final TypeDesc optimisticLockType = TypeDesc.forClass(OptimisticLockException.class); final TypeDesc persistExceptionType = TypeDesc.forClass(PersistException.class); // Add constructor that accepts a MasterSupport. { TypeDesc[] params = {masterSupportType}; MethodInfo mi = mClassFile.addConstructor(Modifiers.PUBLIC, params); CodeBuilder b = new CodeBuilder(mi); b.loadThis(); b.loadLocal(b.getParameter(0)); b.invokeSuperConstructor(new TypeDesc[] {triggerSupportType}); b.returnVoid(); } // Declare protected abstract methods. { MethodInfo mi = mClassFile.addMethod (Modifiers.PROTECTED.toAbstract(true), DO_TRY_INSERT_MASTER_METHOD_NAME, TypeDesc.BOOLEAN, null); mi.addException(persistExceptionType); mi = mClassFile.addMethod (Modifiers.PROTECTED.toAbstract(true), DO_TRY_UPDATE_MASTER_METHOD_NAME, TypeDesc.BOOLEAN, null); mi.addException(persistExceptionType); mi = mClassFile.addMethod (Modifiers.PROTECTED.toAbstract(true), DO_TRY_DELETE_MASTER_METHOD_NAME, TypeDesc.BOOLEAN, null); mi.addException(persistExceptionType); } // Add required protected doTryInsert method. { // If sequence support requested, implement special insert hook to // call sequences for properties which are UNINITIALIZED. User may // provide explicit values for properties with sequences. if (mFeatures.contains(MasterFeature.INSERT_SEQUENCES)) { MethodInfo mi = mClassFile.addMethod (Modifiers.PROTECTED, StorableGenerator.CHECK_PK_FOR_INSERT_METHOD_NAME, null, null); CodeBuilder b = new CodeBuilder(mi); int ordinal = 0; for (StorableProperty<S> property : mAllProperties.values()) { if (property.getSequenceName() != null) { // Check the state of this property, to see if it is // uninitialized. Uninitialized state has value zero. String stateFieldName = StorableGenerator.PROPERTY_STATE_FIELD_NAME + (ordinal >> 4); b.loadThis(); b.loadField(stateFieldName, TypeDesc.INT); int shift = (ordinal & 0xf) * 2; b.loadConstant(StorableGenerator.PROPERTY_STATE_MASK << shift); b.math(Opcode.IAND); Label isInitialized = b.createLabel(); b.ifZeroComparisonBranch(isInitialized, "!="); // Load this in preparation for storing value to property. b.loadThis(); // Call MasterSupport.getSequenceValueProducer(String). TypeDesc seqValueProdType = TypeDesc.forClass(SequenceValueProducer.class); b.loadThis(); b.loadField(StorableGenerator.SUPPORT_FIELD_NAME, triggerSupportType); b.checkCast(masterSupportType); b.loadConstant(property.getSequenceName()); b.invokeInterface (masterSupportType, "getSequenceValueProducer", seqValueProdType, new TypeDesc[] {TypeDesc.STRING}); // Find appropriate method to call for getting next sequence value. TypeDesc propertyType = TypeDesc.forClass(property.getType()); TypeDesc propertyObjType = propertyType.toObjectType(); Method method; try { if (propertyObjType == TypeDesc.LONG.toObjectType()) { method = SequenceValueProducer.class .getMethod("nextLongValue", (Class[]) null); } else if (propertyObjType == TypeDesc.INT.toObjectType()) { method = SequenceValueProducer.class .getMethod("nextIntValue", (Class[]) null); } else if (propertyObjType == TypeDesc.STRING) { method = SequenceValueProducer.class .getMethod("nextDecimalValue", (Class[]) null); } else { throw new SupportException ("Unable to support sequence of type \"" + property.getType().getName() + "\" for property: " + property.getName()); } } catch (NoSuchMethodException e) { Error err = new NoSuchMethodError(); err.initCause(e); throw err; } b.invoke(method); b.convert(TypeDesc.forClass(method.getReturnType()), propertyType); // Store property b.storeField(property.getName(), propertyType); // Set state to dirty. b.loadThis(); b.loadThis(); b.loadField(stateFieldName, TypeDesc.INT); b.loadConstant(StorableGenerator.PROPERTY_STATE_DIRTY << shift); b.math(Opcode.IOR); b.storeField(stateFieldName, TypeDesc.INT); isInitialized.setLocation(); } ordinal++; } // We've tried our best to fill in missing values, now run the // original check method. b.loadThis(); b.invokeSuper(mClassFile.getSuperClassName(), StorableGenerator.CHECK_PK_FOR_INSERT_METHOD_NAME, null, null); b.returnVoid(); } MethodInfo mi = mClassFile.addMethod (Modifiers.PROTECTED.toFinal(true), StorableGenerator.DO_TRY_INSERT_METHOD_NAME, TypeDesc.BOOLEAN, null); mi.addException(persistExceptionType); CodeBuilder b = new CodeBuilder(mi); LocalVariable txnVar = b.createLocalVariable(null, transactionType); Label tryStart = addEnterTransaction(b, INSERT_OP, txnVar); if (mFeatures.contains(MasterFeature.VERSIONING)) { // Only set if uninitialized. b.loadThis(); b.invokeVirtual(StorableGenerator.IS_VERSION_INITIALIZED_METHOD_NAME, TypeDesc.BOOLEAN, null); Label isInitialized = b.createLabel(); b.ifZeroComparisonBranch(isInitialized, "!="); addAdjustVersionProperty(b, null, 1); isInitialized.setLocation(); } if (mFeatures.contains(MasterFeature.INSERT_CHECK_REQUIRED)) { // Ensure that required properties have been set. b.loadThis(); b.invokeVirtual(StorableGenerator.IS_REQUIRED_DATA_INITIALIZED_METHOD_NAME, TypeDesc.BOOLEAN, null); Label isInitialized = b.createLabel(); b.ifZeroComparisonBranch(isInitialized, "!="); // Throw a ConstraintException. TypeDesc exType = TypeDesc.forClass(ConstraintException.class); b.newObject(exType); b.dup(); // Append all the uninitialized property names to the exception message. LocalVariable countVar = b.createLocalVariable(null, TypeDesc.INT); b.loadConstant(0); b.storeLocal(countVar); TypeDesc sbType = TypeDesc.forClass(StringBuilder.class); b.newObject(sbType); b.dup(); b.loadConstant("Not all required properties have been set: "); TypeDesc[] stringParam = {TypeDesc.STRING}; b.invokeConstructor(sbType, stringParam); LocalVariable sbVar = b.createLocalVariable(null, sbType); b.storeLocal(sbVar); int ordinal = -1; HashSet<Integer> stateAppendMethods = new HashSet<Integer>(); // Parameters are: StringBuilder, count, mask, property name TypeDesc[] appendParams = {sbType, TypeDesc.INT, TypeDesc.INT, TypeDesc.STRING}; for (StorableProperty<S> property : mAllProperties.values()) { ordinal++; if (property.isJoin() || property.isPrimaryKeyMember() || property.isNullable()) { continue; } int stateField = ordinal >> 4; String stateAppendMethodName = APPEND_UNINIT_PROPERTY + stateField; if (!stateAppendMethods.contains(stateField)) { stateAppendMethods.add(stateField); MethodInfo mi2 = mClassFile.addMethod (Modifiers.PRIVATE, stateAppendMethodName, TypeDesc.INT, appendParams); CodeBuilder b2 = new CodeBuilder(mi2); // Load the StringBuilder parameter. b2.loadLocal(b2.getParameter(0)); String stateFieldName = StorableGenerator.PROPERTY_STATE_FIELD_NAME + (ordinal >> 4); b2.loadThis(); b2.loadField(stateFieldName, TypeDesc.INT); // Load the mask parameter. b2.loadLocal(b2.getParameter(2)); b2.math(Opcode.IAND); Label propIsInitialized = b2.createLabel(); b2.ifZeroComparisonBranch(propIsInitialized, "!="); // Load the count parameter. b2.loadLocal(b2.getParameter(1)); Label noComma = b2.createLabel(); b2.ifZeroComparisonBranch(noComma, "=="); b2.loadConstant(", "); b2.invokeVirtual(sbType, "append", sbType, stringParam); noComma.setLocation(); // Load the property name parameter. b2.loadLocal(b2.getParameter(3)); b2.invokeVirtual(sbType, "append", sbType, stringParam); // Increment the count parameter. b2.integerIncrement(b2.getParameter(1), 1); propIsInitialized.setLocation(); // Return the possibly updated count. b2.loadLocal(b2.getParameter(1)); b2.returnValue(TypeDesc.INT); } b.loadThis(); // Parameters are: StringBuilder, count, mask, property name b.loadLocal(sbVar); b.loadLocal(countVar); b.loadConstant(StorableGenerator.PROPERTY_STATE_MASK << ((ordinal & 0xf) * 2)); b.loadConstant(property.getName()); b.invokePrivate(stateAppendMethodName, TypeDesc.INT, appendParams); b.storeLocal(countVar); } b.loadLocal(sbVar); b.invokeVirtual(sbType, "toString", TypeDesc.STRING, null); b.invokeConstructor(exType, new TypeDesc[] {TypeDesc.STRING}); b.throwObject(); isInitialized.setLocation(); } b.loadThis(); b.invokeVirtual(DO_TRY_INSERT_MASTER_METHOD_NAME, TypeDesc.BOOLEAN, null); if (tryStart == null) { b.returnValue(TypeDesc.BOOLEAN); } else { Label failed = b.createLabel(); b.ifZeroComparisonBranch(failed, "=="); addCommitAndExitTransaction(b, INSERT_OP, txnVar); b.loadConstant(true); b.returnValue(TypeDesc.BOOLEAN); failed.setLocation(); addExitTransaction(b, INSERT_OP, txnVar); b.loadConstant(false); b.returnValue(TypeDesc.BOOLEAN); addExitTransaction(b, INSERT_OP, txnVar, tryStart); } } // Add required protected doTryUpdate method. addDoTryUpdate: { MethodInfo mi = mClassFile.addMethod (Modifiers.PROTECTED.toFinal(true), StorableGenerator.DO_TRY_UPDATE_METHOD_NAME, TypeDesc.BOOLEAN, null); mi.addException(persistExceptionType); CodeBuilder b = new CodeBuilder(mi); if ((!mFeatures.contains(MasterFeature.VERSIONING)) && (!mFeatures.contains(MasterFeature.UPDATE_FULL)) && (!mFeatures.contains(MasterFeature.UPDATE_TXN))) { // Nothing special needs to be done, so just delegate and return. b.loadThis(); b.invokeVirtual(DO_TRY_UPDATE_MASTER_METHOD_NAME, TypeDesc.BOOLEAN, null); b.returnValue(TypeDesc.BOOLEAN); break addDoTryUpdate; } LocalVariable txnVar = b.createLocalVariable(null, transactionType); LocalVariable savedVar = null; Label tryStart = addEnterTransaction(b, UPDATE_OP, txnVar); Label failed = b.createLabel(); if (mFeatures.contains(MasterFeature.UPDATE_FULL)) { // Storable saved = copy(); b.loadThis(); b.invokeVirtual(COPY_METHOD_NAME, storableType, null); b.checkCast(mClassFile.getType()); savedVar = b.createLocalVariable(null, mClassFile.getType()); b.storeLocal(savedVar); // if (!saved.tryLoad()) { // goto failed; // } b.loadLocal(savedVar); b.invokeInterface(storableType, TRY_LOAD_METHOD_NAME, TypeDesc.BOOLEAN, null); b.ifZeroComparisonBranch(failed, "=="); // if (version support enabled) { // if (this.getVersionNumber() != saved.getVersionNumber()) { // throw new OptimisticLockException // (this.getVersionNumber(), saved.getVersionNumber(), this); // } // } if (mFeatures.contains(MasterFeature.VERSIONING)) { TypeDesc versionType = TypeDesc.forClass(mInfo.getVersionProperty().getType()); b.loadThis(); b.invoke(mInfo.getVersionProperty().getReadMethod()); b.loadLocal(savedVar); b.invoke(mInfo.getVersionProperty().getReadMethod()); Label sameVersion = b.createLabel(); CodeBuilderUtil.addValuesEqualCall(b, versionType, true, sameVersion, true); b.newObject(optimisticLockType); b.dup(); b.loadThis(); b.invoke(mInfo.getVersionProperty().getReadMethod()); b.convert(versionType, TypeDesc.OBJECT); b.loadLocal(savedVar); b.invoke(mInfo.getVersionProperty().getReadMethod()); b.convert(versionType, TypeDesc.OBJECT); b.loadThis(); b.invokeConstructor (optimisticLockType, new TypeDesc[] {TypeDesc.OBJECT, TypeDesc.OBJECT, storableType}); b.throwObject(); sameVersion.setLocation(); } // this.copyDirtyProperties(saved); // if (version support enabled) { // saved.setVersionNumber(saved.getVersionNumber() + 1); // } b.loadThis(); b.loadLocal(savedVar); b.invokeVirtual(COPY_DIRTY_PROPERTIES, null, new TypeDesc[] {storableType}); if (mFeatures.contains(MasterFeature.VERSIONING)) { addAdjustVersionProperty(b, savedVar, -1); } // if (!saved.doTryUpdateMaster()) { // goto failed; // } b.loadLocal(savedVar); b.invokeVirtual(DO_TRY_UPDATE_MASTER_METHOD_NAME, TypeDesc.BOOLEAN, null); b.ifZeroComparisonBranch(failed, "=="); // saved.copyUnequalProperties(this); b.loadLocal(savedVar); b.loadThis(); b.invokeInterface (storableType, COPY_UNEQUAL_PROPERTIES, null, new TypeDesc[] {storableType}); } else { // if (!this.doTryUpdateMaster()) { // goto failed; // } b.loadThis(); b.invokeVirtual(DO_TRY_UPDATE_MASTER_METHOD_NAME, TypeDesc.BOOLEAN, null); b.ifZeroComparisonBranch(failed, "=="); } // txn.commit(); // txn.exit(); // return true; addCommitAndExitTransaction(b, UPDATE_OP, txnVar); b.loadConstant(true); b.returnValue(TypeDesc.BOOLEAN); // failed: // txn.exit(); failed.setLocation(); addExitTransaction(b, UPDATE_OP, txnVar); // return false; b.loadConstant(false); b.returnValue(TypeDesc.BOOLEAN); addExitTransaction(b, UPDATE_OP, txnVar, tryStart); } // Add required protected doTryDelete method. { MethodInfo mi = mClassFile.addMethod (Modifiers.PROTECTED.toFinal(true), StorableGenerator.DO_TRY_DELETE_METHOD_NAME, TypeDesc.BOOLEAN, null); mi.addException(persistExceptionType); CodeBuilder b = new CodeBuilder(mi); LocalVariable txnVar = b.createLocalVariable(null, transactionType); Label tryStart = addEnterTransaction(b, DELETE_OP, txnVar); b.loadThis(); b.invokeVirtual(DO_TRY_DELETE_MASTER_METHOD_NAME, TypeDesc.BOOLEAN, null); if (tryStart == null) { b.returnValue(TypeDesc.BOOLEAN); } else { Label failed = b.createLabel(); b.ifZeroComparisonBranch(failed, "=="); addCommitAndExitTransaction(b, DELETE_OP, txnVar); b.loadConstant(true); b.returnValue(TypeDesc.BOOLEAN); failed.setLocation(); addExitTransaction(b, DELETE_OP, txnVar); b.loadConstant(false); b.returnValue(TypeDesc.BOOLEAN); addExitTransaction(b, DELETE_OP, txnVar, tryStart); } } }
| 1,111,780
|
public void layoutContainer(Container parent) { LeftRightHeight lrh = calcSizes(parent); Dimension size = parent.getSize(); Insets ins = parent.getInsets(); int lColWidth = Math.min(size.width, lrh.left); int rColWidth = size.width - lColWidth - ins.left - ins.right; int height = Math.min(size.height, lrh.height); Dimension d; int lHeight = 0; int y = ins.top; for (int i = 0; i < parent.getComponentCount(); i++) { Component c = parent.getComponent(i); d = c.getPreferredSize(); if (i%2 == 0) { // left-hand column c.setBounds(ins.left, y, lColWidth, d.height); lHeight = d.height; } else { // right-hand column c.setBounds(lColWidth + ins.left + hgap, y, rColWidth, d.height); y += Math.max(d.height, lHeight) + vgap; } } }
|
public void layoutContainer(Container parent) { LeftRightHeight lrh = calcSizes(parent); Dimension size = parent.getSize(); Insets ins = parent.getInsets(); int lColWidth = Math.min(size.width, lrh.left); int rColWidth = size.width - ins.left - lColWidth - hgap - ins.right; int height = Math.min(size.height, lrh.height); Dimension d; int lHeight = 0; int y = ins.top; for (int i = 0; i < parent.getComponentCount(); i++) { Component c = parent.getComponent(i); d = c.getPreferredSize(); if (i%2 == 0) { // left-hand column c.setBounds(ins.left, y, lColWidth, d.height); lHeight = d.height; } else { // right-hand column c.setBounds(lColWidth + ins.left + hgap, y, rColWidth, d.height); y += Math.max(d.height, lHeight) + vgap; } } }
| 1,111,781
|
public void layoutContainer(Container parent) { LeftRightHeight lrh = calcSizes(parent); Dimension size = parent.getSize(); Insets ins = parent.getInsets(); int lColWidth = Math.min(size.width, lrh.left); int rColWidth = size.width - lColWidth - ins.left - ins.right; int height = Math.min(size.height, lrh.height); Dimension d; int lHeight = 0; int y = ins.top; for (int i = 0; i < parent.getComponentCount(); i++) { Component c = parent.getComponent(i); d = c.getPreferredSize(); if (i%2 == 0) { // left-hand column c.setBounds(ins.left, y, lColWidth, d.height); lHeight = d.height; } else { // right-hand column c.setBounds(lColWidth + ins.left + hgap, y, rColWidth, d.height); y += Math.max(d.height, lHeight) + vgap; } } }
|
public void layoutContainer(Container parent) { LeftRightHeight lrh = calcSizes(parent); Dimension size = parent.getSize(); Insets ins = parent.getInsets(); int lColWidth = Math.min(size.width, lrh.left); int rColWidth = size.width - lColWidth - ins.left - ins.right; int height = Math.min(size.height, lrh.height); Dimension d; int lHeight = 0; int y = ins.top; for (int i = 0; i < parent.getComponentCount(); i++) { Component c = parent.getComponent(i); d = c.getPreferredSize(); if (i%2 == 0) { // left-hand column c.setBounds(ins.left, y, lColWidth, d.height); lHeight = d.height; } else { // right-hand column int width = c.getPreferredSize().width; if (c instanceof JTextField) { width = rColWidth; } c.setBounds(lColWidth + ins.left + hgap, y, width, d.height); y += Math.max(d.height, lHeight) + vgap; } } }
| 1,111,782
|
public void windowClosing(WindowEvent e) { frame.dispose(); }
|
public void windowClosing(WindowEvent e) { frame.dispose(); }
| 1,111,783
|
public void showSelectionPropsDialog() { PhotoInfo photo = getSelected(); if ( photo != null ) { // TODO: Change PhotoInfoEditor to a dialog!!! final JFrame frame = new JFrame( "Photo properties" ); PhotoInfoController ctrl = new PhotoInfoController(); PhotoInfoEditor editor = new PhotoInfoEditor( ctrl ); ctrl.setPhoto( photo ); frame.getContentPane().add( editor, BorderLayout.CENTER ); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { frame.dispose( ); } } ); frame.pack(); frame.setVisible( true ); } }
|
public void showSelectionPropsDialog() { PhotoInfo photo = getSelected(); if ( photo != null ) { // TODO: Change PhotoInfoEditor to a dialog!!! final JFrame frame = new JFrame( "Photo properties" ); PhotoInfoController ctrl = new PhotoInfoController(); PhotoInfoEditor editor = new PhotoInfoEditor( ctrl ); ctrl.setPhoto( photo ); frame.getContentPane().add( editor, BorderLayout.CENTER ); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { frame.dispose( ); } } ); frame.pack(); frame.setVisible( true ); } }
| 1,111,784
|
public Dimension getPreferredSize() { int wide = BORDER*2; int high = BORDER*2; if (filteredHaplos == null) {return new Dimension(wide, high);} // height for the marker digits int markerDigits = (int) (0.0000001 + Math.log(theData.markerInfo.size()) / Math.log(10)) + 1; high += MARKER_CHAR_WIDTH * markerDigits; // space for the diamond high += TAG_SPAN; int maxh = 0; for (int i = 0; i < filteredHaplos.length; i++){ maxh = Math.max(filteredHaplos[i].length, maxh); // size of genotypes for this column // +4 for the percentage reading wide += (filteredHaplos[i][0].getGeno().length + 4) * CHAR_WIDTH; // percentage plus the line size if (i != 0) wide += LINE_SPAN; } // +1 because of extra row for multi between the columns high += (maxh + 1) * ROW_HEIGHT; return new Dimension(wide, high); }
|
public Dimension getPreferredSize() { int wide = BORDER*2; int high = BORDER*2; if (filteredHaplos == null) {return new Dimension(wide, high);} // height for the marker digits int markerDigits = (int) (0.0000001 + Math.log(Chromosome.size()) / Math.log(10)) + 1; high += MARKER_CHAR_WIDTH * markerDigits; // space for the diamond high += TAG_SPAN; int maxh = 0; for (int i = 0; i < filteredHaplos.length; i++){ maxh = Math.max(filteredHaplos[i].length, maxh); // size of genotypes for this column // +4 for the percentage reading wide += (filteredHaplos[i][0].getGeno().length + 4) * CHAR_WIDTH; // percentage plus the line size if (i != 0) wide += LINE_SPAN; } // +1 because of extra row for multi between the columns high += (maxh + 1) * ROW_HEIGHT; return new Dimension(wide, high); }
| 1,111,785
|
public void paintComponent(Graphics graphics) { if (filteredHaplos == null){ super.paintComponent(graphics); return; } Graphics2D g = (Graphics2D) graphics; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //System.out.println(getSize()); Dimension size = getSize(); Dimension pref = getPreferredSize(); g.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); //g.drawRect(0, 0, pref.width, pref.height); final BasicStroke thinStroke = new BasicStroke(0.5f); final BasicStroke thickStroke = new BasicStroke(2.0f); // width of one letter of the haplotype block //int letterWidth = haploMetrics.charWidth('G'); //int percentWidth = pctMetrics.stringWidth(".000"); //final int verticalOffset = 43; // room for tags and diamonds int left = BORDER; int top = BORDER; //verticalOffset; //int totalWidth = 0; // percentages for each haplotype NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); nf.setMinimumIntegerDigits(0); nf.setMaximumIntegerDigits(0); // multi reading, between the columns NumberFormat nfMulti = NumberFormat.getInstance(); nfMulti.setMinimumFractionDigits(2); nfMulti.setMaximumFractionDigits(2); nfMulti.setMinimumIntegerDigits(0); nfMulti.setMaximumIntegerDigits(0); int[][] lookupPos = new int[filteredHaplos.length][]; for (int p = 0; p < lookupPos.length; p++) { lookupPos[p] = new int[filteredHaplos[p].length]; for (int q = 0; q < lookupPos[p].length; q++){ lookupPos[p][filteredHaplos[p][q].getListOrder()] = q; } } // set number formatter to pad with appropriate number of zeroes NumberFormat nfMarker = NumberFormat.getInstance(); int markerCount = theData.markerInfo.size(); // the +0.0000001 is because there is // some suckage where log(1000) / log(10) isn't actually 3 int markerDigits = (int) (0.0000001 + Math.log(markerCount) / Math.log(10)) + 1; nfMarker.setMinimumIntegerDigits(markerDigits); nfMarker.setMaximumIntegerDigits(markerDigits); //int tagShapeX[] = new int[3]; //int tagShapeY[] = new int[3]; //Polygon tagShape; int textRight = 0; // gets updated for scooting over // i = 0 to number of columns - 1 for (int i = 0; i < filteredHaplos.length; i++) { int[] markerNums = filteredHaplos[i][0].getMarkers(); boolean[] tags = filteredHaplos[i][0].getTags(); //int headerX = x; for (int z = 0; z < markerNums.length; z++) { //int tagMiddle = tagMetrics.getAscent() / 2; //int tagLeft = x + z*letterWidth + tagMiddle; //g.translate(tagLeft, 20); // if tag snp, draw little triangle pooper if (tags[z]) { g.drawImage(tagImage, left + z*CHAR_WIDTH, top + markerDigits*MARKER_CHAR_WIDTH + -(CHAR_HEIGHT - TAG_SPAN), null); } //g.rotate(-Math.PI / 2.0); //g.drawLine(0, 0, 0, 0); //g.setColor(Color.black); //g.drawString(nfMarker.format(markerNums[z]), 0, tagMiddle); char markerChars[] = nfMarker.format(markerNums[z]+1).toCharArray(); for (int m = 0; m < markerDigits; m++) { g.drawImage(markerNumImages[markerChars[m] - '0'], left + z*CHAR_WIDTH + (1 + CHAR_WIDTH - MARKER_CHAR_HEIGHT)/2, top + (markerDigits-m-1)*MARKER_CHAR_WIDTH, null); } // undo the transform.. no push/pop.. arrgh //g.rotate(Math.PI / 2.0); //g.translate(-tagLeft, -20); } // y position of the first image for the haplotype letter // top + the size of the marker digits + the size of the tag + // the character height centered in the row's height int above = top + markerDigits*MARKER_CHAR_WIDTH + TAG_SPAN + (ROW_HEIGHT - CHAR_HEIGHT) / 2; for (int j = 0; j < filteredHaplos[i].length; j++){ int curHapNum = lookupPos[i][j]; //String theHap = new String(); //String thePercentage = new String(); int[] theGeno = filteredHaplos[i][curHapNum].getGeno(); //getGeno(); // j is the row of haplotype for (int k = 0; k < theGeno.length; k++) { // theGeno[k] will be 1,2,3,4 (acgt) or 8 (for bad) g.drawImage(charImages[theGeno[k] - 1], left + k*CHAR_WIDTH, above + j*ROW_HEIGHT, null); } //draw the percentage value in non mono font double percent = filteredHaplos[i][curHapNum].getPercentage(); //thePercentage = " " + nf.format(percent); char percentChars[] = nf.format(percent).toCharArray(); // perhaps need an exceptional case for 1.0 being the percent for (int m = 0; m < percentChars.length; m++) { g.drawImage(grayNumImages[(m == 0) ? 10 : percentChars[m]-'0'], left + theGeno.length*CHAR_WIDTH + m*CHAR_WIDTH, above + j*ROW_HEIGHT, null); } // 4 is the number of chars in .999 for the percent textRight = left + theGeno.length*CHAR_WIDTH + 4*CHAR_WIDTH; g.setColor(Color.black); if (i < filteredHaplos.length - 1) { //draw crossovers for (int crossCount = 0; crossCount < filteredHaplos[i+1].length; crossCount++) { double crossVal = filteredHaplos[i][curHapNum].getCrossover(crossCount); //draw thin and thick lines int crossValue = (int) (crossVal*100); if (crossValue > thinThresh) { g.setStroke(crossValue > thickThresh ? thickStroke : thinStroke); int connectTo = filteredHaplos[i+1][crossCount].getListOrder(); g.drawLine(textRight + LINE_LEFT, above + j*ROW_HEIGHT + ROW_HEIGHT/2, textRight + LINE_RIGHT, above + connectTo*ROW_HEIGHT + ROW_HEIGHT/2); } } } } left = textRight; // add the multilocus d prime if appropriate if (i < filteredHaplos.length - 1) { //put the numbers in the right place vertically int depth; if (filteredHaplos[i].length > filteredHaplos[i+1].length){ depth = filteredHaplos[i].length; }else{ depth = filteredHaplos[i+1].length; } char multiChars[] = nfMulti.format(multidprimeArray[i]).toCharArray(); for (int m = 0; m < 3; m++) { // 7*CHAR_WIDTH/2 = CHAR_WIDTH*3.5 to center it better // since the . char is right-aligned, and visually off g.drawImage(blackNumImages[(m == 0) ? 10 : multiChars[m]-'0'], left + (LINE_SPAN - 7*CHAR_WIDTH/2)/2 + m*CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); } //int multiX = x + totalWidth + 3; //g.drawString(nfMulti.format(multidprimeArray[i]), // multiX+2, windowY - 3); } left += LINE_SPAN; //x += (totalWidth + 40); //y = verticalOffset; //left = textRight + LINE_SPAN; } }
|
public void paintComponent(Graphics graphics) { if (filteredHaplos == null){ super.paintComponent(graphics); return; } Graphics2D g = (Graphics2D) graphics; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //System.out.println(getSize()); Dimension size = getSize(); Dimension pref = getPreferredSize(); g.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); //g.drawRect(0, 0, pref.width, pref.height); final BasicStroke thinStroke = new BasicStroke(0.5f); final BasicStroke thickStroke = new BasicStroke(2.0f); // width of one letter of the haplotype block //int letterWidth = haploMetrics.charWidth('G'); //int percentWidth = pctMetrics.stringWidth(".000"); //final int verticalOffset = 43; // room for tags and diamonds int left = BORDER; int top = BORDER; //verticalOffset; //int totalWidth = 0; // percentages for each haplotype NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); nf.setMinimumIntegerDigits(0); nf.setMaximumIntegerDigits(0); // multi reading, between the columns NumberFormat nfMulti = NumberFormat.getInstance(); nfMulti.setMinimumFractionDigits(2); nfMulti.setMaximumFractionDigits(2); nfMulti.setMinimumIntegerDigits(0); nfMulti.setMaximumIntegerDigits(0); int[][] lookupPos = new int[filteredHaplos.length][]; for (int p = 0; p < lookupPos.length; p++) { lookupPos[p] = new int[filteredHaplos[p].length]; for (int q = 0; q < lookupPos[p].length; q++){ lookupPos[p][filteredHaplos[p][q].getListOrder()] = q; } } // set number formatter to pad with appropriate number of zeroes NumberFormat nfMarker = NumberFormat.getInstance(); int markerCount = Chromosome.size(); // the +0.0000001 is because there is // some suckage where log(1000) / log(10) isn't actually 3 int markerDigits = (int) (0.0000001 + Math.log(markerCount) / Math.log(10)) + 1; nfMarker.setMinimumIntegerDigits(markerDigits); nfMarker.setMaximumIntegerDigits(markerDigits); //int tagShapeX[] = new int[3]; //int tagShapeY[] = new int[3]; //Polygon tagShape; int textRight = 0; // gets updated for scooting over // i = 0 to number of columns - 1 for (int i = 0; i < filteredHaplos.length; i++) { int[] markerNums = filteredHaplos[i][0].getMarkers(); boolean[] tags = filteredHaplos[i][0].getTags(); //int headerX = x; for (int z = 0; z < markerNums.length; z++) { //int tagMiddle = tagMetrics.getAscent() / 2; //int tagLeft = x + z*letterWidth + tagMiddle; //g.translate(tagLeft, 20); // if tag snp, draw little triangle pooper if (tags[z]) { g.drawImage(tagImage, left + z*CHAR_WIDTH, top + markerDigits*MARKER_CHAR_WIDTH + -(CHAR_HEIGHT - TAG_SPAN), null); } //g.rotate(-Math.PI / 2.0); //g.drawLine(0, 0, 0, 0); //g.setColor(Color.black); //g.drawString(nfMarker.format(markerNums[z]), 0, tagMiddle); char markerChars[] = nfMarker.format(markerNums[z]+1).toCharArray(); for (int m = 0; m < markerDigits; m++) { g.drawImage(markerNumImages[markerChars[m] - '0'], left + z*CHAR_WIDTH + (1 + CHAR_WIDTH - MARKER_CHAR_HEIGHT)/2, top + (markerDigits-m-1)*MARKER_CHAR_WIDTH, null); } // undo the transform.. no push/pop.. arrgh //g.rotate(Math.PI / 2.0); //g.translate(-tagLeft, -20); } // y position of the first image for the haplotype letter // top + the size of the marker digits + the size of the tag + // the character height centered in the row's height int above = top + markerDigits*MARKER_CHAR_WIDTH + TAG_SPAN + (ROW_HEIGHT - CHAR_HEIGHT) / 2; for (int j = 0; j < filteredHaplos[i].length; j++){ int curHapNum = lookupPos[i][j]; //String theHap = new String(); //String thePercentage = new String(); int[] theGeno = filteredHaplos[i][curHapNum].getGeno(); //getGeno(); // j is the row of haplotype for (int k = 0; k < theGeno.length; k++) { // theGeno[k] will be 1,2,3,4 (acgt) or 8 (for bad) g.drawImage(charImages[theGeno[k] - 1], left + k*CHAR_WIDTH, above + j*ROW_HEIGHT, null); } //draw the percentage value in non mono font double percent = filteredHaplos[i][curHapNum].getPercentage(); //thePercentage = " " + nf.format(percent); char percentChars[] = nf.format(percent).toCharArray(); // perhaps need an exceptional case for 1.0 being the percent for (int m = 0; m < percentChars.length; m++) { g.drawImage(grayNumImages[(m == 0) ? 10 : percentChars[m]-'0'], left + theGeno.length*CHAR_WIDTH + m*CHAR_WIDTH, above + j*ROW_HEIGHT, null); } // 4 is the number of chars in .999 for the percent textRight = left + theGeno.length*CHAR_WIDTH + 4*CHAR_WIDTH; g.setColor(Color.black); if (i < filteredHaplos.length - 1) { //draw crossovers for (int crossCount = 0; crossCount < filteredHaplos[i+1].length; crossCount++) { double crossVal = filteredHaplos[i][curHapNum].getCrossover(crossCount); //draw thin and thick lines int crossValue = (int) (crossVal*100); if (crossValue > thinThresh) { g.setStroke(crossValue > thickThresh ? thickStroke : thinStroke); int connectTo = filteredHaplos[i+1][crossCount].getListOrder(); g.drawLine(textRight + LINE_LEFT, above + j*ROW_HEIGHT + ROW_HEIGHT/2, textRight + LINE_RIGHT, above + connectTo*ROW_HEIGHT + ROW_HEIGHT/2); } } } } left = textRight; // add the multilocus d prime if appropriate if (i < filteredHaplos.length - 1) { //put the numbers in the right place vertically int depth; if (filteredHaplos[i].length > filteredHaplos[i+1].length){ depth = filteredHaplos[i].length; }else{ depth = filteredHaplos[i+1].length; } char multiChars[] = nfMulti.format(multidprimeArray[i]).toCharArray(); for (int m = 0; m < 3; m++) { // 7*CHAR_WIDTH/2 = CHAR_WIDTH*3.5 to center it better // since the . char is right-aligned, and visually off g.drawImage(blackNumImages[(m == 0) ? 10 : multiChars[m]-'0'], left + (LINE_SPAN - 7*CHAR_WIDTH/2)/2 + m*CHAR_WIDTH, above + (depth * ROW_HEIGHT), null); } //int multiX = x + totalWidth + 3; //g.drawString(nfMulti.format(multidprimeArray[i]), // multiX+2, windowY - 3); } left += LINE_SPAN; //x += (totalWidth + 40); //y = verticalOffset; //left = textRight + LINE_SPAN; } }
| 1,111,786
|
public void normalizePrimaryKey() { try { if (getColumns().isEmpty()) return; boolean donePk = false; int i = 0; Iterator it = getColumns().iterator(); while (it.hasNext()) { SQLColumn col = (SQLColumn) it.next(); if (col.getPrimaryKeySeq() == null) donePk = true; if (!donePk) { col.primaryKeySeq = new Integer(i); } else { col.primaryKeySeq = null; } i++; } } catch (ArchitectException e) { logger.warn("Unexpected ArchitectException in normalizePrimaryKey "+e); } }
|
public void normalizePrimaryKey() { try { if (getColumns().isEmpty()) return; boolean donePk = false; int i = 0; Iterator it = getColumns().iterator(); while (it.hasNext()) { SQLColumn col = (SQLColumn) it.next(); if (col.getPrimaryKeySeq() == null) donePk = true; if (!donePk) { col.primaryKeySeq = new Integer(i); } else { col.primaryKeySeq = null; } i++; } } catch (ArchitectException e) { logger.warn("Unexpected ArchitectException in normalizePrimaryKey "+e); } }
| 1,111,787
|
public void normalizePrimaryKey() { try { if (getColumns().isEmpty()) return; boolean donePk = false; int i = 0; Iterator it = getColumns().iterator(); while (it.hasNext()) { SQLColumn col = (SQLColumn) it.next(); if (col.getPrimaryKeySeq() == null) donePk = true; if (!donePk) { col.primaryKeySeq = new Integer(i); } else { col.primaryKeySeq = null; } i++; } } catch (ArchitectException e) { logger.warn("Unexpected ArchitectException in normalizePrimaryKey "+e); } }
|
public void normalizePrimaryKey() { try { if (getColumns().isEmpty()) return; boolean donePk = false; int i = 0; Iterator it = getColumns().iterator(); while (it.hasNext()) { SQLColumn col = (SQLColumn) it.next(); if (col.getPrimaryKeySeq() == null) donePk = true; if (!donePk) { col.primaryKeySeq = new Integer(i); } else { col.primaryKeySeq = null; } i++; } } catch (ArchitectException e) { logger.warn("Unexpected ArchitectException in normalizePrimaryKey "+e); } finally { endCompoundEdit("Normalizing Primary Key"); } }
| 1,111,788
|
public void doTag(XMLOutput output) throws Exception { if (select == null) { throw new MissingAttributeException( "select" ); } Object xpathContext = getXPathContext(); if ( select.booleanValueOf(xpathContext) ) { getBody().run( context, output ); } }
|
public void doTag(XMLOutput output) throws Exception { if (select == null) { throw new MissingAttributeException( "select" ); } Object xpathContext = getXPathContext(); if ( select.booleanValueOf(xpathContext) ) { invokeBody(output); } }
| 1,111,789
|
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); } if(forceIncludeTags != null) { 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: " + 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(tagging != Tagger.NONE) { 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, tagging); 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()); } }
|
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); } if(forceIncludeTags != null) { 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: " + 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.getAbsolutePath()); }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(tagging != Tagger.NONE) { 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, tagging); 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()); } }
| 1,111,791
|
public void doTag(XMLOutput output) throws Exception { if (endpoint == null) { throw new MissingAttributeException("endpoint"); } if (namespace == null) { throw new MissingAttributeException("namespace"); } if (method == null) { throw new MissingAttributeException("method"); } Service service = getService(); if (service == null) { service = createService(); } Call call = (Call) service.createCall(); // @todo Jelly should have native support for URL and QName // directly on properties call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName(new QName(namespace, method)); Object ret = call.invoke(new Object[]{getBodyText()}); if (var != null) { context.setVariable(var, ret); } else { // should turn the answer into XML events... throw new JellyException( "Not implemented yet; should stream results as XML events. Results: " + ret ); } }
|
public void doTag(XMLOutput output) throws Exception { if (endpoint == null) { throw new MissingAttributeException("endpoint"); } if (namespace == null) { throw new MissingAttributeException("namespace"); } if (method == null) { throw new MissingAttributeException("method"); } Service service = getService(); if (service == null) { service = createService(); } Call call = (Call) service.createCall(); // @todo Jelly should have native support for URL and QName // directly on properties call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName(new QName(namespace, method)); Object answer = call.invoke(params); if (var != null) { context.setVariable(var, ret); } else { // should turn the answer into XML events... throw new JellyException( "Not implemented yet; should stream results as XML events. Results: " + ret ); } }
| 1,111,792
|
public void doTag(XMLOutput output) throws Exception { if (endpoint == null) { throw new MissingAttributeException("endpoint"); } if (namespace == null) { throw new MissingAttributeException("namespace"); } if (method == null) { throw new MissingAttributeException("method"); } Service service = getService(); if (service == null) { service = createService(); } Call call = (Call) service.createCall(); // @todo Jelly should have native support for URL and QName // directly on properties call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName(new QName(namespace, method)); Object ret = call.invoke(new Object[]{getBodyText()}); if (var != null) { context.setVariable(var, ret); } else { // should turn the answer into XML events... throw new JellyException( "Not implemented yet; should stream results as XML events. Results: " + ret ); } }
|
public void doTag(XMLOutput output) throws Exception { if (endpoint == null) { throw new MissingAttributeException("endpoint"); } if (namespace == null) { throw new MissingAttributeException("namespace"); } if (method == null) { throw new MissingAttributeException("method"); } Service service = getService(); if (service == null) { service = createService(); } Call call = (Call) service.createCall(); // @todo Jelly should have native support for URL and QName // directly on properties call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName(new QName(namespace, method)); Object ret = call.invoke(new Object[]{getBodyText()}); if (var != null) { context.setVariable(var, answer); } else { // should turn the answer into XML events... throw new JellyException( "Not implemented yet; should stream results as XML events. Results: " + ret ); } }
| 1,111,793
|
public void doTag(XMLOutput output) throws Exception { if (endpoint == null) { throw new MissingAttributeException("endpoint"); } if (namespace == null) { throw new MissingAttributeException("namespace"); } if (method == null) { throw new MissingAttributeException("method"); } Service service = getService(); if (service == null) { service = createService(); } Call call = (Call) service.createCall(); // @todo Jelly should have native support for URL and QName // directly on properties call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName(new QName(namespace, method)); Object ret = call.invoke(new Object[]{getBodyText()}); if (var != null) { context.setVariable(var, ret); } else { // should turn the answer into XML events... throw new JellyException( "Not implemented yet; should stream results as XML events. Results: " + ret ); } }
|
public void doTag(XMLOutput output) throws Exception { if (endpoint == null) { throw new MissingAttributeException("endpoint"); } if (namespace == null) { throw new MissingAttributeException("namespace"); } if (method == null) { throw new MissingAttributeException("method"); } Service service = getService(); if (service == null) { service = createService(); } Call call = (Call) service.createCall(); // @todo Jelly should have native support for URL and QName // directly on properties call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName(new QName(namespace, method)); Object ret = call.invoke(new Object[]{getBodyText()}); if (var != null) { context.setVariable(var, ret); } else { // should turn the answer into XML events... throw new JellyException( "Not implemented yet; should stream results as XML events. Results: " + answer ); } }
| 1,111,794
|
public Object evaluate(JellyContext context) { try { JellyInterpreter interpreter = BeanShellExpressionFactory.getInterpreter(context); if ( log.isDebugEnabled() ) { log.debug( "Evaluating EL: " + text ); } return interpreter.eval( text ); } catch (Exception e) { log.warn( "Caught exception evaluating: " + text + ". Reason: " + e, e ); return null; } }
|
public Object evaluate(JellyContext context) { try { JellyInterpreter interpreter = new JellyInterpreter(); interpreter.setJellyContext(context); if ( log.isDebugEnabled() ) { log.debug( "Evaluating EL: " + text ); } return interpreter.eval( text ); } catch (Exception e) { log.warn( "Caught exception evaluating: " + text + ". Reason: " + e, e ); return null; } }
| 1,111,795
|
public Object evaluate(JellyContext context) { try { JellyInterpreter interpreter = BeanShellExpressionFactory.getInterpreter(context); if ( log.isDebugEnabled() ) { log.debug( "Evaluating EL: " + text ); } return interpreter.eval( text ); } catch (Exception e) { log.warn( "Caught exception evaluating: " + text + ". Reason: " + e, e ); return null; } }
|
public Object evaluate(JellyContext context) { try { JellyInterpreter interpreter = BeanShellExpressionFactory.getInterpreter(context); if ( log.isDebugEnabled() ) { log.debug( "Evaluating beanshell: " + text ); } return interpreter.eval( text ); } catch (Exception e) { log.warn( "Caught exception evaluating: " + text + ". Reason: " + e, e ); return null; } }
| 1,111,796
|
public JellyContext getJellyContext() throws MalformedURLException { if (context == null) { // take off the name off the URL String text = getUrl().toString(); int idx = text.lastIndexOf('/'); text = text.substring(0, idx + 1); JellyContext parentContext = new JellyContext(getRootContext(), new URL(text)); context = new AntJellyContext(project, parentContext); // register the Ant tag library context.registerTagLibrary( "jelly:ant", new AntTagLibrary(project) ); } return context; }
|
public JellyContext getJellyContext() throws MalformedURLException { if (context == null) { // take off the name off the URL String text = getUrl().toString(); int idx = text.lastIndexOf('/'); text = text.substring(0, idx + 1); JellyContext parentContext = new JellyContext(getRootContext(), new URL(text)); context = new AntJellyContext(project, parentContext); // register the Ant tag library context.registerTagLibrary( "jelly:ant", new AntTagLibrary() ); } return context; }
| 1,111,798
|
public TagScript createTagScript(String name, Attributes attributes) throws Exception { Class type = (Class) tags.get(name); Tag tag = (Tag) type.newInstance(); return TagScript.newInstance(tag); }
|
public TagScript createTagScript(String name, Attributes attributes) throws Exception { Class type = (Class) tags.get(name); Tag tag = (Tag) type.newInstance(); return TagScript.newInstance(tag); }
| 1,111,799
|
public void doTag(XMLOutput output) throws Exception { if (!maxRowsSpecified) { Object obj = context.getVariable("org.apache.commons.jelly.sql.maxRows"); if (obj != null) { if (obj instanceof Integer) { maxRows = ((Integer) obj).intValue(); } else if (obj instanceof String) { try { maxRows = Integer.parseInt((String) obj); } catch (NumberFormatException nfe) { throw new JellyException( Resources.getMessage("SQL_MAXROWS_PARSE_ERROR", (String) obj), nfe); } } else { throw new JellyException(Resources.getMessage("SQL_MAXROWS_INVALID")); } } } Result result = null; String sqlStatement = null; log.debug( "About to lookup connection" ); try { conn = getConnection(); /* * Use the SQL statement specified by the sql attribute, if any, * otherwise use the body as the statement. */ if (sql != null) { sqlStatement = sql; } else { sqlStatement = getBodyText(); } if (sqlStatement == null || sqlStatement.trim().length() == 0) { throw new JellyException(Resources.getMessage("SQL_NO_STATEMENT")); } /* * We shouldn't have a negative startRow or illegal maxrows */ if ((startRow < 0) || (maxRows < -1)) { throw new JellyException(Resources.getMessage("PARAM_BAD_VALUE")); } /* * Note! We must not use the setMaxRows() method on the * the statement to limit the number of rows, since the * Result factory must be able to figure out the correct * value for isLimitedByMaxRows(); there's no way to check * if it was from the ResultSet. */ PreparedStatement ps = conn.prepareStatement(sqlStatement); setParameters(ps, parameters); if ( log.isDebugEnabled() ) { log.debug( "About to execute query: " + sqlStatement ); } ResultSet rs = ps.executeQuery(); result = new ResultImpl(rs, startRow, maxRows); context.setVariable(var, result); } catch (SQLException e) { throw new JellyException(sqlStatement + ": " + e.getMessage(), e); } finally { if (conn != null && !isPartOfTransaction) { try { conn.close(); } catch (SQLException e) { } // Not much we can do conn = null; } parameters = null; } }
|
public void doTag(XMLOutput output) throws Exception { if (!maxRowsSpecified) { Object obj = context.getVariable("org.apache.commons.jelly.sql.maxRows"); if (obj != null) { if (obj instanceof Integer) { maxRows = ((Integer) obj).intValue(); } else if (obj instanceof String) { try { maxRows = Integer.parseInt((String) obj); } catch (NumberFormatException nfe) { throw new JellyException( Resources.getMessage("SQL_MAXROWS_PARSE_ERROR", (String) obj), nfe); } } else { throw new JellyException(Resources.getMessage("SQL_MAXROWS_INVALID")); } } } Result result = null; String sqlStatement = null; log.debug( "About to lookup connection" ); try { conn = getConnection(); /* * Use the SQL statement specified by the sql attribute, if any, * otherwise use the body as the statement. */ if (sql != null) { sqlStatement = sql; } else { sqlStatement = getBodyText(); } if (sqlStatement == null || sqlStatement.trim().length() == 0) { throw new JellyException(Resources.getMessage("SQL_NO_STATEMENT")); } /* * We shouldn't have a negative startRow or illegal maxrows */ if ((startRow < 0) || (maxRows < -1)) { throw new JellyException(Resources.getMessage("PARAM_BAD_VALUE")); } /* * Note! We must not use the setMaxRows() method on the * the statement to limit the number of rows, since the * Result factory must be able to figure out the correct * value for isLimitedByMaxRows(); there's no way to check * if it was from the ResultSet. */ PreparedStatement ps = conn.prepareStatement(sqlStatement); setParameters(ps, parameters); if ( log.isDebugEnabled() ) { log.debug( "About to execute query: " + sqlStatement ); } ResultSet rs = ps.executeQuery(); result = new ResultImpl(rs, startRow, maxRows); context.setVariable(var, result); } catch (SQLException e) { throw new JellyException(sqlStatement + ": " + e.getMessage(), e); } finally { if (conn != null && !isPartOfTransaction) { try { conn.close(); } catch (SQLException e) { } // Not much we can do conn = null; } parameters = null; } }
| 1,111,800
|
public void doTag(XMLOutput output) throws Exception { if (!maxRowsSpecified) { Object obj = context.getVariable("org.apache.commons.jelly.sql.maxRows"); if (obj != null) { if (obj instanceof Integer) { maxRows = ((Integer) obj).intValue(); } else if (obj instanceof String) { try { maxRows = Integer.parseInt((String) obj); } catch (NumberFormatException nfe) { throw new JellyException( Resources.getMessage("SQL_MAXROWS_PARSE_ERROR", (String) obj), nfe); } } else { throw new JellyException(Resources.getMessage("SQL_MAXROWS_INVALID")); } } } Result result = null; String sqlStatement = null; log.debug( "About to lookup connection" ); try { conn = getConnection(); /* * Use the SQL statement specified by the sql attribute, if any, * otherwise use the body as the statement. */ if (sql != null) { sqlStatement = sql; } else { sqlStatement = getBodyText(); } if (sqlStatement == null || sqlStatement.trim().length() == 0) { throw new JellyException(Resources.getMessage("SQL_NO_STATEMENT")); } /* * We shouldn't have a negative startRow or illegal maxrows */ if ((startRow < 0) || (maxRows < -1)) { throw new JellyException(Resources.getMessage("PARAM_BAD_VALUE")); } /* * Note! We must not use the setMaxRows() method on the * the statement to limit the number of rows, since the * Result factory must be able to figure out the correct * value for isLimitedByMaxRows(); there's no way to check * if it was from the ResultSet. */ PreparedStatement ps = conn.prepareStatement(sqlStatement); setParameters(ps, parameters); if ( log.isDebugEnabled() ) { log.debug( "About to execute query: " + sqlStatement ); } ResultSet rs = ps.executeQuery(); result = new ResultImpl(rs, startRow, maxRows); context.setVariable(var, result); } catch (SQLException e) { throw new JellyException(sqlStatement + ": " + e.getMessage(), e); } finally { if (conn != null && !isPartOfTransaction) { try { conn.close(); } catch (SQLException e) { } // Not much we can do conn = null; } parameters = null; } }
|
public void doTag(XMLOutput output) throws Exception { if (!maxRowsSpecified) { Object obj = context.getVariable("org.apache.commons.jelly.sql.maxRows"); if (obj != null) { if (obj instanceof Integer) { maxRows = ((Integer) obj).intValue(); } else if (obj instanceof String) { try { maxRows = Integer.parseInt((String) obj); } catch (NumberFormatException nfe) { throw new JellyException( Resources.getMessage("SQL_MAXROWS_PARSE_ERROR", (String) obj), nfe); } } else { throw new JellyException(Resources.getMessage("SQL_MAXROWS_INVALID")); } } } Result result = null; String sqlStatement = null; log.debug( "About to lookup connection" ); try { conn = getConnection(); /* * Use the SQL statement specified by the sql attribute, if any, * otherwise use the body as the statement. */ if (sql != null) { sqlStatement = sql; } else { sqlStatement = getBodyText(); } if (sqlStatement == null || sqlStatement.trim().length() == 0) { throw new JellyException(Resources.getMessage("SQL_NO_STATEMENT")); } /* * We shouldn't have a negative startRow or illegal maxrows */ if ((startRow < 0) || (maxRows < -1)) { throw new JellyException(Resources.getMessage("PARAM_BAD_VALUE")); } /* * Note! We must not use the setMaxRows() method on the * the statement to limit the number of rows, since the * Result factory must be able to figure out the correct * value for isLimitedByMaxRows(); there's no way to check * if it was from the ResultSet. */ PreparedStatement ps = conn.prepareStatement(sqlStatement); setParameters(ps, parameters); if ( log.isDebugEnabled() ) { log.debug( "About to execute query: " + sqlStatement ); } ResultSet rs = null; if ( parameters == null || parameters.size() == 0 ) { Statement statement = conn.createStatement(); rs = statement.executeQuery(sqlStatement); } else { PreparedStatement ps = conn.prepareStatement(sqlStatement); setParameters(ps, parameters); rs = ps.executeQuery(); } result = new ResultImpl(rs, startRow, maxRows); context.setVariable(var, result); } catch (SQLException e) { throw new JellyException(sqlStatement + ": " + e.getMessage(), e); } finally { if (conn != null && !isPartOfTransaction) { try { conn.close(); } catch (SQLException e) { } // Not much we can do conn = null; } parameters = null; } }
| 1,111,801
|
public void start() { // TODO: threads for new applications are not getting started for (ApplicationConfig appConfig : ApplicationConfigManager .getAllApplications()) { ApplicationDowntimeTrackingThread thread = new ApplicationDowntimeTrackingThread(appConfig); threads.add(thread); thread.start(); } addListener(recorder); logger.info("ApplicationDowntimeService started."); }
|
public void start() { // TODO: threads for new applications are not getting started for (ApplicationConfig appConfig : ApplicationConfigManager .getAllApplications()) { ApplicationDowntimeTrackingThread thread = new ApplicationDowntimeTrackingThread(appConfig); threads.add(thread); thread.start(); } addListener(recorder); logger.info("ApplicationDowntimeService started."); }
| 1,111,802
|
public void start() { // TODO: threads for new applications are not getting started for (ApplicationConfig appConfig : ApplicationConfigManager .getAllApplications()) { ApplicationDowntimeTrackingThread thread = new ApplicationDowntimeTrackingThread(appConfig); threads.add(thread); thread.start(); } addListener(recorder); logger.info("ApplicationDowntimeService started."); }
|
public void start() { // TODO: threads for new applications are not getting started for (ApplicationConfig appConfig : ApplicationConfigManager .getAllApplications()) { ApplicationDowntimeTrackingThread thread = new ApplicationDowntimeTrackingThread(appConfig); threads.add(thread); thread.start(); } EventSystem eventSystem = EventSystem.getInstance(); eventSystem.addListener(recorder, ApplicationEvent.class); 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."); }
| 1,111,803
|
public void stop() { for(ApplicationDowntimeTrackingThread thread: threads){ thread.end(); } threads.clear(); eventListeners.clear(); }
|
public void stop() { for(ApplicationHeartBeatThread thread: threads){ thread.end(); } threads.clear(); eventListeners.clear(); }
| 1,111,804
|
public void stop() { for(ApplicationDowntimeTrackingThread thread: threads){ thread.end(); } threads.clear(); eventListeners.clear(); }
|
public void stop() { for(ApplicationDowntimeTrackingThread thread: threads){ thread.end(); } threads.clear(); }
| 1,111,805
|
public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception{ String component = DashboardComponentHelper.drawComponent(context, request, request.getParameter("dashBID"), request.getParameter("componentID")); response.getOutputStream().print(component); return null; }
|
public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception{ String component = DashboardComponentHelper.refreshComponent(context, request, request.getParameter("dashBID"), request.getParameter("componentID")); response.getOutputStream().print(component); return null; }
| 1,111,806
|
public void testRetrieve() { DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() ); folders = (DList) query.execute(); tx.commit(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder = (PhotoFolder) iter.next(); if ( folder.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder.getFolderId() ); assertEquals( "Folder with id 0 should be the top", folder.getName(), "Top" ); } } assertTrue( "Top folder not found", found ); }
|
public void testRetrieve() { DList folders = null; Transaction tx = odmg.newTransaction(); tx.begin(); try { OQLQuery query = odmg.newOQLQuery(); query.create( "select folders from " + PhotoFolder.class.getName() + " where name = \"Top\"" ); folders = (DList) query.execute(); tx.commit(); } catch ( Exception e ) { tx.abort(); fail( e.getMessage() ); } Iterator iter = folders.iterator(); boolean found = false; while ( iter.hasNext() ) { PhotoFolder folder = (PhotoFolder) iter.next(); if ( folder.getName().equals( "Top" ) ) { found = true; log.debug( "found top, id = " + folder.getFolderId() ); assertEquals( "Folder with id 0 should be the top", folder.getName(), "Top" ); } } assertTrue( "Top folder not found", found ); }
| 1,111,807
|
public SQLObject[] getPathToNode(SQLObject node) { LinkedList path = new LinkedList(); if (! (node instanceof DBTreeRoot)) { while (node != null) { path.add(0, node); node = node.getParent(); } } path.add(0, root); return (SQLObject[]) path.toArray(new SQLObject[path.size()]); }
|
public SQLObject[] getPathToNode(SQLObject node) { LinkedList path = new LinkedList(); if (! (node instanceof DBTreeRoot)) { while (node != null) { path.add(0, node); node = node.getParent(); } } path.add(0, root); return (SQLObject[]) path.toArray(new SQLObject[path.size()]); }
| 1,111,808
|
public LockedColumnException(String message) { super(message); }
|
public LockedColumnException(String message) { super(message); }
| 1,111,809
|
public JUnitTagLibrary() { registerTag("assert", AssertTag.class); registerTag("assertEquals", AssertEqualsTag.class); registerTag("assertThrown", AssertThrownTag.class); registerTag("fail", FailTag.class); registerTag("run", RunTag.class ); registerTag("case", CaseTag.class ); registerTag("suite", SuiteTag.class ); }
|
public JUnitTagLibrary() { registerTag("assert", AssertTag.class); registerTag("assertEquals", AssertEqualsTag.class); registerTag("assertThrows", AssertThrowsTag.class); registerTag("fail", FailTag.class); registerTag("run", RunTag.class ); registerTag("case", CaseTag.class ); registerTag("suite", SuiteTag.class ); }
| 1,111,810
|
protected TagScript createStaticTag( final String namespaceURI, final String localName, final String qName, Attributes list) throws SAXException { try { StaticTag tag = new StaticTag( namespaceURI, localName, qName ); StaticTagScript script = new StaticTagScript( new TagFactory() { public Tag createTag(String name, Attributes attributes) { return new StaticTag( namespaceURI, localName, qName ); } } ); configureTagScript(script); // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeValue = list.getValue(i); Expression expression = CompositeExpression.parse( attributeValue, getExpressionFactory() ); String attrQName = list.getQName(i); script.addAttribute(attrQName, expression); } return script; } catch (Exception e) { log.warn( "Could not create static tag for URI: " + namespaceURI + " tag name: " + localName, e); throw createSAXException(e); } }
|
protected TagScript createStaticTag( final String namespaceURI, final String localName, final String qName, Attributes list) throws SAXException { try { StaticTag tag = new StaticTag( namespaceURI, localName, qName ); StaticTagScript script = new StaticTagScript( new TagFactory() { public Tag createTag(String name, Attributes attributes) { return new StaticTag( namespaceURI, localName, qName ); } } ); configureTagScript(script); // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeValue = list.getValue(i); Expression expression = CompositeExpression.parse( attributeValue, getExpressionFactory() ); String attrQName = list.getQName(i); int p = attrQName.indexOf(':'); String prefix = p>=0 ? attrQName.substring(0,p): ""; script.addAttribute(list.getLocalName(i), prefix, list.getURI(i), expression); } return script; } catch (Exception e) { log.warn( "Could not create static tag for URI: " + namespaceURI + " tag name: " + localName, e); throw createSAXException(e); } }
| 1,111,811
|
private static void saveConfig(){ ConfigWriter writer = ConfigWriter.getInstance(); writer.write(new Config(applicationConfigs, dashboardConfigs)); }
|
private static void saveConfig(){ ConfigWriter writer = ConfigWriter.getInstance(); writer.write(new Config(applicationConfigs)); }
| 1,111,812
|
public void run(JellyContext context, XMLOutput output) throws Exception { DynaTag dynaTag = (DynaTag) tag; // ### probably compiling this to 2 arrays might be quicker and smaller for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Expression expression = (Expression) entry.getValue(); Object value = expression.evaluate(context); dynaTag.setAttribute(name, value); } tag.setContext(context); tag.doTag(output); }
|
public void run(JellyContext context, XMLOutput output) throws Exception { DynaTag dynaTag = (DynaTag) tag; // ### probably compiling this to 2 arrays might be quicker and smaller for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Expression expression = (Expression) entry.getValue(); Object value = expression.evaluate(context); dynaTag.setAttribute(name, value); } tag.doTag(output); }
| 1,111,813
|
public static JDialog createArchitectPanelDialog( final ArchitectPanel arch, final Window dialogParent, final String dialogTitle, final String actionButtonTitle, final Action okAction, final Action cancelAction) { final JDialog d; if (dialogParent instanceof Frame) { d = new JDialog((Frame) dialogParent, dialogTitle); } else if (dialogParent instanceof Dialog) { d = new JDialog((Dialog) dialogParent, dialogTitle); } else { throw new IllegalArgumentException( "The dialogParent you gave me is not a " + "Frame or Dialog (it is a " + dialogParent.getClass().getName() + ")"); } JComponent panel = arch.getPanel(); // In all cases we have to close the dialog. Action closeAction = new CommonCloseAction(d); JButton okButton = new JDefaultButton(okAction); okButton.setText(actionButtonTitle); okButton.addActionListener(closeAction); JButton cancelButton = new JDefaultButton(cancelAction); cancelButton.setText(CANCEL_BUTTON_LABEL); cancelButton.addActionListener(closeAction); // Handle if the user presses Enter in the dialog - do OK action d.getRootPane().setDefaultButton(okButton); makeJDialogCancellable(d, cancelAction); // Now build the GUI. JPanel cp = new JPanel(new BorderLayout()); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); cp.add(panel, BorderLayout.CENTER); cp.add(ButtonBarFactory.buildOKCancelBar(okButton, cancelButton), BorderLayout.SOUTH); cp.setBorder(Borders.DIALOG_BORDER); //d.add(cp); d.setContentPane(cp); // XXX maybe pass yet another argument for this? // d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.pack(); return d; }
|
public static JDialog createArchitectPanelDialog( final ArchitectPanel arch, final Window dialogParent, final String dialogTitle, final String actionButtonTitle, final Action okAction, final Action cancelAction) { final JDialog d; if (dialogParent instanceof Frame) { d = new JDialog((Frame) dialogParent, dialogTitle); } else if (dialogParent instanceof Dialog) { d = new JDialog((Dialog) dialogParent, dialogTitle); } else { throw new IllegalArgumentException( "The dialogParent you gave me is not a " + "Frame or Dialog (it is a " + dialogParent.getClass().getName() + ")"); } JComponent panel = arch.getPanel(); // In all cases we have to close the dialog. Action closeAction = new CommonCloseAction(d); JButton okButton = new JDefaultButton(okAction); okButton.setText(actionButtonTitle); okButton.addActionListener(closeAction); JButton cancelButton = new JDefaultButton(cancelAction); cancelButton.setText(CANCEL_BUTTON_LABEL); cancelButton.addActionListener(closeAction); // Handle if the user presses Enter in the dialog - do OK action d.getRootPane().setDefaultButton(okButton); makeJDialogCancellable(d, cancelAction); // Now build the GUI. JPanel cp = new JPanel(new BorderLayout()); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); cp.add(panel, BorderLayout.CENTER); cp.add(ButtonBarFactory.buildOKCancelBar(okButton, cancelButton), BorderLayout.SOUTH); cp.setBorder(Borders.DIALOG_BORDER); //d.add(cp); d.setContentPane(cp); // XXX maybe pass yet another argument for this? // d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.pack(); return d; }
| 1,111,815
|
public static JDialog createArchitectPanelDialog( final ArchitectPanel arch, final Window dialogParent, final String dialogTitle, final String actionButtonTitle, final Action okAction, final Action cancelAction) { final JDialog d; if (dialogParent instanceof Frame) { d = new JDialog((Frame) dialogParent, dialogTitle); } else if (dialogParent instanceof Dialog) { d = new JDialog((Dialog) dialogParent, dialogTitle); } else { throw new IllegalArgumentException( "The dialogParent you gave me is not a " + "Frame or Dialog (it is a " + dialogParent.getClass().getName() + ")"); } JComponent panel = arch.getPanel(); // In all cases we have to close the dialog. Action closeAction = new CommonCloseAction(d); JButton okButton = new JDefaultButton(okAction); okButton.setText(actionButtonTitle); okButton.addActionListener(closeAction); JButton cancelButton = new JDefaultButton(cancelAction); cancelButton.setText(CANCEL_BUTTON_LABEL); cancelButton.addActionListener(closeAction); // Handle if the user presses Enter in the dialog - do OK action d.getRootPane().setDefaultButton(okButton); makeJDialogCancellable(d, cancelAction); // Now build the GUI. JPanel cp = new JPanel(new BorderLayout()); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); cp.add(panel, BorderLayout.CENTER); cp.add(ButtonBarFactory.buildOKCancelBar(okButton, cancelButton), BorderLayout.SOUTH); cp.setBorder(Borders.DIALOG_BORDER); //d.add(cp); d.setContentPane(cp); // XXX maybe pass yet another argument for this? // d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.pack(); return d; }
|
public static JDialog createArchitectPanelDialog( final ArchitectPanel arch, final Window dialogParent, final String dialogTitle, final String actionButtonTitle, final Action okAction, final Action cancelAction) { final JDialog d; if (dialogParent instanceof Frame) { d = new JDialog((Frame) dialogParent, dialogTitle); } else if (dialogParent instanceof Dialog) { d = new JDialog((Dialog) dialogParent, dialogTitle); } else { throw new IllegalArgumentException( "The dialogParent you gave me is not a " + "Frame or Dialog (it is a " + dialogParent.getClass().getName() + ")"); } JComponent panel = arch.getPanel(); // In all cases we have to close the dialog. Action closeAction = new CommonCloseAction(d); JButton okButton = new JDefaultButton(okAction); okButton.setText(actionButtonTitle); okButton.addActionListener(closeAction); JButton cancelButton = new JDefaultButton(cancelAction); cancelButton.setText(CANCEL_BUTTON_LABEL); cancelButton.addActionListener(closeAction); // Handle if the user presses Enter in the dialog - do OK action d.getRootPane().setDefaultButton(okButton); // Now build the GUI. JPanel cp = new JPanel(new BorderLayout()); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); cp.add(panel, BorderLayout.CENTER); cp.add(ButtonBarFactory.buildOKCancelBar(okButton, cancelButton), BorderLayout.SOUTH); cp.setBorder(Borders.DIALOG_BORDER); //d.add(cp); d.setContentPane(cp); // XXX maybe pass yet another argument for this? // d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.pack(); return d; }
| 1,111,817
|
public void actionPerformed(ActionEvent evt) { SQLTable t = new SQLTable(); t.initFolders(true); t.setTableName("New_Table"); TablePane tp = new TablePane(t); pp.addFloating(tp); }
|
public void actionPerformed(ActionEvent evt) { SQLTable t = new SQLTable(); t.initFolders(true); t.setTableName("New_Table"); TablePane tp = new TablePane(t, pp.getFontRenderContext()); pp.addFloating(tp); }
| 1,111,818
|
protected void runScript(String name) throws Exception { InputStream in = getClass().getResourceAsStream( name ); Script script = parser.parse( in ); script = script.compile(); log.info( "Evaluating: " + script ); script.run( parser.getContext(), output ); }
|
protected void runScript(String name) throws Exception { InputStream in = getClass().getResourceAsStream( name ); Script script = parser.parse( in ); script = script.compile(); log.info( "Evaluating: " + script ); script.run( parser.getJellyContext(), output ); }
| 1,111,820
|
public Expression createExpression( ExpressionFactory factory, TagScript tagScript, String attributeName, String attributeValue) throws Exception { // #### may need to include some namespace URI information in the XPath instance? if (attributeName.equals("select")) { if ( log.isDebugEnabled() ) { log.debug( "Parsing XPath expression: " + attributeValue ); } try { XPath xpath = new Dom4jXPath(attributeValue); return new XPathExpression(attributeValue, xpath, tagScript); } 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, tagScript, attributeName, attributeValue); }
|
public Expression createExpression( ExpressionFactory factory, TagScript tagScript, String attributeName, String attributeValue) throws Exception { // #### may need to include some namespace URI information in the XPath instance? if (attributeName.equals("select") || attributeName.equals("sort")) { if ( log.isDebugEnabled() ) { log.debug( "Parsing XPath expression: " + attributeValue ); } try { XPath xpath = new Dom4jXPath(attributeValue); return new XPathExpression(attributeValue, xpath, tagScript); } 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, tagScript, attributeName, attributeValue); }
| 1,111,822
|
public Object getValueAt(Object node, int column) { HaplotypeAssociationNode n = (HaplotypeAssociationNode) node; switch (column){ case 0: return n.getName(); case 1: return n.getFreq(); case 2: if(this.countsOrRatios == SHOW_COUNTS) { return n.getCounts(); } else if(this.countsOrRatios == SHOW_RATIOS) { return n.getRatios(); } case 3: return n.getChiSq(); case 4: return n.getPVal(); } return null; }
|
public Object getValueAt(Object node, int column) { HaplotypeAssociationNode n = (HaplotypeAssociationNode) node; switch (column){ case 0: return n.getName(); case 1: return n.getFreq(); case 2: if(this.countsOrRatios == SHOW_HAP_COUNTS) { return n.getCounts(); } else if(this.countsOrRatios == SHOW_RATIOS) { return n.getRatios(); } case 3: return n.getChiSq(); case 4: return n.getPVal(); } return null; }
| 1,111,823
|
public Object getValueAt(Object node, int column) { HaplotypeAssociationNode n = (HaplotypeAssociationNode) node; switch (column){ case 0: return n.getName(); case 1: return n.getFreq(); case 2: if(this.countsOrRatios == SHOW_COUNTS) { return n.getCounts(); } else if(this.countsOrRatios == SHOW_RATIOS) { return n.getRatios(); } case 3: return n.getChiSq(); case 4: return n.getPVal(); } return null; }
|
public Object getValueAt(Object node, int column) { HaplotypeAssociationNode n = (HaplotypeAssociationNode) node; switch (column){ case 0: return n.getName(); case 1: return n.getFreq(); case 2: if(this.countsOrRatios == SHOW_COUNTS) { return n.getCounts(); } else if(this.countsOrRatios == SHOW_RATIOS) { return n.getRatios(); } case 3: return n.getChiSq(); case 4: return n.getPVal(); } return null; }
| 1,111,824
|
public Map runNamedScript( String name, Map params ) throws Exception { return runNamedScript(name, params, createXMLOutput()); }
|
public Map runNamedScript( String name, Map params ) throws Exception { return runNamedScript(name, params, createXMLOutput()); }
| 1,111,826
|
public Map runScript( String url, Map params, XMLOutput output ) throws Exception { URL actualUrl = null; try { actualUrl = new URL( url ); } catch( MalformedURLException x ) { throw new JellyException( "Could not find script at URL [" + url + "]: " + x.getMessage(), x ); } // Set up the context JellyContext context = createJellyContext(); context.setVariables( params ); // Run the script context.runScript(url, output); return context.getVariables(); }
|
public Map runScript( String url, Map params, XMLOutput output ) throws Exception { URL actualUrl = null; try { actualUrl = new URL( url ); } catch( MalformedURLException x ) { throw new JellyException( "Could not find script at URL [" + url + "]: " + x.getMessage(), x ); } // Set up the context JellyContext context = createJellyContext(); context.setVariables( params ); // Run the script context.runScript(url, output); return context.getVariables(); }
| 1,111,827
|
public void login(ServiceContext context, String username, String password) throws ServiceException{ LoginCallbackHandler callbackHandler = new LoginCallbackHandler(); callbackHandler.setUsername(username); callbackHandler.setPassword(password); User user = null; UserManager userManager = UserManager.getInstance(); UserActivityLogger logger = UserActivityLogger.getInstance(); try{ LoginContext loginContext = new LoginContext(AuthConstants.AUTH_CONFIG_INDEX, callbackHandler); loginContext.login(); /* set Subject in session */ context._setSubject(loginContext.getSubject()); /* Successful login: update the lock count and status */ user = userManager.getUser(username); user.setLockCount(0); user.setStatus(null); userManager.updateUser(user); logger.logActivity(username, user.getName()+" logged in successfully"); }catch(LoginException lex){ user = userManager.getUser(username); String errorCode = ErrorCodes.UNKNOWN_ERROR; Object[] values = null; /* Conditionalize the error message */ if(user == null){ errorCode = ErrorCodes.INVALID_CREDENTIALS; }else if("I".equals(user.getStatus())){ errorCode = ErrorCodes.ACCOUNT_LOCKED; }else if(user.getLockCount() < MAX_LOGIN_ATTEMPTS_ALLOWED){ int thisAttempt = user.getLockCount()+1; user.setLockCount(thisAttempt); if(thisAttempt == MAX_LOGIN_ATTEMPTS_ALLOWED){ user.setStatus("I"); userManager.updateUser(user); errorCode = ErrorCodes.ACCOUNT_LOCKED; }else{ userManager.updateUser(user); errorCode = ErrorCodes.INVALID_LOGIN_ATTEMPTS; values = new Object[]{ String.valueOf(MAX_LOGIN_ATTEMPTS_ALLOWED - thisAttempt)}; } } logger.logActivity(username, user.getName()+" failed to login"); throw new ServiceException(errorCode, values); } }
|
public void login(ServiceContext context, String username, String password) throws ServiceException{ LoginCallbackHandler callbackHandler = new LoginCallbackHandler(); callbackHandler.setUsername(username); callbackHandler.setPassword(password); User user = null; UserManager userManager = UserManager.getInstance(); UserActivityLogger logger = UserActivityLogger.getInstance(); try{ LoginContext loginContext = new LoginContext(AuthConstants.AUTH_CONFIG_INDEX, callbackHandler); loginContext.login(); /* set Subject in session */ context._setSubject(loginContext.getSubject()); /* Successful login: update the lock count and status */ user = userManager.getUser(username); user.setLockCount(0); user.setStatus(null); userManager.updateUser(user); logger.logActivity(username, "logged in successfully"); }catch(LoginException lex){ user = userManager.getUser(username); String errorCode = ErrorCodes.UNKNOWN_ERROR; Object[] values = null; /* Conditionalize the error message */ if(user == null){ errorCode = ErrorCodes.INVALID_CREDENTIALS; }else if("I".equals(user.getStatus())){ errorCode = ErrorCodes.ACCOUNT_LOCKED; }else if(user.getLockCount() < MAX_LOGIN_ATTEMPTS_ALLOWED){ int thisAttempt = user.getLockCount()+1; user.setLockCount(thisAttempt); if(thisAttempt == MAX_LOGIN_ATTEMPTS_ALLOWED){ user.setStatus("I"); userManager.updateUser(user); errorCode = ErrorCodes.ACCOUNT_LOCKED; }else{ userManager.updateUser(user); errorCode = ErrorCodes.INVALID_LOGIN_ATTEMPTS; values = new Object[]{ String.valueOf(MAX_LOGIN_ATTEMPTS_ALLOWED - thisAttempt)}; } } logger.logActivity(username, user.getName()+" failed to login"); throw new ServiceException(errorCode, values); } }
| 1,111,828
|
public void populate() throws ArchitectException { if (populated) return; logger.debug("SQLCatalog: populate starting"); int oldSize = children.size(); synchronized (parent) { Connection con = null; ResultSet rs = null; try { con = ((SQLDatabase) parent).getConnection(); DatabaseMetaData dbmd = con.getMetaData(); con.setCatalog(getName()); rs = dbmd.getSchemas(); while (rs.next()) { String schName = rs.getString(1); SQLSchema schema = null; if (schName != null) { schema = new SQLSchema(this, schName, false); children.add(schema); schema.setNativeTerm(dbmd.getSchemaTerm()); logger.debug("Set schema term to "+schema.getNativeTerm()); } } rs.close(); rs = null; if (oldSize == children.size()) { rs = dbmd.getTables(getName(), null, "%", new String[] {"TABLE", "VIEW"}); while (rs.next()) { children.add(new SQLTable(this, rs.getString(3), rs.getString(5), rs.getString(4), false)); } rs.close(); rs = null; } } catch (SQLException e) { throw new ArchitectException("catalog.populate.fail", e); } finally { populated = true; int newSize = children.size(); if (newSize > oldSize) { int[] changedIndices = new int[newSize - oldSize]; for (int i = 0, n = newSize - oldSize; i < n; i++) { changedIndices[i] = oldSize + i; } fireDbChildrenInserted(changedIndices, children.subList(oldSize, newSize)); } try { if (rs != null) rs.close(); } catch (SQLException e2) { throw new ArchitectException("catalog.rs.close.fail", e2); } try { if (con != null) con.close(); } catch (SQLException e2) { throw new ArchitectException("Couldn't close connection", e2); } } } logger.debug("SQLCatalog: populate finished"); }
|
public void populate() throws ArchitectException { if (populated) return; logger.debug("SQLCatalog: populate starting"); int oldSize = children.size(); synchronized (parent) { Connection con = null; ResultSet rs = null; try { con = ((SQLDatabase) parent).getConnection(); DatabaseMetaData dbmd = con.getMetaData(); try { con.setCatalog(getName()); } catch (SQLException ex) { logger.info("populate: Could not setCatalog("+getName()+"). Assuming it's a permission problem. Stack trace:", ex); return; } rs = dbmd.getSchemas(); while (rs.next()) { String schName = rs.getString(1); SQLSchema schema = null; if (schName != null) { schema = new SQLSchema(this, schName, false); children.add(schema); schema.setNativeTerm(dbmd.getSchemaTerm()); logger.debug("Set schema term to "+schema.getNativeTerm()); } } rs.close(); rs = null; if (oldSize == children.size()) { rs = dbmd.getTables(getName(), null, "%", new String[] {"TABLE", "VIEW"}); while (rs.next()) { children.add(new SQLTable(this, rs.getString(3), rs.getString(5), rs.getString(4), false)); } rs.close(); rs = null; } } catch (SQLException e) { throw new ArchitectException("catalog.populate.fail", e); } finally { populated = true; int newSize = children.size(); if (newSize > oldSize) { int[] changedIndices = new int[newSize - oldSize]; for (int i = 0, n = newSize - oldSize; i < n; i++) { changedIndices[i] = oldSize + i; } fireDbChildrenInserted(changedIndices, children.subList(oldSize, newSize)); } try { if (rs != null) rs.close(); } catch (SQLException e2) { throw new ArchitectException("catalog.rs.close.fail", e2); } try { if (con != null) con.close(); } catch (SQLException e2) { throw new ArchitectException("Couldn't close connection", e2); } } } logger.debug("SQLCatalog: populate finished"); }
| 1,111,830
|
public synchronized TablePane importTableCopy(SQLTable source, Point preferredLocation) throws ArchitectException { SQLTable newTable = SQLTable.getDerivedInstance(source, db); // adds newTable to db String key = source.getTableName().toLowerCase(); // ensure tablename is unique if (logger.isDebugEnabled()) logger.debug("before add: " + tableNames); if (!tableNames.add(key)) { boolean done = false; int newSuffix = 0; while (!done) { newSuffix++; done = tableNames.add(key+"_"+newSuffix); } newTable.setTableName(source.getTableName()+"_"+newSuffix); } if (logger.isDebugEnabled()) logger.debug("after add: " + tableNames); TablePane tp = new TablePane(newTable); logger.info("adding table "+newTable); add(tp, preferredLocation); tp.revalidate(); // create exported relationships if the importing tables exist in pp Iterator sourceKeys = source.getExportedKeys().iterator(); while (sourceKeys.hasNext()) { SQLRelationship r = (SQLRelationship) sourceKeys.next(); if (logger.isInfoEnabled()) { logger.info("Looking for fk table "+r.getFkTable().getName()+" in playpen"); } TablePane fkTablePane = findTablePaneByName(r.getFkTable().getName()); if (fkTablePane != null) { logger.info("FOUND IT!"); SQLTable fkTable = fkTablePane.getModel(); SQLRelationship newRel = new SQLRelationship(); newRel.setName(r.getName()); newRel.setIdentifying(true); newRel.setPkTable(newTable); newTable.addExportedKey(newRel); newRel.setFkTable(fkTable); fkTable.addImportedKey(newRel); add(new Relationship(this, newRel)); Iterator mappings = r.getChildren().iterator(); while (mappings.hasNext()) { SQLRelationship.ColumnMapping m = (SQLRelationship.ColumnMapping) mappings.next(); SQLColumn pkCol = newTable.getColumnByName(m.getPkColumn().getName()); SQLColumn fkCol = fkTable.getColumnByName(m.getFkColumn().getName()); if (pkCol == null) { // this shouldn't happen throw new IllegalStateException("Couldn't fink pkCol "+m.getPkColumn().getName()+" in new table"); } if (fkCol == null) { // this might reasonably happen (user deleted the column) continue; } SQLRelationship.ColumnMapping newMapping = new SQLRelationship.ColumnMapping(); newMapping.setPkColumn(pkCol); newMapping.setFkColumn(fkCol); newRel.addChild(newMapping); } } else { logger.info("NOT FOUND"); } } // create imported relationships if the exporting tables exist in pp sourceKeys = source.getImportedKeys().iterator(); while (sourceKeys.hasNext()) { SQLRelationship r = (SQLRelationship) sourceKeys.next(); if (logger.isDebugEnabled()) { logger.info("Looking for pk table "+r.getPkTable().getName()+" in playpen"); } TablePane pkTablePane = findTablePaneByName(r.getPkTable().getName()); if (pkTablePane != null) { logger.info("FOUND IT!"); SQLTable pkTable = pkTablePane.getModel(); SQLRelationship newRel = new SQLRelationship(); newRel.setName(r.getName()); newRel.setIdentifying(true); newRel.setPkTable(pkTable); pkTable.addExportedKey(newRel); newRel.setFkTable(newTable); newTable.addImportedKey(newRel); add(new Relationship(this, newRel)); Iterator mappings = r.getChildren().iterator(); while (mappings.hasNext()) { SQLRelationship.ColumnMapping m = (SQLRelationship.ColumnMapping) mappings.next(); SQLColumn pkCol = pkTable.getColumnByName(m.getPkColumn().getName()); SQLColumn fkCol = newTable.getColumnByName(m.getFkColumn().getName()); if (fkCol == null) { // this shouldn't happen throw new IllegalStateException("Couldn't fink fkCol "+m.getPkColumn().getName()+" in new table"); } if (pkCol == null) { // this might reasonably happen (user deleted the column) continue; } SQLRelationship.ColumnMapping newMapping = new SQLRelationship.ColumnMapping(); newMapping.setPkColumn(pkCol); newMapping.setFkColumn(fkCol); newRel.addChild(newMapping); } } else { logger.info("NOT FOUND"); } } return tp; }
|
public synchronized TablePane importTableCopy(SQLTable source, Point preferredLocation) throws ArchitectException { SQLTable newTable = SQLTable.getDerivedInstance(source, db); // adds newTable to db String key = source.getTableName().toLowerCase(); // ensure tablename is unique if (logger.isDebugEnabled()) logger.debug("before add: " + tableNames); if (!tableNames.add(key)) { boolean done = false; int newSuffix = 0; while (!done) { newSuffix++; done = tableNames.add(key+"_"+newSuffix); } newTable.setTableName(source.getTableName()+"_"+newSuffix); } if (logger.isDebugEnabled()) logger.debug("after add: " + tableNames); TablePane tp = new TablePane(newTable, getFontRenderContext()); logger.info("adding table "+newTable); add(tp, preferredLocation); tp.revalidate(); // create exported relationships if the importing tables exist in pp Iterator sourceKeys = source.getExportedKeys().iterator(); while (sourceKeys.hasNext()) { SQLRelationship r = (SQLRelationship) sourceKeys.next(); if (logger.isInfoEnabled()) { logger.info("Looking for fk table "+r.getFkTable().getName()+" in playpen"); } TablePane fkTablePane = findTablePaneByName(r.getFkTable().getName()); if (fkTablePane != null) { logger.info("FOUND IT!"); SQLTable fkTable = fkTablePane.getModel(); SQLRelationship newRel = new SQLRelationship(); newRel.setName(r.getName()); newRel.setIdentifying(true); newRel.setPkTable(newTable); newTable.addExportedKey(newRel); newRel.setFkTable(fkTable); fkTable.addImportedKey(newRel); add(new Relationship(this, newRel)); Iterator mappings = r.getChildren().iterator(); while (mappings.hasNext()) { SQLRelationship.ColumnMapping m = (SQLRelationship.ColumnMapping) mappings.next(); SQLColumn pkCol = newTable.getColumnByName(m.getPkColumn().getName()); SQLColumn fkCol = fkTable.getColumnByName(m.getFkColumn().getName()); if (pkCol == null) { // this shouldn't happen throw new IllegalStateException("Couldn't fink pkCol "+m.getPkColumn().getName()+" in new table"); } if (fkCol == null) { // this might reasonably happen (user deleted the column) continue; } SQLRelationship.ColumnMapping newMapping = new SQLRelationship.ColumnMapping(); newMapping.setPkColumn(pkCol); newMapping.setFkColumn(fkCol); newRel.addChild(newMapping); } } else { logger.info("NOT FOUND"); } } // create imported relationships if the exporting tables exist in pp sourceKeys = source.getImportedKeys().iterator(); while (sourceKeys.hasNext()) { SQLRelationship r = (SQLRelationship) sourceKeys.next(); if (logger.isDebugEnabled()) { logger.info("Looking for pk table "+r.getPkTable().getName()+" in playpen"); } TablePane pkTablePane = findTablePaneByName(r.getPkTable().getName()); if (pkTablePane != null) { logger.info("FOUND IT!"); SQLTable pkTable = pkTablePane.getModel(); SQLRelationship newRel = new SQLRelationship(); newRel.setName(r.getName()); newRel.setIdentifying(true); newRel.setPkTable(pkTable); pkTable.addExportedKey(newRel); newRel.setFkTable(newTable); newTable.addImportedKey(newRel); add(new Relationship(this, newRel)); Iterator mappings = r.getChildren().iterator(); while (mappings.hasNext()) { SQLRelationship.ColumnMapping m = (SQLRelationship.ColumnMapping) mappings.next(); SQLColumn pkCol = pkTable.getColumnByName(m.getPkColumn().getName()); SQLColumn fkCol = newTable.getColumnByName(m.getFkColumn().getName()); if (fkCol == null) { // this shouldn't happen throw new IllegalStateException("Couldn't fink fkCol "+m.getPkColumn().getName()+" in new table"); } if (pkCol == null) { // this might reasonably happen (user deleted the column) continue; } SQLRelationship.ColumnMapping newMapping = new SQLRelationship.ColumnMapping(); newMapping.setPkColumn(pkCol); newMapping.setFkColumn(fkCol); newRel.addChild(newMapping); } } else { logger.info("NOT FOUND"); } } return tp; }
| 1,111,831
|
public static void main(String[] args) { //set defaults Options.setMissingThreshold(0.5); Options.setSpacingThreshold(0.0); Options.setAssocTest(ASSOC_NONE); Options.setHaplotypeDisplayThreshold(1); Options.setMaxDistance(500); Options.setLDColorScheme(STD_SCHEME); Options.setShowGBrowse(false); //this parses the command line arguments. if nogui mode is specified, //then haploText will execute whatever the user specified HaploText argParser = new HaploText(args); //if nogui is specified, then HaploText has already executed everything, and let Main() return //otherwise, we want to actually load and run the gui if(!argParser.isNogui()) { 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); final SwingWorker worker = new SwingWorker(){ UpdateChecker uc; public Object construct() { uc = new UpdateChecker(); uc.checkForUpdate(); return null; } public void finished() { if(uc != null) { if(uc.isNewVersionAvailable()) { //theres an update available so lets pop some crap up final JLayeredPane jlp = window.getLayeredPane(); final JPanel udp = new JPanel(); udp.setLayout(new BoxLayout(udp, BoxLayout.Y_AXIS)); double version = uc.getNewVersion(); Font detailsFont = new Font("Default", Font.PLAIN, 14); JLabel announceLabel = new JLabel("A newer version of Haploview (" +version+") is available."); announceLabel.setFont(detailsFont); JLabel detailsLabel = new JLabel("See \"Check for update\" in the file menu for details."); detailsLabel.setFont(detailsFont); udp.add(announceLabel); udp.add(detailsLabel); udp.setBorder(BorderFactory.createRaisedBevelBorder()); int width = udp.getPreferredSize().width; int height = udp.getPreferredSize().height; int borderwidth = udp.getBorder().getBorderInsets(udp).right; int borderheight = udp.getBorder().getBorderInsets(udp).bottom; udp.setBounds(jlp.getWidth()-width-borderwidth, jlp.getHeight()-height-borderheight, udp.getPreferredSize().width, udp.getPreferredSize().height); udp.setOpaque(true); jlp.add(udp, JLayeredPane.POPUP_LAYER); java.util.Timer updateTimer = new Timer(); //show this update message for 6.5 seconds updateTimer.schedule(new TimerTask() { public void run() { jlp.remove(udp); jlp.repaint(); } },6000); } } } }; //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); worker.start(); //parse command line stuff for input files or prompt data dialog 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 static void main(String[] args) { //set defaults Options.setMissingThreshold(0.5); Options.setSpacingThreshold(0.0); Options.setAssocTest(ASSOC_NONE); Options.setHaplotypeDisplayThreshold(1); Options.setMaxDistance(500); Options.setLDColorScheme(STD_SCHEME); Options.setShowGBrowse(false); //this parses the command line arguments. if nogui mode is specified, //then haploText will execute whatever the user specified HaploText argParser = new HaploText(args); //if nogui is specified, then HaploText has already executed everything, and let Main() return //otherwise, we want to actually load and run the gui if(!argParser.isNogui()) { 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); final SwingWorker worker = new SwingWorker(){ UpdateChecker uc; public Object construct() { uc = new UpdateChecker(); uc.checkForUpdate(); return null; } public void finished() { if(uc != null) { if(uc.isNewVersionAvailable()) { //theres an update available so lets pop some crap up final JLayeredPane jlp = window.getLayeredPane(); final JPanel udp = new JPanel(); udp.setLayout(new BoxLayout(udp, BoxLayout.Y_AXIS)); double version = uc.getNewVersion(); Font detailsFont = new Font("Default", Font.PLAIN, 14); JLabel announceLabel = new JLabel("A newer version of Haploview (" +version+") is available."); announceLabel.setFont(detailsFont); JLabel detailsLabel = new JLabel("See \"Check for update\" in the file menu for details."); detailsLabel.setFont(detailsFont); udp.add(announceLabel); udp.add(detailsLabel); udp.setBorder(BorderFactory.createRaisedBevelBorder()); int width = udp.getPreferredSize().width; int height = udp.getPreferredSize().height; int borderwidth = udp.getBorder().getBorderInsets(udp).right; int borderheight = udp.getBorder().getBorderInsets(udp).bottom; udp.setBounds(jlp.getWidth()-width-borderwidth, jlp.getHeight()-height-borderheight, udp.getPreferredSize().width, udp.getPreferredSize().height); udp.setOpaque(true); jlp.add(udp, JLayeredPane.POPUP_LAYER); java.util.Timer updateTimer = new Timer(); //show this update message for 6.5 seconds updateTimer.schedule(new TimerTask() { public void run() { jlp.remove(udp); jlp.repaint(); } },6000); } } } }; //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); worker.start(); //parse command line stuff for input files or prompt data dialog 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] = null; window.readGenotypes(inputArray, HMP); }else{ ReadDataDialog readDialog = new ReadDataDialog("Welcome to HaploView", window); readDialog.pack(); readDialog.setVisible(true); } } }
| 1,111,832
|
public void register(AlertHandler handler, String alertId, String alertName){ assert this.handler == null; assert connection == null; this.handler = handler; /* start looking for this notification */ connection = ServerConnector.getServerConnection( sourceConfig.getApplicationConfig()); monitorObjName = new ObjectName("jmanage:name=" + alertName + ",id=" + alertId + ",type=GaugeMonitor"); /* check if the MBean is already registered */ Set mbeans = connection.queryNames(monitorObjName); if(mbeans != null && mbeans.size() > 0){ /* remove the MBean */ connection.unregisterMBean(monitorObjName); } /* create the MBean */ connection.createMBean("javax.management.monitor.GaugeMonitor", monitorObjName, null, null); /* set attributes */ List attributes = new LinkedList(); attributes.add(new ObjectAttribute("GranularityPeriod", new Long(5000))); attributes.add(new ObjectAttribute("NotifyHigh", Boolean.TRUE)); attributes.add(new ObjectAttribute("NotifyLow", Boolean.TRUE)); attributes.add(new ObjectAttribute("ObservedAttribute", sourceConfig.getAttributeName())); // note the following is deprecated, but this is what weblogic exposes attributes.add(new ObjectAttribute("ObservedObject", connection.buildObjectName(sourceConfig.getObjectName()))); connection.setAttributes(monitorObjName, attributes); /* add observed object */ /* connection.invoke(monitorObjName, "addObservedObject", new Object[]{new ObjectName(sourceConfig.getObjectName())}, new String[]{"javax.management.ObjectName"}); */ /* set thresholds */ Object[] params = new Object[]{sourceConfig.getHighThreshold(), sourceConfig.getLowThreshold()}; String[] signature = new String[]{Number.class.getName(), Number.class.getName()}; connection.invoke(monitorObjName, "setThresholds", params, signature); /* start the monitor */ connection.invoke(monitorObjName, "start", new Object[0], new String[0]); /* now look for notifications from this mbean */ listener = new ObjectNotificationListener(){ public void handleNotification(ObjectNotification notification, Object handback) { try { GaugeAlertSource.this.handler.handle( new AlertInfo(notification)); } catch (Exception e) { logger.log(Level.SEVERE, "Error while handling alert", e); } } }; filter = new ObjectNotificationFilterSupport(); filter.enableType("jmx.monitor.gauge.high"); filter.enableType("jmx.monitor.gauge.low"); filter.enableType("jmx.monitor.error.attribute"); filter.enableType("jmx.monitor.error.type"); filter.enableType("jmx.monitor.error.mbean"); filter.enableType("jmx.monitor.error.runtime"); filter.enableType("jmx.monitor.error.threshold"); connection.addNotificationListener(monitorObjName, listener, filter, null); }
|
public void register(AlertHandler handler, String alertId, String alertName){ assert this.handler == null; assert connection == null; this.handler = handler; /* start looking for this notification */ connection = ServerConnector.getServerConnection( sourceConfig.getApplicationConfig()); monitorObjName = new ObjectName("jmanage.alerts:name=" + alertName + ",id=" + alertId + ",type=GaugeMonitor"); /* check if the MBean is already registered */ Set mbeans = connection.queryNames(monitorObjName); if(mbeans != null && mbeans.size() > 0){ /* remove the MBean */ connection.unregisterMBean(monitorObjName); } /* create the MBean */ connection.createMBean("javax.management.monitor.GaugeMonitor", monitorObjName, null, null); /* set attributes */ List attributes = new LinkedList(); attributes.add(new ObjectAttribute("GranularityPeriod", new Long(5000))); attributes.add(new ObjectAttribute("NotifyHigh", Boolean.TRUE)); attributes.add(new ObjectAttribute("NotifyLow", Boolean.TRUE)); attributes.add(new ObjectAttribute("ObservedAttribute", sourceConfig.getAttributeName())); // note the following is deprecated, but this is what weblogic exposes attributes.add(new ObjectAttribute("ObservedObject", connection.buildObjectName(sourceConfig.getObjectName()))); connection.setAttributes(monitorObjName, attributes); /* add observed object */ /* connection.invoke(monitorObjName, "addObservedObject", new Object[]{new ObjectName(sourceConfig.getObjectName())}, new String[]{"javax.management.ObjectName"}); */ /* set thresholds */ Object[] params = new Object[]{sourceConfig.getHighThreshold(), sourceConfig.getLowThreshold()}; String[] signature = new String[]{Number.class.getName(), Number.class.getName()}; connection.invoke(monitorObjName, "setThresholds", params, signature); /* start the monitor */ connection.invoke(monitorObjName, "start", new Object[0], new String[0]); /* now look for notifications from this mbean */ listener = new ObjectNotificationListener(){ public void handleNotification(ObjectNotification notification, Object handback) { try { GaugeAlertSource.this.handler.handle( new AlertInfo(notification)); } catch (Exception e) { logger.log(Level.SEVERE, "Error while handling alert", e); } } }; filter = new ObjectNotificationFilterSupport(); filter.enableType("jmx.monitor.gauge.high"); filter.enableType("jmx.monitor.gauge.low"); filter.enableType("jmx.monitor.error.attribute"); filter.enableType("jmx.monitor.error.type"); filter.enableType("jmx.monitor.error.mbean"); filter.enableType("jmx.monitor.error.runtime"); filter.enableType("jmx.monitor.error.threshold"); connection.addNotificationListener(monitorObjName, listener, filter, null); }
| 1,111,833
|
public void register(AlertHandler handler, String alertId, String alertName){ assert this.handler == null; assert connection == null; this.handler = handler; /* start looking for this notification */ connection = ServerConnector.getServerConnection( sourceConfig.getApplicationConfig()); monitorObjName = new ObjectName("jmanage:name=" + alertName + ",id=" + alertId + ",type=GaugeMonitor"); /* check if the MBean is already registered */ Set mbeans = connection.queryNames(monitorObjName); if(mbeans != null && mbeans.size() > 0){ /* remove the MBean */ connection.unregisterMBean(monitorObjName); } /* create the MBean */ connection.createMBean("javax.management.monitor.GaugeMonitor", monitorObjName, null, null); /* set attributes */ List attributes = new LinkedList(); attributes.add(new ObjectAttribute("GranularityPeriod", new Long(5000))); attributes.add(new ObjectAttribute("NotifyHigh", Boolean.TRUE)); attributes.add(new ObjectAttribute("NotifyLow", Boolean.TRUE)); attributes.add(new ObjectAttribute("ObservedAttribute", sourceConfig.getAttributeName())); // note the following is deprecated, but this is what weblogic exposes attributes.add(new ObjectAttribute("ObservedObject", connection.buildObjectName(sourceConfig.getObjectName()))); connection.setAttributes(monitorObjName, attributes); /* add observed object */ /* connection.invoke(monitorObjName, "addObservedObject", new Object[]{new ObjectName(sourceConfig.getObjectName())}, new String[]{"javax.management.ObjectName"}); */ /* set thresholds */ Object[] params = new Object[]{sourceConfig.getHighThreshold(), sourceConfig.getLowThreshold()}; String[] signature = new String[]{Number.class.getName(), Number.class.getName()}; connection.invoke(monitorObjName, "setThresholds", params, signature); /* start the monitor */ connection.invoke(monitorObjName, "start", new Object[0], new String[0]); /* now look for notifications from this mbean */ listener = new ObjectNotificationListener(){ public void handleNotification(ObjectNotification notification, Object handback) { try { GaugeAlertSource.this.handler.handle( new AlertInfo(notification)); } catch (Exception e) { logger.log(Level.SEVERE, "Error while handling alert", e); } } }; filter = new ObjectNotificationFilterSupport(); filter.enableType("jmx.monitor.gauge.high"); filter.enableType("jmx.monitor.gauge.low"); filter.enableType("jmx.monitor.error.attribute"); filter.enableType("jmx.monitor.error.type"); filter.enableType("jmx.monitor.error.mbean"); filter.enableType("jmx.monitor.error.runtime"); filter.enableType("jmx.monitor.error.threshold"); connection.addNotificationListener(monitorObjName, listener, filter, null); }
|
public void register(AlertHandler handler, String alertId, String alertName){ assert this.handler == null; assert connection == null; this.handler = handler; /* start looking for this notification */ connection = ServerConnector.getServerConnection( sourceConfig.getApplicationConfig()); monitorObjName = new ObjectName("jmanage:name=" + alertName + ",id=" + alertId + ",type=GaugeMonitor"); /* check if the MBean is already registered */ Set mbeans = connection.queryNames(monitorObjName); if(mbeans != null && mbeans.size() > 0){ /* remove the MBean */ connection.unregisterMBean(monitorObjName); } /* create the MBean */ connection.createMBean("javax.management.monitor.GaugeMonitor", monitorObjName, new Object[0], new String[0]); /* set attributes */ List attributes = new LinkedList(); attributes.add(new ObjectAttribute("GranularityPeriod", new Long(5000))); attributes.add(new ObjectAttribute("NotifyHigh", Boolean.TRUE)); attributes.add(new ObjectAttribute("NotifyLow", Boolean.TRUE)); attributes.add(new ObjectAttribute("ObservedAttribute", sourceConfig.getAttributeName())); // note the following is deprecated, but this is what weblogic exposes attributes.add(new ObjectAttribute("ObservedObject", connection.buildObjectName(sourceConfig.getObjectName()))); connection.setAttributes(monitorObjName, attributes); /* add observed object */ /* connection.invoke(monitorObjName, "addObservedObject", new Object[]{new ObjectName(sourceConfig.getObjectName())}, new String[]{"javax.management.ObjectName"}); */ /* set thresholds */ Object[] params = new Object[]{sourceConfig.getHighThreshold(), sourceConfig.getLowThreshold()}; String[] signature = new String[]{Number.class.getName(), Number.class.getName()}; connection.invoke(monitorObjName, "setThresholds", params, signature); /* start the monitor */ connection.invoke(monitorObjName, "start", new Object[0], new String[0]); /* now look for notifications from this mbean */ listener = new ObjectNotificationListener(){ public void handleNotification(ObjectNotification notification, Object handback) { try { GaugeAlertSource.this.handler.handle( new AlertInfo(notification)); } catch (Exception e) { logger.log(Level.SEVERE, "Error while handling alert", e); } } }; filter = new ObjectNotificationFilterSupport(); filter.enableType("jmx.monitor.gauge.high"); filter.enableType("jmx.monitor.gauge.low"); filter.enableType("jmx.monitor.error.attribute"); filter.enableType("jmx.monitor.error.type"); filter.enableType("jmx.monitor.error.mbean"); filter.enableType("jmx.monitor.error.runtime"); filter.enableType("jmx.monitor.error.threshold"); connection.addNotificationListener(monitorObjName, listener, filter, null); }
| 1,111,834
|
public void unregister() { assert connection != null; assert monitorObjName != null; try { /* remove notification listener */ connection.removeNotificationListener(monitorObjName, listener, filter, null); } catch (Exception e) { logger.log(Level.WARNING, "Error while Removing Notification Listener", e); } try { /* unregister GaugeMonitor MBean */ connection.unregisterMBean(monitorObjName); } catch (Exception e) { logger.log(Level.WARNING, "Error while unregistering MBean: " + monitorObjName, e); } /* close the connection */ try { connection.close(); } catch (IOException e) { logger.log(Level.SEVERE, "Error while closing connection", e); } connection = null; handler = null; listener = null; filter = null; }
|
public void unregister() { assert connection != null; assert monitorObjName != null; try { /* remove notification listener */ connection.removeNotificationListener(monitorObjName, listener, filter, null); } catch (Exception e) { logger.log(Level.WARNING, "Error while Removing Notification Listener", e); } try { /* unregister GaugeMonitor MBean */ connection.unregisterMBean(monitorObjName); } catch (Exception e) { logger.log(Level.WARNING, "Error while unregistering MBean: " + monitorObjName, e); } /* close the connection */ try { connection.close(); } catch (IOException e) { logger.log(Level.WARNING, "Error while closing connection", e); } connection = null; handler = null; listener = null; filter = null; }
| 1,111,835
|
private PresentationObject getMailInputTable(IWContext iwc){ Table T = new Table(); T.setCellpaddingAndCellspacing(0); T.setColor(_bgColor); TextInput email = new TextInput("nl_email"); email.setStyleAttribute(_inputStyle); email.setLength(_inputLength); email.setContent(iwrb.getLocalizedString("enter_email_here","Enter e-mail here")); email.setOnFocus("this.value=''"); SubmitButton send,cancel; if (submitImage != null) { send = new SubmitButton(submitImage, "nl_send"); } else { send = new SubmitButton(iwrb.getLocalizedImageButton("subscribe", "Subscribe"), "nl_send"); } if (cancelImage != null) { cancel = new SubmitButton(cancelImage, "nl_stop"); } else { cancel = new SubmitButton(iwrb.getLocalizedImageButton("unsubscribe", "Unsubscribe"), "nl_stop"); } if(!_submitBelowTopics) { if ( _submitBelow ) { T.add(email, 1, 1); T.setHeight(1, 2, _spaceBetween); T.add(send, 1, 3); if (_showCancelImage) T.add(cancel, 1, 3); } else { T.add(email, 1, 1); T.setWidth(2, 1, _spaceBetween); T.add(send, 3, 1); if (_showCancelImage) T.add(cancel, 3, 1); } } return T; }
|
private PresentationObject getMailInputTable(IWContext iwc){ Table T = new Table(); T.setCellpaddingAndCellspacing(0); T.setColor(_bgColor); TextInput email = new TextInput("nl_email"); email.setStyleAttribute(_inputStyle); email.setLength(_inputLength); email.setContent(iwrb.getLocalizedString("enter_email_here","Enter e-mail here")); email.setOnFocus("this.value=''"); SubmitButton send,cancel; if (submitImage != null) { send = new SubmitButton(submitImage, "nl_send"); } else { send = new SubmitButton(iwrb.getLocalizedImageButton("subscribe", "Subscribe"), "nl_send"); } if (cancelImage != null) { cancel = new SubmitButton(cancelImage, "nl_stop"); } else { cancel = new SubmitButton(iwrb.getLocalizedImageButton("unsubscribe", "Unsubscribe"), "nl_stop"); } if ( _submitBelow ) { T.add(email, 1, 1); T.setHeight(1, 2, _spaceBetween); T.add(send, 1, 3); if (_showCancelImage) T.add(cancel, 1, 3); } else { T.add(email, 1, 1); T.setWidth(2, 1, _spaceBetween); T.add(send, 3, 1); if (_showCancelImage) T.add(cancel, 3, 1); } } return T; }
| 1,111,836
|
private PresentationObject getMailInputTable(IWContext iwc){ Table T = new Table(); T.setCellpaddingAndCellspacing(0); T.setColor(_bgColor); TextInput email = new TextInput("nl_email"); email.setStyleAttribute(_inputStyle); email.setLength(_inputLength); email.setContent(iwrb.getLocalizedString("enter_email_here","Enter e-mail here")); email.setOnFocus("this.value=''"); SubmitButton send,cancel; if (submitImage != null) { send = new SubmitButton(submitImage, "nl_send"); } else { send = new SubmitButton(iwrb.getLocalizedImageButton("subscribe", "Subscribe"), "nl_send"); } if (cancelImage != null) { cancel = new SubmitButton(cancelImage, "nl_stop"); } else { cancel = new SubmitButton(iwrb.getLocalizedImageButton("unsubscribe", "Unsubscribe"), "nl_stop"); } if(!_submitBelowTopics) { if ( _submitBelow ) { T.add(email, 1, 1); T.setHeight(1, 2, _spaceBetween); T.add(send, 1, 3); if (_showCancelImage) T.add(cancel, 1, 3); } else { T.add(email, 1, 1); T.setWidth(2, 1, _spaceBetween); T.add(send, 3, 1); if (_showCancelImage) T.add(cancel, 3, 1); } } return T; }
|
private PresentationObject getMailInputTable(IWContext iwc){ Table T = new Table(); T.setCellpaddingAndCellspacing(0); T.setColor(_bgColor); TextInput email = new TextInput("nl_email"); email.setStyleAttribute(_inputStyle); email.setLength(_inputLength); email.setContent(iwrb.getLocalizedString("enter_email_here","Enter e-mail here")); email.setOnFocus("this.value=''"); SubmitButton send,cancel; if (submitImage != null) { send = new SubmitButton(submitImage, "nl_send"); } else { send = new SubmitButton(iwrb.getLocalizedImageButton("subscribe", "Subscribe"), "nl_send"); } if (cancelImage != null) { cancel = new SubmitButton(cancelImage, "nl_stop"); } else { cancel = new SubmitButton(iwrb.getLocalizedImageButton("unsubscribe", "Unsubscribe"), "nl_stop"); } if(!_submitBelowTopics) { if ( _submitBelow ) { T.add(email, 1, 1); T.setHeight(1, 2, _spaceBetween); T.add(send, 1, 3); if (_showCancelImage) T.add(cancel, 1, 3); } else { T.add(email, 1, 1); T.setWidth(2, 1, _spaceBetween); T.add(send, 3, 1); if (_showCancelImage) T.add(cancel, 3, 1); } } return T; }
| 1,111,837
|
private PresentationObject getMailInputTable(IWContext iwc){ Table T = new Table(); T.setCellpaddingAndCellspacing(0); T.setColor(_bgColor); TextInput email = new TextInput("nl_email"); email.setStyleAttribute(_inputStyle); email.setLength(_inputLength); email.setContent(iwrb.getLocalizedString("enter_email_here","Enter e-mail here")); email.setOnFocus("this.value=''"); SubmitButton send,cancel; if (submitImage != null) { send = new SubmitButton(submitImage, "nl_send"); } else { send = new SubmitButton(iwrb.getLocalizedImageButton("subscribe", "Subscribe"), "nl_send"); } if (cancelImage != null) { cancel = new SubmitButton(cancelImage, "nl_stop"); } else { cancel = new SubmitButton(iwrb.getLocalizedImageButton("unsubscribe", "Unsubscribe"), "nl_stop"); } if(!_submitBelowTopics) { if ( _submitBelow ) { T.add(email, 1, 1); T.setHeight(1, 2, _spaceBetween); T.add(send, 1, 3); if (_showCancelImage) T.add(cancel, 1, 3); } else { T.add(email, 1, 1); T.setWidth(2, 1, _spaceBetween); T.add(send, 3, 1); if (_showCancelImage) T.add(cancel, 3, 1); } } return T; }
|
private PresentationObject getMailInputTable(IWContext iwc){ Table T = new Table(); T.setCellpaddingAndCellspacing(0); T.setColor(_bgColor); TextInput email = new TextInput("nl_email"); email.setStyleAttribute(_inputStyle); email.setLength(_inputLength); email.setContent(iwrb.getLocalizedString("enter_email_here","Enter e-mail here")); email.setOnFocus("this.value=''"); SubmitButton send,cancel; if (submitImage != null) { send = new SubmitButton(submitImage, "nl_send"); } else { send = new SubmitButton(iwrb.getLocalizedImageButton("subscribe", "Subscribe"), "nl_send"); } if (cancelImage != null) { cancel = new SubmitButton(cancelImage, "nl_stop"); } else { cancel = new SubmitButton(iwrb.getLocalizedImageButton("unsubscribe", "Unsubscribe"), "nl_stop"); } if(!_submitBelowTopics) { if ( _submitBelow ) { T.add(email, 1, 1); T.setHeight(1, 2, _spaceBetween); T.add(send, 1, 3); if (_showCancelImage) T.add(cancel, 1, 3); } else { T.add(email, 1, 1); T.setWidth(2, 1, _spaceBetween); T.add(send, 3, 1); if (_showCancelImage) T.add(cancel, 3, 1); } } return T; }
| 1,111,838
|
private PresentationObject getMailInputTable(IWContext iwc){ Table T = new Table(); T.setCellpaddingAndCellspacing(0); T.setColor(_bgColor); TextInput email = new TextInput("nl_email"); email.setStyleAttribute(_inputStyle); email.setLength(_inputLength); email.setContent(iwrb.getLocalizedString("enter_email_here","Enter e-mail here")); email.setOnFocus("this.value=''"); SubmitButton send,cancel; if (submitImage != null) { send = new SubmitButton(submitImage, "nl_send"); } else { send = new SubmitButton(iwrb.getLocalizedImageButton("subscribe", "Subscribe"), "nl_send"); } if (cancelImage != null) { cancel = new SubmitButton(cancelImage, "nl_stop"); } else { cancel = new SubmitButton(iwrb.getLocalizedImageButton("unsubscribe", "Unsubscribe"), "nl_stop"); } if(!_submitBelowTopics) { if ( _submitBelow ) { T.add(email, 1, 1); T.setHeight(1, 2, _spaceBetween); T.add(send, 1, 3); if (_showCancelImage) T.add(cancel, 1, 3); } else { T.add(email, 1, 1); T.setWidth(2, 1, _spaceBetween); T.add(send, 3, 1); if (_showCancelImage) T.add(cancel, 3, 1); } } return T; }
|
private PresentationObject getMailInputTable(IWContext iwc){ Table T = new Table(); T.setCellpaddingAndCellspacing(0); T.setColor(_bgColor); TextInput email = new TextInput("nl_email"); email.setStyleAttribute(_inputStyle); email.setLength(_inputLength); email.setContent(iwrb.getLocalizedString("enter_email_here","Enter e-mail here")); email.setOnFocus("this.value=''"); SubmitButton send,cancel; if (submitImage != null) { send = new SubmitButton(submitImage, "nl_send"); else { send = new SubmitButton(iwrb.getLocalizedImageButton("subscribe", "Subscribe"), "nl_send"); if (cancelImage != null) { cancel = new SubmitButton(cancelImage, "nl_stop"); else { cancel = new SubmitButton(iwrb.getLocalizedImageButton("unsubscribe", "Unsubscribe"), "nl_stop"); if(!_submitBelowTopics) { if ( _submitBelow ) { T.add(email, 1, 1); T.setHeight(1, 2, _spaceBetween); T.add(send, 1, 3); if (_showCancelImage) T.add(cancel, 1, 3); else { T.add(email, 1, 1); T.setWidth(2, 1, _spaceBetween); T.add(send, 3, 1); if (_showCancelImage) T.add(cancel, 3, 1); return T;
| 1,111,839
|
public void dragGestureRecognized(DragGestureEvent dge) { Point p = ((MouseEvent) dge.getTriggerEvent()).getPoint(); PlayPenComponent c = contentPane.getComponentAt(p); if ( c instanceof TablePane ) { TablePane tp = (TablePane) c; int colIndex = TablePane.COLUMN_INDEX_NONE; Point dragOrigin = tp.getPlayPen().unzoomPoint(new Point(dge.getDragOrigin())); dragOrigin.x -= tp.getX(); dragOrigin.y -= tp.getY(); // ignore drag events that aren't from the left mouse button if (dge.getTriggerEvent() instanceof MouseEvent && (dge.getTriggerEvent().getModifiers() & InputEvent.BUTTON1_MASK) == 0) return; // ignore drag events if we're in the middle of a createRelationship if (ArchitectFrame.getMainInstance().createRelationshipIsActive()) { logger.debug("CreateRelationship() is active, short circuiting DnD."); return; } try { colIndex = tp.pointToColumnIndex(dragOrigin); } catch (ArchitectException e) { logger.error("Got exception while translating drag point", e); } logger.debug("Recognized drag gesture on "+tp.getName()+"! origin="+dragOrigin +"; col="+colIndex); try { logger.debug("DGL: colIndex="+colIndex+",columnsSize="+tp.getModel().getColumns().size()); if (colIndex == TablePane.COLUMN_INDEX_TITLE) { // we don't use this because it often misses drags // that start near the edge of the titlebar logger.debug("Discarding drag on titlebar (handled by mousePressed())"); draggingTablePanes = true; } else if (colIndex >= 0 && colIndex < tp.getModel().getColumns().size()) { // export column as DnD event if (logger.isDebugEnabled()) { logger.debug("Exporting column "+colIndex+" with DnD"); } tp.draggingColumn = tp.getModel().getColumn(colIndex); DBTree tree = ArchitectFrame.getMainInstance().dbTree; int[] path = tree.getDnDPathToNode(tp.draggingColumn); if (logger.isDebugEnabled()) { StringBuffer array = new StringBuffer(); for (int i = 0; i < path.length; i++) { array.append(path[i]); array.append(","); } logger.debug("Path to dragged node: "+array); } // export list of DnD-type tree paths ArrayList paths = new ArrayList(1); paths.add(path); logger.info("DBTree: exporting 1-item list of DnD-type tree path"); dge.getDragSource().startDrag (dge, null, //DragSource.DefaultCopyNoDrop, new DnDTreePathTransferable(paths), tp); } } catch (ArchitectException ex) { logger.error("Couldn't drag column", ex); JOptionPane.showMessageDialog(tp.getPlayPen(), "Can't drag column: "+ex.getMessage()); } } else { return; } }
|
public void dragGestureRecognized(DragGestureEvent dge) { Point p = ((MouseEvent) dge.getTriggerEvent()).getPoint(); PlayPenComponent c = contentPane.getComponentAt(p); if ( c instanceof TablePane ) { TablePane tp = (TablePane) c; int colIndex = TablePane.COLUMN_INDEX_NONE; Point dragOrigin = tp.getPlayPen().unzoomPoint(new Point(dge.getDragOrigin())); dragOrigin.x -= tp.getX(); dragOrigin.y -= tp.getY(); // ignore drag events that aren't from the left mouse button if (dge.getTriggerEvent() instanceof MouseEvent && (dge.getTriggerEvent().getModifiers() & InputEvent.BUTTON1_MASK) == 0) return; // ignore drag events if we're in the middle of a createRelationship if (ArchitectFrame.getMainInstance().createRelationshipIsActive()) { logger.debug("CreateRelationship() is active, short circuiting DnD."); return; } try { colIndex = tp.pointToColumnIndex(dragOrigin); } catch (ArchitectException e) { logger.error("Got exception while translating drag point", e); } logger.debug("Recognized drag gesture on "+tp.getName()+"! origin="+dragOrigin +"; col="+colIndex); try { logger.debug("DGL: colIndex="+colIndex+",columnsSize="+tp.getModel().getColumns().size()); if (colIndex == TablePane.COLUMN_INDEX_TITLE) { // we don't use this because it often misses drags // that start near the edge of the titlebar logger.debug("Discarding drag on titlebar (handled by mousePressed())"); draggingTablePanes = true; } else if (colIndex >= 0 && colIndex < tp.getModel().getColumns().size()) { // export column as DnD event if (logger.isDebugEnabled()) { logger.debug("Exporting column "+colIndex+" with DnD"); } tp.draggingColumn = tp.getModel().getColumn(colIndex); DBTree tree = ArchitectFrame.getMainInstance().dbTree; int[] path = tree.getDnDPathToNode(tp.draggingColumn); if (logger.isDebugEnabled()) { StringBuffer array = new StringBuffer(); for (int i = 0; i < path.length; i++) { array.append(path[i]); array.append(","); } logger.debug("Path to dragged node: "+array); } // export list of DnD-type tree paths ArrayList paths = new ArrayList(1); paths.add(path); logger.info("DBTree: exporting 1-item list of DnD-type tree path"); dge.getDragSource().startDrag (dge, null, //DragSource.DefaultCopyNoDrop, new DnDTreePathTransferable(paths), tp); } } catch (ArchitectException ex) { logger.error("Couldn't drag column", ex); JOptionPane.showMessageDialog(tp.getPlayPen(), "Can't drag column: "+ex.getMessage()); } } else { return; } }
| 1,111,840
|
public void waitForProcessCompletion() { try { iss.join(); ess.join(); } catch (InterruptedException ex) { System.out.println("Interrupted while waiting for engine"); } output.append("Execution halted"); }
|
public void waitForProcessCompletion() { try { iss.join(); ess.join(); } catch (InterruptedException ex) { logger.error("Interrupted while waiting for engine", ex); } output.append("Execution halted"); }
| 1,111,842
|
public Vector findTags() { tags = new Vector(); untagged = new Vector(); taggedSoFar = 0; //potentialTagsHash stores the PotentialTag objects keyed on the corresponding sequences Hashtable potentialTagByVarSeq = new Hashtable(); PotentialTagComparator ptcomp = new PotentialTagComparator(); VariantSequence currentVarSeq; //create SequenceComparison objects for each potential Tag, and //add any comparisons which have an r-squared greater than the minimum. for(int i=0;i<snps.size();i++) { currentVarSeq = (VariantSequence)snps.get(i); if(!(forceExclude.contains(currentVarSeq) ) ){ PotentialTag tempPT = new PotentialTag(currentVarSeq); for(int j=0;j<snps.size();j++) { if( maxComparisonDistance == 0 || Math.abs(((SNP)currentVarSeq).getLocation() - ((SNP)snps.get(j)).getLocation()) <= maxComparisonDistance) { if( getPairwiseCompRsq(currentVarSeq,(VariantSequence) snps.get(j)) >= minRSquared) { tempPT.addTagged((VariantSequence) snps.get(j)); } } } potentialTagByVarSeq.put(currentVarSeq,tempPT); } } Vector sitesToCapture = (Vector) snps.clone(); debugPrint("snps to tag: " + sitesToCapture.size()); int countTagged = 0; //add Tags for the ones which are forced in. Vector includedPotentialTags = new Vector(); //construct a list of PotentialTag objects for forced in sequences for (int i = 0; i < forceInclude.size(); i++) { VariantSequence variantSequence = (VariantSequence) forceInclude.elementAt(i); if(variantSequence != null && potentialTagByVarSeq.containsKey(variantSequence)) { includedPotentialTags.add((PotentialTag) potentialTagByVarSeq.get(variantSequence)); } } Vector toRemove = new Vector(); //add each forced in sequence to the list of tags for(int i=0;i<includedPotentialTags.size();i++) { PotentialTag curPT = (PotentialTag) includedPotentialTags.get(i); HashSet newlyTagged = addTag(curPT,potentialTagByVarSeq); countTagged += newlyTagged.size(); sitesToCapture.removeAll(newlyTagged); sitesToCapture.remove(curPT.sequence); if(Options.getTaggerMinDistance() !=0){ long tagLocation = ((SNP)curPT.sequence).getLocation(); Iterator itr = potentialTagByVarSeq.keySet().iterator(); while(itr.hasNext()) { PotentialTag pt = (PotentialTag) potentialTagByVarSeq.get(itr.next()); if(Math.abs(((SNP)pt.sequence).getLocation() - tagLocation) <= Options.getTaggerMinDistance() ){ toRemove.add(pt.sequence); } } } } if(Options.getTaggerMinDistance() !=0){ for(int i=0;i<toRemove.size();i++){ potentialTagByVarSeq.remove(toRemove.get(i)); } } if (findTags){ //loop until all snps are tagged while(sitesToCapture.size() > 0) { Vector potentialTags = new Vector(potentialTagByVarSeq.values()); if(potentialTags.size() == 0) { //we still have sites left to capture, but we have no more available tags. //this should only happen if the sites remaining in sitesToCapture were specifically //excluded from being tags. Since we can't add any more tags, break out of the loop. break; } //sorts the array of potential tags according to the number of untagged sites they can tag. //the last element is the one which tags the most untagged sites, so we choose that as our next tag. Collections.sort(potentialTags,ptcomp); PotentialTag currentBestTag = (PotentialTag) potentialTags.lastElement(); //look at the last one and ones before it that tag the same number of things //from that set choose based on design score if (designScores != null){ double currentBestScore = 0; if (designScores.containsKey(currentBestTag.sequence.getName())){ currentBestScore = ((Double)designScores.get(currentBestTag.sequence.getName())).doubleValue(); } for (int i = potentialTags.size()-1; i>0; i--){ if (currentBestTag.taggedCount() == ((PotentialTag)potentialTags.get(i)).taggedCount()){ double previousScore = 0; if (designScores.containsKey(((PotentialTag)potentialTags.get(i)))){ previousScore = ((Double)designScores.get(((PotentialTag)potentialTags.get(i)))).doubleValue(); } if (previousScore > currentBestScore){ currentBestTag = (PotentialTag)potentialTags.get(i); currentBestScore = previousScore; } }else{ break; } } } HashSet newlyTagged = addTag(currentBestTag,potentialTagByVarSeq); countTagged += newlyTagged.size(); sitesToCapture.removeAll(newlyTagged); sitesToCapture.remove(currentBestTag.sequence); if(Options.getTaggerMinDistance() !=0){ Vector tooClose = new Vector(); long tagLocation = ((SNP)currentBestTag.sequence).getLocation(); Iterator itr = potentialTagByVarSeq.keySet().iterator(); while(itr.hasNext()) { PotentialTag pt = (PotentialTag) potentialTagByVarSeq.get(itr.next()); if(Math.abs(((SNP)pt.sequence).getLocation() - tagLocation) <= Options.getTaggerMinDistance() ){ potentialTags.remove(pt); tooClose.add(pt.sequence); } } for(int i =0;i<tooClose.size();i++){ potentialTagByVarSeq.remove(tooClose.get(i)); } } } } taggedSoFar = countTagged; if(sitesToCapture.size() > 0) { //any sites left in sitesToCapture could not be tagged, so we add them all to the untagged Vector untagged.addAll(sitesToCapture); } debugPrint("tagged " + countTagged + " SNPS using " + tags.size() +" tags" ); debugPrint("# of SNPs that could not be tagged: " + untagged.size()); if (aggression != PAIRWISE_ONLY){ //peelback starting with the worst tag (i.e. the one that tags the fewest other snps. Vector tags2BPeeled = (Vector)tags.clone(); Collections.reverse(tags2BPeeled); peelBack(tags2BPeeled); } //we've done the best we can. now we check to see if there's a limit to the //num of tags we're allowed to choose. if (maxNumTags > 0){ //if so we need to chuck out the extras. figure out the utility of each tagSNP //i.e. how many SNPs for which they and their combos are the only tags while (getTagSNPs().size() > maxNumTags){ Vector tagSNPs = getTagSNPs(); potentialTagByVarSeq = new Hashtable(); Hashtable tagSeqByPotentialTag = new Hashtable(); //account for stuff tagged by snps themselves for (int i = 0; i < tagSNPs.size(); i++){ TagSequence ts = (TagSequence) tagSNPs.get(i); PotentialTag pt = new PotentialTag(ts.getSequence()); pt.addTagged(ts.getTagged()); potentialTagByVarSeq.put(ts.getSequence(),pt); tagSeqByPotentialTag.put(pt,ts); } //go through all pt's and add their utilities as members of combos Vector tagHaps = getTagHaplotypes(); for (int i = 0; i < tagHaps.size(); i++){ TagSequence ts = (TagSequence) tagHaps.get(i); Block b = (Block) ts.getSequence(); for (int j = 0; j < b.getSnps().size(); j++){ ((PotentialTag)potentialTagByVarSeq.get(b.getSNP(j))).addTagged(ts.getTagged()); } } //now perform the steps of sorting and peeling Vector potTagVec = new Vector(potentialTagByVarSeq.values()); Collections.sort(potTagVec,ptcomp); int count = 0; PotentialTag dumpedPT = (PotentialTag)potTagVec.elementAt(count); while (forceInclude.contains(dumpedPT.sequence)){ count++; dumpedPT = (PotentialTag)potTagVec.elementAt(count); } TagSequence dumpedTS = (TagSequence) tagSeqByPotentialTag.get(dumpedPT); Vector taggedByCurTag = dumpedTS.getTagged(); for (int j = 0; j < taggedByCurTag.size(); j++){ //note for everything tagged by this guy that they're no longer tagged by him VariantSequence vs = (VariantSequence)taggedByCurTag.get(j); vs.removeTag(dumpedTS); if (vs.getTags().size() == 0){ taggedSoFar--; } } tagHaps = getTagHaplotypes(); for (int i = 0; i < tagHaps.size(); i++){ TagSequence ts = (TagSequence) tagHaps.get(i); Block b = (Block) ts.getSequence(); if (b.getSnps().contains(dumpedTS.getSequence())){ //this hap tag is now defunct because it was comprised in part by dumpedTS Vector taggedByHap = ts.getTagged(); for (int j = 0; j < taggedByHap.size(); j++){ VariantSequence vs = (VariantSequence)taggedByCurTag.get(j); vs.removeTag(dumpedTS); if (vs.getTags().size() == 0){ taggedSoFar--; } } tags.remove(ts); } } tags.remove(dumpedTS); } } int count = 0; double numOver8 = 0; meanRSq = 0; Iterator itr = snps.iterator(); while (itr.hasNext()){ SNP s = (SNP) itr.next(); TagSequence ts = s.getBestTag(); if (ts != null){ double d = getPairwiseComp(s, ts.getSequence()).getRsq(); meanRSq += d; count++; if (d >= 0.8){ numOver8++; } } } //apparently some people think untagged SNPS should be averaged in as zeroes...leaving commented out for now. //count += untagged.size(); meanRSq /= count; percentOver8 = (int) Math.rint((100*numOver8) / count); return new Vector(tags); }
|
public Vector findTags() { tags = new Vector(); untagged = new Vector(); taggedSoFar = 0; //potentialTagsHash stores the PotentialTag objects keyed on the corresponding sequences Hashtable potentialTagByVarSeq = new Hashtable(); PotentialTagComparator ptcomp = new PotentialTagComparator(); VariantSequence currentVarSeq; //create SequenceComparison objects for each potential Tag, and //add any comparisons which have an r-squared greater than the minimum. for(int i=0;i<snps.size();i++) { currentVarSeq = (VariantSequence)snps.get(i); if(!(forceExclude.contains(currentVarSeq) ) ){ PotentialTag tempPT = new PotentialTag(currentVarSeq); for(int j=0;j<snps.size();j++) { if( maxComparisonDistance == 0 || Math.abs(((SNP)currentVarSeq).getLocation() - ((SNP)snps.get(j)).getLocation()) <= maxComparisonDistance) { if( getPairwiseCompRsq(currentVarSeq,(VariantSequence) snps.get(j)) >= minRSquared) { tempPT.addTagged((VariantSequence) snps.get(j)); } } } potentialTagByVarSeq.put(currentVarSeq,tempPT); } } Vector sitesToCapture = (Vector) snps.clone(); debugPrint("snps to tag: " + sitesToCapture.size()); int countTagged = 0; //add Tags for the ones which are forced in. Vector includedPotentialTags = new Vector(); //construct a list of PotentialTag objects for forced in sequences for (int i = 0; i < forceInclude.size(); i++) { VariantSequence variantSequence = (VariantSequence) forceInclude.elementAt(i); if(variantSequence != null && potentialTagByVarSeq.containsKey(variantSequence)) { includedPotentialTags.add((PotentialTag) potentialTagByVarSeq.get(variantSequence)); } } Vector toRemove = new Vector(); //add each forced in sequence to the list of tags for(int i=0;i<includedPotentialTags.size();i++) { PotentialTag curPT = (PotentialTag) includedPotentialTags.get(i); HashSet newlyTagged = addTag(curPT,potentialTagByVarSeq); countTagged += newlyTagged.size(); sitesToCapture.removeAll(newlyTagged); sitesToCapture.remove(curPT.sequence); if(Options.getTaggerMinDistance() !=0){ long tagLocation = ((SNP)curPT.sequence).getLocation(); Iterator itr = potentialTagByVarSeq.keySet().iterator(); while(itr.hasNext()) { PotentialTag pt = (PotentialTag) potentialTagByVarSeq.get(itr.next()); if(Math.abs(((SNP)pt.sequence).getLocation() - tagLocation) <= Options.getTaggerMinDistance() ){ toRemove.add(pt.sequence); } } } } if(Options.getTaggerMinDistance() !=0){ for(int i=0;i<toRemove.size();i++){ potentialTagByVarSeq.remove(toRemove.get(i)); } } if (findTags){ //loop until all snps are tagged while(sitesToCapture.size() > 0) { Vector potentialTags = new Vector(potentialTagByVarSeq.values()); if(potentialTags.size() == 0) { //we still have sites left to capture, but we have no more available tags. //this should only happen if the sites remaining in sitesToCapture were specifically //excluded from being tags. Since we can't add any more tags, break out of the loop. break; } //sorts the array of potential tags according to the number of untagged sites they can tag. //the last element is the one which tags the most untagged sites, so we choose that as our next tag. Collections.sort(potentialTags,ptcomp); PotentialTag currentBestTag = (PotentialTag) potentialTags.lastElement(); //look at the last one and ones before it that tag the same number of things //from that set choose based on design score if (designScores != null){ double currentBestScore = 0; if (designScores.containsKey(currentBestTag.sequence.getName())){ currentBestScore = ((Double)designScores.get(currentBestTag.sequence.getName())).doubleValue(); } for (int i = potentialTags.size()-1; i>0; i--){ if (currentBestTag.taggedCount() == ((PotentialTag)potentialTags.get(i)).taggedCount()){ double previousScore = 0; if (designScores.containsKey(((PotentialTag)potentialTags.get(i)))){ previousScore = ((Double)designScores.get(((PotentialTag)potentialTags.get(i)))).doubleValue(); } if (previousScore > currentBestScore){ currentBestTag = (PotentialTag)potentialTags.get(i); currentBestScore = previousScore; } }else{ break; } } } HashSet newlyTagged = addTag(currentBestTag,potentialTagByVarSeq); countTagged += newlyTagged.size(); sitesToCapture.removeAll(newlyTagged); sitesToCapture.remove(currentBestTag.sequence); if(Options.getTaggerMinDistance() !=0){ Vector tooClose = new Vector(); long tagLocation = ((SNP)currentBestTag.sequence).getLocation(); Iterator itr = potentialTagByVarSeq.keySet().iterator(); while(itr.hasNext()) { PotentialTag pt = (PotentialTag) potentialTagByVarSeq.get(itr.next()); if(Math.abs(((SNP)pt.sequence).getLocation() - tagLocation) <= Options.getTaggerMinDistance() ){ potentialTags.remove(pt); tooClose.add(pt.sequence); } } for(int i =0;i<tooClose.size();i++){ potentialTagByVarSeq.remove(tooClose.get(i)); } } } } taggedSoFar = countTagged; if(sitesToCapture.size() > 0) { //any sites left in sitesToCapture could not be tagged, so we add them all to the untagged Vector untagged.addAll(sitesToCapture); } debugPrint("tagged " + countTagged + " SNPS using " + tags.size() +" tags" ); debugPrint("# of SNPs that could not be tagged: " + untagged.size()); if (aggression != PAIRWISE_ONLY){ //peelback starting with the worst tag (i.e. the one that tags the fewest other snps. Vector tags2BPeeled = (Vector)tags.clone(); Collections.reverse(tags2BPeeled); peelBack(tags2BPeeled); } //we've done the best we can. now we check to see if there's a limit to the //num of tags we're allowed to choose. if (maxNumTags > 0){ //if so we need to chuck out the extras. figure out the utility of each tagSNP //i.e. how many SNPs for which they and their combos are the only tags while (getTagSNPs().size() > maxNumTags){ Vector tagSNPs = getTagSNPs(); potentialTagByVarSeq = new Hashtable(); Hashtable tagSeqByPotentialTag = new Hashtable(); //account for stuff tagged by snps themselves for (int i = 0; i < tagSNPs.size(); i++){ TagSequence ts = (TagSequence) tagSNPs.get(i); PotentialTag pt = new PotentialTag(ts.getSequence()); pt.addTagged(ts.getTagged()); potentialTagByVarSeq.put(ts.getSequence(),pt); tagSeqByPotentialTag.put(pt,ts); } //go through all pt's and add their utilities as members of combos Vector tagHaps = getTagHaplotypes(); for (int i = 0; i < tagHaps.size(); i++){ TagSequence ts = (TagSequence) tagHaps.get(i); Block b = (Block) ts.getSequence(); for (int j = 0; j < b.getSnps().size(); j++){ ((PotentialTag)potentialTagByVarSeq.get(b.getSNP(j))).addTagged(ts.getTagged()); } } //now perform the steps of sorting and peeling Vector potTagVec = new Vector(potentialTagByVarSeq.values()); Collections.sort(potTagVec,ptcomp); int count = 0; PotentialTag dumpedPT = (PotentialTag)potTagVec.elementAt(count); while (forceInclude.contains(dumpedPT.sequence)){ count++; dumpedPT = (PotentialTag)potTagVec.elementAt(count); } TagSequence dumpedTS = (TagSequence) tagSeqByPotentialTag.get(dumpedPT); Vector taggedByCurTag = dumpedTS.getTagged(); for (int j = 0; j < taggedByCurTag.size(); j++){ //note for everything tagged by this guy that they're no longer tagged by him VariantSequence vs = (VariantSequence)taggedByCurTag.get(j); vs.removeTag(dumpedTS); if (vs.getTags().size() == 0){ taggedSoFar--; } } tagHaps = getTagHaplotypes(); for (int i = 0; i < tagHaps.size(); i++){ TagSequence ts = (TagSequence) tagHaps.get(i); Block b = (Block) ts.getSequence(); if (b.getSnps().contains(dumpedTS.getSequence())){ //this hap tag is now defunct because it was comprised in part by dumpedTS Vector taggedByHap = ts.getTagged(); for (int j = 0; j < taggedByHap.size(); j++){ VariantSequence vs = (VariantSequence)taggedByCurTag.get(j); vs.removeTag(dumpedTS); if (vs.getTags().size() == 0){ taggedSoFar--; } } tags.remove(ts); } } tags.remove(dumpedTS); } } int count = 0; double numOver8 = 0; meanRSq = 0; Iterator itr = snps.iterator(); while (itr.hasNext()){ SNP s = (SNP) itr.next(); TagSequence ts = s.getBestTag(); if (ts != null){ double d = getPairwiseComp(s, ts.getSequence()).getRsq(); meanRSq += d; count++; if (d >= 0.8){ numOver8++; } } } //apparently some people think untagged SNPS should be averaged in as zeroes...leaving commented out for now. //count += untagged.size(); meanRSq /= count; percentOver8 = (int) Math.rint((100*numOver8) / count); return new Vector(tags); }
| 1,111,843
|
public ExportDialog(HaploView h){ super(h, "Export Data"); hv = h; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); JPanel tabPanel = new JPanel(); int currTab = hv.tabs.getSelectedIndex(); tabPanel.setBorder(new TitledBorder("Tab to Export")); tabPanel.setLayout(new BoxLayout(tabPanel,BoxLayout.Y_AXIS)); tabPanel.setAlignmentX(CENTER_ALIGNMENT); ButtonGroup g1 = new ButtonGroup(); dpButton = new JRadioButton("LD"); dpButton.setActionCommand("ldtab"); dpButton.addActionListener(this); g1.add(dpButton); tabPanel.add(dpButton); if (currTab == VIEW_D_NUM){ dpButton.setSelected(true); } hapButton = new JRadioButton("Haplotypes"); hapButton.setActionCommand("haptab"); hapButton.addActionListener(this); g1.add(hapButton); tabPanel.add(hapButton); if (currTab == VIEW_HAP_NUM){ hapButton.setSelected(true); } if (hv.checkPanel != null){ checkButton = new JRadioButton("Data Checks"); checkButton.setActionCommand("checktab"); checkButton.addActionListener(this); g1.add(checkButton); tabPanel.add(checkButton); if (currTab == VIEW_CHECK_NUM){ checkButton.setSelected(true); } } if (Options.getAssocTest() != ASSOC_NONE){ singleAssocButton = new JRadioButton("Single Marker Association Tests"); singleAssocButton.setActionCommand("singleassoctab"); singleAssocButton.addActionListener(this); g1.add(singleAssocButton); tabPanel.add(singleAssocButton); hapAssocButton = new JRadioButton("Haplotype Association Tests"); hapAssocButton.setActionCommand("hapassoctab"); hapAssocButton.addActionListener(this); g1.add(hapAssocButton); tabPanel.add(hapAssocButton); permAssocButton = new JRadioButton("Permutation Results"); permAssocButton.setActionCommand("permtab"); permAssocButton.addActionListener(this); g1.add(permAssocButton); tabPanel.add(permAssocButton); if (currTab == VIEW_ASSOC_NUM){ Component c = ((JTabbedPane)hv.tabs.getComponent(currTab)).getSelectedComponent(); if(c == hv.tdtPanel){ singleAssocButton.setSelected(true); }else if (c == hv.hapAssocPanel){ hapAssocButton.setSelected(true); }else if (c == hv.permutationPanel){ permAssocButton.setSelected(true); } } } contents.add(tabPanel); JPanel formatPanel = new JPanel(); formatPanel.setBorder(new TitledBorder("Output Format")); ButtonGroup g2 = new ButtonGroup(); txtButton = new JRadioButton("Text"); txtButton.addActionListener(this); formatPanel.add(txtButton); g2.add(txtButton); txtButton.setSelected(true); pngButton = new JRadioButton("PNG Image"); pngButton.addActionListener(this); formatPanel.add(pngButton); g2.add(pngButton); compressCheckBox = new JCheckBox("Compress image (smaller file)"); formatPanel.add(compressCheckBox); compressCheckBox.setEnabled(false); if (currTab == VIEW_CHECK_NUM || currTab == VIEW_ASSOC_NUM){ pngButton.setEnabled(false); } contents.add(formatPanel); JPanel rangePanel = new JPanel(); rangePanel.setBorder(new TitledBorder("Range")); ButtonGroup g3 = new ButtonGroup(); allButton = new JRadioButton("All"); allButton.addActionListener(this); rangePanel.add(allButton); g3.add(allButton); allButton.setSelected(true); someButton = new JRadioButton("Marker "); someButton.addActionListener(this); rangePanel.add(someButton); g3.add(someButton); lowRange = new NumberTextField("",5,false); rangePanel.add(lowRange); rangePanel.add(new JLabel(" to ")); upperRange = new NumberTextField("",5,false); rangePanel.add(upperRange); upperRange.setEnabled(false); lowRange.setEnabled(false); adjButton = new JRadioButton("Adjacent markers only"); adjButton.addActionListener(this); rangePanel.add(adjButton); g3.add(adjButton); if (currTab != VIEW_D_NUM){ someButton.setEnabled(false); adjButton.setEnabled(false); } contents.add(rangePanel); JPanel choicePanel = new JPanel(); JButton okButton = new JButton("OK"); okButton.addActionListener(this); choicePanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); choicePanel.add(cancelButton); contents.add(choicePanel); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); }
|
public ExportDialog(HaploView h){ super(h, "Export Data"); hv = h; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); JPanel tabPanel = new JPanel(); int currTab = hv.tabs.getSelectedIndex(); tabPanel.setBorder(new TitledBorder("Tab to Export")); tabPanel.setLayout(new BoxLayout(tabPanel,BoxLayout.Y_AXIS)); tabPanel.setAlignmentX(CENTER_ALIGNMENT); ButtonGroup g1 = new ButtonGroup(); dpButton = new JRadioButton("LD"); dpButton.setActionCommand("ldtab"); dpButton.addActionListener(this); g1.add(dpButton); tabPanel.add(dpButton); if (currTab == VIEW_D_NUM){ dpButton.setSelected(true); } hapButton = new JRadioButton("Haplotypes"); hapButton.setActionCommand("haptab"); hapButton.addActionListener(this); g1.add(hapButton); tabPanel.add(hapButton); if (currTab == VIEW_HAP_NUM){ hapButton.setSelected(true); } if (hv.checkPanel != null){ checkButton = new JRadioButton("Data Checks"); checkButton.setActionCommand("checktab"); checkButton.addActionListener(this); g1.add(checkButton); tabPanel.add(checkButton); if (currTab == VIEW_CHECK_NUM){ checkButton.setSelected(true); } } if (Options.getAssocTest() != ASSOC_NONE){ singleAssocButton = new JRadioButton("Single Marker Association Tests"); singleAssocButton.setActionCommand("singleassoctab"); singleAssocButton.addActionListener(this); g1.add(singleAssocButton); tabPanel.add(singleAssocButton); hapAssocButton = new JRadioButton("Haplotype Association Tests"); hapAssocButton.setActionCommand("hapassoctab"); hapAssocButton.addActionListener(this); g1.add(hapAssocButton); tabPanel.add(hapAssocButton); permAssocButton = new JRadioButton("Permutation Results"); permAssocButton.setActionCommand("permtab"); permAssocButton.addActionListener(this); g1.add(permAssocButton); tabPanel.add(permAssocButton); if (currTab == VIEW_ASSOC_NUM){ Component c = ((JTabbedPane)((HaploviewTab)hv.tabs.getComponent(currTab)).getComponent()).getSelectedComponent(); if(c == hv.tdtPanel){ singleAssocButton.setSelected(true); }else if (c == hv.hapAssocPanel){ hapAssocButton.setSelected(true); }else if (c == hv.permutationPanel){ permAssocButton.setSelected(true); } } } contents.add(tabPanel); JPanel formatPanel = new JPanel(); formatPanel.setBorder(new TitledBorder("Output Format")); ButtonGroup g2 = new ButtonGroup(); txtButton = new JRadioButton("Text"); txtButton.addActionListener(this); formatPanel.add(txtButton); g2.add(txtButton); txtButton.setSelected(true); pngButton = new JRadioButton("PNG Image"); pngButton.addActionListener(this); formatPanel.add(pngButton); g2.add(pngButton); compressCheckBox = new JCheckBox("Compress image (smaller file)"); formatPanel.add(compressCheckBox); compressCheckBox.setEnabled(false); if (currTab == VIEW_CHECK_NUM || currTab == VIEW_ASSOC_NUM){ pngButton.setEnabled(false); } contents.add(formatPanel); JPanel rangePanel = new JPanel(); rangePanel.setBorder(new TitledBorder("Range")); ButtonGroup g3 = new ButtonGroup(); allButton = new JRadioButton("All"); allButton.addActionListener(this); rangePanel.add(allButton); g3.add(allButton); allButton.setSelected(true); someButton = new JRadioButton("Marker "); someButton.addActionListener(this); rangePanel.add(someButton); g3.add(someButton); lowRange = new NumberTextField("",5,false); rangePanel.add(lowRange); rangePanel.add(new JLabel(" to ")); upperRange = new NumberTextField("",5,false); rangePanel.add(upperRange); upperRange.setEnabled(false); lowRange.setEnabled(false); adjButton = new JRadioButton("Adjacent markers only"); adjButton.addActionListener(this); rangePanel.add(adjButton); g3.add(adjButton); if (currTab != VIEW_D_NUM){ someButton.setEnabled(false); adjButton.setEnabled(false); } contents.add(rangePanel); JPanel choicePanel = new JPanel(); JButton okButton = new JButton("OK"); okButton.addActionListener(this); choicePanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); choicePanel.add(cancelButton); contents.add(choicePanel); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); }
| 1,111,844
|
public LocusCorrelation getCorrelation(VariantSequence v1, VariantSequence v2) { if(v1 == v2) { return new LocusCorrelation(null,1); } if (v1 instanceof SNP && v2 instanceof SNP){ //we are comparing two snps int v1Index = ((Integer)indicesByVarSeq.get(v1)).intValue(); int v2Index = ((Integer)indicesByVarSeq.get(v2)).intValue(); double rsq; if (v1Index > v2Index){ rsq =((PairwiseLinkage)dpTable.getLDStats(v2Index, v1Index)).getRSquared(); }else{ rsq = ((PairwiseLinkage)dpTable.getLDStats(v1Index, v2Index)).getRSquared(); } LocusCorrelation lc = new LocusCorrelation(null,rsq); return lc; }else{ //we are comparing a snp vs. a block SNP theSNP; Block theBlock; if (v1 instanceof SNP){ theSNP = (SNP) v1; theBlock = (Block) v2; }else{ theSNP = (SNP) v2; theBlock = (Block) v1; } Comparison c = new Comparison(theSNP, theBlock); if (lcByComparison.containsKey(c)){ return (LocusCorrelation) lcByComparison.get(c); } Allele curBestAllele = null; double curBestRsq = 0; int[][] genos = new int[phasedCache.length][theBlock.getMarkerCount()+1]; for (int i = 0; i < phasedCache.length; i++){ //create a temporary set of mini hap genotypes with theSNP as the first marker and theBlock's markers as the rest genos[i][0] = phasedCache[i].getGeno()[((Integer)phasedCacheIndicesByVarSeq.get(theSNP)).intValue()]; for (int j = 1; j < theBlock.getMarkerCount()+1; j++){ genos[i][j] = phasedCache[i].getGeno()[((Integer)phasedCacheIndicesByVarSeq.get(theBlock.getSNP(j-1))).intValue()]; } } for (int i = 0; i < genos.length; i++){ double aa=0,ab=0,bb=0,ba=0; StringBuffer sb = new StringBuffer(); for (int j = 1; j < genos[i].length; j++){ sb.append(genos[i][j]); } String curHapStr = sb.toString(); for (int j = 0; j < genos.length; j++){ sb = new StringBuffer(); for (int k = 1; k < genos[j].length; k++){ sb.append(genos[j][k]); } String testHapStr = sb.toString(); if (genos[j][0] == genos[0][0]){ if (!curHapStr.equals(testHapStr)){ ab += phasedCache[j].getPercentage(); }else{ aa += phasedCache[j].getPercentage(); } }else{ if (!curHapStr.equals(testHapStr)){ bb += phasedCache[j].getPercentage(); }else{ ba += phasedCache[j].getPercentage(); } } } //p is snp's freq, q is hap's freq double p = aa+ab; double q = ba+aa; //round to 5 decimal places. double rsq = ((double)Math.round(100000*Math.pow((aa*bb - ab*ba),2)/(p*(1-p)*q*(1-q))))/100000; if (rsq > curBestRsq){ curBestAllele = new Allele(theBlock,curHapStr); curBestRsq = rsq; } } LocusCorrelation lc = new LocusCorrelation(curBestAllele, curBestRsq); lcByComparison.put(new Comparison(theSNP, theBlock),lc); return (lc); } }
|
public LocusCorrelation getCorrelation(VariantSequence v1, VariantSequence v2) { if(v1 == v2) { return new LocusCorrelation(null,1); } if (v1 instanceof SNP && v2 instanceof SNP){ //we are comparing two snps int v1Index = ((Integer)indicesByVarSeq.get(v1)).intValue(); int v2Index = ((Integer)indicesByVarSeq.get(v2)).intValue(); double rsq; if (v1Index > v2Index){ rsq =((PairwiseLinkage)dpTable.getLDStats(v2Index, v1Index)).getRSquared(); }else{ rsq = ((PairwiseLinkage)dpTable.getLDStats(v1Index, v2Index)).getRSquared(); } LocusCorrelation lc = new LocusCorrelation(null,rsq); return lc; }else{ //we are comparing a snp vs. a block SNP theSNP; Block theBlock; if (v1 instanceof SNP){ theSNP = (SNP) v1; theBlock = (Block) v2; }else{ theSNP = (SNP) v2; theBlock = (Block) v1; } Comparison c = new Comparison(theSNP, theBlock); if (lcByComparison.containsKey(c)){ return (LocusCorrelation) lcByComparison.get(c); } Allele curBestAllele = null; double curBestRsq = 0; int[][] genos = new int[phasedCache.length][theBlock.getMarkerCount()+1]; for (int i = 0; i < phasedCache.length; i++){ //create a temporary set of mini hap genotypes with theSNP as the first marker and theBlock's markers as the rest genos[i][0] = phasedCache[i].getGeno()[((Integer)phasedCacheIndicesByVarSeq.get(theSNP)).intValue()]; for (int j = 1; j < theBlock.getMarkerCount()+1; j++){ genos[i][j] = phasedCache[i].getGeno()[((Integer)phasedCacheIndicesByVarSeq.get(theBlock.getSNP(j-1))).intValue()]; } } for (int i = 0; i < genos.length; i++){ double aa=0,ab=0,bb=0,ba=0; StringBuffer sb = new StringBuffer(); for (int j = 1; j < genos[i].length; j++){ sb.append(genos[i][j]); } String curHapStr = sb.toString(); for (int j = 0; j < genos.length; j++){ sb = new StringBuffer(); for (int k = 1; k < genos[j].length; k++){ sb.append(genos[j][k]); } String testHapStr = sb.toString(); if (genos[j][0] == genos[0][0]){ if (!curHapStr.equals(testHapStr)){ ab += phasedCache[j].getPercentage(); }else{ aa += phasedCache[j].getPercentage(); } }else{ if (!curHapStr.equals(testHapStr)){ bb += phasedCache[j].getPercentage(); }else{ ba += phasedCache[j].getPercentage(); } } } //p is snp's freq, q is hap's freq double p = aa+ab; double q = ba+aa; //round to 5 decimal places. double rsq = ((double)Math.round(100000*Math.pow((aa*bb - ab*ba),2)/(p*(1-p)*q*(1-q))))/100000; if (rsq > curBestRsq){ curBestAllele = new Allele(theBlock,curHapStr); curBestRsq = rsq; } } LocusCorrelation lc = new LocusCorrelation(curBestAllele, curBestRsq); lcByComparison.put(new Comparison(theSNP, theBlock),lc); return (lc); } }
| 1,111,845
|
public LocusCorrelation getCorrelation(VariantSequence v1, VariantSequence v2) { if(v1 == v2) { return new LocusCorrelation(null,1); } if (v1 instanceof SNP && v2 instanceof SNP){ //we are comparing two snps int v1Index = ((Integer)indicesByVarSeq.get(v1)).intValue(); int v2Index = ((Integer)indicesByVarSeq.get(v2)).intValue(); double rsq; if (v1Index > v2Index){ rsq =((PairwiseLinkage)dpTable.getLDStats(v2Index, v1Index)).getRSquared(); }else{ rsq = ((PairwiseLinkage)dpTable.getLDStats(v1Index, v2Index)).getRSquared(); } LocusCorrelation lc = new LocusCorrelation(null,rsq); return lc; }else{ //we are comparing a snp vs. a block SNP theSNP; Block theBlock; if (v1 instanceof SNP){ theSNP = (SNP) v1; theBlock = (Block) v2; }else{ theSNP = (SNP) v2; theBlock = (Block) v1; } Comparison c = new Comparison(theSNP, theBlock); if (lcByComparison.containsKey(c)){ return (LocusCorrelation) lcByComparison.get(c); } Allele curBestAllele = null; double curBestRsq = 0; int[][] genos = new int[phasedCache.length][theBlock.getMarkerCount()+1]; for (int i = 0; i < phasedCache.length; i++){ //create a temporary set of mini hap genotypes with theSNP as the first marker and theBlock's markers as the rest genos[i][0] = phasedCache[i].getGeno()[((Integer)phasedCacheIndicesByVarSeq.get(theSNP)).intValue()]; for (int j = 1; j < theBlock.getMarkerCount()+1; j++){ genos[i][j] = phasedCache[i].getGeno()[((Integer)phasedCacheIndicesByVarSeq.get(theBlock.getSNP(j-1))).intValue()]; } } for (int i = 0; i < genos.length; i++){ double aa=0,ab=0,bb=0,ba=0; StringBuffer sb = new StringBuffer(); for (int j = 1; j < genos[i].length; j++){ sb.append(genos[i][j]); } String curHapStr = sb.toString(); for (int j = 0; j < genos.length; j++){ sb = new StringBuffer(); for (int k = 1; k < genos[j].length; k++){ sb.append(genos[j][k]); } String testHapStr = sb.toString(); if (genos[j][0] == genos[0][0]){ if (!curHapStr.equals(testHapStr)){ ab += phasedCache[j].getPercentage(); }else{ aa += phasedCache[j].getPercentage(); } }else{ if (!curHapStr.equals(testHapStr)){ bb += phasedCache[j].getPercentage(); }else{ ba += phasedCache[j].getPercentage(); } } } //p is snp's freq, q is hap's freq double p = aa+ab; double q = ba+aa; //round to 5 decimal places. double rsq = ((double)Math.round(100000*Math.pow((aa*bb - ab*ba),2)/(p*(1-p)*q*(1-q))))/100000; if (rsq > curBestRsq){ curBestAllele = new Allele(theBlock,curHapStr); curBestRsq = rsq; } } LocusCorrelation lc = new LocusCorrelation(curBestAllele, curBestRsq); lcByComparison.put(new Comparison(theSNP, theBlock),lc); return (lc); } }
|
public LocusCorrelation getCorrelation(VariantSequence v1, VariantSequence v2) { if(v1 == v2) { return new LocusCorrelation(null,1); } if (v1 instanceof SNP && v2 instanceof SNP){ //we are comparing two snps int v1Index = ((Integer)indicesByVarSeq.get(v1)).intValue(); int v2Index = ((Integer)indicesByVarSeq.get(v2)).intValue(); double rsq; if (v1Index > v2Index){ rsq =((PairwiseLinkage)dpTable.getLDStats(v2Index, v1Index)).getRSquared(); }else{ rsq = ((PairwiseLinkage)dpTable.getLDStats(v1Index, v2Index)).getRSquared(); } LocusCorrelation lc = new LocusCorrelation(null,rsq); return lc; }else{ //we are comparing a snp vs. a block SNP theSNP; Block theBlock; if (v1 instanceof SNP){ theSNP = (SNP) v1; theBlock = (Block) v2; }else{ theSNP = (SNP) v2; theBlock = (Block) v1; } Comparison c = new Comparison(theSNP, theBlock); if (lcByComparison.containsKey(c)){ return (LocusCorrelation) lcByComparison.get(c); } Allele curBestAllele = null; double curBestRsq = 0; int[][] genos = new int[phasedCache.length][theBlock.getMarkerCount()+1]; for (int i = 0; i < phasedCache.length; i++){ //create a temporary set of mini hap genotypes with theSNP as the first marker and theBlock's markers as the rest genos[i][0] = phasedCache[i].getGeno()[((Integer)phasedCacheIndicesByVarSeq.get(theSNP)).intValue()]; for (int j = 1; j < theBlock.getMarkerCount()+1; j++){ genos[i][j] = phasedCache[i].getGeno()[((Integer)phasedCacheIndicesByVarSeq.get(theBlock.getSNP(j-1))).intValue()]; } } for (int i = 0; i < genos.length; i++){ double aa=0,ab=0,bb=0,ba=0; StringBuffer sb = new StringBuffer(); for (int j = 1; j < genos[i].length; j++){ sb.append(genos[i][j]); } String curHapStr = sb.toString(); for (int j = 0; j < genos.length; j++){ sb = new StringBuffer(); for (int k = 1; k < genos[j].length; k++){ sb.append(genos[j][k]); } String testHapStr = sb.toString(); if (genos[j][0] == genos[0][0]){ if (!curHapStr.equals(testHapStr)){ ab += phasedCache[j].getPercentage(); }else{ aa += phasedCache[j].getPercentage(); } }else{ if (!curHapStr.equals(testHapStr)){ bb += phasedCache[j].getPercentage(); }else{ ba += phasedCache[j].getPercentage(); } } } //p is snp's freq, q is hap's freq double p = aa+ab; double q = ba+aa; //round to 5 decimal places. double rsq = ((double)Math.round(100000*Math.pow((aa*bb - ab*ba),2)/(p*(1-p)*q*(1-q))))/100000; if (rsq > curBestRsq){ curBestAllele = new Allele(theBlock,curHapStr); curBestRsq = rsq; } } LocusCorrelation lc = new LocusCorrelation(curBestAllele, curBestRsq); lcByComparison.put(new Comparison(theSNP, theBlock),lc); return (lc); } }
| 1,111,846
|
public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component cell = super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column); int myRating = ((CheckDataTableSorter)table.getModel()).getRating(row); int myDupStatus = ((CheckDataTableSorter)table.getModel()).getDupStatus(row); String thisColumnName = table.getColumnName(column); cell.setForeground(Color.black); cell.setBackground(Color.white); if (myDupStatus > 0){ //I'm a dup so color the background in bright, ugly yellow cell.setBackground(Color.yellow); } if (((String)table.getValueAt(row,1)).equals(hv.getChosenMarker())){ cell.setBackground(Color.cyan); } //bitmasking to decode the status bits if (myRating < 0){ myRating *= -1; if ((myRating & 1) != 0){ if(thisColumnName.equals("ObsHET")){ cell.setForeground(Color.red); } } if ((myRating & 2) != 0){ if (thisColumnName.equals("%Geno")){ cell.setForeground(Color.red); } } if ((myRating & 4) != 0){ if (thisColumnName.equals("HWpval")){ cell.setForeground(Color.red); } } if ((myRating & 8) != 0){ if (thisColumnName.equals("MendErr")){ cell.setForeground(Color.red); } } if ((myRating & 16) != 0){ if (thisColumnName.equals("MAF")){ cell.setForeground(Color.red); } } } return cell; }
|
public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component cell = super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column); int myRating = ((CheckDataTableSorter)table.getModel()).getRating(row); int myDupStatus = ((CheckDataTableSorter)table.getModel()).getDupStatus(row); String thisColumnName = table.getColumnName(column); cell.setForeground(Color.black); cell.setBackground(Color.white); if (myDupStatus > 0){ //I'm a dup so color the background in bright, ugly yellow cell.setBackground(Color.yellow); } if (((String)table.getValueAt(row,1)).equals(hv.getChosenMarker())){ cell.setBackground(Color.cyan); } //bitmasking to decode the status bits if (myRating < 0){ myRating *= -1; if ((myRating & 1) != 0){ if(thisColumnName.equals("ObsHET")){ cell.setForeground(Color.red); } } if ((myRating & 2) != 0){ if (thisColumnName.equals("%Geno")){ cell.setForeground(Color.red); } } if ((myRating & 4) != 0){ if (thisColumnName.equals("HWpval")){ cell.setForeground(Color.red); } } if ((myRating & 8) != 0){ if (thisColumnName.equals("MendErr")){ cell.setForeground(Color.red); } } if ((myRating & 16) != 0){ if (thisColumnName.equals("MAF")){ cell.setForeground(Color.red); } } } return cell; }
| 1,111,847
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*) \"ROWCOUNT\""); int i = 0; for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
| 1,111,848
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
| 1,111,849
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
| 1,111,850
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
| 1,111,851
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
| 1,111,852
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
| 1,111,853
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
| 1,111,854
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
| 1,111,855
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
| 1,111,856
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
| 1,111,857
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
| 1,111,858
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
| 1,111,859
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
| 1,111,860
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
| 1,111,861
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
| 1,111,862
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
|
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; try { conn = db.getConnection(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*)"); for (SQLColumn col : table.getColumns()) { if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")"); } if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")"); } if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")"); } if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")"); } if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))"); } if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))"); } if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))"); } } sql.append("\nFROM ").append(table.getName()); stmt = conn.createStatement(); lastSQL = sql.toString(); long startTime = System.currentTimeMillis(); rs = stmt.executeQuery(lastSQL); long endTime = System.currentTimeMillis(); if ( rs.next() ) { int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++)); putResult(table, tableProfileResult); for (SQLColumn col : table.getColumns()) { ColumnProfileResult colResult = new ColumnProfileResult(endTime-startTime); if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++)); } if (findingMin) { colResult.setMinValue(rs.getObject(rscol++)); } if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++)); } if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++)); } if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++)); } if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++)); } if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++)); } putResult(col, colResult); } } rs.close(); rs = null; // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); throw ex; } finally { try { if (rs != null) rs.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up statement", ex); } try { if (conn != null) conn.close(); } catch (SQLException ex) { logger.error("Couldn't clean up connection", ex); } } }
| 1,111,863
|
protected void updateQuery() { query.clear(); String photographer = basicFields.getPhotographer(); if( photographer.length() > 0 ) { query.setLikeCriteria( PhotoQuery.FIELD_PHOTOGRAPHER, photographer ); } String desc = basicFields.getDescription(); if( desc.length() > 0 ) { query.setLikeCriteria( PhotoQuery.FIELD_DESCRIPTION, desc ); } String shootingPlace = basicFields.getShootingPlace(); if( shootingPlace.length() > 0 ) { query.setLikeCriteria( PhotoQuery.FIELD_SHOOTING_PLACE, shootingPlace ); } if ( dateCB.isSelected() ) { query.setFieldCriteriaRange( PhotoQuery.FIELD_SHOOTING_TIME, shootingDateRange.getStartDate(), shootingDateRange.getEndDate() ); } }
|
protected void updateQuery() { query.clear(); String photographer = basicFields.getPhotographer(); if( photographer.length() > 0 ) { query.setLikeCriteria( PhotoQuery.FIELD_PHOTOGRAPHER, photographer ); } String desc = basicFields.getDescription(); if( desc.length() > 0 ) { query.setLikeCriteria( PhotoQuery.FIELD_DESCRIPTION, "%" + desc + "%" ); } String shootingPlace = basicFields.getShootingPlace(); if( shootingPlace.length() > 0 ) { query.setLikeCriteria( PhotoQuery.FIELD_SHOOTING_PLACE, shootingPlace ); } if ( dateCB.isSelected() ) { query.setFieldCriteriaRange( PhotoQuery.FIELD_SHOOTING_TIME, shootingDateRange.getStartDate(), shootingDateRange.getEndDate() ); } }
| 1,111,865
|
public static Database getODMGDatabase() { if ( db == null ) { db = odmg.newDatabase(); try { db.open( "repository.xml", Database.OPEN_READ_WRITE ); } catch ( ODMGException e ) { log.warn( "Could not open database: " + e.getMessage() ); db = null; } } return db; }
|
public static Database getODMGDatabase() { if ( db == null ) { db = odmg.newDatabase(); try { db.open( "repository.xml", Database.OPEN_READ_WRITE ); } catch ( ODMGException e ) { log.warn( "Could not open database: " + e.getMessage() ); db = null; } } return db; }
| 1,111,867
|
public static Implementation getODMGImplementation() { if ( odmg == null ) { odmg = OJB.getInstance(); } return odmg; }
|
public static Implementation getODMGImplementation() { if ( odmg == null ) { odmg = ODMG.getODMGImplementation(); } return odmg; }
| 1,111,868
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.