DataAccess ds = info.getVersioningDataStore().getDataStore(null);
if (!(ds instanceof VersionedPostgisDataStore)) {
throw new GSSException(
"The store attached to the gss module is not a PostGIS versioning one");
}
VersionedPostgisDataStore dataStore = (VersionedPostgisDataStore) ds;
Set<String> typeNames = new HashSet<String>(Arrays.asList(dataStore.getTypeNames()));
// the synchronized tables list
if (!typeNames.contains(SYNCH_TABLES)) {
runStatement(dataStore, SYNC_TABLES_CREATION);
}
dataStore.setVersioned(SYNCH_TABLES, false, null, null);
// version enable all tables that are supposed to be shared
fi = dataStore.getFeatureSource(SYNCH_TABLES).getFeatures().features();
while (fi.hasNext()) {
String tableName = (String) fi.next().getAttribute("table_name");
dataStore.setVersioned(tableName, true, null, null);
}
fi.close();
if (info.getMode() == GSSMode.Unit) {
// hmm... we should really try to use createSchema() instead, but atm
// we don't have the necessary control over it
// the unit synchronisation history
if (!typeNames.contains(SYNCH_HISTORY)) {
runStatement(dataStore, SYNCH_HISTORY_CREATION);
}
dataStore.setVersioned(SYNCH_HISTORY, false, null, null);
// the conflict table
if (!typeNames.contains(SYNCH_CONFLICTS)) {
runStatement(dataStore, SYNCH_CONFLICTS_CREATION);
}
dataStore.setVersioned(SYNCH_CONFLICTS, true, null, null);
} else {
if (!typeNames.contains(SYNCH_UNITS)) {
runStatement(dataStore, SYNCH_UNITS_CREATION);
}
dataStore.setVersioned(SYNCH_UNITS, false, null, null);
if (!typeNames.contains(SYNCH_UNIT_TABLES)) {
runStatement(dataStore, SYNCH_UNIT_TABLES_CREATION);
}
dataStore.setVersioned(SYNCH_UNITS, false, null, null);
if (!typeNames.contains(SYNCH_OUTSTANDING)) {
runStatement(dataStore, SYNCH_OUTSTANDING_CREATION);
}
}