From: <rv...@us...> - 2009-06-18 09:38:55
|
Revision: 58 http://treebase.svn.sourceforge.net/treebase/?rev=58&view=rev Author: rvos Date: 2009-06-18 09:38:54 +0000 (Thu, 18 Jun 2009) Log Message: ----------- Added getters/setters for NeXML objects Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/ContinuousMatrixJDBC.java trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/DiscreteMatrixJDBC.java trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/MatrixJDBC.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/ContinuousMatrixJDBC.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/ContinuousMatrixJDBC.java 2009-06-18 09:34:25 UTC (rev 57) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/ContinuousMatrixJDBC.java 2009-06-18 09:38:54 UTC (rev 58) @@ -39,6 +39,7 @@ import org.cipres.treebase.domain.matrix.ContinuousMatrix; import org.cipres.treebase.domain.matrix.ItemDefinition; import org.cipres.treebase.domain.nexus.mesquite.MesquiteMatrixConverter; +import org.cipres.treebase.domain.nexus.nexml.NexmlMatrixConverter; /** * Helper class for direct Matrix related SQL operations. Bypass the hibernate framework for high @@ -83,6 +84,10 @@ private Map<String, Long> mItemDefNameToIDMap; + private org.nexml.model.ContinuousMatrix mNexmlCharacterData; + + private NexmlMatrixConverter mNexmlMatrixConverter; + // Note: currently we support only one set of item definitions for the entire matrix. // It is modeled in continuousMatrix.itemDefinitions. // The matrixColumn.itemDefinitions are not supported at this time since Mesquite (and Nexus) @@ -117,6 +122,15 @@ } + public ContinuousMatrixJDBC(ContinuousMatrix tbMatrix, + org.nexml.model.ContinuousMatrix xmlMatrix, + NexmlMatrixConverter nexmlMatrixConverter) { + this(); + setCharacterMatrix(tbMatrix); + setNexmlCharacterData(xmlMatrix); + setNexmlMatrixConverter(nexmlMatrixConverter); + } + // /** // * Return the ItemDefJDBCs field. // * Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/DiscreteMatrixJDBC.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/DiscreteMatrixJDBC.java 2009-06-18 09:34:25 UTC (rev 57) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/DiscreteMatrixJDBC.java 2009-06-18 09:38:54 UTC (rev 58) @@ -38,9 +38,11 @@ import org.springframework.jdbc.UncategorizedSQLException; import org.cipres.treebase.domain.matrix.CharacterMatrix; +import org.cipres.treebase.domain.matrix.ContinuousMatrix; import org.cipres.treebase.domain.matrix.DiscreteChar; import org.cipres.treebase.domain.matrix.DiscreteCharState; import org.cipres.treebase.domain.nexus.mesquite.MesquiteMatrixConverter; +import org.cipres.treebase.domain.nexus.nexml.NexmlMatrixConverter; /** * Helper class for direct Matrix related SQL operations. Bypass the hibernate framework for high @@ -121,6 +123,15 @@ mRowSymbolBufs.add(new StringBuffer()); } } + + public DiscreteMatrixJDBC(CharacterMatrix tbMatrix, + org.nexml.model.CategoricalMatrix xmlMatrix, + NexmlMatrixConverter nexmlMatrixConverter) { + this(); + setCharacterMatrix(tbMatrix); + setNexmlCharacterData(xmlMatrix); + setNexmlMatrixConverter(nexmlMatrixConverter); + } /** * Return the RowSymbolBufs field. Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/MatrixJDBC.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/MatrixJDBC.java 2009-06-18 09:34:25 UTC (rev 57) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/MatrixJDBC.java 2009-06-18 09:38:54 UTC (rev 58) @@ -32,11 +32,13 @@ import org.apache.log4j.Logger; import org.hibernate.Query; import org.hibernate.Session; +import org.nexml.model.Matrix; import org.springframework.jdbc.UncategorizedSQLException; import org.cipres.treebase.domain.matrix.CharacterMatrix; import org.cipres.treebase.domain.matrix.ContinuousMatrix; import org.cipres.treebase.domain.nexus.mesquite.MesquiteMatrixConverter; +import org.cipres.treebase.domain.nexus.nexml.NexmlMatrixConverter; /** * Helper class for direct Matrix related SQL operations. Bypass the hibernate framework for high @@ -86,6 +88,8 @@ private List<MatrixColumnJDBC> mMatrixColumnJDBCs; private MesquiteMatrixConverter mMesqMatrixConverter; + private NexmlMatrixConverter mNexmlMatrixConverter; + private Matrix mNexmlCharacterData; /** * Factory methods for creating a new MatrixJDBC instance based on the CharacterMatrix type. @@ -287,6 +291,16 @@ mMesquiteCharacterData = pNewMesquiteCharacterData; } + protected void setNexmlMatrixConverter( + NexmlMatrixConverter nexmlMatrixConverter) { + mNexmlMatrixConverter = nexmlMatrixConverter; + } + + protected void setNexmlCharacterData( + org.nexml.model.Matrix xmlMatrix) { + mNexmlCharacterData = xmlMatrix; + } + /** * Return the discriminator value for the sub classes in MatrixElement class hierarchy. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yo...@us...> - 2010-02-02 20:54:54
|
Revision: 481 http://treebase.svn.sourceforge.net/treebase/?rev=481&view=rev Author: youjun Date: 2010-02-02 20:54:48 +0000 (Tue, 02 Feb 2010) Log Message: ----------- fix sql, postgresql will not accept 1,0 for boolean type Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/ContinuousMatrixElementJDBC.java trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/DiscreteMatrixElementJDBC.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/ContinuousMatrixElementJDBC.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/ContinuousMatrixElementJDBC.java 2010-01-25 20:27:40 UTC (rev 480) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/ContinuousMatrixElementJDBC.java 2010-02-02 20:54:48 UTC (rev 481) @@ -83,7 +83,7 @@ // DISCRETECHARSTATE_ID ps.setDouble(1, e.getValue()); // Value - ps.setShort(2, e.getGap()); // Gap + ps.setBoolean(2, e.getGap()); // Gap ps.setLong(3, e.getMatrixColID()); // MATRIXCOLUMN_ID // ps.setLong(4, 0); // ITEMDEFINITION_ID //Only by compound elements. ps.setLong(4, e.getMatrixRowID()); // MATRIXROW_ID @@ -125,8 +125,8 @@ * * @return short mGap */ - public short getGap() { - return mGap; + public boolean getGap() { + return (mGap!=0); } /** Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/DiscreteMatrixElementJDBC.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/DiscreteMatrixElementJDBC.java 2010-01-25 20:27:40 UTC (rev 480) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/DiscreteMatrixElementJDBC.java 2010-02-02 20:54:48 UTC (rev 481) @@ -93,7 +93,7 @@ // Value: (continuous) // ITEMDEFINITION_ID: (continuous) - ps.setShort(1, e.getGap()); // Gap + ps.setBoolean(1, e.getGap()); // Gap ps.setLong(2, e.getMatrixColID()); // MATRIXCOLUMN_ID ps.setLong(3, e.getMatrixRowID()); // MATRIXROW_ID @@ -138,8 +138,8 @@ * * @return short mGap */ - public short getGap() { - return mGap; + public boolean getGap() { + return (mGap!=0); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vga...@us...> - 2010-02-11 16:35:36
|
Revision: 491 http://treebase.svn.sourceforge.net/treebase/?rev=491&view=rev Author: vgapeyev Date: 2010-02-11 16:35:29 +0000 (Thu, 11 Feb 2010) Log Message: ----------- Modifying DB2-specific SQL to work under Pg Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/ContinuousMatrixJDBC.java trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/DiscreteMatrixJDBC.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/ContinuousMatrixJDBC.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/ContinuousMatrixJDBC.java 2010-02-11 06:51:56 UTC (rev 490) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/ContinuousMatrixJDBC.java 2010-02-11 16:35:29 UTC (rev 491) @@ -165,8 +165,10 @@ // insert new phylochar. // Note: this is db2 specific code (faster), see EnvrionmentTest.testGetGeneratedKey() // for generic jdbc code. - String queryBuf = "select phylochar_id from final table(INSERT INTO PHYLOCHAR(TYPE, PHYLOCHAR_ID, VERSION, DESCRIPTION, LOWERLIMIT, UPPERLIMIT) VALUES('N', default, 0, ?, ?, ?))"; - + //--String queryBuf = "select phylochar_id from final table(INSERT INTO PHYLOCHAR(TYPE, PHYLOCHAR_ID, VERSION, DESCRIPTION, LOWERLIMIT, UPPERLIMIT) VALUES('N', default, 0, ?, ?, ?))"; + //VG 2010-02-10 Replacing above DB2 sql with this PostreSQL: + String queryBuf = "INSERT INTO PHYLOCHAR(TYPE, PHYLOCHAR_ID, VERSION, DESCRIPTION, LOWERLIMIT, UPPERLIMIT) VALUES('N', default, 0, ?, ?, ?) returning phylochar_id"; + PreparedStatement ps = pCon.prepareStatement(queryBuf); for (MatrixColumnJDBC columnJDBC : columns) { Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/DiscreteMatrixJDBC.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/DiscreteMatrixJDBC.java 2010-02-11 06:51:56 UTC (rev 490) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/dao/jdbc/DiscreteMatrixJDBC.java 2010-02-11 16:35:29 UTC (rev 491) @@ -334,8 +334,10 @@ try { // insert new discrete phylochar. //Note: this is db2 specific code (faster), see EnvrionmentTest.testGetGeneratedKey() for generic jdbc code. - String queryBuf = "select phylochar_id from final table(INSERT INTO PHYLOCHAR(TYPE, PHYLOCHAR_ID, VERSION, DESCRIPTION) VALUES('D', default, 0, ?))"; - + //VG-- String queryBuf = "select phylochar_id from final table(INSERT INTO PHYLOCHAR(TYPE, PHYLOCHAR_ID, VERSION, DESCRIPTION) VALUES('D', default, 0, ?))"; + //VG 2010-02-10 Replacing above DB2 sql with this PostreSQL: + String queryBuf = "INSERT INTO PHYLOCHAR(TYPE, PHYLOCHAR_ID, VERSION, DESCRIPTION) VALUES('D', default, 0, ?) RETURNING phylochar_id"; + PreparedStatement ps = pCon.prepareStatement(queryBuf); // String stateStr = "INSERT INTO DISCRETECHARSTATE(DISCRETECHARSTATE_ID, VERSION, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |