X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.backup.ontology%2Fsrc%2Forg%2Fsimantics%2Fbackup%2Fontology%2FBackupResource.java;fp=bundles%2Forg.simantics.backup.ontology%2Fsrc%2Forg%2Fsimantics%2Fbackup%2Fontology%2FBackupResource.java;h=0000000000000000000000000000000000000000;hb=34a3b4cec59379e4a869acfdc09d191243e032e4;hp=ee321ea40c852be8e1b56f02176ccbf76ce01c0a;hpb=32a6aa7b656804c95b8a2a2df06900955c6df44b;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.backup.ontology/src/org/simantics/backup/ontology/BackupResource.java b/bundles/org.simantics.backup.ontology/src/org/simantics/backup/ontology/BackupResource.java deleted file mode 100644 index ee321ea40..000000000 --- a/bundles/org.simantics.backup.ontology/src/org/simantics/backup/ontology/BackupResource.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.simantics.backup.ontology; - -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 BackupResource { - - public final Resource ModelledBackupProvider; - public final Resource ModelledBackupProvider_instance; - public final Resource ModelledBackupProvider_instance_Inverse; - public final Resource SCLMain; - public final Resource modelledBackupProvider; - - public static class URIs { - public static final String ModelledBackupProvider = "http://www.simantics.org/Backup-1.0/ModelledBackupProvider"; - public static final String ModelledBackupProvider_instance = "http://www.simantics.org/Backup-1.0/ModelledBackupProvider/instance"; - public static final String ModelledBackupProvider_instance_Inverse = "http://www.simantics.org/Backup-1.0/ModelledBackupProvider/instance/Inverse"; - public static final String SCLMain = "http://www.simantics.org/Backup-1.0/SCLMain"; - public static final String modelledBackupProvider = "http://www.simantics.org/Backup-1.0/modelledBackupProvider"; - } - - public static Resource getResourceOrNull(ReadGraph graph, String uri) { - try { - return graph.getResource(uri); - } catch(DatabaseException e) { - System.err.println(e.getMessage()); - return null; - } - } - - public BackupResource(ReadGraph graph) { - ModelledBackupProvider = getResourceOrNull(graph, URIs.ModelledBackupProvider); - ModelledBackupProvider_instance = getResourceOrNull(graph, URIs.ModelledBackupProvider_instance); - ModelledBackupProvider_instance_Inverse = getResourceOrNull(graph, URIs.ModelledBackupProvider_instance_Inverse); - SCLMain = getResourceOrNull(graph, URIs.SCLMain); - modelledBackupProvider = getResourceOrNull(graph, URIs.modelledBackupProvider); - } - - public static BackupResource getInstance(ReadGraph graph) { - Session session = graph.getSession(); - BackupResource ret = session.peekService(BackupResource.class); - if(ret == null) { - QueryControl qc = graph.getService(QueryControl.class); - ret = new BackupResource(qc.getIndependentGraph(graph)); - session.registerService(BackupResource.class, ret); - } - return ret; - } - - public static BackupResource getInstance(RequestProcessor session) throws DatabaseException { - BackupResource ret = session.peekService(BackupResource.class); - if(ret == null) { - ret = session.syncRequest(new Read() { - public BackupResource perform(ReadGraph graph) throws DatabaseException { - QueryControl qc = graph.getService(QueryControl.class); - return new BackupResource(qc.getIndependentGraph(graph)); - } - }); - session.registerService(BackupResource.class, ret); - } - return ret; - } - -} -