Newer
Older
boolean unchanged;
//
// check feature timestamps have not changed
Vector names_checked = new Vector();
if(tsn.getType() != ChadoTransaction.INSERT_FEATURE ||
tsn.getType() != ChadoTransaction.DELETE_FEATURE)
{
if(names_checked.contains((String)uniquename.get(j)))
continue;
names_checked.add((String)uniquename.get(j));
unchanged = checkFeatureTimestamp(schema,
(String)uniquename.get(j),
tsn.getLastModified(), dao);
if(!unchanged)
return 0;
}
if(dao instanceof IBatisDAO)
((IBatisDAO) dao).startTransaction();
//
// commit to database
for(i = 0; i < sql.size(); i++)
ChadoTransaction tsn = (ChadoTransaction) sql.get(i);
if(tsn.getType() == ChadoTransaction.UPDATE)
else if(tsn.getType() == ChadoTransaction.INSERT)
else if(tsn.getType() == ChadoTransaction.DELETE)
else if(tsn.getType() == ChadoTransaction.INSERT_FEATURE)
dao.insertFeature(tsn, feature_id);
else if(tsn.getType() == ChadoTransaction.DELETE_FEATURE)
else if(tsn.getType() == ChadoTransaction.DELETE_DBXREF)
dao.deleteFeatureDbxref(tsn);
else if(tsn.getType() == ChadoTransaction.INSERT_DBXREF)
dao.insertFeatureDbxref(tsn);
else if(tsn.getType() == ChadoTransaction.DELETE_ALIAS)
else if(tsn.getType() == ChadoTransaction.INSERT_ALIAS)
else if(tsn.getType() == ChadoTransaction.UPDATE_FEATURE_RELATIONSHIP)
dao.updateFeatureRelationshipsForSubjectId(tsn);
}
//
// update timelastmodified timestamp
Timestamp ts = null;
Timestamp ts2;
names_checked = new Vector();
for(int j = 0; j < sql.size(); j++)
{
ChadoTransaction tsn = (ChadoTransaction) sql.get(j);
if(tsn.getType() != ChadoTransaction.INSERT_FEATURE &&
tsn.getType() != ChadoTransaction.DELETE_FEATURE)
final List uniquename = tsn.getUniquename();
// update timelastmodified timestamp
for(int k = 0; k < uniquename.size(); k++)
{
if(names_checked.contains((String) uniquename.get(k)))
continue;
names_checked.add((String) uniquename.get(k));
dao.writeTimeLastModified((String) uniquename.get(k), ts);
ts2 = dao.getTimeLastModified((String) uniquename.get(k));
if(ts2 == null)
continue;
if(ts == null)
ts = ts2;
GFFStreamFeature gff_feature = (GFFStreamFeature) tsn
.getFeatureObject();
gff_feature.setLastModified(ts);
}
if(dao instanceof IBatisDAO &&
System.getProperty("nocommit") == null)
((IBatisDAO) dao).commitTransaction();
}
finally
{
if(dao instanceof IBatisDAO)
((IBatisDAO) dao).endTransaction();
}
JOptionPane.showMessageDialog(null, "Problems Writing...\n" +
JOptionPane.showMessageDialog(null, "Problems connecting..."+
conn_ex.getMessage(),
"Database Connection Error - Check Server",
JOptionPane.ERROR_MESSAGE);
/**
* Check the <code>Timestamp</code> on a feature (for versioning).
* @param schema the schema
* @param uniquename the feature uniquename
* @param timestamp the last read feature timestamp
* @throws SQLException
*/
public boolean checkFeatureTimestamp(final String schema,
final String uniquename,
final Timestamp timestamp,
final ChadoDAO dao)
throws SQLException
Timestamp now = dao.getTimeLastModified(uniquename);
{
now.setNanos(0);
timestamp.setNanos(0);
if(now.compareTo(timestamp) != 0)
{
SimpleDateFormat date_format =
new SimpleDateFormat("dd.MM.yyyy hh:mm:ss z");
//System.out.println(date_format.format(now)+" "+
// date_format.format(timestamp));
int select = JOptionPane.showConfirmDialog(null, uniquename +
date_format.format(now)+"\nOverwite?",
"Feature Changed",
JOptionPane.OK_CANCEL_OPTION);
if(select == JOptionPane.OK_OPTION)
return true;
else
return false;
public static void main(String args[])
{
try
{
ChadoDAO dao;
DatabaseEntrySource src = new DatabaseEntrySource();
src.setLocation(true);
if(System.getProperty("ibatis") == null)
dao = new JdbcDAO(src.getLocation(), src.getPfield());
else
dao = new IBatisDAO(src.getPfield());
ChadoFeature feature = new ChadoFeature();
feature.setUniquename(args[0]);
List schemas = new Vector();
schemas.add(args[1]);
List featureList = dao.getLazyFeature(feature);
int fmin = feature.getFeatureloc().getFmin() + 1;
int fmax = feature.getFeatureloc().getFmax();
String featprop =
((ChadoFeatureProp)feature.getFeaturepropList().get(0)).getCvterm().getName();
Hashtable synonyms = dao.getAlias(feature.getUniquename());
Vector syns = (Vector)synonyms.get(new Integer(feature.getId()));
for(int j=0; j<syns.size(); j++)
{
ChadoFeatureSynonym alias = (ChadoFeatureSynonym)syns.get(j);
System.out.print(" "+alias.getSynonym().getCvterm().getName()+
"="+alias.getSynonym().getName());
}
catch(SQLException sqle)
{
sqle.printStackTrace();
}
catch(ConnectException e)
{
e.printStackTrace();
}
public Document getParent()
{
return null;
}