rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
List list = block.getScriptList(); int size = list.size(); if ( size > 0 ) { Script script = (Script) list.get(0); if ( script instanceof TextScript ) { TextScript textScript = (TextScript) script; textScript.trimStartWhitespace(); } if ( size > 1 ) { script = (Script) list.get(size - 1); if ( script instanceof TextScript ) { TextScript textScript = (TextScript) script; textScript.trimEndWhitespace(); } } } | block.trimWhitespace(); | protected void trimBody() { synchronized(body) { // #### should refactor this code into // #### trimWhitespace() methods on the Script objects if ( body instanceof CompositeTextScriptBlock ) { CompositeTextScriptBlock block = (CompositeTextScriptBlock) body; List list = block.getScriptList(); int size = list.size(); if ( size > 0 ) { Script script = (Script) list.get(0); if ( script instanceof TextScript ) { TextScript textScript = (TextScript) script; textScript.trimStartWhitespace(); } if ( size > 1 ) { script = (Script) list.get(size - 1); if ( script instanceof TextScript ) { TextScript textScript = (TextScript) script; textScript.trimEndWhitespace(); } } } } else 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; textScript.trimWhitespace(); } } } |
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); } } } | block.trimWhitespace(); | protected void trimBody() { synchronized(body) { // #### should refactor this code into // #### trimWhitespace() methods on the Script objects if ( body instanceof CompositeTextScriptBlock ) { CompositeTextScriptBlock block = (CompositeTextScriptBlock) body; List list = block.getScriptList(); int size = list.size(); if ( size > 0 ) { Script script = (Script) list.get(0); if ( script instanceof TextScript ) { TextScript textScript = (TextScript) script; textScript.trimStartWhitespace(); } if ( size > 1 ) { script = (Script) list.get(size - 1); if ( script instanceof TextScript ) { TextScript textScript = (TextScript) script; textScript.trimEndWhitespace(); } } } } else 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; textScript.trimWhitespace(); } } } |
if (dc.equalsIgnoreCase(s)){ | if (!dc.equalsIgnoreCase(s)){ | public void parseHapMap(Vector rawLines) throws PedFileException { int colNum = -1; int numLines = rawLines.size(); Individual ind; this.order = new Vector(); //sort first Vector lines = new Vector(); Hashtable sortHelp = new Hashtable(numLines-1,1.0f); long[] pos = new long[numLines-1]; lines.add(rawLines.get(0)); for (int k = 1; k < numLines; k++){ StringTokenizer st = new StringTokenizer((String) rawLines.get(k)); //strip off 1st 3 cols st.nextToken();st.nextToken();st.nextToken(); pos[k-1] = new Long(st.nextToken()).longValue(); sortHelp.put(new Long(pos[k-1]),rawLines.get(k)); } Arrays.sort(pos); for (int i = 0; i < pos.length; i++){ lines.add(sortHelp.get(new Long(pos[i]))); } //enumerate indivs StringTokenizer st = new StringTokenizer((String)lines.get(0), "\n\t\" \""); int numMetaColumns = 0; boolean doneMeta = false; while(!doneMeta && st.hasMoreTokens()){ String thisfield = st.nextToken(); numMetaColumns++; //first indiv ID will be a string beginning with "NA" if (thisfield.startsWith("NA")){ doneMeta = true; } } numMetaColumns--; st = new StringTokenizer((String)lines.get(0), "\n\t\" \""); for (int i = 0; i < numMetaColumns; i++){ st.nextToken(); } Vector namesIncludingDups = new Vector(); StringTokenizer dt; while (st.hasMoreTokens()){ ind = new Individual(numLines); String name = st.nextToken(); namesIncludingDups.add(name); if (name.endsWith("dup")){ //skip dups (i.e. don't add 'em to ind array) continue; } String details = (String)hapMapTranslate.get(name); if (details == null){ throw new PedFileException("Hapmap data format error: " + name); } dt = new StringTokenizer(details, "\n\t\" \""); ind.setFamilyID(dt.nextToken().trim()); ind.setIndividualID(dt.nextToken().trim()); ind.setDadID(dt.nextToken().trim()); ind.setMomID(dt.nextToken().trim()); try { ind.setGender(Integer.parseInt(dt.nextToken().trim())); ind.setAffectedStatus(Integer.parseInt(dt.nextToken().trim())); }catch(NumberFormatException nfe) { throw new PedFileException("File error: invalid gender or affected status for indiv " + name); } //check if the family exists already in the Hashtable Family fam = (Family)this.families.get(ind.getFamilyID()); if(fam == null){ //it doesnt exist, so create a new Family object fam = new Family(ind.getFamilyID()); } fam.addMember(ind); this.families.put(ind.getFamilyID(),fam); String[] indFamID = new String[2]; indFamID[0] = ind.getFamilyID(); indFamID[1] = ind.getIndividualID(); this.order.add(ind); } //start at k=1 to skip header which we just processed above. hminfo = new String[numLines-1][]; for(int k=1;k<numLines;k++){ StringTokenizer tokenizer = new StringTokenizer((String)lines.get(k)); //reading the first line if(colNum < 0){ //only check column number count for the first line colNum = tokenizer.countTokens(); } if(colNum != tokenizer.countTokens()) { //this line has a different number of columns //should send some sort of error message //TODO: add something which stores number of markers for all lines and checks that they're consistent throw new PedFileException("Line number mismatch in input file. line " + (k+1)); } if(tokenizer.hasMoreTokens()){ hminfo[k-1] = new String[2]; for (int skip = 0; skip < numMetaColumns; skip++){ //meta-data crap String s = tokenizer.nextToken().trim(); //get marker name, chrom and pos if (skip == 0){ hminfo[k-1][0] = s; } if (skip == 2){ String dc = Chromosome.getDataChrom(); if (dc != null){ if (dc.equalsIgnoreCase(s)){ throw new PedFileException("Hapmap file format error on line " + (k+1) + ":\n The file appears to contain multiple chromosomes:" + "\n" + dc + ", " + s); } }else{ Chromosome.setDataChrom(s); } } if (skip == 3){ hminfo[k-1][1] = s; } } int index = 0; int indexIncludingDups = -1; while(tokenizer.hasMoreTokens()){ String alleles = tokenizer.nextToken(); indexIncludingDups++; //we've skipped the dups in the ind array, so we skip their genotypes if (((String)namesIncludingDups.elementAt(indexIncludingDups)).endsWith("dup")){ continue; } ind = (Individual)order.elementAt(index); int allele1=0, allele2=0; if (alleles.substring(0,1).equals("A")){ allele1 = 1; }else if (alleles.substring(0,1).equals("C")){ allele1 = 2; }else if (alleles.substring(0,1).equals("G")){ allele1 = 3; }else if (alleles.substring(0,1).equals("T")){ allele1 = 4; } if (alleles.substring(1,2).equals("A")){ allele2 = 1; }else if (alleles.substring(1,2).equals("C")){ allele2 = 2; }else if (alleles.substring(1,2).equals("G")){ allele2 = 3; }else if (alleles.substring(1,2).equals("T")){ allele2 = 4; } byte[] markers = new byte[2]; markers[0] = (byte)allele1; markers[1]= (byte)allele2; ind.addMarker(markers); index++; } } } } |
if (compoundDepth == 0) throw new IllegalStateException("Not in a compound edit"); compoundDepth--; if (compoundDepth == 0) { log.add(currentCompoundLog); currentCompoundLog = null; } | public void compoundEditEnd(UndoCompoundEvent e) { if (compoundDepth == 0) throw new IllegalStateException("Not in a compound edit"); compoundDepth--; if (compoundDepth == 0) { log.add(currentCompoundLog); currentCompoundLog = null; } } |
|
compoundDepth++; if (compoundDepth == 1) { currentCompoundLog = new ArrayList(); } | public void compoundEditStart(UndoCompoundEvent e) { compoundDepth++; if (compoundDepth == 1) { currentCompoundLog = new ArrayList(); } } |
|
log.add(e); | addToLog(LogItemType.INSERT, e); | public void dbChildrenInserted(SQLObjectEvent e) { log.add(e); } |
log.add(e); | addToLog(LogItemType.REMOVE, e); | public void dbChildrenRemoved(SQLObjectEvent e) { log.add(e); } |
log.add(e); | addToLog(LogItemType.CHANGE, e); | public void dbObjectChanged(SQLObjectEvent e) { log.add(e); } |
log.add(e); | throw new UnsupportedOperationException("Structure changes are not undoable"); | public void dbStructureChanged(SQLObjectEvent e) { log.add(e); } |
public List<Map<String,Object>> makeTableSnapshot(SQLTable t) { return null; | public TableSnapshot makeTableSnapshot(SQLTable t) throws Exception { return new TableSnapshot(t); | public List<Map<String,Object>> makeTableSnapshot(SQLTable t) { return null; //TODO: finish method } |
public void testChangeFifthColumnKey() throws ArchitectException{ | public void testChangeFifthColumnKey() throws Exception { EventLogger l = new EventLogger(); | public void testChangeFifthColumnKey() throws ArchitectException{ SQLColumn col5 = table.getColumnByName("five"); assertNotNull(col5); col5.setPrimaryKeySeq(0); assertEquals(4, table.getPkSize()); assertEquals(0, table.getColumnIndex(table.getColumnByName("one"))); assertEquals(1, table.getColumnIndex(table.getColumnByName("five"))); assertEquals(2, table.getColumnIndex(table.getColumnByName("two"))); assertEquals(3, table.getColumnIndex(table.getColumnByName("three"))); assertEquals(4, table.getColumnIndex(table.getColumnByName("four"))); assertEquals(5, table.getColumnIndex(table.getColumnByName("six"))); } |
col5.setPrimaryKeySeq(0); | TableSnapshot original = l.makeTableSnapshot(table); ArchitectUtils.listenToHierarchy(l, table); col5.setPrimaryKeySeq(0); ArchitectUtils.unlistenToHierarchy(l, table); System.out.println("Event log:\n"+l); TableSnapshot afterChange = l.makeTableSnapshot(table); | public void testChangeFifthColumnKey() throws ArchitectException{ SQLColumn col5 = table.getColumnByName("five"); assertNotNull(col5); col5.setPrimaryKeySeq(0); assertEquals(4, table.getPkSize()); assertEquals(0, table.getColumnIndex(table.getColumnByName("one"))); assertEquals(1, table.getColumnIndex(table.getColumnByName("five"))); assertEquals(2, table.getColumnIndex(table.getColumnByName("two"))); assertEquals(3, table.getColumnIndex(table.getColumnByName("three"))); assertEquals(4, table.getColumnIndex(table.getColumnByName("four"))); assertEquals(5, table.getColumnIndex(table.getColumnByName("six"))); } |
assertEquals(5, table.getColumnIndex(table.getColumnByName("six"))); | assertEquals(5, table.getColumnIndex(table.getColumnByName("six"))); System.out.println("Original: "+original); System.out.println("After: "+afterChange); l.rollBack(afterChange); assertEquals(original.toString(), afterChange.toString()); | public void testChangeFifthColumnKey() throws ArchitectException{ SQLColumn col5 = table.getColumnByName("five"); assertNotNull(col5); col5.setPrimaryKeySeq(0); assertEquals(4, table.getPkSize()); assertEquals(0, table.getColumnIndex(table.getColumnByName("one"))); assertEquals(1, table.getColumnIndex(table.getColumnByName("five"))); assertEquals(2, table.getColumnIndex(table.getColumnByName("two"))); assertEquals(3, table.getColumnIndex(table.getColumnByName("three"))); assertEquals(4, table.getColumnIndex(table.getColumnByName("four"))); assertEquals(5, table.getColumnIndex(table.getColumnByName("six"))); } |
int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeName = list.getLocalName(i); String attributeValue = list.getValue(i); Expression expression = taglib.createExpression( getExpressionFactory(), localName, attributeName, attributeValue); if (expression == null) { expression = createConstantExpression(localName, attributeName, attributeValue); | if ( script != null ) { int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeName = list.getLocalName(i); String attributeValue = list.getValue(i); Expression expression = taglib.createExpression( getExpressionFactory(), localName, attributeName, attributeValue); if (expression == null) { expression = createConstantExpression(localName, attributeName, attributeValue); } script.addAttribute(attributeName, expression); | protected TagScript createTag( String namespaceURI, String localName, Attributes list) throws SAXException { try { // use the URI to load a taglib TagLibrary taglib = context.getTagLibrary(namespaceURI); if (taglib == null) { if (namespaceURI != null && namespaceURI.startsWith("jelly:")) { String uri = namespaceURI.substring(6); // try to find the class on the claspath try { Class taglibClass = getClassLoader().loadClass(uri); taglib = (TagLibrary) taglibClass.newInstance(); context.registerTagLibrary(namespaceURI, taglib); } catch (ClassNotFoundException e) { log.warn("Could not load class: " + uri + " so disabling the taglib"); } } } if (taglib != null) { TagScript script = taglib.createTagScript(localName, list); // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeName = list.getLocalName(i); String attributeValue = list.getValue(i); Expression expression = taglib.createExpression( getExpressionFactory(), localName, attributeName, attributeValue); if (expression == null) { expression = createConstantExpression(localName, attributeName, attributeValue); } script.addAttribute(attributeName, expression); } return script; } return null; } catch (Exception e) { log.warn( "Could not create taglib or URI: " + namespaceURI + " tag name: " + localName, e); throw createSAXException(e); } catch (Throwable e) { log.warn( "Could not create taglib or URI: " + namespaceURI + " tag name: " + localName, e); return null; } } |
script.addAttribute(attributeName, expression); | protected TagScript createTag( String namespaceURI, String localName, Attributes list) throws SAXException { try { // use the URI to load a taglib TagLibrary taglib = context.getTagLibrary(namespaceURI); if (taglib == null) { if (namespaceURI != null && namespaceURI.startsWith("jelly:")) { String uri = namespaceURI.substring(6); // try to find the class on the claspath try { Class taglibClass = getClassLoader().loadClass(uri); taglib = (TagLibrary) taglibClass.newInstance(); context.registerTagLibrary(namespaceURI, taglib); } catch (ClassNotFoundException e) { log.warn("Could not load class: " + uri + " so disabling the taglib"); } } } if (taglib != null) { TagScript script = taglib.createTagScript(localName, list); // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeName = list.getLocalName(i); String attributeValue = list.getValue(i); Expression expression = taglib.createExpression( getExpressionFactory(), localName, attributeName, attributeValue); if (expression == null) { expression = createConstantExpression(localName, attributeName, attributeValue); } script.addAttribute(attributeName, expression); } return script; } return null; } catch (Exception e) { log.warn( "Could not create taglib or URI: " + namespaceURI + " tag name: " + localName, e); throw createSAXException(e); } catch (Throwable e) { log.warn( "Could not create taglib or URI: " + namespaceURI + " tag name: " + localName, e); return null; } } |
|
boolean[] killMe = new boolean[indList.size()]; Arrays.fill(killMe, false); | 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 Vector indList = getOrder(); Individual currentInd; Family currentFamily; //the killMe array has a boolean for each person which specifies which people should be removed. //the parents or children of such a person are also removed. boolean[] killMe = new boolean[indList.size()]; Arrays.fill(killMe, false); for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.elementAt(x); currentFamily = getFamily(currentInd.getFamilyID()); if(currentInd.getIsTyped()){ //this person is a singleton if(currentFamily.getNumMembers() == 1){ double numMissing = 0; int numMarkers = currentInd.getNumMarkers(); for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == 0 || thisMarker[1] == 0){ numMissing++; } } if (numMissing/numMarkers > Options.getMissingThreshold()){ killMe[x] = true; } }else if (currentInd.hasBothParents()){ //this person has parents Individual mom = currentFamily.getMember(currentInd.getMomID()); double momMissing = 0; double dadMissing = 0; Individual dad = currentFamily.getMember(currentInd.getDadID()); if (!(mom.hasBothParents() || dad.hasBothParents())){ //if my parents have parents, skip me because i don't add any information //i.e. i'm a 3rd+ generation member of this family int numMarkers = currentInd.getNumMarkers(); for (int i = 0; i < numMarkers; i++){ byte[] dadMarker = dad.getMarker(i); byte[] momMarker = mom.getMarker(i); if (momMarker[0] == 0 || momMarker[1] == 0){ momMissing++; } if (dadMarker[0] == 0 || dadMarker[1] == 0){ dadMissing++; } } if (momMissing/numMarkers > Options.getMissingThreshold() || dadMissing/numMarkers > Options.getMissingThreshold()){ killMe[x] = true; } } } } } for (int x = 0; x < killMe.length; x++){ //now loop through the list of people to be killed //making sure to get their parents and kids if they exist if (killMe[x]){ currentInd = (Individual)indList.elementAt(x); currentFamily = getFamily(currentInd.getFamilyID()); order.removeElement(currentInd); axedPeople.add(currentInd.getIndividualID()); currentFamily.removeMember(currentInd.getIndividualID()); Enumeration peopleinFam = currentFamily.getMemberList(); while (peopleinFam.hasMoreElements()){ //this looks at the whole family and if any of the members are //parents or kids of the current ind, we kill them too String p = (String)peopleinFam.nextElement(); Individual thisPerson = currentFamily.getMember(p); if (thisPerson.getMomID().equals(currentInd.getIndividualID()) || thisPerson.getDadID().equals(currentInd.getIndividualID()) || currentInd.getMomID().equals(thisPerson.getIndividualID()) || currentInd.getDadID().equals(thisPerson.getIndividualID())){ order.removeElement(thisPerson); axedPeople.add(currentInd.getIndividualID()); currentFamily.removeMember(thisPerson.getIndividualID()); } } if (currentFamily.getNumMembers() == 0){ //if everyone in a family is gone, we remove it from the list families.remove(currentInd.getFamilyID()); axedFamilies.add(currentInd.getFamilyID()); } } } CheckData cd = new CheckData(this); Vector results = cd.check(); /*int size = results.size(); for (int i = 0; i < size; i++) { MarkerResult markerResult = (MarkerResult) results.elementAt(i); System.out.println(markerResult.toString()); }*/ this.results = results; return results; } |
|
if(currentInd.getIsTyped()){ if(currentFamily.getNumMembers() == 1){ double numMissing = 0; int numMarkers = currentInd.getNumMarkers(); for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == 0 || thisMarker[1] == 0){ numMissing++; } } if (numMissing/numMarkers > Options.getMissingThreshold()){ killMe[x] = true; } }else if (currentInd.hasBothParents()){ Individual mom = currentFamily.getMember(currentInd.getMomID()); double momMissing = 0; double dadMissing = 0; Individual dad = currentFamily.getMember(currentInd.getDadID()); if (!(mom.hasBothParents() || dad.hasBothParents())){ int numMarkers = currentInd.getNumMarkers(); for (int i = 0; i < numMarkers; i++){ byte[] dadMarker = dad.getMarker(i); byte[] momMarker = mom.getMarker(i); if (momMarker[0] == 0 || momMarker[1] == 0){ momMissing++; } if (dadMarker[0] == 0 || dadMarker[1] == 0){ dadMissing++; | double numMissing = 0; int numMarkers = currentInd.getNumMarkers(); for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == 0 || thisMarker[1] == 0){ numMissing++; } } if (numMissing/numMarkers > Options.getMissingThreshold()){ order.removeElement(currentInd); axedPeople.add(currentInd.getIndividualID()); if (currentFamily.getNumMembers() > 1){ if (currentInd.hasEitherParent()){ Enumeration peopleinFam = currentFamily.getMemberList(); while (peopleinFam.hasMoreElements()){ Individual nextMember = currentFamily.getMember((String)peopleinFam.nextElement()); if (nextMember.getDadID().equals(currentInd.getIndividualID()) || nextMember.getMomID().equals(currentInd.getIndividualID())){ order.removeElement(nextMember); currentFamily.removeMember(nextMember.getIndividualID()); | 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 Vector indList = getOrder(); Individual currentInd; Family currentFamily; //the killMe array has a boolean for each person which specifies which people should be removed. //the parents or children of such a person are also removed. boolean[] killMe = new boolean[indList.size()]; Arrays.fill(killMe, false); for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.elementAt(x); currentFamily = getFamily(currentInd.getFamilyID()); if(currentInd.getIsTyped()){ //this person is a singleton if(currentFamily.getNumMembers() == 1){ double numMissing = 0; int numMarkers = currentInd.getNumMarkers(); for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == 0 || thisMarker[1] == 0){ numMissing++; } } if (numMissing/numMarkers > Options.getMissingThreshold()){ killMe[x] = true; } }else if (currentInd.hasBothParents()){ //this person has parents Individual mom = currentFamily.getMember(currentInd.getMomID()); double momMissing = 0; double dadMissing = 0; Individual dad = currentFamily.getMember(currentInd.getDadID()); if (!(mom.hasBothParents() || dad.hasBothParents())){ //if my parents have parents, skip me because i don't add any information //i.e. i'm a 3rd+ generation member of this family int numMarkers = currentInd.getNumMarkers(); for (int i = 0; i < numMarkers; i++){ byte[] dadMarker = dad.getMarker(i); byte[] momMarker = mom.getMarker(i); if (momMarker[0] == 0 || momMarker[1] == 0){ momMissing++; } if (dadMarker[0] == 0 || dadMarker[1] == 0){ dadMissing++; } } if (momMissing/numMarkers > Options.getMissingThreshold() || dadMissing/numMarkers > Options.getMissingThreshold()){ killMe[x] = true; } } } } } for (int x = 0; x < killMe.length; x++){ //now loop through the list of people to be killed //making sure to get their parents and kids if they exist if (killMe[x]){ currentInd = (Individual)indList.elementAt(x); currentFamily = getFamily(currentInd.getFamilyID()); order.removeElement(currentInd); axedPeople.add(currentInd.getIndividualID()); currentFamily.removeMember(currentInd.getIndividualID()); Enumeration peopleinFam = currentFamily.getMemberList(); while (peopleinFam.hasMoreElements()){ //this looks at the whole family and if any of the members are //parents or kids of the current ind, we kill them too String p = (String)peopleinFam.nextElement(); Individual thisPerson = currentFamily.getMember(p); if (thisPerson.getMomID().equals(currentInd.getIndividualID()) || thisPerson.getDadID().equals(currentInd.getIndividualID()) || currentInd.getMomID().equals(thisPerson.getIndividualID()) || currentInd.getDadID().equals(thisPerson.getIndividualID())){ order.removeElement(thisPerson); axedPeople.add(currentInd.getIndividualID()); currentFamily.removeMember(thisPerson.getIndividualID()); } } if (currentFamily.getNumMembers() == 0){ //if everyone in a family is gone, we remove it from the list families.remove(currentInd.getFamilyID()); axedFamilies.add(currentInd.getFamilyID()); } } } CheckData cd = new CheckData(this); Vector results = cd.check(); /*int size = results.size(); for (int i = 0; i < size; i++) { MarkerResult markerResult = (MarkerResult) results.elementAt(i); System.out.println(markerResult.toString()); }*/ this.results = results; return results; } |
if (momMissing/numMarkers > Options.getMissingThreshold() || dadMissing/numMarkers > Options.getMissingThreshold()){ killMe[x] = true; | }else{ String spouseID = ""; Enumeration peopleinFam = currentFamily.getMemberList(); while (peopleinFam.hasMoreElements()){ Individual nextMember = currentFamily.getMember((String)peopleinFam.nextElement()); if (nextMember.getDadID().equals(currentInd.getIndividualID())) spouseID = nextMember.getMomID(); if (nextMember.getMomID().equals(currentInd.getIndividualID())) spouseID = nextMember.getDadID(); } if (!spouseID.equals("")){ if (currentFamily.getMember(spouseID).hasEitherParent()){ peopleinFam = currentFamily.getMemberList(); while (peopleinFam.hasMoreElements()){ Individual nextMember = currentFamily.getMember((String)peopleinFam.nextElement()); if (nextMember.getDadID().equals(currentInd.getIndividualID()) || nextMember.getMomID().equals(currentInd.getIndividualID())){ order.removeElement(nextMember); currentFamily.removeMember(nextMember.getIndividualID()); } } }else{ order.removeElement(currentFamily.getMember(spouseID)); currentFamily.removeMember(spouseID); peopleinFam = currentFamily.getMemberList(); boolean oneFound = false; while (peopleinFam.hasMoreElements()){ Individual nextMember = currentFamily.getMember((String)peopleinFam.nextElement()); if (nextMember.getDadID().equals(currentInd.getIndividualID()) || nextMember.getMomID().equals(currentInd.getIndividualID())){ if (oneFound){ order.removeElement(nextMember); currentFamily.removeMember(nextMember.getIndividualID()); }else{ nextMember.setDadID("0"); nextMember.setMomID("0"); oneFound = true; } } } } | 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 Vector indList = getOrder(); Individual currentInd; Family currentFamily; //the killMe array has a boolean for each person which specifies which people should be removed. //the parents or children of such a person are also removed. boolean[] killMe = new boolean[indList.size()]; Arrays.fill(killMe, false); for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.elementAt(x); currentFamily = getFamily(currentInd.getFamilyID()); if(currentInd.getIsTyped()){ //this person is a singleton if(currentFamily.getNumMembers() == 1){ double numMissing = 0; int numMarkers = currentInd.getNumMarkers(); for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == 0 || thisMarker[1] == 0){ numMissing++; } } if (numMissing/numMarkers > Options.getMissingThreshold()){ killMe[x] = true; } }else if (currentInd.hasBothParents()){ //this person has parents Individual mom = currentFamily.getMember(currentInd.getMomID()); double momMissing = 0; double dadMissing = 0; Individual dad = currentFamily.getMember(currentInd.getDadID()); if (!(mom.hasBothParents() || dad.hasBothParents())){ //if my parents have parents, skip me because i don't add any information //i.e. i'm a 3rd+ generation member of this family int numMarkers = currentInd.getNumMarkers(); for (int i = 0; i < numMarkers; i++){ byte[] dadMarker = dad.getMarker(i); byte[] momMarker = mom.getMarker(i); if (momMarker[0] == 0 || momMarker[1] == 0){ momMissing++; } if (dadMarker[0] == 0 || dadMarker[1] == 0){ dadMissing++; } } if (momMissing/numMarkers > Options.getMissingThreshold() || dadMissing/numMarkers > Options.getMissingThreshold()){ killMe[x] = true; } } } } } for (int x = 0; x < killMe.length; x++){ //now loop through the list of people to be killed //making sure to get their parents and kids if they exist if (killMe[x]){ currentInd = (Individual)indList.elementAt(x); currentFamily = getFamily(currentInd.getFamilyID()); order.removeElement(currentInd); axedPeople.add(currentInd.getIndividualID()); currentFamily.removeMember(currentInd.getIndividualID()); Enumeration peopleinFam = currentFamily.getMemberList(); while (peopleinFam.hasMoreElements()){ //this looks at the whole family and if any of the members are //parents or kids of the current ind, we kill them too String p = (String)peopleinFam.nextElement(); Individual thisPerson = currentFamily.getMember(p); if (thisPerson.getMomID().equals(currentInd.getIndividualID()) || thisPerson.getDadID().equals(currentInd.getIndividualID()) || currentInd.getMomID().equals(thisPerson.getIndividualID()) || currentInd.getDadID().equals(thisPerson.getIndividualID())){ order.removeElement(thisPerson); axedPeople.add(currentInd.getIndividualID()); currentFamily.removeMember(thisPerson.getIndividualID()); } } if (currentFamily.getNumMembers() == 0){ //if everyone in a family is gone, we remove it from the list families.remove(currentInd.getFamilyID()); axedFamilies.add(currentInd.getFamilyID()); } } } CheckData cd = new CheckData(this); Vector results = cd.check(); /*int size = results.size(); for (int i = 0; i < size; i++) { MarkerResult markerResult = (MarkerResult) results.elementAt(i); System.out.println(markerResult.toString()); }*/ this.results = results; return results; } |
} } for (int x = 0; x < killMe.length; x++){ if (killMe[x]){ currentInd = (Individual)indList.elementAt(x); currentFamily = getFamily(currentInd.getFamilyID()); order.removeElement(currentInd); axedPeople.add(currentInd.getIndividualID()); | 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 Vector indList = getOrder(); Individual currentInd; Family currentFamily; //the killMe array has a boolean for each person which specifies which people should be removed. //the parents or children of such a person are also removed. boolean[] killMe = new boolean[indList.size()]; Arrays.fill(killMe, false); for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.elementAt(x); currentFamily = getFamily(currentInd.getFamilyID()); if(currentInd.getIsTyped()){ //this person is a singleton if(currentFamily.getNumMembers() == 1){ double numMissing = 0; int numMarkers = currentInd.getNumMarkers(); for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == 0 || thisMarker[1] == 0){ numMissing++; } } if (numMissing/numMarkers > Options.getMissingThreshold()){ killMe[x] = true; } }else if (currentInd.hasBothParents()){ //this person has parents Individual mom = currentFamily.getMember(currentInd.getMomID()); double momMissing = 0; double dadMissing = 0; Individual dad = currentFamily.getMember(currentInd.getDadID()); if (!(mom.hasBothParents() || dad.hasBothParents())){ //if my parents have parents, skip me because i don't add any information //i.e. i'm a 3rd+ generation member of this family int numMarkers = currentInd.getNumMarkers(); for (int i = 0; i < numMarkers; i++){ byte[] dadMarker = dad.getMarker(i); byte[] momMarker = mom.getMarker(i); if (momMarker[0] == 0 || momMarker[1] == 0){ momMissing++; } if (dadMarker[0] == 0 || dadMarker[1] == 0){ dadMissing++; } } if (momMissing/numMarkers > Options.getMissingThreshold() || dadMissing/numMarkers > Options.getMissingThreshold()){ killMe[x] = true; } } } } } for (int x = 0; x < killMe.length; x++){ //now loop through the list of people to be killed //making sure to get their parents and kids if they exist if (killMe[x]){ currentInd = (Individual)indList.elementAt(x); currentFamily = getFamily(currentInd.getFamilyID()); order.removeElement(currentInd); axedPeople.add(currentInd.getIndividualID()); currentFamily.removeMember(currentInd.getIndividualID()); Enumeration peopleinFam = currentFamily.getMemberList(); while (peopleinFam.hasMoreElements()){ //this looks at the whole family and if any of the members are //parents or kids of the current ind, we kill them too String p = (String)peopleinFam.nextElement(); Individual thisPerson = currentFamily.getMember(p); if (thisPerson.getMomID().equals(currentInd.getIndividualID()) || thisPerson.getDadID().equals(currentInd.getIndividualID()) || currentInd.getMomID().equals(thisPerson.getIndividualID()) || currentInd.getDadID().equals(thisPerson.getIndividualID())){ order.removeElement(thisPerson); axedPeople.add(currentInd.getIndividualID()); currentFamily.removeMember(thisPerson.getIndividualID()); } } if (currentFamily.getNumMembers() == 0){ //if everyone in a family is gone, we remove it from the list families.remove(currentInd.getFamilyID()); axedFamilies.add(currentInd.getFamilyID()); } } } CheckData cd = new CheckData(this); Vector results = cd.check(); /*int size = results.size(); for (int i = 0; i < size; i++) { MarkerResult markerResult = (MarkerResult) results.elementAt(i); System.out.println(markerResult.toString()); }*/ this.results = results; return results; } |
|
Enumeration peopleinFam = currentFamily.getMemberList(); while (peopleinFam.hasMoreElements()){ String p = (String)peopleinFam.nextElement(); Individual thisPerson = currentFamily.getMember(p); if (thisPerson.getMomID().equals(currentInd.getIndividualID()) || thisPerson.getDadID().equals(currentInd.getIndividualID()) || currentInd.getMomID().equals(thisPerson.getIndividualID()) || currentInd.getDadID().equals(thisPerson.getIndividualID())){ order.removeElement(thisPerson); axedPeople.add(currentInd.getIndividualID()); currentFamily.removeMember(thisPerson.getIndividualID()); } } | 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 Vector indList = getOrder(); Individual currentInd; Family currentFamily; //the killMe array has a boolean for each person which specifies which people should be removed. //the parents or children of such a person are also removed. boolean[] killMe = new boolean[indList.size()]; Arrays.fill(killMe, false); for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.elementAt(x); currentFamily = getFamily(currentInd.getFamilyID()); if(currentInd.getIsTyped()){ //this person is a singleton if(currentFamily.getNumMembers() == 1){ double numMissing = 0; int numMarkers = currentInd.getNumMarkers(); for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == 0 || thisMarker[1] == 0){ numMissing++; } } if (numMissing/numMarkers > Options.getMissingThreshold()){ killMe[x] = true; } }else if (currentInd.hasBothParents()){ //this person has parents Individual mom = currentFamily.getMember(currentInd.getMomID()); double momMissing = 0; double dadMissing = 0; Individual dad = currentFamily.getMember(currentInd.getDadID()); if (!(mom.hasBothParents() || dad.hasBothParents())){ //if my parents have parents, skip me because i don't add any information //i.e. i'm a 3rd+ generation member of this family int numMarkers = currentInd.getNumMarkers(); for (int i = 0; i < numMarkers; i++){ byte[] dadMarker = dad.getMarker(i); byte[] momMarker = mom.getMarker(i); if (momMarker[0] == 0 || momMarker[1] == 0){ momMissing++; } if (dadMarker[0] == 0 || dadMarker[1] == 0){ dadMissing++; } } if (momMissing/numMarkers > Options.getMissingThreshold() || dadMissing/numMarkers > Options.getMissingThreshold()){ killMe[x] = true; } } } } } for (int x = 0; x < killMe.length; x++){ //now loop through the list of people to be killed //making sure to get their parents and kids if they exist if (killMe[x]){ currentInd = (Individual)indList.elementAt(x); currentFamily = getFamily(currentInd.getFamilyID()); order.removeElement(currentInd); axedPeople.add(currentInd.getIndividualID()); currentFamily.removeMember(currentInd.getIndividualID()); Enumeration peopleinFam = currentFamily.getMemberList(); while (peopleinFam.hasMoreElements()){ //this looks at the whole family and if any of the members are //parents or kids of the current ind, we kill them too String p = (String)peopleinFam.nextElement(); Individual thisPerson = currentFamily.getMember(p); if (thisPerson.getMomID().equals(currentInd.getIndividualID()) || thisPerson.getDadID().equals(currentInd.getIndividualID()) || currentInd.getMomID().equals(thisPerson.getIndividualID()) || currentInd.getDadID().equals(thisPerson.getIndividualID())){ order.removeElement(thisPerson); axedPeople.add(currentInd.getIndividualID()); currentFamily.removeMember(thisPerson.getIndividualID()); } } if (currentFamily.getNumMembers() == 0){ //if everyone in a family is gone, we remove it from the list families.remove(currentInd.getFamilyID()); axedFamilies.add(currentInd.getFamilyID()); } } } CheckData cd = new CheckData(this); Vector results = cd.check(); /*int size = results.size(); for (int i = 0; i < size; i++) { MarkerResult markerResult = (MarkerResult) results.elementAt(i); System.out.println(markerResult.toString()); }*/ this.results = results; return results; } |
|
} } } indList = getOrder(); for (int x = 0; x < indList.size(); x++){ currentInd = (Individual)indList.elementAt(x); currentFamily = getFamily(currentInd.getFamilyID()); Enumeration peopleinFam = currentFamily.getMemberList(); while (peopleinFam.hasMoreElements()){ Individual nextMember = currentFamily.getMember((String)peopleinFam.nextElement()); if (nextMember.getMomID().equals(currentInd.getIndividualID()) || nextMember.getDadID().equals(currentInd.getIndividualID())){ currentInd.setHasKids(true); break; | 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 Vector indList = getOrder(); Individual currentInd; Family currentFamily; //the killMe array has a boolean for each person which specifies which people should be removed. //the parents or children of such a person are also removed. boolean[] killMe = new boolean[indList.size()]; Arrays.fill(killMe, false); for(int x=0; x < indList.size(); x++){ currentInd = (Individual)indList.elementAt(x); currentFamily = getFamily(currentInd.getFamilyID()); if(currentInd.getIsTyped()){ //this person is a singleton if(currentFamily.getNumMembers() == 1){ double numMissing = 0; int numMarkers = currentInd.getNumMarkers(); for (int i = 0; i < numMarkers; i++){ byte[] thisMarker = currentInd.getMarker(i); if (thisMarker[0] == 0 || thisMarker[1] == 0){ numMissing++; } } if (numMissing/numMarkers > Options.getMissingThreshold()){ killMe[x] = true; } }else if (currentInd.hasBothParents()){ //this person has parents Individual mom = currentFamily.getMember(currentInd.getMomID()); double momMissing = 0; double dadMissing = 0; Individual dad = currentFamily.getMember(currentInd.getDadID()); if (!(mom.hasBothParents() || dad.hasBothParents())){ //if my parents have parents, skip me because i don't add any information //i.e. i'm a 3rd+ generation member of this family int numMarkers = currentInd.getNumMarkers(); for (int i = 0; i < numMarkers; i++){ byte[] dadMarker = dad.getMarker(i); byte[] momMarker = mom.getMarker(i); if (momMarker[0] == 0 || momMarker[1] == 0){ momMissing++; } if (dadMarker[0] == 0 || dadMarker[1] == 0){ dadMissing++; } } if (momMissing/numMarkers > Options.getMissingThreshold() || dadMissing/numMarkers > Options.getMissingThreshold()){ killMe[x] = true; } } } } } for (int x = 0; x < killMe.length; x++){ //now loop through the list of people to be killed //making sure to get their parents and kids if they exist if (killMe[x]){ currentInd = (Individual)indList.elementAt(x); currentFamily = getFamily(currentInd.getFamilyID()); order.removeElement(currentInd); axedPeople.add(currentInd.getIndividualID()); currentFamily.removeMember(currentInd.getIndividualID()); Enumeration peopleinFam = currentFamily.getMemberList(); while (peopleinFam.hasMoreElements()){ //this looks at the whole family and if any of the members are //parents or kids of the current ind, we kill them too String p = (String)peopleinFam.nextElement(); Individual thisPerson = currentFamily.getMember(p); if (thisPerson.getMomID().equals(currentInd.getIndividualID()) || thisPerson.getDadID().equals(currentInd.getIndividualID()) || currentInd.getMomID().equals(thisPerson.getIndividualID()) || currentInd.getDadID().equals(thisPerson.getIndividualID())){ order.removeElement(thisPerson); axedPeople.add(currentInd.getIndividualID()); currentFamily.removeMember(thisPerson.getIndividualID()); } } if (currentFamily.getNumMembers() == 0){ //if everyone in a family is gone, we remove it from the list families.remove(currentInd.getFamilyID()); axedFamilies.add(currentInd.getFamilyID()); } } } CheckData cd = new CheckData(this); Vector results = cd.check(); /*int size = results.size(); for (int i = 0; i < size; i++) { MarkerResult markerResult = (MarkerResult) results.elementAt(i); System.out.println(markerResult.toString()); }*/ this.results = results; return results; } |
|
ind.setIsTyped(true); | public void parseHapMap(Vector rawLines) throws PedFileException { int colNum = -1; int numLines = rawLines.size(); Individual ind; this.order = new Vector(); //sort first Vector lines = new Vector(); Hashtable sortHelp = new Hashtable(numLines-1,1.0f); long[] pos = new long[numLines-1]; lines.add(rawLines.get(0)); for (int k = 1; k < numLines; k++){ StringTokenizer st = new StringTokenizer((String) rawLines.get(k)); //strip off 1st 3 cols st.nextToken();st.nextToken();st.nextToken(); pos[k-1] = new Long(st.nextToken()).longValue(); sortHelp.put(new Long(pos[k-1]),rawLines.get(k)); } Arrays.sort(pos); for (int i = 0; i < pos.length; i++){ lines.add(sortHelp.get(new Long(pos[i]))); } //enumerate indivs StringTokenizer st = new StringTokenizer((String)lines.get(0), "\n\t\" \""); int numMetaColumns = 0; boolean doneMeta = false; while(!doneMeta && st.hasMoreTokens()){ String thisfield = st.nextToken(); numMetaColumns++; //so currently the first person ID always starts with NA (Coriell ID) but //todo: will this be true with AA samples etc? if (thisfield.startsWith("NA")){ doneMeta = true; } } numMetaColumns--; st = new StringTokenizer((String)lines.get(0), "\n\t\" \""); for (int i = 0; i < numMetaColumns; i++){ st.nextToken(); } StringTokenizer dt; while (st.hasMoreTokens()){ ind = new Individual(numLines); String name = st.nextToken(); String details = (String)hapMapTranslate.get(name); if (details == null){ throw new PedFileException("Hapmap data format error: " + name); } dt = new StringTokenizer(details, "\n\t\" \""); ind.setFamilyID(dt.nextToken().trim()); ind.setIndividualID(dt.nextToken().trim()); ind.setDadID(dt.nextToken().trim()); ind.setMomID(dt.nextToken().trim()); try { ind.setGender(Integer.parseInt(dt.nextToken().trim())); ind.setAffectedStatus(Integer.parseInt(dt.nextToken().trim())); }catch(NumberFormatException nfe) { throw new PedFileException("File error: invalid gender or affected status for indiv " + name); } ind.setIsTyped(true); //check if the family exists already in the Hashtable Family fam = (Family)this.families.get(ind.getFamilyID()); if(fam == null){ //it doesnt exist, so create a new Family object fam = new Family(ind.getFamilyID()); } fam.addMember(ind); this.families.put(ind.getFamilyID(),fam); String[] indFamID = new String[2]; indFamID[0] = ind.getFamilyID(); indFamID[1] = ind.getIndividualID(); this.order.add(ind); } //start at k=1 to skip header which we just processed above. hminfo = new String[numLines-1][]; for(int k=1;k<numLines;k++){ StringTokenizer tokenizer = new StringTokenizer((String)lines.get(k)); //reading the first line if(colNum < 0){ //only check column number count for the first line colNum = tokenizer.countTokens(); } if(colNum != tokenizer.countTokens()) { //this line has a different number of columns //should send some sort of error message //TODO: add something which stores number of markers for all lines and checks that they're consistent throw new PedFileException("Line number mismatch in input file. line " + (k+1)); } if(tokenizer.hasMoreTokens()){ hminfo[k-1] = new String[2]; for (int skip = 0; skip < numMetaColumns; skip++){ //meta-data crap String s = tokenizer.nextToken().trim(); //get marker name, chrom and pos if (skip == 0){ hminfo[k-1][0] = s; } if (skip == 2){ if (Chromosome.dataChrom != null){ if (!Chromosome.dataChrom.equals(s)){ throw new PedFileException("Hapmap file format error on line " + (k+1)+ ":\n There appear to be multiple chromosomes in the file."); } }else{ Chromosome.dataChrom = s; } } if (skip == 3){ hminfo[k-1][1] = s; } } int index = 0; while(tokenizer.hasMoreTokens()){ ind = (Individual)order.elementAt(index); String alleles = tokenizer.nextToken(); int allele1=0, allele2=0; if (alleles.substring(0,1).equals("A")){ allele1 = 1; }else if (alleles.substring(0,1).equals("C")){ allele1 = 2; }else if (alleles.substring(0,1).equals("G")){ allele1 = 3; }else if (alleles.substring(0,1).equals("T")){ allele1 = 4; } if (alleles.substring(1,2).equals("A")){ allele2 = 1; }else if (alleles.substring(1,2).equals("C")){ allele2 = 2; }else if (alleles.substring(1,2).equals("G")){ allele2 = 3; }else if (alleles.substring(1,2).equals("T")){ allele2 = 4; } byte[] markers = new byte[2]; markers[0] = (byte)allele1; markers[1]= (byte)allele2; ind.addMarker(markers); index++; } } } } |
|
boolean isTyped = false; | public void parseLinkage(Vector pedigrees) throws PedFileException { int colNum = -1; boolean withOptionalColumn = false; int numLines = pedigrees.size(); Individual ind; this.order = new Vector(); for(int k=0; k<numLines; k++){ StringTokenizer tokenizer = new StringTokenizer((String)pedigrees.get(k), "\n\t\" \""); //reading the first line if(colNum < 1){ //only check column number count for the first nonblank line colNum = tokenizer.countTokens(); if(colNum%2==1) { withOptionalColumn = true; } } if(colNum != tokenizer.countTokens()) { //this line has a different number of columns //should send some sort of error message //TODO: add something which stores number of markers for all lines and checks that they're consistent throw new PedFileException("line number mismatch in pedfile. line " + (k+1)); } ind = new Individual(tokenizer.countTokens()); if(tokenizer.hasMoreTokens()){ ind.setFamilyID(tokenizer.nextToken().trim()); ind.setIndividualID(tokenizer.nextToken().trim()); ind.setDadID(tokenizer.nextToken().trim()); ind.setMomID(tokenizer.nextToken().trim()); try { //TODO: affected/liability should not be forced into Integers! ind.setGender(Integer.parseInt(tokenizer.nextToken().trim())); ind.setAffectedStatus(Integer.parseInt(tokenizer.nextToken().trim())); if(withOptionalColumn) { ind.setLiability(Integer.parseInt(tokenizer.nextToken().trim())); } }catch(NumberFormatException nfe) { throw new PedFileException("Pedfile error: invalid gender or affected status on line " + (k+1)); } boolean isTyped = false; while(tokenizer.hasMoreTokens()){ try { int allele1 = Integer.parseInt(tokenizer.nextToken().trim()); int allele2 = Integer.parseInt(tokenizer.nextToken().trim()); if ( !( (allele1==0) && (allele2 == 0) ) ) isTyped = true; if(allele1 <0 || allele1 > 4 || allele2 <0 || allele2 >4) { throw new PedFileException("Pedigree file input error: invalid genotype on line " + (k+1) + ".\n all genotypes must be 0-4."); } byte[] markers = new byte[2]; markers[0] = (byte)allele1; markers[1]= (byte)allele2; ind.addMarker(markers); }catch(NumberFormatException nfe) { throw new PedFileException("Pedigree file input error: invalid genotype on line " + (k+1) ); } } //note whether this is a real indiv (true) or a "dummy" (false) ind.setIsTyped(isTyped); //check if the family exists already in the Hashtable Family fam = (Family)this.families.get(ind.getFamilyID()); if(fam == null){ //it doesnt exist, so create a new Family object fam = new Family(ind.getFamilyID()); } fam.addMember(ind); this.families.put(ind.getFamilyID(),fam); String[] indFamID = new String[2]; indFamID[0] = ind.getFamilyID(); indFamID[1] = ind.getIndividualID(); this.order.add(ind); } } } |
|
if ( !( (allele1==0) && (allele2 == 0) ) ) isTyped = true; | public void parseLinkage(Vector pedigrees) throws PedFileException { int colNum = -1; boolean withOptionalColumn = false; int numLines = pedigrees.size(); Individual ind; this.order = new Vector(); for(int k=0; k<numLines; k++){ StringTokenizer tokenizer = new StringTokenizer((String)pedigrees.get(k), "\n\t\" \""); //reading the first line if(colNum < 1){ //only check column number count for the first nonblank line colNum = tokenizer.countTokens(); if(colNum%2==1) { withOptionalColumn = true; } } if(colNum != tokenizer.countTokens()) { //this line has a different number of columns //should send some sort of error message //TODO: add something which stores number of markers for all lines and checks that they're consistent throw new PedFileException("line number mismatch in pedfile. line " + (k+1)); } ind = new Individual(tokenizer.countTokens()); if(tokenizer.hasMoreTokens()){ ind.setFamilyID(tokenizer.nextToken().trim()); ind.setIndividualID(tokenizer.nextToken().trim()); ind.setDadID(tokenizer.nextToken().trim()); ind.setMomID(tokenizer.nextToken().trim()); try { //TODO: affected/liability should not be forced into Integers! ind.setGender(Integer.parseInt(tokenizer.nextToken().trim())); ind.setAffectedStatus(Integer.parseInt(tokenizer.nextToken().trim())); if(withOptionalColumn) { ind.setLiability(Integer.parseInt(tokenizer.nextToken().trim())); } }catch(NumberFormatException nfe) { throw new PedFileException("Pedfile error: invalid gender or affected status on line " + (k+1)); } boolean isTyped = false; while(tokenizer.hasMoreTokens()){ try { int allele1 = Integer.parseInt(tokenizer.nextToken().trim()); int allele2 = Integer.parseInt(tokenizer.nextToken().trim()); if ( !( (allele1==0) && (allele2 == 0) ) ) isTyped = true; if(allele1 <0 || allele1 > 4 || allele2 <0 || allele2 >4) { throw new PedFileException("Pedigree file input error: invalid genotype on line " + (k+1) + ".\n all genotypes must be 0-4."); } byte[] markers = new byte[2]; markers[0] = (byte)allele1; markers[1]= (byte)allele2; ind.addMarker(markers); }catch(NumberFormatException nfe) { throw new PedFileException("Pedigree file input error: invalid genotype on line " + (k+1) ); } } //note whether this is a real indiv (true) or a "dummy" (false) ind.setIsTyped(isTyped); //check if the family exists already in the Hashtable Family fam = (Family)this.families.get(ind.getFamilyID()); if(fam == null){ //it doesnt exist, so create a new Family object fam = new Family(ind.getFamilyID()); } fam.addMember(ind); this.families.put(ind.getFamilyID(),fam); String[] indFamID = new String[2]; indFamID[0] = ind.getFamilyID(); indFamID[1] = ind.getIndividualID(); this.order.add(ind); } } } |
|
ind.setIsTyped(isTyped); | public void parseLinkage(Vector pedigrees) throws PedFileException { int colNum = -1; boolean withOptionalColumn = false; int numLines = pedigrees.size(); Individual ind; this.order = new Vector(); for(int k=0; k<numLines; k++){ StringTokenizer tokenizer = new StringTokenizer((String)pedigrees.get(k), "\n\t\" \""); //reading the first line if(colNum < 1){ //only check column number count for the first nonblank line colNum = tokenizer.countTokens(); if(colNum%2==1) { withOptionalColumn = true; } } if(colNum != tokenizer.countTokens()) { //this line has a different number of columns //should send some sort of error message //TODO: add something which stores number of markers for all lines and checks that they're consistent throw new PedFileException("line number mismatch in pedfile. line " + (k+1)); } ind = new Individual(tokenizer.countTokens()); if(tokenizer.hasMoreTokens()){ ind.setFamilyID(tokenizer.nextToken().trim()); ind.setIndividualID(tokenizer.nextToken().trim()); ind.setDadID(tokenizer.nextToken().trim()); ind.setMomID(tokenizer.nextToken().trim()); try { //TODO: affected/liability should not be forced into Integers! ind.setGender(Integer.parseInt(tokenizer.nextToken().trim())); ind.setAffectedStatus(Integer.parseInt(tokenizer.nextToken().trim())); if(withOptionalColumn) { ind.setLiability(Integer.parseInt(tokenizer.nextToken().trim())); } }catch(NumberFormatException nfe) { throw new PedFileException("Pedfile error: invalid gender or affected status on line " + (k+1)); } boolean isTyped = false; while(tokenizer.hasMoreTokens()){ try { int allele1 = Integer.parseInt(tokenizer.nextToken().trim()); int allele2 = Integer.parseInt(tokenizer.nextToken().trim()); if ( !( (allele1==0) && (allele2 == 0) ) ) isTyped = true; if(allele1 <0 || allele1 > 4 || allele2 <0 || allele2 >4) { throw new PedFileException("Pedigree file input error: invalid genotype on line " + (k+1) + ".\n all genotypes must be 0-4."); } byte[] markers = new byte[2]; markers[0] = (byte)allele1; markers[1]= (byte)allele2; ind.addMarker(markers); }catch(NumberFormatException nfe) { throw new PedFileException("Pedigree file input error: invalid genotype on line " + (k+1) ); } } //note whether this is a real indiv (true) or a "dummy" (false) ind.setIsTyped(isTyped); //check if the family exists already in the Hashtable Family fam = (Family)this.families.get(ind.getFamilyID()); if(fam == null){ //it doesnt exist, so create a new Family object fam = new Family(ind.getFamilyID()); } fam.addMember(ind); this.families.put(ind.getFamilyID(),fam); String[] indFamID = new String[2]; indFamID[0] = ind.getFamilyID(); indFamID[1] = ind.getIndividualID(); this.order.add(ind); } } } |
|
public Tag createTag() throws Exception { | public Tag createTag(String name, Attributes attributes) throws Exception { | public TagScript createTagScript(String name, Attributes attributes) throws Exception { TagScript answer = super.createTagScript(name, attributes); if ( answer == null ) { final Factory factory = getFactory( name ); if ( factory != null ) { return new TagScript( new TagFactory() { public Tag createTag() throws Exception { if ( factory instanceof TagFactory ) { return ((TagFactory) factory).createTag(); } else { return new ComponentTag(factory); } } } ); } } return answer; } |
return ((TagFactory) factory).createTag(); | return ((TagFactory) factory).createTag(name, attributes); | public TagScript createTagScript(String name, Attributes attributes) throws Exception { TagScript answer = super.createTagScript(name, attributes); if ( answer == null ) { final Factory factory = getFactory( name ); if ( factory != null ) { return new TagScript( new TagFactory() { public Tag createTag() throws Exception { if ( factory instanceof TagFactory ) { return ((TagFactory) factory).createTag(); } else { return new ComponentTag(factory); } } } ); } } return answer; } |
public Tag createTag() throws Exception { | public Tag createTag(String name, Attributes attributes) throws Exception { | public Tag createTag() throws Exception { if ( factory instanceof TagFactory ) { return ((TagFactory) factory).createTag(); } else { return new ComponentTag(factory); } } |
return ((TagFactory) factory).createTag(); | return ((TagFactory) factory).createTag(name, attributes); | public Tag createTag() throws Exception { if ( factory instanceof TagFactory ) { return ((TagFactory) factory).createTag(); } else { return new ComponentTag(factory); } } |
String text = getBodyText(); Object[] args = { text }; | Object[] args = { body }; | public void doTag(XMLOutput output) throws Exception { Project project = getAntProject(); String tagName = getTagName(); Object parentObject = findBeanAncestor(); // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask if ( ! ( parentObject instanceof Task ) && project.getTaskDefinitions().containsKey( tagName ) ) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { String text = getBodyText(); Object[] args = { text }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { if ( log.isDebugEnabled() ) { log.debug( "Creating a nested object name: " + tagName ); } Object nested = createNestedObject( parentObject, tagName ); if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { if (log.isDebugEnabled()) { log.debug("About to set the: " + tagName + " property on: " + parentObject + " to value: " + nested + " with type: " + nested.getClass() ); } ih.storeElement( project, parentObject, nested, tagName ); } catch (Exception e) { log.warn( "Caught exception setting nested: " + tagName, e ); } // now try to set the property for good measure // as the storeElement() method does not // seem to call any setter methods of non-String types try { BeanUtils.setProperty( parentObject, tagName, nested ); } catch (Exception e) { log.debug("Caught exception trying to set property: " + tagName + " on: " + parentObject); } } } else { // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } } |
} | log.error("Caught exception while closing statement: " + e, e); } | public void doTag(XMLOutput output) throws Exception { if (!maxRowsSpecified) { Object obj = context.getVariable("org.apache.commons.jelly.sql.maxRows"); if (obj != null) { if (obj instanceof Integer) { maxRows = ((Integer) obj).intValue(); } else if (obj instanceof String) { try { maxRows = Integer.parseInt((String) obj); } catch (NumberFormatException nfe) { throw new JellyException( Resources.getMessage("SQL_MAXROWS_PARSE_ERROR", (String) obj), nfe); } } else { throw new JellyException(Resources.getMessage("SQL_MAXROWS_INVALID")); } } } Result result = null; String sqlStatement = null; log.debug( "About to lookup connection" ); ResultSet rs = null; Statement statement = null; try { conn = getConnection(); /* * Use the SQL statement specified by the sql attribute, if any, * otherwise use the body as the statement. */ if (sql != null) { sqlStatement = sql; } else { sqlStatement = getBodyText(); } if (sqlStatement == null || sqlStatement.trim().length() == 0) { throw new JellyException(Resources.getMessage("SQL_NO_STATEMENT")); } /* * We shouldn't have a negative startRow or illegal maxrows */ if ((startRow < 0) || (maxRows < -1)) { throw new JellyException(Resources.getMessage("PARAM_BAD_VALUE")); } /* * Note! We must not use the setMaxRows() method on the * the statement to limit the number of rows, since the * Result factory must be able to figure out the correct * value for isLimitedByMaxRows(); there's no way to check * if it was from the ResultSet. */ if ( log.isDebugEnabled() ) { log.debug( "About to execute query: " + sqlStatement ); } if ( hasParameters() ) { PreparedStatement ps = conn.prepareStatement(sqlStatement); statement = ps; setParameters(ps); rs = ps.executeQuery(); } else { statement = conn.createStatement(); rs = statement.executeQuery(sqlStatement); } result = new ResultImpl(rs, startRow, maxRows); context.setVariable(var, result); } catch (SQLException e) { throw new JellyException(sqlStatement + ": " + e.getMessage(), e); } finally { if (statement != null) { try { statement.close(); } catch (SQLException e) { } // Not much we can do } if (rs != null) { try { rs.close(); } catch (SQLException e) { } // Not much we can do } if (conn != null && !isPartOfTransaction) { try { conn.close(); } catch (SQLException e) { } // Not much we can do conn = null; } clearParameters(); } } |
} | log.error("Caught exception while closing result set: " + e, e); } | public void doTag(XMLOutput output) throws Exception { if (!maxRowsSpecified) { Object obj = context.getVariable("org.apache.commons.jelly.sql.maxRows"); if (obj != null) { if (obj instanceof Integer) { maxRows = ((Integer) obj).intValue(); } else if (obj instanceof String) { try { maxRows = Integer.parseInt((String) obj); } catch (NumberFormatException nfe) { throw new JellyException( Resources.getMessage("SQL_MAXROWS_PARSE_ERROR", (String) obj), nfe); } } else { throw new JellyException(Resources.getMessage("SQL_MAXROWS_INVALID")); } } } Result result = null; String sqlStatement = null; log.debug( "About to lookup connection" ); ResultSet rs = null; Statement statement = null; try { conn = getConnection(); /* * Use the SQL statement specified by the sql attribute, if any, * otherwise use the body as the statement. */ if (sql != null) { sqlStatement = sql; } else { sqlStatement = getBodyText(); } if (sqlStatement == null || sqlStatement.trim().length() == 0) { throw new JellyException(Resources.getMessage("SQL_NO_STATEMENT")); } /* * We shouldn't have a negative startRow or illegal maxrows */ if ((startRow < 0) || (maxRows < -1)) { throw new JellyException(Resources.getMessage("PARAM_BAD_VALUE")); } /* * Note! We must not use the setMaxRows() method on the * the statement to limit the number of rows, since the * Result factory must be able to figure out the correct * value for isLimitedByMaxRows(); there's no way to check * if it was from the ResultSet. */ if ( log.isDebugEnabled() ) { log.debug( "About to execute query: " + sqlStatement ); } if ( hasParameters() ) { PreparedStatement ps = conn.prepareStatement(sqlStatement); statement = ps; setParameters(ps); rs = ps.executeQuery(); } else { statement = conn.createStatement(); rs = statement.executeQuery(sqlStatement); } result = new ResultImpl(rs, startRow, maxRows); context.setVariable(var, result); } catch (SQLException e) { throw new JellyException(sqlStatement + ": " + e.getMessage(), e); } finally { if (statement != null) { try { statement.close(); } catch (SQLException e) { } // Not much we can do } if (rs != null) { try { rs.close(); } catch (SQLException e) { } // Not much we can do } if (conn != null && !isPartOfTransaction) { try { conn.close(); } catch (SQLException e) { } // Not much we can do conn = null; } clearParameters(); } } |
} | log.error("Caught exception while closing connection: " + e, e); } | public void doTag(XMLOutput output) throws Exception { if (!maxRowsSpecified) { Object obj = context.getVariable("org.apache.commons.jelly.sql.maxRows"); if (obj != null) { if (obj instanceof Integer) { maxRows = ((Integer) obj).intValue(); } else if (obj instanceof String) { try { maxRows = Integer.parseInt((String) obj); } catch (NumberFormatException nfe) { throw new JellyException( Resources.getMessage("SQL_MAXROWS_PARSE_ERROR", (String) obj), nfe); } } else { throw new JellyException(Resources.getMessage("SQL_MAXROWS_INVALID")); } } } Result result = null; String sqlStatement = null; log.debug( "About to lookup connection" ); ResultSet rs = null; Statement statement = null; try { conn = getConnection(); /* * Use the SQL statement specified by the sql attribute, if any, * otherwise use the body as the statement. */ if (sql != null) { sqlStatement = sql; } else { sqlStatement = getBodyText(); } if (sqlStatement == null || sqlStatement.trim().length() == 0) { throw new JellyException(Resources.getMessage("SQL_NO_STATEMENT")); } /* * We shouldn't have a negative startRow or illegal maxrows */ if ((startRow < 0) || (maxRows < -1)) { throw new JellyException(Resources.getMessage("PARAM_BAD_VALUE")); } /* * Note! We must not use the setMaxRows() method on the * the statement to limit the number of rows, since the * Result factory must be able to figure out the correct * value for isLimitedByMaxRows(); there's no way to check * if it was from the ResultSet. */ if ( log.isDebugEnabled() ) { log.debug( "About to execute query: " + sqlStatement ); } if ( hasParameters() ) { PreparedStatement ps = conn.prepareStatement(sqlStatement); statement = ps; setParameters(ps); rs = ps.executeQuery(); } else { statement = conn.createStatement(); rs = statement.executeQuery(sqlStatement); } result = new ResultImpl(rs, startRow, maxRows); context.setVariable(var, result); } catch (SQLException e) { throw new JellyException(sqlStatement + ": " + e.getMessage(), e); } finally { if (statement != null) { try { statement.close(); } catch (SQLException e) { } // Not much we can do } if (rs != null) { try { rs.close(); } catch (SQLException e) { } // Not much we can do } if (conn != null && !isPartOfTransaction) { try { conn.close(); } catch (SQLException e) { } // Not much we can do conn = null; } clearParameters(); } } |
throw new JellyTagException( "this tag must be nested within a <tr> tag" ); | throw new JellyTagException( "this tag must be nested within a <borderLayout> tag" ); | public void addChild(Component component, Object constraints) throws JellyTagException { BorderLayoutTag tag = (BorderLayoutTag) findAncestorWithClass( BorderLayoutTag.class ); if (tag == null) { throw new JellyTagException( "this tag must be nested within a <tr> tag" ); } tag.addLayoutComponent(component, getConstraints()); } |
for (int j = i+1; j < dPrime.getLength(i); j++){ | for (int j = i+1; j < i + dPrime.getLength(i); j++){ | static Vector doSpine(DPrimeTable dPrime){ // find blocks by searching for stretches between two markers A,B where // D prime is > a threshold for all informative combinations of A, (A+1...B) int baddies; int verticalExtent=0; int horizontalExtent=0; Vector blocks = new Vector(); for (int i = 0; i < Chromosome.getSize(); i++){ baddies=0; //find how far LD from marker i extends for (int j = i+1; j < dPrime.getLength(i); j++){ PairwiseLinkage thisPair = dPrime.getLDStats(i,j); if (thisPair == null){ continue; } //LD extends if D' > threshold if (thisPair.getDPrime() < spineDP){ //LD extends through one 'bad' marker if (baddies < 1){ baddies++; } else { verticalExtent = j-1; break; } } verticalExtent=j; } //now we need to find a stretch of LD of all markers between i and j //start with the longest possible block of LD and work backwards to find //one which is good for (int m = verticalExtent; m > i; m--){ for (int k = i; k < m; k++){ PairwiseLinkage thisPair = dPrime.getLDStats(k,m); if (thisPair == null){ continue; } if(thisPair.getDPrime() < spineDP){ if (baddies < 1){ baddies++; } else { break; } } horizontalExtent=k+1; } //is this a block of LD? //previously, this algorithm was more complex and made some calls better //but caused major problems in others. since the guessing is somewhat //arbitrary, this new and simple method is fine. if(horizontalExtent == m){ blocks.add(i + " " + m); i=m; } } } return stringVec2intVec(blocks); } |
setPropertyValue( target, property, value ); | setPropertyValue( target, property, answer ); | public void doTag(XMLOutput output) throws Exception { Object answer = null; if ( value != null ) { answer = value.evaluate(context); } else { answer = getBodyText(); } if ( var != null ) { context.setVariable(var, answer); } else { if ( target == null ) { throw new JellyException( "Either a 'var' or a 'target' attribute must be defined for this tag" ); } if ( property == null ) { throw new JellyException( "You must define a 'property' attribute if you specify a 'target'" ); } setPropertyValue( target, property, value ); } } |
if ( target instanceof Map ) { Map map = (Map) target; map.put( property, value ); | try { if ( target instanceof Map ) { Map map = (Map) target; map.put( property, value ); } else { BeanUtils.setProperty( target, property, value ); } | protected void setPropertyValue( Object target, String property, Object value ) throws Exception { if ( target instanceof Map ) { Map map = (Map) target; map.put( property, value ); } else { BeanUtils.setProperty( target, property, value ); } } |
else { BeanUtils.setProperty( target, property, value ); | catch (Exception e) { log.error( "Failed to set the property: " + property + " on bean: " + target + " to value: " + value + " due to exception: " + e, e ); | protected void setPropertyValue( Object target, String property, Object value ) throws Exception { if ( target instanceof Map ) { Map map = (Map) target; map.put( property, value ); } else { BeanUtils.setProperty( target, property, value ); } } |
public void addColumn(SQLColumn c, SQLTable t) throws ArchitectDiffException { | public void addColumn(SQLColumn c) { | public void addColumn(SQLColumn c, SQLTable t) throws ArchitectDiffException { Map colNameMap = new HashMap(); print("\n ALTER TABLE "); print( toQualifiedName(t) ); print(" ADD COLUMN "); print(columnDefinition(c,colNameMap)); endStatement(DDLStatement.StatementType.CREATE, c); } |
print( toQualifiedName(t) ); | print(toQualifiedName(c.getParentTable())); | public void addColumn(SQLColumn c, SQLTable t) throws ArchitectDiffException { Map colNameMap = new HashMap(); print("\n ALTER TABLE "); print( toQualifiedName(t) ); print(" ADD COLUMN "); print(columnDefinition(c,colNameMap)); endStatement(DDLStatement.StatementType.CREATE, c); } |
public void addPrimaryKey(SQLTable t, String primaryKeyName) throws ArchitectException { | public void addPrimaryKey(SQLTable t) throws ArchitectException { | public void addPrimaryKey(SQLTable t, String primaryKeyName) throws ArchitectException { Map colNameMap = new HashMap(); StringBuffer sqlStatement = new StringBuffer(); boolean first = true; sqlStatement.append("ALTER TABLE "+ toQualifiedName(t.getCatalogName(),t.getSchemaName(),t.getName()) + " ADD PRIMARY KEY ("); for (SQLColumn c : t.getColumns()) { if (c.isPrimaryKey()) { if (!first) { sqlStatement.append(","); }else{ first =false; } sqlStatement.append(createPhysicalName(colNameMap,c)); } } sqlStatement.append(")"); if (!first) { print(sqlStatement.toString()); endStatement(DDLStatement.StatementType.CREATE,t); } } |
sqlStatement.append("ALTER TABLE "+ toQualifiedName(t.getCatalogName(),t.getSchemaName(),t.getName()) | sqlStatement.append("ALTER TABLE "+ toQualifiedName(t.getName()) | public void addPrimaryKey(SQLTable t, String primaryKeyName) throws ArchitectException { Map colNameMap = new HashMap(); StringBuffer sqlStatement = new StringBuffer(); boolean first = true; sqlStatement.append("ALTER TABLE "+ toQualifiedName(t.getCatalogName(),t.getSchemaName(),t.getName()) + " ADD PRIMARY KEY ("); for (SQLColumn c : t.getColumns()) { if (c.isPrimaryKey()) { if (!first) { sqlStatement.append(","); }else{ first =false; } sqlStatement.append(createPhysicalName(colNameMap,c)); } } sqlStatement.append(")"); if (!first) { print(sqlStatement.toString()); endStatement(DDLStatement.StatementType.CREATE,t); } } |
public void addRelationship(SQLRelationship r) throws ArchitectDiffException { | public void addRelationship(SQLRelationship r) { | public void addRelationship(SQLRelationship r) throws ArchitectDiffException { print("\n ALTER TABLE "); print( toQualifiedName(r.getFkTable()) ); print(" ADD CONSTRAINT "); print(r.getName()); print(" FOREIGN KEY ( "); Map<String, SQLColumn> colNameMap = new HashMap<String, SQLColumn> (); boolean firstColumn = true; for (ColumnMapping cm : r.getMappings()) { SQLColumn c = cm.getFkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if (firstColumn) { firstColumn = false; print(createPhysicalName(colNameMap, c)); } else { print(", " + createPhysicalName(colNameMap, c)); } colNameMap.put(c.getName(), c); } } print(" ) REFERENCES "); print( toQualifiedName(r.getPkTable()) ); print(" ( "); colNameMap = new HashMap<String, SQLColumn>(); firstColumn = true; for (ColumnMapping cm : r.getMappings()) { SQLColumn c = cm.getPkColumn(); // make sure this is unique if (colNameMap.get(c.getName()) == null) { if (firstColumn) { firstColumn = false; print(createPhysicalName(colNameMap, c)); } else { print(", " + createPhysicalName(colNameMap, c)); } colNameMap.put(c.getName(), c); } } print(" )"); endStatement(DDLStatement.StatementType.CREATE, r); } |
protected String columnDefinition(SQLColumn c, Map colNameMap) throws ArchitectDiffException { | protected String columnDefinition(SQLColumn c, Map colNameMap) { | protected String columnDefinition(SQLColumn c, Map colNameMap) throws ArchitectDiffException { StringBuffer def = new StringBuffer(); // Column name def.append(createPhysicalName(colNameMap, c)); def.append(" "); def.append(columnType(c)); def.append(" "); // Column nullability def.append(columnNullability(c)); return def.toString(); } |
public void dropColumn(SQLColumn c, SQLTable t) throws ArchitectDiffException { | public void dropColumn(SQLColumn c) { | public void dropColumn(SQLColumn c, SQLTable t) throws ArchitectDiffException { Map colNameMap = new HashMap(); print("\n ALTER TABLE "); print( toQualifiedName(t) ); print(" DROP COLUMN "); print(createPhysicalName(colNameMap,c)); endStatement(DDLStatement.StatementType.DROP, c); } |
print( toQualifiedName(t) ); | print(toQualifiedName(c.getParentTable())); | public void dropColumn(SQLColumn c, SQLTable t) throws ArchitectDiffException { Map colNameMap = new HashMap(); print("\n ALTER TABLE "); print( toQualifiedName(t) ); print(" DROP COLUMN "); print(createPhysicalName(colNameMap,c)); endStatement(DDLStatement.StatementType.DROP, c); } |
public void dropPrimaryKey(SQLTable t, String primaryKeyName) { | public void dropPrimaryKey(SQLTable t) { | public void dropPrimaryKey(SQLTable t, String primaryKeyName) { print("ALTER TABLE " + toQualifiedName(t.getCatalogName(),t.getSchemaName(),t.getName()) + " DROP PRIMARY KEY " + primaryKeyName); endStatement(DDLStatement.StatementType.DROP,t); } |
print("ALTER TABLE " + toQualifiedName(t.getCatalogName(),t.getSchemaName(),t.getName()) + " DROP PRIMARY KEY " + primaryKeyName); endStatement(DDLStatement.StatementType.DROP,t); | print("ALTER TABLE " + toQualifiedName(t.getName()) + " DROP PRIMARY KEY " + t.getPrimaryKeyName()); endStatement(DDLStatement.StatementType.DROP, t); | public void dropPrimaryKey(SQLTable t, String primaryKeyName) { print("ALTER TABLE " + toQualifiedName(t.getCatalogName(),t.getSchemaName(),t.getName()) + " DROP PRIMARY KEY " + primaryKeyName); endStatement(DDLStatement.StatementType.DROP,t); } |
print(makeDropTableSQL(t.getCatalogName(), t.getSchemaName(), t.getName())); | print(makeDropTableSQL(t.getName())); | public void dropTable(SQLTable t) { print(makeDropTableSQL(t.getCatalogName(), t.getSchemaName(), t.getName())); endStatement(DDLStatement.StatementType.DROP, t); } |
public List generateDDLStatements(SQLDatabase source) throws SQLException, ArchitectException { | public List<DDLStatement> generateDDLStatements(SQLDatabase source) throws SQLException, ArchitectException { | public List generateDDLStatements(SQLDatabase source) throws SQLException, ArchitectException { warnings = new ArrayList(); ddlStatements = new ArrayList(); ddl = new StringBuffer(500); topLevelNames = new HashMap(); // for tracking dup table/relationship names try { if (allowConnection) { con = source.getConnection(); } else { con = null; } createTypeMap(); Iterator it = source.getChildren().iterator(); while (it.hasNext()) { SQLTable t = (SQLTable) it.next(); writeTable(t); writePrimaryKey(t); } it = source.getChildren().iterator(); while (it.hasNext()) { SQLTable t = (SQLTable) it.next(); writeExportedRelationships(t); } // TODO add warnings for the originals of the existing duplicate name warnings } finally { try { if (con != null) con.close(); } catch (SQLException ex) { logger.error("Couldn't close connection", ex); } } return ddlStatements; } |
ddlStatements = new ArrayList(); | ddlStatements = new ArrayList<DDLStatement>(); | public List generateDDLStatements(SQLDatabase source) throws SQLException, ArchitectException { warnings = new ArrayList(); ddlStatements = new ArrayList(); ddl = new StringBuffer(500); topLevelNames = new HashMap(); // for tracking dup table/relationship names try { if (allowConnection) { con = source.getConnection(); } else { con = null; } createTypeMap(); Iterator it = source.getChildren().iterator(); while (it.hasNext()) { SQLTable t = (SQLTable) it.next(); writeTable(t); writePrimaryKey(t); } it = source.getChildren().iterator(); while (it.hasNext()) { SQLTable t = (SQLTable) it.next(); writeExportedRelationships(t); } // TODO add warnings for the originals of the existing duplicate name warnings } finally { try { if (con != null) con.close(); } catch (SQLException ex) { logger.error("Couldn't close connection", ex); } } return ddlStatements; } |
public String makeDropForeignKeySQL(String fkCatalog, String fkSchema, String fkTable, String fkName) { | public String makeDropForeignKeySQL(String fkTable, String fkName) { | public String makeDropForeignKeySQL(String fkCatalog, String fkSchema, String fkTable, String fkName) { return "ALTER TABLE " +toQualifiedName(fkCatalog, fkSchema, fkTable) +" DROP FOREIGN KEY " +fkName; } |
+toQualifiedName(fkCatalog, fkSchema, fkTable) | +toQualifiedName(fkTable) | public String makeDropForeignKeySQL(String fkCatalog, String fkSchema, String fkTable, String fkName) { return "ALTER TABLE " +toQualifiedName(fkCatalog, fkSchema, fkTable) +" DROP FOREIGN KEY " +fkName; } |
public String makeDropTableSQL(String catalog, String schema, String table) { return "DROP TABLE "+toQualifiedName(catalog, schema, table); | public String makeDropTableSQL(String table) { return "DROP TABLE "+toQualifiedName(table); | public String makeDropTableSQL(String catalog, String schema, String table) { return "DROP TABLE "+toQualifiedName(catalog, schema, table); } |
public void modifyColumn(SQLColumn c) throws ArchitectDiffException { | public void modifyColumn(SQLColumn c) { | public void modifyColumn(SQLColumn c) throws ArchitectDiffException { Map colNameMap = new HashMap(); SQLTable t = c.getParentTable(); print("\n ALTER TABLE "); print( toQualifiedName(t) ); print(" ALTER COLUMN "); print(columnDefinition(c,colNameMap)); endStatement(DDLStatement.StatementType.MODIFY, c); } |
String catalog = getTargetCatalog(); if ( catalog == null ) catalog = t.getCatalogName(); String schema = getTargetSchema(); if ( schema == null ) schema = t.getSchemaName(); return DDLUtils.toQualifiedName(catalog,schema,t.getPhysicalName()); | return toQualifiedName(t.getPhysicalName()); | public String toQualifiedName(SQLTable t) { String catalog = getTargetCatalog(); if ( catalog == null ) catalog = t.getCatalogName(); String schema = getTargetSchema(); if ( schema == null ) schema = t.getSchemaName(); return DDLUtils.toQualifiedName(catalog,schema,t.getPhysicalName()); } |
append(pkCols, cmap.getPkColumn().getPhysicalName()); append(fkCols, cmap.getFkColumn().getPhysicalName()); | pkCols.append(cmap.getPkColumn().getPhysicalName()); fkCols.append(cmap.getFkColumn().getPhysicalName()); | protected void writeExportedRelationships(SQLTable t) throws ArchitectException { Iterator it = t.getExportedKeys().iterator(); while (it.hasNext()) { SQLRelationship rel = (SQLRelationship) it.next(); // geneate a physical name for this relationship createPhysicalName(topLevelNames,rel); // println(""); print("ALTER TABLE "); // this works because all the tables have had their physical names generated already... print( toQualifiedName(rel.getFkTable()) ); print(" ADD CONSTRAINT "); print(rel.getPhysicalName()); println(""); print("FOREIGN KEY ("); StringBuffer pkCols = new StringBuffer(); StringBuffer fkCols = new StringBuffer(); boolean firstCol = true; Iterator mappings = rel.getChildren().iterator(); while (mappings.hasNext()) { SQLRelationship.ColumnMapping cmap = (SQLRelationship.ColumnMapping) mappings.next(); if (!firstCol) { pkCols.append(", "); fkCols.append(", "); } // append(pkCols, cmap.getPkColumn().getPhysicalName()); append(fkCols, cmap.getFkColumn().getPhysicalName()); firstCol = false; } print(fkCols.toString()); println(")"); print("REFERENCES "); print( toQualifiedName(rel.getPkTable()) ); print(" ("); print(pkCols.toString()); print(")"); endStatement(DDLStatement.StatementType.ADD_FK, t); } } |
Implementation odmg = ODMG.getODMGImplementation(); Database db = ODMG.getODMGDatabase(); | public void delete() { Implementation odmg = ODMG.getODMGImplementation(); Database db = ODMG.getODMGDatabase(); ODMGXAWrapper txw = new ODMGXAWrapper(); db.deletePersistent( this ); if ( imageFile != null && !imageFile.delete() ) { log.error( "File " + imageFile.getAbsolutePath() + " could not be deleted" ); } txw.commit(); } |
|
if ( imageFile != null && !imageFile.delete() ) { log.error( "File " + imageFile.getAbsolutePath() + " could not be deleted" ); | if ( !(volume instanceof ExternalVolume) ) { if ( imageFile != null && !imageFile.delete() ) { log.error( "File " + imageFile.getAbsolutePath() + " could not be deleted" ); } | public void delete() { Implementation odmg = ODMG.getODMGImplementation(); Database db = ODMG.getODMGDatabase(); ODMGXAWrapper txw = new ODMGXAWrapper(); db.deletePersistent( this ); if ( imageFile != null && !imageFile.delete() ) { log.error( "File " + imageFile.getAbsolutePath() + " could not be deleted" ); } txw.commit(); } |
return checkTime; | return checkTime != null ? (java.util.Date) checkTime.clone() : null; | public java.util.Date getCheckTime() { ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.READ ); txw.commit(); return checkTime; } |
return (byte[]) hash.clone(); | return (hash != null) ? (byte[]) hash.clone() : null; | public byte[] getHash() { if ( hash == null && imageFile != null ) { calcHash(); } return (byte[]) hash.clone(); } |
reader.setInput( iis, true ); width = reader.getWidth( 0 ); height = reader.getHeight( 0 ); iis.close(); | if ( iis != null ) { reader.setInput( iis, true ); width = reader.getWidth( 0 ); height = reader.getHeight( 0 ); iis.close(); } | protected void readImageFile() throws IOException { // Find the JPEG image reader // TODO: THis shoud decode also other readers from fname Iterator readers = ImageIO.getImageReadersByFormatName("jpg"); ImageReader reader = (ImageReader)readers.next(); ImageInputStream iis = ImageIO.createImageInputStream( imageFile ); reader.setInput( iis, true ); width = reader.getWidth( 0 ); height = reader.getHeight( 0 ); iis.close(); } |
if(context.isRefreshRequest()){ return output.toString(); } | public String draw(DashboardContext context) { StringBuffer output = new StringBuffer(); output.append(component.draw(context)); // append script final String dashboardId = context.getDashboardConfig().getDashboardId(); String appId = context.getWebContext().getApplicationConfig().getApplicationId(); output.append("\n<script>"); output.append("self.setTimeout(\"refreshDBComponent("); output.append("''"); output.append(dashboardId); output.append("'', ''"); output.append(getId()); output.append("'', "); output.append(refreshInterval + ", " + appId + ",''dummy'',''dummy'')\", " + refreshInterval + ");"); output.append("</script>"); return output.toString(); } |
|
modified(); | public void addPhoto( PhotoInfo photo ) { if ( photos == null ) { photos = new Vector(); } ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); photo.addedToFolder( this ); photos.add( photo ); txw.commit(); } |
|
modified(); | public void removePhoto( PhotoInfo photo ) { if ( photos == null ) { return; } ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); photo.removedFromFolder( this ); photos.remove( photo ); txw.commit(); } |
|
return (String) this.context.getVariable(name); | Object value = this.context.getVariable(name); if (value == null) { return null; } else { return value.toString(); } | public String getProperty(String name) { if (name == null) { return null; } return (String) this.context.getVariable(name); } |
log.warn( "Checking bounds" ); | log.debug( "Checking bounds" ); | protected Rectangle getPhotoBounds( int photoNum ) { if ( photoNum < photoCollection.getPhotoCount() ) { PhotoInfo photoCandidate = photoCollection.getPhoto( photoNum ); log.warn( "Checking bounds" ); // Check whether the click was inside the thumbnail or not int width = 100; int height = 75; Thumbnail thumb = photoCandidate.getThumbnail(); if ( thumb != null ) { BufferedImage img = thumb.getImage(); width = img.getWidth(); height = img.getHeight(); } int row = (int) photoNum / columnCount; int col = photoNum - row*columnCount; int imgX = col * columnWidth + (columnWidth - width)/(int)2; int imgY = row * rowHeight + (rowHeight - height)/(int)2; Rectangle imgRect = new Rectangle( imgX, imgY, width, height ); return imgRect; } return null; } |
Thumbnail thumb = photoCandidate.getThumbnail(); | Thumbnail thumb = null; if ( photoCandidate.hasThumbnail() ) { thumb = photoCandidate.getThumbnail(); } | protected Rectangle getPhotoBounds( int photoNum ) { if ( photoNum < photoCollection.getPhotoCount() ) { PhotoInfo photoCandidate = photoCollection.getPhoto( photoNum ); log.warn( "Checking bounds" ); // Check whether the click was inside the thumbnail or not int width = 100; int height = 75; Thumbnail thumb = photoCandidate.getThumbnail(); if ( thumb != null ) { BufferedImage img = thumb.getImage(); width = img.getWidth(); height = img.getHeight(); } int row = (int) photoNum / columnCount; int col = photoNum - row*columnCount; int imgX = col * columnWidth + (columnWidth - width)/(int)2; int imgY = row * rowHeight + (rowHeight - height)/(int)2; Rectangle imgRect = new Rectangle( imgX, imgY, width, height ); return imgRect; } return null; } |
log.debug( "Thumbnail request submitted" ); | private void paintThumbnail( Graphics2D g2, PhotoInfo photo, int startx, int starty, boolean isSelected ) { // Current position in which attributes can be drawn int ypos = starty + rowHeight/2; if ( photo != null ) { Thumbnail thumbnail = null; if ( photo.hasThumbnail() ) { thumbnail = photo.getThumbnail(); } else { thumbnail = Thumbnail.getDefaultThumbnail(); if ( !thumbCreatorThread.isBusy() ) { thumbCreatorThread.createThumbnail( photo ); } } // 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; g2.drawImage( img, new AffineTransform( 1f, 0f, 0f, 1f, x, y ), null ); 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( "request submitted" ); | public void thumbnailCreated( PhotoInfo photo ) { repaintPhoto( photo ); Container parent = getParent(); Rectangle viewRect = null; if ( parent instanceof JViewport ) { viewRect = ((JViewport)parent).getViewRect(); } PhotoInfo nextPhoto = null; // Walk through all phoso until we find a photo that is visible // and does not have a thumbnail for ( int n = 0; n < photoCollection.getPhotoCount(); n++ ) { PhotoInfo photoCandidate = photoCollection.getPhoto( n ); if ( !photoCandidate.hasThumbnail() ) { Rectangle photoRect = getPhotoBounds( n ); if ( photoRect.intersects( viewRect ) ) { // This photo is visible so it is a perfect candidate // for thumbnail creation. Do not look further nextPhoto = photoCandidate; break; } else if ( nextPhoto == null ) { // Not visible but no photo without thumbnail has been // found previously. Store as a candidate and keep looking. nextPhoto = photoCandidate; } } } if ( nextPhoto != null && !thumbCreatorThread.isBusy() ) { final PhotoInfo p = nextPhoto;// SwingUtilities.invokeLater( new Runnable() {// public void run() { thumbCreatorThread.createThumbnail( p );// }// }); } } |
|
invokeBody(output); | ChooseTag tag = (ChooseTag) findAncestorWithClass( ChooseTag.class ); if ( tag == null ) { throw new JellyException( "This tag must be enclosed inside a <choose> tag" ); } if ( ! tag.isBlockEvaluated() ) { tag.setBlockEvaluated(true); invokeBody(output); } | public void doTag(XMLOutput output) throws Exception { invokeBody(output); } |
int numMarkers = Chromosome.getSize(); | int numMarkers = Chromosome.getFilteredSize(); | public static Vector calcCCTDT(Vector chromosomes){ Vector results = new Vector(); int numMarkers = Chromosome.getSize(); for (int i = 0; i < numMarkers; i++){ TDTResult thisResult = new TDTResult(Chromosome.getMarker(i)); for (int j = 0; j < chromosomes.size()-1; j++){ Chromosome theChrom = (Chromosome)chromosomes.get(j); j++; Chromosome nextChrom = (Chromosome)chromosomes.get(j); if (theChrom.getAffected()){ thisResult.tallyCCInd(theChrom.getGenotype(i), nextChrom.getGenotype(i), 0); }else{ thisResult.tallyCCInd(theChrom.getGenotype(i), nextChrom.getGenotype(i), 1); } } results.add(thisResult); } return results; } |
thisResult.tallyCCInd(theChrom.getGenotype(i), nextChrom.getGenotype(i), 0); | thisResult.tallyCCInd(theChrom.getFilteredGenotype(i), nextChrom.getFilteredGenotype(i), 0); | public static Vector calcCCTDT(Vector chromosomes){ Vector results = new Vector(); int numMarkers = Chromosome.getSize(); for (int i = 0; i < numMarkers; i++){ TDTResult thisResult = new TDTResult(Chromosome.getMarker(i)); for (int j = 0; j < chromosomes.size()-1; j++){ Chromosome theChrom = (Chromosome)chromosomes.get(j); j++; Chromosome nextChrom = (Chromosome)chromosomes.get(j); if (theChrom.getAffected()){ thisResult.tallyCCInd(theChrom.getGenotype(i), nextChrom.getGenotype(i), 0); }else{ thisResult.tallyCCInd(theChrom.getGenotype(i), nextChrom.getGenotype(i), 1); } } results.add(thisResult); } return results; } |
thisResult.tallyCCInd(theChrom.getGenotype(i), nextChrom.getGenotype(i), 1); | thisResult.tallyCCInd(theChrom.getFilteredGenotype(i), nextChrom.getFilteredGenotype(i), 1); | public static Vector calcCCTDT(Vector chromosomes){ Vector results = new Vector(); int numMarkers = Chromosome.getSize(); for (int i = 0; i < numMarkers; i++){ TDTResult thisResult = new TDTResult(Chromosome.getMarker(i)); for (int j = 0; j < chromosomes.size()-1; j++){ Chromosome theChrom = (Chromosome)chromosomes.get(j); j++; Chromosome nextChrom = (Chromosome)chromosomes.get(j); if (theChrom.getAffected()){ thisResult.tallyCCInd(theChrom.getGenotype(i), nextChrom.getGenotype(i), 0); }else{ thisResult.tallyCCInd(theChrom.getGenotype(i), nextChrom.getGenotype(i), 1); } } results.add(thisResult); } return results; } |
int numMarkers = Chromosome.getSize(); | int numMarkers = Chromosome.getFilteredSize(); | public static Vector calcTrioTDT(Vector chromosomes) { Vector results = new Vector(); int numMarkers = Chromosome.getSize(); for(int k=0;k<numMarkers;k++){ results.add(new TDTResult(Chromosome.getMarker(k))); } for(int i=0;i<chromosomes.size()-3;i++){ Chromosome chrom1T = (Chromosome)chromosomes.get(i); i++; Chromosome chrom1U = (Chromosome)chromosomes.get(i); i++; Chromosome chrom2T = (Chromosome)chromosomes.get(i); i++; Chromosome chrom2U = (Chromosome)chromosomes.get(i); //System.out.println("ind1T: " + chrom1T.getPed() + "\t" + chrom1T.getIndividual() ); //System.out.println("ind1U: " + chrom1U.getPed() + "\t" + chrom1U.getIndividual() ); //System.out.println("ind2T: " + chrom2T.getPed() + "\t" + chrom2T.getIndividual() ); //System.out.println("ind2U: " + chrom2U.getPed() + "\t" + chrom2U.getIndividual() ); for(int j=0;j<numMarkers;j++){ if(!chrom1T.kidMissing[j] && !chrom2T.kidMissing[j]) { byte allele1T = chrom1T.getGenotype(j); byte allele1U = chrom1U.getGenotype(j); byte allele2T = chrom2T.getGenotype(j); byte allele2U = chrom2U.getGenotype(j); if( !(allele1T == 0 || allele1U == 0 || allele2T == 0 || allele2U == 0) ){ TDTResult curRes = (TDTResult)results.get(j); curRes.tallyTrioInd(allele1T,allele1U); curRes.tallyTrioInd(allele2T,allele2U); } } } } return results; } |
byte allele1T = chrom1T.getGenotype(j); byte allele1U = chrom1U.getGenotype(j); byte allele2T = chrom2T.getGenotype(j); byte allele2U = chrom2U.getGenotype(j); | byte allele1T = chrom1T.getFilteredGenotype(j); byte allele1U = chrom1U.getFilteredGenotype(j); byte allele2T = chrom2T.getFilteredGenotype(j); byte allele2U = chrom2U.getFilteredGenotype(j); | public static Vector calcTrioTDT(Vector chromosomes) { Vector results = new Vector(); int numMarkers = Chromosome.getSize(); for(int k=0;k<numMarkers;k++){ results.add(new TDTResult(Chromosome.getMarker(k))); } for(int i=0;i<chromosomes.size()-3;i++){ Chromosome chrom1T = (Chromosome)chromosomes.get(i); i++; Chromosome chrom1U = (Chromosome)chromosomes.get(i); i++; Chromosome chrom2T = (Chromosome)chromosomes.get(i); i++; Chromosome chrom2U = (Chromosome)chromosomes.get(i); //System.out.println("ind1T: " + chrom1T.getPed() + "\t" + chrom1T.getIndividual() ); //System.out.println("ind1U: " + chrom1U.getPed() + "\t" + chrom1U.getIndividual() ); //System.out.println("ind2T: " + chrom2T.getPed() + "\t" + chrom2T.getIndividual() ); //System.out.println("ind2U: " + chrom2U.getPed() + "\t" + chrom2U.getIndividual() ); for(int j=0;j<numMarkers;j++){ if(!chrom1T.kidMissing[j] && !chrom2T.kidMissing[j]) { byte allele1T = chrom1T.getGenotype(j); byte allele1U = chrom1U.getGenotype(j); byte allele2T = chrom2T.getGenotype(j); byte allele2U = chrom2U.getGenotype(j); if( !(allele1T == 0 || allele1U == 0 || allele2T == 0 || allele2U == 0) ){ TDTResult curRes = (TDTResult)results.get(j); curRes.tallyTrioInd(allele1T,allele1U); curRes.tallyTrioInd(allele2T,allele2U); } } } } return results; } |
log.info("Adding resource and not found handlers to context:" + currContext.getContextPath()); | public void doTag(XMLOutput xmlOutput) throws Exception { // allow nested tags first, e.g body invokeBody(xmlOutput); // if no listeners create a default port listener if (_server.getListeners().length == 0) { SocketListener listener=new SocketListener(); listener.setPort(DEFAULT_PORT); listener.setHost(DEFAULT_HOST); _server.addListener(listener); } // if no context/s create a default context if (_server.getContexts().length == 0) { // Create a context HttpContext context = _server.getContext(DEFAULT_HOST, DEFAULT_CONTEXT_PATH); // Serve static content from the context URL baseResourceURL = getContext().getResource(DEFAULT_RESOURCE_BASE); Resource resource = Resource.newResource(baseResourceURL); context.setBaseResource(resource); _server.addContext(context); } // check that all the contexts have at least one handler // if not then add a default resource handler and a not found handler HttpContext[] allContexts = _server.getContexts(); for (int i = 0; i < allContexts.length; i++) { HttpContext currContext = allContexts[i]; if (currContext.getHandlers().length == 0) { currContext.addHandler(new ResourceHandler()); currContext.addHandler(new NotFoundHandler()); } } // Start the http server _server.start(); // set variable to value if required if (getVar() != null) { getContext().setVariable(getVar(), _server); } } |
|
MailProcessingRecord mailProcessingRecord = new MailProcessingRecord(); mailProcessingRecord.setReceivingQueue("smtpOutbound"); mailProcessingRecord.setTimeFetchStart(System.currentTimeMillis()); mailProcessingRecord.setByteReceivedTotal(message.getSize()); try { if (!MailMatchingUtils.isMatchCandidate(message)) return; String id = MailMatchingUtils.getMailIdHeader(message); mailProcessingRecord.setMailId(id); String[] subjectHeader = message.getHeader("Subject"); if (subjectHeader != null && subjectHeader.length > 0) { mailProcessingRecord.setSubject(subjectHeader[0]); } mailProcessingRecord.setTimeFetchEnd(System.currentTimeMillis()); } catch(MessagingException e) { log.error("error processing incoming mail: " + e.getMessage()); throw e; } finally{ MailProcessingRecord matchedAndMergedRecord = m_results.matchMailRecord(mailProcessingRecord); if (matchedAndMergedRecord == null) { if (mailProcessingRecord.getMailId() == null) mailProcessingRecord.setMailId(MailProcessingRecord.getNextId()); m_results.addNewMailRecord(mailProcessingRecord); } else { MailMatchingUtils.validateMail(message, matchedAndMergedRecord); } } | try { new SMTPMailAnalyzeStrategy("smtpOutbound", m_results, message).handle(); } catch (Exception e) { throw new MessagingException("error handling message", e); } | public void sendMail(MailAddress sender, Collection recipients, MimeMessage message) throws MessagingException { //log.info("start processing incoming mail having id = " + msg.getMessageID()); MailProcessingRecord mailProcessingRecord = new MailProcessingRecord(); mailProcessingRecord.setReceivingQueue("smtpOutbound"); mailProcessingRecord.setTimeFetchStart(System.currentTimeMillis()); mailProcessingRecord.setByteReceivedTotal(message.getSize()); try { if (!MailMatchingUtils.isMatchCandidate(message)) return; String id = MailMatchingUtils.getMailIdHeader(message); mailProcessingRecord.setMailId(id); String[] subjectHeader = message.getHeader("Subject"); if (subjectHeader != null && subjectHeader.length > 0) { mailProcessingRecord.setSubject(subjectHeader[0]); } // TODO mailProcessingRecord.setByteReceivedText(); // TODO mailProcessingRecord.setByteReceivedBinary(); mailProcessingRecord.setTimeFetchEnd(System.currentTimeMillis()); } catch(MessagingException e) { log.error("error processing incoming mail: " + e.getMessage()); throw e; // rethrow after logging } finally{ MailProcessingRecord matchedAndMergedRecord = m_results.matchMailRecord(mailProcessingRecord); if (matchedAndMergedRecord == null) { if (mailProcessingRecord.getMailId() == null) mailProcessingRecord.setMailId(MailProcessingRecord.getNextId()); m_results.addNewMailRecord(mailProcessingRecord); } else { MailMatchingUtils.validateMail(message, matchedAndMergedRecord); } } } |
Object parentObject = null; TaskSource ancestor = (TaskSource) findAncestorWithClass( TaskSource.class ); if ( ancestor != null ) { parentObject = ancestor.getTaskObject(); } | Object parentObject = findBeanAncestor(); | public void doTag(XMLOutput output) throws Exception { Project project = getAntProject(); String tagName = getTagName(); Object parentObject = null; // must be a datatype. TaskSource ancestor = (TaskSource) findAncestorWithClass( TaskSource.class ); if ( ancestor != null ) { parentObject = ancestor.getTaskObject(); } // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask if ( ! ( parentObject instanceof Task ) && project.getTaskDefinitions().containsKey( tagName ) ) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { String text = getBodyText(); Object[] args = { text }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { if ( log.isDebugEnabled() ) { log.debug( "Creating a nested object name: " + tagName ); } if ( parentObject == null ) { parentObject = findBeanAncestor(); } Object nested = createNestedObject( parentObject, tagName ); if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { ih.storeElement( project, parentObject, nested, tagName ); } catch (Exception e) { //log.warn( "Caught exception setting nested: " + tagName, e ); } } } else { // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } } |
if ( parentObject == null ) { parentObject = findBeanAncestor(); } | public void doTag(XMLOutput output) throws Exception { Project project = getAntProject(); String tagName = getTagName(); Object parentObject = null; // must be a datatype. TaskSource ancestor = (TaskSource) findAncestorWithClass( TaskSource.class ); if ( ancestor != null ) { parentObject = ancestor.getTaskObject(); } // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask if ( ! ( parentObject instanceof Task ) && project.getTaskDefinitions().containsKey( tagName ) ) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { String text = getBodyText(); Object[] args = { text }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { if ( log.isDebugEnabled() ) { log.debug( "Creating a nested object name: " + tagName ); } if ( parentObject == null ) { parentObject = findBeanAncestor(); } Object nested = createNestedObject( parentObject, tagName ); if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { ih.storeElement( project, parentObject, nested, tagName ); } catch (Exception e) { //log.warn( "Caught exception setting nested: " + tagName, e ); } } } else { // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } } |
|
log.warn( "Caught exception setting nested: " + tagName, e ); } try { BeanUtils.setProperty( parentObject, tagName, nested ); } catch (Exception e) { log.debug("Caught exception trying to set property: " + tagName + " on: " + parentObject); | public void doTag(XMLOutput output) throws Exception { Project project = getAntProject(); String tagName = getTagName(); Object parentObject = null; // must be a datatype. TaskSource ancestor = (TaskSource) findAncestorWithClass( TaskSource.class ); if ( ancestor != null ) { parentObject = ancestor.getTaskObject(); } // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask if ( ! ( parentObject instanceof Task ) && project.getTaskDefinitions().containsKey( tagName ) ) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { String text = getBodyText(); Object[] args = { text }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { if ( log.isDebugEnabled() ) { log.debug( "Creating a nested object name: " + tagName ); } if ( parentObject == null ) { parentObject = findBeanAncestor(); } Object nested = createNestedObject( parentObject, tagName ); if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { ih.storeElement( project, parentObject, nested, tagName ); } catch (Exception e) { //log.warn( "Caught exception setting nested: " + tagName, e ); } } } else { // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } } |
|
if (tag != null) { | while (tag != null) { | protected Object findBeanAncestor() throws Exception { Tag tag = getParent(); if (tag != null) { if (tag instanceof BeanSource) { BeanSource beanSource = (BeanSource) tag; return beanSource.getBean(); } } return tag; } |
return tag; | return getParent(); | protected Object findBeanAncestor() throws Exception { Tag tag = getParent(); if (tag != null) { if (tag instanceof BeanSource) { BeanSource beanSource = (BeanSource) tag; return beanSource.getBean(); } } return tag; } |
JMenuItem newWindowItem = new JMenuItem( "New window", KeyEvent.VK_N ); newWindowItem.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { BrowserWindow br = new BrowserWindow(); br.setVisible( true ); } }); fileMenu.add( newWindowItem ); | protected void createUI() { tabPane = new JTabbedPane(); queryPane = new QueryPane(); treePane = new PhotoFolderTree(); tabPane.addTab( "Query", queryPane ); tabPane.addTab( "Folders", treePane ); // viewPane = new TableCollectionView(); viewPane = new PhotoCollectionThumbView(); viewPane.setCollection( queryPane.getResultCollection() ); // Set listeners to both query and folder tree panes /* If an actionEvent comes from queryPane & the viewed folder is no the query resouts, swich to it (the result folder will be nodified of changes to quert parameters directly */ queryPane.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { if ( viewPane.getCollection() != queryPane.getResultCollection() ) { viewPane.setCollection( queryPane.getResultCollection() ); } } } ); /* If the selected folder is changed in treePane, switch to that immediately */ treePane.addPhotoFolderTreeListener( new PhotoFolderTreeListener() { public void photoFolderTreeSelectionChanged( PhotoFolderTreeEvent e ) { PhotoFolder f = e.getSelected(); if ( f != null ) { viewPane.setCollection( f ); } } } ); // Create the split pane to display both of these components JScrollPane viewScroll = new JScrollPane( viewPane ); JSplitPane split = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, tabPane, viewScroll ); Container cp = getContentPane(); cp.setLayout( new BorderLayout() ); cp.add( split, BorderLayout.CENTER ); // Create the menu bar & menus JMenuBar menuBar = new JMenuBar(); setJMenuBar( menuBar ); JMenu fileMenu = new JMenu( "File" ); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add( fileMenu ); JMenuItem importItem = new JMenuItem( "Import image...", KeyEvent.VK_I ); importItem.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { importFile(); } }); fileMenu.add( importItem ); JMenuItem exitItem = new JMenuItem( "Exit", KeyEvent.VK_X ); exitItem.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { System.exit( 0 ); } }); fileMenu.add( exitItem ); pack(); } |
|
importFile(); | BrowserWindow br = new BrowserWindow(); br.setVisible( true ); | public void actionPerformed( ActionEvent e ) { importFile(); } |
System.exit( 0 ); | importFile(); | public void actionPerformed( ActionEvent e ) { System.exit( 0 ); } |
log.warn("Could not load class: " + uri + " so disabling the taglib", e); | throw createSAXException("Could not load class: " + uri + " so taglib instantiation failed", e); | protected TagScript createTag( String namespaceURI, String localName, Attributes list) throws SAXException { try { // use the URI to load a taglib TagLibrary taglib = context.getTagLibrary(namespaceURI); if (taglib == null) { if (namespaceURI != null && namespaceURI.startsWith("jelly:")) { String uri = namespaceURI.substring(6); // try to find the class on the claspath try { Class taglibClass = getClassLoader().loadClass(uri); taglib = (TagLibrary) taglibClass.newInstance(); context.registerTagLibrary(namespaceURI, taglib); } catch (ClassNotFoundException e) { log.warn("Could not load class: " + uri + " so disabling the taglib", e); } catch (IllegalAccessException e) { log.warn("Constructor for class is not accessible: " + uri + " so disabling the taglib", e); } catch (InstantiationException e) { log.warn("Class could not be instantiated: " + uri + " so disabling the taglib", e); } catch (ClassCastException e) { log.warn("Class is not a TagLibrary: " + uri + " so disabling the taglib", e); } } } if (taglib != null) { TagScript script = taglib.createTagScript(localName, list); if ( script != null ) { configureTagScript(script); // clone the attributes to keep them around after this parse script.setSaxAttributes(new AttributesImpl(list)); // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeName = list.getLocalName(i); String attributeValue = list.getValue(i); Expression expression = taglib.createExpression( getExpressionFactory(), script, attributeName, attributeValue); if (expression == null) { expression = createConstantExpression(localName, attributeName, attributeValue); } script.addAttribute(attributeName, expression); } } return script; } return null; } catch (Exception e) { log.warn( "Could not create taglib or URI: " + namespaceURI + " tag name: " + localName, e); throw createSAXException(e); } } |
log.warn("Constructor for class is not accessible: " + uri + " so disabling the taglib", e); | throw createSAXException("Constructor for class is not accessible: " + uri + " so taglib instantiation failed",e); | protected TagScript createTag( String namespaceURI, String localName, Attributes list) throws SAXException { try { // use the URI to load a taglib TagLibrary taglib = context.getTagLibrary(namespaceURI); if (taglib == null) { if (namespaceURI != null && namespaceURI.startsWith("jelly:")) { String uri = namespaceURI.substring(6); // try to find the class on the claspath try { Class taglibClass = getClassLoader().loadClass(uri); taglib = (TagLibrary) taglibClass.newInstance(); context.registerTagLibrary(namespaceURI, taglib); } catch (ClassNotFoundException e) { log.warn("Could not load class: " + uri + " so disabling the taglib", e); } catch (IllegalAccessException e) { log.warn("Constructor for class is not accessible: " + uri + " so disabling the taglib", e); } catch (InstantiationException e) { log.warn("Class could not be instantiated: " + uri + " so disabling the taglib", e); } catch (ClassCastException e) { log.warn("Class is not a TagLibrary: " + uri + " so disabling the taglib", e); } } } if (taglib != null) { TagScript script = taglib.createTagScript(localName, list); if ( script != null ) { configureTagScript(script); // clone the attributes to keep them around after this parse script.setSaxAttributes(new AttributesImpl(list)); // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeName = list.getLocalName(i); String attributeValue = list.getValue(i); Expression expression = taglib.createExpression( getExpressionFactory(), script, attributeName, attributeValue); if (expression == null) { expression = createConstantExpression(localName, attributeName, attributeValue); } script.addAttribute(attributeName, expression); } } return script; } return null; } catch (Exception e) { log.warn( "Could not create taglib or URI: " + namespaceURI + " tag name: " + localName, e); throw createSAXException(e); } } |
log.warn("Class could not be instantiated: " + uri + " so disabling the taglib", e); | throw createSAXException("Class could not be instantiated: " + uri + " so taglib instantiation failed",e); | protected TagScript createTag( String namespaceURI, String localName, Attributes list) throws SAXException { try { // use the URI to load a taglib TagLibrary taglib = context.getTagLibrary(namespaceURI); if (taglib == null) { if (namespaceURI != null && namespaceURI.startsWith("jelly:")) { String uri = namespaceURI.substring(6); // try to find the class on the claspath try { Class taglibClass = getClassLoader().loadClass(uri); taglib = (TagLibrary) taglibClass.newInstance(); context.registerTagLibrary(namespaceURI, taglib); } catch (ClassNotFoundException e) { log.warn("Could not load class: " + uri + " so disabling the taglib", e); } catch (IllegalAccessException e) { log.warn("Constructor for class is not accessible: " + uri + " so disabling the taglib", e); } catch (InstantiationException e) { log.warn("Class could not be instantiated: " + uri + " so disabling the taglib", e); } catch (ClassCastException e) { log.warn("Class is not a TagLibrary: " + uri + " so disabling the taglib", e); } } } if (taglib != null) { TagScript script = taglib.createTagScript(localName, list); if ( script != null ) { configureTagScript(script); // clone the attributes to keep them around after this parse script.setSaxAttributes(new AttributesImpl(list)); // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeName = list.getLocalName(i); String attributeValue = list.getValue(i); Expression expression = taglib.createExpression( getExpressionFactory(), script, attributeName, attributeValue); if (expression == null) { expression = createConstantExpression(localName, attributeName, attributeValue); } script.addAttribute(attributeName, expression); } } return script; } return null; } catch (Exception e) { log.warn( "Could not create taglib or URI: " + namespaceURI + " tag name: " + localName, e); throw createSAXException(e); } } |
log.warn("Class is not a TagLibrary: " + uri + " so disabling the taglib", e); | throw createSAXException("Class is not a TagLibrary: " + uri + " so taglib instantiation failed",e); | protected TagScript createTag( String namespaceURI, String localName, Attributes list) throws SAXException { try { // use the URI to load a taglib TagLibrary taglib = context.getTagLibrary(namespaceURI); if (taglib == null) { if (namespaceURI != null && namespaceURI.startsWith("jelly:")) { String uri = namespaceURI.substring(6); // try to find the class on the claspath try { Class taglibClass = getClassLoader().loadClass(uri); taglib = (TagLibrary) taglibClass.newInstance(); context.registerTagLibrary(namespaceURI, taglib); } catch (ClassNotFoundException e) { log.warn("Could not load class: " + uri + " so disabling the taglib", e); } catch (IllegalAccessException e) { log.warn("Constructor for class is not accessible: " + uri + " so disabling the taglib", e); } catch (InstantiationException e) { log.warn("Class could not be instantiated: " + uri + " so disabling the taglib", e); } catch (ClassCastException e) { log.warn("Class is not a TagLibrary: " + uri + " so disabling the taglib", e); } } } if (taglib != null) { TagScript script = taglib.createTagScript(localName, list); if ( script != null ) { configureTagScript(script); // clone the attributes to keep them around after this parse script.setSaxAttributes(new AttributesImpl(list)); // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeName = list.getLocalName(i); String attributeValue = list.getValue(i); Expression expression = taglib.createExpression( getExpressionFactory(), script, attributeName, attributeValue); if (expression == null) { expression = createConstantExpression(localName, attributeName, attributeValue); } script.addAttribute(attributeName, expression); } } return script; } return null; } catch (Exception e) { log.warn( "Could not create taglib or URI: " + namespaceURI + " tag name: " + localName, e); throw createSAXException(e); } } |
public AntTag(Project project, String tagName) { this.project = project; | public AntTag(String tagName) { | public AntTag(Project project, String tagName) { this.project = project; this.tagName = tagName; } |
dataType = (DataType) ctor.newInstance(new Object[] {project}); | dataType = (DataType) ctor.newInstance(new Object[] { getAntProject() }); | public Object createDataType(String name) throws Exception { Object dataType = null; Class type = (Class) getAntProject().getDataTypeDefinitions().get(name); if ( type != null ) { try { Constructor ctor = null; boolean noArg = false; // DataType can have a "no arg" constructor or take a single // Project argument. try { ctor = type.getConstructor(new Class[0]); noArg = true; } catch (NoSuchMethodException nse) { ctor = type.getConstructor(new Class[] { Project.class }); noArg = false; } if (noArg) { dataType = (DataType) ctor.newInstance(new Object[0]); } else { dataType = (DataType) ctor.newInstance(new Object[] {project}); } ((DataType)dataType).setProject( project ); } catch (Throwable t) { // ignore log.error(t); } } return dataType; } |
((DataType)dataType).setProject( project ); | ((DataType)dataType).setProject( getAntProject() ); | public Object createDataType(String name) throws Exception { Object dataType = null; Class type = (Class) getAntProject().getDataTypeDefinitions().get(name); if ( type != null ) { try { Constructor ctor = null; boolean noArg = false; // DataType can have a "no arg" constructor or take a single // Project argument. try { ctor = type.getConstructor(new Class[0]); noArg = true; } catch (NoSuchMethodException nse) { ctor = type.getConstructor(new Class[] { Project.class }); noArg = false; } if (noArg) { dataType = (DataType) ctor.newInstance(new Object[0]); } else { dataType = (DataType) ctor.newInstance(new Object[] {project}); } ((DataType)dataType).setProject( project ); } catch (Throwable t) { // ignore log.error(t); } } return dataType; } |
return this.project; | return AntTagLibrary.getProject(context); | public Project getAntProject() { return this.project; } |
if (caller.hapDisplay != null){ caller.hapDisplay.setVisible(false); } | public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command==RAW_DATA){ load(PED); }else if (command == PHASED_DATA){ load(HAPS); }else if (command == HAPMAP_DATA){ load(HMP); }else if (command == BROWSE_GENO){ browse(GENO); }else if (command == BROWSE_INFO){ browse(INFO); }else if (command == "OK"){ HaploView caller = (HaploView)this.getParent(); if (doTDT.isSelected()){ if (trioButton.isSelected()){ caller.assocTest = 1; } else { caller.assocTest = 2; } }else{ caller.assocTest = 0; } String[] returnStrings = {genoFileField.getText(), infoFileField.getText(), maxComparisonDistField.getText()}; caller.readGenotypes(returnStrings, fileType); if (caller.dPrimeDisplay != null){ caller.dPrimeDisplay.setVisible(false); } this.dispose(); }else if (command == "Cancel"){ this.dispose(); }else if (command == "tdt"){ if(this.doTDT.isSelected()){ trioButton.setEnabled(true); ccButton.setEnabled(true); }else{ trioButton.setEnabled(false); ccButton.setEnabled(false); } } } |
|
getBody().run(context, output); | invokeBody(output); | public void doTag(XMLOutput output) throws Exception { getBody().run(context, output); } |
log.debug( "registering volume " + volumeName + ", basedir " + volumeBaseDir ); | private void registerVolume() { if ( volumes == null ) { volumes = new HashMap(); } volumes.put( volumeName, this ); } |
|
log.debug( "New basedir for " + volumeName + ": " + baseDir ); | public void setBaseDir( File baseDir ) { volumeBaseDir = baseDir; if ( !volumeBaseDir.exists() ) { volumeBaseDir.mkdir(); } } |
|
logger.debug("getTransferData returns '"+data.getName()+"'"+data.getClass().getName()+"@"+data.hashCode()); | public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { if (flavor != this.flavor) { throw new IllegalArgumentException("Unsupported flavor "+flavor); } return data; } |
|
request.setAttribute(RequestAttributes.USERS, users); | Map orderedUsers = new TreeMap(users); request.setAttribute(RequestAttributes.USERS, orderedUsers); | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { Map users = UserManager.getInstance().getAllUsers(); request.setAttribute(RequestAttributes.USERS, users); return mapping.findForward(Forwards.SUCCESS); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.