From: Jonathan C. <jcr...@us...> - 2007-02-09 01:37:49
|
Update of /cvsroot/gmod/apollo/src/java/apollo/dataadapter/chado/jdbc In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv29541 Modified Files: JdbcChadoAdapter.java Log Message: This should have been committed earlier (sorry). It's been modified to take the new cv/cvterm configuration parameters into account, and to account for the fact that the featureprop.rank column is NOT nullable. Index: JdbcChadoAdapter.java =================================================================== RCS file: /cvsroot/gmod/apollo/src/java/apollo/dataadapter/chado/jdbc/JdbcChadoAdapter.java,v retrieving revision 1.169 retrieving revision 1.170 diff -C2 -d -r1.169 -r1.170 *** JdbcChadoAdapter.java 7 Feb 2007 21:14:14 -0000 1.169 --- JdbcChadoAdapter.java 9 Feb 2007 01:37:47 -0000 1.170 *************** *** 914,918 **** --- 914,951 ---- return (Long)(this.propertyTypeCvTerms.get(name)); } + + // ------------------------------------- + // Retrieve an arbitrary cvterm + // ------------------------------------- + // TODO - cache these results also + Long getCVTermId(String cvName, String cvTermName) { + Long result = null; + String cvNameCol = chadoVersion.getCvNameCol(); + + String sql = "SELECT cvt.cvterm_id " + + "FROM cvterm cvt, cv c " + + "WHERE c.cv_id = cvt.cv_id " + + "AND c." + cvNameCol + "='" + cvName + "' " + + "AND cvt.name = '" + cvTermName + "' "; + + try { + ResultSet rs = executeLoggedSelectQuery("getCVTermId", sql); + if (rs.next()) { + result = new Long(rs.getLong("cvterm_id")); + } else { + logger.warn("no cvterm_id found for cvterm '" + cvTermName + "' in CV '" + cvName + "'"); + } + if (rs.next()) { + logger.error("multiple cvterm_ids found for cvterm '" + cvTermName + "' in CV '" + cvName + "'"); + } + } + catch (SQLException sqle) { + logger.error("SQLException retrieving cvterms with cvname = " + cvTermName, sqle); + } + + return result; + } + // ------------------ // Organism map/cache *************** *** 1491,1494 **** --- 1524,1531 ---- "FROM featureprop fp, cvterm "+ "WHERE fp.feature_id = "+feature_id+" AND fp.type_id = cvterm.cvterm_id"; + + String ownerTerm = chadoInstance.getFeatureOwnerPropertyTerm(); + String altDescrTerm = chadoInstance.getSeqDescriptionTerm(); + try { ResultSet rs = executeLoggedSelectQuery("addAnnotationFeatProps", sql); *************** *** 1496,1500 **** String type = rs.getString("name"); String value = rs.getString("value"); ! if (type.equals("owner")) // only makes sense for transcripts annot.setOwner(value); // "non-canonical_splice_site"?? Transcript ->AnnotatedFeat --- 1533,1537 ---- String type = rs.getString("name"); String value = rs.getString("value"); ! if (type.equals(ownerTerm)) // only makes sense for transcripts annot.setOwner(value); // "non-canonical_splice_site"?? Transcript ->AnnotatedFeat *************** *** 1508,1511 **** --- 1545,1550 ---- else if (type.equals("description")) annot.setDescription(value); + else if (type.equals(altDescrTerm)) + annot.setDescription(value); else annot.addProperty(type,value); *************** *** 1640,1644 **** boolean getTargetSeqsSeparately, boolean lazyTgtSeqs, boolean getTargetSeqDescriptions, - String targetSeqDescriptionCVTerm, boolean joinWithFeatureProp, SequenceI refSeq, StrandedFeatureSet sfs, String scoreColumn, --- 1679,1682 ---- *************** *** 1704,1708 **** tgtDescField = "tgtDescription"; //tgtDescSelect = "tgt_fp.value as "+tgtDescField+", "; ! Long descriptionTypeId = getPropertyTypeCVTermId(targetSeqDescriptionCVTerm); //tgtDescOuterJoin = "LEFT OUTER JOIN featureprop tgt_fp ON "+ //"(tgtFeat.feature_id = tgt_fp.feature_id " --- 1742,1750 ---- tgtDescField = "tgtDescription"; //tgtDescSelect = "tgt_fp.value as "+tgtDescField+", "; ! ! String seqDescrCv = chadoInstance.getSeqDescriptionCVName(); ! String seqDescrTerm = chadoInstance.getSeqDescriptionTerm(); ! Long descriptionTypeId = getCVTermId(seqDescrCv, seqDescrTerm); ! //tgtDescOuterJoin = "LEFT OUTER JOIN featureprop tgt_fp ON "+ //"(tgtFeat.feature_id = tgt_fp.feature_id " *************** *** 3926,3930 **** } ! public Long insertFeaturepropRow(Long featureId, Long typeId, String value, Long rank) { String tableName = "featureprop"; --- 3968,3972 ---- } ! public Long insertFeaturepropRow(Long featureId, Long typeId, String value, long rank) { String tableName = "featureprop"; *************** *** 3939,3946 **** colValues.put("feature_id", featureId); colValues.put("type_id", typeId); ! // NULLable columns - if (rank != null) { colValues.put("rank", rank); } if (value != null) { colValues.put("value", value); } --- 3981,3987 ---- colValues.put("feature_id", featureId); colValues.put("type_id", typeId); ! colValues.put("rank", new Long(rank)); // NULLable columns if (value != null) { colValues.put("value", value); } |