Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Finkbeiner2011-10-24 14:24:16 -0400
committerRoberto E. Escobar2011-10-24 14:24:16 -0400
commitcce70701b2a857bae234537715ab65f5e226c9f2 (patch)
tree06c06b229175fce1f36709bffc47758679c074a9
parentf45d8c0ce30df5da8c1fccf21fbe43d4d5638245 (diff)
downloadorg.eclipse.osee-cce70701b2a857bae234537715ab65f5e226c9f2.tar.gz
org.eclipse.osee-cce70701b2a857bae234537715ab65f5e226c9f2.tar.xz
org.eclipse.osee-cce70701b2a857bae234537715ab65f5e226c9f2.zip
feature[ats_PX09C]: Update db connection services and type loading so multiple H2 tests can run
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/OseeCachingServiceRegistrationHandler.java3
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/ServerOseeCachingServiceFactory.java2
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java2
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/IOseeCachingServiceFactory.java2
-rw-r--r--plugins/org.eclipse.osee.framework.database/OSGI-INF/database.service.xml9
-rw-r--r--plugins/org.eclipse.osee.framework.database/OSGI-INF/identity.service.xml8
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/Activator.java8
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/IdentityServiceImpl.java9
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeConnectionPoolImpl.java13
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeDatabaseServiceImpl.java74
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/trackers/OseeDatabaseServiceRegistrationHandler.java61
-rw-r--r--plugins/org.eclipse.osee.framework.h2/src/org/eclipse/osee/framework/h2/H2DbServer.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/OrcsIntegrationTestSuite.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OsrcsApiTest.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/CachingService.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db.mock/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/TestDatabase.java8
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/CacheFactoryService.java19
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/ArtifactTypeDataAccessor.java119
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/TypeLoaderImpl.java138
20 files changed, 266 insertions, 221 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/OseeCachingServiceRegistrationHandler.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/OseeCachingServiceRegistrationHandler.java
index cab21d7a58..80012ecbd7 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/OseeCachingServiceRegistrationHandler.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/OseeCachingServiceRegistrationHandler.java
@@ -41,7 +41,6 @@ public class OseeCachingServiceRegistrationHandler extends AbstractTrackingHandl
IDataTranslationService.class,
IApplicationServerLookup.class,
IApplicationServerManager.class,
-// IOseeModelingService.class,
IResourceLocatorManager.class,
IResourceManager.class,
IdentityService.class,
@@ -59,7 +58,7 @@ public class OseeCachingServiceRegistrationHandler extends AbstractTrackingHandl
@Override
public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
IOseeCachingServiceFactory factory = createCachingFactoryService(context, services);
- IOseeCachingService cachingService = factory.createCachingService();
+ IOseeCachingService cachingService = factory.createCachingService(true);
factoryRegistration = context.registerService(IOseeCachingServiceFactory.class.getName(), factory, null);
cachingServiceRegistration = context.registerService(IOseeCachingService.class.getName(), cachingService, null);
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/ServerOseeCachingServiceFactory.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/ServerOseeCachingServiceFactory.java
index 176ab66911..caab150cef 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/ServerOseeCachingServiceFactory.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/ServerOseeCachingServiceFactory.java
@@ -64,7 +64,7 @@ public class ServerOseeCachingServiceFactory implements IOseeCachingServiceFacto
}
@Override
- public IOseeCachingService createCachingService() {
+ public IOseeCachingService createCachingService(boolean needsPriming) {
TransactionCache txCache = new TransactionCache();
IBranchUpdateEvent branchEventSender = new BranchUpdateEventImpl(translationService, appManager, serverLookUp);
BranchCache branchCache =
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java
index d73a89a912..49fe4b4861 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/OseeModelingServiceImpl.java
@@ -105,7 +105,7 @@ public class OseeModelingServiceImpl implements IOseeModelingService {
}
OseeDsl inputModel = ModelUtil.loadModel("osee:/" + modelName, request.getModel());
- IOseeCachingService tempCacheService = cachingFactoryService.createCachingService();
+ IOseeCachingService tempCacheService = cachingFactoryService.createCachingService(false);
OseeTypeCache tempCache =
new OseeTypeCache(tempCacheService.getArtifactTypeCache(), tempCacheService.getAttributeTypeCache(),
tempCacheService.getRelationTypeCache(), tempCacheService.getEnumTypeCache());
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/IOseeCachingServiceFactory.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/IOseeCachingServiceFactory.java
index 0bd7637359..6fff5df3e4 100644
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/IOseeCachingServiceFactory.java
+++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/IOseeCachingServiceFactory.java
@@ -15,5 +15,5 @@ package org.eclipse.osee.framework.core.services;
*/
public interface IOseeCachingServiceFactory {
- IOseeCachingService createCachingService();
+ IOseeCachingService createCachingService(boolean needsPriming);
}
diff --git a/plugins/org.eclipse.osee.framework.database/OSGI-INF/database.service.xml b/plugins/org.eclipse.osee.framework.database/OSGI-INF/database.service.xml
new file mode 100644
index 0000000000..630fa725bb
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.database/OSGI-INF/database.service.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop" name="org.eclipse.osee.framework.database.IOseeDatabaseService">
+ <implementation class="org.eclipse.osee.framework.database.internal.core.OseeDatabaseServiceImpl"/>
+ <service>
+ <provide interface="org.eclipse.osee.framework.database.IOseeDatabaseService"/>
+ </service>
+ <reference bind="setDatabaseInfoProvider" cardinality="1..1" interface="org.eclipse.osee.framework.database.core.IDatabaseInfoProvider" name="IDatabaseInfoProvider" policy="static" unbind="removeDatabaseInfoProvider" />
+ <reference bind="addConnectionFactory" unbind="removeConnectionFactory" cardinality="1..n" interface="org.eclipse.osee.framework.database.core.IConnectionFactory" name="IConnectionFactory" policy="static"/>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.framework.database/OSGI-INF/identity.service.xml b/plugins/org.eclipse.osee.framework.database/OSGI-INF/identity.service.xml
new file mode 100644
index 0000000000..b61abab1cf
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.database/OSGI-INF/identity.service.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" name="org.eclipse.osee.framework.IdentityService">
+ <implementation class="org.eclipse.osee.framework.database.internal.core.IdentityServiceImpl"/>
+ <reference bind="setOseeDatabaseService" cardinality="1..1" interface="org.eclipse.osee.framework.database.IOseeDatabaseService" name="IOseeDatabaseService" policy="static"/>
+ <service>
+ <provide interface="org.eclipse.osee.framework.core.services.IdentityService"/>
+ </service>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/Activator.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/Activator.java
index 5f9f7fce14..f2cfe7400d 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/Activator.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/Activator.java
@@ -12,10 +12,8 @@ package org.eclipse.osee.framework.database.internal;
import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.core.services.IOseeCachingService;
-import org.eclipse.osee.framework.core.util.ServiceDependencyTracker;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
-import org.eclipse.osee.framework.database.internal.trackers.OseeDatabaseServiceRegistrationHandler;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;
@@ -28,7 +26,6 @@ public class Activator implements BundleActivator, IOseeDatabaseServiceProvider
private static Activator instance = null;
- private ServiceDependencyTracker databaseServiceTracker;
private ServiceTracker dbTracker;
private ServiceTracker cacheTracker;
private DatabaseInfoProvider databaseInfoProvider;
@@ -38,10 +35,6 @@ public class Activator implements BundleActivator, IOseeDatabaseServiceProvider
instance = this;
databaseInfoProvider = new DatabaseInfoProvider(bundleContext);
- databaseServiceTracker =
- new ServiceDependencyTracker(bundleContext, new OseeDatabaseServiceRegistrationHandler());
- databaseServiceTracker.open();
-
dbTracker = new ServiceTracker(bundleContext, IOseeDatabaseService.class.getName(), null);
dbTracker.open(true);
@@ -64,7 +57,6 @@ public class Activator implements BundleActivator, IOseeDatabaseServiceProvider
@Override
public void stop(BundleContext context) throws Exception {
- databaseServiceTracker.close();
dbTracker.close();
cacheTracker.close();
databaseInfoProvider = null;
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/IdentityServiceImpl.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/IdentityServiceImpl.java
index 87fc96e97d..81341a2c24 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/IdentityServiceImpl.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/IdentityServiceImpl.java
@@ -30,11 +30,14 @@ public class IdentityServiceImpl implements IdentityService {
private final Map<Integer, Long> localIdToUniversalId = new ConcurrentHashMap<Integer, Long>();
private final Set<Long> persistedIds = new ConcurrentSkipListSet<Long>();
- private final IOseeDatabaseService service;
+ private IOseeDatabaseService service;
private volatile boolean ensurePopulatedRanOnce;
- public IdentityServiceImpl(IOseeDatabaseService service) {
- super();
+ public void start() {
+ //nothing to do
+ }
+
+ public void setOseeDatabaseService(IOseeDatabaseService service) {
this.service = service;
}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeConnectionPoolImpl.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeConnectionPoolImpl.java
index 6af69b9d83..541c9b189b 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeConnectionPoolImpl.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeConnectionPoolImpl.java
@@ -28,20 +28,14 @@ public class OseeConnectionPoolImpl {
private final List<OseeConnectionImpl> connections = new CopyOnWriteArrayList<OseeConnectionImpl>();
private final String dbUrl;
private final Properties properties;
- private final ConnectionFactoryProvider connectionFactory;
- private final String driver;
+ private final IConnectionFactory connectionFactory;
- public OseeConnectionPoolImpl(ConnectionFactoryProvider connectionFactory, String driver, String dbUrl, Properties properties) {
+ public OseeConnectionPoolImpl(IConnectionFactory connectionFactory, String dbUrl, Properties properties) {
this.connectionFactory = connectionFactory;
- this.driver = driver;
this.dbUrl = dbUrl;
this.properties = properties;
}
- private IConnectionFactory createConnection(String driver) throws OseeCoreException {
- return connectionFactory.get(driver);
- }
-
public synchronized boolean hasOpenConnection() {
return connections.size() > 0;
}
@@ -80,8 +74,7 @@ public class OseeConnectionPoolImpl {
private OseeConnectionImpl getOseeConnection() throws OseeCoreException {
try {
- IConnectionFactory connectionDriver = createConnection(driver);
- Connection connection = connectionDriver.getConnection(properties, dbUrl);
+ Connection connection = connectionFactory.getConnection(properties, dbUrl);
connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
return new OseeConnectionImpl(connection, this);
} catch (Exception ex) {
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeDatabaseServiceImpl.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeDatabaseServiceImpl.java
index 4cbda6ebf6..3068e00012 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeDatabaseServiceImpl.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeDatabaseServiceImpl.java
@@ -10,19 +10,25 @@
*******************************************************************************/
package org.eclipse.osee.framework.database.internal.core;
+import java.sql.Connection;
+import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Timer;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import org.eclipse.osee.framework.core.data.IDatabaseInfo;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.core.exception.OseeNotFoundException;
import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.core.IConnectionFactory;
import org.eclipse.osee.framework.database.core.IDatabaseInfoProvider;
import org.eclipse.osee.framework.database.core.IOseeSequence;
import org.eclipse.osee.framework.database.core.IOseeStatement;
@@ -38,14 +44,59 @@ public class OseeDatabaseServiceImpl implements IOseeDatabaseService {
private static final Map<String, OseeConnectionPoolImpl> dbInfoToPools =
new HashMap<String, OseeConnectionPoolImpl>();
- private final IOseeSequence oseeSequence;
- private final ConnectionFactoryProvider dbConnectionFactory;
- private final IDatabaseInfoProvider dbInfoProvider;
+ private IOseeSequence oseeSequence;
+ private IDatabaseInfoProvider dbInfoProvider;
- public OseeDatabaseServiceImpl(IDatabaseInfoProvider dbInfoProvider, ConnectionFactoryProvider dbConnectionFactory) {
+ private final Map<String, IConnectionFactory> factories = new ConcurrentHashMap<String, IConnectionFactory>();
+
+ public void start() {
this.oseeSequence = new OseeSequenceImpl(this);
- this.dbInfoProvider = dbInfoProvider;
- this.dbConnectionFactory = dbConnectionFactory;
+ }
+
+ public void stop() {
+ this.oseeSequence = null;
+ }
+
+ public void setDatabaseInfoProvider(IDatabaseInfoProvider databaseInfoProvider) {
+ dbInfoProvider = databaseInfoProvider;
+ }
+
+ public void removeDatabaseInfoProvider(IDatabaseInfoProvider databaseInfoProvider) throws OseeDataStoreException {
+ dbInfoToPools.remove(databaseInfoProvider.getDatabaseInfo().getId());
+ dbInfoProvider = null;
+ }
+
+ public void addConnectionFactory(IConnectionFactory connectionFactory) {
+ factories.put(connectionFactory.getDriver(), connectionFactory);
+ }
+
+ public void removeConnectionFactory(IConnectionFactory connectionFactory) {
+ factories.remove(connectionFactory.getDriver());
+
+ }
+
+ private static final class DefaultConnectionFactory implements IConnectionFactory {
+
+ private final String driver;
+
+ public DefaultConnectionFactory(String driver) {
+ this.driver = driver;
+ }
+
+ @Override
+ public Connection getConnection(Properties properties, String connectionURL) throws Exception {
+ try {
+ Class.forName(driver);
+ } catch (Exception ex) {
+ throw new OseeNotFoundException("Unable to find connection factory with driver [%s]", driver);
+ }
+ return DriverManager.getConnection(connectionURL, properties);
+ }
+
+ @Override
+ public String getDriver() {
+ return driver;
+ }
}
private IDatabaseInfo getDatabaseInfoProvider() throws OseeDataStoreException {
@@ -73,7 +124,7 @@ public class OseeDatabaseServiceImpl implements IOseeDatabaseService {
OseeConnectionPoolImpl pool = dbInfoToPools.get(databaseInfo.getId());
if (pool == null) {
pool =
- new OseeConnectionPoolImpl(dbConnectionFactory, databaseInfo.getDriver(), databaseInfo.getConnectionUrl(),
+ new OseeConnectionPoolImpl(getFactory(databaseInfo.getDriver()), databaseInfo.getConnectionUrl(),
databaseInfo.getConnectionProperties());
dbInfoToPools.put(databaseInfo.getId(), pool);
timer.schedule(new StaleConnectionCloser(pool), 900000, 900000);
@@ -81,6 +132,15 @@ public class OseeDatabaseServiceImpl implements IOseeDatabaseService {
return pool;
}
+ private IConnectionFactory getFactory(String driver) {
+ IConnectionFactory factory = factories.get(driver);
+ if (factory == null) {
+ return new DefaultConnectionFactory(driver);
+ } else {
+ return factory;
+ }
+ }
+
@Override
public OseeConnection getConnection(IDatabaseInfo databaseInfo) throws OseeCoreException {
return getConnectionPool(databaseInfo).getConnection();
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/trackers/OseeDatabaseServiceRegistrationHandler.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/trackers/OseeDatabaseServiceRegistrationHandler.java
deleted file mode 100644
index 23a71c9f8d..0000000000
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/trackers/OseeDatabaseServiceRegistrationHandler.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * 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:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.internal.trackers;
-
-import java.util.Map;
-import org.eclipse.osee.framework.core.services.IdentityService;
-import org.eclipse.osee.framework.core.util.AbstractTrackingHandler;
-import org.eclipse.osee.framework.core.util.OsgiUtil;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.IDatabaseInfoProvider;
-import org.eclipse.osee.framework.database.internal.core.ConnectionFactoryProvider;
-import org.eclipse.osee.framework.database.internal.core.IdentityServiceImpl;
-import org.eclipse.osee.framework.database.internal.core.OseeDatabaseServiceImpl;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * @author Roberto E. Escobar
- */
-public final class OseeDatabaseServiceRegistrationHandler extends AbstractTrackingHandler {
-
- private final static Class<?>[] SERVICE_DEPENDENCIES = new Class<?>[] {IDatabaseInfoProvider.class};
-
- private ServiceRegistration<?> serviceRegistration;
- private ServiceRegistration<?> serviceRegistration2;
-
- public OseeDatabaseServiceRegistrationHandler() {
- super();
- }
-
- @Override
- public Class<?>[] getDependencies() {
- return SERVICE_DEPENDENCIES;
- }
-
- @Override
- public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
- IDatabaseInfoProvider dbInfoProvider = getService(IDatabaseInfoProvider.class, services);
-
- ConnectionFactoryProvider dbConnectionFactory = new ConnectionFactoryProvider(context);
- IOseeDatabaseService databaseService = new OseeDatabaseServiceImpl(dbInfoProvider, dbConnectionFactory);
- serviceRegistration = context.registerService(IOseeDatabaseService.class.getName(), databaseService, null);
-
- IdentityService identityService = new IdentityServiceImpl(databaseService);
- serviceRegistration2 = context.registerService(IdentityService.class.getName(), identityService, null);
- }
-
- @Override
- public void onDeActivate() {
- OsgiUtil.close(serviceRegistration);
- OsgiUtil.close(serviceRegistration2);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.h2/src/org/eclipse/osee/framework/h2/H2DbServer.java b/plugins/org.eclipse.osee.framework.h2/src/org/eclipse/osee/framework/h2/H2DbServer.java
index a609860254..481e62c0e8 100644
--- a/plugins/org.eclipse.osee.framework.h2/src/org/eclipse/osee/framework/h2/H2DbServer.java
+++ b/plugins/org.eclipse.osee.framework.h2/src/org/eclipse/osee/framework/h2/H2DbServer.java
@@ -31,6 +31,10 @@ public class H2DbServer {
instance.startServerInternal(host, port);
}
+ public static void stopServer() {
+ instance.shutdown();
+ }
+
private void startServerInternal(String host, int port) throws Exception {
OseeLog.logf(H2DbServer.class, Level.INFO, "Starting H2 Database Server on [%s:%s]....", host, port);
try {
diff --git a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/OrcsIntegrationTestSuite.java b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/OrcsIntegrationTestSuite.java
index f577817c30..6fbe6c2dfe 100644
--- a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/OrcsIntegrationTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/OrcsIntegrationTestSuite.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.orcs.core;
import org.eclipse.osee.orcs.core.internal.OrcsQueryTest;
+import org.eclipse.osee.orcs.core.internal.OsrcsApiTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -18,8 +19,7 @@ import org.junit.runners.Suite;
* @author Roberto E. Escobar
*/
@RunWith(Suite.class)
-@Suite.SuiteClasses({//OsrcsApiTest.class,
-OrcsQueryTest.class})
+@Suite.SuiteClasses({OsrcsApiTest.class, OrcsQueryTest.class})
public class OrcsIntegrationTestSuite {
// Test Suite
}
diff --git a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OsrcsApiTest.java b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OsrcsApiTest.java
index 9be7768f56..caaf3d93c4 100644
--- a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OsrcsApiTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OsrcsApiTest.java
@@ -100,6 +100,7 @@ public class OsrcsApiTest {
Assert.assertEquals(2, graph.getExistingRelationTypes(art9).size());
Assert.assertEquals(1, graph.getRelatedArtifacts(art9, CoreRelationTypes.Default_Hierarchical__Parent).size());
Assert.assertEquals(20, graph.getRelatedArtifacts(art9, CoreRelationTypes.Users_User).size());
+
}
Map<Integer, ReadableArtifact> creatLookup(List<ReadableArtifact> arts) {
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/CachingService.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/CachingService.java
index a48600fff3..03cbcc50d3 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/CachingService.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/CachingService.java
@@ -47,7 +47,7 @@ public class CachingService implements IOseeCachingService {
}
public void start() {
- proxied = factory.createCachingService();
+ proxied = factory.createCachingService(true);
getLogger().info("ORCS Cache - Created");
}
diff --git a/plugins/org.eclipse.osee.orcs.db.mock/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.db.mock/META-INF/MANIFEST.MF
index 5d66d028ad..9673882f15 100644
--- a/plugins/org.eclipse.osee.orcs.db.mock/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.db.mock/META-INF/MANIFEST.MF
@@ -9,6 +9,7 @@ Import-Package: org.eclipse.osee.framework.core.data,
org.eclipse.osee.framework.core.exception,
org.eclipse.osee.framework.database,
org.eclipse.osee.framework.database.core,
+ org.eclipse.osee.framework.h2,
org.eclipse.osee.framework.jdk.core.util,
org.eclipse.osee.framework.jdk.core.util.network,
org.junit;version="4.8.2",
diff --git a/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/TestDatabase.java b/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/TestDatabase.java
index 6fb4dfde26..a1fa6261d5 100644
--- a/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/TestDatabase.java
+++ b/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/TestDatabase.java
@@ -19,6 +19,7 @@ import org.eclipse.osee.framework.core.data.IDatabaseInfo;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.database.core.IDatabaseInfoProvider;
import org.eclipse.osee.framework.database.core.OseeConnection;
+import org.eclipse.osee.framework.h2.H2DbServer;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.network.PortUtil;
import org.eclipse.osee.orcs.db.mock.OseeDatabase;
@@ -77,8 +78,7 @@ public class TestDatabase {
IDatabaseInfo databaseInfo = new DbInfo(connectionId, port, dbPath);
TestDbProvider provider = new TestDbProvider(databaseInfo);
- String serverAddress = String.format("0.0.0.0:%s", port);
- System.setProperty("osee.db.embedded.server", serverAddress);
+ System.setProperty("osee.db.embedded.server", "");
System.setProperty("osee.application.server.data", tempFolder.getAbsolutePath());
BundleContext context = getContext(bundle);
registration = context.registerService(IDatabaseInfoProvider.class, provider, null);
@@ -86,6 +86,8 @@ public class TestDatabase {
IOseeDatabaseService dbService = OsgiUtil.getService(IOseeDatabaseService.class);
Assert.assertNotNull(dbService);
+ H2DbServer.startServer("0.0.0.0", port);
+
OseeConnection connection = dbService.getConnection();
try {
Assert.assertNotNull(connection);
@@ -131,7 +133,7 @@ public class TestDatabase {
System.setProperty("osee.application.server.data", "");
System.setProperty("osee.db.embedded.server", "");
-
+ H2DbServer.stopServer();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/CacheFactoryService.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/CacheFactoryService.java
index f546345101..5c5defa85d 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/CacheFactoryService.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/CacheFactoryService.java
@@ -35,6 +35,7 @@ import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.db.internal.accessor.ArtifactTypeDataAccessor;
import org.eclipse.osee.orcs.db.internal.accessor.DatabaseBranchAccessor;
import org.eclipse.osee.orcs.db.internal.accessor.DatabaseTransactionRecordAccessor;
+import org.eclipse.osee.orcs.db.internal.accessor.TypeLoaderImpl;
/**
* @author Roberto E. Escobar
@@ -96,7 +97,7 @@ public class CacheFactoryService implements IOseeCachingServiceFactory {
}
@Override
- public IOseeCachingService createCachingService() {
+ public IOseeCachingService createCachingService(boolean needsPriming) {
TransactionCache txCache = new TransactionCache();
BranchCache branchCache =
new BranchCache(new DatabaseBranchAccessor(logger, executorAdmin, eventService, dbService, txCache,
@@ -104,18 +105,18 @@ public class CacheFactoryService implements IOseeCachingServiceFactory {
txCache.setAccessor(new DatabaseTransactionRecordAccessor(dbService, branchCache,
factoryService.getTransactionFactory()));
+ TypeLoaderImpl loader =
+ new TypeLoaderImpl(modelingService, identityService, dbService, resourceLocator, resourceManager, branchCache,
+ needsPriming);
+
OseeEnumTypeCache oseeEnumTypeCache =
- new OseeEnumTypeCache(new ArtifactTypeDataAccessor<OseeEnumType>(modelingService, identityService, dbService,
- resourceLocator, resourceManager, branchCache));
+ new OseeEnumTypeCache(new ArtifactTypeDataAccessor<OseeEnumType>(identityService, loader));
AttributeTypeCache attributeCache =
- new AttributeTypeCache(new ArtifactTypeDataAccessor<AttributeType>(modelingService, identityService,
- dbService, resourceLocator, resourceManager, branchCache));
+ new AttributeTypeCache(new ArtifactTypeDataAccessor<AttributeType>(identityService, loader));
ArtifactTypeCache artifactCache =
- new ArtifactTypeCache(new ArtifactTypeDataAccessor<ArtifactType>(modelingService, identityService, dbService,
- resourceLocator, resourceManager, branchCache));
+ new ArtifactTypeCache(new ArtifactTypeDataAccessor<ArtifactType>(identityService, loader));
RelationTypeCache relationCache =
- new RelationTypeCache(new ArtifactTypeDataAccessor<RelationType>(modelingService, identityService, dbService,
- resourceLocator, resourceManager, branchCache));
+ new RelationTypeCache(new ArtifactTypeDataAccessor<RelationType>(identityService, loader));
return new OseeCachingService(branchCache, txCache, artifactCache, attributeCache, relationCache,
oseeEnumTypeCache, identityService);
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/ArtifactTypeDataAccessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/ArtifactTypeDataAccessor.java
index 3b97094f4d..1503564937 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/ArtifactTypeDataAccessor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/ArtifactTypeDataAccessor.java
@@ -10,78 +10,34 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.accessor;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
-import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
-import org.eclipse.osee.framework.core.enums.CoreBranches;
-import org.eclipse.osee.framework.core.enums.TxChange;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
import org.eclipse.osee.framework.core.model.AbstractOseeType;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.core.model.OseeImportModelRequest;
-import org.eclipse.osee.framework.core.model.OseeImportModelResponse;
-import org.eclipse.osee.framework.core.model.cache.BranchCache;
import org.eclipse.osee.framework.core.model.cache.IOseeCache;
import org.eclipse.osee.framework.core.model.cache.IOseeDataAccessor;
-import org.eclipse.osee.framework.core.services.IOseeModelingService;
import org.eclipse.osee.framework.core.services.IdentityService;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.IOseeStatement;
-import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.resource.management.IResource;
-import org.eclipse.osee.framework.resource.management.IResourceLocator;
-import org.eclipse.osee.framework.resource.management.IResourceLocatorManager;
-import org.eclipse.osee.framework.resource.management.IResourceManager;
-import org.eclipse.osee.framework.resource.management.StandardOptions;
/**
* @author John R. Misinco
*/
public class ArtifactTypeDataAccessor<T extends AbstractOseeType<Long>> implements IOseeDataAccessor<Long, T> {
- private static final String LOAD_OSEE_TYPE_DEF_URIS =
- "select attr.uri from osee_txs txs1, osee_artifact art, osee_attribute attr, osee_txs txs2 where txs1.branch_id = ? and txs1.tx_current = ? and txs1.gamma_id = art.gamma_id and txs2.branch_id = ? and txs2.tx_current = ? and txs2.gamma_id = attr.gamma_id and art.art_type_id = ? and art.art_id = attr.art_id and attr.attr_type_id = ?";
-
- private static volatile boolean wasLoaded;
+ public static interface TypeLoader {
+ void load() throws OseeCoreException;
+ }
- private final IOseeModelingService modelingService;
+ private final TypeLoader loader;
private final IdentityService identityService;
- private final IOseeDatabaseService dbService;
- private final IResourceLocatorManager locatorManager;
- private final IResourceManager resourceManager;
- private final BranchCache branchCache;
- public ArtifactTypeDataAccessor(IOseeModelingService modelingService, IdentityService identityService, IOseeDatabaseService dbService, IResourceLocatorManager locatorManager, IResourceManager resourceManager, BranchCache branchCache) {
- this.modelingService = modelingService;
+ public ArtifactTypeDataAccessor(IdentityService identityService, TypeLoader loader) {
this.identityService = identityService;
- this.dbService = dbService;
- this.locatorManager = locatorManager;
- this.resourceManager = resourceManager;
- this.branchCache = branchCache;
+ this.loader = loader;
}
@Override
public synchronized void load(IOseeCache<Long, T> cache) throws OseeCoreException {
- if (!wasLoaded) {
- wasLoaded = true;
- Collection<String> uriPaths = findOseeTypeData();
- if (!uriPaths.isEmpty()) {
- List<IResource> resources = getTypeData(uriPaths);
- String modelData = createCombinedFile(resources);
- String modelName = String.format("osee.types.%s.osee", Lib.getDateTimeString());
- OseeImportModelRequest request = new OseeImportModelRequest(modelName, modelData, false, false, true);
- OseeImportModelResponse response = new OseeImportModelResponse();
- modelingService.importOseeTypes(new NullProgressMonitor(), true, request, response);
- }
- }
+ loader.load();
}
@Override
@@ -96,65 +52,4 @@ public class ArtifactTypeDataAccessor<T extends AbstractOseeType<Long>> implemen
type.clearDirty();
}
}
-
- private Collection<String> findOseeTypeData() throws OseeCoreException {
- Collection<String> paths = new ArrayList<String>();
-
- Integer artifactTypeId = identityService.getLocalId(CoreArtifactTypes.OseeTypeDefinition);
- Integer attributeTypeId = identityService.getLocalId(CoreAttributeTypes.UriGeneralStringData);
-
- Branch commonBranch = branchCache.get(CoreBranches.COMMON);
-
- if (commonBranch != null) {
- IOseeStatement chStmt = null;
- try {
- chStmt = dbService.getStatement();
- chStmt.runPreparedQuery(LOAD_OSEE_TYPE_DEF_URIS, commonBranch.getId(), TxChange.CURRENT.getValue(),
- commonBranch.getId(), TxChange.CURRENT.getValue(), artifactTypeId, attributeTypeId);
- while (chStmt.next()) {
- String uri = chStmt.getString("uri");
- paths.add(uri);
- }
- } finally {
- Lib.close(chStmt);
- }
- }
- return paths;
- }
-
- private List<IResource> getTypeData(Collection<String> paths) throws OseeCoreException {
- List<IResource> toReturn = new ArrayList<IResource>();
-
- PropertyStore options = new PropertyStore();
- options.put(StandardOptions.DecompressOnAquire.name(), "true");
- for (String path : paths) {
- IResourceLocator locator = locatorManager.getResourceLocator(path);
- IResource resource = resourceManager.acquire(locator, options);
- toReturn.add(resource);
- }
- return toReturn;
- }
-
- private String createCombinedFile(List<IResource> resources) throws OseeCoreException {
- StringWriter writer = new StringWriter();
- for (IResource resource : resources) {
- InputStream inputStream = null;
- try {
- inputStream = resource.getContent();
- String oseeTypeFragment = Lib.inputStreamToString(inputStream);
- oseeTypeFragment = oseeTypeFragment.replaceAll("import\\s+\"", "// import \"");
- writer.write("\n");
- writer.write("////////////// ");
- writer.write(resource.getName());
- writer.write("\n");
- writer.write("\n");
- writer.write(oseeTypeFragment);
- } catch (IOException ex) {
- OseeExceptions.wrapAndThrow(ex);
- } finally {
- Lib.close(inputStream);
- }
- }
- return writer.toString();
- }
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/TypeLoaderImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/TypeLoaderImpl.java
new file mode 100644
index 0000000000..4740c41a5d
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/TypeLoaderImpl.java
@@ -0,0 +1,138 @@
+/*
+ * Created on Oct 24, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.orcs.db.internal.accessor;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.TxChange;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.OseeImportModelRequest;
+import org.eclipse.osee.framework.core.model.OseeImportModelResponse;
+import org.eclipse.osee.framework.core.model.cache.BranchCache;
+import org.eclipse.osee.framework.core.services.IOseeModelingService;
+import org.eclipse.osee.framework.core.services.IdentityService;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.resource.management.IResource;
+import org.eclipse.osee.framework.resource.management.IResourceLocator;
+import org.eclipse.osee.framework.resource.management.IResourceLocatorManager;
+import org.eclipse.osee.framework.resource.management.IResourceManager;
+import org.eclipse.osee.framework.resource.management.StandardOptions;
+import org.eclipse.osee.orcs.db.internal.accessor.ArtifactTypeDataAccessor.TypeLoader;
+
+public class TypeLoaderImpl implements TypeLoader {
+ private static final String LOAD_OSEE_TYPE_DEF_URIS =
+ "select attr.uri from osee_txs txs1, osee_artifact art, osee_attribute attr, osee_txs txs2 where txs1.branch_id = ? and txs1.tx_current = ? and txs1.gamma_id = art.gamma_id and txs2.branch_id = ? and txs2.tx_current = ? and txs2.gamma_id = attr.gamma_id and art.art_type_id = ? and art.art_id = attr.art_id and attr.attr_type_id = ?";
+
+ private volatile boolean needsPriming = true;
+
+ private final IOseeModelingService modelingService;
+ private final IdentityService identityService;
+ private final IOseeDatabaseService dbService;
+ private final IResourceLocatorManager locatorManager;
+ private final IResourceManager resourceManager;
+ private final BranchCache branchCache;
+
+ public TypeLoaderImpl(IOseeModelingService modelingService, IdentityService identityService, IOseeDatabaseService dbService, IResourceLocatorManager locatorManager, IResourceManager resourceManager, BranchCache branchCache, boolean needsPriming) {
+ super();
+ this.modelingService = modelingService;
+ this.identityService = identityService;
+ this.dbService = dbService;
+ this.locatorManager = locatorManager;
+ this.resourceManager = resourceManager;
+ this.branchCache = branchCache;
+ this.needsPriming = needsPriming;
+ }
+
+ @Override
+ public synchronized void load() throws OseeCoreException {
+ if (needsPriming) {
+ needsPriming = false;
+ Collection<String> uriPaths = findOseeTypeData();
+ if (!uriPaths.isEmpty()) {
+ List<IResource> resources = getTypeData(uriPaths);
+ String modelData = createCombinedFile(resources);
+ String modelName = String.format("osee.types.%s.osee", Lib.getDateTimeString());
+ OseeImportModelRequest request = new OseeImportModelRequest(modelName, modelData, false, false, true);
+ OseeImportModelResponse response = new OseeImportModelResponse();
+ modelingService.importOseeTypes(new NullProgressMonitor(), true, request, response);
+ }
+ }
+ }
+
+ private Collection<String> findOseeTypeData() throws OseeCoreException {
+ Collection<String> paths = new ArrayList<String>();
+
+ Integer artifactTypeId = identityService.getLocalId(CoreArtifactTypes.OseeTypeDefinition);
+ Integer attributeTypeId = identityService.getLocalId(CoreAttributeTypes.UriGeneralStringData);
+
+ Branch commonBranch = branchCache.get(CoreBranches.COMMON);
+
+ if (commonBranch != null) {
+ IOseeStatement chStmt = null;
+ try {
+ chStmt = dbService.getStatement();
+ chStmt.runPreparedQuery(LOAD_OSEE_TYPE_DEF_URIS, commonBranch.getId(), TxChange.CURRENT.getValue(),
+ commonBranch.getId(), TxChange.CURRENT.getValue(), artifactTypeId, attributeTypeId);
+ while (chStmt.next()) {
+ String uri = chStmt.getString("uri");
+ paths.add(uri);
+ }
+ } finally {
+ Lib.close(chStmt);
+ }
+ }
+ return paths;
+ }
+
+ private List<IResource> getTypeData(Collection<String> paths) throws OseeCoreException {
+ List<IResource> toReturn = new ArrayList<IResource>();
+
+ PropertyStore options = new PropertyStore();
+ options.put(StandardOptions.DecompressOnAquire.name(), "true");
+ for (String path : paths) {
+ IResourceLocator locator = locatorManager.getResourceLocator(path);
+ IResource resource = resourceManager.acquire(locator, options);
+ toReturn.add(resource);
+ }
+ return toReturn;
+ }
+
+ private String createCombinedFile(List<IResource> resources) throws OseeCoreException {
+ StringWriter writer = new StringWriter();
+ for (IResource resource : resources) {
+ InputStream inputStream = null;
+ try {
+ inputStream = resource.getContent();
+ String oseeTypeFragment = Lib.inputStreamToString(inputStream);
+ oseeTypeFragment = oseeTypeFragment.replaceAll("import\\s+\"", "// import \"");
+ writer.write("\n");
+ writer.write("////////////// ");
+ writer.write(resource.getName());
+ writer.write("\n");
+ writer.write("\n");
+ writer.write(oseeTypeFragment);
+ } catch (IOException ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ } finally {
+ Lib.close(inputStream);
+ }
+ }
+ return writer.toString();
+ }
+}

Back to the top