diff --git a/artemis_sqlmap/Feature.xml b/artemis_sqlmap/Feature.xml index 97d468b53a93279549891eea4cac6f0cff5503c0..aef073ca6252daa25c5bd577657da64e7055392e 100644 --- a/artemis_sqlmap/Feature.xml +++ b/artemis_sqlmap/Feature.xml @@ -7,12 +7,12 @@ <sqlMap namespace="Feature"> - <parameterMap id="schema-cvlist" class="uk.ac.sanger.ibatis.SchemaCVList"> + <parameterMap id="schema-cvlist" class="uk.ac.sanger.artemis.chado.SchemaCVList"> <parameter property="schema" javaType="java.lang.String"/> <parameter property="cvlist" javaType="java.util.List"/> </parameterMap> - <resultMap id="select-feature-properties-result" class="uk.ac.sanger.ibatis.Feature"> + <resultMap id="select-feature-properties-result" class="uk.ac.sanger.artemis.chado.ChadoFeature"> <result property="timelastmodified" column="timelastmodified"/> <result property="id" column="id"/> <result property="object_id" column="object_id"/> @@ -26,7 +26,7 @@ <result property="phase" column="phase" nullValue="10"/> </resultMap> - <resultMap id="select-feature-result" class="uk.ac.sanger.ibatis.Feature"> + <resultMap id="select-feature-result" class="uk.ac.sanger.artemis.chado.ChadoFeature"> <result property="id" column="id"/> <result property="uniquename" column="uniquename"/> <result property="name" column="name"/> @@ -38,12 +38,12 @@ <result property="strand" column="strand" nullValue="0" /> </resultMap> - <resultMap id="select-feature-sequence-result" class="uk.ac.sanger.ibatis.Feature"> + <resultMap id="select-feature-sequence-result" class="uk.ac.sanger.artemis.chado.ChadoFeature"> <result property="name" column="name"/> <result property="residues" column="residues"/> </resultMap> - <resultMap id="select-feature-with-residues-result" class="uk.ac.sanger.ibatis.Feature"> + <resultMap id="select-feature-with-residues-result" class="uk.ac.sanger.artemis.chado.ChadoFeature"> <result property="abbreviation" column="abbreviation"/> <result property="name" column="name"/> <result property="id" column="feature_id"/> @@ -52,7 +52,7 @@ <!-- get feature name --> - <select id="getFeatureName" parameterClass="uk.ac.sanger.ibatis.Feature" + <select id="getFeatureName" parameterClass="uk.ac.sanger.artemis.chado.ChadoFeature" resultClass="java.lang.String"> SELECT name @@ -68,7 +68,7 @@ </iterate> </select> - <select id="getGffLine" parameterClass="uk.ac.sanger.ibatis.Feature" + <select id="getGffLine" parameterClass="uk.ac.sanger.artemis.chado.ChadoFeature" resultMap="select-feature-properties-result"> SELECT timelastmodified, @@ -99,7 +99,7 @@ ORDER BY f.type_id, uniquename </select> - <select id="getSequence" parameterClass="uk.ac.sanger.ibatis.Feature" + <select id="getSequence" parameterClass="uk.ac.sanger.artemis.chado.ChadoFeature" resultMap="select-feature-sequence-result"> SELECT name, @@ -136,7 +136,7 @@ ORDER BY abbreviation </select> - <select id="getFeature" resultMap ="select-feature-result" parameterClass="uk.ac.sanger.ibatis.Feature"> + <select id="getFeature" resultMap ="select-feature-result" parameterClass="uk.ac.sanger.artemis.chado.ChadoFeature"> SELECT $schema$.feature.feature_id AS id, uniquename, diff --git a/uk/ac/sanger/artemis/chado/ChadoDAO.java b/uk/ac/sanger/artemis/chado/ChadoDAO.java index 560840a542e7e73045f93e3deded2fba53d7973b..9d20a6ca42ecba82413aa5b440a1c336adb8d5c2 100644 --- a/uk/ac/sanger/artemis/chado/ChadoDAO.java +++ b/uk/ac/sanger/artemis/chado/ChadoDAO.java @@ -38,8 +38,8 @@ public interface ChadoDAO * @param schema schema/organism name or null * */ - public Feature getSequence(final int feature_id, - final String schema) + public ChadoFeature getSequence(final int feature_id, + final String schema) throws SQLException; /** @@ -91,7 +91,7 @@ public interface ChadoDAO /** * - * Get available schemas (as a List of Feature objects). + * Get available schemas (as a List of ChadoFeature objects). * */ public List getSchema() diff --git a/uk/ac/sanger/artemis/chado/Feature.java b/uk/ac/sanger/artemis/chado/ChadoFeature.java similarity index 99% rename from uk/ac/sanger/artemis/chado/Feature.java rename to uk/ac/sanger/artemis/chado/ChadoFeature.java index 7127d5b8d2136da41caade1c9dd72226e475d55d..e4bbee52ed64ee72064aaa03ecfec7155a525634 100644 --- a/uk/ac/sanger/artemis/chado/Feature.java +++ b/uk/ac/sanger/artemis/chado/ChadoFeature.java @@ -1,4 +1,4 @@ -/* Feature.java +/* ChadoFeature.java * * created: 2005 * @@ -29,7 +29,7 @@ import java.util.Date; import java.util.Hashtable; import java.util.Vector; -public class Feature +public class ChadoFeature { /** schema */ diff --git a/uk/ac/sanger/artemis/chado/ChadoTransaction.java b/uk/ac/sanger/artemis/chado/ChadoTransaction.java index fe8ba3f72d3ae6f3cd426f357df16f565c2fc33f..460e1ccd0d083feec01da1097d980531803225c7 100644 --- a/uk/ac/sanger/artemis/chado/ChadoTransaction.java +++ b/uk/ac/sanger/artemis/chado/ChadoTransaction.java @@ -35,12 +35,19 @@ import java.util.StringTokenizer; **/ public class ChadoTransaction { + // + // ATTRIBUTE TRANSACTIONS /** update statement */ public static final int UPDATE = 1; /** insert statement */ public static final int INSERT = 2; /** delete statement */ public static final int DELETE = 3; + + // FEATURE TRANSACTIONS + /** insert feature statement */ + public static final int INSERT_FEATURE = 4; + /** properties store */ private List properties; /** old properties store */ @@ -71,6 +78,17 @@ public class ChadoTransaction this.chadoTable = chadoTable; } + /** + * + * @param type transaction type + * @param uniquename uniquename of feature + * + */ + public ChadoTransaction(int type, ChadoFeature new_feature) + { + this.type = type; + } + /** * * @@ -144,7 +162,7 @@ public class ChadoTransaction { if(constraint == null) constraint = new Vector(); - constraint.add(name+"="+"\'"+value+"\'"); + constraint.add(name+"="+value); } @@ -183,7 +201,6 @@ public class ChadoTransaction return propertiesName; } - /** * * Get properties to this transaction that will be changed. @@ -214,7 +231,6 @@ public class ChadoTransaction return constraint; } - /** * * Get uniquenames of features. @@ -230,21 +246,26 @@ public class ChadoTransaction } return names; -// String str_names[] = new String[names.size()]; -// for(int i=0; i<str_names.length; i++) -// str_names[i] = (String)names.get(i); -// return str_names; } + /** + * + * Set the feature id + * + */ public void setFeature_id(final int feature_id) { this.feature_id = feature_id; } + /** + * + * Get the feature id + * + */ public int getFeature_id() { return feature_id; } - } diff --git a/uk/ac/sanger/artemis/chado/ChadoTransactionManager.java b/uk/ac/sanger/artemis/chado/ChadoTransactionManager.java index f8c6af39fb914557450dfe9dd3c7a52e82493747..a22fcf159a9a37eb2b82f1c7b78f5806dde27d98 100644 --- a/uk/ac/sanger/artemis/chado/ChadoTransactionManager.java +++ b/uk/ac/sanger/artemis/chado/ChadoTransactionManager.java @@ -146,7 +146,7 @@ public class ChadoTransactionManager { feature_uniquename = JOptionPane.showInputDialog(null, "Provide a systematic_id : ", - "systematic_id missing "+ + "systematic_id missing in "+ feature.getIDString(), JOptionPane.QUESTION_MESSAGE).trim(); } @@ -161,7 +161,11 @@ public class ChadoTransactionManager else System.out.println("HERE feature_uniquename != null "+feature_uniquename); -// ChadoTransaction tsn = new ChadoTransaction(ChadoTransaction.INSERT, +/* + + ChadoTransaction tsn = new ChadoTransaction(ChadoTransaction.INSERT_FEATURE, + feature); +*/ } diff --git a/uk/ac/sanger/artemis/chado/IBatisDAO.java b/uk/ac/sanger/artemis/chado/IBatisDAO.java index 79497995ce7418587e755108a88762e9faa8556c..6374b8607adcb6325767ed7b97b03cc497d35272 100644 --- a/uk/ac/sanger/artemis/chado/IBatisDAO.java +++ b/uk/ac/sanger/artemis/chado/IBatisDAO.java @@ -42,7 +42,7 @@ public class IBatisDAO implements ChadoDAO * Get feature name given the feature_id and schema * */ - public String getFeatureName(final Feature feature) + public String getFeatureName(final ChadoFeature feature) throws SQLException { SqlMapClient sqlMap = DbSqlConfig.getSqlMapInstance(); @@ -60,7 +60,7 @@ public class IBatisDAO implements ChadoDAO final String schema) throws SQLException { - Feature feature = new Feature(); + ChadoFeature feature = new ChadoFeature(); feature.setId(feature_id); if(schema != null) feature.setSchema(schema); @@ -81,7 +81,7 @@ public class IBatisDAO implements ChadoDAO throws SQLException { SqlMapClient sqlMap = DbSqlConfig.getSqlMapInstance(); - Feature feature = new Feature(); + ChadoFeature feature = new ChadoFeature(); feature.setId(feature_id); if(schema != null) feature.setSchema(schema); @@ -99,16 +99,16 @@ public class IBatisDAO implements ChadoDAO * @param schema schema/organism name or null * */ - public Feature getSequence(final int feature_id, + public ChadoFeature getSequence(final int feature_id, final String schema) throws SQLException { SqlMapClient sqlMap = DbSqlConfig.getSqlMapInstance(); - Feature feature = new Feature(); + ChadoFeature feature = new ChadoFeature(); feature.setId(feature_id); if(schema != null) feature.setSchema(schema); - return (Feature)sqlMap.queryForObject("getSequence", + return (ChadoFeature)sqlMap.queryForObject("getSequence", feature); } @@ -150,7 +150,7 @@ public class IBatisDAO implements ChadoDAO /** * - * Get available schemas (as a List of Feature objects) + * Get available schemas (as a List of ChadoFeature objects) * */ public List getSchema() diff --git a/uk/ac/sanger/artemis/chado/JdbcDAO.java b/uk/ac/sanger/artemis/chado/JdbcDAO.java index 32730b80d00e46490cd66e8a01553f50715fac87..8f9df8dadc62d758b2113017645d9441005402cc 100644 --- a/uk/ac/sanger/artemis/chado/JdbcDAO.java +++ b/uk/ac/sanger/artemis/chado/JdbcDAO.java @@ -58,7 +58,7 @@ public class JdbcDAO return conn; } - public Feature getSequence(final int feature_id, + public ChadoFeature getSequence(final int feature_id, final String schema) throws SQLException { @@ -71,7 +71,7 @@ public class JdbcDAO ResultSet rs = st.executeQuery(sql); rs.next(); - Feature feature = new Feature(); + ChadoFeature feature = new ChadoFeature(); feature.setName(rs.getString("name")); feature.setResidues(rs.getBytes("residues")); return feature; @@ -135,7 +135,7 @@ public class JdbcDAO List list = new Vector(); while(rs.next()) { - Feature feature = new Feature(); + ChadoFeature feature = new ChadoFeature(); feature.setFmin( rs.getInt("fmin") ); feature.setFmax( rs.getInt("fmax") ); feature.setType_id( rs.getLong("type_id") ); @@ -175,18 +175,18 @@ public class JdbcDAO // merge same features in the list int feature_size = list.size(); List flatten_list = new Vector(); - Feature featNext = null; + ChadoFeature featNext = null; for(int i = 0; i < feature_size; i++) { - Feature feat = (Feature)list.get(i); + ChadoFeature feat = (ChadoFeature)list.get(i); String name = feat.getUniquename(); feat.addQualifier(feat.getProp_type_id(), feat.getValue()); if(i < feature_size - 1) - featNext = (Feature)list.get(i + 1); + featNext = (ChadoFeature)list.get(i + 1); // merge next line if part of the same feature while(featNext != null && featNext.getUniquename().equals(name)) @@ -195,7 +195,7 @@ public class JdbcDAO featNext.getValue()); i++; if(i < feature_size - 1) - featNext = (Feature)list.get(i + 1); + featNext = (ChadoFeature)list.get(i + 1); else break; } @@ -240,7 +240,7 @@ public class JdbcDAO List list = new Vector(); while(rs.next()) { - Feature feature = new Feature(); + ChadoFeature feature = new ChadoFeature(); feature.setId( rs.getInt("feature_id") ); feature.setAbbreviation( rs.getString("abbreviation") ); feature.setName( rs.getString("name") ); @@ -279,7 +279,7 @@ public class JdbcDAO /** * - * Get available schemas (as a List of Feature objects) + * Get available schemas (as a List of ChadoFeature objects) * */ public List getSchema() diff --git a/uk/ac/sanger/artemis/util/DatabaseDocument.java b/uk/ac/sanger/artemis/util/DatabaseDocument.java index a922e773b6426d5258438f7a26e89d15c3642942..1d2bc059fabec3f9fac598648e81bb3b5eac3f50 100644 --- a/uk/ac/sanger/artemis/util/DatabaseDocument.java +++ b/uk/ac/sanger/artemis/util/DatabaseDocument.java @@ -370,7 +370,7 @@ public class DatabaseDocument extends Document // build feature name store for(int i = 0; i < feature_size; i++) { - Feature feat = (Feature)featList.get(i); + ChadoFeature feat = (ChadoFeature)featList.get(i); String name = feat.getUniquename(); String feature_id = Integer.toString(feat.getId()); @@ -379,7 +379,7 @@ public class DatabaseDocument extends Document for(int i = 0; i < feature_size; i++) { - Feature feat = (Feature)featList.get(i); + ChadoFeature feat = (ChadoFeature)featList.get(i); int fmin = feat.getFmin() + 1; int fmax = feat.getFmax(); long type_id = feat.getType_id(); @@ -536,7 +536,7 @@ public class DatabaseDocument extends Document private ByteBuffer getSequence(ChadoDAO dao, ByteBuffer buff) throws java.sql.SQLException { - Feature feature = dao.getSequence(Integer.parseInt(feature_id), + ChadoFeature feature = dao.getSequence(Integer.parseInt(feature_id), schema); buff.append("##FASTA\n>"); @@ -582,7 +582,7 @@ public class DatabaseDocument extends Document Iterator it_residue_features = list_residue_features.iterator(); while(it_residue_features.hasNext()) { - Feature feature = (Feature)it_residue_features.next(); + ChadoFeature feature = (ChadoFeature)it_residue_features.next(); String org = feature.getAbbreviation(); String typeName = getCvtermName(feature.getType_id()); @@ -733,7 +733,7 @@ public class DatabaseDocument extends Document DbSqlConfig.init(new JPasswordField()); SqlMapClient sqlMap = DbSqlConfig.getSqlMapInstance(); - Feature feature = new Feature(); + ChadoFeature feature = new ChadoFeature(); feature.setId(Integer.parseInt(args[0])); feature.setSchema(args[1]); @@ -741,7 +741,7 @@ public class DatabaseDocument extends Document for(int i = 0; i < featureList.size(); i++) { - feature = (Feature)featureList.get(i); + feature = (ChadoFeature)featureList.get(i); int fmin = feature.getFmin() + 1; int fmax = feature.getFmax();