rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
usedParents.add(mom); usedParents.add(dad);
private void buildParenTDTTrioSet(PedFile pf, Vector permuteInd, TreeSet snpsToBeTested) throws PedFileException{ Vector results = new Vector(); Vector indList = pf.getAllIndividuals(); if(permuteInd == null || permuteInd.size() != indList.size()) { permuteInd = new Vector(); for (int i = 0; i < indList.size(); i++){ permuteInd.add(new Boolean(false)); } } //todo: need to make sure each set of parents only used once int numMarkers = Chromosome.getUnfilteredSize(); for (int i = 0; i < numMarkers; i++){ SNP currentMarker = Chromosome.getUnfilteredMarker(i); if (snpsToBeTested.contains(currentMarker)){ int discordantNotTallied=0; int discordantTallied = 0; Individual currentInd; Family currentFam; HashSet usedParents = new HashSet(); AssociationResult.TallyTrio tt = new AssociationResult.TallyTrio(); for (int j = 0; j < indList.size(); j++){ currentInd = (Individual)indList.elementAt(j); currentFam = pf.getFamily(currentInd.getFamilyID()); if (currentFam.containsMember(currentInd.getMomID()) && currentFam.containsMember(currentInd.getDadID()) && currentInd.getAffectedStatus() == 2){ //if he has both parents, and is affected, we can get a transmission Individual mom = currentFam.getMember(currentInd.getMomID()); Individual dad = currentFam.getMember(currentInd.getDadID()); if(usedParents.contains(mom) || usedParents.contains(dad)) { continue; } if(currentInd.getZeroed(i) || dad.getZeroed(i) || mom.getZeroed(i)) { continue; } byte kid1 = currentInd.getMarkerA(i); byte kid2 = currentInd.getMarkerB(i); byte dad1 = dad.getMarkerA(i); byte dad2 = dad.getMarkerB(i); byte mom1 = mom.getMarkerA(i); byte mom2 = mom.getMarkerB(i); byte momT=0, momU=0, dadT=0, dadU=0; if (kid1 == 0 || kid2 == 0 || dad1 == 0 || dad2 == 0 || mom1 == 0 || mom2 == 0) { continue; } else if (kid1 == kid2) { //kid homozygous if (dad1 == kid1) { dadT = dad1; dadU = dad2; } else { dadT = dad2; dadU = dad1; } if (mom1 == kid1) { momT = mom1; momU = mom2; } else { momT = mom2; momU = mom1; } } else { if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadT = dad1; dadU = dad2; if (kid1 == dad1) { momT = kid2; momU = kid1; } else { momT = kid1; momU = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momT = mom1; momU = mom2; if (kid1 == mom1) { dadT = kid2; dadU = kid1; } else { dadT = kid1; dadU = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadT = dad1; dadU = dad1; momT = mom1; momU = mom1; } else { //everybody het dadT = (byte)(4+dad1); dadU = (byte)(4+dad2); momT = (byte)(4+mom1); momU = (byte)(4+mom2); } } if(((Boolean)permuteInd.get(j)).booleanValue()) { tt.tallyTrioInd(dadU, dadT); tt.tallyTrioInd(momU, momT); } else { tt.tallyTrioInd(dadT, dadU); tt.tallyTrioInd(momT, momU); } if(mom.getAffectedStatus() != dad.getAffectedStatus()) { //discordant parental phenotypes if(!(dad1 == mom1 && dad2 == mom2) && !(dad1 == mom2 && dad2 == mom1)) { if(mom.getAffectedStatus() == 2) { tt.tallyDiscordantParents(momT,momU,dadT,dadU); } else if(dad.getAffectedStatus() == 2) { tt.tallyDiscordantParents(dadT,dadU,momT,momU); } discordantTallied++; }else { discordantNotTallied++; } } usedParents.add(mom); usedParents.add(dad); } } int[] g1 = {tt.allele1}; int[] g2 = {tt.allele2}; int[] m = {i}; Haplotype thisSNP1 = new Haplotype(g1, 0, m, null); thisSNP1.setTransCount(tt.counts[0][0]); thisSNP1.setUntransCount(tt.counts[1][0]); thisSNP1.setDiscordantAlleleCounts(tt.discordantAlleleCounts); Haplotype thisSNP2 = new Haplotype(g2, 0, m, null); thisSNP2.setTransCount(tt.counts[0][1]); thisSNP2.setUntransCount(tt.counts[1][1]); thisSNP2.setDiscordantAlleleCounts(tt.getDiscordantCountsAllele2()); Haplotype[] daBlock = {thisSNP1, thisSNP2}; results.add(new MarkerAssociationResult(daBlock, currentMarker.getName(), currentMarker)); } } this.results = results; }
if(currentInd.getZeroed(i) || dad.getZeroed(i) || mom.getZeroed(i)) { continue; } byte kid1 = currentInd.getMarkerA(i); byte kid2 = currentInd.getMarkerB(i); byte dad1 = dad.getMarkerA(i); byte dad2 = dad.getMarkerB(i); byte mom1 = mom.getMarkerA(i); byte mom2 = mom.getMarkerB(i);
if(currentInd.getZeroed(i) || dad.getZeroed(i) || mom.getZeroed(i)) { continue; } byte[] thisMarker = currentInd.getMarker(i); byte kid1 = thisMarker[0]; byte kid2 = thisMarker[1]; thisMarker = dad.getMarker(i); byte dad1 = thisMarker[0]; byte dad2 = thisMarker[1]; thisMarker = mom.getMarker(i); byte mom1 = thisMarker[0]; byte mom2 = thisMarker[1];
private void buildTrioSet(PedFile pf, Vector permuteInd, TreeSet snpsToBeTested) throws PedFileException{ Vector results = new Vector(); Vector indList = pf.getAllIndividuals(); if(permuteInd == null || permuteInd.size() != indList.size()) { permuteInd = new Vector(); for (int i = 0; i < indList.size(); i++){ permuteInd.add(new Boolean(false)); } } int numMarkers = Chromosome.getUnfilteredSize(); for (int i = 0; i < numMarkers; i++){ SNP currentMarker = Chromosome.getUnfilteredMarker(i); if (snpsToBeTested.contains(currentMarker)){ Individual currentInd; Family currentFam; AssociationResult.TallyTrio tt = new AssociationResult.TallyTrio(); for (int j = 0; j < indList.size(); j++){ currentInd = (Individual)indList.elementAt(j); currentFam = pf.getFamily(currentInd.getFamilyID()); if (currentFam.containsMember(currentInd.getMomID()) && currentFam.containsMember(currentInd.getDadID()) && currentInd.getAffectedStatus() == 2){ //if he has both parents, and is affected, we can get a transmission Individual mom = currentFam.getMember(currentInd.getMomID()); Individual dad = currentFam.getMember(currentInd.getDadID()); if(currentInd.getZeroed(i) || dad.getZeroed(i) || mom.getZeroed(i)) { continue; } byte kid1 = currentInd.getMarkerA(i); byte kid2 = currentInd.getMarkerB(i); byte dad1 = dad.getMarkerA(i); byte dad2 = dad.getMarkerB(i); byte mom1 = mom.getMarkerA(i); byte mom2 = mom.getMarkerB(i); byte momT=0, momU=0, dadT=0, dadU=0; if (kid1 == 0 || kid2 == 0 || dad1 == 0 || dad2 == 0 || mom1 == 0 || mom2 == 0) { continue; } else if (kid1 == kid2) { //kid homozygous if (dad1 == kid1) { dadT = dad1; dadU = dad2; } else { dadT = dad2; dadU = dad1; } if (mom1 == kid1) { momT = mom1; momU = mom2; } else { momT = mom2; momU = mom1; } } else { if (dad1 == dad2 && mom1 != mom2) { //dad hom mom het dadT = dad1; dadU = dad2; if (kid1 == dad1) { momT = kid2; momU = kid1; } else { momT = kid1; momU = kid2; } } else if (mom1 == mom2 && dad1 != dad2) { //dad het mom hom momT = mom1; momU = mom2; if (kid1 == mom1) { dadT = kid2; dadU = kid1; } else { dadT = kid1; dadU = kid2; } } else if (dad1 == dad2 && mom1 == mom2) { //mom & dad hom dadT = dad1; dadU = dad1; momT = mom1; momU = mom1; } else { //everybody het dadT = (byte)(4+dad1); dadU = (byte)(4+dad2); momT = (byte)(4+mom1); momU = (byte)(4+mom2); } } if(((Boolean)permuteInd.get(j)).booleanValue()) { tt.tallyTrioInd(dadU, dadT); tt.tallyTrioInd(momU, momT); } else { tt.tallyTrioInd(dadT, dadU); tt.tallyTrioInd(momT, momU); } } } int[] g1 = {tt.allele1}; int[] g2 = {tt.allele2}; int[] m = {i}; Haplotype thisSNP1 = new Haplotype(g1, 0, m, null); thisSNP1.setTransCount(tt.counts[0][0]); thisSNP1.setUntransCount(tt.counts[1][0]); Haplotype thisSNP2 = new Haplotype(g2, 0, m, null); thisSNP2.setTransCount(tt.counts[0][1]); thisSNP2.setUntransCount(tt.counts[1][1]); Haplotype[] daBlock = {thisSNP1, thisSNP2}; results.add(new MarkerAssociationResult(daBlock, currentMarker.getName(), currentMarker)); } } this.results = results; }
Object o = britr.next(); if(o != null) { HaplotypeAssociationResult har = (HaplotypeAssociationResult) o; res.add(har); }
HaplotypeAssociationResult har = (HaplotypeAssociationResult) britr.next(); res.add(har);
public void runFileTests(HaploData theData, Vector inputSNPResults) throws HaploViewException { Vector res = new Vector(); if(tests == null || theData == null) { return; } Vector blocks = new Vector(); Vector names = new Vector(); Vector alleles = new Vector(); Hashtable blockHash = new Hashtable(); int multiMarkerTestcount =0; for(int i=0;i<tests.size();i++) { //first go through and get all the multimarker tests to package up to hand to theData.generateHaplotypes() AssociationTest currentTest = (AssociationTest) tests.get(i); if(currentTest.getNumMarkers() > 1) { names.add(currentTest.getName()); alleles.add(currentTest.getAllele()); if(!blockHash.containsKey(currentTest)){ blocks.add(currentTest.getFilteredMarkerArray()); blockHash.put(currentTest,new Integer(blocks.size()-1)); } multiMarkerTestcount++; } } this.filterAlleles = alleles; System.out.println("blocks.size() = " + blocks.size()); Haplotype[][] blockHaps = theData.generateHaplotypes(blocks, permTests); System.out.println("blockHaps.length = " + blockHaps.length); Haplotype[][] realBlockHaps = new Haplotype[multiMarkerTestcount][]; int multiMarkerCountTemp=0; for(int i=0;i<tests.size();i++) { AssociationTest currentTest = (AssociationTest) tests.get(i); if(currentTest.getNumMarkers() > 1) { realBlockHaps[multiMarkerCountTemp] = blockHaps[((Integer)blockHash.get(currentTest)).intValue()]; multiMarkerCountTemp++; } } Vector blockResults = new AssociationTestSet(realBlockHaps, names, alleles).getResults(); Iterator britr = blockResults.iterator(); for (int i = 0; i < tests.size(); i++){ AssociationTest currentTest = (AssociationTest) tests.get(i); if(currentTest.getNumMarkers() > 1) { //grab the next block result from above /*HaplotypeAssociationResult har = (HaplotypeAssociationResult) britr.next(); res.add(har);*/ Object o = britr.next(); if(o != null) { //grab the next block result from above HaplotypeAssociationResult har = (HaplotypeAssociationResult) o; res.add(har); } }else if (currentTest.getNumMarkers() == 1){ //grab appropriate single marker result. res.add(inputSNPResults.get(currentTest.getMarkerArray()[0])); } } results = res; }
if (r.pkTable == null) { logger.error("addImportedRelationshipsToTable: Couldn't find exporting table " +rs.getString(1)+"."+rs.getString(2)+"."+rs.getString(3) +" in target database!"); continue; }
static void addImportedRelationshipsToTable(SQLTable table) throws ArchitectException { SQLDatabase db = table.getParentDatabase(); if (!db.isPopulated()) { throw new ArchitectException("relationship.unpopulatedTargetDatabase"); } Connection con = db.getConnection(); ResultSet rs = null; try { DatabaseMetaData dbmd = con.getMetaData(); SQLRelationship r = null; int currentKeySeq; LinkedList newKeys = new LinkedList(); rs = dbmd.getImportedKeys(table.getCatalogName(), table.getSchemaName(), table.getTableName()); while (rs.next()) { currentKeySeq = rs.getInt(9); if (currentKeySeq == 1) { r = new SQLRelationship(); newKeys.add(r); } ColumnMapping m = new ColumnMapping(); m.parent = r; r.children.add(m); r.pkTable = db.getTableByName(rs.getString(1), // catalog rs.getString(2), // schema rs.getString(3)); // table logger.debug("Looking for pk column '"+rs.getString(4)+"' in table '"+r.pkTable+"'"); m.pkColumn = r.pkTable.getColumnByName(rs.getString(4)); if (m.pkColumn == null) { throw new ArchitectException("relationship.populate.nullPkColumn"); } r.fkTable = db.getTableByName(rs.getString(5), // catalog rs.getString(6), // schema rs.getString(7)); // table if (r.fkTable != table) { throw new IllegalStateException("fkTable did not match requested table"); } m.fkColumn = r.fkTable.getColumnByName(rs.getString(8)); if (m.fkColumn == null) { throw new ArchitectException("relationship.populate.nullFkColumn"); } // column 9 (currentKeySeq) handled above r.updateRule = rs.getInt(10); r.deleteRule = rs.getInt(11); r.name = rs.getString(12); r.deferrability = rs.getInt(14); } // now that all the new SQLRelationship objects are set up, add them to their tables Iterator it = newKeys.iterator(); while (it.hasNext()) { r = (SQLRelationship) it.next(); r.pkTable.columnsFolder.addSQLObjectListener(r.fkColumnManager); r.pkTable.addExportedKey(r); logger.debug("Added exported key to "+r.pkTable.getName()); r.fkTable.addImportedKey(r); logger.debug("Added imported key to "+r.fkTable.getName()); } } catch (SQLException e) { throw new ArchitectException("relationship.populate", e); } finally { try { if (rs != null) rs.close(); } catch (SQLException e) { logger.warn("Couldn't close resultset", e); } } }
String text = textScript.getText(); text = text.trim(); textScript.setText(text);
textScript.trimWhitespace();
protected void trimBody() { if ( body instanceof ScriptBlock ) { ScriptBlock block = (ScriptBlock) body; List list = block.getScriptList(); for ( int i = list.size() - 1; i >= 0; i-- ) { Script script = (Script) list.get(i); if ( script instanceof TextScript ) { TextScript textScript = (TextScript) script; String text = textScript.getText(); text = text.trim(); if ( text.length() == 0 ) { list.remove(i); } else { textScript.setText(text); } } } } else if ( body instanceof TextScript ) { TextScript textScript = (TextScript) body; String text = textScript.getText(); text = text.trim(); textScript.setText(text); } this.hasTrimmed = true; }
String shortHapInputFileName;
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); String shortHapInputFileName; if (command == READ_GENOTYPES){ ReadDataDialog readDialog = new ReadDataDialog("Open new data", this); readDialog.pack(); readDialog.setVisible(true); /**if (command == "Open Linkage File"){ fc.setSelectedFile(null); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { shortHapInputFileName = fc.getSelectedFile().getName(); try{ hapInputFileName = fc.getSelectedFile().getCanonicalPath(); }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } //pop open checkdata window checkWindow = new JFrame(); checkPanel = new CheckDataPanel(fc.getSelectedFile()); checkWindow.setTitle("Checking markers..."+shortHapInputFileName); JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JButton checkContinueButton = new JButton("Continue"); checkContinueButton.addActionListener(this); checkPanel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(checkPanel); checkContinueButton.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(checkContinueButton); JLabel infoLabel = new JLabel("(this will create a haplotype file named " + shortHapInputFileName + ".haps)"); infoLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(infoLabel); checkWindow.setContentPane(metaCheckPanel); checkWindow.pack(); if (false){ checkWindow.dispose(); JOptionPane.showMessageDialog(this, "File format error", "File Error", JOptionPane.ERROR_MESSAGE); } checkWindow.setVisible(true); } }else if (command == "Open Haplotype File"){ fc.setSelectedFile(null); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION){ processInput(fc.getSelectedFile()); }**/ }else if (command == "Continue"){ /** JTable table = checkPanel.getTable(); checkWindow.dispose(); boolean[] markerResultArray = new boolean[table.getRowCount()]; for (int i = 0; i < table.getRowCount(); i++){ markerResultArray[i] = ((Boolean)table.getValueAt(i,7)).booleanValue(); } try{ new TextMethods().linkageToHaps(markerResultArray,checkPanel.getPedFile(),hapInputFileName+".haps"); }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } processInput(new File(hapInputFileName+".haps"));**/ } else if (command == READ_MARKERS){ fc.setSelectedFile(null); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { readMarkers(fc.getSelectedFile()); } }else if (command == "Clear All Blocks"){ theBlocks.clearBlocks(); }else if (command == DEFINE_BLOCKS){ defineBlocks(); }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); } } }
theBlocks.clearBlocks();
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); String shortHapInputFileName; if (command == READ_GENOTYPES){ ReadDataDialog readDialog = new ReadDataDialog("Open new data", this); readDialog.pack(); readDialog.setVisible(true); /**if (command == "Open Linkage File"){ fc.setSelectedFile(null); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { shortHapInputFileName = fc.getSelectedFile().getName(); try{ hapInputFileName = fc.getSelectedFile().getCanonicalPath(); }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } //pop open checkdata window checkWindow = new JFrame(); checkPanel = new CheckDataPanel(fc.getSelectedFile()); checkWindow.setTitle("Checking markers..."+shortHapInputFileName); JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JButton checkContinueButton = new JButton("Continue"); checkContinueButton.addActionListener(this); checkPanel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(checkPanel); checkContinueButton.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(checkContinueButton); JLabel infoLabel = new JLabel("(this will create a haplotype file named " + shortHapInputFileName + ".haps)"); infoLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(infoLabel); checkWindow.setContentPane(metaCheckPanel); checkWindow.pack(); if (false){ checkWindow.dispose(); JOptionPane.showMessageDialog(this, "File format error", "File Error", JOptionPane.ERROR_MESSAGE); } checkWindow.setVisible(true); } }else if (command == "Open Haplotype File"){ fc.setSelectedFile(null); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION){ processInput(fc.getSelectedFile()); }**/ }else if (command == "Continue"){ /** JTable table = checkPanel.getTable(); checkWindow.dispose(); boolean[] markerResultArray = new boolean[table.getRowCount()]; for (int i = 0; i < table.getRowCount(); i++){ markerResultArray[i] = ((Boolean)table.getValueAt(i,7)).booleanValue(); } try{ new TextMethods().linkageToHaps(markerResultArray,checkPanel.getPedFile(),hapInputFileName+".haps"); }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } processInput(new File(hapInputFileName+".haps"));**/ } else if (command == READ_MARKERS){ fc.setSelectedFile(null); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { readMarkers(fc.getSelectedFile()); } }else if (command == "Clear All Blocks"){ theBlocks.clearBlocks(); }else if (command == DEFINE_BLOCKS){ defineBlocks(); }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); } } }
String oldCatalog = null;
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(); // This can fail in SS2K because of privelege problems. There is // apparently no way to check if it will fail; you just have to try. try { con.setCatalog(getName()); } catch (SQLException ex) { logger.info("populate: Could not setCatalog("+getName()+"). Assuming it's a permission problem. Stack trace:", ex); return; } rs = dbmd.getSchemas(); while (rs.next()) { String schName = rs.getString(1); SQLSchema schema = null; if (schName != null) { schema = new SQLSchema(this, schName, false); children.add(schema); schema.setNativeTerm(dbmd.getSchemaTerm()); logger.debug("Set schema term to "+schema.getNativeTerm()); } } rs.close(); rs = null; if (oldSize == children.size()) { rs = dbmd.getTables(getName(), null, "%", new String[] {"TABLE", "VIEW"}); while (rs.next()) { children.add(new SQLTable(this, rs.getString(3), rs.getString(5), rs.getString(4), false)); } rs.close(); rs = null; } } catch (SQLException e) { throw new ArchitectException("catalog.populate.fail", e); } finally { populated = true; int newSize = children.size(); if (newSize > oldSize) { int[] changedIndices = new int[newSize - oldSize]; for (int i = 0, n = newSize - oldSize; i < n; i++) { changedIndices[i] = oldSize + i; } fireDbChildrenInserted(changedIndices, children.subList(oldSize, newSize)); } try { if (rs != null) rs.close(); } catch (SQLException e2) { throw new ArchitectException("catalog.rs.close.fail", e2); } try { if (con != null) con.close(); } catch (SQLException e2) { throw new ArchitectException("Couldn't close connection", e2); } } } logger.debug("SQLCatalog: populate finished"); }
oldCatalog = con.getCatalog();
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(); // This can fail in SS2K because of privelege problems. There is // apparently no way to check if it will fail; you just have to try. try { con.setCatalog(getName()); } catch (SQLException ex) { logger.info("populate: Could not setCatalog("+getName()+"). Assuming it's a permission problem. Stack trace:", ex); return; } rs = dbmd.getSchemas(); while (rs.next()) { String schName = rs.getString(1); SQLSchema schema = null; if (schName != null) { schema = new SQLSchema(this, schName, false); children.add(schema); schema.setNativeTerm(dbmd.getSchemaTerm()); logger.debug("Set schema term to "+schema.getNativeTerm()); } } rs.close(); rs = null; if (oldSize == children.size()) { rs = dbmd.getTables(getName(), null, "%", new String[] {"TABLE", "VIEW"}); while (rs.next()) { children.add(new SQLTable(this, rs.getString(3), rs.getString(5), rs.getString(4), false)); } rs.close(); rs = null; } } catch (SQLException e) { throw new ArchitectException("catalog.populate.fail", e); } finally { populated = true; int newSize = children.size(); if (newSize > oldSize) { int[] changedIndices = new int[newSize - oldSize]; for (int i = 0, n = newSize - oldSize; i < n; i++) { changedIndices[i] = oldSize + i; } fireDbChildrenInserted(changedIndices, children.subList(oldSize, newSize)); } try { if (rs != null) rs.close(); } catch (SQLException e2) { throw new ArchitectException("catalog.rs.close.fail", e2); } try { if (con != null) con.close(); } catch (SQLException e2) { throw new ArchitectException("Couldn't close connection", e2); } } } logger.debug("SQLCatalog: populate finished"); }
if (con != null) con.close();
if (con != null) { con.setCatalog(oldCatalog); con.close(); }
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(); // This can fail in SS2K because of privelege problems. There is // apparently no way to check if it will fail; you just have to try. try { con.setCatalog(getName()); } catch (SQLException ex) { logger.info("populate: Could not setCatalog("+getName()+"). Assuming it's a permission problem. Stack trace:", ex); return; } rs = dbmd.getSchemas(); while (rs.next()) { String schName = rs.getString(1); SQLSchema schema = null; if (schName != null) { schema = new SQLSchema(this, schName, false); children.add(schema); schema.setNativeTerm(dbmd.getSchemaTerm()); logger.debug("Set schema term to "+schema.getNativeTerm()); } } rs.close(); rs = null; if (oldSize == children.size()) { rs = dbmd.getTables(getName(), null, "%", new String[] {"TABLE", "VIEW"}); while (rs.next()) { children.add(new SQLTable(this, rs.getString(3), rs.getString(5), rs.getString(4), false)); } rs.close(); rs = null; } } catch (SQLException e) { throw new ArchitectException("catalog.populate.fail", e); } finally { populated = true; int newSize = children.size(); if (newSize > oldSize) { int[] changedIndices = new int[newSize - oldSize]; for (int i = 0, n = newSize - oldSize; i < n; i++) { changedIndices[i] = oldSize + i; } fireDbChildrenInserted(changedIndices, children.subList(oldSize, newSize)); } try { if (rs != null) rs.close(); } catch (SQLException e2) { throw new ArchitectException("catalog.rs.close.fail", e2); } try { if (con != null) con.close(); } catch (SQLException e2) { throw new ArchitectException("Couldn't close connection", e2); } } } logger.debug("SQLCatalog: populate finished"); }
public void run(Context context, XMLOutput output) throws Exception {
public void run(JellyContext context, XMLOutput output) throws Exception {
public void run(Context context, XMLOutput output) throws Exception { if ( var == null ) { throw new IllegalArgumentException( "The var attribute cannot be null" ); } Document document = null; if ( source == null ) { SAXContentHandler handler = new SAXContentHandler(); XMLOutput newOutput = new XMLOutput( handler ); handler.startDocument(); getBody().run( context, newOutput ); handler.endDocument(); document = handler.getDocument();/* // the following is inefficient as it requires a parse of the text // but is left here in the code to see how it could be done. String text = getBodyText( context ); if ( log.isDebugEnabled() ) { log.debug( "About to parse: " + text ); } document = getSAXReader().read( new StringReader( text ) );*/ } else { if ( source instanceof String ) { document = getSAXReader().read( (String) source ); } else if ( source instanceof Reader ) { document = getSAXReader().read( (Reader) source ); } else if ( source instanceof InputStream ) { document = getSAXReader().read( (InputStream) source ); } else if ( source instanceof URL ) { document = getSAXReader().read( (URL) source ); } else { throw new IllegalArgumentException( "Invalid source argument. Must be a String, Reader, InputStream or URL." + " Was type; " + source.getClass().getName() + " with value: " + source ); } } context.setVariable( var, document ); }
String text = getBodyText( context );
String text = getBodyText();
public void run(Context context, XMLOutput output) throws Exception { if ( var == null ) { throw new IllegalArgumentException( "The var attribute cannot be null" ); } Document document = null; if ( source == null ) { SAXContentHandler handler = new SAXContentHandler(); XMLOutput newOutput = new XMLOutput( handler ); handler.startDocument(); getBody().run( context, newOutput ); handler.endDocument(); document = handler.getDocument();/* // the following is inefficient as it requires a parse of the text // but is left here in the code to see how it could be done. String text = getBodyText( context ); if ( log.isDebugEnabled() ) { log.debug( "About to parse: " + text ); } document = getSAXReader().read( new StringReader( text ) );*/ } else { if ( source instanceof String ) { document = getSAXReader().read( (String) source ); } else if ( source instanceof Reader ) { document = getSAXReader().read( (Reader) source ); } else if ( source instanceof InputStream ) { document = getSAXReader().read( (InputStream) source ); } else if ( source instanceof URL ) { document = getSAXReader().read( (URL) source ); } else { throw new IllegalArgumentException( "Invalid source argument. Must be a String, Reader, InputStream or URL." + " Was type; " + source.getClass().getName() + " with value: " + source ); } } context.setVariable( var, document ); }
if (items != null) { Iterator iter = items.evaluateAsIterator(context); if (log.isDebugEnabled()) { log.debug("Iterating through: " + iter);
try { if (items != null) { Iterator iter = items.evaluateAsIterator(context); if (log.isDebugEnabled()) { log.debug("Iterating through: " + iter); } for (index = 0; index < begin && iter.hasNext(); index++ ) { iter.next(); } while (iter.hasNext() && index < end) { Object value = iter.next(); if (var != null) { context.setVariable(var, value); } if (indexVar != null) { context.setVariable(indexVar, new Integer(index)); } invokeBody(output); index++; for ( int i = 1; i < step; i++, index++ ) { if ( ! iter.hasNext() ) { return; } iter.next(); } }
public void doTag(XMLOutput output) throws Exception { if (log.isDebugEnabled()) { log.debug("running with items: " + items); } if (items != null) { Iterator iter = items.evaluateAsIterator(context); if (log.isDebugEnabled()) { log.debug("Iterating through: " + iter); } // ignore the first items of the iterator for (index = 0; index < begin && iter.hasNext(); index++ ) { iter.next(); } while (iter.hasNext() && index < end) { Object value = iter.next(); if (var != null) { context.setVariable(var, value); } if (indexVar != null) { context.setVariable(indexVar, new Integer(index)); } invokeBody(output); // now we need to move to next index index++; for ( int i = 1; i < step; i++, index++ ) { if ( ! iter.hasNext() ) { return; } iter.next(); } } } else { if ( end == Integer.MAX_VALUE && begin == 0 ) { throw new MissingAttributeException( "items" ); } else { String varName = var; if ( varName == null ) { varName = indexVar; } for (index = begin; index <= end; index += step ) { if (varName != null) { Object value = new Integer(index); context.setVariable(varName, value); } invokeBody(output); } } } }
for (index = 0; index < begin && iter.hasNext(); index++ ) { iter.next(); } while (iter.hasNext() && index < end) { Object value = iter.next(); if (var != null) { context.setVariable(var, value);
else { if ( end == Integer.MAX_VALUE && begin == 0 ) { throw new MissingAttributeException( "items" );
public void doTag(XMLOutput output) throws Exception { if (log.isDebugEnabled()) { log.debug("running with items: " + items); } if (items != null) { Iterator iter = items.evaluateAsIterator(context); if (log.isDebugEnabled()) { log.debug("Iterating through: " + iter); } // ignore the first items of the iterator for (index = 0; index < begin && iter.hasNext(); index++ ) { iter.next(); } while (iter.hasNext() && index < end) { Object value = iter.next(); if (var != null) { context.setVariable(var, value); } if (indexVar != null) { context.setVariable(indexVar, new Integer(index)); } invokeBody(output); // now we need to move to next index index++; for ( int i = 1; i < step; i++, index++ ) { if ( ! iter.hasNext() ) { return; } iter.next(); } } } else { if ( end == Integer.MAX_VALUE && begin == 0 ) { throw new MissingAttributeException( "items" ); } else { String varName = var; if ( varName == null ) { varName = indexVar; } for (index = begin; index <= end; index += step ) { if (varName != null) { Object value = new Integer(index); context.setVariable(varName, value); } invokeBody(output); } } } }
if (indexVar != null) { context.setVariable(indexVar, new Integer(index)); } invokeBody(output); index++; for ( int i = 1; i < step; i++, index++ ) { if ( ! iter.hasNext() ) { return;
else { String varName = var; if ( varName == null ) { varName = indexVar;
public void doTag(XMLOutput output) throws Exception { if (log.isDebugEnabled()) { log.debug("running with items: " + items); } if (items != null) { Iterator iter = items.evaluateAsIterator(context); if (log.isDebugEnabled()) { log.debug("Iterating through: " + iter); } // ignore the first items of the iterator for (index = 0; index < begin && iter.hasNext(); index++ ) { iter.next(); } while (iter.hasNext() && index < end) { Object value = iter.next(); if (var != null) { context.setVariable(var, value); } if (indexVar != null) { context.setVariable(indexVar, new Integer(index)); } invokeBody(output); // now we need to move to next index index++; for ( int i = 1; i < step; i++, index++ ) { if ( ! iter.hasNext() ) { return; } iter.next(); } } } else { if ( end == Integer.MAX_VALUE && begin == 0 ) { throw new MissingAttributeException( "items" ); } else { String varName = var; if ( varName == null ) { varName = indexVar; } for (index = begin; index <= end; index += step ) { if (varName != null) { Object value = new Integer(index); context.setVariable(varName, value); } invokeBody(output); } } } }
iter.next();
for (index = begin; index <= end; index += step ) { if (varName != null) { Object value = new Integer(index); context.setVariable(varName, value); } invokeBody(output); }
public void doTag(XMLOutput output) throws Exception { if (log.isDebugEnabled()) { log.debug("running with items: " + items); } if (items != null) { Iterator iter = items.evaluateAsIterator(context); if (log.isDebugEnabled()) { log.debug("Iterating through: " + iter); } // ignore the first items of the iterator for (index = 0; index < begin && iter.hasNext(); index++ ) { iter.next(); } while (iter.hasNext() && index < end) { Object value = iter.next(); if (var != null) { context.setVariable(var, value); } if (indexVar != null) { context.setVariable(indexVar, new Integer(index)); } invokeBody(output); // now we need to move to next index index++; for ( int i = 1; i < step; i++, index++ ) { if ( ! iter.hasNext() ) { return; } iter.next(); } } } else { if ( end == Integer.MAX_VALUE && begin == 0 ) { throw new MissingAttributeException( "items" ); } else { String varName = var; if ( varName == null ) { varName = indexVar; } for (index = begin; index <= end; index += step ) { if (varName != null) { Object value = new Integer(index); context.setVariable(varName, value); } invokeBody(output); } } } }
else { if ( end == Integer.MAX_VALUE && begin == 0 ) { throw new MissingAttributeException( "items" ); } else { String varName = var; if ( varName == null ) { varName = indexVar; } for (index = begin; index <= end; index += step ) { if (varName != null) { Object value = new Integer(index); context.setVariable(varName, value); } invokeBody(output); }
catch (BreakException e) { if (log.isDebugEnabled()) { log.debug("loop terminated by break: " + e, e);
public void doTag(XMLOutput output) throws Exception { if (log.isDebugEnabled()) { log.debug("running with items: " + items); } if (items != null) { Iterator iter = items.evaluateAsIterator(context); if (log.isDebugEnabled()) { log.debug("Iterating through: " + iter); } // ignore the first items of the iterator for (index = 0; index < begin && iter.hasNext(); index++ ) { iter.next(); } while (iter.hasNext() && index < end) { Object value = iter.next(); if (var != null) { context.setVariable(var, value); } if (indexVar != null) { context.setVariable(indexVar, new Integer(index)); } invokeBody(output); // now we need to move to next index index++; for ( int i = 1; i < step; i++, index++ ) { if ( ! iter.hasNext() ) { return; } iter.next(); } } } else { if ( end == Integer.MAX_VALUE && begin == 0 ) { throw new MissingAttributeException( "items" ); } else { String varName = var; if ( varName == null ) { varName = indexVar; } for (index = begin; index <= end; index += step ) { if (varName != null) { Object value = new Integer(index); context.setVariable(varName, value); } invokeBody(output); } } } }
logger.debug("dbchildrenadd. source="+e.getSource());
public void dbChildrenInserted(SQLObjectEvent e) { if (!SwingUtilities.isEventDispatchThread()) return; if (logger.isDebugEnabled()) { if (e.getSQLSource() instanceof SQLRelationship) { SQLRelationship r = (SQLRelationship) e.getSQLSource(); logger.debug("dbChildrenInserted SQLObjectEvent: "+e +"; pk path="+Arrays.asList(getPkPathToRelationship(r)) +"; fk path="+Arrays.asList(getFkPathToRelationship(r))); } else { logger.debug("dbChildrenInserted SQLObjectEvent: "+e +"; tree path="+Arrays.asList(getPathToNode(e.getSQLSource()))); } } try { SQLObject[] newEventSources = e.getChildren(); for (int i = 0; i < newEventSources.length; i++) { ArchitectUtils.listenToHierarchy(this, newEventSources[i]); } } catch (ArchitectException ex) { logger.error("Error listening to added object", ex); } // relationships have two parents (pktable and fktable) so we need to fire two TMEs if (e.getSQLSource() instanceof SQLRelationship) { TreeModelEvent tme = new TreeModelEvent (this, getPkPathToRelationship((SQLRelationship) e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesInserted(tme); tme = new TreeModelEvent (this, getFkPathToRelationship((SQLRelationship) e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesInserted(tme); } else { TreeModelEvent tme = new TreeModelEvent (this, getPathToNode(e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesInserted(tme); } }
logger.debug("dbchildrenremove. source="+e.getSource());
public void dbChildrenRemoved(SQLObjectEvent e) { if (!SwingUtilities.isEventDispatchThread()) return; if (logger.isDebugEnabled()) logger.debug("dbChildrenRemoved SQLObjectEvent: "+e); try { SQLObject[] oldEventSources = e.getChildren(); for (int i = 0; i < oldEventSources.length; i++) { ArchitectUtils.unlistenToHierarchy(this, oldEventSources[i]); } } catch (ArchitectException ex) { logger.error("Error unlistening to removed object", ex); } if (e.getSQLSource() instanceof SQLRelationship) { TreeModelEvent tme = new TreeModelEvent (this, getPkPathToRelationship((SQLRelationship) e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesRemoved(tme); tme = new TreeModelEvent (this, getFkPathToRelationship((SQLRelationship) e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesRemoved(tme); } else { TreeModelEvent tme = new TreeModelEvent (this, getPathToNode(e.getSQLSource()), e.getChangedIndices(), e.getChildren()); fireTreeNodesRemoved(tme); } }
if (e.getPropertyName().equals("name") && !e.getNewValue().equals(e.getSQLSource().getName()) ) { logger.error("Name change event has wrong new value. new="+e.getNewValue()+"; real="+e.getSQLSource().getName()); }
public void dbObjectChanged(SQLObjectEvent e) { if (!SwingUtilities.isEventDispatchThread()) return; if (logger.isDebugEnabled()) logger.debug("dbObjectChanged SQLObjectEvent: "+e); SQLObject source = e.getSQLSource(); if (source instanceof SQLRelationship) { SQLRelationship r = (SQLRelationship) source; fireTreeNodesChanged(new TreeModelEvent(this, getPkPathToRelationship(r))); fireTreeNodesChanged(new TreeModelEvent(this, getFkPathToRelationship(r))); } else { fireTreeNodesChanged(new TreeModelEvent(this, getPathToNode(source))); } }
final TreeModelEvent ev =e;
logger.debug("firing TreeStructuredChanged. source="+e.getSource()); final TreeModelEvent ev =e;
protected void fireTreeStructureChanged(TreeModelEvent e) { final TreeModelEvent ev =e; Runnable notifier = new Runnable(){ public void run() { Iterator it = treeModelListeners.iterator(); while (it.hasNext()) { ((TreeModelListener) it.next()).treeStructureChanged(ev); } } };// TODO FIXME XXX Replace this with an alternate method leads to nasty behavior. There are 3 others too notifier.run(); }
public PhotoFolderTreeModel() {
public PhotoFolderTreeModel( FolderNodeMapper mapper ) {
public PhotoFolderTreeModel() { super(); nodeMapper = new DefaultFolderNodeMapper(); }
nodeMapper = new DefaultFolderNodeMapper();
nodeMapper = mapper;
public PhotoFolderTreeModel() { super(); nodeMapper = new DefaultFolderNodeMapper(); }
TreeModelListener l = (TreeModelListener) iter.next();
final TreeModelListener l = (TreeModelListener) iter.next(); SwingUtilities.invokeLater( new Runnable() { public void run() { l.treeStructureChanged( fe ); } });
protected void fireTreeModelEvent( TreeModelEvent e ) { Iterator iter = treeModelListeners.iterator(); while ( iter.hasNext() ) { TreeModelListener l = (TreeModelListener) iter.next(); log.warn( "Sending treeModelEvent" ); l.treeStructureChanged( e ); } }
l.treeStructureChanged( e );
protected void fireTreeModelEvent( TreeModelEvent e ) { Iterator iter = treeModelListeners.iterator(); while ( iter.hasNext() ) { TreeModelListener l = (TreeModelListener) iter.next(); log.warn( "Sending treeModelEvent" ); l.treeStructureChanged( e ); } }
hv.export(tab,format,0,Chromosome.getSize());
hv.export(tab,format,0,Chromosome.getFilteredSize());
public void actionPerformed (ActionEvent e){ String command = e.getActionCommand(); if (dpButton.isSelected()){ if(txtButton.isSelected()){ adjButton.setEnabled(true); compressCheckBox.setEnabled(false); }else{ compressCheckBox.setEnabled(true); adjButton.setEnabled(false); if (adjButton.isSelected()){ allButton.setSelected(true); } } someButton.setEnabled(true); }else{ compressCheckBox.setEnabled(false); someButton.setEnabled(false); adjButton.setEnabled(false); if (adjButton.isSelected() || someButton.isSelected()){ allButton.setSelected(true); } } if (someButton.isSelected()){ upperRange.setEnabled(true); lowRange.setEnabled(true); }else{ upperRange.setEnabled(false); lowRange.setEnabled(false); } if (command.equals("ldtab") || command.equals("haptab")){ pngButton.setEnabled(true); }else if (command.equals("checktab") || command.equals("assoctab")){ pngButton.setEnabled(false); txtButton.setSelected(true); }else if (command.equals("OK")){ int format, tab; if (pngButton.isSelected()){ if (compressCheckBox.isSelected()){ format = COMPRESSED_PNG_MODE; }else{ format = PNG_MODE; } }else{ format = TXT_MODE; } if (dpButton.isSelected()){ tab = VIEW_D_NUM; } else if (hapButton.isSelected()){ tab = VIEW_HAP_NUM; } else if (checkButton.isSelected()){ tab = VIEW_CHECK_NUM; } else { tab = VIEW_TDT_NUM; } this.dispose(); if (allButton.isSelected()){ hv.export(tab,format,0,Chromosome.getSize()); }else if (someButton.isSelected()){ try{ hv.export(tab,format,Integer.parseInt(lowRange.getText())-1, Integer.parseInt(upperRange.getText())); }catch (NumberFormatException nfe){ JOptionPane.showMessageDialog(hv, "Invalid marker range: " + lowRange.getText() + " - " + upperRange.getText(), "Export Error", JOptionPane.ERROR_MESSAGE); } }else{ hv.export(tab,format,-1,-1); } }else if (command.equals("Cancel")){ this.dispose(); } }
public SQLSchema(SQLObject parent, String name) { this.parent = parent; this.schemaName = name; this.children = new LinkedList();
public SQLSchema() { this(null, null);
public SQLSchema(SQLObject parent, String name) { this.parent = parent; this.schemaName = name; this.children = new LinkedList(); }
int format, tab;
int format; HaploviewTab tab;
public void actionPerformed (ActionEvent e){ String command = e.getActionCommand(); if (dpButton.isSelected()){ if(txtButton.isSelected()){ adjButton.setEnabled(true); compressCheckBox.setEnabled(false); }else{ compressCheckBox.setEnabled(true); adjButton.setEnabled(false); if (adjButton.isSelected()){ allButton.setSelected(true); } } someButton.setEnabled(true); }else{ compressCheckBox.setEnabled(false); someButton.setEnabled(false); adjButton.setEnabled(false); if (adjButton.isSelected() || someButton.isSelected()){ allButton.setSelected(true); } } if (someButton.isSelected()){ upperRange.setEnabled(true); lowRange.setEnabled(true); }else{ upperRange.setEnabled(false); lowRange.setEnabled(false); } if (command.equals("ldtab") || command.equals("haptab")){ pngButton.setEnabled(true); }else if (command.equals("checktab") || command.equals("singleassoctab") || command.equals("hapassoctab")){ pngButton.setEnabled(false); txtButton.setSelected(true); }else if (command.equals("OK")){ int format, tab; if (pngButton.isSelected()){ if (compressCheckBox.isSelected()){ format = COMPRESSED_PNG_MODE; }else{ format = PNG_MODE; } }else{ format = TXT_MODE; } if (dpButton.isSelected()){ tab = VIEW_D_NUM; } else if (hapButton.isSelected()){ tab = VIEW_HAP_NUM; } else if (checkButton.isSelected()){ tab = VIEW_CHECK_NUM; } else if (singleAssocButton.isSelected()){ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.tdtPanel); }else if (hapAssocButton.isSelected()){ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.hapAssocPanel); }else{ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.permutationPanel); } this.dispose(); if (allButton.isSelected()){ hv.export(tab,format,0,Chromosome.getUnfilteredSize()); }else if (someButton.isSelected()){ try{ hv.export(tab,format,Integer.parseInt(lowRange.getText())-1, Integer.parseInt(upperRange.getText())); }catch (NumberFormatException nfe){ JOptionPane.showMessageDialog(hv, "Invalid marker range: " + lowRange.getText() + " - " + upperRange.getText(), "Export Error", JOptionPane.ERROR_MESSAGE); } }else{ hv.export(tab,format,-1,-1); } }else if (command.equals("Cancel")){ this.dispose(); } }
tab = VIEW_D_NUM;
tab = hv.ldTab;
public void actionPerformed (ActionEvent e){ String command = e.getActionCommand(); if (dpButton.isSelected()){ if(txtButton.isSelected()){ adjButton.setEnabled(true); compressCheckBox.setEnabled(false); }else{ compressCheckBox.setEnabled(true); adjButton.setEnabled(false); if (adjButton.isSelected()){ allButton.setSelected(true); } } someButton.setEnabled(true); }else{ compressCheckBox.setEnabled(false); someButton.setEnabled(false); adjButton.setEnabled(false); if (adjButton.isSelected() || someButton.isSelected()){ allButton.setSelected(true); } } if (someButton.isSelected()){ upperRange.setEnabled(true); lowRange.setEnabled(true); }else{ upperRange.setEnabled(false); lowRange.setEnabled(false); } if (command.equals("ldtab") || command.equals("haptab")){ pngButton.setEnabled(true); }else if (command.equals("checktab") || command.equals("singleassoctab") || command.equals("hapassoctab")){ pngButton.setEnabled(false); txtButton.setSelected(true); }else if (command.equals("OK")){ int format, tab; if (pngButton.isSelected()){ if (compressCheckBox.isSelected()){ format = COMPRESSED_PNG_MODE; }else{ format = PNG_MODE; } }else{ format = TXT_MODE; } if (dpButton.isSelected()){ tab = VIEW_D_NUM; } else if (hapButton.isSelected()){ tab = VIEW_HAP_NUM; } else if (checkButton.isSelected()){ tab = VIEW_CHECK_NUM; } else if (singleAssocButton.isSelected()){ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.tdtPanel); }else if (hapAssocButton.isSelected()){ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.hapAssocPanel); }else{ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.permutationPanel); } this.dispose(); if (allButton.isSelected()){ hv.export(tab,format,0,Chromosome.getUnfilteredSize()); }else if (someButton.isSelected()){ try{ hv.export(tab,format,Integer.parseInt(lowRange.getText())-1, Integer.parseInt(upperRange.getText())); }catch (NumberFormatException nfe){ JOptionPane.showMessageDialog(hv, "Invalid marker range: " + lowRange.getText() + " - " + upperRange.getText(), "Export Error", JOptionPane.ERROR_MESSAGE); } }else{ hv.export(tab,format,-1,-1); } }else if (command.equals("Cancel")){ this.dispose(); } }
tab = VIEW_HAP_NUM;
tab = hv.hapsTab;
public void actionPerformed (ActionEvent e){ String command = e.getActionCommand(); if (dpButton.isSelected()){ if(txtButton.isSelected()){ adjButton.setEnabled(true); compressCheckBox.setEnabled(false); }else{ compressCheckBox.setEnabled(true); adjButton.setEnabled(false); if (adjButton.isSelected()){ allButton.setSelected(true); } } someButton.setEnabled(true); }else{ compressCheckBox.setEnabled(false); someButton.setEnabled(false); adjButton.setEnabled(false); if (adjButton.isSelected() || someButton.isSelected()){ allButton.setSelected(true); } } if (someButton.isSelected()){ upperRange.setEnabled(true); lowRange.setEnabled(true); }else{ upperRange.setEnabled(false); lowRange.setEnabled(false); } if (command.equals("ldtab") || command.equals("haptab")){ pngButton.setEnabled(true); }else if (command.equals("checktab") || command.equals("singleassoctab") || command.equals("hapassoctab")){ pngButton.setEnabled(false); txtButton.setSelected(true); }else if (command.equals("OK")){ int format, tab; if (pngButton.isSelected()){ if (compressCheckBox.isSelected()){ format = COMPRESSED_PNG_MODE; }else{ format = PNG_MODE; } }else{ format = TXT_MODE; } if (dpButton.isSelected()){ tab = VIEW_D_NUM; } else if (hapButton.isSelected()){ tab = VIEW_HAP_NUM; } else if (checkButton.isSelected()){ tab = VIEW_CHECK_NUM; } else if (singleAssocButton.isSelected()){ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.tdtPanel); }else if (hapAssocButton.isSelected()){ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.hapAssocPanel); }else{ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.permutationPanel); } this.dispose(); if (allButton.isSelected()){ hv.export(tab,format,0,Chromosome.getUnfilteredSize()); }else if (someButton.isSelected()){ try{ hv.export(tab,format,Integer.parseInt(lowRange.getText())-1, Integer.parseInt(upperRange.getText())); }catch (NumberFormatException nfe){ JOptionPane.showMessageDialog(hv, "Invalid marker range: " + lowRange.getText() + " - " + upperRange.getText(), "Export Error", JOptionPane.ERROR_MESSAGE); } }else{ hv.export(tab,format,-1,-1); } }else if (command.equals("Cancel")){ this.dispose(); } }
tab = VIEW_CHECK_NUM;
tab = hv.checkTab;
public void actionPerformed (ActionEvent e){ String command = e.getActionCommand(); if (dpButton.isSelected()){ if(txtButton.isSelected()){ adjButton.setEnabled(true); compressCheckBox.setEnabled(false); }else{ compressCheckBox.setEnabled(true); adjButton.setEnabled(false); if (adjButton.isSelected()){ allButton.setSelected(true); } } someButton.setEnabled(true); }else{ compressCheckBox.setEnabled(false); someButton.setEnabled(false); adjButton.setEnabled(false); if (adjButton.isSelected() || someButton.isSelected()){ allButton.setSelected(true); } } if (someButton.isSelected()){ upperRange.setEnabled(true); lowRange.setEnabled(true); }else{ upperRange.setEnabled(false); lowRange.setEnabled(false); } if (command.equals("ldtab") || command.equals("haptab")){ pngButton.setEnabled(true); }else if (command.equals("checktab") || command.equals("singleassoctab") || command.equals("hapassoctab")){ pngButton.setEnabled(false); txtButton.setSelected(true); }else if (command.equals("OK")){ int format, tab; if (pngButton.isSelected()){ if (compressCheckBox.isSelected()){ format = COMPRESSED_PNG_MODE; }else{ format = PNG_MODE; } }else{ format = TXT_MODE; } if (dpButton.isSelected()){ tab = VIEW_D_NUM; } else if (hapButton.isSelected()){ tab = VIEW_HAP_NUM; } else if (checkButton.isSelected()){ tab = VIEW_CHECK_NUM; } else if (singleAssocButton.isSelected()){ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.tdtPanel); }else if (hapAssocButton.isSelected()){ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.hapAssocPanel); }else{ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.permutationPanel); } this.dispose(); if (allButton.isSelected()){ hv.export(tab,format,0,Chromosome.getUnfilteredSize()); }else if (someButton.isSelected()){ try{ hv.export(tab,format,Integer.parseInt(lowRange.getText())-1, Integer.parseInt(upperRange.getText())); }catch (NumberFormatException nfe){ JOptionPane.showMessageDialog(hv, "Invalid marker range: " + lowRange.getText() + " - " + upperRange.getText(), "Export Error", JOptionPane.ERROR_MESSAGE); } }else{ hv.export(tab,format,-1,-1); } }else if (command.equals("Cancel")){ this.dispose(); } }
tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.tdtPanel);
tab = hv.associationTab; ((JTabbedPane)tab.getComponent(0)).setSelectedComponent(hv.tdtPanel);
public void actionPerformed (ActionEvent e){ String command = e.getActionCommand(); if (dpButton.isSelected()){ if(txtButton.isSelected()){ adjButton.setEnabled(true); compressCheckBox.setEnabled(false); }else{ compressCheckBox.setEnabled(true); adjButton.setEnabled(false); if (adjButton.isSelected()){ allButton.setSelected(true); } } someButton.setEnabled(true); }else{ compressCheckBox.setEnabled(false); someButton.setEnabled(false); adjButton.setEnabled(false); if (adjButton.isSelected() || someButton.isSelected()){ allButton.setSelected(true); } } if (someButton.isSelected()){ upperRange.setEnabled(true); lowRange.setEnabled(true); }else{ upperRange.setEnabled(false); lowRange.setEnabled(false); } if (command.equals("ldtab") || command.equals("haptab")){ pngButton.setEnabled(true); }else if (command.equals("checktab") || command.equals("singleassoctab") || command.equals("hapassoctab")){ pngButton.setEnabled(false); txtButton.setSelected(true); }else if (command.equals("OK")){ int format, tab; if (pngButton.isSelected()){ if (compressCheckBox.isSelected()){ format = COMPRESSED_PNG_MODE; }else{ format = PNG_MODE; } }else{ format = TXT_MODE; } if (dpButton.isSelected()){ tab = VIEW_D_NUM; } else if (hapButton.isSelected()){ tab = VIEW_HAP_NUM; } else if (checkButton.isSelected()){ tab = VIEW_CHECK_NUM; } else if (singleAssocButton.isSelected()){ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.tdtPanel); }else if (hapAssocButton.isSelected()){ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.hapAssocPanel); }else{ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.permutationPanel); } this.dispose(); if (allButton.isSelected()){ hv.export(tab,format,0,Chromosome.getUnfilteredSize()); }else if (someButton.isSelected()){ try{ hv.export(tab,format,Integer.parseInt(lowRange.getText())-1, Integer.parseInt(upperRange.getText())); }catch (NumberFormatException nfe){ JOptionPane.showMessageDialog(hv, "Invalid marker range: " + lowRange.getText() + " - " + upperRange.getText(), "Export Error", JOptionPane.ERROR_MESSAGE); } }else{ hv.export(tab,format,-1,-1); } }else if (command.equals("Cancel")){ this.dispose(); } }
tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.hapAssocPanel);
tab = hv.associationTab; ((JTabbedPane)tab.getComponent(0)).setSelectedComponent(hv.hapAssocPanel);
public void actionPerformed (ActionEvent e){ String command = e.getActionCommand(); if (dpButton.isSelected()){ if(txtButton.isSelected()){ adjButton.setEnabled(true); compressCheckBox.setEnabled(false); }else{ compressCheckBox.setEnabled(true); adjButton.setEnabled(false); if (adjButton.isSelected()){ allButton.setSelected(true); } } someButton.setEnabled(true); }else{ compressCheckBox.setEnabled(false); someButton.setEnabled(false); adjButton.setEnabled(false); if (adjButton.isSelected() || someButton.isSelected()){ allButton.setSelected(true); } } if (someButton.isSelected()){ upperRange.setEnabled(true); lowRange.setEnabled(true); }else{ upperRange.setEnabled(false); lowRange.setEnabled(false); } if (command.equals("ldtab") || command.equals("haptab")){ pngButton.setEnabled(true); }else if (command.equals("checktab") || command.equals("singleassoctab") || command.equals("hapassoctab")){ pngButton.setEnabled(false); txtButton.setSelected(true); }else if (command.equals("OK")){ int format, tab; if (pngButton.isSelected()){ if (compressCheckBox.isSelected()){ format = COMPRESSED_PNG_MODE; }else{ format = PNG_MODE; } }else{ format = TXT_MODE; } if (dpButton.isSelected()){ tab = VIEW_D_NUM; } else if (hapButton.isSelected()){ tab = VIEW_HAP_NUM; } else if (checkButton.isSelected()){ tab = VIEW_CHECK_NUM; } else if (singleAssocButton.isSelected()){ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.tdtPanel); }else if (hapAssocButton.isSelected()){ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.hapAssocPanel); }else{ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.permutationPanel); } this.dispose(); if (allButton.isSelected()){ hv.export(tab,format,0,Chromosome.getUnfilteredSize()); }else if (someButton.isSelected()){ try{ hv.export(tab,format,Integer.parseInt(lowRange.getText())-1, Integer.parseInt(upperRange.getText())); }catch (NumberFormatException nfe){ JOptionPane.showMessageDialog(hv, "Invalid marker range: " + lowRange.getText() + " - " + upperRange.getText(), "Export Error", JOptionPane.ERROR_MESSAGE); } }else{ hv.export(tab,format,-1,-1); } }else if (command.equals("Cancel")){ this.dispose(); } }
tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.permutationPanel);
tab = hv.associationTab; ((JTabbedPane)tab.getComponent(0)).setSelectedComponent(hv.permutationPanel);
public void actionPerformed (ActionEvent e){ String command = e.getActionCommand(); if (dpButton.isSelected()){ if(txtButton.isSelected()){ adjButton.setEnabled(true); compressCheckBox.setEnabled(false); }else{ compressCheckBox.setEnabled(true); adjButton.setEnabled(false); if (adjButton.isSelected()){ allButton.setSelected(true); } } someButton.setEnabled(true); }else{ compressCheckBox.setEnabled(false); someButton.setEnabled(false); adjButton.setEnabled(false); if (adjButton.isSelected() || someButton.isSelected()){ allButton.setSelected(true); } } if (someButton.isSelected()){ upperRange.setEnabled(true); lowRange.setEnabled(true); }else{ upperRange.setEnabled(false); lowRange.setEnabled(false); } if (command.equals("ldtab") || command.equals("haptab")){ pngButton.setEnabled(true); }else if (command.equals("checktab") || command.equals("singleassoctab") || command.equals("hapassoctab")){ pngButton.setEnabled(false); txtButton.setSelected(true); }else if (command.equals("OK")){ int format, tab; if (pngButton.isSelected()){ if (compressCheckBox.isSelected()){ format = COMPRESSED_PNG_MODE; }else{ format = PNG_MODE; } }else{ format = TXT_MODE; } if (dpButton.isSelected()){ tab = VIEW_D_NUM; } else if (hapButton.isSelected()){ tab = VIEW_HAP_NUM; } else if (checkButton.isSelected()){ tab = VIEW_CHECK_NUM; } else if (singleAssocButton.isSelected()){ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.tdtPanel); }else if (hapAssocButton.isSelected()){ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.hapAssocPanel); }else{ tab = VIEW_ASSOC_NUM; ((JTabbedPane)hv.tabs.getComponent(tab)).setSelectedComponent(hv.permutationPanel); } this.dispose(); if (allButton.isSelected()){ hv.export(tab,format,0,Chromosome.getUnfilteredSize()); }else if (someButton.isSelected()){ try{ hv.export(tab,format,Integer.parseInt(lowRange.getText())-1, Integer.parseInt(upperRange.getText())); }catch (NumberFormatException nfe){ JOptionPane.showMessageDialog(hv, "Invalid marker range: " + lowRange.getText() + " - " + upperRange.getText(), "Export Error", JOptionPane.ERROR_MESSAGE); } }else{ hv.export(tab,format,-1,-1); } }else if (command.equals("Cancel")){ this.dispose(); } }
new TextMethods().linkageToHaps(markerResultArray,checkPanel.getPedFile(),filenames[0]+".haps");
new TextMethods().linkageToHaps(markerResultArray,checkPanel.getPedFile(),inputOptions[0]+".haps");
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 == "Continue"){ //TODO: change it so writing to a file is a checkbox on the CheckDataPanel theData = new HaploData(); JTable table = checkPanel.getTable(); checkWindow.dispose(); boolean[] markerResultArray = new boolean[table.getRowCount()]; for (int i = 0; i < table.getRowCount(); i++){ markerResultArray[i] = ((Boolean)table.getValueAt(i,7)).booleanValue(); } /* try{ new TextMethods().linkageToHaps(markerResultArray,checkPanel.getPedFile(),filenames[0]+".haps"); }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } */ theData.linkageToChrom(markerResultArray,checkPanel.getPedFile()); processData(); //processInput(new File(hapInputFileName+".haps")); } else if (command == READ_MARKERS){ fc.setSelectedFile(null); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { readMarkers(fc.getSelectedFile()); } }else if (command == "Clear All Blocks"){ //theBlocks.clearBlocks(); }else if (command == DEFINE_BLOCKS){ defineBlocks(); }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); } } }
hapScroller.setViewportView(hapDisplay);
void defineBlocks(){ String[] methodStrings = {"95% of informative pairwise comparisons show strong LD via confidence intervals (SFS)", "Four Gamete Rule", "Solid block of strong LD via D prime (MJD)"}; JComboBox methodList = new JComboBox(methodStrings); JOptionPane.showMessageDialog(this, methodList, "Select a block-finding algorithm", JOptionPane.QUESTION_MESSAGE); theData.guessBlocks(methodList.getSelectedIndex()); hapDisplay.getHaps(); dPrimeDisplay.refreshWorldmap(); if (tabs.getSelectedIndex() == 0) dPrimeDisplay.repaint(); }
JScrollPane hapScroller = new JScrollPane(hapDisplay);
hapScroller = new JScrollPane(hapDisplay);
void drawPicture(HaploData theData){ Container contents = getContentPane(); contents.removeAll(); //remember which tab we're in if they've already been set up int currentTabIndex = 0; if (!(tabs == null)){ currentTabIndex = 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.dPrimeTable, infoKnown); 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[0], panel); //compute and show haps on next tab panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); hapDisplay = new HaplotypeDisplay(theData); HaplotypeDisplayController hdc = new HaplotypeDisplayController(hapDisplay); JScrollPane hapScroller = new JScrollPane(hapDisplay); panel.add(hapScroller); panel.add(hdc); tabs.addTab(viewItems[1], panel); tabs.setSelectedIndex(currentTabIndex); contents.add(tabs); //next add a little spacer //ontents.add(Box.createRigidArea(new Dimension(0,5))); //and then add the block display //theBlocks = new BlockDisplay(theData.markerInfo, theData.blocks, dPrimeDisplay, infoKnown); //contents.setBackground(Color.black); //put the block display in a scroll pane in case the data set is very large. //JScrollPane blockScroller = new JScrollPane(theBlocks, // JScrollPane.VERTICAL_SCROLLBAR_NEVER, // JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); //blockScroller.getHorizontalScrollBar().setUnitIncrement(60); //blockScroller.setMinimumSize(new Dimension(800, 100)); //contents.add(blockScroller); repaint(); setVisible(true); }
maxCompDist = Long.parseLong(filenames[2])*1000;
maxCompDist = Long.parseLong(inputOptions[2])*1000;
void processData(){ maxCompDist = Long.parseLong(filenames[2])*1000; try{ this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); final SwingWorker worker = new SwingWorker(){ public Object construct(){ dPrimeDisplay=null; infoKnown = false; if (!(filenames[1].equals(""))){ readMarkers(new File(filenames[1])); } theData.generateDPrimeTable(maxCompDist); theData.guessBlocks(0); drawPicture(theData); theData.finished = true; return ""; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ if (theData.finished){ timer.stop(); defineBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); worker.start(); timer.start(); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } }
if (!(filenames[1].equals(""))){ readMarkers(new File(filenames[1]));
if (!(inputOptions[1].equals(""))){ readMarkers(new File(inputOptions[1]));
void processData(){ maxCompDist = Long.parseLong(filenames[2])*1000; try{ this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); final SwingWorker worker = new SwingWorker(){ public Object construct(){ dPrimeDisplay=null; infoKnown = false; if (!(filenames[1].equals(""))){ readMarkers(new File(filenames[1])); } theData.generateDPrimeTable(maxCompDist); theData.guessBlocks(0); drawPicture(theData); theData.finished = true; return ""; } }; timer = new javax.swing.Timer(50, new ActionListener(){ public void actionPerformed(ActionEvent evt){ if (theData.finished){ timer.stop(); defineBlocksItem.setEnabled(true); readMarkerItem.setEnabled(true); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); worker.start(); timer.start(); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } }
if (!(filenames[1].equals(""))){ readMarkers(new File(filenames[1]));
if (!(inputOptions[1].equals(""))){ readMarkers(new File(inputOptions[1]));
public Object construct(){ dPrimeDisplay=null; infoKnown = false; if (!(filenames[1].equals(""))){ readMarkers(new File(filenames[1])); } theData.generateDPrimeTable(maxCompDist); theData.guessBlocks(0); drawPicture(theData); theData.finished = true; return ""; }
filenames = f; File pedFile = new File(filenames[0]);
inputOptions = f; File pedFile = new File(inputOptions[0]);
void readPedGenotypes(String[] f){ //input is a 3 element array with //filenames[0] = ped file //filenames[1] = info file (null if none) //filenames[2] = max comparison distance (don't compute d' if markers are greater than this dist apart) filenames = f; File pedFile = new File(filenames[0]); //pop open checkdata window checkWindow = new JFrame(); checkPanel = new CheckDataPanel(pedFile); checkWindow.setTitle("Checking markers..." + pedFile.getName()); JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JButton checkContinueButton = new JButton("Continue"); checkContinueButton.addActionListener(this); checkPanel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(checkPanel); checkContinueButton.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(checkContinueButton); JLabel infoLabel = new JLabel("(this will create a haplotype file named " + pedFile.getName() + ".haps)"); infoLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(infoLabel); checkWindow.setContentPane(metaCheckPanel); checkWindow.pack(); checkWindow.setVisible(true); }
filenames = f;
inputOptions = f;
void readPhasedGenotypes(String[] f){ //input is a 3 element array with //filenames[0] = haps file //filenames[1] = info file (null if none) //filenames[2] = max comparison distance (don't compute d' if markers are greater than this dist apart) filenames = f; theData = new HaploData(); try{ theData.prepareHapsInput(new File(filenames[0])); processData(); }catch(IOException ioexec) { JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } }
theData.prepareHapsInput(new File(filenames[0]));
theData.prepareHapsInput(new File(inputOptions[0]));
void readPhasedGenotypes(String[] f){ //input is a 3 element array with //filenames[0] = haps file //filenames[1] = info file (null if none) //filenames[2] = max comparison distance (don't compute d' if markers are greater than this dist apart) filenames = f; theData = new HaploData(); try{ theData.prepareHapsInput(new File(filenames[0])); processData(); }catch(IOException ioexec) { JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } }
while (comparator.compare(sourceColumn, targetColumn) < 0) {
if (comparator.compare(sourceColumn, targetColumn) < 0) {
private List<DiffChunk<SQLObject>> generateColumnDiffs( SQLTable sourceTable, SQLTable targetTable) throws ArchitectException { TreeSet<SQLColumn> sourceColumnList; TreeSet<SQLColumn> targetColumnList; Iterator<SQLColumn> sourceColIter; Iterator<SQLColumn> targetColIter; SQLColumn sourceColumn; SQLColumn targetColumn; boolean sourceColContinue; boolean targetColContinue; sourceColumnList = new TreeSet<SQLColumn>(comparator); targetColumnList = new TreeSet<SQLColumn>(comparator); sourceColContinue = false; targetColContinue = false; sourceColIter = null; targetColIter = null; sourceColumn = null; targetColumn = null; // We store the diffs in here, then return this listS List<DiffChunk<SQLObject>> diffs = new ArrayList<DiffChunk<SQLObject>>(); if (sourceTable != null) { sourceColumnList.addAll(sourceTable.getColumns()); } if (targetTable != null) { targetColumnList.addAll(targetTable.getColumns()); } if (sourceColumnList.size() == 0) { sourceColumnList = null; sourceColContinue = false; } else { sourceColIter = sourceColumnList.iterator(); sourceColumn = sourceColIter.next(); sourceColContinue = true; } if (targetColumnList.size() == 0) { targetColumnList = null; targetColContinue = false; } else { targetColIter = targetColumnList.iterator(); targetColumn = targetColIter.next(); targetColContinue = true; } while (sourceColContinue && targetColContinue) { // Comparing Columns while (comparator.compare(sourceColumn, targetColumn) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceColumn, DiffType.LEFTONLY)); if (sourceColIter.hasNext()) { sourceColumn = sourceColIter.next(); } else { sourceColContinue = false; break; } } // Comparing Columns while (comparator.compare(sourceColumn, targetColumn) > 0) { diffs.add(new DiffChunk<SQLObject>(targetColumn, DiffType.RIGHTONLY)); if (targetColIter.hasNext()) { targetColumn = targetColIter.next(); } else { targetColContinue = false; break; } } // Comparing Columns while (comparator.compare(sourceColumn, targetColumn) == 0) { if (targetColumn.getType() != sourceColumn.getType() || (targetColumn.getPrecision() != sourceColumn.getPrecision()) || (targetColumn.getScale() != sourceColumn.getScale()) || (targetColumn.getNullable() != sourceColumn.getNullable()) ) { diffs.add(new DiffChunk<SQLObject>(targetColumn, DiffType.MODIFIED)); } else { diffs.add(new DiffChunk<SQLObject>(sourceColumn, DiffType.SAME)); } if (targetColIter.hasNext()) { targetColumn = targetColIter.next(); } else { targetColContinue = false; } if (sourceColIter.hasNext()) { sourceColumn = sourceColIter.next(); } else { sourceColContinue = false; } if (!sourceColContinue || !targetColContinue) { break; } } } while (sourceColContinue) { diffs.add(new DiffChunk<SQLObject>(sourceColumn, DiffType.LEFTONLY)); if (sourceColIter.hasNext()) { sourceColumn = sourceColIter.next(); } else { sourceColContinue = false; } } while (targetColContinue) { diffs.add(new DiffChunk<SQLObject>(targetColumn, DiffType.RIGHTONLY)); if (targetColIter.hasNext()) { targetColumn = targetColIter.next(); } else { targetColContinue = false; } } return diffs; }
break;
private List<DiffChunk<SQLObject>> generateColumnDiffs( SQLTable sourceTable, SQLTable targetTable) throws ArchitectException { TreeSet<SQLColumn> sourceColumnList; TreeSet<SQLColumn> targetColumnList; Iterator<SQLColumn> sourceColIter; Iterator<SQLColumn> targetColIter; SQLColumn sourceColumn; SQLColumn targetColumn; boolean sourceColContinue; boolean targetColContinue; sourceColumnList = new TreeSet<SQLColumn>(comparator); targetColumnList = new TreeSet<SQLColumn>(comparator); sourceColContinue = false; targetColContinue = false; sourceColIter = null; targetColIter = null; sourceColumn = null; targetColumn = null; // We store the diffs in here, then return this listS List<DiffChunk<SQLObject>> diffs = new ArrayList<DiffChunk<SQLObject>>(); if (sourceTable != null) { sourceColumnList.addAll(sourceTable.getColumns()); } if (targetTable != null) { targetColumnList.addAll(targetTable.getColumns()); } if (sourceColumnList.size() == 0) { sourceColumnList = null; sourceColContinue = false; } else { sourceColIter = sourceColumnList.iterator(); sourceColumn = sourceColIter.next(); sourceColContinue = true; } if (targetColumnList.size() == 0) { targetColumnList = null; targetColContinue = false; } else { targetColIter = targetColumnList.iterator(); targetColumn = targetColIter.next(); targetColContinue = true; } while (sourceColContinue && targetColContinue) { // Comparing Columns while (comparator.compare(sourceColumn, targetColumn) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceColumn, DiffType.LEFTONLY)); if (sourceColIter.hasNext()) { sourceColumn = sourceColIter.next(); } else { sourceColContinue = false; break; } } // Comparing Columns while (comparator.compare(sourceColumn, targetColumn) > 0) { diffs.add(new DiffChunk<SQLObject>(targetColumn, DiffType.RIGHTONLY)); if (targetColIter.hasNext()) { targetColumn = targetColIter.next(); } else { targetColContinue = false; break; } } // Comparing Columns while (comparator.compare(sourceColumn, targetColumn) == 0) { if (targetColumn.getType() != sourceColumn.getType() || (targetColumn.getPrecision() != sourceColumn.getPrecision()) || (targetColumn.getScale() != sourceColumn.getScale()) || (targetColumn.getNullable() != sourceColumn.getNullable()) ) { diffs.add(new DiffChunk<SQLObject>(targetColumn, DiffType.MODIFIED)); } else { diffs.add(new DiffChunk<SQLObject>(sourceColumn, DiffType.SAME)); } if (targetColIter.hasNext()) { targetColumn = targetColIter.next(); } else { targetColContinue = false; } if (sourceColIter.hasNext()) { sourceColumn = sourceColIter.next(); } else { sourceColContinue = false; } if (!sourceColContinue || !targetColContinue) { break; } } } while (sourceColContinue) { diffs.add(new DiffChunk<SQLObject>(sourceColumn, DiffType.LEFTONLY)); if (sourceColIter.hasNext()) { sourceColumn = sourceColIter.next(); } else { sourceColContinue = false; } } while (targetColContinue) { diffs.add(new DiffChunk<SQLObject>(targetColumn, DiffType.RIGHTONLY)); if (targetColIter.hasNext()) { targetColumn = targetColIter.next(); } else { targetColContinue = false; } } return diffs; }
while (comparator.compare(sourceColumn, targetColumn) > 0) {
if (comparator.compare(sourceColumn, targetColumn) > 0) {
private List<DiffChunk<SQLObject>> generateColumnDiffs( SQLTable sourceTable, SQLTable targetTable) throws ArchitectException { TreeSet<SQLColumn> sourceColumnList; TreeSet<SQLColumn> targetColumnList; Iterator<SQLColumn> sourceColIter; Iterator<SQLColumn> targetColIter; SQLColumn sourceColumn; SQLColumn targetColumn; boolean sourceColContinue; boolean targetColContinue; sourceColumnList = new TreeSet<SQLColumn>(comparator); targetColumnList = new TreeSet<SQLColumn>(comparator); sourceColContinue = false; targetColContinue = false; sourceColIter = null; targetColIter = null; sourceColumn = null; targetColumn = null; // We store the diffs in here, then return this listS List<DiffChunk<SQLObject>> diffs = new ArrayList<DiffChunk<SQLObject>>(); if (sourceTable != null) { sourceColumnList.addAll(sourceTable.getColumns()); } if (targetTable != null) { targetColumnList.addAll(targetTable.getColumns()); } if (sourceColumnList.size() == 0) { sourceColumnList = null; sourceColContinue = false; } else { sourceColIter = sourceColumnList.iterator(); sourceColumn = sourceColIter.next(); sourceColContinue = true; } if (targetColumnList.size() == 0) { targetColumnList = null; targetColContinue = false; } else { targetColIter = targetColumnList.iterator(); targetColumn = targetColIter.next(); targetColContinue = true; } while (sourceColContinue && targetColContinue) { // Comparing Columns while (comparator.compare(sourceColumn, targetColumn) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceColumn, DiffType.LEFTONLY)); if (sourceColIter.hasNext()) { sourceColumn = sourceColIter.next(); } else { sourceColContinue = false; break; } } // Comparing Columns while (comparator.compare(sourceColumn, targetColumn) > 0) { diffs.add(new DiffChunk<SQLObject>(targetColumn, DiffType.RIGHTONLY)); if (targetColIter.hasNext()) { targetColumn = targetColIter.next(); } else { targetColContinue = false; break; } } // Comparing Columns while (comparator.compare(sourceColumn, targetColumn) == 0) { if (targetColumn.getType() != sourceColumn.getType() || (targetColumn.getPrecision() != sourceColumn.getPrecision()) || (targetColumn.getScale() != sourceColumn.getScale()) || (targetColumn.getNullable() != sourceColumn.getNullable()) ) { diffs.add(new DiffChunk<SQLObject>(targetColumn, DiffType.MODIFIED)); } else { diffs.add(new DiffChunk<SQLObject>(sourceColumn, DiffType.SAME)); } if (targetColIter.hasNext()) { targetColumn = targetColIter.next(); } else { targetColContinue = false; } if (sourceColIter.hasNext()) { sourceColumn = sourceColIter.next(); } else { sourceColContinue = false; } if (!sourceColContinue || !targetColContinue) { break; } } } while (sourceColContinue) { diffs.add(new DiffChunk<SQLObject>(sourceColumn, DiffType.LEFTONLY)); if (sourceColIter.hasNext()) { sourceColumn = sourceColIter.next(); } else { sourceColContinue = false; } } while (targetColContinue) { diffs.add(new DiffChunk<SQLObject>(targetColumn, DiffType.RIGHTONLY)); if (targetColIter.hasNext()) { targetColumn = targetColIter.next(); } else { targetColContinue = false; } } return diffs; }
while (comparator.compare(sourceColumn, targetColumn) == 0) {
if (comparator.compare(sourceColumn, targetColumn) == 0) {
private List<DiffChunk<SQLObject>> generateColumnDiffs( SQLTable sourceTable, SQLTable targetTable) throws ArchitectException { TreeSet<SQLColumn> sourceColumnList; TreeSet<SQLColumn> targetColumnList; Iterator<SQLColumn> sourceColIter; Iterator<SQLColumn> targetColIter; SQLColumn sourceColumn; SQLColumn targetColumn; boolean sourceColContinue; boolean targetColContinue; sourceColumnList = new TreeSet<SQLColumn>(comparator); targetColumnList = new TreeSet<SQLColumn>(comparator); sourceColContinue = false; targetColContinue = false; sourceColIter = null; targetColIter = null; sourceColumn = null; targetColumn = null; // We store the diffs in here, then return this listS List<DiffChunk<SQLObject>> diffs = new ArrayList<DiffChunk<SQLObject>>(); if (sourceTable != null) { sourceColumnList.addAll(sourceTable.getColumns()); } if (targetTable != null) { targetColumnList.addAll(targetTable.getColumns()); } if (sourceColumnList.size() == 0) { sourceColumnList = null; sourceColContinue = false; } else { sourceColIter = sourceColumnList.iterator(); sourceColumn = sourceColIter.next(); sourceColContinue = true; } if (targetColumnList.size() == 0) { targetColumnList = null; targetColContinue = false; } else { targetColIter = targetColumnList.iterator(); targetColumn = targetColIter.next(); targetColContinue = true; } while (sourceColContinue && targetColContinue) { // Comparing Columns while (comparator.compare(sourceColumn, targetColumn) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceColumn, DiffType.LEFTONLY)); if (sourceColIter.hasNext()) { sourceColumn = sourceColIter.next(); } else { sourceColContinue = false; break; } } // Comparing Columns while (comparator.compare(sourceColumn, targetColumn) > 0) { diffs.add(new DiffChunk<SQLObject>(targetColumn, DiffType.RIGHTONLY)); if (targetColIter.hasNext()) { targetColumn = targetColIter.next(); } else { targetColContinue = false; break; } } // Comparing Columns while (comparator.compare(sourceColumn, targetColumn) == 0) { if (targetColumn.getType() != sourceColumn.getType() || (targetColumn.getPrecision() != sourceColumn.getPrecision()) || (targetColumn.getScale() != sourceColumn.getScale()) || (targetColumn.getNullable() != sourceColumn.getNullable()) ) { diffs.add(new DiffChunk<SQLObject>(targetColumn, DiffType.MODIFIED)); } else { diffs.add(new DiffChunk<SQLObject>(sourceColumn, DiffType.SAME)); } if (targetColIter.hasNext()) { targetColumn = targetColIter.next(); } else { targetColContinue = false; } if (sourceColIter.hasNext()) { sourceColumn = sourceColIter.next(); } else { sourceColContinue = false; } if (!sourceColContinue || !targetColContinue) { break; } } } while (sourceColContinue) { diffs.add(new DiffChunk<SQLObject>(sourceColumn, DiffType.LEFTONLY)); if (sourceColIter.hasNext()) { sourceColumn = sourceColIter.next(); } else { sourceColContinue = false; } } while (targetColContinue) { diffs.add(new DiffChunk<SQLObject>(targetColumn, DiffType.RIGHTONLY)); if (targetColIter.hasNext()) { targetColumn = targetColIter.next(); } else { targetColContinue = false; } } return diffs; }
SQLRelationshipComparator relComparator = new SQLRelationshipComparator();
private List<DiffChunk<SQLObject>> generateRelationshipDiffs( Collection<SQLTable> sourceTables, Collection<SQLTable> targetTables) throws ArchitectException { //XXX: This is using an incorrect comparator, it only checks by relationship //names and does not get into a deeper level of checking the mappings. Set<SQLRelationship> sourceRels = new TreeSet<SQLRelationship>(comparator); Set<SQLRelationship> targetRels = new TreeSet<SQLRelationship>(comparator); for (SQLTable t : sourceTables) { sourceRels.addAll(t.getImportedKeys()); } for (SQLTable t : targetTables) { targetRels.addAll(t.getImportedKeys()); } logger.debug("Source relationships: "+sourceRels); logger.debug("Target relationships: "+targetRels); List<DiffChunk<SQLObject>> diffs = new ArrayList<DiffChunk<SQLObject>>(); Iterator<SQLRelationship> sourceIter = sourceRels.iterator(); Iterator<SQLRelationship> targetIter = targetRels.iterator(); SQLRelationship targetRel; SQLRelationship sourceRel; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceRel = sourceIter.next(); } else { sourceContinue = false; sourceRel = null; } if (targetIter.hasNext()) { targetContinue = true; targetRel = targetIter.next(); } else { targetContinue = false; targetRel = null; } // Will loop until one or both of the lists reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceRel, targetRel) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceRel, targetRel) > 0) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); // now do the mappings diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceRel, targetRel) == 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.SAME)); // now do the columns diffs.addAll(generateMappingDiffs(sourceRel, targetRel)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; } } return diffs; }
Set<SQLRelationship> sourceRels = new TreeSet<SQLRelationship>(comparator); Set<SQLRelationship> targetRels = new TreeSet<SQLRelationship>(comparator);
Set<SQLRelationship> sourceRels = new TreeSet<SQLRelationship>(relComparator); Set<SQLRelationship> targetRels = new TreeSet<SQLRelationship>(relComparator);
private List<DiffChunk<SQLObject>> generateRelationshipDiffs( Collection<SQLTable> sourceTables, Collection<SQLTable> targetTables) throws ArchitectException { //XXX: This is using an incorrect comparator, it only checks by relationship //names and does not get into a deeper level of checking the mappings. Set<SQLRelationship> sourceRels = new TreeSet<SQLRelationship>(comparator); Set<SQLRelationship> targetRels = new TreeSet<SQLRelationship>(comparator); for (SQLTable t : sourceTables) { sourceRels.addAll(t.getImportedKeys()); } for (SQLTable t : targetTables) { targetRels.addAll(t.getImportedKeys()); } logger.debug("Source relationships: "+sourceRels); logger.debug("Target relationships: "+targetRels); List<DiffChunk<SQLObject>> diffs = new ArrayList<DiffChunk<SQLObject>>(); Iterator<SQLRelationship> sourceIter = sourceRels.iterator(); Iterator<SQLRelationship> targetIter = targetRels.iterator(); SQLRelationship targetRel; SQLRelationship sourceRel; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceRel = sourceIter.next(); } else { sourceContinue = false; sourceRel = null; } if (targetIter.hasNext()) { targetContinue = true; targetRel = targetIter.next(); } else { targetContinue = false; targetRel = null; } // Will loop until one or both of the lists reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceRel, targetRel) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceRel, targetRel) > 0) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); // now do the mappings diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceRel, targetRel) == 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.SAME)); // now do the columns diffs.addAll(generateMappingDiffs(sourceRel, targetRel)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; } } return diffs; }
for (SQLTable t : sourceTables) { sourceRels.addAll(t.getImportedKeys()); }
for (SQLTable t : sourceTables) { if (t.getImportedKeys() != null){ sourceRels.addAll(t.getImportedKeys()); } } for (SQLTable t : targetTables) { if (t.getImportedKeys() != null){ targetRels.addAll(t.getImportedKeys()); } }
private List<DiffChunk<SQLObject>> generateRelationshipDiffs( Collection<SQLTable> sourceTables, Collection<SQLTable> targetTables) throws ArchitectException { //XXX: This is using an incorrect comparator, it only checks by relationship //names and does not get into a deeper level of checking the mappings. Set<SQLRelationship> sourceRels = new TreeSet<SQLRelationship>(comparator); Set<SQLRelationship> targetRels = new TreeSet<SQLRelationship>(comparator); for (SQLTable t : sourceTables) { sourceRels.addAll(t.getImportedKeys()); } for (SQLTable t : targetTables) { targetRels.addAll(t.getImportedKeys()); } logger.debug("Source relationships: "+sourceRels); logger.debug("Target relationships: "+targetRels); List<DiffChunk<SQLObject>> diffs = new ArrayList<DiffChunk<SQLObject>>(); Iterator<SQLRelationship> sourceIter = sourceRels.iterator(); Iterator<SQLRelationship> targetIter = targetRels.iterator(); SQLRelationship targetRel; SQLRelationship sourceRel; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceRel = sourceIter.next(); } else { sourceContinue = false; sourceRel = null; } if (targetIter.hasNext()) { targetContinue = true; targetRel = targetIter.next(); } else { targetContinue = false; targetRel = null; } // Will loop until one or both of the lists reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceRel, targetRel) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceRel, targetRel) > 0) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); // now do the mappings diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceRel, targetRel) == 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.SAME)); // now do the columns diffs.addAll(generateMappingDiffs(sourceRel, targetRel)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; } } return diffs; }
for (SQLTable t : targetTables) { targetRels.addAll(t.getImportedKeys()); }
private List<DiffChunk<SQLObject>> generateRelationshipDiffs( Collection<SQLTable> sourceTables, Collection<SQLTable> targetTables) throws ArchitectException { //XXX: This is using an incorrect comparator, it only checks by relationship //names and does not get into a deeper level of checking the mappings. Set<SQLRelationship> sourceRels = new TreeSet<SQLRelationship>(comparator); Set<SQLRelationship> targetRels = new TreeSet<SQLRelationship>(comparator); for (SQLTable t : sourceTables) { sourceRels.addAll(t.getImportedKeys()); } for (SQLTable t : targetTables) { targetRels.addAll(t.getImportedKeys()); } logger.debug("Source relationships: "+sourceRels); logger.debug("Target relationships: "+targetRels); List<DiffChunk<SQLObject>> diffs = new ArrayList<DiffChunk<SQLObject>>(); Iterator<SQLRelationship> sourceIter = sourceRels.iterator(); Iterator<SQLRelationship> targetIter = targetRels.iterator(); SQLRelationship targetRel; SQLRelationship sourceRel; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceRel = sourceIter.next(); } else { sourceContinue = false; sourceRel = null; } if (targetIter.hasNext()) { targetContinue = true; targetRel = targetIter.next(); } else { targetContinue = false; targetRel = null; } // Will loop until one or both of the lists reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceRel, targetRel) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceRel, targetRel) > 0) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); // now do the mappings diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceRel, targetRel) == 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.SAME)); // now do the columns diffs.addAll(generateMappingDiffs(sourceRel, targetRel)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; } } return diffs; }
while (comparator.compare(sourceRel, targetRel) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null));
if (relComparator.compare(sourceRel, targetRel) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY));
private List<DiffChunk<SQLObject>> generateRelationshipDiffs( Collection<SQLTable> sourceTables, Collection<SQLTable> targetTables) throws ArchitectException { //XXX: This is using an incorrect comparator, it only checks by relationship //names and does not get into a deeper level of checking the mappings. Set<SQLRelationship> sourceRels = new TreeSet<SQLRelationship>(comparator); Set<SQLRelationship> targetRels = new TreeSet<SQLRelationship>(comparator); for (SQLTable t : sourceTables) { sourceRels.addAll(t.getImportedKeys()); } for (SQLTable t : targetTables) { targetRels.addAll(t.getImportedKeys()); } logger.debug("Source relationships: "+sourceRels); logger.debug("Target relationships: "+targetRels); List<DiffChunk<SQLObject>> diffs = new ArrayList<DiffChunk<SQLObject>>(); Iterator<SQLRelationship> sourceIter = sourceRels.iterator(); Iterator<SQLRelationship> targetIter = targetRels.iterator(); SQLRelationship targetRel; SQLRelationship sourceRel; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceRel = sourceIter.next(); } else { sourceContinue = false; sourceRel = null; } if (targetIter.hasNext()) { targetContinue = true; targetRel = targetIter.next(); } else { targetContinue = false; targetRel = null; } // Will loop until one or both of the lists reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceRel, targetRel) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceRel, targetRel) > 0) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); // now do the mappings diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceRel, targetRel) == 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.SAME)); // now do the columns diffs.addAll(generateMappingDiffs(sourceRel, targetRel)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; } } return diffs; }
break;
private List<DiffChunk<SQLObject>> generateRelationshipDiffs( Collection<SQLTable> sourceTables, Collection<SQLTable> targetTables) throws ArchitectException { //XXX: This is using an incorrect comparator, it only checks by relationship //names and does not get into a deeper level of checking the mappings. Set<SQLRelationship> sourceRels = new TreeSet<SQLRelationship>(comparator); Set<SQLRelationship> targetRels = new TreeSet<SQLRelationship>(comparator); for (SQLTable t : sourceTables) { sourceRels.addAll(t.getImportedKeys()); } for (SQLTable t : targetTables) { targetRels.addAll(t.getImportedKeys()); } logger.debug("Source relationships: "+sourceRels); logger.debug("Target relationships: "+targetRels); List<DiffChunk<SQLObject>> diffs = new ArrayList<DiffChunk<SQLObject>>(); Iterator<SQLRelationship> sourceIter = sourceRels.iterator(); Iterator<SQLRelationship> targetIter = targetRels.iterator(); SQLRelationship targetRel; SQLRelationship sourceRel; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceRel = sourceIter.next(); } else { sourceContinue = false; sourceRel = null; } if (targetIter.hasNext()) { targetContinue = true; targetRel = targetIter.next(); } else { targetContinue = false; targetRel = null; } // Will loop until one or both of the lists reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceRel, targetRel) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceRel, targetRel) > 0) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); // now do the mappings diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceRel, targetRel) == 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.SAME)); // now do the columns diffs.addAll(generateMappingDiffs(sourceRel, targetRel)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; } } return diffs; }
while (comparator.compare(sourceRel, targetRel) > 0) {
if (relComparator.compare(sourceRel, targetRel) > 0) {
private List<DiffChunk<SQLObject>> generateRelationshipDiffs( Collection<SQLTable> sourceTables, Collection<SQLTable> targetTables) throws ArchitectException { //XXX: This is using an incorrect comparator, it only checks by relationship //names and does not get into a deeper level of checking the mappings. Set<SQLRelationship> sourceRels = new TreeSet<SQLRelationship>(comparator); Set<SQLRelationship> targetRels = new TreeSet<SQLRelationship>(comparator); for (SQLTable t : sourceTables) { sourceRels.addAll(t.getImportedKeys()); } for (SQLTable t : targetTables) { targetRels.addAll(t.getImportedKeys()); } logger.debug("Source relationships: "+sourceRels); logger.debug("Target relationships: "+targetRels); List<DiffChunk<SQLObject>> diffs = new ArrayList<DiffChunk<SQLObject>>(); Iterator<SQLRelationship> sourceIter = sourceRels.iterator(); Iterator<SQLRelationship> targetIter = targetRels.iterator(); SQLRelationship targetRel; SQLRelationship sourceRel; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceRel = sourceIter.next(); } else { sourceContinue = false; sourceRel = null; } if (targetIter.hasNext()) { targetContinue = true; targetRel = targetIter.next(); } else { targetContinue = false; targetRel = null; } // Will loop until one or both of the lists reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceRel, targetRel) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceRel, targetRel) > 0) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); // now do the mappings diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceRel, targetRel) == 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.SAME)); // now do the columns diffs.addAll(generateMappingDiffs(sourceRel, targetRel)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; } } return diffs; }
diffs.addAll(generateMappingDiffs(null, targetRel));
private List<DiffChunk<SQLObject>> generateRelationshipDiffs( Collection<SQLTable> sourceTables, Collection<SQLTable> targetTables) throws ArchitectException { //XXX: This is using an incorrect comparator, it only checks by relationship //names and does not get into a deeper level of checking the mappings. Set<SQLRelationship> sourceRels = new TreeSet<SQLRelationship>(comparator); Set<SQLRelationship> targetRels = new TreeSet<SQLRelationship>(comparator); for (SQLTable t : sourceTables) { sourceRels.addAll(t.getImportedKeys()); } for (SQLTable t : targetTables) { targetRels.addAll(t.getImportedKeys()); } logger.debug("Source relationships: "+sourceRels); logger.debug("Target relationships: "+targetRels); List<DiffChunk<SQLObject>> diffs = new ArrayList<DiffChunk<SQLObject>>(); Iterator<SQLRelationship> sourceIter = sourceRels.iterator(); Iterator<SQLRelationship> targetIter = targetRels.iterator(); SQLRelationship targetRel; SQLRelationship sourceRel; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceRel = sourceIter.next(); } else { sourceContinue = false; sourceRel = null; } if (targetIter.hasNext()) { targetContinue = true; targetRel = targetIter.next(); } else { targetContinue = false; targetRel = null; } // Will loop until one or both of the lists reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceRel, targetRel) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceRel, targetRel) > 0) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); // now do the mappings diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceRel, targetRel) == 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.SAME)); // now do the columns diffs.addAll(generateMappingDiffs(sourceRel, targetRel)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; } } return diffs; }
while (comparator.compare(sourceRel, targetRel) == 0) {
if (relComparator.compare(sourceRel, targetRel) == 0) {
private List<DiffChunk<SQLObject>> generateRelationshipDiffs( Collection<SQLTable> sourceTables, Collection<SQLTable> targetTables) throws ArchitectException { //XXX: This is using an incorrect comparator, it only checks by relationship //names and does not get into a deeper level of checking the mappings. Set<SQLRelationship> sourceRels = new TreeSet<SQLRelationship>(comparator); Set<SQLRelationship> targetRels = new TreeSet<SQLRelationship>(comparator); for (SQLTable t : sourceTables) { sourceRels.addAll(t.getImportedKeys()); } for (SQLTable t : targetTables) { targetRels.addAll(t.getImportedKeys()); } logger.debug("Source relationships: "+sourceRels); logger.debug("Target relationships: "+targetRels); List<DiffChunk<SQLObject>> diffs = new ArrayList<DiffChunk<SQLObject>>(); Iterator<SQLRelationship> sourceIter = sourceRels.iterator(); Iterator<SQLRelationship> targetIter = targetRels.iterator(); SQLRelationship targetRel; SQLRelationship sourceRel; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceRel = sourceIter.next(); } else { sourceContinue = false; sourceRel = null; } if (targetIter.hasNext()) { targetContinue = true; targetRel = targetIter.next(); } else { targetContinue = false; targetRel = null; } // Will loop until one or both of the lists reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceRel, targetRel) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceRel, targetRel) > 0) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); // now do the mappings diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceRel, targetRel) == 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.SAME)); // now do the columns diffs.addAll(generateMappingDiffs(sourceRel, targetRel)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; } } return diffs; }
diffs.addAll(generateMappingDiffs(sourceRel, targetRel));
private List<DiffChunk<SQLObject>> generateRelationshipDiffs( Collection<SQLTable> sourceTables, Collection<SQLTable> targetTables) throws ArchitectException { //XXX: This is using an incorrect comparator, it only checks by relationship //names and does not get into a deeper level of checking the mappings. Set<SQLRelationship> sourceRels = new TreeSet<SQLRelationship>(comparator); Set<SQLRelationship> targetRels = new TreeSet<SQLRelationship>(comparator); for (SQLTable t : sourceTables) { sourceRels.addAll(t.getImportedKeys()); } for (SQLTable t : targetTables) { targetRels.addAll(t.getImportedKeys()); } logger.debug("Source relationships: "+sourceRels); logger.debug("Target relationships: "+targetRels); List<DiffChunk<SQLObject>> diffs = new ArrayList<DiffChunk<SQLObject>>(); Iterator<SQLRelationship> sourceIter = sourceRels.iterator(); Iterator<SQLRelationship> targetIter = targetRels.iterator(); SQLRelationship targetRel; SQLRelationship sourceRel; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceRel = sourceIter.next(); } else { sourceContinue = false; sourceRel = null; } if (targetIter.hasNext()) { targetContinue = true; targetRel = targetIter.next(); } else { targetContinue = false; targetRel = null; } // Will loop until one or both of the lists reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceRel, targetRel) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceRel, targetRel) > 0) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); // now do the mappings diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceRel, targetRel) == 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.SAME)); // now do the columns diffs.addAll(generateMappingDiffs(sourceRel, targetRel)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; } } return diffs; }
targetContinue = false; break;
targetContinue = false;
private List<DiffChunk<SQLObject>> generateRelationshipDiffs( Collection<SQLTable> sourceTables, Collection<SQLTable> targetTables) throws ArchitectException { //XXX: This is using an incorrect comparator, it only checks by relationship //names and does not get into a deeper level of checking the mappings. Set<SQLRelationship> sourceRels = new TreeSet<SQLRelationship>(comparator); Set<SQLRelationship> targetRels = new TreeSet<SQLRelationship>(comparator); for (SQLTable t : sourceTables) { sourceRels.addAll(t.getImportedKeys()); } for (SQLTable t : targetTables) { targetRels.addAll(t.getImportedKeys()); } logger.debug("Source relationships: "+sourceRels); logger.debug("Target relationships: "+targetRels); List<DiffChunk<SQLObject>> diffs = new ArrayList<DiffChunk<SQLObject>>(); Iterator<SQLRelationship> sourceIter = sourceRels.iterator(); Iterator<SQLRelationship> targetIter = targetRels.iterator(); SQLRelationship targetRel; SQLRelationship sourceRel; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceRel = sourceIter.next(); } else { sourceContinue = false; sourceRel = null; } if (targetIter.hasNext()) { targetContinue = true; targetRel = targetIter.next(); } else { targetContinue = false; targetRel = null; } // Will loop until one or both of the lists reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceRel, targetRel) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceRel, targetRel) > 0) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); // now do the mappings diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceRel, targetRel) == 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.SAME)); // now do the columns diffs.addAll(generateMappingDiffs(sourceRel, targetRel)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; } } return diffs; }
diffs.addAll(generateMappingDiffs(sourceRel, null));
private List<DiffChunk<SQLObject>> generateRelationshipDiffs( Collection<SQLTable> sourceTables, Collection<SQLTable> targetTables) throws ArchitectException { //XXX: This is using an incorrect comparator, it only checks by relationship //names and does not get into a deeper level of checking the mappings. Set<SQLRelationship> sourceRels = new TreeSet<SQLRelationship>(comparator); Set<SQLRelationship> targetRels = new TreeSet<SQLRelationship>(comparator); for (SQLTable t : sourceTables) { sourceRels.addAll(t.getImportedKeys()); } for (SQLTable t : targetTables) { targetRels.addAll(t.getImportedKeys()); } logger.debug("Source relationships: "+sourceRels); logger.debug("Target relationships: "+targetRels); List<DiffChunk<SQLObject>> diffs = new ArrayList<DiffChunk<SQLObject>>(); Iterator<SQLRelationship> sourceIter = sourceRels.iterator(); Iterator<SQLRelationship> targetIter = targetRels.iterator(); SQLRelationship targetRel; SQLRelationship sourceRel; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceRel = sourceIter.next(); } else { sourceContinue = false; sourceRel = null; } if (targetIter.hasNext()) { targetContinue = true; targetRel = targetIter.next(); } else { targetContinue = false; targetRel = null; } // Will loop until one or both of the lists reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceRel, targetRel) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceRel, targetRel) > 0) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); // now do the mappings diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceRel, targetRel) == 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.SAME)); // now do the columns diffs.addAll(generateMappingDiffs(sourceRel, targetRel)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; } } return diffs; }
diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); diffs.addAll(generateMappingDiffs(null, targetRel));
diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY));
private List<DiffChunk<SQLObject>> generateRelationshipDiffs( Collection<SQLTable> sourceTables, Collection<SQLTable> targetTables) throws ArchitectException { //XXX: This is using an incorrect comparator, it only checks by relationship //names and does not get into a deeper level of checking the mappings. Set<SQLRelationship> sourceRels = new TreeSet<SQLRelationship>(comparator); Set<SQLRelationship> targetRels = new TreeSet<SQLRelationship>(comparator); for (SQLTable t : sourceTables) { sourceRels.addAll(t.getImportedKeys()); } for (SQLTable t : targetTables) { targetRels.addAll(t.getImportedKeys()); } logger.debug("Source relationships: "+sourceRels); logger.debug("Target relationships: "+targetRels); List<DiffChunk<SQLObject>> diffs = new ArrayList<DiffChunk<SQLObject>>(); Iterator<SQLRelationship> sourceIter = sourceRels.iterator(); Iterator<SQLRelationship> targetIter = targetRels.iterator(); SQLRelationship targetRel; SQLRelationship sourceRel; boolean sourceContinue; boolean targetContinue; //Checks if both lists of tables contain any tables at all, if they do //the iterator is initialized for the list if (sourceIter.hasNext()) { sourceContinue = true; sourceRel = sourceIter.next(); } else { sourceContinue = false; sourceRel = null; } if (targetIter.hasNext()) { targetContinue = true; targetRel = targetIter.next(); } else { targetContinue = false; targetRel = null; } // Will loop until one or both of the lists reaches its last table while (sourceContinue && targetContinue) { // bring the source table up to the same level as the target while (comparator.compare(sourceRel, targetRel) < 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } // bring the target table up to the same level as the source while (comparator.compare(sourceRel, targetRel) > 0) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); // now do the mappings diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } } while (comparator.compare(sourceRel, targetRel) == 0) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.SAME)); // now do the columns diffs.addAll(generateMappingDiffs(sourceRel, targetRel)); if (!targetIter.hasNext() && !sourceIter.hasNext()) { targetContinue = false; sourceContinue = false; break; } if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; break; } if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; break; } } } // If any tables in the sourceList still exist, the changes are added while (sourceContinue) { diffs.add(new DiffChunk<SQLObject>(sourceRel, DiffType.LEFTONLY)); diffs.addAll(generateMappingDiffs(sourceRel, null)); if (sourceIter.hasNext()) { sourceRel = sourceIter.next(); } else { sourceContinue = false; } } //If any remaining tables in the targetList still exist, they are now being added while (targetContinue) { diffs.add(new DiffChunk<SQLObject>(targetRel, DiffType.RIGHTONLY)); diffs.addAll(generateMappingDiffs(null, targetRel)); if (targetIter.hasNext()) { targetRel = targetIter.next(); } else { targetContinue = false; } } return diffs; }
public String draw();
public String draw(String applicationName);
public String draw();
private void applicationChanged(ApplicationConfig appConfig) { removeApplication(appConfig); addApplication(appConfig);
private void applicationChanged(ApplicationEvent appEvent) { removeApplication(appEvent.getApplicationConfig()); addApplication(appEvent);
private void applicationChanged(ApplicationConfig appConfig) { removeApplication(appConfig); addApplication(appConfig); }
addApplication(((NewApplicationEvent)event).getApplicationConfig());
addApplication((NewApplicationEvent)event);
public void start() { for (ApplicationConfig appConfig : ApplicationConfigManager .getAllApplications()) { // only add non-cluster applications if(!appConfig.isCluster()) addApplication(appConfig); } // TODO: perfect dependency to be injected via Spring framework --rk EventSystem eventSystem = EventSystem.getInstance(); /* Add the recorder to record the downtimes to the DB */ eventSystem.addListener(recorder, ApplicationEvent.class); /* application event listener to add */ eventSystem.addListener(new EventListener(){ public void handleEvent(EventObject event) { if(!(event instanceof ApplicationEvent)){ throw new IllegalArgumentException("event must be of type ApplicationEvent"); } if(event instanceof NewApplicationEvent){ addApplication(((NewApplicationEvent)event).getApplicationConfig()); }else if(event instanceof ApplicationChangedEvent){ applicationChanged(((ApplicationChangedEvent)event).getApplicationConfig()); }else if(event instanceof ApplicationRemovedEvent){ removeApplication(((ApplicationRemovedEvent)event).getApplicationConfig()); } } }, ApplicationEvent.class); logger.info("ApplicationDowntimeService started."); }
applicationChanged(((ApplicationChangedEvent)event).getApplicationConfig());
applicationChanged((ApplicationChangedEvent)event);
public void start() { for (ApplicationConfig appConfig : ApplicationConfigManager .getAllApplications()) { // only add non-cluster applications if(!appConfig.isCluster()) addApplication(appConfig); } // TODO: perfect dependency to be injected via Spring framework --rk EventSystem eventSystem = EventSystem.getInstance(); /* Add the recorder to record the downtimes to the DB */ eventSystem.addListener(recorder, ApplicationEvent.class); /* application event listener to add */ eventSystem.addListener(new EventListener(){ public void handleEvent(EventObject event) { if(!(event instanceof ApplicationEvent)){ throw new IllegalArgumentException("event must be of type ApplicationEvent"); } if(event instanceof NewApplicationEvent){ addApplication(((NewApplicationEvent)event).getApplicationConfig()); }else if(event instanceof ApplicationChangedEvent){ applicationChanged(((ApplicationChangedEvent)event).getApplicationConfig()); }else if(event instanceof ApplicationRemovedEvent){ removeApplication(((ApplicationRemovedEvent)event).getApplicationConfig()); } } }, ApplicationEvent.class); logger.info("ApplicationDowntimeService started."); }
addApplication(((NewApplicationEvent)event).getApplicationConfig());
addApplication((NewApplicationEvent)event);
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()); }else if(event instanceof ApplicationRemovedEvent){ removeApplication(((ApplicationRemovedEvent)event).getApplicationConfig()); } }
applicationChanged(((ApplicationChangedEvent)event).getApplicationConfig());
applicationChanged((ApplicationChangedEvent)event);
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()); }else if(event instanceof ApplicationRemovedEvent){ removeApplication(((ApplicationRemovedEvent)event).getApplicationConfig()); } }
} catch (Exception e) {
} catch (ConnectionFailedException e){
public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { makeResponseNotCacheable(response); final ObjectName objectName = context.getObjectName(); final ApplicationConfig config = context.getApplicationConfig(); final MBeanConfig configuredMBean = config.findMBeanByObjectName(objectName.getCanonicalName()); AccessController.checkAccess(context.getServiceContext(), ACL_VIEW_APPLICATIONS); if(configuredMBean != null) AccessController.checkAccess(context.getServiceContext(), ACL_VIEW_MBEANS); List applications = null; if(config.isCluster()){ applications = config.getApplications(); }else{ applications = new ArrayList(1); applications.add(config); } /* the ObjectInfo for the mbean that is being viewed */ ObjectInfo objInfo = null; /* array that will be initialized with all attribute names for this mbean */ String[] attributeNames = null; /* a Map which constains list of attribute values for each application in the cluster. ApplicationConfig is the key and attribute List is the value*/ final Map appConfigToAttrListMap = new HashMap(applications.size()); for(Iterator it=applications.iterator(); it.hasNext(); ){ ApplicationConfig childAppConfig = (ApplicationConfig)it.next(); try { ServerConnection serverConnection = ServerConnector.getServerConnection(childAppConfig); /* assuming that all servers in this cluster have exact same object info, we will get the ObjectInfo from the first server in the list */ if(objInfo == null){ objInfo = serverConnection.getObjectInfo(objectName); assert objInfo != null; ObjectAttributeInfo[] attributes = objInfo.getAttributes(); attributeNames = new String[attributes.length]; for (int i = 0; i < attributes.length; i++) { // TODO: we should only add the readable attributes here attributeNames[i] = attributes[i].getName(); } } /* add attribute values of this application to the map*/ appConfigToAttrListMap.put(childAppConfig, serverConnection.getAttributes(objectName, attributeNames)); } catch (Exception e) { logger.log(Level.FINE, "Error retrieving attributes for:" + childAppConfig.getName(), e); /* add null, indicating that the server is down */ appConfigToAttrListMap.put(childAppConfig, null); } } request.setAttribute("objInfo", objInfo); request.setAttribute("appConfigToAttrListMap", appConfigToAttrListMap); /* setup the form to be used in the html form */ MBeanConfigForm mbeanConfigForm = (MBeanConfigForm)actionForm; mbeanConfigForm.setObjectName(objectName.getCanonicalName()); ApplicationConfig appConfig = context.getApplicationConfig(); MBeanConfig mbeanConfig = appConfig.findMBeanByObjectName(objectName.getCanonicalName()); if(mbeanConfig != null){ if(appConfig.isCluster()){ request.setAttribute("mbeanIncludedIn", "cluster"); }else{ request.setAttribute("mbeanIncludedIn", "application"); } request.setAttribute("mbeanConfig", mbeanConfig); }else{ ApplicationConfig clusterConfig = appConfig.getClusterConfig(); if(clusterConfig != null){ mbeanConfig = clusterConfig.findMBeanByObjectName(objectName.getCanonicalName()); } if(mbeanConfig != null){ request.setAttribute("mbeanIncludedIn", "cluster"); request.setAttribute("mbeanConfig", mbeanConfig); } } return mapping.findForward(Forwards.SUCCESS); }
super("Edit Table Properties...",
super("Table Properties...",
public EditTableAction() { super("Edit Table Properties...", ASUtils.createIcon("TableProperties", "Edit Table Properties", ArchitectFrame.getMainInstance().sprefs.getInt(SwingUserSettings.ICON_SIZE, 24))); }
"Edit Table Properties",
"Table Properties",
public EditTableAction() { super("Edit Table Properties...", ASUtils.createIcon("TableProperties", "Edit Table Properties", ArchitectFrame.getMainInstance().sprefs.getInt(SwingUserSettings.ICON_SIZE, 24))); }
putValue(SHORT_DESCRIPTION, "Table Properties");
public EditTableAction() { super("Edit Table Properties...", ASUtils.createIcon("TableProperties", "Edit Table Properties", ArchitectFrame.getMainInstance().sprefs.getInt(SwingUserSettings.ICON_SIZE, 24))); }
"match"
element
protected SAXReader createSAXReader() throws Exception { // installs the NekoHTML parser SAXParser parser = new SAXParser(); parser.setProperty( "http://cyberneko.org/html/properties/names/elems", "match" ); parser.setProperty( "http://cyberneko.org/html/properties/names/attrs", "match" ); return new SAXReader( parser ); }
"match"
attribute
protected SAXReader createSAXReader() throws Exception { // installs the NekoHTML parser SAXParser parser = new SAXParser(); parser.setProperty( "http://cyberneko.org/html/properties/names/elems", "match" ); parser.setProperty( "http://cyberneko.org/html/properties/names/attrs", "match" ); return new SAXReader( parser ); }
registerTag("sleep", SleepTag.class);
public UtilTagLibrary() { registerTag("loadText", LoadTextTag.class); registerTag("properties", PropertiesTag.class); registerTag("tokenize", TokenizeTag.class); }
suite.addTestSuite(TestCompareDMPanel.class);
public static Test suite() { TestSuite suite = new TestSuite("Test for Architect's Swing GUI"); //$JUnit-BEGIN$ suite.addTestSuite(TestSwingUIProject.class); suite.addTestSuite(TestArchitectFrame.class); suite.addTestSuite(TestAutoLayoutAction.class); suite.addTestSuite(TestPlayPen.class); suite.addTestSuite(TestUndoManager.class); suite.addTestSuite(TestColumnEditPanel.class); suite.addTestSuite(TestSQLObjectUndoableEventAdapter.class); suite.addTestSuite(TestFruchtermanReingoldForceLayout.class); //$JUnit-END$ return suite; }
if ( uri == null ) { throw new JellyException( "<j:include> must have a 'uri' attribute defined" );
if (uri == null) { throw new MissingAttributeException( "uri" );
public void doTag(XMLOutput output) throws Exception { if ( uri == null ) { throw new JellyException( "<j:include> must have a 'uri' attribute defined" ); } // we need to create a new JellyContext of the URI // take off the script name from the URL context.runScript( uri, output ); }
public Object getSource() {
public String getSource() {
public Object getSource() { return source; }
public void setSource(Object source) {
public void setSource(String source) {
public void setSource(Object source) { this.source = source; }
if (!isNew) { oldName = dbcsPanel.getDbcs().getName(); } else { oldName = null; }
public DBCS_OkAction(DBCSPanel dbcsPanel, boolean isNew) { super("Ok"); this.dbcsPanel = dbcsPanel; this.isNew = isNew; }
public void actionPerformed(ActionEvent e) { logger.debug(getValue(SHORT_DESCRIPTION) + " started"); dbcsPanel.applyChanges();
public void actionPerformed(ActionEvent e) {
public void actionPerformed(ActionEvent e) { logger.debug(getValue(SHORT_DESCRIPTION) + " started"); dbcsPanel.applyChanges(); ArchitectDataSource newDS = dbcsPanel.getDbcs(); if (isNew) { if ("".equals(newDS.getName().trim())) { JOptionPane.showMessageDialog(newConnectionDialog,"A connection must have at least 1 character that is not whitespace"); newConnectionDialog.setVisible(true); } else { PlDotIni plDotIni = ArchitectFrame.getMainInstance().getUserSettings().getPlDotIni(); if (plDotIni.getDataSource(newDS.getName()) == null ) { plDotIni.addDataSource(newDS); } else { JOptionPane.showMessageDialog(newConnectionDialog,"A connection with the name \""+newDS.getName()+"\" already exists"); newConnectionDialog.setVisible(true); } } } }
JOptionPane.showMessageDialog(newConnectionDialog,"A connection with the name \""+newDS.getName()+"\" already exists");
JOptionPane.showMessageDialog(newConnectionDialog,"A connection with the name \""+curName+"\" already exists");
public void actionPerformed(ActionEvent e) { logger.debug(getValue(SHORT_DESCRIPTION) + " started"); dbcsPanel.applyChanges(); ArchitectDataSource newDS = dbcsPanel.getDbcs(); if (isNew) { if ("".equals(newDS.getName().trim())) { JOptionPane.showMessageDialog(newConnectionDialog,"A connection must have at least 1 character that is not whitespace"); newConnectionDialog.setVisible(true); } else { PlDotIni plDotIni = ArchitectFrame.getMainInstance().getUserSettings().getPlDotIni(); if (plDotIni.getDataSource(newDS.getName()) == null ) { plDotIni.addDataSource(newDS); } else { JOptionPane.showMessageDialog(newConnectionDialog,"A connection with the name \""+newDS.getName()+"\" already exists"); newConnectionDialog.setVisible(true); } } } }
}
} else if (curName.equals(oldName)) { System.out.println("The current Name is the same as the old name"); dbcsPanel.applyChanges(); } else { PlDotIni plDotIni = ArchitectFrame.getMainInstance().getUserSettings().getPlDotIni(); if (plDotIni.getDataSource(newDS.getName()) == null ) { dbcsPanel.applyChanges(); } else { JOptionPane.showMessageDialog(newConnectionDialog,"A connection with the name \""+curName+"\" already exists"); newConnectionDialog.setVisible(true); } }
public void actionPerformed(ActionEvent e) { logger.debug(getValue(SHORT_DESCRIPTION) + " started"); dbcsPanel.applyChanges(); ArchitectDataSource newDS = dbcsPanel.getDbcs(); if (isNew) { if ("".equals(newDS.getName().trim())) { JOptionPane.showMessageDialog(newConnectionDialog,"A connection must have at least 1 character that is not whitespace"); newConnectionDialog.setVisible(true); } else { PlDotIni plDotIni = ArchitectFrame.getMainInstance().getUserSettings().getPlDotIni(); if (plDotIni.getDataSource(newDS.getName()) == null ) { plDotIni.addDataSource(newDS); } else { JOptionPane.showMessageDialog(newConnectionDialog,"A connection with the name \""+newDS.getName()+"\" already exists"); newConnectionDialog.setVisible(true); } } } }
}
} else { g2.setBackground( this.getBackground() ); }
private void paintThumbnail( Graphics2D g2, PhotoInfo photo, int startx, int starty, boolean isSelected ) { log.debug( "paintThumbnail entry " + photo.getUid() ); long startTime = System.currentTimeMillis(); long thumbReadyTime = 0; long thumbDrawnTime = 0; long endTime = 0; // Current position in which attributes can be drawn int ypos = starty + rowHeight/2; // Create a transaction which will be used for persisten object operations // during painting (to avoid creating several short-livin transactions) ODMGXAWrapper txw = new ODMGXAWrapper(); if ( photo != null ) { Thumbnail thumbnail = null; log.debug( "finding thumb" ); boolean hasThumbnail = photo.hasThumbnail(); log.debug( "asked if has thumb" ); if ( hasThumbnail ) { log.debug( "Photo " + photo.getUid() + " has thumbnail" ); thumbnail = photo.getThumbnail(); log.debug( "got thumbnail" ); } else { thumbnail = Thumbnail.getDefaultThumbnail(); if ( !thumbCreatorThread.isBusy() ) { log.debug( "Create thumbnail for " + photo.getUid() ); thumbCreatorThread.createThumbnail( photo ); log.debug( "Thumbnail request submitted" ); } } thumbReadyTime = System.currentTimeMillis(); log.debug( "starting to draw" ); // Find the position for the thumbnail BufferedImage img = thumbnail.getImage(); int x = startx + (columnWidth - img.getWidth())/(int)2; int y = starty + (rowHeight - img.getHeight())/(int)2; log.debug( "drawing thumbnail" ); g2.drawImage( img, new AffineTransform( 1f, 0f, 0f, 1f, x, y ), null ); log.debug( "Drawn, drawing decorations" ); if ( isSelected ) { Stroke prevStroke = g2.getStroke(); Color prevColor = g2.getColor(); g2.setStroke( new BasicStroke( 3.0f) ); g2.setColor( Color.BLUE ); g2.drawRect( x, y, img.getWidth(), img.getHeight() ); g2.setColor( prevColor ); g2.setStroke( prevStroke ); } thumbDrawnTime = System.currentTimeMillis(); // Increase ypos so that attributes are drawn under the image ypos += ((int)img.getHeight())/2 + 4; // Draw the attributes Color prevBkg = g2.getBackground(); if ( isSelected ) { g2.setBackground( Color.BLUE ); } Font attrFont = new Font( "Arial", Font.PLAIN, 10 ); FontRenderContext frc = g2.getFontRenderContext(); if ( showDate && photo.getShootTime() != null ) { FuzzyDate fd = new FuzzyDate( photo.getShootTime(), photo.getTimeAccuracy() ); String dateStr = fd.format(); TextLayout txt = new TextLayout( dateStr, attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth - bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } String shootPlace = photo.getShootingPlace(); if ( showPlace && shootPlace != null && shootPlace.length() > 0 ) { TextLayout txt = new TextLayout( photo.getShootingPlace(), attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth-bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } g2.setBackground( prevBkg ); } txw.commit(); endTime = System.currentTimeMillis(); log.debug( "paintThumbnail: exit " + photo.getUid() ); log.debug( "Thumb fetch " + (thumbReadyTime - startTime ) + " ms" ); log.debug( "Thumb draw " + ( thumbDrawnTime - thumbReadyTime ) + " ms" ); log.debug( "Deacoration draw " + (endTime - thumbDrawnTime ) + " ms" ); log.debug( "Total " + (endTime - startTime ) + " ms" ); }
Date lower = new Date( date.getTime() - lAccuracy ); Date upper = new Date( date.getTime() + (lAccuracy-1) ); if ( fdParsers == null ) { createParsers(); }
public String format() { long lAccuracy = (long) (accuracy * 24 * 3600 * 1000); String dateStr = ""; if ( date == null ) { return ""; } if ( accuracy > 0 ) { // Find the correct format to use String formatStr =accuracyFormatStrings[0]; for ( int i = 1; i < accuracyFormatLimits.length; i++ ) { if ( accuracy < accuracyFormatLimits[i] ) { break; } formatStr =accuracyFormatStrings[i]; } // Show the limits of the accuracy range DateFormat df = new SimpleDateFormat( formatStr ); Date lower = new Date( date.getTime() - lAccuracy ); Date upper = new Date( date.getTime() + lAccuracy ); String lowerStr = df.format( lower ); String upperStr = df.format( upper ); dateStr = lowerStr; if ( !lowerStr.equals( upperStr ) ) { dateStr += " - " + upperStr; } } else { DateFormat df = new SimpleDateFormat( "dd.MM.yyyy k:mm" ); dateStr = df.format( date ); } return dateStr; }
String formatStr =accuracyFormatStrings[0]; for ( int i = 1; i < accuracyFormatLimits.length; i++ ) { if ( accuracy < accuracyFormatLimits[i] ) {
FuzzyDateParser parser = fdParsers[0]; for ( int i = 0; i < fdParsers.length; i++ ) { if ( (2 * lAccuracy) < fdParsers[i].getFuzzyPeriodLength( lower ) ) {
public String format() { long lAccuracy = (long) (accuracy * 24 * 3600 * 1000); String dateStr = ""; if ( date == null ) { return ""; } if ( accuracy > 0 ) { // Find the correct format to use String formatStr =accuracyFormatStrings[0]; for ( int i = 1; i < accuracyFormatLimits.length; i++ ) { if ( accuracy < accuracyFormatLimits[i] ) { break; } formatStr =accuracyFormatStrings[i]; } // Show the limits of the accuracy range DateFormat df = new SimpleDateFormat( formatStr ); Date lower = new Date( date.getTime() - lAccuracy ); Date upper = new Date( date.getTime() + lAccuracy ); String lowerStr = df.format( lower ); String upperStr = df.format( upper ); dateStr = lowerStr; if ( !lowerStr.equals( upperStr ) ) { dateStr += " - " + upperStr; } } else { DateFormat df = new SimpleDateFormat( "dd.MM.yyyy k:mm" ); dateStr = df.format( date ); } return dateStr; }
formatStr =accuracyFormatStrings[i];
parser = fdParsers[i];
public String format() { long lAccuracy = (long) (accuracy * 24 * 3600 * 1000); String dateStr = ""; if ( date == null ) { return ""; } if ( accuracy > 0 ) { // Find the correct format to use String formatStr =accuracyFormatStrings[0]; for ( int i = 1; i < accuracyFormatLimits.length; i++ ) { if ( accuracy < accuracyFormatLimits[i] ) { break; } formatStr =accuracyFormatStrings[i]; } // Show the limits of the accuracy range DateFormat df = new SimpleDateFormat( formatStr ); Date lower = new Date( date.getTime() - lAccuracy ); Date upper = new Date( date.getTime() + lAccuracy ); String lowerStr = df.format( lower ); String upperStr = df.format( upper ); dateStr = lowerStr; if ( !lowerStr.equals( upperStr ) ) { dateStr += " - " + upperStr; } } else { DateFormat df = new SimpleDateFormat( "dd.MM.yyyy k:mm" ); dateStr = df.format( date ); } return dateStr; }
DateFormat df = new SimpleDateFormat( formatStr ); Date lower = new Date( date.getTime() - lAccuracy ); Date upper = new Date( date.getTime() + lAccuracy ); String lowerStr = df.format( lower ); String upperStr = df.format( upper );
String lowerStr = parser.format( lower ); String upperStr = parser.format( upper );
public String format() { long lAccuracy = (long) (accuracy * 24 * 3600 * 1000); String dateStr = ""; if ( date == null ) { return ""; } if ( accuracy > 0 ) { // Find the correct format to use String formatStr =accuracyFormatStrings[0]; for ( int i = 1; i < accuracyFormatLimits.length; i++ ) { if ( accuracy < accuracyFormatLimits[i] ) { break; } formatStr =accuracyFormatStrings[i]; } // Show the limits of the accuracy range DateFormat df = new SimpleDateFormat( formatStr ); Date lower = new Date( date.getTime() - lAccuracy ); Date upper = new Date( date.getTime() + lAccuracy ); String lowerStr = df.format( lower ); String upperStr = df.format( upper ); dateStr = lowerStr; if ( !lowerStr.equals( upperStr ) ) { dateStr += " - " + upperStr; } } else { DateFormat df = new SimpleDateFormat( "dd.MM.yyyy k:mm" ); dateStr = df.format( date ); } return dateStr; }
showInPlayPenAction = new ShowInPlayPenAction();
public DBTree() { setUI(new MultiDragTreeUI()); setRootVisible(false); setShowsRootHandles(true); ds = new DragSource(); DragGestureRecognizer dgr = ds.createDefaultDragGestureRecognizer (this, DnDConstants.ACTION_COPY, new DBTreeDragGestureListener()); newDBCSAction = new NewDBCSAction(); dbcsPropertiesAction = new DBCSPropertiesAction(); removeDBCSAction = new RemoveDBCSAction(); setupPropDialog(); addMouseListener(new PopupListener()); setCellRenderer(new SQLObjectRenderer()); }
mi = new JMenuItem(); mi.setAction(showInPlayPenAction); newMenu.add(mi);
protected JPopupMenu refreshMenu(TreePath p) { logger.debug("refreshMenu is being called."); JPopupMenu newMenu = new JPopupMenu(); if (isTargetDatabaseNode(p)) { // two menu items: "Set Target Database" and "Connection Properties newMenu.add(connectionsMenu = new JMenu("Set Target Database")); if (ArchitectFrame.getMainInstance().getUserSettings().getConnections().size() == 0) { // disable if there's no connections in user settings yet (annoying, but less confusing) connectionsMenu.setEnabled(false); } else { // populate Iterator it = ArchitectFrame.getMainInstance().getUserSettings().getConnections().iterator(); while(it.hasNext()) { ArchitectDataSource dbcs = (ArchitectDataSource) it.next(); connectionsMenu.add(new JMenuItem(new setTargetDBCSAction(dbcs))); } /* this doesn't work, but it's what I want to do... final ScrollablePopupMenu smenu = new ScrollablePopupMenu(new Vector(ArchitectFrame.getMainInstance().getUserSettings().getConnections())); smenu.addActionListener( new ActionListener() { public void actionPerformed (ActionEvent evt) { ArchitectDataSource dbcs = (ArchitectDataSource) smenu.getSelectedItem(); logger.debug("Performing setTargetDBCSAction..."); panelHoldsNewDBCS = false; // we are editing the Target Database dbcs, which has already been created edittingDB = ArchitectFrame.getMainInstance().getProject().getPlayPen().getDatabase(); // copy over the values from the selected DB. ArchitectDataSource tSpec = edittingDB.getDataSource(); // don't copy the sequence number, or it will prevent the Target Database and whatever it // was cloned from from co-existing in the same project tSpec.setDriverClass(dbcs.getDriverClass()); tSpec.setUrl(dbcs.getUrl()); tSpec.setUser(dbcs.getUser()); tSpec.setPass(dbcs.getPass()); // for some reason, the above property change events are not being received properly by // parent SQLDatabase objects dbcsPanel.setDbcs(tSpec); propDialog.setVisible(true); propDialog.requestFocus(); } }); connectionsMenu.add(smenu); */ } JMenuItem popupProperties = new JMenuItem(dbcsPropertiesAction); newMenu.add(popupProperties); } else if (isTargetDatabaseChild(p)) { ArchitectFrame af = ArchitectFrame.getMainInstance(); JMenuItem mi; mi = new JMenuItem(); mi.setAction(af.editColumnAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if(p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLColumn.class) { mi.setEnabled(true); } else { mi.setEnabled(false); } mi = new JMenuItem(); mi.setAction(af.insertColumnAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if(p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLTable.class || p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLColumn.class) { mi.setEnabled(true); } else { mi.setEnabled(false); } newMenu.addSeparator(); mi = new JMenuItem(); mi.setAction(af.editTableAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if(p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLTable.class || p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLColumn.class) { mi.setEnabled(true); } else { mi.setEnabled(false); } mi = new JMenuItem(); mi.setAction(af.editRelationshipAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if(p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLRelationship.class) { mi.setEnabled(true); } else { mi.setEnabled(false); } mi = new JMenuItem(); mi.setAction(af.deleteSelectedAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if(p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLTable.class || p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLColumn.class || p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLRelationship.class) { mi.setEnabled(true); } else { mi.setEnabled(false); } } else if (p != null) { // clicked on DBCS item in DBTree if (p.getLastPathComponent() instanceof SQLDatabase) { newMenu.add(new JMenuItem(removeDBCSAction)); } JMenuItem popupProperties = new JMenuItem(dbcsPropertiesAction); newMenu.add(popupProperties); } else { // p == null, background click newMenu.add(connectionsMenu = new JMenu("Add Connection")); connectionsMenu.add(new JMenuItem(newDBCSAction)); connectionsMenu.addSeparator(); // populate Iterator it = ArchitectFrame.getMainInstance().getUserSettings().getConnections().iterator(); while(it.hasNext()) { ArchitectDataSource dbcs = (ArchitectDataSource) it.next(); connectionsMenu.add(new JMenuItem(new AddDBCSAction(dbcs))); } } // add in Show Listeners if debug is enabled if (logger.isDebugEnabled()) { newMenu.addSeparator(); JMenuItem showListeners = new JMenuItem("Show Listeners"); showListeners.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SQLObject so = (SQLObject) getLastSelectedPathComponent(); if (so != null) { JOptionPane.showMessageDialog(DBTree.this, new JScrollPane(new JList(new java.util.Vector(so.getSQLObjectListeners())))); } } }); newMenu.add(showListeners); } return newMenu; }
public Object evaluate(Context context) { try {
public Object evaluate(JellyContext context) {
public Object evaluate(Context context) { try { JexlContext jexlContext = new JexlContext() { Map ctx; public void setVars(Map vars) { ctx = vars; } public Map getVars() { return ctx; } }; jexlContext.setVars(context.getVariables()); if ( log.isDebugEnabled() ) { log.debug( "Evaluating EL: " + expression ); } return expression.evaluate( jexlContext ); } catch (Exception e) { log.warn( "Caught exception evaluating: " + expression + ". Reason: " + e, e ); return null; } }
JexlContext jexlContext = new JexlContext() { Map ctx;
try {
public Object evaluate(Context context) { try { JexlContext jexlContext = new JexlContext() { Map ctx; public void setVars(Map vars) { ctx = vars; } public Map getVars() { return ctx; } }; jexlContext.setVars(context.getVariables()); if ( log.isDebugEnabled() ) { log.debug( "Evaluating EL: " + expression ); } return expression.evaluate( jexlContext ); } catch (Exception e) { log.warn( "Caught exception evaluating: " + expression + ". Reason: " + e, e ); return null; } }
public void setVars(Map vars) { ctx = vars; }
JexlContext jexlContext = new JexlContext() {
public Object evaluate(Context context) { try { JexlContext jexlContext = new JexlContext() { Map ctx; public void setVars(Map vars) { ctx = vars; } public Map getVars() { return ctx; } }; jexlContext.setVars(context.getVariables()); if ( log.isDebugEnabled() ) { log.debug( "Evaluating EL: " + expression ); } return expression.evaluate( jexlContext ); } catch (Exception e) { log.warn( "Caught exception evaluating: " + expression + ". Reason: " + e, e ); return null; } }
public Map getVars() { return ctx; } };
Map ctx;
public Object evaluate(Context context) { try { JexlContext jexlContext = new JexlContext() { Map ctx; public void setVars(Map vars) { ctx = vars; } public Map getVars() { return ctx; } }; jexlContext.setVars(context.getVariables()); if ( log.isDebugEnabled() ) { log.debug( "Evaluating EL: " + expression ); } return expression.evaluate( jexlContext ); } catch (Exception e) { log.warn( "Caught exception evaluating: " + expression + ". Reason: " + e, e ); return null; } }
jexlContext.setVars(context.getVariables());
public void setVars(Map vars) {
public Object evaluate(Context context) { try { JexlContext jexlContext = new JexlContext() { Map ctx; public void setVars(Map vars) { ctx = vars; } public Map getVars() { return ctx; } }; jexlContext.setVars(context.getVariables()); if ( log.isDebugEnabled() ) { log.debug( "Evaluating EL: " + expression ); } return expression.evaluate( jexlContext ); } catch (Exception e) { log.warn( "Caught exception evaluating: " + expression + ". Reason: " + e, e ); return null; } }
if ( log.isDebugEnabled() ) { log.debug( "Evaluating EL: " + expression ); } return expression.evaluate( jexlContext ); } catch (Exception e) { log.warn( "Caught exception evaluating: " + expression + ". Reason: " + e, e ); return null; } }
ctx = vars; } public Map getVars() { return ctx; } }; jexlContext.setVars(context.getVariables()); if (log.isDebugEnabled()) { log.debug("Evaluating EL: " + expression); } return expression.evaluate(jexlContext); } catch (Exception e) { log.warn("Caught exception evaluating: " + expression + ". Reason: " + e, e); return null; } }
public Object evaluate(Context context) { try { JexlContext jexlContext = new JexlContext() { Map ctx; public void setVars(Map vars) { ctx = vars; } public Map getVars() { return ctx; } }; jexlContext.setVars(context.getVariables()); if ( log.isDebugEnabled() ) { log.debug( "Evaluating EL: " + expression ); } return expression.evaluate( jexlContext ); } catch (Exception e) { log.warn( "Caught exception evaluating: " + expression + ". Reason: " + e, e ); return null; } }
unrelatedIndividuals = new Vector();
unrelatedIndividuals = useable;
public Vector check() throws PedFileException{ //before we perform the check we want to prune out individuals with too much missing data //or trios which contain individuals with too much missing data Iterator fitr = families.values().iterator(); Vector useable = new Vector(); while (fitr.hasNext()){ Family curFam = (Family) fitr.next(); Enumeration indIDEnum = curFam.getMemberList(); Vector victor = new Vector(); while (indIDEnum.hasMoreElements()){ victor.add(curFam.getMember((String) indIDEnum.nextElement())); } PedParser pp = new PedParser(); try { SimpleGraph sg = pp.buildGraph(victor, Options.getMissingThreshold()); Vector indStrings = pp.parsePed(sg); if (indStrings != null){ Iterator sitr = indStrings.iterator(); while (sitr.hasNext()){ useable.add(curFam.getMember((String)sitr.next())); } } }catch (PedigreeException pe){ String pem = pe.getMessage(); if (pem.indexOf("one parent") != -1){ indIDEnum = curFam.getMemberList(); while (indIDEnum.hasMoreElements()){ curFam.getMember((String) indIDEnum.nextElement()).setReasonImAxed(pem); } }else{ throw new PedFileException(pem + "\nin family " + curFam.getFamilyName()); } } } unrelatedIndividuals = new Vector(); Vector indList = (Vector)allIndividuals.clone(); Individual currentInd; Family currentFamily; //deal with individuals who are missing too much data for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.elementAt(x); currentFamily = getFamily(currentInd.getFamilyID()); if (currentInd.getGenoPC() < 1 - Options.getMissingThreshold()){ allIndividuals.removeElement(currentInd); axedPeople.add(currentInd); currentInd.setReasonImAxed("% Genotypes: " + new Double(currentInd.getGenoPC()*100).intValue()); currentFamily.removeMember(currentInd.getIndividualID()); if (currentFamily.getNumMembers() == 0){ //if everyone in a family is gone, we remove it from the list families.remove(currentInd.getFamilyID()); } }else if (!useable.contains(currentInd)){ axedPeople.add(currentInd); if (currentInd.getReasonImAxed() == null){ currentInd.setReasonImAxed("Not a member of maximum unrelated subset."); } } } if (useable.size() == 0){ //todo: this should be more specific about the problems. throw new PedFileException("File contains zero valid individuals."); } CheckData cd = new CheckData(this); Vector results = cd.check(); this.results = results; return results; }
return;
logger.debug("SQLColumn: populate is a no-op");
public void populate() throws ArchitectException { // SQLColumn doesn't have children, so populate does nothing! return; }
System.out.println(form.getField(0) + " " + form.getField(1) + ". " +
logger.info(form.getField(0) + " " + form.getField(1) + ". " +
public static void main(String[] args) { JTextField[] fields = { new JTextField(), new JTextField(), new JTextField(), new JTextField() }; String[] labels = { "First Name", "Middle Initial", "Last Name", "Age" }; char[] mnemonics = { 'F', 'M', 'L', 'A' }; int[] widths = { 15, 1, 15, 3 }; String[] descs = { "First Name", "Middle Initial", "Last Name", "Age" }; final TextPanel form = new TextPanel(fields, labels, mnemonics, widths, descs); JButton submit = new JButton("Submit Form"); submit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println(form.getField(0) + " " + form.getField(1) + ". " + form.getField(2) + ", age " + form.getField(3)); } }); JFrame f = new JFrame("Text Form Example"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(form, BorderLayout.NORTH); JPanel p = new JPanel(); p.add(submit); f.getContentPane().add(p, BorderLayout.SOUTH); f.pack(); f.setVisible(true); }
System.out.println(form.getField(0) + " " + form.getField(1) + ". " +
logger.info(form.getField(0) + " " + form.getField(1) + ". " +
public void actionPerformed(ActionEvent e) { System.out.println(form.getField(0) + " " + form.getField(1) + ". " + form.getField(2) + ", age " + form.getField(3)); }
thumbReadyTime = System.currentTimeMillis();
private void paintThumbnail( Graphics2D g2, PhotoInfo photo, int startx, int starty, boolean isSelected ) { log.debug( "paintThumbnail entry " + photo.getUid() ); // Current position in which attributes can be drawn int ypos = starty + rowHeight/2; if ( photo != null ) { Thumbnail thumbnail = null; log.debug( "finding thumb" ); boolean hasThumbnail = photo.hasThumbnail(); log.debug( "asked if has thumb" ); if ( hasThumbnail ) { log.debug( "Photo " + photo.getUid() + " has thumbnail" ); thumbnail = photo.getThumbnail(); log.debug( "got thumbnail" ); } else { thumbnail = Thumbnail.getDefaultThumbnail(); if ( !thumbCreatorThread.isBusy() ) { log.debug( "Create thumbnail for " + photo.getUid() ); thumbCreatorThread.createThumbnail( photo ); log.debug( "Thumbnail request submitted" ); } } log.debug( "starting to draw" ); // Find the position for the thumbnail BufferedImage img = thumbnail.getImage(); int x = startx + (columnWidth - img.getWidth())/(int)2; int y = starty + (rowHeight - img.getHeight())/(int)2; log.debug( "drawing thumbnail" ); g2.drawImage( img, new AffineTransform( 1f, 0f, 0f, 1f, x, y ), null ); log.debug( "Drawn, drawing decorations" ); if ( isSelected ) { Stroke prevStroke = g2.getStroke(); Color prevColor = g2.getColor(); g2.setStroke( new BasicStroke( 3.0f) ); g2.setColor( Color.BLUE ); g2.drawRect( x, y, img.getWidth(), img.getHeight() ); g2.setColor( prevColor ); g2.setStroke( prevStroke ); } // Increase ypos so that attributes are drawn under the image ypos += ((int)img.getHeight())/2 + 4; // Draw the attributes Color prevBkg = g2.getBackground(); if ( isSelected ) { g2.setBackground( Color.BLUE ); } Font attrFont = new Font( "Arial", Font.PLAIN, 10 ); FontRenderContext frc = g2.getFontRenderContext(); if ( showDate && photo.getShootTime() != null ) { FuzzyDate fd = new FuzzyDate( photo.getShootTime(), photo.getTimeAccuracy() ); // long accuracy = ((long) photo.getTimeAccuracy() ) * 24 * 3600 * 1000;// log.warn( "Accuracy = " + accuracy );// String dateStr = "";// if ( accuracy > 0 ) {// double accuracyFormatLimits[] = {0, 3, 14, 180};// String accuracyFormatStrings[] = {// "dd.MM.yyyy",// "'wk' w yyyy",// "MMMM yyyy",// "yyyy"// };// // Find the correct format to use// double dblAccuracy = photo.getTimeAccuracy();// String formatStr =accuracyFormatStrings[0];// for ( int i = 1; i < accuracyFormatLimits.length; i++ ) {// if ( dblAccuracy < accuracyFormatLimits[i] ) {// break;// }// formatStr =accuracyFormatStrings[i];// } // // Show the limits of the accuracy range// DateFormat df = new SimpleDateFormat( formatStr );// Date lower = new Date( photo.getShootTime().getTime() - accuracy );// Date upper = new Date( photo.getShootTime().getTime() + accuracy );// String lowerStr = df.format( lower );// String upperStr = df.format( upper );// dateStr = lowerStr;// if ( !lowerStr.equals( upperStr ) ) {// dateStr += " - " + upperStr;// }// } else {// DateFormat df = new SimpleDateFormat( "dd.MM.yyyy k:mm" );// dateStr = df.format( photo.getShootTime() );// } String dateStr = fd.format(); TextLayout txt = new TextLayout( dateStr, attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth - bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } String shootPlace = photo.getShootingPlace(); if ( showPlace && shootPlace != null && shootPlace.length() > 0 ) { TextLayout txt = new TextLayout( photo.getShootingPlace(), attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth-bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } g2.setBackground( prevBkg ); } log.debug( "paintThumbnail: exit " + photo.getUid() ); }
log.debug( "Thumb fetch " + (thumbReadyTime - startTime ) + " ms" ); log.debug( "Thumb draw " + ( thumbDrawnTime - thumbReadyTime ) + " ms" ); log.debug( "Deacoration draw " + (endTime - thumbDrawnTime ) + " ms" ); log.debug( "Total " + (endTime - startTime ) + " ms" );
private void paintThumbnail( Graphics2D g2, PhotoInfo photo, int startx, int starty, boolean isSelected ) { log.debug( "paintThumbnail entry " + photo.getUid() ); // Current position in which attributes can be drawn int ypos = starty + rowHeight/2; if ( photo != null ) { Thumbnail thumbnail = null; log.debug( "finding thumb" ); boolean hasThumbnail = photo.hasThumbnail(); log.debug( "asked if has thumb" ); if ( hasThumbnail ) { log.debug( "Photo " + photo.getUid() + " has thumbnail" ); thumbnail = photo.getThumbnail(); log.debug( "got thumbnail" ); } else { thumbnail = Thumbnail.getDefaultThumbnail(); if ( !thumbCreatorThread.isBusy() ) { log.debug( "Create thumbnail for " + photo.getUid() ); thumbCreatorThread.createThumbnail( photo ); log.debug( "Thumbnail request submitted" ); } } log.debug( "starting to draw" ); // Find the position for the thumbnail BufferedImage img = thumbnail.getImage(); int x = startx + (columnWidth - img.getWidth())/(int)2; int y = starty + (rowHeight - img.getHeight())/(int)2; log.debug( "drawing thumbnail" ); g2.drawImage( img, new AffineTransform( 1f, 0f, 0f, 1f, x, y ), null ); log.debug( "Drawn, drawing decorations" ); if ( isSelected ) { Stroke prevStroke = g2.getStroke(); Color prevColor = g2.getColor(); g2.setStroke( new BasicStroke( 3.0f) ); g2.setColor( Color.BLUE ); g2.drawRect( x, y, img.getWidth(), img.getHeight() ); g2.setColor( prevColor ); g2.setStroke( prevStroke ); } // Increase ypos so that attributes are drawn under the image ypos += ((int)img.getHeight())/2 + 4; // Draw the attributes Color prevBkg = g2.getBackground(); if ( isSelected ) { g2.setBackground( Color.BLUE ); } Font attrFont = new Font( "Arial", Font.PLAIN, 10 ); FontRenderContext frc = g2.getFontRenderContext(); if ( showDate && photo.getShootTime() != null ) { FuzzyDate fd = new FuzzyDate( photo.getShootTime(), photo.getTimeAccuracy() ); // long accuracy = ((long) photo.getTimeAccuracy() ) * 24 * 3600 * 1000;// log.warn( "Accuracy = " + accuracy );// String dateStr = "";// if ( accuracy > 0 ) {// double accuracyFormatLimits[] = {0, 3, 14, 180};// String accuracyFormatStrings[] = {// "dd.MM.yyyy",// "'wk' w yyyy",// "MMMM yyyy",// "yyyy"// };// // Find the correct format to use// double dblAccuracy = photo.getTimeAccuracy();// String formatStr =accuracyFormatStrings[0];// for ( int i = 1; i < accuracyFormatLimits.length; i++ ) {// if ( dblAccuracy < accuracyFormatLimits[i] ) {// break;// }// formatStr =accuracyFormatStrings[i];// } // // Show the limits of the accuracy range// DateFormat df = new SimpleDateFormat( formatStr );// Date lower = new Date( photo.getShootTime().getTime() - accuracy );// Date upper = new Date( photo.getShootTime().getTime() + accuracy );// String lowerStr = df.format( lower );// String upperStr = df.format( upper );// dateStr = lowerStr;// if ( !lowerStr.equals( upperStr ) ) {// dateStr += " - " + upperStr;// }// } else {// DateFormat df = new SimpleDateFormat( "dd.MM.yyyy k:mm" );// dateStr = df.format( photo.getShootTime() );// } String dateStr = fd.format(); TextLayout txt = new TextLayout( dateStr, attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth - bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } String shootPlace = photo.getShootingPlace(); if ( showPlace && shootPlace != null && shootPlace.length() > 0 ) { TextLayout txt = new TextLayout( photo.getShootingPlace(), attrFont, frc ); // Calculate the position for the text Rectangle2D bounds = txt.getBounds(); int xpos = startx + ((int)(columnWidth-bounds.getWidth()))/2 - (int)bounds.getMinX(); g2.clearRect( xpos-2, ypos-2, (int)bounds.getWidth()+4, (int)bounds.getHeight()+4 ); txt.draw( g2, xpos, (int)(ypos + bounds.getHeight()) ); ypos += bounds.getHeight() + 4; } g2.setBackground( prevBkg ); } log.debug( "paintThumbnail: exit " + photo.getUid() ); }