\r
protected Set<String> browseContexts = defaultBrowseContexts;\r
\r
- protected static final Comparator<Action> ACTION_COMPARATOR = new Comparator<Action>() {\r
+ public static final Comparator<Action> ACTION_COMPARATOR = new Comparator<Action>() {\r
@Override\r
public int compare(Action o1, Action o2) {\r
String t1 = o1.getText();\r
SimanticsPlatform.INSTANCE.shutdown(null);\r
}\r
public static void reconnectPlatform() throws Exception {\r
- SimanticsPlatform.INSTANCE.reconnect(null);\r
+ SimanticsPlatform.INSTANCE.reconnect(Simantics.getDefaultDatabaseDriver());\r
}\r
public static void synchronizeOntologies() throws Exception {\r
SimanticsPlatform.INSTANCE.synchronizeOntologies(new NullProgressMonitor(), OntologyRecoveryPolicy.Merge, true);\r
import org.simantics.utils.FileUtils;\r
\r
public class ServerManagerFactory {\r
- public static ServerManager create(String databaseId, String address) throws IOException, DatabaseException {\r
- Driver driver = Manager.getDriver(databaseId);\r
+ public static ServerManager create(String databaseDriverId, String address) throws IOException, DatabaseException {\r
+ Driver driver = Manager.getDriver(databaseDriverId);\r
if (driver == null)\r
- throw new IllegalArgumentException("Database driver for ID " + databaseId + " Could not be found!");\r
- System.out.println("ServerManagerFactory.create called with databaseId=" + databaseId + " and driver is " + driver.toString());\r
- DatabaseUserAgent agent = Manager.getUserAgent(databaseId);\r
+ throw new IllegalArgumentException("Database driver for ID " + databaseDriverId + " Could not be found!");\r
+ System.out.println("ServerManagerFactory.create called with databaseId=" + databaseDriverId + " and driver is " + driver.toString());\r
+ DatabaseUserAgent agent = Manager.getUserAgent(databaseDriverId);\r
if (agent != null)\r
driver.setDatabaseUserAgent(address, agent);\r
return new ServerManager(driver);\r
import org.eclipse.swt.widgets.Listener;\r
import org.eclipse.swt.widgets.Shell;\r
import org.eclipse.ui.IPerspectiveDescriptor;\r
-import org.eclipse.ui.IWorkbench;\r
import org.eclipse.ui.PlatformUI;\r
import org.eclipse.ui.application.IWorkbenchConfigurer;\r
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;\r
import org.simantics.db.indexing.DatabaseIndexing;\r
import org.simantics.db.procore.server.environment.RebootRequiredException;\r
import org.simantics.db.procore.server.environment.windows.Product;\r
-import org.simantics.db.procore.ui.ProCoreUserAgent;\r
import org.simantics.internal.TimedSessionCache;\r
import org.simantics.project.IProject;\r
import org.simantics.project.ProjectKeys;\r
*/\r
private static final String INSTALLED_FEATURES = "installedFeatures"; //$NON-NLS-1$\r
\r
- /**\r
- * Default database ID\r
- */\r
- private static final String DEFAULT_DATABASE_ID = "procore";\r
- \r
/**\r
* The arguments received by the application.\r
*/\r
throw new PlatformException("Argument not supported: " + SimanticsArguments.SERVER + " " + serverAddress);\r
}\r
\r
- // TODO: Default to procore for now;\r
- String databaseId = DEFAULT_DATABASE_ID;\r
+ String databaseDriverId = Simantics.getDefaultDatabaseDriver();\r
if (args.contains(SimanticsArguments.DATABASE_ID)) {\r
- databaseId = args.get(SimanticsArguments.DATABASE_ID);\r
+ databaseDriverId = args.get(SimanticsArguments.DATABASE_ID);\r
+ Simantics.setDefaultDatabaseDriver(databaseDriverId);\r
}\r
\r
IProgressMonitor mon = null;\r
if (PROFILE_PLATFORM_STARTUP)\r
mon = new TimingProgressMonitor();\r
- IWorkbench wb = PlatformUI.getWorkbench();\r
- SimanticsPlatform.INSTANCE.startUp(databaseId, mon, workspacePolicy, ontologyPolicy, requireSynchronize, new JFaceUserAgent());\r
+ SimanticsPlatform.INSTANCE.startUp(databaseDriverId, mon, workspacePolicy, ontologyPolicy, requireSynchronize, new JFaceUserAgent());\r
\r
// Make sure that the default perspective comes from the project if\r
// the project has set ProjectKeys#DEFAULT_PERSPECTIVE.\r
*/\r
public class Simantics {\r
\r
+ /**\r
+ * Default database driver ID\r
+ */\r
+ private static final String DEFAULT_DATABASE_DRIVER_ID = "procore";\r
+\r
+ private static String defaultDatabaseDriverId = DEFAULT_DATABASE_DRIVER_ID;\r
+\r
private static ISessionContextProviderSource providerSource = null;\r
private static volatile FileServiceImpl fileService = null;\r
\r
+ /**\r
+ * Sets the database driver to be used by the platform. To have any effect,\r
+ * this must be set before platform startup.\r
+ * \r
+ * @param id driver id\r
+ */\r
+ public static void setDefaultDatabaseDriver(String id) {\r
+ defaultDatabaseDriverId = id;\r
+ }\r
+\r
+ /**\r
+ * Returns currently set default database driver id.\r
+ */\r
+ public static String getDefaultDatabaseDriver() {\r
+ return defaultDatabaseDriverId;\r
+ }\r
+\r
/**\r
* @param args\r
* @param progress\r
\r
if (progress == null)\r
progress = new NullProgressMonitor();\r
- return SimanticsPlatform.INSTANCE.startUp(null, progress, workspacePolicy, ontologyPolicy, true, new ConsoleUserAgent());\r
+ return SimanticsPlatform.INSTANCE.startUp(defaultDatabaseDriverId, progress, workspacePolicy, ontologyPolicy, true, new ConsoleUserAgent());\r
}\r
\r
/**\r
import org.eclipse.core.runtime.Status;\r
import org.eclipse.core.runtime.SubMonitor;\r
import org.eclipse.osgi.service.resolver.BundleDescription;\r
-import org.simantics.SimanticsPlatform.OntologyRecoveryPolicy;\r
-import org.simantics.SimanticsPlatform.RecoveryPolicy;\r
import org.simantics.databoard.Bindings;\r
import org.simantics.databoard.Databoard;\r
import org.simantics.datatypes.literal.Font;\r
return application != null ? application : UUID.randomUUID().toString();\r
}\r
\r
- private Session setupDatabase(String databaseId, IProgressMonitor progressMonitor, RecoveryPolicy workspacePolicy, PlatformUserAgent userAgent) throws PlatformException {\r
+ private Session setupDatabase(String databaseDriverId, IProgressMonitor progressMonitor, RecoveryPolicy workspacePolicy, PlatformUserAgent userAgent) throws PlatformException {\r
if (progressMonitor == null)\r
progressMonitor = new NullProgressMonitor();\r
File dbLocation = Platform.getLocation().append("db").toFile();\r
ServerManager serverManager;\r
try {\r
- serverManager = ServerManagerFactory.create(databaseId, dbLocation.getAbsolutePath());\r
+ serverManager = ServerManagerFactory.create(databaseDriverId, dbLocation.getAbsolutePath());\r
} catch (DatabaseException | IOException e) {\r
throw new PlatformException("Failed to initialize Server Manager", e);\r
}\r
* startup or <code>null</code> to resort to default measures\r
* @throws PlatformException\r
*/\r
- public SessionContext startUp(String databaseId, IProgressMonitor progressMonitor, RecoveryPolicy workspacePolicy,\r
+ public SessionContext startUp(String databaseDriverId, IProgressMonitor progressMonitor, RecoveryPolicy workspacePolicy,\r
OntologyRecoveryPolicy ontologyPolicy, boolean requireSynchronize, PlatformUserAgent userAgent)\r
throws PlatformException\r
{\r
VariableRepository.clear();\r
\r
// 1. Assert there is a database at <workspace>/db\r
- session = setupDatabase(databaseId, progressMonitor, workspacePolicy, userAgent);\r
+ session = setupDatabase(databaseDriverId, progressMonitor, workspacePolicy, userAgent);\r
TimeLogger.log("Database setup complete");\r
\r
// 2. Assert all graphs, and correct versions, are installed to the database\r
return false;\r
}\r
\r
- public void reconnect(String databaseId) throws Exception {\r
+ public void reconnect(String databaseDriverId) throws Exception {\r
// Starts database server.\r
- SimanticsPlatform.INSTANCE.startUp(databaseId, null, RecoveryPolicy.ThrowError, OntologyRecoveryPolicy.ThrowError, true, null);\r
+ SimanticsPlatform.INSTANCE.startUp(databaseDriverId, null, RecoveryPolicy.ThrowError, OntologyRecoveryPolicy.ThrowError, true, null);\r
}\r
\r
private void dumpPlatformBundleState() {\r