diff --git a/uk/ac/sanger/artemis/chado/ChadoTransactionManager.java b/uk/ac/sanger/artemis/chado/ChadoTransactionManager.java index a50cfd74015a666d605bee184a7028c692fbdb29..23d5f92627c3d90664e76dad3a392a12e017954c 100644 --- a/uk/ac/sanger/artemis/chado/ChadoTransactionManager.java +++ b/uk/ac/sanger/artemis/chado/ChadoTransactionManager.java @@ -712,7 +712,11 @@ public class ChadoTransactionManager // happens when duplicating features FeatureProp featureprop = new FeatureProp(); featureprop.setValue((String)qualifier_values.elementAt(value_index)); - chado_feature.addQualifier(type_id, featureprop); + CvTerm cvTerm = new CvTerm(); + cvTerm.setCvTermId(type_id); + featureprop.setCvTerm(cvTerm); + chado_feature.addFeatureProp(featureprop); + // chado_feature.addQualifier(type_id, featureprop); // } } } diff --git a/uk/ac/sanger/artemis/chado/Feature.java b/uk/ac/sanger/artemis/chado/Feature.java index 259c72f070945a0fd07949c6d224c60bf168e5ec..9abf44d8b260456775a5813c08a5f1e7c3cd70b6 100644 --- a/uk/ac/sanger/artemis/chado/Feature.java +++ b/uk/ac/sanger/artemis/chado/Feature.java @@ -69,8 +69,6 @@ public class Feature private Organism organism; /** optional primary public stable identifier */ private FeatureDbXRef featureDbXRef; - /** merged featureprops */ - private Hashtable qualifiers; /** list of FeatureProp */ private Collection featureProps; /** list of FeatureRelationship children */ @@ -403,11 +401,11 @@ public class Feature { this.featureProps = featureProps; - for(int i=0; i<featureProps.size(); i++) +/* for(int i=0; i<featureProps.size(); i++) { FeatureProp featureprop = (FeatureProp)(((List)featureProps).get(i)); addQualifier(featureprop.getCvTerm().getCvTermId(), featureprop); - } + }*/ } /** @@ -494,44 +492,19 @@ public class Feature this.featureSynonymsForFeatureId = featureSynonymsForFeatureId; } - - - /** - * Used in merging the qualifiers to store them as a <code>Hashtable</code> of - * the cvTerm type_id (of the property name) and the property values as a - * <code>Vector</code>. - * @param the cvTerm type_id of the property name - * @param the property value - */ - public void addQualifier(long prop_type_id, FeatureProp featprop) - { - if(qualifiers == null) - qualifiers = new Hashtable(); - - final Long type_id = new Long(prop_type_id); - if(qualifiers.containsKey(type_id)) - { - Vector v = (Vector)qualifiers.get(type_id); - v.add(featprop); - qualifiers.put(type_id, v); - } - else - { - Vector v = new Vector(); - v.add(featprop); - qualifiers.put(type_id, v); - } - } - /** - * Get the qualifiers which are stored as a <code>Hashtable</code> of cvTerm - * type_id (of the property name) and the property values as a <code>Vector</code>. - * @return the qualifiers as a <code>Hashtable</code> + * Used in merging the qualifiers to store them as a <code>List</code> of + * <code>FeatureProp</code>. + * @param the FeatureProp */ - public Hashtable getQualifiers() + public void addFeatureProp(final FeatureProp featureprop) { - return qualifiers; + if(featureProps == null) + featureProps = new Vector(); + + featureProps.add(featureprop); } + /** * Utility for finding a feature location from a List that corresponds diff --git a/uk/ac/sanger/artemis/chado/IBatisDAO.java b/uk/ac/sanger/artemis/chado/IBatisDAO.java index 6b17a2764f4b82e48d4c32330bcd21ac69942435..49b2be4d5b3fa0f5333d992f658c89d5fab3b88e 100644 --- a/uk/ac/sanger/artemis/chado/IBatisDAO.java +++ b/uk/ac/sanger/artemis/chado/IBatisDAO.java @@ -92,7 +92,8 @@ public class IBatisDAO implements ChadoDAO List feature_list = sqlMap.queryForList("getFeature", feature); // merge same features in the list - return mergeList(feature_list); + //return mergeList(feature_list); + return feature_list; } /** @@ -494,52 +495,7 @@ public class IBatisDAO implements ChadoDAO { sqlMap.commitTransaction(); } - - /** - * Takes a list and creates a new one merging all feature objects - * within it with the same feature and stores the qualifiers/attributes - * as a hash - * @param list of feature objects - * @return list of flattened/merged feature objects - */ - protected static List mergeList(final List list) - { - // merge same features in the list - int feature_size = list.size(); - final List flatten_list = new Vector(); - Feature featNext = null; - for(int i = 0; i < feature_size; i++) - { - Feature feat = (Feature)list.get(i); - String name = feat.getUniqueName(); - - feat.addQualifier(feat.getFeatureprop().getCvTerm().getCvTermId(), - feat.getFeatureprop()); - - if(i < feature_size - 1) - featNext = (Feature)list.get(i + 1); - else - featNext = null; - - // merge next line if part of the same feature - while(featNext != null && featNext.getUniqueName().equals(name)) - { - feat.addQualifier(featNext.getFeatureprop().getCvTerm().getCvTermId(), - featNext.getFeatureprop()); - i++; - - if(i < feature_size - 1) - featNext = (Feature)list.get(i + 1); - else - break; - } - - flatten_list.add(feat); - } - - return flatten_list; - } /** * Takes a list and creates a <code>Hashtable</code> with the keys diff --git a/uk/ac/sanger/artemis/chado/JdbcDAO.java b/uk/ac/sanger/artemis/chado/JdbcDAO.java index 90b2f0b0560f28f1a27d3a6946702d6698d38b2a..29bf7cd72f371e64bdb3d05fb1c8b37db3d92a80 100644 --- a/uk/ac/sanger/artemis/chado/JdbcDAO.java +++ b/uk/ac/sanger/artemis/chado/JdbcDAO.java @@ -251,7 +251,7 @@ public class JdbcDAO throw new RuntimeException(sqle); } // merge same features in the list - return IBatisDAO.mergeList(list); + return mergeList(list); } @@ -1183,4 +1183,51 @@ public class JdbcDAO } } + /** + * Takes a list and creates a new one merging all feature objects + * within it with the same feature and stores the qualifiers/attributes + * as a hash + * @param list of feature objects + * @return list of flattened/merged feature objects + */ + private static List mergeList(final List list) + { + // merge same features in the list + int feature_size = list.size(); + final List flatten_list = new Vector(); + Feature featNext = null; + + for(int i = 0; i < feature_size; i++) + { + Feature feat = (Feature)list.get(i); + String name = feat.getUniqueName(); + + feat.addFeatureProp(feat.getFeatureprop()); + //feat.addQualifier(feat.getFeatureprop().getCvTerm().getCvTermId(), + // feat.getFeatureprop()); + + if(i < feature_size - 1) + featNext = (Feature)list.get(i + 1); + else + featNext = null; + + // merge next line if part of the same feature + while(featNext != null && featNext.getUniqueName().equals(name)) + { + //feat.addQualifier(featNext.getFeatureprop().getCvTerm().getCvTermId(), + // featNext.getFeatureprop()); + feat.addFeatureProp(featNext.getFeatureprop()); + i++; + + if(i < feature_size - 1) + featNext = (Feature)list.get(i + 1); + else + break; + } + + flatten_list.add(feat); + } + + return flatten_list; + } } diff --git a/uk/ac/sanger/artemis/util/DatabaseDocument.java b/uk/ac/sanger/artemis/util/DatabaseDocument.java index faaa54131f79c336b3c4fef0d55213687265bfa9..6933841273c4f5f06a4497eb23b327fef27012d9 100644 --- a/uk/ac/sanger/artemis/util/DatabaseDocument.java +++ b/uk/ac/sanger/artemis/util/DatabaseDocument.java @@ -740,29 +740,20 @@ public class DatabaseDocument extends Document //this_buff.append("feature_id="+feature_id+";"); // attributes - Hashtable qualifiers = feat.getQualifiers(); - - if(qualifiers != null && qualifiers.size() > 0) + if(feat.getFeatureProps() != null) { - Enumeration e_qualifiers = qualifiers.keys(); - while(e_qualifiers.hasMoreElements()) + List featureprops = (List)feat.getFeatureProps(); + for(int j=0; j<featureprops.size(); j++) { - Long qualifier_type_id = (Long)e_qualifiers.nextElement(); - String qualifier_name = getCvtermName(qualifier_type_id.longValue(), dao); + FeatureProp featprop = (FeatureProp)featureprops.get(j); + String qualifier_name = getCvtermName(featprop.getCvTerm().getCvTermId(), dao); if(qualifier_name == null) continue; - - Vector qualifier_value = (Vector)qualifiers.get(qualifier_type_id); - for(int j=0; j<qualifier_value.size(); j++) - { - FeatureProp featprop = (FeatureProp)qualifier_value.get(j); - - if(featprop.getValue() != null) - this_buff.append(qualifier_name+ "=" + - GFFStreamFeature.encode(featprop.getValue())+";"); - } + if(featprop.getValue() != null) + this_buff.append(qualifier_name+ "=" + + GFFStreamFeature.encode(featprop.getValue())+";"); } - } + } // append dbxrefs if(dbxref != null && dbxref.size() > 0)