Skip to content
Snippets Groups Projects
Commit 431ddf9e authored by tjc's avatar tjc
Browse files

chado qualifier updates

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@3302 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 830ce054
Branches
Tags
No related merge requests found
......@@ -46,7 +46,7 @@ public class ChadoTransaction
/** properties store */
protected Hashtable properties;
/** old properties store */
protected Hashtable old_properties;
protected Hashtable constraint;
/** type of statement */
protected int type;
......@@ -114,16 +114,11 @@ public class ChadoTransaction
properties.put(name, value);
}
/**
*
* Add a property to this transaction that will be changed.
*
*/
public void addOldProperty(String name, String old_value)
public void setConstraint(String name, String value)
{
if (properties == null)
old_properties = new Hashtable();
old_properties.put(name, old_value);
if(constraint == null)
constraint = new Hashtable();
constraint.put(name, value);
}
public String getSqlQuery()
......@@ -146,8 +141,19 @@ public class ChadoTransaction
if(enum_prop.hasMoreElements())
sqlBuff.append(" , ");
}
sqlBuff.append(" WHERE feature.feature_id=featureloc.feature_id AND feature.uniquename='");
sqlBuff.append(" WHERE feature.feature_id="+chadoTable+".feature_id AND feature.uniquename='");
sqlBuff.append(uniquename+"'");
if(constraint != null)
{
Enumeration enum_constraint = constraint.keys();
while(enum_constraint.hasMoreElements())
{
name = (String)enum_constraint.nextElement();
value = (String)constraint.get(name);
sqlBuff.append(" AND "+name+"="+value);
}
}
}
// else if(type == INSERT)
// else
......
......@@ -176,15 +176,23 @@ public class ChadoTransactionManager
final StringVector qualifier_strings =
StreamQualifier.toStringVector(null, this_qualifier);
long cvterm_id = DatabaseDocument.getCvtermID(name);
String cvterm_id = DatabaseDocument.getCvtermID(name).toString();
for(int value_index = 0; value_index < qualifier_strings.size();
++value_index)
{
final String qualifier_string = qualifier_strings.elementAt(value_index);
// tsn.addProperty("value", qualifier_string);
String qualifier_string = qualifier_strings.elementAt(value_index);
int index = qualifier_string.indexOf("=");
if(index > -1)
qualifier_string = qualifier_string.substring(index+1);
tsn.addProperty("value", "'"+qualifier_string+"'");
}
tsn.setConstraint("featureprop.type_id", cvterm_id);
sql.add(tsn);
System.out.println("******** "+DatabaseDocument.getCvtermID(name));
System.out.println(tsn.getSqlQuery());
}
else // insert qualifier
{}
......
......@@ -295,16 +295,16 @@ public class DatabaseDocument extends Document
return cdsBuffer.toString();
}
public static long getCvtermID(String name)
public static Long getCvtermID(String name)
{
Enumeration enum_cvterm = cvterm.keys();
while(enum_cvterm.hasMoreElements())
{
Long key = (Long)enum_cvterm.nextElement();
if(name.equals(cvterm.get(key)))
return key.longValue();
return key;
}
return (long)-1.;
return new Long("-1.");
}
private String getCvtermName(Connection conn, long id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment