X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.layer0%2Fsrc%2Forg%2Fsimantics%2Flayer0%2FDatabaseManagementResource.java;fp=bundles%2Forg.simantics.layer0%2Fsrc%2Forg%2Fsimantics%2Flayer0%2FDatabaseManagementResource.java;h=0000000000000000000000000000000000000000;hb=34a3b4cec59379e4a869acfdc09d191243e032e4;hp=30fda6919175911a5e1c1ef0b61ed355c14b45ec;hpb=32a6aa7b656804c95b8a2a2df06900955c6df44b;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.layer0/src/org/simantics/layer0/DatabaseManagementResource.java b/bundles/org.simantics.layer0/src/org/simantics/layer0/DatabaseManagementResource.java deleted file mode 100644 index 30fda6919..000000000 --- a/bundles/org.simantics.layer0/src/org/simantics/layer0/DatabaseManagementResource.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.simantics.layer0; - -import org.simantics.db.RequestProcessor; -import org.simantics.db.Resource; -import org.simantics.db.ReadGraph; -import org.simantics.db.request.Read; -import org.simantics.db.Session; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.service.QueryControl; - -public class DatabaseManagementResource { - - public final Resource Bundles; - public final Resource GraphBundle; - public final Resource HasFile; - public final Resource HasFile_Inverse; - public final Resource HasHashCode; - public final Resource HasHashCode_Inverse; - public final Resource HasInstallInfo; - public final Resource HasInstallInfo_Inverse; - public final Resource HasVersionedId; - public final Resource HasVersionedId_Inverse; - public final Resource InstallInfo; - public final Resource InstalledGraphBundles; - public final Resource OSGiSymbolicName; - public final Resource OSGiVersion; - public final Resource VersionedId; - - public static class URIs { - public static final String Bundles = "http://www.simantics.org/Layer0-1.1/DatabaseManagement/Bundles"; - public static final String GraphBundle = "http://www.simantics.org/Layer0-1.1/DatabaseManagement/GraphBundle"; - public static final String HasFile = "http://www.simantics.org/Layer0-1.1/DatabaseManagement/HasFile"; - public static final String HasFile_Inverse = "http://www.simantics.org/Layer0-1.1/DatabaseManagement/HasFile/Inverse"; - public static final String HasHashCode = "http://www.simantics.org/Layer0-1.1/DatabaseManagement/HasHashCode"; - public static final String HasHashCode_Inverse = "http://www.simantics.org/Layer0-1.1/DatabaseManagement/HasHashCode/Inverse"; - public static final String HasInstallInfo = "http://www.simantics.org/Layer0-1.1/DatabaseManagement/HasInstallInfo"; - public static final String HasInstallInfo_Inverse = "http://www.simantics.org/Layer0-1.1/DatabaseManagement/HasInstallInfo/Inverse"; - public static final String HasVersionedId = "http://www.simantics.org/Layer0-1.1/DatabaseManagement/HasVersionedId"; - public static final String HasVersionedId_Inverse = "http://www.simantics.org/Layer0-1.1/DatabaseManagement/HasVersionedId/Inverse"; - public static final String InstallInfo = "http://www.simantics.org/Layer0-1.1/DatabaseManagement/InstallInfo"; - public static final String InstalledGraphBundles = "http://www.simantics.org/Layer0-1.1/DatabaseManagement/InstalledGraphBundles"; - public static final String OSGiSymbolicName = "http://www.simantics.org/Layer0-1.1/DatabaseManagement/OSGiSymbolicName"; - public static final String OSGiVersion = "http://www.simantics.org/Layer0-1.1/DatabaseManagement/OSGiVersion"; - public static final String VersionedId = "http://www.simantics.org/Layer0-1.1/DatabaseManagement/VersionedId"; - } - - public static Resource getResourceOrNull(ReadGraph graph, String uri) { - try { - return graph.getResource(uri); - } catch(DatabaseException e) { - System.err.println(e.getMessage()); - return null; - } - } - - public DatabaseManagementResource(ReadGraph graph) { - Bundles = getResourceOrNull(graph, URIs.Bundles); - GraphBundle = getResourceOrNull(graph, URIs.GraphBundle); - HasFile = getResourceOrNull(graph, URIs.HasFile); - HasFile_Inverse = getResourceOrNull(graph, URIs.HasFile_Inverse); - HasHashCode = getResourceOrNull(graph, URIs.HasHashCode); - HasHashCode_Inverse = getResourceOrNull(graph, URIs.HasHashCode_Inverse); - HasInstallInfo = getResourceOrNull(graph, URIs.HasInstallInfo); - HasInstallInfo_Inverse = getResourceOrNull(graph, URIs.HasInstallInfo_Inverse); - HasVersionedId = getResourceOrNull(graph, URIs.HasVersionedId); - HasVersionedId_Inverse = getResourceOrNull(graph, URIs.HasVersionedId_Inverse); - InstallInfo = getResourceOrNull(graph, URIs.InstallInfo); - InstalledGraphBundles = getResourceOrNull(graph, URIs.InstalledGraphBundles); - OSGiSymbolicName = getResourceOrNull(graph, URIs.OSGiSymbolicName); - OSGiVersion = getResourceOrNull(graph, URIs.OSGiVersion); - VersionedId = getResourceOrNull(graph, URIs.VersionedId); - } - - public static DatabaseManagementResource getInstance(ReadGraph graph) { - Session session = graph.getSession(); - DatabaseManagementResource ret = session.peekService(DatabaseManagementResource.class); - if(ret == null) { - QueryControl qc = graph.getService(QueryControl.class); - ret = new DatabaseManagementResource(qc.getIndependentGraph(graph)); - session.registerService(DatabaseManagementResource.class, ret); - } - return ret; - } - - public static DatabaseManagementResource getInstance(RequestProcessor session) throws DatabaseException { - DatabaseManagementResource ret = session.peekService(DatabaseManagementResource.class); - if(ret == null) { - ret = session.syncRequest(new Read() { - public DatabaseManagementResource perform(ReadGraph graph) throws DatabaseException { - QueryControl qc = graph.getService(QueryControl.class); - return new DatabaseManagementResource(qc.getIndependentGraph(graph)); - } - }); - session.registerService(DatabaseManagementResource.class, ret); - } - return ret; - } - -} -