rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
PreparedStatement ps = conn.prepareStatement(sqlStatement); setParameters(ps, parameters);
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; } }
ResultSet rs = ps.executeQuery();
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(); }
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; } }
ApplicationDowntimeTrackingThread thread = new ApplicationDowntimeTrackingThread(appConfig); threads.add(thread); thread.start();
addApplication(appConfig);
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."); }
addListener(recorder);
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);
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."); }
for(ApplicationDowntimeTrackingThread thread: threads){
for(ApplicationHeartBeatThread thread: threads){
public void stop() { for(ApplicationDowntimeTrackingThread thread: threads){ thread.end(); } threads.clear(); eventListeners.clear(); }
eventListeners.clear();
public void stop() { for(ApplicationDowntimeTrackingThread thread: threads){ thread.end(); } threads.clear(); eventListeners.clear(); }
String component = DashboardComponentHelper.drawComponent(context,
String component = DashboardComponentHelper.refreshComponent(context,
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; }
query.create( "select folders from " + PhotoFolder.class.getName() );
query.create( "select folders from " + PhotoFolder.class.getName() + " where name = \"Top\"" );
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 ); }
if (! (node instanceof DBTreeRoot)) { while (node != null) { path.add(0, node); node = node.getParent(); }
while (node != null && node != root) { path.add(0, node); node = node.getParent();
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 LockedColumnException(String message) { super(message);
public LockedColumnException(SQLRelationship lockingRelationship) { super("Locked column belongs to relationship "+lockingRelationship); this.lockingRelationship = lockingRelationship;
public LockedColumnException(String message) { super(message); }
registerTag("assertThrown", AssertThrownTag.class);
registerTag("assertThrows", AssertThrowsTag.class);
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 ); }
script.addAttribute(attrQName, expression);
int p = attrQName.indexOf(':'); String prefix = p>=0 ? attrQName.substring(0,p): ""; script.addAttribute(list.getLocalName(i), prefix, list.getURI(i), expression);
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); } }
writer.write(new Config(applicationConfigs, dashboardConfigs));
writer.write(new Config(applicationConfigs));
private static void saveConfig(){ ConfigWriter writer = ConfigWriter.getInstance(); writer.write(new Config(applicationConfigs, dashboardConfigs)); }
tag.setContext(context);
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); }
if (value instanceof SQLObject) { if (((SQLObject) value).isPopulated()) { setForeground(Color.black); } else { setForeground(Color.lightGray); } }
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { setText(value.toString()); if (value instanceof SQLDatabase) { setIcon(dbIcon); } else if (value instanceof SQLCatalog) { if (((SQLCatalog) value).getNativeTerm().equals("owner")) { setIcon(ownerIcon); } else if (((SQLCatalog) value).getNativeTerm().equals("database")) { setIcon(dbIcon); } else if (((SQLCatalog) value).getNativeTerm().equals("schema")) { setIcon(schemaIcon); } else { setIcon(cataIcon); } } else if (value instanceof SQLSchema) { if (((SQLSchema) value).getNativeTerm().equals("owner")) { setIcon(ownerIcon); } else { setIcon(schemaIcon); } } else if (value instanceof SQLTable) { setIcon(tableIcon); if (((SQLTable) value).getObjectType() != null) { setText(((SQLTable) value).getName()+" ("+((SQLTable) value).getObjectType()+")"); } else { setText(((SQLTable) value).getName()); } } else if (value instanceof SQLRelationship) { setIcon(keyIcon); } else { setIcon(null); } this.selected = sel; this.hasFocus = hasFocus; return this; }
JButton okButton = new JDefaultButton(okAction); okButton.setText(actionButtonTitle);
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; }
makeJDialogCancellable(d, closeAction);
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; }
makeJDialogCancellable(d, cancelAction);
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; }
TablePane tp = new TablePane(t);
TablePane tp = new TablePane(t, pp.getFontRenderContext());
public void actionPerformed(ActionEvent evt) { SQLTable t = new SQLTable(); t.initFolders(true); t.setTableName("New_Table"); TablePane tp = new TablePane(t); pp.addFloating(tp); }
AlertSourceConfig alertSrcConfig = alertConfig.getAlertSourceConfig(); request.setAttribute("alertSourceType",alertSrcConfig.getSourceType()); request.setAttribute("sourceMBean", alertSrcConfig.getObjectName()); request.setAttribute("notificationType", alertSrcConfig.getNotificationType()); form.setAlertSourceType(alertSrcConfig.getSourceType()); form.setObjectName(alertSrcConfig.getObjectName()); form.setNotificationType(alertSrcConfig.getNotificationType());
public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { AlertForm form = (AlertForm)actionForm; String alertId = request.getParameter(RequestParams.ALERT_ID); ApplicationConfig appConfig = context.getApplicationConfig(); AlertConfig alertConfig = appConfig.findAlertById(alertId); if(alertConfig!=null){ form.setAlertName(alertConfig.getAlertName()); form.setSubject(alertConfig.getSubject()); form.setAlertDelivery(alertConfig.getAlertDelivery()); form.setEmailAddress(alertConfig.getEmailAddress()); } return mapping.findForward(Forwards.SUCCESS); }
script.run( parser.getContext(), output );
script.run( parser.getJellyContext(), 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.getContext(), output ); }
registerTag("sort", SortTag.class);
public XMLTagLibrary() { registerTag("out", ExprTag.class); registerTag("if", IfTag.class); registerTag("forEach", ForEachTag.class); registerTag("parse", ParseTag.class); registerTag("set", SetTag.class); registerTag("transform", TransformTag.class); registerTag("param", ParamTag.class); // extensions to JSTL registerTag("expr", ExprTag.class); registerTag("element", ElementTag.class); registerTag("attribute", AttributeTag.class); registerTag("copy", CopyTag.class); registerTag("copyOf", CopyOfTag.class); registerTag("doctype", DoctypeTag.class); }
if (attributeName.equals("select")) {
if (attributeName.equals("select") || attributeName.equals("sort")) {
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); }
if(this.countsOrRatios == SHOW_COUNTS) {
if(this.countsOrRatios == SHOW_HAP_COUNTS) {
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; }
} else if(this.countsOrRatios == SHOW_RATIOS) { return n.getRatios();
} else if(this.countsOrRatios == SHOW_HAP_RATIOS) { return n.getCCFreqs();
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; }
if(url == null){ return host + ":" + port; }
public String getURL() { return url; }
public Map runNamedScript( String name, Map params ) throws Exception { return runNamedScript(name, params, createXMLOutput()); }
public Map runNamedScript( String name, Map params ) throws Exception;
public Map runNamedScript( String name, Map params ) throws Exception { return runNamedScript(name, params, createXMLOutput()); }
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 ); } JellyContext context = createJellyContext(); context.setVariables( params ); context.runScript(url, output); return context.getVariables(); }
public Map runScript( String url, Map params, XMLOutput output ) throws Exception;
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(); }
logger.logActivity(username, user.getName()+" logged in successfully");
logger.logActivity(username, "logged in successfully");
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); } }
JPanel missingCutoffPanel = new JPanel(); missingCutoffField = new NumberTextField("25",3, false); missingCutoffPanel.add(new JLabel("Exclude individuals with >")); missingCutoffPanel.add(missingCutoffField); missingCutoffPanel.add(new JLabel("% missing genotypes.")); contents.add(missingCutoffPanel);
void load(int ft){ fileType = ft; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); JPanel filePanel = new JPanel(); filePanel.setLayout(new BoxLayout(filePanel, BoxLayout.Y_AXIS)); JPanel topFilePanel = new JPanel(); JPanel botFilePanel = new JPanel(); genoFileField = new JTextField("",20); //workaround for dumb Swing can't requestFocus until shown bug //this one seems to throw a harmless exception in certain versions of the linux JRE try{ SwingUtilities.invokeLater( new Runnable(){ public void run() { genoFileField.requestFocus(); }}); }catch (RuntimeException re){ } //this one seems to really fuck over the 1.3 version of the windows JRE //in short: Java sucks. /*genoFileField.dispatchEvent( new FocusEvent( genoFileField, FocusEvent.FOCUS_GAINED, false ) );*/ infoFileField = new JTextField("",20); JButton browseGenoButton = new JButton("Browse"); browseGenoButton.setActionCommand(BROWSE_GENO); browseGenoButton.addActionListener(this); JButton browseInfoButton = new JButton("Browse"); browseInfoButton.setActionCommand(BROWSE_INFO); browseInfoButton.addActionListener(this); topFilePanel.add(new JLabel("Genotype file: ")); topFilePanel.add(genoFileField); topFilePanel.add(browseGenoButton); botFilePanel.add(new JLabel("Locus information file: ")); botFilePanel.add(infoFileField); botFilePanel.add(browseInfoButton); filePanel.add(topFilePanel); if (ft != HMP){ filePanel.add(botFilePanel); } filePanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); contents.add(filePanel); JPanel compDistPanel = new JPanel(); maxComparisonDistField = new NumberTextField("500",4, false); compDistPanel.add(new JLabel("Ignore pairwise comparisons of markers >")); compDistPanel.add(maxComparisonDistField); compDistPanel.add(new JLabel("kb apart.")); contents.add(compDistPanel); doGB = new JCheckBox();//show gbrowse pic from hapmap website? doGB.setSelected(false); if (ft == HMP){ JPanel gBrowsePanel = new JPanel(); gBrowsePanel.add(doGB); gBrowsePanel.add(new JLabel("Download and show HapMap info track? (requires internet connection)")); contents.add(gBrowsePanel); } doTDT = new JCheckBox();//"Do association test?"); doTDT.setSelected(false); doTDT.setActionCommand("tdt"); doTDT.addActionListener(this); trioButton = new JRadioButton("Family trio data", true); trioButton.setEnabled(false); ccButton = new JRadioButton("Case/Control data"); ccButton.setEnabled(false); ButtonGroup group = new ButtonGroup(); group.add(trioButton); group.add(ccButton); if (ft == PED){ JPanel tdtOptsPanel = new JPanel(); JPanel tdtCheckBoxPanel = new JPanel(); tdtCheckBoxPanel.add(doTDT); tdtCheckBoxPanel.add(new JLabel("Do association test?")); tdtOptsPanel.add(trioButton); tdtOptsPanel.add(ccButton); contents.add(tdtCheckBoxPanel); contents.add(tdtOptsPanel); } JPanel choicePanel = new JPanel(); JButton okButton = new JButton("OK"); this.getRootPane().setDefaultButton(okButton); okButton.addActionListener(this); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); choicePanel.add(okButton); choicePanel.add(cancelButton); contents.add(choicePanel); this.setContentPane(contents); this.pack(); }
con.setCatalog(getName());
try { con.setCatalog(getName()); } catch (SQLException ex) { logger.info("populate: Could not setCatalog("+getName()+"). Assuming it's a permission problem. Stack trace:", ex); return; }
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"); }
TablePane tp = new TablePane(newTable);
TablePane tp = new TablePane(newTable, getFontRenderContext());
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; }
inputArray[1] = "";
inputArray[1] = null;
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); } } }
monitorObjName = new ObjectName("jmanage:name=" + alertName +
monitorObjName = new ObjectName("jmanage.alerts:name=" + alertName +
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); }
monitorObjName, null, null);
monitorObjName, new Object[0], new String[0]);
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); }
logger.log(Level.SEVERE, "Error while closing connection", e);
logger.log(Level.WARNING, "Error while closing connection", e);
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; }
if(!_submitBelowTopics) {
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; }
T.add(send, 1, 3); if (_showCancelImage) T.add(cancel, 1, 3);
if(!_submitBelowTopics) { T.add(send, 1, 3); if (_showCancelImage) T.add(cancel, 1, 3); }
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; }
T.add(send, 3, 1); if (_showCancelImage) T.add(cancel, 3, 1);
if(!_submitBelowTopics) { T.add(send, 3, 1); if (_showCancelImage) T.add(cancel, 3, 1); }
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; }
dge.getDragSource().startDrag (dge, null, new DnDTreePathTransferable(paths), tp);
JLabel label = new JLabel(tp.getModel().getName()+"."+tp.draggingColumn.getName()); Dimension labelSize = label.getPreferredSize(); label.setSize(labelSize); BufferedImage dragImage = new BufferedImage(labelSize.width, labelSize.height, BufferedImage.TYPE_4BYTE_ABGR); Graphics2D imageGraphics = dragImage.createGraphics(); label.paint(imageGraphics); imageGraphics.dispose(); dge.getDragSource().startDrag(dge, null, dragImage, new Point(0, 0), new DnDTreePathTransferable(paths), tp);
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; } }
if (start < 0){ start = 0; }
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if(command.equals("Cancel")) { this.dispose(); } if (command.equals("GO")){ if(rangeInput.getText().equals("")){ JOptionPane.showMessageDialog(this, "Please enter a range", "Invalid value", JOptionPane.ERROR_MESSAGE); return; } String pop = (String)popChooser.getSelectedItem(); int range = Integer.parseInt(rangeInput.getText()); long start = (markerPosition/1000)-range; long end = (markerPosition/1000)+range; String gotoStart = new Long(start).toString(); String gotoEnd = new Long(end).toString(); String phase = (String)phaseChooser.getSelectedItem(); hv.setChosenMarker(marker); if (gBrowse.isSelected()){ Options.setShowGBrowse(true); } String[] returnStrings; returnStrings = new String[]{"Chr " + chrom + ":" + pop + ":" + gotoStart + ".." + gotoEnd, pop, gotoStart, gotoEnd, chrom, phase}; this.dispose(); hv.readGenotypes(returnStrings, PHASEDHMPDL_FILE, true); } }
System.out.println("Interrupted while waiting for engine");
logger.error("Interrupted while waiting for engine", ex);
public void waitForProcessCompletion() { try { iss.join(); ess.join(); } catch (InterruptedException ex) { System.out.println("Interrupted while waiting for engine"); } output.append("Execution halted"); }
VariantSequence vs = (VariantSequence)taggedByCurTag.get(j); vs.removeTag(dumpedTS);
VariantSequence vs = (VariantSequence)taggedByHap.get(j); vs.removeTag(ts);
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); }
Component c = ((JTabbedPane)hv.tabs.getComponent(currTab)).getSelectedComponent();
Component c = ((JTabbedPane)((HaploviewTab)hv.tabs.getComponent(currTab)).getComponent()).getSelectedComponent();
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); }
rsq =((PairwiseLinkage)dpTable.getLDStats(v2Index, v1Index)).getRSquared();
pl = dpTable.getLDStats(v2Index,v1Index); }else{ pl = dpTable.getLDStats(v1Index,v2Index); }
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); } }
}else{ rsq = ((PairwiseLinkage)dpTable.getLDStats(v1Index, v2Index)).getRSquared();
if(pl == null) { rsq = 0; } else { rsq =pl.getRSquared();
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); } }
if (((String)table.getValueAt(row,1)).equals(hv.getChosenMarker())){ cell.setBackground(Color.cyan);
if (hv.getChosenMarker() != null){ if (((String)table.getValueAt(row,1)).equals(hv.getChosenMarker())){ cell.setBackground(Color.cyan); }
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; }
sql.append("SELECT COUNT(*)");
sql.append("SELECT COUNT(*) \"ROWCOUNT\""); int i = 0;
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); } } }
if (findingDistinctCount) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(")");
if (findingDistinctCount && col.getType() != Types.LONGVARCHAR && col.getType() != Types.LONGVARBINARY ) { sql.append(",\n COUNT(DISTINCT ").append(col.getName()).append(") \"DISTINCTCOUNT_"+i+"\"");
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); } } }
if (findingMin) { sql.append(",\n MIN(").append(col.getName()).append(")");
if (findingMin && col.getType() != Types.LONGVARCHAR && col.getType() != Types.VARBINARY && col.getType() != Types.LONGVARBINARY ) { sql.append(",\n MIN(").append(col.getName()).append(") \"MINVALUE_"+i+"\"");
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); } } }
if (findingMax) { sql.append(",\n MAX(").append(col.getName()).append(")");
if (findingMax && col.getType() != Types.LONGVARCHAR && col.getType() != Types.VARBINARY && col.getType() != Types.LONGVARBINARY ) { sql.append(",\n MAX(").append(col.getName()).append(") \"MAXVALUE_"+i+"\"");
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); } } }
if (findingAvg) { sql.append(",\n AVG(").append(col.getName()).append(")");
if (findingAvg && col.getType() != Types.LONGVARCHAR && col.getType() != Types.LONGVARBINARY && col.getType() != Types.VARBINARY && col.getType() != Types.TIMESTAMP && col.getType() != Types.CHAR && col.getType() != Types.VARCHAR ) { sql.append(",\n AVG(").append(col.getName()).append(") \"AVGVALUE_"+i+"\"");
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); } } }
if (findingMinLength) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append("))");
if (findingMinLength && col.getType() != Types.LONGVARCHAR && col.getType() != Types.LONGVARBINARY ) { sql.append(",\n MIN(LENGTH(").append(col.getName()).append(")) \"MINLENGTH_"+i+"\"");
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); } } }
if (findingMaxLength) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append("))");
if (findingMaxLength && col.getType() != Types.LONGVARCHAR && col.getType() != Types.LONGVARBINARY ) { sql.append(",\n MAX(LENGTH(").append(col.getName()).append(")) \"MAXLENGTH_"+i+"\"");
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); } } }
if (findingAvgLength) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append("))");
if (findingAvgLength && col.getType() != Types.LONGVARCHAR && col.getType() != Types.LONGVARBINARY ) { sql.append(",\n AVG(LENGTH(").append(col.getName()).append(")) \"AVGLENGTH_"+i+"\"");
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); } } }
int rscol = 1; TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt(rscol++));
TableProfileResult tableProfileResult = new TableProfileResult(endTime-startTime,rs.getInt("ROWCOUNT"));
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); } } }
if (findingDistinctCount) { colResult.setDistinctValueCount(rs.getInt(rscol++));
if (findingDistinctCount && col.getType() != Types.LONGVARCHAR && col.getType() != Types.LONGVARBINARY ) { lastSQL = "DISTINCTCOUNT_"+i; colResult.setDistinctValueCount(rs.getInt(lastSQL));
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); } } }
if (findingMin) { colResult.setMinValue(rs.getObject(rscol++));
if (findingMin && col.getType() != Types.LONGVARCHAR && col.getType() != Types.VARBINARY && col.getType() != Types.LONGVARBINARY ) { lastSQL = "MINVALUE_"+i; colResult.setMinValue(rs.getObject(lastSQL));
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); } } }
if (findingMax) { colResult.setMaxValue(rs.getObject(rscol++));
if (findingMax && col.getType() != Types.LONGVARCHAR && col.getType() != Types.VARBINARY && col.getType() != Types.LONGVARBINARY ) { lastSQL = "MAXVALUE_"+i; colResult.setMaxValue(rs.getObject(lastSQL));
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); } } }
if (findingAvg) { colResult.setAvgValue(rs.getObject(rscol++));
if (findingAvg && col.getType() != Types.LONGVARCHAR && col.getType() != Types.LONGVARBINARY && col.getType() != Types.VARBINARY && col.getType() != Types.TIMESTAMP && col.getType() != Types.CHAR && col.getType() != Types.VARCHAR ) { lastSQL = "AVGVALUE_"+i; colResult.setAvgValue(rs.getObject(lastSQL));
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); } } }
if (findingMinLength) { colResult.setMinLength(rs.getInt(rscol++));
if (findingMinLength && col.getType() != Types.LONGVARCHAR && col.getType() != Types.LONGVARBINARY ) { lastSQL = "MINLENGTH_"+i; colResult.setMinLength(rs.getInt(lastSQL));
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); } } }
if (findingMaxLength) { colResult.setMaxLength(rs.getInt(rscol++));
if (findingMaxLength && col.getType() != Types.LONGVARCHAR && col.getType() != Types.LONGVARBINARY ) { lastSQL = "MAXLENGTH_"+i; colResult.setMaxLength(rs.getInt(lastSQL));
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); } } }
if (findingAvgLength) { colResult.setAvgLength(rs.getInt(rscol++));
if (findingAvgLength && col.getType() != Types.LONGVARCHAR && col.getType() != Types.LONGVARBINARY ) { lastSQL = "AVGLENGTH_"+i; colResult.setAvgLength(rs.getInt(lastSQL));
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); } } }
i++;
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); } } }
desc );
"%" + desc + "%" );
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() ); } }
txw.commit();
protected void addSubfolder( PhotoFolder subfolder ) { subfolders.add( subfolder ); modified(); // Inform all parents & their that the structure has changed subfolderStructureChanged( this ); }
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; }
db = ODMG.getODMGDatabase();
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; }
odmg = OJB.getInstance();
odmg = ODMG.getODMGImplementation();
public static Implementation getODMGImplementation() { if ( odmg == null ) { odmg = OJB.getInstance(); } return odmg; }
Transaction tx = odmg.currentTransaction(); boolean mustCommit = false; if ( tx == null ) { tx = odmg.newTransaction(); tx.begin(); mustCommit = true; } tx.lock( this, Transaction.WRITE );
log.debug( "Field modified" );
protected void modified() { // Find the current transaction or create a new one Transaction tx = odmg.currentTransaction(); boolean mustCommit = false; if ( tx == null ) { tx = odmg.newTransaction(); tx.begin(); mustCommit = true; } // Add folder to the transaction tx.lock( this, Transaction.WRITE ); // Notify the listeners. This is done in the same transaction context so that potential modifications to other // persistent objects are also saved notifyListeners(); // Notify also parents if there are any if ( parent != null ) { parent.subfolderChanged( this ); } // If a new transaction was created, commit it if ( mustCommit ) { tx.commit(); } }
if ( mustCommit ) { tx.commit(); }
protected void modified() { // Find the current transaction or create a new one Transaction tx = odmg.currentTransaction(); boolean mustCommit = false; if ( tx == null ) { tx = odmg.newTransaction(); tx.begin(); mustCommit = true; } // Add folder to the transaction tx.lock( this, Transaction.WRITE ); // Notify the listeners. This is done in the same transaction context so that potential modifications to other // persistent objects are also saved notifyListeners(); // Notify also parents if there are any if ( parent != null ) { parent.subfolderChanged( this ); } // If a new transaction was created, commit it if ( mustCommit ) { tx.commit(); } }
txw.commit();
protected void removeSubfolder( PhotoFolder subfolder ) { subfolders.remove( subfolder ); modified(); // Inform all parents & their that the structure has changed subfolderStructureChanged( this ); }
txw.commit();
public void setDescription(String v) { this.description = v; modified(); }
txw.commit();
public void setName(String v) { this.name = v; modified(); }
txw.commit();
public void setParentFolder( PhotoFolder newParent ) { // If the parent is already set, remove the folder from its subfolders if ( parent != null ) { parent.removeSubfolder( this ); } this.parent = newParent; if ( parent != null ) { parent.addSubfolder( this ); } modified(); }
ArchitectFrame.getMainInstance();
public SQLTestCase(String name) throws Exception { super(name); ArchitectFrame.getMainInstance(); // creates an ArchitectFrame, which loads settings //FIXME: a better approach would be to have an initialsation method // in the business model, which does not depend on the init routine in ArchitectFrame. }
PlDotIni plini = new PlDotIni(); plini.read(new File("pl.regression.ini")); db = new SQLDatabase(plini.getDataSource("regression_test"));
db = new SQLDatabase(getDataSource());
protected void setUp() throws Exception { PlDotIni plini = new PlDotIni(); plini.read(new File("pl.regression.ini")); db = new SQLDatabase(plini.getDataSource("regression_test")); }
dPrimeDisplay.refresh(0);
dPrimeDisplay.refresh();
public void componentResized(ComponentEvent e) { if (dPrimeDisplay != null){ dPrimeDisplay.refresh(0); } }
changeKey(1);
public HaploView(){ try{ fc = new JFileChooser(System.getProperty("user.dir")); }catch(NullPointerException n){ try{ UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); fc = new JFileChooser(System.getProperty("user.dir")); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }catch(Exception e){ } } //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } exportMenuItems[2].setEnabled(true); fileMenu.addSeparator(); fileMenu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem("Quit"); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); displayMenu.setMnemonic(KeyEvent.VK_D); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); viewMenuItems[i].setEnabled(false); group.add(viewMenuItems[i]); } displayMenu.addSeparator(); //a submenu ButtonGroup zg = new ButtonGroup(); JMenu zoomMenu = new JMenu("D prime zoom"); zoomMenu.setMnemonic(KeyEvent.VK_Z); zoomMenuItems = new JRadioButtonMenuItem[zoomItems.length]; for (int i = 0; i < zoomItems.length; i++){ zoomMenuItems[i] = new JRadioButtonMenuItem(zoomItems[i], i==0); zoomMenuItems[i].addActionListener(this); zoomMenuItems[i].setActionCommand("zoom" + i); zoomMenu.add(zoomMenuItems[i]); zg.add(zoomMenuItems[i]); } displayMenu.add(zoomMenu); //another submenu ButtonGroup cg = new ButtonGroup(); JMenu colorMenu = new JMenu("D prime color scheme"); colorMenu.setMnemonic(KeyEvent.VK_C); colorMenuItems = new JRadioButtonMenuItem[colorItems.length]; for (int i = 0; i< colorItems.length; i++){ colorMenuItems[i] = new JRadioButtonMenuItem(colorItems[i],i==0); colorMenuItems[i].addActionListener(this); colorMenuItems[i].setActionCommand("color" + i); colorMenu.add(colorMenuItems[i]); cg.add(colorMenuItems[i]); } displayMenu.add(colorMenu); //analysis menu JMenu analysisMenu = new JMenu("Analysis"); analysisMenu.setMnemonic(KeyEvent.VK_A); menuBar.add(analysisMenu); //a submenu ButtonGroup bg = new ButtonGroup(); JMenu blockMenu = new JMenu("Define Blocks"); blockMenu.setMnemonic(KeyEvent.VK_B); blockMenuItems = new JRadioButtonMenuItem[blockItems.length]; for (int i = 0; i < blockItems.length; i++){ blockMenuItems[i] = new JRadioButtonMenuItem(blockItems[i], i==0); blockMenuItems[i].addActionListener(this); blockMenuItems[i].setActionCommand("block" + (i+1)); blockMenu.add(blockMenuItems[i]); bg.add(blockMenuItems[i]); if (i != 0){ blockMenuItems[i].setEnabled(false); } } analysisMenu.add(blockMenu); clearBlocksItem = new JMenuItem(CLEAR_BLOCKS); setAccelerator(clearBlocksItem, 'C', false); clearBlocksItem.addActionListener(this); clearBlocksItem.setEnabled(false); analysisMenu.add(clearBlocksItem); JMenuItem customizeBlocksItem = new JMenuItem(CUST_BLOCKS); customizeBlocksItem.addActionListener(this); analysisMenu.add(customizeBlocksItem); //color key keyMenu = new JMenu("Key"); changeKey(1); menuBar.add(Box.createHorizontalGlue()); menuBar.add(keyMenu); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ /* clearBlocksMenuItem.addActionListener(this); clearBlocksMenuItem.setEnabled(false); toolMenu.add(clearBlocksMenuItem); */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); addComponentListener(new ResizeListener()); }
dPrimeDisplay.refresh(Integer.valueOf(command.substring(5)).intValue()+1); changeKey(Integer.valueOf(command.substring(5)).intValue()+1);
currentScheme = Integer.valueOf(command.substring(5)).intValue()+1; dPrimeDisplay.colorDPrime(currentScheme); dPrimeDisplay.refresh(); changeKey(currentScheme);
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command == READ_GENOTYPES){ ReadDataDialog readDialog = new ReadDataDialog("Open new data", this); readDialog.pack(); readDialog.setVisible(true); } else if (command == READ_MARKERS){ //JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); fc.setSelectedFile(new File("")); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { readMarkers(fc.getSelectedFile(),null); } }else if (command == CUST_BLOCKS){ TweakBlockDefsDialog tweakDialog = new TweakBlockDefsDialog("Customize Blocks", this); tweakDialog.pack(); tweakDialog.setVisible(true); }else if (command == CLEAR_BLOCKS){ changeBlocks(BLOX_NONE); //blockdef clauses }else if (command.startsWith("block")){ int method = Integer.valueOf(command.substring(5)).intValue(); changeBlocks(method); /*for (int i = 1; i < colorMenuItems.length; i++){ if (method+1 == i){ colorMenuItems[i].setEnabled(true); }else{ colorMenuItems[i].setEnabled(false); } } colorMenuItems[0].setSelected(true);*/ //zooming clauses }else if (command.startsWith("zoom")){ dPrimeDisplay.zoom(Integer.valueOf(command.substring(4)).intValue()); //coloring clauses }else if (command.startsWith("color")){ dPrimeDisplay.refresh(Integer.valueOf(command.substring(5)).intValue()+1); changeKey(Integer.valueOf(command.substring(5)).intValue()+1); //exporting clauses }else if (command == EXPORT_PNG){ export(tabs.getSelectedIndex(), PNG_MODE, 0, Chromosome.getSize()); }else if (command == EXPORT_TEXT){ export(tabs.getSelectedIndex(), TXT_MODE, 0, Chromosome.getSize()); }else if (command == EXPORT_OPTIONS){ ExportDialog exDialog = new ExportDialog(this); exDialog.pack(); exDialog.setVisible(true); }else if (command == "Select All"){ checkPanel.selectAll(); }else if (command == "Rescore Markers"){ String cut = cdc.hwcut.getText(); if (cut.equals("")){ cut = "0"; } CheckData.hwCut = Double.parseDouble(cut); cut = cdc.genocut.getText(); if (cut.equals("")){ cut="0"; } CheckData.failedGenoCut = Integer.parseInt(cut); cut = cdc.mendcut.getText(); if (cut.equals("")){ cut="0"; } CheckData.numMendErrCut = Integer.parseInt(cut); cut = cdc.mafcut.getText(); if (cut.equals("")){ cut="0"; } CheckData.mafCut = Double.parseDouble(cut); checkPanel.redoRatings(); }else if (command == "Tutorial"){ showHelp(); } else if (command == "Quit"){ quit(); } else { for (int i = 0; i < viewItems.length; i++) { if (command == viewItems[i]) tabs.setSelectedIndex(i); } } }
dPrimeDisplay.refresh(0);
dPrimeDisplay.refresh();
public void changeBlocks(int method){ theData.guessBlocks(method); dPrimeDisplay.refresh(0); currentBlockDef = method; try{ if (tabs.getSelectedIndex() == VIEW_HAP_NUM){ hapDisplay.getHaps(); } }catch(HaploViewException hve) { JOptionPane.showMessageDialog(this, hve.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); }
changeKey(1);
void processData(final String[][] hminfo, String[] in) { final String[] inputOptions = in; if (inputOptions[2].equals("")){ inputOptions[2] = "0"; } maxCompDist = Long.parseLong(inputOptions[2])*1000; this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); final SwingWorker worker = new SwingWorker(){ public Object construct(){ dPrimeDisplay=null; theData.infoKnown = false; File markerFile; if (inputOptions[1].equals("")){ markerFile = null; }else{ markerFile = new File(inputOptions[1]); } readMarkers(markerFile, hminfo); theData.generateDPrimeTable(); //theData.guessBlocks(BLOX_GABRIEL); theData.guessBlocks(BLOX_NONE); //for debugging, doesn't call blocks at first colorMenuItems[0].setSelected(true); blockMenuItems[0].setSelected(true); zoomMenuItems[0].setSelected(true); theData.blocksChanged = false; Container contents = getContentPane(); contents.removeAll(); int currentTab = VIEW_D_NUM; /*if (!(tabs == null)){ currentTab = tabs.getSelectedIndex(); } */ tabs = new JTabbedPane(); tabs.addChangeListener(new TabChangeListener()); //first, draw the D' picture JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); dPrimeDisplay = new DPrimeDisplay(theData); JScrollPane dPrimeScroller = new JScrollPane(dPrimeDisplay); dPrimeScroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(dPrimeScroller); tabs.addTab(viewItems[VIEW_D_NUM], panel); viewMenuItems[VIEW_D_NUM].setEnabled(true); //compute and show haps on next tab panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); try { hapDisplay = new HaplotypeDisplay(theData); } catch(HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); hapScroller = new JScrollPane(hapDisplay); hapScroller.getVerticalScrollBar().setUnitIncrement(60); hapScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); viewMenuItems[VIEW_HAP_NUM].setEnabled(true); //LOD panel /*panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); LODDisplay ld = new LODDisplay(theData); JScrollPane lodScroller = new JScrollPane(ld); panel.add(lodScroller); tabs.addTab(viewItems[VIEW_LOD_NUM], panel); viewMenuItems[VIEW_LOD_NUM].setEnabled(true);*/ //int optionalTabCount = 1; //check data panel if (checkPanel != null){ //optionalTabCount++; //VIEW_CHECK_NUM = optionalTabCount; //viewItems[VIEW_CHECK_NUM] = VIEW_CHECK_PANEL; JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JLabel countsLabel = new JLabel("Using " + theData.numSingletons + " singletons and " + theData.numTrios + " trios from " + theData.numPeds + " families."); if (theData.numTrios + theData.numSingletons == 0){ countsLabel.setForeground(Color.red); } countsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(countsLabel); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); tabs.addTab(viewItems[VIEW_CHECK_NUM], metaCheckPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } //TDT panel if(assocTest > 0) { //optionalTabCount++; //VIEW_TDT_NUM = optionalTabCount; //viewItems[VIEW_TDT_NUM] = VIEW_TDT; tdtPanel = new TDTPanel(theData.chromosomes, assocTest); tabs.addTab(viewItems[VIEW_TDT_NUM], tdtPanel); viewMenuItems[VIEW_TDT_NUM].setEnabled(true); } tabs.setSelectedIndex(currentTab); contents.add(tabs); repaint(); setVisible(true); theData.finished = true; setTitle(TITLE_STRING + " -- " + inputOptions[0]); return null; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ if (theData.finished){ timer.stop(); for (int i = 0; i < blockMenuItems.length; i++){ blockMenuItems[i].setEnabled(true); } clearBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); worker.start(); timer.start(); }
changeKey(1);
public Object construct(){ dPrimeDisplay=null; theData.infoKnown = false; File markerFile; if (inputOptions[1].equals("")){ markerFile = null; }else{ markerFile = new File(inputOptions[1]); } readMarkers(markerFile, hminfo); theData.generateDPrimeTable(); //theData.guessBlocks(BLOX_GABRIEL); theData.guessBlocks(BLOX_NONE); //for debugging, doesn't call blocks at first colorMenuItems[0].setSelected(true); blockMenuItems[0].setSelected(true); zoomMenuItems[0].setSelected(true); theData.blocksChanged = false; Container contents = getContentPane(); contents.removeAll(); int currentTab = VIEW_D_NUM; /*if (!(tabs == null)){ currentTab = tabs.getSelectedIndex(); } */ tabs = new JTabbedPane(); tabs.addChangeListener(new TabChangeListener()); //first, draw the D' picture JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); dPrimeDisplay = new DPrimeDisplay(theData); JScrollPane dPrimeScroller = new JScrollPane(dPrimeDisplay); dPrimeScroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(dPrimeScroller); tabs.addTab(viewItems[VIEW_D_NUM], panel); viewMenuItems[VIEW_D_NUM].setEnabled(true); //compute and show haps on next tab panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); try { hapDisplay = new HaplotypeDisplay(theData); } catch(HaploViewException e) { JOptionPane.showMessageDialog(window, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); hapScroller = new JScrollPane(hapDisplay); hapScroller.getVerticalScrollBar().setUnitIncrement(60); hapScroller.getHorizontalScrollBar().setUnitIncrement(60); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[VIEW_HAP_NUM], panel); viewMenuItems[VIEW_HAP_NUM].setEnabled(true); //LOD panel /*panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); LODDisplay ld = new LODDisplay(theData); JScrollPane lodScroller = new JScrollPane(ld); panel.add(lodScroller); tabs.addTab(viewItems[VIEW_LOD_NUM], panel); viewMenuItems[VIEW_LOD_NUM].setEnabled(true);*/ //int optionalTabCount = 1; //check data panel if (checkPanel != null){ //optionalTabCount++; //VIEW_CHECK_NUM = optionalTabCount; //viewItems[VIEW_CHECK_NUM] = VIEW_CHECK_PANEL; JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JLabel countsLabel = new JLabel("Using " + theData.numSingletons + " singletons and " + theData.numTrios + " trios from " + theData.numPeds + " families."); if (theData.numTrios + theData.numSingletons == 0){ countsLabel.setForeground(Color.red); } countsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(countsLabel); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); tabs.addTab(viewItems[VIEW_CHECK_NUM], metaCheckPanel); viewMenuItems[VIEW_CHECK_NUM].setEnabled(true); currentTab=VIEW_CHECK_NUM; } //TDT panel if(assocTest > 0) { //optionalTabCount++; //VIEW_TDT_NUM = optionalTabCount; //viewItems[VIEW_TDT_NUM] = VIEW_TDT; tdtPanel = new TDTPanel(theData.chromosomes, assocTest); tabs.addTab(viewItems[VIEW_TDT_NUM], tdtPanel); viewMenuItems[VIEW_TDT_NUM].setEnabled(true); } tabs.setSelectedIndex(currentTab); contents.add(tabs); repaint(); setVisible(true); theData.finished = true; setTitle(TITLE_STRING + " -- " + inputOptions[0]); return null; }
dPrimeDisplay.refresh(0);
dPrimeDisplay.refresh();
void readMarkers(File inputFile, String[][] hminfo){ try { theData.prepareMarkerInput(inputFile,maxCompDist,hminfo); if (checkPanel != null){ checkPanel.refreshNames(); } if (tdtPanel != null){ tdtPanel.refreshNames(); } }catch (HaploViewException e){ JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } if (dPrimeDisplay != null && tabs.getSelectedIndex() == VIEW_D_NUM){ dPrimeDisplay.refresh(0); } }
if ( p != null && folder != null ) { folder.addPhoto( p );
if ( p != null ) { if ( photoInstanceCounts.containsKey( p ) ) { int refCount = ((Integer)photoInstanceCounts.get( p ) ).intValue(); photoInstanceCounts.remove( p ); photoInstanceCounts.put( p, Integer.valueOf( refCount+1 )); } else { folder.addPhoto( p ); photoInstanceCounts.put( p, Integer.valueOf( 1 )); }
void indexDirectory( File dir, PhotoFolder folder, int startPercent, int endPercent ) { File files[] = dir.listFiles(); // Count the files int fileCount = 0; int subdirCount = 0; for ( int n = 0; n < files.length; n++ ) { if ( files[n].isDirectory() ) { subdirCount++; } else { fileCount++; } } ProgressCalculator c = new ProgressCalculator( startPercent, endPercent, fileCount, subdirCount ); int nFile = 0; int nDir = 0; for ( int n = 0; n < files.length; n++ ) { File f = files[n]; if ( f.isDirectory() ) { // Create the matching folder PhotoFolder subfolder = null; if ( folder != null ) { subfolder = findSubfolderByName( folder, f.getName() ); if ( subfolder == null ) { subfolder = PhotoFolder.create( f.getName(), folder ); newFolderCount++; } } /* Calclate the start & end percentages to use when indexing this directory. Formula goes so that we estimate that to index current dirctory completely we must index files in subDirCount+1 directories (all subdirs + current directory). So we divide endPercent - startPercent into this many steps) */ int subdirStart = c.getProgress(); nDir++; c.setProcessedSubdirs( nDir ); int subdirEnd = c.getProgress(); indexDirectory( f, subfolder, subdirStart, subdirEnd ); percentComplete = c.getProgress(); } else { if ( f.canRead() ) { currentEvent = new ExtVolIndexerEvent( this ); PhotoInfo p = indexFile( f ); if ( p != null && folder != null ) { folder.addPhoto( p ); } nFile++; c.setProcessedFiles( nFile ); percentComplete = c.getProgress(); notifyListeners( currentEvent ); } } } }
Iterator iter = photoInstanceCounts.keySet().iterator(); while ( iter.hasNext() ) { PhotoInfo p = (PhotoInfo ) iter.next(); int refCount = ((Integer)photoInstanceCounts.get( p )).intValue(); if ( refCount == 0 ) { folder.removePhoto( p ); } }
void indexDirectory( File dir, PhotoFolder folder, int startPercent, int endPercent ) { File files[] = dir.listFiles(); // Count the files int fileCount = 0; int subdirCount = 0; for ( int n = 0; n < files.length; n++ ) { if ( files[n].isDirectory() ) { subdirCount++; } else { fileCount++; } } ProgressCalculator c = new ProgressCalculator( startPercent, endPercent, fileCount, subdirCount ); int nFile = 0; int nDir = 0; for ( int n = 0; n < files.length; n++ ) { File f = files[n]; if ( f.isDirectory() ) { // Create the matching folder PhotoFolder subfolder = null; if ( folder != null ) { subfolder = findSubfolderByName( folder, f.getName() ); if ( subfolder == null ) { subfolder = PhotoFolder.create( f.getName(), folder ); newFolderCount++; } } /* Calclate the start & end percentages to use when indexing this directory. Formula goes so that we estimate that to index current dirctory completely we must index files in subDirCount+1 directories (all subdirs + current directory). So we divide endPercent - startPercent into this many steps) */ int subdirStart = c.getProgress(); nDir++; c.setProcessedSubdirs( nDir ); int subdirEnd = c.getProgress(); indexDirectory( f, subfolder, subdirStart, subdirEnd ); percentComplete = c.getProgress(); } else { if ( f.canRead() ) { currentEvent = new ExtVolIndexerEvent( this ); PhotoInfo p = indexFile( f ); if ( p != null && folder != null ) { folder.addPhoto( p ); } nFile++; c.setProcessedFiles( nFile ); percentComplete = c.getProgress(); notifyListeners( currentEvent ); } } } }
ImageInstance oldInstance = null; try { oldInstance = ImageInstance.retrieve( volume, volume.mapFileToVolumeRelativeName(f ) ); } catch ( PhotoNotFoundException e ) { } if ( oldInstance != null ) { if ( oldInstance.doConsistencyCheck() ) { PhotoInfo photo = null; try { photo = PhotoInfo.retrievePhotoInfo(oldInstance.getPhotoUid()); } catch (PhotoNotFoundException ex) { ex.printStackTrace(); } return photo; } else { PhotoInfo photo = null; try { photo = PhotoInfo.retrievePhotoInfo(oldInstance.getPhotoUid()); } catch (PhotoNotFoundException ex) { ex.printStackTrace(); } Vector instances = photo.getInstances(); int instNum = instances.indexOf( oldInstance ); if ( instNum >= 0 ) { photo.removeInstance( instNum ); } } }
PhotoInfo indexFile( File f ) { indexedFileCount++; // Check whether this is really an image file ODMGXAWrapper txw = new ODMGXAWrapper(); ImageInstance instance = ImageInstance.create( volume, f ); if ( instance == null ) { currentEvent.setResult( ExtVolIndexerEvent.RESULT_NOT_IMAGE ); /* ImageInstance already aborts transaction if reading image file was unsuccessfull. */ return null; } byte[] hash = instance.getHash(); // Check whether there is already an image instance with the same hash PhotoInfo matchingPhotos[] = PhotoInfo.retrieveByOrigHash( hash ); PhotoInfo photo = null; if ( matchingPhotos != null && matchingPhotos.length > 0 ) { // If yes then get the PhotoInfo and add this file as an instance with // the same type as the one with same hash. If only PhotoInfo with no // instances add as original for that photo = matchingPhotos[0]; photo.addInstance( instance ); currentEvent.setResult( ExtVolIndexerEvent.RESULT_NEW_INSTANCE ); newInstanceCount++; } else { photo = PhotoInfo.create(); photo.addInstance( instance ); photo.updateFromOriginalFile(); // Create a thumbnail for this photo photo.getThumbnail(); currentEvent.setResult( ExtVolIndexerEvent.RESULT_NEW_PHOTO ); newInstanceCount++; newPhotoCount++; } currentEvent.setPhoto( photo ); txw.commit(); return photo; }
} if (skip == 2){ if (Chromosome.dataChrom != null){ if (!Chromosome.dataChrom.equals(s)){ throw new PedFileException("Hapmap file format error on line " + (k+1)+ ":\n There appear to be multiple chromosomes in the file."); } }else{ Chromosome.dataChrom = s; }
public void parseHapMap(Vector rawLines) throws PedFileException { int colNum = -1; int numLines = rawLines.size(); Individual ind; this.order = new Vector(); //sort first Vector lines = new Vector(); Hashtable sortHelp = new Hashtable(numLines-1,1.0f); long[] pos = new long[numLines-1]; lines.add(rawLines.get(0)); for (int k = 1; k < numLines; k++){ StringTokenizer st = new StringTokenizer((String) rawLines.get(k)); //strip off 1st 3 cols st.nextToken();st.nextToken();st.nextToken(); pos[k-1] = new Long(st.nextToken()).longValue(); sortHelp.put(new Long(pos[k-1]),rawLines.get(k)); } Arrays.sort(pos); for (int i = 0; i < pos.length; i++){ lines.add(sortHelp.get(new Long(pos[i]))); } //enumerate indivs StringTokenizer st = new StringTokenizer((String)lines.get(0), "\n\t\" \""); int numMetaColumns = 0; boolean doneMeta = false; while(!doneMeta && st.hasMoreTokens()){ String thisfield = st.nextToken(); numMetaColumns++; //so currently the first person ID always starts with NA (Coriell ID) but //todo: will this be true with AA samples etc? if (thisfield.startsWith("NA")){ doneMeta = true; } } numMetaColumns--; st = new StringTokenizer((String)lines.get(0), "\n\t\" \""); for (int i = 0; i < numMetaColumns; i++){ st.nextToken(); } StringTokenizer dt; while (st.hasMoreTokens()){ ind = new Individual(); String name = st.nextToken(); String details = (String)hapMapTranslate.get(name); if (details == null){ throw new PedFileException("Hapmap data format error: " + name); } dt = new StringTokenizer(details, "\n\t\" \""); ind.setFamilyID(dt.nextToken().trim()); ind.setIndividualID(dt.nextToken().trim()); ind.setDadID(dt.nextToken().trim()); ind.setMomID(dt.nextToken().trim()); try { ind.setGender(Integer.parseInt(dt.nextToken().trim())); ind.setAffectedStatus(Integer.parseInt(dt.nextToken().trim())); }catch(NumberFormatException nfe) { throw new PedFileException("File error: invalid gender or affected status for indiv " + name); } ind.setIsTyped(true); //check if the family exists already in the Hashtable Family fam = (Family)this.families.get(ind.getFamilyID()); if(fam == null){ //it doesnt exist, so create a new Family object fam = new Family(ind.getFamilyID()); } fam.addMember(ind); this.families.put(ind.getFamilyID(),fam); String[] indFamID = new String[2]; indFamID[0] = ind.getFamilyID(); indFamID[1] = ind.getIndividualID(); this.order.add(indFamID); } //start at k=1 to skip header which we just processed above. hminfo = new String[numLines-1][]; for(int k=1;k<numLines;k++){ StringTokenizer tokenizer = new StringTokenizer((String)lines.get(k)); //reading the first line if(colNum < 0){ //only check column number count for the first line colNum = tokenizer.countTokens(); } if(colNum != tokenizer.countTokens()) { //this line has a different number of columns //should send some sort of error message //TODO: add something which stores number of markers for all lines and checks that they're consistent throw new PedFileException("Line number mismatch in input file. line " + (k+1)); } if(tokenizer.hasMoreTokens()){ hminfo[k-1] = new String[2]; for (int skip = 0; skip < numMetaColumns; skip++){ //meta-data crap String s = tokenizer.nextToken().trim(); //get marker name and pos if (skip == 0){ hminfo[k-1][0] = s; } if (skip == 3){ hminfo[k-1][1] = s; } } int index = 0; while(tokenizer.hasMoreTokens()){ ind = ((Family)families.get(((String[])order.elementAt(index))[0])).getMember( ((String[])order.elementAt(index))[1]); String alleles = tokenizer.nextToken(); int allele1=0, allele2=0; if (alleles.substring(0,1).equals("A")){ allele1 = 1; }else if (alleles.substring(0,1).equals("C")){ allele1 = 2; }else if (alleles.substring(0,1).equals("G")){ allele1 = 3; }else if (alleles.substring(0,1).equals("T")){ allele1 = 4; } if (alleles.substring(1,2).equals("A")){ allele2 = 1; }else if (alleles.substring(1,2).equals("C")){ allele2 = 2; }else if (alleles.substring(1,2).equals("G")){ allele2 = 3; }else if (alleles.substring(1,2).equals("T")){ allele2 = 4; } byte[] markers = new byte[2]; markers[0] = (byte)allele1; markers[1]= (byte)allele2; ind.addMarker(markers); index++; } } } }
if ( model.isErrorColumnProfile(row) )
if ( model.isErrorColumnProfile(row2) )
public TableCellRenderer getCellRenderer(int row, int column) { TableModelSortDecorator t = (TableModelSortDecorator) getModel(); ProfileTableModel model = (ProfileTableModel) t.getTableModel(); int modelColumn = convertColumnIndexToModel(column); ProfileColumn pc = ProfileColumn.values()[modelColumn]; switch(pc) { case DATABASE: case SCHEMA: case CATALOG: case TABLE: case COLUMN: SQLObjectRendererFactory objectRendererFactory = new SQLObjectRendererFactory(); if ( model.isErrorColumnProfile(row) ) objectRendererFactory.setError(true); return objectRendererFactory; case RUNDATE: return new DateRendererFactory(); case PERCENT_UNIQUE: case PERCENT_NULL: return new PercentRendererFactory(); case AVERAGE_LENGTH: return new DecimalRendererFactory(); case MIN_VALUE: case MAX_VALUE: case AVERAGE_VALUE: return new ValueRendererFactory(); case TOP_VALUE: ValueRendererFactory valueRendererFactory = new ValueRendererFactory(); StringBuffer toolTip = new StringBuffer(); List<ColumnValueCount> topNValue = model.getTopNValueAt(row); if ( topNValue != null ) { toolTip.append("<html><table>"); for ( ColumnValueCount v : topNValue ) { toolTip.append("<tr>"); toolTip.append("<td align=\"left\">"); if ( v.getValue() == null ) { toolTip.append("null"); } else { toolTip.append(v.getValue().toString()); } toolTip.append("</td>"); toolTip.append("<td>&nbsp;&nbsp;&nbsp;</td>"); toolTip.append("<td align=\"right\">"); toolTip.append(v.getCount()); toolTip.append("</td>"); toolTip.append("</tr>"); } toolTip.append("</table></html>"); valueRendererFactory.setToolTipText(toolTip.toString()); } return valueRendererFactory; default: return super.getCellRenderer(row, column); } }
List<ColumnValueCount> topNValue = model.getTopNValueAt(row);
List<ColumnValueCount> topNValue = model.getTopNValueAt(row2);
public TableCellRenderer getCellRenderer(int row, int column) { TableModelSortDecorator t = (TableModelSortDecorator) getModel(); ProfileTableModel model = (ProfileTableModel) t.getTableModel(); int modelColumn = convertColumnIndexToModel(column); ProfileColumn pc = ProfileColumn.values()[modelColumn]; switch(pc) { case DATABASE: case SCHEMA: case CATALOG: case TABLE: case COLUMN: SQLObjectRendererFactory objectRendererFactory = new SQLObjectRendererFactory(); if ( model.isErrorColumnProfile(row) ) objectRendererFactory.setError(true); return objectRendererFactory; case RUNDATE: return new DateRendererFactory(); case PERCENT_UNIQUE: case PERCENT_NULL: return new PercentRendererFactory(); case AVERAGE_LENGTH: return new DecimalRendererFactory(); case MIN_VALUE: case MAX_VALUE: case AVERAGE_VALUE: return new ValueRendererFactory(); case TOP_VALUE: ValueRendererFactory valueRendererFactory = new ValueRendererFactory(); StringBuffer toolTip = new StringBuffer(); List<ColumnValueCount> topNValue = model.getTopNValueAt(row); if ( topNValue != null ) { toolTip.append("<html><table>"); for ( ColumnValueCount v : topNValue ) { toolTip.append("<tr>"); toolTip.append("<td align=\"left\">"); if ( v.getValue() == null ) { toolTip.append("null"); } else { toolTip.append(v.getValue().toString()); } toolTip.append("</td>"); toolTip.append("<td>&nbsp;&nbsp;&nbsp;</td>"); toolTip.append("<td align=\"right\">"); toolTip.append(v.getCount()); toolTip.append("</td>"); toolTip.append("</tr>"); } toolTip.append("</table></html>"); valueRendererFactory.setToolTipText(toolTip.toString()); } return valueRendererFactory; default: return super.getCellRenderer(row, column); } }
toolTip.append("<td align=\"right\">");
toolTip.append("<td align=\"right\"><b>[");
public TableCellRenderer getCellRenderer(int row, int column) { TableModelSortDecorator t = (TableModelSortDecorator) getModel(); ProfileTableModel model = (ProfileTableModel) t.getTableModel(); int modelColumn = convertColumnIndexToModel(column); ProfileColumn pc = ProfileColumn.values()[modelColumn]; switch(pc) { case DATABASE: case SCHEMA: case CATALOG: case TABLE: case COLUMN: SQLObjectRendererFactory objectRendererFactory = new SQLObjectRendererFactory(); if ( model.isErrorColumnProfile(row) ) objectRendererFactory.setError(true); return objectRendererFactory; case RUNDATE: return new DateRendererFactory(); case PERCENT_UNIQUE: case PERCENT_NULL: return new PercentRendererFactory(); case AVERAGE_LENGTH: return new DecimalRendererFactory(); case MIN_VALUE: case MAX_VALUE: case AVERAGE_VALUE: return new ValueRendererFactory(); case TOP_VALUE: ValueRendererFactory valueRendererFactory = new ValueRendererFactory(); StringBuffer toolTip = new StringBuffer(); List<ColumnValueCount> topNValue = model.getTopNValueAt(row); if ( topNValue != null ) { toolTip.append("<html><table>"); for ( ColumnValueCount v : topNValue ) { toolTip.append("<tr>"); toolTip.append("<td align=\"left\">"); if ( v.getValue() == null ) { toolTip.append("null"); } else { toolTip.append(v.getValue().toString()); } toolTip.append("</td>"); toolTip.append("<td>&nbsp;&nbsp;&nbsp;</td>"); toolTip.append("<td align=\"right\">"); toolTip.append(v.getCount()); toolTip.append("</td>"); toolTip.append("</tr>"); } toolTip.append("</table></html>"); valueRendererFactory.setToolTipText(toolTip.toString()); } return valueRendererFactory; default: return super.getCellRenderer(row, column); } }
toolTip.append("</td>");
toolTip.append("]</td>");
public TableCellRenderer getCellRenderer(int row, int column) { TableModelSortDecorator t = (TableModelSortDecorator) getModel(); ProfileTableModel model = (ProfileTableModel) t.getTableModel(); int modelColumn = convertColumnIndexToModel(column); ProfileColumn pc = ProfileColumn.values()[modelColumn]; switch(pc) { case DATABASE: case SCHEMA: case CATALOG: case TABLE: case COLUMN: SQLObjectRendererFactory objectRendererFactory = new SQLObjectRendererFactory(); if ( model.isErrorColumnProfile(row) ) objectRendererFactory.setError(true); return objectRendererFactory; case RUNDATE: return new DateRendererFactory(); case PERCENT_UNIQUE: case PERCENT_NULL: return new PercentRendererFactory(); case AVERAGE_LENGTH: return new DecimalRendererFactory(); case MIN_VALUE: case MAX_VALUE: case AVERAGE_VALUE: return new ValueRendererFactory(); case TOP_VALUE: ValueRendererFactory valueRendererFactory = new ValueRendererFactory(); StringBuffer toolTip = new StringBuffer(); List<ColumnValueCount> topNValue = model.getTopNValueAt(row); if ( topNValue != null ) { toolTip.append("<html><table>"); for ( ColumnValueCount v : topNValue ) { toolTip.append("<tr>"); toolTip.append("<td align=\"left\">"); if ( v.getValue() == null ) { toolTip.append("null"); } else { toolTip.append(v.getValue().toString()); } toolTip.append("</td>"); toolTip.append("<td>&nbsp;&nbsp;&nbsp;</td>"); toolTip.append("<td align=\"right\">"); toolTip.append(v.getCount()); toolTip.append("</td>"); toolTip.append("</tr>"); } toolTip.append("</table></html>"); valueRendererFactory.setToolTipText(toolTip.toString()); } return valueRendererFactory; default: return super.getCellRenderer(row, column); } }
return super.getCellRenderer(row, column);
return super.getCellRenderer(row2, column);
public TableCellRenderer getCellRenderer(int row, int column) { TableModelSortDecorator t = (TableModelSortDecorator) getModel(); ProfileTableModel model = (ProfileTableModel) t.getTableModel(); int modelColumn = convertColumnIndexToModel(column); ProfileColumn pc = ProfileColumn.values()[modelColumn]; switch(pc) { case DATABASE: case SCHEMA: case CATALOG: case TABLE: case COLUMN: SQLObjectRendererFactory objectRendererFactory = new SQLObjectRendererFactory(); if ( model.isErrorColumnProfile(row) ) objectRendererFactory.setError(true); return objectRendererFactory; case RUNDATE: return new DateRendererFactory(); case PERCENT_UNIQUE: case PERCENT_NULL: return new PercentRendererFactory(); case AVERAGE_LENGTH: return new DecimalRendererFactory(); case MIN_VALUE: case MAX_VALUE: case AVERAGE_VALUE: return new ValueRendererFactory(); case TOP_VALUE: ValueRendererFactory valueRendererFactory = new ValueRendererFactory(); StringBuffer toolTip = new StringBuffer(); List<ColumnValueCount> topNValue = model.getTopNValueAt(row); if ( topNValue != null ) { toolTip.append("<html><table>"); for ( ColumnValueCount v : topNValue ) { toolTip.append("<tr>"); toolTip.append("<td align=\"left\">"); if ( v.getValue() == null ) { toolTip.append("null"); } else { toolTip.append(v.getValue().toString()); } toolTip.append("</td>"); toolTip.append("<td>&nbsp;&nbsp;&nbsp;</td>"); toolTip.append("<td align=\"right\">"); toolTip.append(v.getCount()); toolTip.append("</td>"); toolTip.append("</tr>"); } toolTip.append("</table></html>"); valueRendererFactory.setToolTipText(toolTip.toString()); } return valueRendererFactory; default: return super.getCellRenderer(row, column); } }
public void doTag(XMLOutput output) throws Exception {
public void doTag(XMLOutput output) throws JellyTagException {
public void doTag(XMLOutput output) throws Exception { calledCreatepath = false; calledSetClasspath = false; invokeBody(output); if (! calledCreatepath) { throw new AssertionFailedError("call to createClasspath() was not made"); } if (! calledSetClasspath) { throw new AssertionFailedError("call to setClasspath() was not made"); } log.info( "Called with classpath: " + classpath ); if (var != null) { context.setVariable(var, classpath); } }
for (int j = i+1; j < dPrime.getLength(i); j++){
for (int j = i+1; j < i + dPrime.getLength(i); j++){
public void colorDPrime(int scheme){ currentScheme = scheme; DPrimeTable dPrime = theData.dpTable; noImage = true; if (scheme == STD_SCHEME){ // set coloring based on LOD and D' for (int i = 0; i < Chromosome.getSize()-1; i++){ for (int j = i+1; j < dPrime.getLength(i)+i; j++){ PairwiseLinkage thisPair = dPrime.getLDStats(i,j); if (thisPair == null){ continue; } double d = thisPair.getDPrime(); double l = thisPair.getLOD(); Color boxColor = null; if (l > 2) { if (d < 0.5) { //high LOD, low D' boxColor = new Color(255, 224, 224); } else { //high LOD, high D' shades of red double blgr = (255-32)*2*(1-d); boxColor = new Color(255, (int) blgr, (int) blgr); //boxColor = new Color(224, (int) blgr, (int) blgr); } } else if (d > 0.99) { //high D', low LOD blueish color boxColor = new Color(192, 192, 240); } else { //no LD boxColor = Color.white; } thisPair.setColor(boxColor); } } }else if (scheme == SFS_SCHEME){ for (int x = 0; x < Chromosome.getSize()-1; x++){ for (int y = x+1; y < Chromosome.getSize(); y++){ PairwiseLinkage thisPair = dPrime.getLDStats(x,y); if (thisPair == null){ continue; } //get the right bits double lowCI = thisPair.getConfidenceLow(); double highCI = thisPair.getConfidenceHigh(); //color in squares if (lowCI >= FindBlocks.cutLowCI && highCI >= FindBlocks.cutHighCI) { thisPair.setColor(Color.darkGray); //strong LD }else if (highCI >= FindBlocks.recHighCI) { thisPair.setColor(Color.lightGray); //uninformative } else { thisPair.setColor(Color.white); //recomb } } } }else if (scheme == GAM_SCHEME){ for (int x = 0; x < Chromosome.getSize()-1; x++){ for (int y = x+1; y < Chromosome.getSize(); y++){ PairwiseLinkage thisPair = dPrime.getLDStats(x,y); if (thisPair == null) { continue; } double[] freqs = thisPair.getFreqs(); int numGam = 0; for (int i = 0; i < freqs.length; i++){ //add a little bump for EM probs which should be zero but are really like 10^-10 if (freqs[i] > FindBlocks.fourGameteCutoff + 1E-8) numGam++; } //color in squares if(numGam > 3){ thisPair.setColor(Color.white); }else{ thisPair.setColor(Color.darkGray); } } } }else if (scheme == WMF_SCHEME){ // set coloring based on LOD and D', but without (arbitrary) cutoffs to introduce // "color damage" (Tufte) // first get the maximum LOD score so we can scale relative to that. double max_l = 0.0; for (int i = 0; i < Chromosome.getSize(); i++){ for (int j = i+1; j < dPrime.getLength(i); j++){ PairwiseLinkage thisPair = dPrime.getLDStats(i,j); if (thisPair == null){ continue; } if (thisPair.getLOD() > max_l) max_l = thisPair.getLOD(); } } // cap the max LOD score if (max_l > 5.0) max_l = 5.0; for (int i = 0; i < Chromosome.getSize(); i++){ for (int j = i+1; j < dPrime.getLength(i); j++){ PairwiseLinkage thisPair = dPrime.getLDStats(i,j); if (thisPair == null){ continue; } double d = thisPair.getDPrime(); double l = thisPair.getLOD(); Color boxColor = null; double lod_scale = l / max_l; // if greater than the cap, call it the cap if (lod_scale > 1.0) lod_scale = 1.0; // there can be negative LOD scores, apparently if (lod_scale < 0.0) lod_scale = 0.0; // also, scale the D' so anything under .2 is white. d = (1.0 / 0.8) * (d - 0.2); if (d < 0.0) d = 0.0; // if there is low(er) D' but big LOD score, this should be in a gray scale // scaled to the D' value if (lod_scale > d) { lod_scale = d; } int r, g, b; // r = (int)(200.0 * d + 55.0 * lod_scale); // g = (int)(255.0 * d - 255.0 * lod_scale); // b = (int)(255.0 * d - 255.0 * lod_scale); double ap, cp, dp, ep, jp, kp; ap = 0.0; cp = -255.0; dp = -55.0; ep = -200.0; jp = 255.0; kp = 255.0; r = (int)(ap * d + cp * lod_scale + jp); g = b = (int)(dp * d + ep * lod_scale + kp); if (r < 0) r = 0; if (g < 0) g = 0; if (b < 0) b = 0; boxColor = new Color(r, g, b); thisPair.setColor(boxColor); } } }else if (scheme == RSQ_SCHEME){ // set coloring based on R-squared values for (int i = 0; i < Chromosome.getSize(); i++){ for (int j = i+1; j < dPrime.getLength(i); j++){ PairwiseLinkage thisPair = dPrime.getLDStats(i,j); if (thisPair == null){ continue; } double rsq = thisPair.getRSquared(); Color boxColor = null; int r, g, b; r = g = b = (int)(255.0 * (1.0 - rsq)); boxColor = new Color(r, g, b); thisPair.setColor(boxColor); } } } }
doColumnProfile(table.getColumns(), conn);
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; TableProfileResult tableResult = new TableProfileResult(System.currentTimeMillis()); try { conn = db.getConnection(); String databaseIdentifierQuoteString = null; /* DatabaseMetaData dbmd = conn.getMetaData(); rs = dbmd.getTypeInfo(); while (rs.next()) { System.out.println("name="+rs.getString(1)+" type:"+rs.getInt(2)); } rs.close();*/ databaseIdentifierQuoteString = conn.getMetaData().getIdentifierQuoteString(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*) AS ROW__COUNT"); sql.append("\nFROM "); sql.append(DDLUtils.toQualifiedName(table.getCatalogName(), table.getSchemaName(), table.getName(), databaseIdentifierQuoteString, databaseIdentifierQuoteString)); stmt = conn.createStatement(); stmt.setEscapeProcessing(false); lastSQL = sql.toString(); rs = stmt.executeQuery(lastSQL); if ( rs.next() ) { tableResult.setRowCount(rs.getInt("ROW__COUNT")); } rs.close(); rs = null; doColumnProfile(table.getColumns(), conn); // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); tableResult.setError(true); tableResult.setEx(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); } tableResult.setCreateEndTime(System.currentTimeMillis()); putResult(table, tableResult); } }
tableResult.setCreateEndTime(System.currentTimeMillis()); putResult(table, tableResult);
private void doTableProfile(SQLTable table) throws SQLException, ArchitectException { SQLDatabase db = table.getParentDatabase(); Connection conn = null; Statement stmt = null; ResultSet rs = null; String lastSQL = null; TableProfileResult tableResult = new TableProfileResult(System.currentTimeMillis()); try { conn = db.getConnection(); String databaseIdentifierQuoteString = null; /* DatabaseMetaData dbmd = conn.getMetaData(); rs = dbmd.getTypeInfo(); while (rs.next()) { System.out.println("name="+rs.getString(1)+" type:"+rs.getInt(2)); } rs.close();*/ databaseIdentifierQuoteString = conn.getMetaData().getIdentifierQuoteString(); StringBuffer sql = new StringBuffer(); sql.append("SELECT COUNT(*) AS ROW__COUNT"); sql.append("\nFROM "); sql.append(DDLUtils.toQualifiedName(table.getCatalogName(), table.getSchemaName(), table.getName(), databaseIdentifierQuoteString, databaseIdentifierQuoteString)); stmt = conn.createStatement(); stmt.setEscapeProcessing(false); lastSQL = sql.toString(); rs = stmt.executeQuery(lastSQL); if ( rs.next() ) { tableResult.setRowCount(rs.getInt("ROW__COUNT")); } rs.close(); rs = null; doColumnProfile(table.getColumns(), conn); // XXX: add where filter later } catch (SQLException ex) { logger.error("Error in SQL query: "+lastSQL, ex); tableResult.setError(true); tableResult.setEx(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); } tableResult.setCreateEndTime(System.currentTimeMillis()); putResult(table, tableResult); } }
colResult.setAvgLength(rs.getInt(columnName));
colResult.setAvgLength(rs.getDouble(columnName));
private ColumnProfileResult execProfileFunction(ProfileFunctionDescriptor pfd, SQLColumn col, DDLGenerator ddlg, Connection conn) throws SQLException { long createStartTime = System.currentTimeMillis(); int i = 0; StringBuffer sql = new StringBuffer(); Statement stmt = null; ResultSet rs = null; String lastSQL = null; String columnName = null; String databaseIdentifierQuoteString = null; try { databaseIdentifierQuoteString = conn.getMetaData().getIdentifierQuoteString(); sql.append("SELECT 1"); if (findingDistinctCount && pfd.isCountDist() ) { sql.append(",\n COUNT(DISTINCT \""); sql.append(col.getName()); sql.append("\") AS DISTINCTCOUNT_"+i); } if (findingMin && pfd.isMinValue() ) { sql.append(",\n MIN(\""); sql.append(col.getName()); sql.append("\") AS MINVALUE_"+i); } if (findingMax && pfd.isMaxValue() ) { sql.append(",\n MAX(\""); sql.append(col.getName()); sql.append("\") AS MAXVALUE_"+i); } if (findingAvg && pfd.isAvgValue() ) { sql.append(",\n "); sql.append(ddlg.getAverageSQLFunctionName("\""+col.getName()+"\"")); sql.append(" AS AVGVALUE_"+i); } if (findingMinLength && pfd.isMinLength() ) { sql.append(",\n MIN("); sql.append(ddlg.getStringLengthSQLFunctionName("\""+col.getName()+"\"")); sql.append(") AS MINLENGTH_"+i); } if (findingMaxLength && pfd.isMaxLength() ) { sql.append(",\n MAX("); sql.append(ddlg.getStringLengthSQLFunctionName("\""+col.getName()+"\"")); sql.append(") AS MAXLENGTH_"+i); } if (findingAvgLength && pfd.isAvgLength() ) { sql.append(",\n AVG("); sql.append(ddlg.getStringLengthSQLFunctionName("\""+col.getName()+"\"")); sql.append(") AS AVGLENGTH_"+i); } if ( findingNullCount && pfd.isSumDecode() ) { sql.append(",\n SUM("); sql.append(ddlg.caseWhen("\""+col.getName()+"\"", "NULL", "1")); sql.append(") AS NULLCOUNT_"+i); } SQLTable table = col.getParentTable(); sql.append("\n FROM "); sql.append(DDLUtils.toQualifiedName(table.getCatalogName(), table.getSchemaName(), table.getName(), databaseIdentifierQuoteString, databaseIdentifierQuoteString)); stmt = conn.createStatement(); stmt.setEscapeProcessing(false); lastSQL = sql.toString(); rs = stmt.executeQuery(lastSQL); ColumnProfileResult colResult = new ColumnProfileResult(createStartTime); if ( rs.next() ) { if (findingDistinctCount && pfd.isCountDist() ) { columnName = "DISTINCTCOUNT_"+i; colResult.setDistinctValueCount(rs.getInt(columnName)); } if (findingMin && pfd.isMinValue() ) { columnName = "MINVALUE_"+i; colResult.setMinValue(rs.getObject(columnName)); } if (findingMax && pfd.isMaxValue() ) { columnName = "MAXVALUE_"+i; colResult.setMaxValue(rs.getObject(columnName)); } if (findingAvg && pfd.isAvgValue() ) { columnName = "AVGVALUE_"+i; colResult.setAvgValue(rs.getObject(columnName)); } if (findingMinLength && pfd.isMinLength() ) { columnName = "MINLENGTH_"+i; colResult.setMinLength(rs.getInt(columnName)); } if (findingMaxLength && pfd.isMaxLength() ) { columnName = "MAXLENGTH_"+i; colResult.setMaxLength(rs.getInt(columnName)); } if (findingAvgLength && pfd.isAvgLength() ) { columnName = "AVGLENGTH_"+i; colResult.setAvgLength(rs.getInt(columnName)); } if ( findingNullCount && pfd.isSumDecode() ) { columnName = "NULLCOUNT_"+i; colResult.setNullCount(rs.getInt(columnName)); } } else { throw new IllegalStateException("Query executed, but returns no rows:\n" + lastSQL + "\nColumn Name: " + columnName ); } rs.close(); rs = null; if (findingTopTen && pfd.isCountDist() ) { sql = new StringBuffer(); sql.append("SELECT ").append(databaseIdentifierQuoteString); sql.append(col.getName()).append(databaseIdentifierQuoteString); sql.append(" AS MYVALUE, COUNT(*) AS COUNT1 FROM "); sql.append(DDLUtils.toQualifiedName(table.getCatalogName(), table.getSchemaName(), table.getName(), databaseIdentifierQuoteString, databaseIdentifierQuoteString)); sql.append(" GROUP BY ").append(databaseIdentifierQuoteString); sql.append(col.getName()).append(databaseIdentifierQuoteString); sql.append(" ORDER BY COUNT1 DESC"); lastSQL = sql.toString(); rs = stmt.executeQuery(lastSQL); for ( int n=0; rs.next() && n < topNCount; n++ ) { colResult.addValueCount(rs.getObject("MYVALUE"), rs.getInt("COUNT1")); } } colResult.setCreateEndTime(System.currentTimeMillis()); return colResult; } finally { try { if (rs != null) rs.close(); if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("Couldn't clean up result set", ex); } } }
String[] inputArray = new String[2];
String[] inputArray = new String[3];
public static void main(String[] args) { //set defaults Options.setTaggerRsqCutoff(Tagger.DEFAULT_RSQ_CUTOFF); Options.setTaggerLODCutoff(Tagger.DEFAULT_LOD_CUTOFF); 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); Options.setgBrowseOpts(GB_DEFAULT_OPTS); Options.setgBrowseTypes(GB_DEFAULT_TYPES); //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.put("EditorPane.selectionBackground",Color.lightGray); 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(); try { uc.checkForUpdate(); } catch(IOException ioe) { //this means we couldnt connect but we want it to die quietly } 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 java.util.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_FILE); }else if (argParser.getPedFileName() != null){ inputArray[0] = argParser.getPedFileName(); inputArray[1] = argParser.getInfoFileName(); window.readGenotypes(inputArray, PED_FILE); }else if (argParser.getHapmapFileName() != null){ inputArray[0] = argParser.getHapmapFileName(); inputArray[1] = null; window.readGenotypes(inputArray, HMP_FILE); }else{ ReadDataDialog readDialog = new ReadDataDialog("Welcome to HaploView", window); readDialog.pack(); readDialog.setVisible(true); } } }
inputArray[2] = null;
public static void main(String[] args) { //set defaults Options.setTaggerRsqCutoff(Tagger.DEFAULT_RSQ_CUTOFF); Options.setTaggerLODCutoff(Tagger.DEFAULT_LOD_CUTOFF); 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); Options.setgBrowseOpts(GB_DEFAULT_OPTS); Options.setgBrowseTypes(GB_DEFAULT_TYPES); //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.put("EditorPane.selectionBackground",Color.lightGray); 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(); try { uc.checkForUpdate(); } catch(IOException ioe) { //this means we couldnt connect but we want it to die quietly } 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 java.util.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_FILE); }else if (argParser.getPedFileName() != null){ inputArray[0] = argParser.getPedFileName(); inputArray[1] = argParser.getInfoFileName(); window.readGenotypes(inputArray, PED_FILE); }else if (argParser.getHapmapFileName() != null){ inputArray[0] = argParser.getHapmapFileName(); inputArray[1] = null; window.readGenotypes(inputArray, HMP_FILE); }else{ ReadDataDialog readDialog = new ReadDataDialog("Welcome to HaploView", window); readDialog.pack(); readDialog.setVisible(true); } } }