import org.eclipse.osgi.service.resolver.BundleDescription;
import org.ini4j.Ini;
import org.ini4j.InvalidFileFormatException;
+import org.simantics.SimanticsPlatform.OntologyRecoveryPolicy;
+import org.simantics.SimanticsPlatform.RecoveryPolicy;
import org.simantics.databoard.Bindings;
import org.simantics.databoard.Databoard;
import org.simantics.datatypes.literal.Font;
import org.simantics.db.UndoContext;
import org.simantics.db.VirtualGraph;
import org.simantics.db.WriteGraph;
+import org.simantics.db.common.processor.MergingDelayedWriteProcessor;
+import org.simantics.db.common.processor.MergingGraphRequestProcessor;
import org.simantics.db.common.request.ObjectsWithType;
import org.simantics.db.common.request.WriteResultRequest;
import org.simantics.db.common.utils.Transaction;
import org.simantics.db.service.UndoRedoSupport;
import org.simantics.db.service.VirtualGraphSupport;
import org.simantics.db.service.XSupport;
+import org.simantics.db.services.GlobalServiceInitializer;
import org.simantics.graph.db.GraphDependencyAnalyzer;
import org.simantics.graph.db.GraphDependencyAnalyzer.IU;
import org.simantics.graph.db.GraphDependencyAnalyzer.IdentityNode;
* It is applied when the ontology in the database of a workspace doesn't match
* a newer ontology in the Eclipse workspace.
*/
- public static enum OntologyRecoveryPolicy { ThrowError, Merge, ReinstallDatabase }
+ public static enum OntologyRecoveryPolicy { ThrowError, Merge, ReinstallDatabase, Bypass}
/**
* This policy dictates how the Simantics platform startup should react if
session.getService(XSupport.class).setServiceMode(true, true);
// Throw error
- if (ontologyPolicy == OntologyRecoveryPolicy.ThrowError) {
+ if (ontologyPolicy == OntologyRecoveryPolicy.ThrowError || ontologyPolicy == OntologyRecoveryPolicy.Bypass) {
StringBuilder sb = new StringBuilder("The following graphs are not installed in the database: ");
if (!installTGs.isEmpty()) {
int i = 0;
sb.append(" Database/Platform Bundle version mismatch.\n");
}
sb.append("Hint: Use -fixErrors to install the graphs.");
- throw new PlatformException(sb.toString());
+ if (ontologyPolicy == OntologyRecoveryPolicy.ThrowError)
+ throw new PlatformException(sb.toString());
+ else
+ log.log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, sb.toString()));
}
+
// Reinstall database
if (ontologyPolicy == OntologyRecoveryPolicy.ReinstallDatabase) {
log.log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "Reinstalling the database."));
}
public void resetDatabase(IProgressMonitor monitor) throws PlatformException {
+ // TODO: fix this to use Path APIs
File dbLocation = Platform.getLocation().append("db").toFile();
if(!dbLocation.exists()) return;
try { // Load driver
- Driver driver = Manager.getDriver("procore");
+ Driver driver = Manager.getDriver("acorn");
Management management = driver.getManagement(dbLocation.getAbsolutePath(), null);
management.delete();
} catch (DatabaseException e) {
}
+ public void registerServices(SessionContext context) {
+ new GlobalServiceInitializer().initialize(session);
+ session.registerService(MergingGraphRequestProcessor.class, new MergingGraphRequestProcessor("SessionService", session, 20));
+ session.registerService(MergingDelayedWriteProcessor.class, new MergingDelayedWriteProcessor(session, 20));
+ }
+
+
public SessionContext createSessionContext(boolean init) throws PlatformException {
try {
// Construct and initialize SessionContext from Session.
String message = "Session context created";
LOGGER.info(message);
if (init) {
- sessionContext.registerServices();
+ registerServices(sessionContext);
message = "Session services registered";
LOGGER.info(message);
}