X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.project%2Fsrc%2Forg%2Fsimantics%2Fproject%2Fmanagement%2FDatabaseAgent.java;fp=bundles%2Forg.simantics.project%2Fsrc%2Forg%2Fsimantics%2Fproject%2Fmanagement%2FDatabaseAgent.java;h=70b2f5f0c0f53360fbb3c5c533237f166e03ee0a;hp=afdf3b71f4bec7d8253179f6a9ae0112417a570b;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.project/src/org/simantics/project/management/DatabaseAgent.java b/bundles/org.simantics.project/src/org/simantics/project/management/DatabaseAgent.java index afdf3b71f..70b2f5f0c 100644 --- a/bundles/org.simantics.project/src/org/simantics/project/management/DatabaseAgent.java +++ b/bundles/org.simantics.project/src/org/simantics/project/management/DatabaseAgent.java @@ -1,102 +1,102 @@ -/******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.project.management; - -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import org.eclipse.equinox.p2.metadata.VersionedId; -import org.simantics.db.ServerEx; -import org.simantics.db.Session; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.service.LifecycleSupport; - -/** - * Database agent installs ontologies and - * - * @author Toni Kalajainen - */ -public class DatabaseAgent { - - ServerEx server; - BundlePool bundlePool; - - /** - * Create a new agent. - * - * @param server - * @param bundlePool - * @throws DatabaseException - */ - public DatabaseAgent(ServerEx server, BundlePool bundlePool) { - this.server = server; - this.bundlePool = bundlePool; - } - - /** - * Get a snapshot of database current profile - * - * @return database specification - * @throws DatabaseException - */ - public DatabaseSpec getSpecification() throws DatabaseException { - // Create session - Properties props = new Properties(); - Session session = server.createSession(props); - try { - return session.syncRequest( DatabaseSpec.QUERY ); - } finally { - // Close session - session.getService(LifecycleSupport.class).close(); - } - } - - /** - * Perform install operation to - * @param spec - * @throws DatabaseException - */ - public void perform(DatabaseSpec spec) throws DatabaseException { - - // 1. Validate Spec - - - } - - public List validate(DatabaseSpec spec) { - ArrayList result = new ArrayList(); - - // 1. Ontology exists for all features - for (ProjectSpec ps : spec.projects) { - for (FeatureSpec fs : ps.features) { - /*IVersionedId vid =*/ VersionedId.parse(fs.versionedId); - // Now use BundlePool to find out ontologies -// bundlePool.getMetadataRepository() - } - } - - return result; - } - - - static class Problem { - // Cost of the problem. 0-100 - public int severity; - public String msg; - } - - static class OntologyVersionConflict { - - } - -} - +/******************************************************************************* + * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.project.management; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import org.eclipse.equinox.p2.metadata.VersionedId; +import org.simantics.db.ServerEx; +import org.simantics.db.Session; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.service.LifecycleSupport; + +/** + * Database agent installs ontologies and + * + * @author Toni Kalajainen + */ +public class DatabaseAgent { + + ServerEx server; + BundlePool bundlePool; + + /** + * Create a new agent. + * + * @param server + * @param bundlePool + * @throws DatabaseException + */ + public DatabaseAgent(ServerEx server, BundlePool bundlePool) { + this.server = server; + this.bundlePool = bundlePool; + } + + /** + * Get a snapshot of database current profile + * + * @return database specification + * @throws DatabaseException + */ + public DatabaseSpec getSpecification() throws DatabaseException { + // Create session + Properties props = new Properties(); + Session session = server.createSession(props); + try { + return session.syncRequest( DatabaseSpec.QUERY ); + } finally { + // Close session + session.getService(LifecycleSupport.class).close(); + } + } + + /** + * Perform install operation to + * @param spec + * @throws DatabaseException + */ + public void perform(DatabaseSpec spec) throws DatabaseException { + + // 1. Validate Spec + + + } + + public List validate(DatabaseSpec spec) { + ArrayList result = new ArrayList(); + + // 1. Ontology exists for all features + for (ProjectSpec ps : spec.projects) { + for (FeatureSpec fs : ps.features) { + /*IVersionedId vid =*/ VersionedId.parse(fs.versionedId); + // Now use BundlePool to find out ontologies +// bundlePool.getMetadataRepository() + } + } + + return result; + } + + + static class Problem { + // Cost of the problem. 0-100 + public int severity; + public String msg; + } + + static class OntologyVersionConflict { + + } + +} +