Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrbrooks2010-07-24 04:02:08 -0400
committerrbrooks2010-07-24 04:02:08 -0400
commit4ed8bddc791fda93940f238c5135556a07041dc0 (patch)
tree64a118285c5006c3a38320dbb2d374e8ea72a061 /plugins/org.eclipse.osee.framework.core.datastore
parent542cc7344d3f129d64e47f547384297c8e1b1f43 (diff)
downloadorg.eclipse.osee-4ed8bddc791fda93940f238c5135556a07041dc0.tar.gz
org.eclipse.osee-4ed8bddc791fda93940f238c5135556a07041dc0.tar.xz
org.eclipse.osee-4ed8bddc791fda93940f238c5135556a07041dc0.zip
converted all line terminators to unix style
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.datastore')
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/.classpath14
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/.project66
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/build.properties12
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/DatastoreInitOperation.java182
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/IOseeSchemaProvider.java44
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/IOseeSchemaResource.java44
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/OseeSchemaProvider.java84
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/SchemaCreationOptions.java100
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/AbstractDatabaseAccessor.java102
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/BranchUpdateEventImpl.java258
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseArtifactTypeAccessor.java530
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseAttributeTypeAccessor.java378
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseBranchAccessor.java364
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseOseeEnumTypeAccessor.java396
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseRelationTypeAccessor.java268
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseTransactionRecordAccessor.java310
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/IBranchUpdateEvent.java46
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/Activator.java92
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/CoreOseeSchemaResource.java50
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/OseeCachingServiceRegistrationHandler.java210
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/ServerOseeCachingServiceFactory.java164
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/data/ConstraintElement.java282
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/data/ReferenceClause.java308
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/CreateSchemaOperation.java116
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/DatabaseDataImporter.java510
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/OperationFactory.java82
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/DerbySqlManager.java242
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/MysqlSqlManager.java316
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/OracleSqlManager.java164
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/PostgreSqlManager.java402
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/SqlManager.java616
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/SqlManagerImpl.java136
32 files changed, 3444 insertions, 3444 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/.classpath b/plugins/org.eclipse.osee.framework.core.datastore/.classpath
index 8a8f1668cd..ad32c83a78 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/.classpath
+++ b/plugins/org.eclipse.osee.framework.core.datastore/.classpath
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/.project b/plugins/org.eclipse.osee.framework.core.datastore/.project
index a423f96380..fa4346eca8 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/.project
+++ b/plugins/org.eclipse.osee.framework.core.datastore/.project
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.osee.framework.core.datastore</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ds.core.builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.framework.core.datastore</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/build.properties b/plugins/org.eclipse.osee.framework.core.datastore/build.properties
index d5c5a0485e..83eb93c180 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/build.properties
+++ b/plugins/org.eclipse.osee.framework.core.datastore/build.properties
@@ -1,6 +1,6 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- OSGI-INF/,\
- support/
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/,\
+ support/
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/DatastoreInitOperation.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/DatastoreInitOperation.java
index 28c12d9bbb..af122814f3 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/DatastoreInitOperation.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/DatastoreInitOperation.java
@@ -1,91 +1,91 @@
-/*******************************************************************************
- * 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.core.datastore;
-
-import java.io.File;
-import java.util.logging.Level;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.branch.management.IOseeBranchService;
-import org.eclipse.osee.framework.core.datastore.internal.Activator;
-import org.eclipse.osee.framework.core.datastore.schema.operations.OperationFactory;
-import org.eclipse.osee.framework.core.enums.PermissionEnum;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.core.operation.AbstractOperation;
-import org.eclipse.osee.framework.core.operation.IOperation;
-import org.eclipse.osee.framework.core.server.IApplicationServerManager;
-import org.eclipse.osee.framework.core.server.OseeServerProperties;
-import org.eclipse.osee.framework.core.util.Conditions;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.OseeInfo;
-import org.eclipse.osee.framework.jdk.core.util.GUID;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Roberto E. Escobar
- */
-public class DatastoreInitOperation extends AbstractOperation {
-
- private static final String ADD_PERMISSION =
- "INSERT INTO OSEE_PERMISSION (PERMISSION_ID, PERMISSION_NAME) VALUES (?,?)";
-
- private final IOseeBranchService branchService;
- private final IOseeDatabaseService dbService;
- private final IOseeSchemaProvider schemaProvider;
- private final SchemaCreationOptions options;
- private final IApplicationServerManager appServerManager;
-
- public DatastoreInitOperation(IApplicationServerManager appServerManager, IOseeDatabaseService dbService, IOseeBranchService branchService, IOseeSchemaProvider schemaProvider, SchemaCreationOptions options) {
- super("Datastore Initialization", Activator.PLUGIN_ID);
- this.appServerManager = appServerManager;
- this.dbService = dbService;
- this.branchService = branchService;
- this.schemaProvider = schemaProvider;
- this.options = options;
- }
-
- @Override
- protected void doWork(IProgressMonitor monitor) throws Exception {
- Conditions.checkExpressionFailOnTrue(dbService.isProduction(),
- "Error - attempting to initialize a production datastore.");
-
- IOperation subOp = OperationFactory.createDbSchema(dbService, schemaProvider, options);
- doSubWork(subOp, monitor, 0.30);
-
- dbService.getSequence().clear();
-
- appServerManager.executeLookupRegistration();
-
- deleteBinaryBackingData();
- String binaryDataPath = OseeServerProperties.getOseeApplicationServerData();
- Lib.deleteDir(new File(binaryDataPath + File.separator + "attr"));
-
- OseeInfo.putValue(OseeInfo.DB_ID_KEY, GUID.create());
- addDefaultPermissions();
-
- subOp = branchService.createSystemRootBranch(monitor);
- doSubWork(subOp, monitor, 0.30);
- }
-
- @SuppressWarnings("unchecked")
- private void addDefaultPermissions() throws OseeDataStoreException {
- for (PermissionEnum permission : PermissionEnum.values()) {
- dbService.runPreparedUpdate(ADD_PERMISSION, permission.getPermId(), permission.getName());
- }
- }
-
- private static void deleteBinaryBackingData() {
- String binaryDataPath = OseeServerProperties.getOseeApplicationServerData();
- OseeLog.log(Activator.class, Level.INFO,
- String.format("Deleting application server binary data [%s]...", binaryDataPath));
- Lib.deleteDir(new File(binaryDataPath + File.separator + "attr"));
- }
-}
+/*******************************************************************************
+ * 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.core.datastore;
+
+import java.io.File;
+import java.util.logging.Level;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.branch.management.IOseeBranchService;
+import org.eclipse.osee.framework.core.datastore.internal.Activator;
+import org.eclipse.osee.framework.core.datastore.schema.operations.OperationFactory;
+import org.eclipse.osee.framework.core.enums.PermissionEnum;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.core.operation.AbstractOperation;
+import org.eclipse.osee.framework.core.operation.IOperation;
+import org.eclipse.osee.framework.core.server.IApplicationServerManager;
+import org.eclipse.osee.framework.core.server.OseeServerProperties;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.core.OseeInfo;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class DatastoreInitOperation extends AbstractOperation {
+
+ private static final String ADD_PERMISSION =
+ "INSERT INTO OSEE_PERMISSION (PERMISSION_ID, PERMISSION_NAME) VALUES (?,?)";
+
+ private final IOseeBranchService branchService;
+ private final IOseeDatabaseService dbService;
+ private final IOseeSchemaProvider schemaProvider;
+ private final SchemaCreationOptions options;
+ private final IApplicationServerManager appServerManager;
+
+ public DatastoreInitOperation(IApplicationServerManager appServerManager, IOseeDatabaseService dbService, IOseeBranchService branchService, IOseeSchemaProvider schemaProvider, SchemaCreationOptions options) {
+ super("Datastore Initialization", Activator.PLUGIN_ID);
+ this.appServerManager = appServerManager;
+ this.dbService = dbService;
+ this.branchService = branchService;
+ this.schemaProvider = schemaProvider;
+ this.options = options;
+ }
+
+ @Override
+ protected void doWork(IProgressMonitor monitor) throws Exception {
+ Conditions.checkExpressionFailOnTrue(dbService.isProduction(),
+ "Error - attempting to initialize a production datastore.");
+
+ IOperation subOp = OperationFactory.createDbSchema(dbService, schemaProvider, options);
+ doSubWork(subOp, monitor, 0.30);
+
+ dbService.getSequence().clear();
+
+ appServerManager.executeLookupRegistration();
+
+ deleteBinaryBackingData();
+ String binaryDataPath = OseeServerProperties.getOseeApplicationServerData();
+ Lib.deleteDir(new File(binaryDataPath + File.separator + "attr"));
+
+ OseeInfo.putValue(OseeInfo.DB_ID_KEY, GUID.create());
+ addDefaultPermissions();
+
+ subOp = branchService.createSystemRootBranch(monitor);
+ doSubWork(subOp, monitor, 0.30);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void addDefaultPermissions() throws OseeDataStoreException {
+ for (PermissionEnum permission : PermissionEnum.values()) {
+ dbService.runPreparedUpdate(ADD_PERMISSION, permission.getPermId(), permission.getName());
+ }
+ }
+
+ private static void deleteBinaryBackingData() {
+ String binaryDataPath = OseeServerProperties.getOseeApplicationServerData();
+ OseeLog.log(Activator.class, Level.INFO,
+ String.format("Deleting application server binary data [%s]...", binaryDataPath));
+ Lib.deleteDir(new File(binaryDataPath + File.separator + "attr"));
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/IOseeSchemaProvider.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/IOseeSchemaProvider.java
index c579500bbb..7ffb669d55 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/IOseeSchemaProvider.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/IOseeSchemaProvider.java
@@ -1,22 +1,22 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.core.datastore;
-
-import java.util.Collection;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface IOseeSchemaProvider {
-
- Collection<IOseeSchemaResource> getSchemaResources();
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009 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.core.datastore;
+
+import java.util.Collection;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IOseeSchemaProvider {
+
+ Collection<IOseeSchemaResource> getSchemaResources();
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/IOseeSchemaResource.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/IOseeSchemaResource.java
index 3dea7eece4..6c717fee83 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/IOseeSchemaResource.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/IOseeSchemaResource.java
@@ -1,22 +1,22 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.core.datastore;
-
-import java.io.InputStream;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface IOseeSchemaResource {
-
- public InputStream getContent() throws OseeCoreException;
-}
+/*******************************************************************************
+ * Copyright (c) 2009 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.core.datastore;
+
+import java.io.InputStream;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IOseeSchemaResource {
+
+ public InputStream getContent() throws OseeCoreException;
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/OseeSchemaProvider.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/OseeSchemaProvider.java
index cb35f6044e..c6c1f8d916 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/OseeSchemaProvider.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/OseeSchemaProvider.java
@@ -1,42 +1,42 @@
-/*******************************************************************************
- * 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.core.datastore;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.eclipse.core.runtime.Platform;
-import org.osgi.framework.Bundle;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * @author Roberto E. Escobar
- */
-public class OseeSchemaProvider implements IOseeSchemaProvider {
-
- public Collection<IOseeSchemaResource> getSchemaResources() {
- Collection<IOseeSchemaResource> providers = new ArrayList<IOseeSchemaResource>();
-
- Bundle bundle = Platform.getBundle("org.eclipse.osee.framework.core.datastore");
- ServiceTracker serviceTracker =
- new ServiceTracker(bundle.getBundleContext(), IOseeSchemaResource.class.getName(), null);
- serviceTracker.open(true);
- Object[] services = serviceTracker.getServices();
- if (services != null) {
- for (Object object : services) {
- if (object instanceof IOseeSchemaResource) {
- providers.add((IOseeSchemaResource) object);
- }
- }
- }
- serviceTracker.close();
- return providers;
- }
-}
+/*******************************************************************************
+ * 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.core.datastore;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.eclipse.core.runtime.Platform;
+import org.osgi.framework.Bundle;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class OseeSchemaProvider implements IOseeSchemaProvider {
+
+ public Collection<IOseeSchemaResource> getSchemaResources() {
+ Collection<IOseeSchemaResource> providers = new ArrayList<IOseeSchemaResource>();
+
+ Bundle bundle = Platform.getBundle("org.eclipse.osee.framework.core.datastore");
+ ServiceTracker serviceTracker =
+ new ServiceTracker(bundle.getBundleContext(), IOseeSchemaResource.class.getName(), null);
+ serviceTracker.open(true);
+ Object[] services = serviceTracker.getServices();
+ if (services != null) {
+ for (Object object : services) {
+ if (object instanceof IOseeSchemaResource) {
+ providers.add((IOseeSchemaResource) object);
+ }
+ }
+ }
+ serviceTracker.close();
+ return providers;
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/SchemaCreationOptions.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/SchemaCreationOptions.java
index ed699f4d24..962ef9baa5 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/SchemaCreationOptions.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/SchemaCreationOptions.java
@@ -1,50 +1,50 @@
-/*******************************************************************************
- * 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.core.datastore;
-
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-
-/**
- * @author Roberto E. Escobar
- */
-public class SchemaCreationOptions {
-
- private final String tableDataSpace;
- private final String indexDataSpace;
- private final boolean useFileSpecifiedSchemas;
-
- public SchemaCreationOptions(String tableDataSpace, String indexDataSpace, boolean useFileSpecifiedSchemas) {
- super();
- this.tableDataSpace = tableDataSpace;
- this.indexDataSpace = indexDataSpace;
- this.useFileSpecifiedSchemas = useFileSpecifiedSchemas;
- }
-
- public String getTableDataSpace() {
- return tableDataSpace;
- }
-
- public String getIndexDataSpace() {
- return indexDataSpace;
- }
-
- public boolean isUseFileSpecifiedSchemas() {
- return useFileSpecifiedSchemas;
- }
-
- public boolean isIndexDataSpaceValid() {
- return Strings.isValid(getIndexDataSpace());
- }
-
- public boolean isTableDataSpaceValid() {
- return Strings.isValid(getTableDataSpace());
- }
-}
+/*******************************************************************************
+ * 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.core.datastore;
+
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class SchemaCreationOptions {
+
+ private final String tableDataSpace;
+ private final String indexDataSpace;
+ private final boolean useFileSpecifiedSchemas;
+
+ public SchemaCreationOptions(String tableDataSpace, String indexDataSpace, boolean useFileSpecifiedSchemas) {
+ super();
+ this.tableDataSpace = tableDataSpace;
+ this.indexDataSpace = indexDataSpace;
+ this.useFileSpecifiedSchemas = useFileSpecifiedSchemas;
+ }
+
+ public String getTableDataSpace() {
+ return tableDataSpace;
+ }
+
+ public String getIndexDataSpace() {
+ return indexDataSpace;
+ }
+
+ public boolean isUseFileSpecifiedSchemas() {
+ return useFileSpecifiedSchemas;
+ }
+
+ public boolean isIndexDataSpaceValid() {
+ return Strings.isValid(getIndexDataSpace());
+ }
+
+ public boolean isTableDataSpaceValid() {
+ return Strings.isValid(getTableDataSpace());
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/AbstractDatabaseAccessor.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/AbstractDatabaseAccessor.java
index 34f18cfeda..9c78f8d1bb 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/AbstractDatabaseAccessor.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/AbstractDatabaseAccessor.java
@@ -1,51 +1,51 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.core.datastore.cache;
-
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.core.model.IOseeStorable;
-import org.eclipse.osee.framework.core.model.cache.IOseeDataAccessor;
-import org.eclipse.osee.framework.core.services.IOseeModelFactoryService;
-import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
-import org.eclipse.osee.framework.database.core.IOseeSequence;
-
-/**
- * @author Roberto E. Escobar
- */
-public abstract class AbstractDatabaseAccessor<T extends IOseeStorable> implements IOseeDataAccessor<T> {
-
- private final IOseeDatabaseServiceProvider databaseProvider;
- private final IOseeModelFactoryServiceProvider factoryProvider;
-
- protected AbstractDatabaseAccessor(IOseeDatabaseServiceProvider databaseProvider, IOseeModelFactoryServiceProvider factoryProvider) {
- this.databaseProvider = databaseProvider;
- this.factoryProvider = factoryProvider;
- }
-
- protected IOseeDatabaseServiceProvider getDatabaseServiceProvider() {
- return databaseProvider;
- }
-
- protected IOseeDatabaseService getDatabaseService() throws OseeDataStoreException {
- return getDatabaseServiceProvider().getOseeDatabaseService();
- }
-
- protected IOseeSequence getSequence() throws OseeDataStoreException {
- return getDatabaseService().getSequence();
- }
-
- protected IOseeModelFactoryService getFactoryService() throws OseeCoreException {
- return factoryProvider.getOseeFactoryService();
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009 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.core.datastore.cache;
+
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.core.model.IOseeStorable;
+import org.eclipse.osee.framework.core.model.cache.IOseeDataAccessor;
+import org.eclipse.osee.framework.core.services.IOseeModelFactoryService;
+import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
+import org.eclipse.osee.framework.database.core.IOseeSequence;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public abstract class AbstractDatabaseAccessor<T extends IOseeStorable> implements IOseeDataAccessor<T> {
+
+ private final IOseeDatabaseServiceProvider databaseProvider;
+ private final IOseeModelFactoryServiceProvider factoryProvider;
+
+ protected AbstractDatabaseAccessor(IOseeDatabaseServiceProvider databaseProvider, IOseeModelFactoryServiceProvider factoryProvider) {
+ this.databaseProvider = databaseProvider;
+ this.factoryProvider = factoryProvider;
+ }
+
+ protected IOseeDatabaseServiceProvider getDatabaseServiceProvider() {
+ return databaseProvider;
+ }
+
+ protected IOseeDatabaseService getDatabaseService() throws OseeDataStoreException {
+ return getDatabaseServiceProvider().getOseeDatabaseService();
+ }
+
+ protected IOseeSequence getSequence() throws OseeDataStoreException {
+ return getDatabaseService().getSequence();
+ }
+
+ protected IOseeModelFactoryService getFactoryService() throws OseeCoreException {
+ return factoryProvider.getOseeFactoryService();
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/BranchUpdateEventImpl.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/BranchUpdateEventImpl.java
index 263af19f91..6b785a3828 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/BranchUpdateEventImpl.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/BranchUpdateEventImpl.java
@@ -8,132 +8,132 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.framework.core.datastore.cache;
-
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.data.OseeServerContext;
-import org.eclipse.osee.framework.core.data.OseeServerInfo;
-import org.eclipse.osee.framework.core.datastore.internal.Activator;
-import org.eclipse.osee.framework.core.enums.CacheOperation;
-import org.eclipse.osee.framework.core.enums.CoreTranslatorId;
-import org.eclipse.osee.framework.core.enums.StorageState;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.message.BranchCacheStoreRequest;
-import org.eclipse.osee.framework.core.message.BranchRow;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.core.operation.AbstractOperation;
-import org.eclipse.osee.framework.core.operation.Operations;
-import org.eclipse.osee.framework.core.server.IApplicationServerLookupProvider;
-import org.eclipse.osee.framework.core.server.IApplicationServerManager;
-import org.eclipse.osee.framework.core.translation.IDataTranslationServiceProvider;
-import org.eclipse.osee.framework.core.util.HttpMessage;
-import org.eclipse.osee.framework.core.util.HttpProcessor.AcquireResult;
-import org.eclipse.osee.framework.jdk.core.util.HttpUrlBuilder;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Roberto E. Escobar
- */
-public class BranchUpdateEventImpl implements IBranchUpdateEvent {
-
- private final IDataTranslationServiceProvider txProvider;
- private final IApplicationServerLookupProvider lookUpProvider;
- private final IApplicationServerManager manager;
-
- public BranchUpdateEventImpl(IDataTranslationServiceProvider translationService, IApplicationServerManager manager, IApplicationServerLookupProvider lookUpProvider) {
- super();
- this.txProvider = translationService;
- this.lookUpProvider = lookUpProvider;
- this.manager = manager;
- }
-
- public void send(final Collection<Branch> branches) throws OseeCoreException {
- List<Branch> branchToUpdate = new ArrayList<Branch>();
- for (Branch branch : branches) {
- if (!branch.isDirty()) {
- branchToUpdate.add(branch);
- }
- }
- Operations.executeAsJob(new ServerSyncOperation(branchToUpdate), false);
- }
-
- private final class ServerSyncOperation extends AbstractOperation {
-
- private final Collection<Branch> branches;
-
- public ServerSyncOperation(Collection<Branch> branches) {
- super("Server Sync", Activator.PLUGIN_ID);
- this.branches = branches;
- }
-
- private boolean is_0_9_2_Compatible(String... versions) {
- for (String version : versions) {
- if (Strings.isValid(version)) {
- String toCheck = version.toLowerCase();
- if (!toCheck.startsWith("0.9.0") && !toCheck.startsWith("0.9.1")) {
- return true;
- }
- }
- }
- return false;
- }
-
- private StorageState getCompatibleState(StorageState state) {
- StorageState toReturn = state;
- if (state == StorageState.PURGED) {
- toReturn = StorageState.DELETED;
- } else if (state == StorageState.LOADED) {
- toReturn = StorageState.MODIFIED;
- }
- return toReturn;
- }
-
- @Override
- protected void doWork(IProgressMonitor monitor) throws Exception {
- BranchCacheStoreRequest request = BranchCacheStoreRequest.fromCache(branches);
- request.setServerUpdateMessage(true);
-
- BranchCacheStoreRequest request0_9_1 = BranchCacheStoreRequest.fromCache(branches);
- request0_9_1.setServerUpdateMessage(true);
- for (BranchRow row : request0_9_1.getBranchRows()) {
- row.setStorageState(getCompatibleState(row.getStorageState()));
- }
-
- Map<String, String> parameters = new HashMap<String, String>();
- parameters.put("function", CacheOperation.STORE.name());
-
- for (OseeServerInfo serverInfo : lookUpProvider.getApplicationServerLookupService().getAvailableServers()) {
- if (!manager.getId().equals(serverInfo.getServerId()) && serverInfo.isAcceptingRequests()) {
- try {
-
- String urlString =
- HttpUrlBuilder.createURL(serverInfo.getServerAddress(), serverInfo.getPort(),
- OseeServerContext.CACHE_CONTEXT, parameters);
-
- BranchCacheStoreRequest message =
- is_0_9_2_Compatible(serverInfo.getVersion()) ? request : request0_9_1;
-
- AcquireResult updateResponse =
- HttpMessage.send(urlString, txProvider.getTranslationService(),
- CoreTranslatorId.BRANCH_CACHE_STORE_REQUEST, message, null);
- if (!updateResponse.wasSuccessful()) {
- OseeLog.log(Activator.class, Level.SEVERE, "Error relaying branch updates to servers");
- }
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, "Error relaying branch updates to servers", ex);
- } catch (UnsupportedEncodingException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, "Error relaying branch updates to servers", ex);
- }
- }
- }
- }
- };
-}
+package org.eclipse.osee.framework.core.datastore.cache;
+
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.data.OseeServerContext;
+import org.eclipse.osee.framework.core.data.OseeServerInfo;
+import org.eclipse.osee.framework.core.datastore.internal.Activator;
+import org.eclipse.osee.framework.core.enums.CacheOperation;
+import org.eclipse.osee.framework.core.enums.CoreTranslatorId;
+import org.eclipse.osee.framework.core.enums.StorageState;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.message.BranchCacheStoreRequest;
+import org.eclipse.osee.framework.core.message.BranchRow;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.operation.AbstractOperation;
+import org.eclipse.osee.framework.core.operation.Operations;
+import org.eclipse.osee.framework.core.server.IApplicationServerLookupProvider;
+import org.eclipse.osee.framework.core.server.IApplicationServerManager;
+import org.eclipse.osee.framework.core.translation.IDataTranslationServiceProvider;
+import org.eclipse.osee.framework.core.util.HttpMessage;
+import org.eclipse.osee.framework.core.util.HttpProcessor.AcquireResult;
+import org.eclipse.osee.framework.jdk.core.util.HttpUrlBuilder;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class BranchUpdateEventImpl implements IBranchUpdateEvent {
+
+ private final IDataTranslationServiceProvider txProvider;
+ private final IApplicationServerLookupProvider lookUpProvider;
+ private final IApplicationServerManager manager;
+
+ public BranchUpdateEventImpl(IDataTranslationServiceProvider translationService, IApplicationServerManager manager, IApplicationServerLookupProvider lookUpProvider) {
+ super();
+ this.txProvider = translationService;
+ this.lookUpProvider = lookUpProvider;
+ this.manager = manager;
+ }
+
+ public void send(final Collection<Branch> branches) throws OseeCoreException {
+ List<Branch> branchToUpdate = new ArrayList<Branch>();
+ for (Branch branch : branches) {
+ if (!branch.isDirty()) {
+ branchToUpdate.add(branch);
+ }
+ }
+ Operations.executeAsJob(new ServerSyncOperation(branchToUpdate), false);
+ }
+
+ private final class ServerSyncOperation extends AbstractOperation {
+
+ private final Collection<Branch> branches;
+
+ public ServerSyncOperation(Collection<Branch> branches) {
+ super("Server Sync", Activator.PLUGIN_ID);
+ this.branches = branches;
+ }
+
+ private boolean is_0_9_2_Compatible(String... versions) {
+ for (String version : versions) {
+ if (Strings.isValid(version)) {
+ String toCheck = version.toLowerCase();
+ if (!toCheck.startsWith("0.9.0") && !toCheck.startsWith("0.9.1")) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private StorageState getCompatibleState(StorageState state) {
+ StorageState toReturn = state;
+ if (state == StorageState.PURGED) {
+ toReturn = StorageState.DELETED;
+ } else if (state == StorageState.LOADED) {
+ toReturn = StorageState.MODIFIED;
+ }
+ return toReturn;
+ }
+
+ @Override
+ protected void doWork(IProgressMonitor monitor) throws Exception {
+ BranchCacheStoreRequest request = BranchCacheStoreRequest.fromCache(branches);
+ request.setServerUpdateMessage(true);
+
+ BranchCacheStoreRequest request0_9_1 = BranchCacheStoreRequest.fromCache(branches);
+ request0_9_1.setServerUpdateMessage(true);
+ for (BranchRow row : request0_9_1.getBranchRows()) {
+ row.setStorageState(getCompatibleState(row.getStorageState()));
+ }
+
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("function", CacheOperation.STORE.name());
+
+ for (OseeServerInfo serverInfo : lookUpProvider.getApplicationServerLookupService().getAvailableServers()) {
+ if (!manager.getId().equals(serverInfo.getServerId()) && serverInfo.isAcceptingRequests()) {
+ try {
+
+ String urlString =
+ HttpUrlBuilder.createURL(serverInfo.getServerAddress(), serverInfo.getPort(),
+ OseeServerContext.CACHE_CONTEXT, parameters);
+
+ BranchCacheStoreRequest message =
+ is_0_9_2_Compatible(serverInfo.getVersion()) ? request : request0_9_1;
+
+ AcquireResult updateResponse =
+ HttpMessage.send(urlString, txProvider.getTranslationService(),
+ CoreTranslatorId.BRANCH_CACHE_STORE_REQUEST, message, null);
+ if (!updateResponse.wasSuccessful()) {
+ OseeLog.log(Activator.class, Level.SEVERE, "Error relaying branch updates to servers");
+ }
+ } catch (OseeCoreException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, "Error relaying branch updates to servers", ex);
+ } catch (UnsupportedEncodingException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, "Error relaying branch updates to servers", ex);
+ }
+ }
+ }
+ }
+ };
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseArtifactTypeAccessor.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseArtifactTypeAccessor.java
index 45610d3c48..410274eb35 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseArtifactTypeAccessor.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseArtifactTypeAccessor.java
@@ -1,265 +1,265 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.core.datastore.cache;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.core.datastore.internal.Activator;
-import org.eclipse.osee.framework.core.enums.StorageState;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.core.exception.OseeInvalidInheritanceException;
-import org.eclipse.osee.framework.core.model.AbstractOseeType;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.core.model.cache.ArtifactTypeCache;
-import org.eclipse.osee.framework.core.model.cache.AttributeTypeCache;
-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.type.ArtifactType;
-import org.eclipse.osee.framework.core.model.type.ArtifactTypeFactory;
-import org.eclipse.osee.framework.core.model.type.AttributeType;
-import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
-import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
-import org.eclipse.osee.framework.database.core.IOseeStatement;
-import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap;
-import org.eclipse.osee.framework.jdk.core.type.HashCollection;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Roberto E. Escobar
- */
-public class DatabaseArtifactTypeAccessor extends AbstractDatabaseAccessor<ArtifactType> {
- protected static final int ABSTRACT_TYPE_INDICATOR = 1;
- protected static final int CONCRETE_TYPE_INDICATOR = 0;
-
- private static final String SELECT_ARTIFACT_TYPES = "select * from osee_artifact_type";
- private static final String INSERT_ARTIFACT_TYPE =
- "insert into osee_artifact_type (art_type_id, art_type_guid, name, is_abstract) VALUES (?,?,?,?)";
-
- private static final String UPDATE_ARTIFACT_TYPE =
- "update osee_artifact_type SET name = ?, is_abstract = ? where art_type_id = ?";
-
- private static final String SELECT_ARTIFACT_TYPE_INHERITANCE =
- "select * from osee_artifact_type_inheritance order by super_art_type_id, art_type_id";
- private static final String INSERT_ARTIFACT_TYPE_INHERITANCE =
- "insert into osee_artifact_type_inheritance (art_type_id, super_art_type_id) VALUES (?,?)";
- private static final String DELETE_ARTIFACT_TYPE_INHERITANCE =
- "delete from osee_artifact_type_inheritance where art_type_id = ?";
-
- private static final String SELECT_ARTIFACT_TYPE_ATTRIBUTES =
- "select * from osee_artifact_type_attributes order by art_type_id, branch_id, attr_type_id";
- private static final String INSERT_ARTIFACT_TYPE_ATTRIBUTES =
- "insert into osee_artifact_type_attributes (art_type_id, attr_type_id, branch_id) VALUES (?, ?, ?)";
- private static final String DELETE_ARTIFACT_TYPE_ATTRIBUTES =
- "delete from osee_artifact_type_attributes where art_type_id = ?";
-
- private final AttributeTypeCache attributeCache;
- private final BranchCache branchCache;
-
- public DatabaseArtifactTypeAccessor(IOseeDatabaseServiceProvider databaseProvider, IOseeModelFactoryServiceProvider factoryProvider, BranchCache branchCache, AttributeTypeCache attributeCache) {
- super(databaseProvider, factoryProvider);
- this.attributeCache = attributeCache;
- this.branchCache = branchCache;
- }
-
- @Override
- public void load(IOseeCache<ArtifactType> cache) throws OseeCoreException {
- attributeCache.ensurePopulated();
- Set<ArtifactType> loadedTypes = new HashSet<ArtifactType>();
- ArtifactTypeCache artCache = (ArtifactTypeCache) cache;
- loadArtifactTypes(artCache, loadedTypes);
- loadTypeInheritance(artCache);
- loadAllTypeValidity(artCache);
- for (ArtifactType type : loadedTypes) {
- type.clearDirty();
- }
- }
-
- private void loadArtifactTypes(ArtifactTypeCache cache, Set<ArtifactType> loadedTypes) throws OseeCoreException {
- ArtifactTypeFactory factory = getFactoryService().getArtifactTypeFactory();
-
- IOseeStatement chStmt = getDatabaseService().getStatement();
- try {
- chStmt.runPreparedQuery(SELECT_ARTIFACT_TYPES);
-
- while (chStmt.next()) {
- try {
- int artTypeId = chStmt.getInt("art_type_id");
- boolean isAbstract = chStmt.getInt("is_abstract") == ABSTRACT_TYPE_INDICATOR;
- String artifactTypeName = chStmt.getString("name");
- String guid = chStmt.getString("art_type_guid");
-
- ArtifactType artifactType =
- factory.createOrUpdate(cache, artTypeId, StorageState.LOADED, guid, isAbstract, artifactTypeName);
- loadedTypes.add(artifactType);
- } catch (OseeDataStoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
- } finally {
- chStmt.close();
- }
- }
-
- private void loadTypeInheritance(ArtifactTypeCache cache) throws OseeCoreException {
- IOseeStatement chStmt2 = getDatabaseService().getStatement();
- try {
- chStmt2.runPreparedQuery(SELECT_ARTIFACT_TYPE_INHERITANCE);
- HashCollection<ArtifactType, ArtifactType> baseToSuperTypes =
- new HashCollection<ArtifactType, ArtifactType>(false, HashSet.class);
-
- while (chStmt2.next()) {
- int artTypeId = chStmt2.getInt("art_type_id");
- int superArtTypeId = chStmt2.getInt("super_art_type_id");
- ArtifactType baseArtType = cache.getById(artTypeId);
- ArtifactType superArtType = cache.getById(superArtTypeId);
-
- if (baseArtType == null) {
- throw new OseeInvalidInheritanceException(String.format(
- "ArtifactType [%s] which inherits from [%s] is null", artTypeId, superArtType));
- }
- if (superArtType == null) {
- throw new OseeInvalidInheritanceException(String.format(
- "ArtifactType [%s] which inherits from null artifact [%s]", artTypeId, superArtType));
- }
- baseToSuperTypes.put(baseArtType, superArtType);
- }
- for (ArtifactType artifactType : baseToSuperTypes.keySet()) {
- Set<ArtifactType> superTypes = (Set<ArtifactType>) baseToSuperTypes.getValues(artifactType);
- if (superTypes != null) {
- artifactType.setSuperTypes(superTypes);
- }
- }
- } finally {
- chStmt2.close();
- }
- }
-
- private void loadAllTypeValidity(ArtifactTypeCache cache) throws OseeCoreException {
- CompositeKeyHashMap<ArtifactType, Branch, Collection<AttributeType>> typeValidity =
- new CompositeKeyHashMap<ArtifactType, Branch, Collection<AttributeType>>();
- IOseeStatement chStmt = getDatabaseService().getStatement();
- try {
- chStmt.runPreparedQuery(2000, SELECT_ARTIFACT_TYPE_ATTRIBUTES);
- while (chStmt.next()) {
- try {
- ArtifactType artifactType = cache.getById(chStmt.getInt("art_type_id"));
- Branch branch = branchCache.getById(chStmt.getInt("branch_id"));
- AttributeType attributeType = attributeCache.getById(chStmt.getInt("attr_type_id"));
- Collection<AttributeType> attributes = typeValidity.get(artifactType, branch);
- if (attributes == null) {
- attributes = new HashSet<AttributeType>();
- typeValidity.put(artifactType, branch, attributes);
- }
- attributes.add(attributeType);
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
- } finally {
- chStmt.close();
- }
- for (Entry<Pair<ArtifactType, Branch>, Collection<AttributeType>> entry : typeValidity.entrySet()) {
- try {
- Pair<ArtifactType, Branch> key = entry.getKey();
- key.getFirst().setAttributeTypes(entry.getValue(), key.getSecond());
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
- }
-
- @Override
- public void store(Collection<ArtifactType> types) throws OseeCoreException {
- Set<ArtifactType> typeInheritanceChanges = new HashSet<ArtifactType>();
- Set<ArtifactType> typeValidityChanges = new HashSet<ArtifactType>();
- List<Object[]> insertData = new ArrayList<Object[]>();
- List<Object[]> updateData = new ArrayList<Object[]>();
-
- for (ArtifactType type : types) {
- if (isDataDirty(type)) {
- int abstractValue = type.isAbstract() ? ABSTRACT_TYPE_INDICATOR : CONCRETE_TYPE_INDICATOR;
- switch (type.getStorageState()) {
- case CREATED:
- type.setId(getSequence().getNextArtifactTypeId());
- insertData.add(new Object[] {type.getId(), type.getGuid(), type.getName(), abstractValue});
- break;
- case MODIFIED:
- updateData.add(new Object[] {type.getName(), abstractValue, type.getId()});
- break;
- default:
- break;
- }
- }
- if (type.isFieldDirty(ArtifactType.ARTIFACT_INHERITANCE_FIELD_KEY)) {
- typeInheritanceChanges.add(type);
-
- }
- if (type.isFieldDirty(ArtifactType.ARTIFACT_TYPE_ATTRIBUTES_FIELD_KEY)) {
- typeValidityChanges.add(type);
- }
- }
- getDatabaseService().runBatchUpdate(INSERT_ARTIFACT_TYPE, insertData);
- getDatabaseService().runBatchUpdate(UPDATE_ARTIFACT_TYPE, updateData);
-
- storeArtifactTypeInheritance(typeInheritanceChanges);
- storeAttributeTypeValidity(types);
-
- for (ArtifactType type : types) {
- type.clearDirty();
- }
- }
-
- private boolean isDataDirty(ArtifactType type) throws OseeCoreException {
- return type.areFieldsDirty(AbstractOseeType.NAME_FIELD_KEY, AbstractOseeType.UNIQUE_ID_FIELD_KEY,
- ArtifactType.ARTIFACT_IS_ABSTRACT_FIELD_KEY);
- }
-
- private void storeArtifactTypeInheritance(Collection<ArtifactType> types) throws OseeDataStoreException {
- List<Object[]> insertInheritanceData = new ArrayList<Object[]>();
- List<Object[]> deleteInheritanceData = new ArrayList<Object[]>();
- for (ArtifactType type : types) {
- deleteInheritanceData.add(new Object[] {type.getId()});
- for (ArtifactType superType : type.getSuperArtifactTypes()) {
- insertInheritanceData.add(new Object[] {type.getId(), superType.getId()});
- }
- }
- getDatabaseService().runBatchUpdate(DELETE_ARTIFACT_TYPE_INHERITANCE, deleteInheritanceData);
- getDatabaseService().runBatchUpdate(INSERT_ARTIFACT_TYPE_INHERITANCE, insertInheritanceData);
- }
-
- private void storeAttributeTypeValidity(Collection<ArtifactType> types) throws OseeCoreException {
- List<Object[]> insertData = new ArrayList<Object[]>();
- List<Object[]> deleteData = new ArrayList<Object[]>();
- for (ArtifactType artifactType : types) {
- deleteData.add(new Object[] {artifactType.getId()});
- Map<Branch, Collection<AttributeType>> entries = artifactType.getLocalAttributeTypes();
- if (entries != null) {
- for (Entry<Branch, Collection<AttributeType>> entry : entries.entrySet()) {
- Branch branch = entry.getKey();
- for (AttributeType attributeType : entry.getValue()) {
- insertData.add(new Object[] {artifactType.getId(), attributeType.getId(), branch.getId()});
- }
- }
- }
- }
- getDatabaseService().runBatchUpdate(DELETE_ARTIFACT_TYPE_ATTRIBUTES, deleteData);
- getDatabaseService().runBatchUpdate(INSERT_ARTIFACT_TYPE_ATTRIBUTES, insertData);
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009 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.core.datastore.cache;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.datastore.internal.Activator;
+import org.eclipse.osee.framework.core.enums.StorageState;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.core.exception.OseeInvalidInheritanceException;
+import org.eclipse.osee.framework.core.model.AbstractOseeType;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.cache.ArtifactTypeCache;
+import org.eclipse.osee.framework.core.model.cache.AttributeTypeCache;
+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.type.ArtifactType;
+import org.eclipse.osee.framework.core.model.type.ArtifactTypeFactory;
+import org.eclipse.osee.framework.core.model.type.AttributeType;
+import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
+import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap;
+import org.eclipse.osee.framework.jdk.core.type.HashCollection;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class DatabaseArtifactTypeAccessor extends AbstractDatabaseAccessor<ArtifactType> {
+ protected static final int ABSTRACT_TYPE_INDICATOR = 1;
+ protected static final int CONCRETE_TYPE_INDICATOR = 0;
+
+ private static final String SELECT_ARTIFACT_TYPES = "select * from osee_artifact_type";
+ private static final String INSERT_ARTIFACT_TYPE =
+ "insert into osee_artifact_type (art_type_id, art_type_guid, name, is_abstract) VALUES (?,?,?,?)";
+
+ private static final String UPDATE_ARTIFACT_TYPE =
+ "update osee_artifact_type SET name = ?, is_abstract = ? where art_type_id = ?";
+
+ private static final String SELECT_ARTIFACT_TYPE_INHERITANCE =
+ "select * from osee_artifact_type_inheritance order by super_art_type_id, art_type_id";
+ private static final String INSERT_ARTIFACT_TYPE_INHERITANCE =
+ "insert into osee_artifact_type_inheritance (art_type_id, super_art_type_id) VALUES (?,?)";
+ private static final String DELETE_ARTIFACT_TYPE_INHERITANCE =
+ "delete from osee_artifact_type_inheritance where art_type_id = ?";
+
+ private static final String SELECT_ARTIFACT_TYPE_ATTRIBUTES =
+ "select * from osee_artifact_type_attributes order by art_type_id, branch_id, attr_type_id";
+ private static final String INSERT_ARTIFACT_TYPE_ATTRIBUTES =
+ "insert into osee_artifact_type_attributes (art_type_id, attr_type_id, branch_id) VALUES (?, ?, ?)";
+ private static final String DELETE_ARTIFACT_TYPE_ATTRIBUTES =
+ "delete from osee_artifact_type_attributes where art_type_id = ?";
+
+ private final AttributeTypeCache attributeCache;
+ private final BranchCache branchCache;
+
+ public DatabaseArtifactTypeAccessor(IOseeDatabaseServiceProvider databaseProvider, IOseeModelFactoryServiceProvider factoryProvider, BranchCache branchCache, AttributeTypeCache attributeCache) {
+ super(databaseProvider, factoryProvider);
+ this.attributeCache = attributeCache;
+ this.branchCache = branchCache;
+ }
+
+ @Override
+ public void load(IOseeCache<ArtifactType> cache) throws OseeCoreException {
+ attributeCache.ensurePopulated();
+ Set<ArtifactType> loadedTypes = new HashSet<ArtifactType>();
+ ArtifactTypeCache artCache = (ArtifactTypeCache) cache;
+ loadArtifactTypes(artCache, loadedTypes);
+ loadTypeInheritance(artCache);
+ loadAllTypeValidity(artCache);
+ for (ArtifactType type : loadedTypes) {
+ type.clearDirty();
+ }
+ }
+
+ private void loadArtifactTypes(ArtifactTypeCache cache, Set<ArtifactType> loadedTypes) throws OseeCoreException {
+ ArtifactTypeFactory factory = getFactoryService().getArtifactTypeFactory();
+
+ IOseeStatement chStmt = getDatabaseService().getStatement();
+ try {
+ chStmt.runPreparedQuery(SELECT_ARTIFACT_TYPES);
+
+ while (chStmt.next()) {
+ try {
+ int artTypeId = chStmt.getInt("art_type_id");
+ boolean isAbstract = chStmt.getInt("is_abstract") == ABSTRACT_TYPE_INDICATOR;
+ String artifactTypeName = chStmt.getString("name");
+ String guid = chStmt.getString("art_type_guid");
+
+ ArtifactType artifactType =
+ factory.createOrUpdate(cache, artTypeId, StorageState.LOADED, guid, isAbstract, artifactTypeName);
+ loadedTypes.add(artifactType);
+ } catch (OseeDataStoreException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+ } finally {
+ chStmt.close();
+ }
+ }
+
+ private void loadTypeInheritance(ArtifactTypeCache cache) throws OseeCoreException {
+ IOseeStatement chStmt2 = getDatabaseService().getStatement();
+ try {
+ chStmt2.runPreparedQuery(SELECT_ARTIFACT_TYPE_INHERITANCE);
+ HashCollection<ArtifactType, ArtifactType> baseToSuperTypes =
+ new HashCollection<ArtifactType, ArtifactType>(false, HashSet.class);
+
+ while (chStmt2.next()) {
+ int artTypeId = chStmt2.getInt("art_type_id");
+ int superArtTypeId = chStmt2.getInt("super_art_type_id");
+ ArtifactType baseArtType = cache.getById(artTypeId);
+ ArtifactType superArtType = cache.getById(superArtTypeId);
+
+ if (baseArtType == null) {
+ throw new OseeInvalidInheritanceException(String.format(
+ "ArtifactType [%s] which inherits from [%s] is null", artTypeId, superArtType));
+ }
+ if (superArtType == null) {
+ throw new OseeInvalidInheritanceException(String.format(
+ "ArtifactType [%s] which inherits from null artifact [%s]", artTypeId, superArtType));
+ }
+ baseToSuperTypes.put(baseArtType, superArtType);
+ }
+ for (ArtifactType artifactType : baseToSuperTypes.keySet()) {
+ Set<ArtifactType> superTypes = (Set<ArtifactType>) baseToSuperTypes.getValues(artifactType);
+ if (superTypes != null) {
+ artifactType.setSuperTypes(superTypes);
+ }
+ }
+ } finally {
+ chStmt2.close();
+ }
+ }
+
+ private void loadAllTypeValidity(ArtifactTypeCache cache) throws OseeCoreException {
+ CompositeKeyHashMap<ArtifactType, Branch, Collection<AttributeType>> typeValidity =
+ new CompositeKeyHashMap<ArtifactType, Branch, Collection<AttributeType>>();
+ IOseeStatement chStmt = getDatabaseService().getStatement();
+ try {
+ chStmt.runPreparedQuery(2000, SELECT_ARTIFACT_TYPE_ATTRIBUTES);
+ while (chStmt.next()) {
+ try {
+ ArtifactType artifactType = cache.getById(chStmt.getInt("art_type_id"));
+ Branch branch = branchCache.getById(chStmt.getInt("branch_id"));
+ AttributeType attributeType = attributeCache.getById(chStmt.getInt("attr_type_id"));
+ Collection<AttributeType> attributes = typeValidity.get(artifactType, branch);
+ if (attributes == null) {
+ attributes = new HashSet<AttributeType>();
+ typeValidity.put(artifactType, branch, attributes);
+ }
+ attributes.add(attributeType);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+ } finally {
+ chStmt.close();
+ }
+ for (Entry<Pair<ArtifactType, Branch>, Collection<AttributeType>> entry : typeValidity.entrySet()) {
+ try {
+ Pair<ArtifactType, Branch> key = entry.getKey();
+ key.getFirst().setAttributeTypes(entry.getValue(), key.getSecond());
+ } catch (OseeCoreException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+ }
+
+ @Override
+ public void store(Collection<ArtifactType> types) throws OseeCoreException {
+ Set<ArtifactType> typeInheritanceChanges = new HashSet<ArtifactType>();
+ Set<ArtifactType> typeValidityChanges = new HashSet<ArtifactType>();
+ List<Object[]> insertData = new ArrayList<Object[]>();
+ List<Object[]> updateData = new ArrayList<Object[]>();
+
+ for (ArtifactType type : types) {
+ if (isDataDirty(type)) {
+ int abstractValue = type.isAbstract() ? ABSTRACT_TYPE_INDICATOR : CONCRETE_TYPE_INDICATOR;
+ switch (type.getStorageState()) {
+ case CREATED:
+ type.setId(getSequence().getNextArtifactTypeId());
+ insertData.add(new Object[] {type.getId(), type.getGuid(), type.getName(), abstractValue});
+ break;
+ case MODIFIED:
+ updateData.add(new Object[] {type.getName(), abstractValue, type.getId()});
+ break;
+ default:
+ break;
+ }
+ }
+ if (type.isFieldDirty(ArtifactType.ARTIFACT_INHERITANCE_FIELD_KEY)) {
+ typeInheritanceChanges.add(type);
+
+ }
+ if (type.isFieldDirty(ArtifactType.ARTIFACT_TYPE_ATTRIBUTES_FIELD_KEY)) {
+ typeValidityChanges.add(type);
+ }
+ }
+ getDatabaseService().runBatchUpdate(INSERT_ARTIFACT_TYPE, insertData);
+ getDatabaseService().runBatchUpdate(UPDATE_ARTIFACT_TYPE, updateData);
+
+ storeArtifactTypeInheritance(typeInheritanceChanges);
+ storeAttributeTypeValidity(types);
+
+ for (ArtifactType type : types) {
+ type.clearDirty();
+ }
+ }
+
+ private boolean isDataDirty(ArtifactType type) throws OseeCoreException {
+ return type.areFieldsDirty(AbstractOseeType.NAME_FIELD_KEY, AbstractOseeType.UNIQUE_ID_FIELD_KEY,
+ ArtifactType.ARTIFACT_IS_ABSTRACT_FIELD_KEY);
+ }
+
+ private void storeArtifactTypeInheritance(Collection<ArtifactType> types) throws OseeDataStoreException {
+ List<Object[]> insertInheritanceData = new ArrayList<Object[]>();
+ List<Object[]> deleteInheritanceData = new ArrayList<Object[]>();
+ for (ArtifactType type : types) {
+ deleteInheritanceData.add(new Object[] {type.getId()});
+ for (ArtifactType superType : type.getSuperArtifactTypes()) {
+ insertInheritanceData.add(new Object[] {type.getId(), superType.getId()});
+ }
+ }
+ getDatabaseService().runBatchUpdate(DELETE_ARTIFACT_TYPE_INHERITANCE, deleteInheritanceData);
+ getDatabaseService().runBatchUpdate(INSERT_ARTIFACT_TYPE_INHERITANCE, insertInheritanceData);
+ }
+
+ private void storeAttributeTypeValidity(Collection<ArtifactType> types) throws OseeCoreException {
+ List<Object[]> insertData = new ArrayList<Object[]>();
+ List<Object[]> deleteData = new ArrayList<Object[]>();
+ for (ArtifactType artifactType : types) {
+ deleteData.add(new Object[] {artifactType.getId()});
+ Map<Branch, Collection<AttributeType>> entries = artifactType.getLocalAttributeTypes();
+ if (entries != null) {
+ for (Entry<Branch, Collection<AttributeType>> entry : entries.entrySet()) {
+ Branch branch = entry.getKey();
+ for (AttributeType attributeType : entry.getValue()) {
+ insertData.add(new Object[] {artifactType.getId(), attributeType.getId(), branch.getId()});
+ }
+ }
+ }
+ }
+ getDatabaseService().runBatchUpdate(DELETE_ARTIFACT_TYPE_ATTRIBUTES, deleteData);
+ getDatabaseService().runBatchUpdate(INSERT_ARTIFACT_TYPE_ATTRIBUTES, insertData);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseAttributeTypeAccessor.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseAttributeTypeAccessor.java
index 12219ca47f..2683afc78d 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseAttributeTypeAccessor.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseAttributeTypeAccessor.java
@@ -1,189 +1,189 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.core.datastore.cache;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.core.datastore.internal.Activator;
-import org.eclipse.osee.framework.core.enums.StorageState;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.core.model.cache.IOseeCache;
-import org.eclipse.osee.framework.core.model.cache.OseeEnumTypeCache;
-import org.eclipse.osee.framework.core.model.type.AttributeType;
-import org.eclipse.osee.framework.core.model.type.AttributeTypeFactory;
-import org.eclipse.osee.framework.core.model.type.OseeEnumType;
-import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
-import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
-import org.eclipse.osee.framework.database.core.IOseeStatement;
-import org.eclipse.osee.framework.database.core.SQL3DataType;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Roberto E. Escobar
- */
-public class DatabaseAttributeTypeAccessor extends AbstractDatabaseAccessor<AttributeType> {
-
- private static final String SELECT_ATTRIBUTE_TYPES =
- "SELECT * FROM osee_attribute_type aty1, osee_attribute_base_type aby1, osee_attribute_provider_type apy1 WHERE aty1.attr_base_type_id = aby1.attr_base_type_id AND aty1.attr_provider_type_id = apy1.attr_provider_type_id";
- private static final String INSERT_ATTRIBUTE_TYPE =
- "INSERT INTO osee_attribute_type (attr_type_id, attr_type_guid, attr_base_type_id, attr_provider_type_id, file_type_extension, name, default_value, enum_type_id, min_occurence, max_occurence, tip_text, tagger_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
- private static final String UPDATE_ATTRIBUTE_TYPE =
- "update osee_attribute_type SET attr_base_type_id=?, attr_provider_type_id=?, file_type_extension=?, name=?, default_value=?, enum_type_id=?, min_occurence=?, max_occurence=?, tip_text=?, tagger_id=? where attr_type_id = ?";
-
- private static final String INSERT_BASE_ATTRIBUTE_TYPE =
- "INSERT INTO osee_attribute_base_type (attr_base_type_id, attribute_class) VALUES (?, ?)";
- private static final String INSERT_ATTRIBUTE_PROVIDER_TYPE =
- "INSERT INTO osee_attribute_provider_type (attr_provider_type_id, attribute_provider_class) VALUES (?, ?)";
- private static final String SELECT_ATTRIBUTE_BASE_TYPE =
- "SELECT attr_base_type_id FROM osee_attribute_base_type WHERE attribute_class = ?";
- private static final String SELECT_ATTRIBUTE_PROVIDER_TYPE =
- "SELECT attr_provider_type_id FROM osee_attribute_provider_type WHERE attribute_provider_class = ?";
-
- private final OseeEnumTypeCache enumCache;
-
- public DatabaseAttributeTypeAccessor(IOseeDatabaseServiceProvider databaseProvider, IOseeModelFactoryServiceProvider factoryProvider, OseeEnumTypeCache enumCache) {
- super(databaseProvider, factoryProvider);
- this.enumCache = enumCache;
- }
-
- @Override
- public void load(IOseeCache<AttributeType> cache) throws OseeCoreException {
- enumCache.ensurePopulated();
-
- AttributeTypeFactory factory = getFactoryService().getAttributeTypeFactory();
- IOseeStatement chStmt = getDatabaseService().getStatement();
-
- try {
- chStmt.runPreparedQuery(SELECT_ATTRIBUTE_TYPES);
-
- while (chStmt.next()) {
- int attributeTypeId = chStmt.getInt("attr_type_id");
- String baseAttributeTypeId = Strings.intern(chStmt.getString("attribute_class"));
- String attributeProviderNameId = Strings.intern(chStmt.getString("attribute_provider_class"));
- try {
- String guid = chStmt.getString("attr_type_guid");
- String typeName = chStmt.getString("name");
- String fileTypeExtension = Strings.intern(chStmt.getString("file_type_extension"));
- String defaultValue = chStmt.getString("default_value");
- int minOccurrences = chStmt.getInt("min_occurence");
- int maxOccurrences = chStmt.getInt("max_occurence");
- String description = chStmt.getString("tip_text");
- String taggerId = Strings.intern(chStmt.getString("tagger_id"));
-
- int enumTypeId = chStmt.getInt("enum_type_id");
- OseeEnumType oseeEnumType = enumCache.getById(enumTypeId);
-
- AttributeType attributeType =
- factory.createOrUpdate(cache, attributeTypeId, StorageState.LOADED, guid, typeName,
- baseAttributeTypeId, attributeProviderNameId, fileTypeExtension, defaultValue, oseeEnumType,
- minOccurrences, maxOccurrences, description, taggerId);
-
- attributeType.clearDirty();
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
- } finally {
- chStmt.close();
- }
- }
-
- @Override
- public void store(Collection<AttributeType> types) throws OseeCoreException {
- List<Object[]> insertData = new ArrayList<Object[]>();
- List<Object[]> updateData = new ArrayList<Object[]>();
- for (AttributeType type : types) {
- if (type.isDirty()) {
- switch (type.getStorageState()) {
- case CREATED:
- type.setId(getSequence().getNextAttributeTypeId());
- insertData.add(toInsertValues(type));
- break;
- case MODIFIED:
- updateData.add(toUpdateValues(type));
- break;
- default:
- break;
- }
- }
- }
- getDatabaseService().runBatchUpdate(INSERT_ATTRIBUTE_TYPE, insertData);
- getDatabaseService().runBatchUpdate(UPDATE_ATTRIBUTE_TYPE, updateData);
- for (AttributeType type : types) {
- type.clearDirty();
- }
- }
-
- private Object[] toInsertValues(AttributeType type) throws OseeDataStoreException {
- int attrBaseTypeId = getOrCreateAttributeBaseType(type.getBaseAttributeTypeId());
- int attrProviderTypeId = getOrCreateAttributeProviderType(type.getAttributeProviderId());
- return new Object[] {type.getId(), type.getGuid(), attrBaseTypeId, attrProviderTypeId,
- type.getFileTypeExtension() == null ? SQL3DataType.VARCHAR : type.getFileTypeExtension(),
- type.getName() == null ? SQL3DataType.VARCHAR : type.getName(),
- type.getDefaultValue() == null ? SQL3DataType.VARCHAR : type.getDefaultValue(), type.getOseeEnumTypeId(),
- type.getMinOccurrences(), type.getMaxOccurrences(),
- type.getDescription() == null ? SQL3DataType.VARCHAR : type.getDescription(),
- type.getTaggerId() == null ? SQL3DataType.VARCHAR : type.getTaggerId()};
- }
-
- private Object[] toUpdateValues(AttributeType type) throws OseeDataStoreException {
- int attrBaseTypeId = getOrCreateAttributeBaseType(type.getBaseAttributeTypeId());
- int attrProviderTypeId = getOrCreateAttributeProviderType(type.getAttributeProviderId());
- return new Object[] {attrBaseTypeId, attrProviderTypeId,
- type.getFileTypeExtension() == null ? SQL3DataType.VARCHAR : type.getFileTypeExtension(),
- type.getName() == null ? SQL3DataType.VARCHAR : type.getName(),
- type.getDefaultValue() == null ? SQL3DataType.VARCHAR : type.getDefaultValue(), type.getOseeEnumTypeId(),
- type.getMinOccurrences(), type.getMaxOccurrences(),
- type.getDescription() == null ? SQL3DataType.VARCHAR : type.getDescription(),
- type.getTaggerId() == null ? SQL3DataType.VARCHAR : type.getTaggerId(), type.getId()};
- }
-
- @SuppressWarnings("unchecked")
- private int getOrCreateAttributeProviderType(String attrProviderExtension) throws OseeDataStoreException {
- int attrBaseTypeId = -1;
- IOseeStatement chStmt = getDatabaseService().getStatement();
- try {
- chStmt.runPreparedQuery(SELECT_ATTRIBUTE_PROVIDER_TYPE, attrProviderExtension);
- if (chStmt.next()) {
- attrBaseTypeId = chStmt.getInt("attr_provider_type_id");
- } else {
- attrBaseTypeId = getSequence().getNextAttributeProviderTypeId();
- getDatabaseService().runPreparedUpdate(INSERT_ATTRIBUTE_PROVIDER_TYPE, attrBaseTypeId,
- attrProviderExtension);
- }
- } finally {
- chStmt.close();
- }
- return attrBaseTypeId;
- }
-
- @SuppressWarnings("unchecked")
- private int getOrCreateAttributeBaseType(String attrBaseExtension) throws OseeDataStoreException {
- int attrBaseTypeId = -1;
- IOseeStatement chStmt = getDatabaseService().getStatement();
- try {
- chStmt.runPreparedQuery(SELECT_ATTRIBUTE_BASE_TYPE, attrBaseExtension);
- if (chStmt.next()) {
- attrBaseTypeId = chStmt.getInt("attr_base_type_id");
- } else {
- attrBaseTypeId = getSequence().getNextAttributeBaseTypeId();
- getDatabaseService().runPreparedUpdate(INSERT_BASE_ATTRIBUTE_TYPE, attrBaseTypeId, attrBaseExtension);
- }
- } finally {
- chStmt.close();
- }
- return attrBaseTypeId;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009 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.core.datastore.cache;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.datastore.internal.Activator;
+import org.eclipse.osee.framework.core.enums.StorageState;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.core.model.cache.IOseeCache;
+import org.eclipse.osee.framework.core.model.cache.OseeEnumTypeCache;
+import org.eclipse.osee.framework.core.model.type.AttributeType;
+import org.eclipse.osee.framework.core.model.type.AttributeTypeFactory;
+import org.eclipse.osee.framework.core.model.type.OseeEnumType;
+import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
+import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.database.core.SQL3DataType;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class DatabaseAttributeTypeAccessor extends AbstractDatabaseAccessor<AttributeType> {
+
+ private static final String SELECT_ATTRIBUTE_TYPES =
+ "SELECT * FROM osee_attribute_type aty1, osee_attribute_base_type aby1, osee_attribute_provider_type apy1 WHERE aty1.attr_base_type_id = aby1.attr_base_type_id AND aty1.attr_provider_type_id = apy1.attr_provider_type_id";
+ private static final String INSERT_ATTRIBUTE_TYPE =
+ "INSERT INTO osee_attribute_type (attr_type_id, attr_type_guid, attr_base_type_id, attr_provider_type_id, file_type_extension, name, default_value, enum_type_id, min_occurence, max_occurence, tip_text, tagger_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
+ private static final String UPDATE_ATTRIBUTE_TYPE =
+ "update osee_attribute_type SET attr_base_type_id=?, attr_provider_type_id=?, file_type_extension=?, name=?, default_value=?, enum_type_id=?, min_occurence=?, max_occurence=?, tip_text=?, tagger_id=? where attr_type_id = ?";
+
+ private static final String INSERT_BASE_ATTRIBUTE_TYPE =
+ "INSERT INTO osee_attribute_base_type (attr_base_type_id, attribute_class) VALUES (?, ?)";
+ private static final String INSERT_ATTRIBUTE_PROVIDER_TYPE =
+ "INSERT INTO osee_attribute_provider_type (attr_provider_type_id, attribute_provider_class) VALUES (?, ?)";
+ private static final String SELECT_ATTRIBUTE_BASE_TYPE =
+ "SELECT attr_base_type_id FROM osee_attribute_base_type WHERE attribute_class = ?";
+ private static final String SELECT_ATTRIBUTE_PROVIDER_TYPE =
+ "SELECT attr_provider_type_id FROM osee_attribute_provider_type WHERE attribute_provider_class = ?";
+
+ private final OseeEnumTypeCache enumCache;
+
+ public DatabaseAttributeTypeAccessor(IOseeDatabaseServiceProvider databaseProvider, IOseeModelFactoryServiceProvider factoryProvider, OseeEnumTypeCache enumCache) {
+ super(databaseProvider, factoryProvider);
+ this.enumCache = enumCache;
+ }
+
+ @Override
+ public void load(IOseeCache<AttributeType> cache) throws OseeCoreException {
+ enumCache.ensurePopulated();
+
+ AttributeTypeFactory factory = getFactoryService().getAttributeTypeFactory();
+ IOseeStatement chStmt = getDatabaseService().getStatement();
+
+ try {
+ chStmt.runPreparedQuery(SELECT_ATTRIBUTE_TYPES);
+
+ while (chStmt.next()) {
+ int attributeTypeId = chStmt.getInt("attr_type_id");
+ String baseAttributeTypeId = Strings.intern(chStmt.getString("attribute_class"));
+ String attributeProviderNameId = Strings.intern(chStmt.getString("attribute_provider_class"));
+ try {
+ String guid = chStmt.getString("attr_type_guid");
+ String typeName = chStmt.getString("name");
+ String fileTypeExtension = Strings.intern(chStmt.getString("file_type_extension"));
+ String defaultValue = chStmt.getString("default_value");
+ int minOccurrences = chStmt.getInt("min_occurence");
+ int maxOccurrences = chStmt.getInt("max_occurence");
+ String description = chStmt.getString("tip_text");
+ String taggerId = Strings.intern(chStmt.getString("tagger_id"));
+
+ int enumTypeId = chStmt.getInt("enum_type_id");
+ OseeEnumType oseeEnumType = enumCache.getById(enumTypeId);
+
+ AttributeType attributeType =
+ factory.createOrUpdate(cache, attributeTypeId, StorageState.LOADED, guid, typeName,
+ baseAttributeTypeId, attributeProviderNameId, fileTypeExtension, defaultValue, oseeEnumType,
+ minOccurrences, maxOccurrences, description, taggerId);
+
+ attributeType.clearDirty();
+ } catch (OseeCoreException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+ } finally {
+ chStmt.close();
+ }
+ }
+
+ @Override
+ public void store(Collection<AttributeType> types) throws OseeCoreException {
+ List<Object[]> insertData = new ArrayList<Object[]>();
+ List<Object[]> updateData = new ArrayList<Object[]>();
+ for (AttributeType type : types) {
+ if (type.isDirty()) {
+ switch (type.getStorageState()) {
+ case CREATED:
+ type.setId(getSequence().getNextAttributeTypeId());
+ insertData.add(toInsertValues(type));
+ break;
+ case MODIFIED:
+ updateData.add(toUpdateValues(type));
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ getDatabaseService().runBatchUpdate(INSERT_ATTRIBUTE_TYPE, insertData);
+ getDatabaseService().runBatchUpdate(UPDATE_ATTRIBUTE_TYPE, updateData);
+ for (AttributeType type : types) {
+ type.clearDirty();
+ }
+ }
+
+ private Object[] toInsertValues(AttributeType type) throws OseeDataStoreException {
+ int attrBaseTypeId = getOrCreateAttributeBaseType(type.getBaseAttributeTypeId());
+ int attrProviderTypeId = getOrCreateAttributeProviderType(type.getAttributeProviderId());
+ return new Object[] {type.getId(), type.getGuid(), attrBaseTypeId, attrProviderTypeId,
+ type.getFileTypeExtension() == null ? SQL3DataType.VARCHAR : type.getFileTypeExtension(),
+ type.getName() == null ? SQL3DataType.VARCHAR : type.getName(),
+ type.getDefaultValue() == null ? SQL3DataType.VARCHAR : type.getDefaultValue(), type.getOseeEnumTypeId(),
+ type.getMinOccurrences(), type.getMaxOccurrences(),
+ type.getDescription() == null ? SQL3DataType.VARCHAR : type.getDescription(),
+ type.getTaggerId() == null ? SQL3DataType.VARCHAR : type.getTaggerId()};
+ }
+
+ private Object[] toUpdateValues(AttributeType type) throws OseeDataStoreException {
+ int attrBaseTypeId = getOrCreateAttributeBaseType(type.getBaseAttributeTypeId());
+ int attrProviderTypeId = getOrCreateAttributeProviderType(type.getAttributeProviderId());
+ return new Object[] {attrBaseTypeId, attrProviderTypeId,
+ type.getFileTypeExtension() == null ? SQL3DataType.VARCHAR : type.getFileTypeExtension(),
+ type.getName() == null ? SQL3DataType.VARCHAR : type.getName(),
+ type.getDefaultValue() == null ? SQL3DataType.VARCHAR : type.getDefaultValue(), type.getOseeEnumTypeId(),
+ type.getMinOccurrences(), type.getMaxOccurrences(),
+ type.getDescription() == null ? SQL3DataType.VARCHAR : type.getDescription(),
+ type.getTaggerId() == null ? SQL3DataType.VARCHAR : type.getTaggerId(), type.getId()};
+ }
+
+ @SuppressWarnings("unchecked")
+ private int getOrCreateAttributeProviderType(String attrProviderExtension) throws OseeDataStoreException {
+ int attrBaseTypeId = -1;
+ IOseeStatement chStmt = getDatabaseService().getStatement();
+ try {
+ chStmt.runPreparedQuery(SELECT_ATTRIBUTE_PROVIDER_TYPE, attrProviderExtension);
+ if (chStmt.next()) {
+ attrBaseTypeId = chStmt.getInt("attr_provider_type_id");
+ } else {
+ attrBaseTypeId = getSequence().getNextAttributeProviderTypeId();
+ getDatabaseService().runPreparedUpdate(INSERT_ATTRIBUTE_PROVIDER_TYPE, attrBaseTypeId,
+ attrProviderExtension);
+ }
+ } finally {
+ chStmt.close();
+ }
+ return attrBaseTypeId;
+ }
+
+ @SuppressWarnings("unchecked")
+ private int getOrCreateAttributeBaseType(String attrBaseExtension) throws OseeDataStoreException {
+ int attrBaseTypeId = -1;
+ IOseeStatement chStmt = getDatabaseService().getStatement();
+ try {
+ chStmt.runPreparedQuery(SELECT_ATTRIBUTE_BASE_TYPE, attrBaseExtension);
+ if (chStmt.next()) {
+ attrBaseTypeId = chStmt.getInt("attr_base_type_id");
+ } else {
+ attrBaseTypeId = getSequence().getNextAttributeBaseTypeId();
+ getDatabaseService().runPreparedUpdate(INSERT_BASE_ATTRIBUTE_TYPE, attrBaseTypeId, attrBaseExtension);
+ }
+ } finally {
+ chStmt.close();
+ }
+ return attrBaseTypeId;
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseBranchAccessor.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseBranchAccessor.java
index eeaf75fd06..a94e9d0a50 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseBranchAccessor.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseBranchAccessor.java
@@ -1,182 +1,182 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.core.datastore.cache;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.logging.Level;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.osee.framework.core.datastore.internal.Activator;
-import org.eclipse.osee.framework.core.enums.BranchArchivedState;
-import org.eclipse.osee.framework.core.enums.BranchState;
-import org.eclipse.osee.framework.core.enums.BranchType;
-import org.eclipse.osee.framework.core.enums.StorageState;
-import org.eclipse.osee.framework.core.exception.BranchDoesNotExist;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.core.model.BranchFactory;
-import org.eclipse.osee.framework.core.model.MergeBranch;
-import org.eclipse.osee.framework.core.model.TransactionRecord;
-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.TransactionCache;
-import org.eclipse.osee.framework.core.operation.Operations;
-import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
-import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
-import org.eclipse.osee.framework.database.core.IOseeStatement;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Roberto E. Escobar
- */
-public class DatabaseBranchAccessor extends AbstractDatabaseAccessor<Branch> {
-
- private static final String SELECT_BRANCHES = "SELECT * FROM osee_branch";
- private static final String SELECT_MERGE_BRANCHES = "SELECT * FROM osee_merge";
-
- private final TransactionCache txCache;
- private final IBranchUpdateEvent eventSender;
-
- public DatabaseBranchAccessor(IOseeDatabaseServiceProvider databaseProvider, IOseeModelFactoryServiceProvider factoryProvider, IBranchUpdateEvent eventSender, TransactionCache txCache) {
- super(databaseProvider, factoryProvider);
- this.txCache = txCache;
- this.eventSender = eventSender;
- }
-
- @Override
- public void load(IOseeCache<Branch> cache) throws OseeCoreException {
- long startTime = System.currentTimeMillis();
- Map<Branch, Integer> childToParent = new HashMap<Branch, Integer>();
- Map<Branch, Integer> branchToBaseTx = new HashMap<Branch, Integer>();
- Map<Branch, Integer> branchToSourceTx = new HashMap<Branch, Integer>();
- Map<Branch, Integer> associatedArtifact = new HashMap<Branch, Integer>();
-
- BranchCache brCache = (BranchCache) cache;
- loadBranches(brCache, childToParent, branchToBaseTx, branchToSourceTx, associatedArtifact);
- loadBranchHierarchy(brCache, childToParent);
- loadMergeBranches(brCache);
- loadAssociatedArtifacts(brCache, associatedArtifact);
- loadBranchRelatedTransactions(brCache, branchToBaseTx, branchToSourceTx);
-
- for (Branch branch : cache.getAll()) {
- branch.clearDirty();
- }
- OseeLog.log(Activator.class, Level.INFO,
- String.format("Branch Cache loaded [%s]", Lib.getElapseString(startTime)));
- }
-
- private void loadBranches(BranchCache cache, Map<Branch, Integer> childToParent, Map<Branch, Integer> branchToBaseTx, Map<Branch, Integer> branchToSourceTx, Map<Branch, Integer> associatedArtifact) throws OseeCoreException {
- BranchFactory factory = getFactoryService().getBranchFactory();
- IOseeStatement chStmt = getDatabaseService().getStatement();
- try {
- chStmt.runPreparedQuery(2000, SELECT_BRANCHES);
- while (chStmt.next()) {
- try {
- int branchId = chStmt.getInt("branch_id");
-
- String branchName = chStmt.getString("branch_name");
- BranchState branchState = BranchState.getBranchState(chStmt.getInt("branch_state"));
- BranchType branchType = BranchType.valueOf(chStmt.getInt("branch_type"));
- boolean isArchived = BranchArchivedState.valueOf(chStmt.getInt("archived")).isArchived();
- String branchGuid = chStmt.getString("branch_guid");
- Branch branch =
- factory.createOrUpdate(cache, branchId, StorageState.LOADED, branchGuid, branchName, branchType,
- branchState, isArchived);
-
- Integer parentBranchId = chStmt.getInt("parent_branch_id");
- if (parentBranchId != BranchStoreOperation.NULL_PARENT_BRANCH_ID) {
- childToParent.put(branch, parentBranchId);
- }
- branchToSourceTx.put(branch, chStmt.getInt("parent_transaction_id"));
- branchToBaseTx.put(branch, chStmt.getInt("baseline_transaction_id"));
- associatedArtifact.put(branch, chStmt.getInt("associated_art_id"));
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
- } finally {
- chStmt.close();
- }
- }
-
- private void loadAssociatedArtifacts(BranchCache cache, Map<Branch, Integer> associatedArtifact) throws OseeCoreException {
- for (Entry<Branch, Integer> entry : associatedArtifact.entrySet()) {
- Branch branch = entry.getKey();
- branch.setAssociatedArtifactId(entry.getValue());
- }
- }
-
- private void loadBranchRelatedTransactions(BranchCache cache, Map<Branch, Integer> branchToBaseTx, Map<Branch, Integer> branchToSourceTx) throws OseeCoreException {
- Set<Integer> transactionIds = new HashSet<Integer>();
- transactionIds.addAll(branchToSourceTx.values());
- transactionIds.addAll(branchToBaseTx.values());
- txCache.loadTransactions(transactionIds);
-
- for (Entry<Branch, Integer> entry : branchToBaseTx.entrySet()) {
- Branch branch = entry.getKey();
- if (branch.getBaseTransaction() == null) {
- TransactionRecord baseTx = txCache.getById(entry.getValue());
- branch.setBaseTransaction(baseTx);
- }
- }
-
- for (Entry<Branch, Integer> entry : branchToSourceTx.entrySet()) {
- Branch branch = entry.getKey();
- if (branch.getSourceTransaction() == null) {
- TransactionRecord srcTx = txCache.getById(entry.getValue());
- branch.setSourceTransaction(srcTx);
- }
- }
- }
-
- private void loadBranchHierarchy(BranchCache branchCache, Map<Branch, Integer> childToParent) throws OseeCoreException {
- for (Entry<Branch, Integer> entry : childToParent.entrySet()) {
- Branch childBranch = entry.getKey();
- Branch parentBranch = branchCache.getById(entry.getValue());
- if (parentBranch == null) {
- throw new BranchDoesNotExist(String.format("Parent Branch id:[%s] does not exist for child branch [%s]",
- entry.getValue(), entry.getKey()));
- }
- childBranch.setParentBranch(parentBranch);
- }
- }
-
- private void loadMergeBranches(BranchCache branchCache) throws OseeCoreException {
- IOseeStatement chStmt = getDatabaseService().getStatement();
- try {
- chStmt.runPreparedQuery(1000, SELECT_MERGE_BRANCHES);
- while (chStmt.next()) {
- Branch sourceBranch = branchCache.getById(chStmt.getInt("source_branch_id"));
- Branch destBranch = branchCache.getById(chStmt.getInt("dest_branch_id"));
-
- MergeBranch mergeBranch = (MergeBranch) branchCache.getById(chStmt.getInt("merge_branch_id"));
- mergeBranch.setSourceBranch(sourceBranch);
- mergeBranch.setDestinationBranch(destBranch);
- }
- } finally {
- chStmt.close();
- }
-
- }
-
- @Override
- public void store(Collection<Branch> branches) throws OseeCoreException {
- Operations.executeWorkAndCheckStatus(
- new BranchStoreOperation(getDatabaseServiceProvider(), eventSender, branches), new NullProgressMonitor(),
- -1);
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009 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.core.datastore.cache;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.logging.Level;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.osee.framework.core.datastore.internal.Activator;
+import org.eclipse.osee.framework.core.enums.BranchArchivedState;
+import org.eclipse.osee.framework.core.enums.BranchState;
+import org.eclipse.osee.framework.core.enums.BranchType;
+import org.eclipse.osee.framework.core.enums.StorageState;
+import org.eclipse.osee.framework.core.exception.BranchDoesNotExist;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.BranchFactory;
+import org.eclipse.osee.framework.core.model.MergeBranch;
+import org.eclipse.osee.framework.core.model.TransactionRecord;
+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.TransactionCache;
+import org.eclipse.osee.framework.core.operation.Operations;
+import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
+import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class DatabaseBranchAccessor extends AbstractDatabaseAccessor<Branch> {
+
+ private static final String SELECT_BRANCHES = "SELECT * FROM osee_branch";
+ private static final String SELECT_MERGE_BRANCHES = "SELECT * FROM osee_merge";
+
+ private final TransactionCache txCache;
+ private final IBranchUpdateEvent eventSender;
+
+ public DatabaseBranchAccessor(IOseeDatabaseServiceProvider databaseProvider, IOseeModelFactoryServiceProvider factoryProvider, IBranchUpdateEvent eventSender, TransactionCache txCache) {
+ super(databaseProvider, factoryProvider);
+ this.txCache = txCache;
+ this.eventSender = eventSender;
+ }
+
+ @Override
+ public void load(IOseeCache<Branch> cache) throws OseeCoreException {
+ long startTime = System.currentTimeMillis();
+ Map<Branch, Integer> childToParent = new HashMap<Branch, Integer>();
+ Map<Branch, Integer> branchToBaseTx = new HashMap<Branch, Integer>();
+ Map<Branch, Integer> branchToSourceTx = new HashMap<Branch, Integer>();
+ Map<Branch, Integer> associatedArtifact = new HashMap<Branch, Integer>();
+
+ BranchCache brCache = (BranchCache) cache;
+ loadBranches(brCache, childToParent, branchToBaseTx, branchToSourceTx, associatedArtifact);
+ loadBranchHierarchy(brCache, childToParent);
+ loadMergeBranches(brCache);
+ loadAssociatedArtifacts(brCache, associatedArtifact);
+ loadBranchRelatedTransactions(brCache, branchToBaseTx, branchToSourceTx);
+
+ for (Branch branch : cache.getAll()) {
+ branch.clearDirty();
+ }
+ OseeLog.log(Activator.class, Level.INFO,
+ String.format("Branch Cache loaded [%s]", Lib.getElapseString(startTime)));
+ }
+
+ private void loadBranches(BranchCache cache, Map<Branch, Integer> childToParent, Map<Branch, Integer> branchToBaseTx, Map<Branch, Integer> branchToSourceTx, Map<Branch, Integer> associatedArtifact) throws OseeCoreException {
+ BranchFactory factory = getFactoryService().getBranchFactory();
+ IOseeStatement chStmt = getDatabaseService().getStatement();
+ try {
+ chStmt.runPreparedQuery(2000, SELECT_BRANCHES);
+ while (chStmt.next()) {
+ try {
+ int branchId = chStmt.getInt("branch_id");
+
+ String branchName = chStmt.getString("branch_name");
+ BranchState branchState = BranchState.getBranchState(chStmt.getInt("branch_state"));
+ BranchType branchType = BranchType.valueOf(chStmt.getInt("branch_type"));
+ boolean isArchived = BranchArchivedState.valueOf(chStmt.getInt("archived")).isArchived();
+ String branchGuid = chStmt.getString("branch_guid");
+ Branch branch =
+ factory.createOrUpdate(cache, branchId, StorageState.LOADED, branchGuid, branchName, branchType,
+ branchState, isArchived);
+
+ Integer parentBranchId = chStmt.getInt("parent_branch_id");
+ if (parentBranchId != BranchStoreOperation.NULL_PARENT_BRANCH_ID) {
+ childToParent.put(branch, parentBranchId);
+ }
+ branchToSourceTx.put(branch, chStmt.getInt("parent_transaction_id"));
+ branchToBaseTx.put(branch, chStmt.getInt("baseline_transaction_id"));
+ associatedArtifact.put(branch, chStmt.getInt("associated_art_id"));
+ } catch (OseeCoreException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+ } finally {
+ chStmt.close();
+ }
+ }
+
+ private void loadAssociatedArtifacts(BranchCache cache, Map<Branch, Integer> associatedArtifact) throws OseeCoreException {
+ for (Entry<Branch, Integer> entry : associatedArtifact.entrySet()) {
+ Branch branch = entry.getKey();
+ branch.setAssociatedArtifactId(entry.getValue());
+ }
+ }
+
+ private void loadBranchRelatedTransactions(BranchCache cache, Map<Branch, Integer> branchToBaseTx, Map<Branch, Integer> branchToSourceTx) throws OseeCoreException {
+ Set<Integer> transactionIds = new HashSet<Integer>();
+ transactionIds.addAll(branchToSourceTx.values());
+ transactionIds.addAll(branchToBaseTx.values());
+ txCache.loadTransactions(transactionIds);
+
+ for (Entry<Branch, Integer> entry : branchToBaseTx.entrySet()) {
+ Branch branch = entry.getKey();
+ if (branch.getBaseTransaction() == null) {
+ TransactionRecord baseTx = txCache.getById(entry.getValue());
+ branch.setBaseTransaction(baseTx);
+ }
+ }
+
+ for (Entry<Branch, Integer> entry : branchToSourceTx.entrySet()) {
+ Branch branch = entry.getKey();
+ if (branch.getSourceTransaction() == null) {
+ TransactionRecord srcTx = txCache.getById(entry.getValue());
+ branch.setSourceTransaction(srcTx);
+ }
+ }
+ }
+
+ private void loadBranchHierarchy(BranchCache branchCache, Map<Branch, Integer> childToParent) throws OseeCoreException {
+ for (Entry<Branch, Integer> entry : childToParent.entrySet()) {
+ Branch childBranch = entry.getKey();
+ Branch parentBranch = branchCache.getById(entry.getValue());
+ if (parentBranch == null) {
+ throw new BranchDoesNotExist(String.format("Parent Branch id:[%s] does not exist for child branch [%s]",
+ entry.getValue(), entry.getKey()));
+ }
+ childBranch.setParentBranch(parentBranch);
+ }
+ }
+
+ private void loadMergeBranches(BranchCache branchCache) throws OseeCoreException {
+ IOseeStatement chStmt = getDatabaseService().getStatement();
+ try {
+ chStmt.runPreparedQuery(1000, SELECT_MERGE_BRANCHES);
+ while (chStmt.next()) {
+ Branch sourceBranch = branchCache.getById(chStmt.getInt("source_branch_id"));
+ Branch destBranch = branchCache.getById(chStmt.getInt("dest_branch_id"));
+
+ MergeBranch mergeBranch = (MergeBranch) branchCache.getById(chStmt.getInt("merge_branch_id"));
+ mergeBranch.setSourceBranch(sourceBranch);
+ mergeBranch.setDestinationBranch(destBranch);
+ }
+ } finally {
+ chStmt.close();
+ }
+
+ }
+
+ @Override
+ public void store(Collection<Branch> branches) throws OseeCoreException {
+ Operations.executeWorkAndCheckStatus(
+ new BranchStoreOperation(getDatabaseServiceProvider(), eventSender, branches), new NullProgressMonitor(),
+ -1);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseOseeEnumTypeAccessor.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseOseeEnumTypeAccessor.java
index 54365cf1ef..abf5897b4f 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseOseeEnumTypeAccessor.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseOseeEnumTypeAccessor.java
@@ -1,198 +1,198 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.core.datastore.cache;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.core.datastore.internal.Activator;
-import org.eclipse.osee.framework.core.enums.StorageState;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.core.model.AbstractOseeType;
-import org.eclipse.osee.framework.core.model.OseeEnumEntry;
-import org.eclipse.osee.framework.core.model.cache.IOseeCache;
-import org.eclipse.osee.framework.core.model.type.OseeEnumType;
-import org.eclipse.osee.framework.core.model.type.OseeEnumTypeFactory;
-import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
-import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
-import org.eclipse.osee.framework.database.core.IOseeStatement;
-import org.eclipse.osee.framework.jdk.core.type.HashCollection;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Roberto E. Escobar
- */
-public class DatabaseOseeEnumTypeAccessor extends AbstractDatabaseAccessor<OseeEnumType> {
-
- private static final String SELECT_OSEE_ENUM_TYPES = "select * from osee_enum_type oet";
- private static final String SELECT_OSEE_ENUM_ENTRIES =
- "select * from osee_enum_type_def order by enum_type_id, ordinal";
-
- private static final String INSERT_ENUM_TYPE =
- "insert into osee_enum_type (enum_type_id, enum_type_guid, enum_type_name) values (?,?,?)";
- private static final String UPDATE_ENUM_TYPE = "update osee_enum_type set enum_type_name=? where enum_type_id=?";
- private static final String DELETE_ENUM_TYPE = "delete from osee_enum_type oet where enum_type_id = ?";
-
- private static final String INSERT_ENUM_TYPE_DEF =
- "insert into osee_enum_type_def (enum_type_id, enum_entry_guid, name, ordinal) values (?,?,?,?)";
- private static final String DELETE_ENUM_TYPE_DEF = "delete from osee_enum_type_def where enum_type_id = ?";
-
- public DatabaseOseeEnumTypeAccessor(IOseeDatabaseServiceProvider databaseProvider, IOseeModelFactoryServiceProvider factoryProvider) {
- super(databaseProvider, factoryProvider);
- }
-
- private void loadEnumEntries(OseeEnumTypeFactory factory, HashCollection<Integer, OseeEnumEntry> entryTypes) throws OseeCoreException {
- IOseeStatement chStmt = getDatabaseService().getStatement();
- try {
- chStmt.runPreparedQuery(SELECT_OSEE_ENUM_ENTRIES);
- while (chStmt.next()) {
- try {
- Integer enumTypeId = chStmt.getInt("enum_type_id");
- String enumEntryGuid = chStmt.getString("enum_entry_guid");
- String enumEntryName = chStmt.getString("name");
- int ordinal = chStmt.getInt("ordinal");
-
- OseeEnumEntry entry = factory.createEnumEntry(enumEntryGuid, enumEntryName, ordinal);
- entry.setStorageState(StorageState.LOADED);
- entry.clearDirty();
- entryTypes.put(enumTypeId, entry);
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
- } finally {
- chStmt.close();
- }
- }
-
- @Override
- public void load(IOseeCache<OseeEnumType> cache) throws OseeCoreException {
- OseeEnumTypeFactory factory = getFactoryService().getOseeEnumTypeFactory();
-
- HashCollection<Integer, OseeEnumEntry> entryTypes = new HashCollection<Integer, OseeEnumEntry>();
-
- loadEnumEntries(factory, entryTypes);
-
- IOseeStatement chStmt = getDatabaseService().getStatement();
- try {
- chStmt.runPreparedQuery(SELECT_OSEE_ENUM_TYPES);
- while (chStmt.next()) {
- try {
- Integer enumTypeId = chStmt.getInt("enum_type_id");
- String enumTypeGuid = chStmt.getString("enum_type_guid");
- String enumTypeName = chStmt.getString("enum_type_name");
-
- OseeEnumType oseeEnumType =
- factory.createOrUpdate(cache, enumTypeId, StorageState.LOADED, enumTypeGuid, enumTypeName);
-
- List<OseeEnumEntry> oseeEnumEntries = (List<OseeEnumEntry>) entryTypes.getValues(enumTypeId);
- if (oseeEnumEntries != null) {
- oseeEnumType.setEntries(oseeEnumEntries);
- oseeEnumType.clearDirty();
- }
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
- } finally {
- chStmt.close();
- }
- }
-
- @Override
- public void store(Collection<OseeEnumType> oseeEnumTypes) throws OseeCoreException {
- Set<OseeEnumType> dirtyEntries = new HashSet<OseeEnumType>();
- List<Object[]> insertData = new ArrayList<Object[]>();
- List<Object[]> updateData = new ArrayList<Object[]>();
- List<Object[]> deleteData = new ArrayList<Object[]>();
- for (OseeEnumType oseeEnumType : oseeEnumTypes) {
- if (isDataDirty(oseeEnumType)) {
- switch (oseeEnumType.getStorageState()) {
- case CREATED:
- oseeEnumType.setId(getSequence().getNextOseeEnumTypeId());
- insertData.add(toInsertValues(oseeEnumType));
- break;
- case MODIFIED:
- updateData.add(toUpdateValues(oseeEnumType));
- break;
- case PURGED:
- deleteData.add(toDeleteValues(oseeEnumType));
- break;
- default:
- break;
- }
- }
- if (oseeEnumType.isFieldDirty(OseeEnumType.OSEE_ENUM_TYPE_ENTRIES_FIELD)) {
- dirtyEntries.add(oseeEnumType);
- }
- }
- getDatabaseService().runBatchUpdate(INSERT_ENUM_TYPE, insertData);
- getDatabaseService().runBatchUpdate(UPDATE_ENUM_TYPE, updateData);
- getDatabaseService().runBatchUpdate(DELETE_ENUM_TYPE, deleteData);
-
- storeOseeEnumEntries(dirtyEntries);
- for (OseeEnumType oseeEnumType : oseeEnumTypes) {
- oseeEnumType.clearDirty();
- for (OseeEnumEntry entry : oseeEnumType.values()) {
- entry.clearDirty();
- }
- }
- }
-
- private boolean isDataDirty(OseeEnumType type) throws OseeCoreException {
- return type.areFieldsDirty(AbstractOseeType.NAME_FIELD_KEY, AbstractOseeType.UNIQUE_ID_FIELD_KEY);
- }
-
- private void storeOseeEnumEntries(Collection<OseeEnumType> oseeEnumTypes) throws OseeCoreException {
- List<Object[]> insertData = new ArrayList<Object[]>();
- List<Object[]> deleteData = new ArrayList<Object[]>();
-
- for (OseeEnumType type : oseeEnumTypes) {
- // Delete all type entries that have been inserted into the DB before
- if (type.isIdValid()) {
- deleteData.add(toDeleteValues(type));
- }
-
- //Re-add only entries that are valid
- for (OseeEnumEntry entry : type.values()) {
- if (StorageState.PURGED != entry.getStorageState()) {
- if (!entry.isIdValid()) {
- entry.setId(type.getId());
- }
- insertData.add(toInsertValues(entry));
- }
- }
- }
-
- getDatabaseService().runBatchUpdate(DELETE_ENUM_TYPE_DEF, deleteData);
- getDatabaseService().runBatchUpdate(INSERT_ENUM_TYPE_DEF, insertData);
- }
-
- private Object[] toInsertValues(OseeEnumType type) throws OseeDataStoreException {
- return new Object[] {type.getId(), type.getGuid(), type.getName()};
- }
-
- private Object[] toUpdateValues(OseeEnumType type) throws OseeDataStoreException {
- return new Object[] {type.getName(), type.getId()};
- }
-
- private Object[] toDeleteValues(OseeEnumType type) throws OseeDataStoreException {
- return new Object[] {type.getId()};
- }
-
- private Object[] toInsertValues(OseeEnumEntry type) throws OseeDataStoreException {
- return new Object[] {type.getId(), type.getGuid(), type.getName(), type.ordinal()};
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009 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.core.datastore.cache;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.datastore.internal.Activator;
+import org.eclipse.osee.framework.core.enums.StorageState;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.core.model.AbstractOseeType;
+import org.eclipse.osee.framework.core.model.OseeEnumEntry;
+import org.eclipse.osee.framework.core.model.cache.IOseeCache;
+import org.eclipse.osee.framework.core.model.type.OseeEnumType;
+import org.eclipse.osee.framework.core.model.type.OseeEnumTypeFactory;
+import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
+import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.jdk.core.type.HashCollection;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class DatabaseOseeEnumTypeAccessor extends AbstractDatabaseAccessor<OseeEnumType> {
+
+ private static final String SELECT_OSEE_ENUM_TYPES = "select * from osee_enum_type oet";
+ private static final String SELECT_OSEE_ENUM_ENTRIES =
+ "select * from osee_enum_type_def order by enum_type_id, ordinal";
+
+ private static final String INSERT_ENUM_TYPE =
+ "insert into osee_enum_type (enum_type_id, enum_type_guid, enum_type_name) values (?,?,?)";
+ private static final String UPDATE_ENUM_TYPE = "update osee_enum_type set enum_type_name=? where enum_type_id=?";
+ private static final String DELETE_ENUM_TYPE = "delete from osee_enum_type oet where enum_type_id = ?";
+
+ private static final String INSERT_ENUM_TYPE_DEF =
+ "insert into osee_enum_type_def (enum_type_id, enum_entry_guid, name, ordinal) values (?,?,?,?)";
+ private static final String DELETE_ENUM_TYPE_DEF = "delete from osee_enum_type_def where enum_type_id = ?";
+
+ public DatabaseOseeEnumTypeAccessor(IOseeDatabaseServiceProvider databaseProvider, IOseeModelFactoryServiceProvider factoryProvider) {
+ super(databaseProvider, factoryProvider);
+ }
+
+ private void loadEnumEntries(OseeEnumTypeFactory factory, HashCollection<Integer, OseeEnumEntry> entryTypes) throws OseeCoreException {
+ IOseeStatement chStmt = getDatabaseService().getStatement();
+ try {
+ chStmt.runPreparedQuery(SELECT_OSEE_ENUM_ENTRIES);
+ while (chStmt.next()) {
+ try {
+ Integer enumTypeId = chStmt.getInt("enum_type_id");
+ String enumEntryGuid = chStmt.getString("enum_entry_guid");
+ String enumEntryName = chStmt.getString("name");
+ int ordinal = chStmt.getInt("ordinal");
+
+ OseeEnumEntry entry = factory.createEnumEntry(enumEntryGuid, enumEntryName, ordinal);
+ entry.setStorageState(StorageState.LOADED);
+ entry.clearDirty();
+ entryTypes.put(enumTypeId, entry);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+ } finally {
+ chStmt.close();
+ }
+ }
+
+ @Override
+ public void load(IOseeCache<OseeEnumType> cache) throws OseeCoreException {
+ OseeEnumTypeFactory factory = getFactoryService().getOseeEnumTypeFactory();
+
+ HashCollection<Integer, OseeEnumEntry> entryTypes = new HashCollection<Integer, OseeEnumEntry>();
+
+ loadEnumEntries(factory, entryTypes);
+
+ IOseeStatement chStmt = getDatabaseService().getStatement();
+ try {
+ chStmt.runPreparedQuery(SELECT_OSEE_ENUM_TYPES);
+ while (chStmt.next()) {
+ try {
+ Integer enumTypeId = chStmt.getInt("enum_type_id");
+ String enumTypeGuid = chStmt.getString("enum_type_guid");
+ String enumTypeName = chStmt.getString("enum_type_name");
+
+ OseeEnumType oseeEnumType =
+ factory.createOrUpdate(cache, enumTypeId, StorageState.LOADED, enumTypeGuid, enumTypeName);
+
+ List<OseeEnumEntry> oseeEnumEntries = (List<OseeEnumEntry>) entryTypes.getValues(enumTypeId);
+ if (oseeEnumEntries != null) {
+ oseeEnumType.setEntries(oseeEnumEntries);
+ oseeEnumType.clearDirty();
+ }
+ } catch (OseeCoreException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+ } finally {
+ chStmt.close();
+ }
+ }
+
+ @Override
+ public void store(Collection<OseeEnumType> oseeEnumTypes) throws OseeCoreException {
+ Set<OseeEnumType> dirtyEntries = new HashSet<OseeEnumType>();
+ List<Object[]> insertData = new ArrayList<Object[]>();
+ List<Object[]> updateData = new ArrayList<Object[]>();
+ List<Object[]> deleteData = new ArrayList<Object[]>();
+ for (OseeEnumType oseeEnumType : oseeEnumTypes) {
+ if (isDataDirty(oseeEnumType)) {
+ switch (oseeEnumType.getStorageState()) {
+ case CREATED:
+ oseeEnumType.setId(getSequence().getNextOseeEnumTypeId());
+ insertData.add(toInsertValues(oseeEnumType));
+ break;
+ case MODIFIED:
+ updateData.add(toUpdateValues(oseeEnumType));
+ break;
+ case PURGED:
+ deleteData.add(toDeleteValues(oseeEnumType));
+ break;
+ default:
+ break;
+ }
+ }
+ if (oseeEnumType.isFieldDirty(OseeEnumType.OSEE_ENUM_TYPE_ENTRIES_FIELD)) {
+ dirtyEntries.add(oseeEnumType);
+ }
+ }
+ getDatabaseService().runBatchUpdate(INSERT_ENUM_TYPE, insertData);
+ getDatabaseService().runBatchUpdate(UPDATE_ENUM_TYPE, updateData);
+ getDatabaseService().runBatchUpdate(DELETE_ENUM_TYPE, deleteData);
+
+ storeOseeEnumEntries(dirtyEntries);
+ for (OseeEnumType oseeEnumType : oseeEnumTypes) {
+ oseeEnumType.clearDirty();
+ for (OseeEnumEntry entry : oseeEnumType.values()) {
+ entry.clearDirty();
+ }
+ }
+ }
+
+ private boolean isDataDirty(OseeEnumType type) throws OseeCoreException {
+ return type.areFieldsDirty(AbstractOseeType.NAME_FIELD_KEY, AbstractOseeType.UNIQUE_ID_FIELD_KEY);
+ }
+
+ private void storeOseeEnumEntries(Collection<OseeEnumType> oseeEnumTypes) throws OseeCoreException {
+ List<Object[]> insertData = new ArrayList<Object[]>();
+ List<Object[]> deleteData = new ArrayList<Object[]>();
+
+ for (OseeEnumType type : oseeEnumTypes) {
+ // Delete all type entries that have been inserted into the DB before
+ if (type.isIdValid()) {
+ deleteData.add(toDeleteValues(type));
+ }
+
+ //Re-add only entries that are valid
+ for (OseeEnumEntry entry : type.values()) {
+ if (StorageState.PURGED != entry.getStorageState()) {
+ if (!entry.isIdValid()) {
+ entry.setId(type.getId());
+ }
+ insertData.add(toInsertValues(entry));
+ }
+ }
+ }
+
+ getDatabaseService().runBatchUpdate(DELETE_ENUM_TYPE_DEF, deleteData);
+ getDatabaseService().runBatchUpdate(INSERT_ENUM_TYPE_DEF, insertData);
+ }
+
+ private Object[] toInsertValues(OseeEnumType type) throws OseeDataStoreException {
+ return new Object[] {type.getId(), type.getGuid(), type.getName()};
+ }
+
+ private Object[] toUpdateValues(OseeEnumType type) throws OseeDataStoreException {
+ return new Object[] {type.getName(), type.getId()};
+ }
+
+ private Object[] toDeleteValues(OseeEnumType type) throws OseeDataStoreException {
+ return new Object[] {type.getId()};
+ }
+
+ private Object[] toInsertValues(OseeEnumEntry type) throws OseeDataStoreException {
+ return new Object[] {type.getId(), type.getGuid(), type.getName(), type.ordinal()};
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseRelationTypeAccessor.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseRelationTypeAccessor.java
index c950191604..f63c8363bc 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseRelationTypeAccessor.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseRelationTypeAccessor.java
@@ -1,134 +1,134 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.core.datastore.cache;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.core.datastore.internal.Activator;
-import org.eclipse.osee.framework.core.enums.RelationTypeMultiplicity;
-import org.eclipse.osee.framework.core.enums.StorageState;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.core.model.cache.ArtifactTypeCache;
-import org.eclipse.osee.framework.core.model.cache.IOseeCache;
-import org.eclipse.osee.framework.core.model.type.ArtifactType;
-import org.eclipse.osee.framework.core.model.type.RelationType;
-import org.eclipse.osee.framework.core.model.type.RelationTypeFactory;
-import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
-import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
-import org.eclipse.osee.framework.database.core.IOseeStatement;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Roberto E. Escobar
- */
-public class DatabaseRelationTypeAccessor extends AbstractDatabaseAccessor<RelationType> {
- private static final String SELECT_LINK_TYPES = "SELECT * FROM osee_relation_link_type";
- private static final String INSERT_RELATION_TYPE =
- "INSERT INTO osee_relation_link_type (rel_link_type_id, rel_link_type_guid, type_name, a_name, b_name, a_art_type_id, b_art_type_id, multiplicity, default_order_type_guid) VALUES (?,?,?,?,?,?,?,?,?)";
- private static final String UPDATE_RELATION_TYPE =
- "update osee_relation_link_type SET type_name=?, a_name=?, b_name=?, a_art_type_id=?, b_art_type_id=?, multiplicity=?, default_order_type_guid=? where rel_link_type_id = ?";
-
- private final ArtifactTypeCache artifactCache;
-
- public DatabaseRelationTypeAccessor(IOseeDatabaseServiceProvider databaseProvider, IOseeModelFactoryServiceProvider factoryProvider, ArtifactTypeCache artifactCache) {
- super(databaseProvider, factoryProvider);
- this.artifactCache = artifactCache;
- }
-
- @Override
- public void load(IOseeCache<RelationType> cache) throws OseeCoreException {
- artifactCache.ensurePopulated();
- RelationTypeFactory factory = getFactoryService().getRelationTypeFactory();
- IOseeStatement chStmt = getDatabaseService().getStatement();
-
- try {
- chStmt.runPreparedQuery(SELECT_LINK_TYPES);
-
- while (chStmt.next()) {
- String typeName = chStmt.getString("type_name");
- int typeId = chStmt.getInt("rel_link_type_id");
- int aArtTypeId = chStmt.getInt("a_art_type_id");
- int bArtTypeId = chStmt.getInt("b_art_type_id");
- int multiplicityValue = chStmt.getInt("multiplicity");
- try {
- ArtifactType artifactTypeSideA = artifactCache.getById(aArtTypeId);
- ArtifactType artifactTypeSideB = artifactCache.getById(bArtTypeId);
- RelationTypeMultiplicity multiplicity =
- RelationTypeMultiplicity.getRelationMultiplicity(multiplicityValue);
- String sideAName = chStmt.getString("a_name");
- String sideBName = chStmt.getString("b_name");
- String defaultOrderTypeGuid = chStmt.getString("default_order_type_guid");
- String guid = chStmt.getString("rel_link_type_guid");
-
- RelationType relationType =
- factory.createOrUpdate(cache, typeId, StorageState.LOADED, guid, typeName, sideAName, sideBName,
- artifactTypeSideA, artifactTypeSideB, multiplicity, defaultOrderTypeGuid);
- relationType.clearDirty();
- } catch (OseeCoreException ex) {
- String message =
- String.format(
- "Error loading relation type - name:[%s] id:[%s] aArtTypeId:[%s] bArtTypeid:[%s] multiplicity:[%s]",
- typeName, typeId, aArtTypeId, bArtTypeId, multiplicityValue);
- OseeLog.log(Activator.class, Level.SEVERE, message, ex);
- }
- }
- } finally {
- chStmt.close();
- }
- }
-
- @Override
- public void store(Collection<RelationType> relationTypes) throws OseeCoreException {
- List<Object[]> insertData = new ArrayList<Object[]>();
- List<Object[]> updateData = new ArrayList<Object[]>();
- for (RelationType type : relationTypes) {
- if (type.isDirty()) {
- switch (type.getStorageState()) {
- case CREATED:
- type.setId(getSequence().getNextRelationTypeId());
- insertData.add(toInsertValues(type));
- break;
- case MODIFIED:
- updateData.add(toUpdateValues(type));
- break;
- default:
- break;
- }
- }
- }
- OseeConnection connection = getDatabaseService().getConnection();
- try {
- getDatabaseService().runBatchUpdate(connection, INSERT_RELATION_TYPE, insertData);
- getDatabaseService().runBatchUpdate(connection, UPDATE_RELATION_TYPE, updateData);
- } finally {
- connection.close();
- }
- for (RelationType type : relationTypes) {
- type.clearDirty();
- }
- }
-
- private Object[] toInsertValues(RelationType type) throws OseeDataStoreException {
- return new Object[] {type.getId(), type.getGuid(), type.getName(), type.getSideAName(), type.getSideBName(),
- type.getArtifactTypeSideA().getId(), type.getArtifactTypeSideB().getId(),
- type.getMultiplicity().getValue(), type.getDefaultOrderTypeGuid()};
- }
-
- private Object[] toUpdateValues(RelationType type) throws OseeDataStoreException {
- return new Object[] {type.getName(), type.getSideAName(), type.getSideBName(),
- type.getArtifactTypeSideA().getId(), type.getArtifactTypeSideB().getId(),
- type.getMultiplicity().getValue(), type.getDefaultOrderTypeGuid(), type.getId()};
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009 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.core.datastore.cache;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.datastore.internal.Activator;
+import org.eclipse.osee.framework.core.enums.RelationTypeMultiplicity;
+import org.eclipse.osee.framework.core.enums.StorageState;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.core.model.cache.ArtifactTypeCache;
+import org.eclipse.osee.framework.core.model.cache.IOseeCache;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+import org.eclipse.osee.framework.core.model.type.RelationType;
+import org.eclipse.osee.framework.core.model.type.RelationTypeFactory;
+import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
+import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.database.core.OseeConnection;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class DatabaseRelationTypeAccessor extends AbstractDatabaseAccessor<RelationType> {
+ private static final String SELECT_LINK_TYPES = "SELECT * FROM osee_relation_link_type";
+ private static final String INSERT_RELATION_TYPE =
+ "INSERT INTO osee_relation_link_type (rel_link_type_id, rel_link_type_guid, type_name, a_name, b_name, a_art_type_id, b_art_type_id, multiplicity, default_order_type_guid) VALUES (?,?,?,?,?,?,?,?,?)";
+ private static final String UPDATE_RELATION_TYPE =
+ "update osee_relation_link_type SET type_name=?, a_name=?, b_name=?, a_art_type_id=?, b_art_type_id=?, multiplicity=?, default_order_type_guid=? where rel_link_type_id = ?";
+
+ private final ArtifactTypeCache artifactCache;
+
+ public DatabaseRelationTypeAccessor(IOseeDatabaseServiceProvider databaseProvider, IOseeModelFactoryServiceProvider factoryProvider, ArtifactTypeCache artifactCache) {
+ super(databaseProvider, factoryProvider);
+ this.artifactCache = artifactCache;
+ }
+
+ @Override
+ public void load(IOseeCache<RelationType> cache) throws OseeCoreException {
+ artifactCache.ensurePopulated();
+ RelationTypeFactory factory = getFactoryService().getRelationTypeFactory();
+ IOseeStatement chStmt = getDatabaseService().getStatement();
+
+ try {
+ chStmt.runPreparedQuery(SELECT_LINK_TYPES);
+
+ while (chStmt.next()) {
+ String typeName = chStmt.getString("type_name");
+ int typeId = chStmt.getInt("rel_link_type_id");
+ int aArtTypeId = chStmt.getInt("a_art_type_id");
+ int bArtTypeId = chStmt.getInt("b_art_type_id");
+ int multiplicityValue = chStmt.getInt("multiplicity");
+ try {
+ ArtifactType artifactTypeSideA = artifactCache.getById(aArtTypeId);
+ ArtifactType artifactTypeSideB = artifactCache.getById(bArtTypeId);
+ RelationTypeMultiplicity multiplicity =
+ RelationTypeMultiplicity.getRelationMultiplicity(multiplicityValue);
+ String sideAName = chStmt.getString("a_name");
+ String sideBName = chStmt.getString("b_name");
+ String defaultOrderTypeGuid = chStmt.getString("default_order_type_guid");
+ String guid = chStmt.getString("rel_link_type_guid");
+
+ RelationType relationType =
+ factory.createOrUpdate(cache, typeId, StorageState.LOADED, guid, typeName, sideAName, sideBName,
+ artifactTypeSideA, artifactTypeSideB, multiplicity, defaultOrderTypeGuid);
+ relationType.clearDirty();
+ } catch (OseeCoreException ex) {
+ String message =
+ String.format(
+ "Error loading relation type - name:[%s] id:[%s] aArtTypeId:[%s] bArtTypeid:[%s] multiplicity:[%s]",
+ typeName, typeId, aArtTypeId, bArtTypeId, multiplicityValue);
+ OseeLog.log(Activator.class, Level.SEVERE, message, ex);
+ }
+ }
+ } finally {
+ chStmt.close();
+ }
+ }
+
+ @Override
+ public void store(Collection<RelationType> relationTypes) throws OseeCoreException {
+ List<Object[]> insertData = new ArrayList<Object[]>();
+ List<Object[]> updateData = new ArrayList<Object[]>();
+ for (RelationType type : relationTypes) {
+ if (type.isDirty()) {
+ switch (type.getStorageState()) {
+ case CREATED:
+ type.setId(getSequence().getNextRelationTypeId());
+ insertData.add(toInsertValues(type));
+ break;
+ case MODIFIED:
+ updateData.add(toUpdateValues(type));
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ OseeConnection connection = getDatabaseService().getConnection();
+ try {
+ getDatabaseService().runBatchUpdate(connection, INSERT_RELATION_TYPE, insertData);
+ getDatabaseService().runBatchUpdate(connection, UPDATE_RELATION_TYPE, updateData);
+ } finally {
+ connection.close();
+ }
+ for (RelationType type : relationTypes) {
+ type.clearDirty();
+ }
+ }
+
+ private Object[] toInsertValues(RelationType type) throws OseeDataStoreException {
+ return new Object[] {type.getId(), type.getGuid(), type.getName(), type.getSideAName(), type.getSideBName(),
+ type.getArtifactTypeSideA().getId(), type.getArtifactTypeSideB().getId(),
+ type.getMultiplicity().getValue(), type.getDefaultOrderTypeGuid()};
+ }
+
+ private Object[] toUpdateValues(RelationType type) throws OseeDataStoreException {
+ return new Object[] {type.getName(), type.getSideAName(), type.getSideBName(),
+ type.getArtifactTypeSideA().getId(), type.getArtifactTypeSideB().getId(),
+ type.getMultiplicity().getValue(), type.getDefaultOrderTypeGuid(), type.getId()};
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseTransactionRecordAccessor.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseTransactionRecordAccessor.java
index b14d51392d..e8a09ed7ee 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseTransactionRecordAccessor.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/DatabaseTransactionRecordAccessor.java
@@ -1,155 +1,155 @@
-/*******************************************************************************
- * 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.core.datastore.cache;
-
-import java.util.Collection;
-import java.util.Date;
-import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
-import org.eclipse.osee.framework.core.enums.TransactionVersion;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeStateException;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.core.model.TransactionRecord;
-import org.eclipse.osee.framework.core.model.TransactionRecordFactory;
-import org.eclipse.osee.framework.core.model.cache.BranchCache;
-import org.eclipse.osee.framework.core.model.cache.ITransactionDataAccessor;
-import org.eclipse.osee.framework.core.model.cache.TransactionCache;
-import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
-import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
-import org.eclipse.osee.framework.database.core.IOseeStatement;
-import org.eclipse.osee.framework.database.core.JoinUtility;
-import org.eclipse.osee.framework.database.core.JoinUtility.IdJoinQuery;
-
-/**
- * @author Roberto E. Escobar
- */
-public class DatabaseTransactionRecordAccessor implements ITransactionDataAccessor {
-
- private static final String SELECT_BASE_TRANSACTION =
- "select txd.* from osee_branch ob, osee_tx_details txd WHERE ob.branch_id = ? AND ob.baseline_transaction_id = txd.transaction_id";
-
- private static final String SELECT_BY_TRANSACTION = "select * from osee_tx_details WHERE transaction_id = ?";
-
- private static final String SELECT_BRANCH_TRANSACTIONS =
- "select * from osee_tx_details where branch_id = ? order by transaction_id DESC";
-
- private static final String SELECT_TRANSACTIONS_BY_QUERY_ID =
- "select * from osee_tx_details txd, osee_join_id oji where txd.transaction_id = oji.id and oji.query_id = ?";
-
- private final IOseeDatabaseServiceProvider oseeDatabaseProvider;
- private final BranchCache branchCache;
- private final IOseeModelFactoryServiceProvider factoryProvider;
-
- public DatabaseTransactionRecordAccessor(IOseeDatabaseServiceProvider oseeDatabaseProvider, IOseeModelFactoryServiceProvider factoryProvider, BranchCache branchCache) {
- this.oseeDatabaseProvider = oseeDatabaseProvider;
- this.factoryProvider = factoryProvider;
- this.branchCache = branchCache;
- }
-
- private synchronized void ensureDependantCachePopulated() throws OseeCoreException {
- branchCache.ensurePopulated();
- }
-
- public void loadTransactionRecord(TransactionCache cache, Collection<Integer> transactionIds) throws OseeCoreException {
- if (transactionIds.isEmpty()) {
- return;
- }
- ensureDependantCachePopulated();
- if (transactionIds.size() > 1) {
- IdJoinQuery joinQuery = JoinUtility.createIdJoinQuery();
- try {
- for (Integer txNumber : transactionIds) {
- joinQuery.add(txNumber);
- }
- joinQuery.store();
-
- loadFromTransaction(cache, null, 5000, false, SELECT_TRANSACTIONS_BY_QUERY_ID, joinQuery.getQueryId());
-
- } finally {
- joinQuery.delete();
- }
- } else {
- loadFromTransaction(cache, null, 1, SELECT_BY_TRANSACTION, transactionIds.iterator().next());
- }
- }
-
- public void loadTransactionRecord(TransactionCache cache, Branch branch) throws OseeCoreException {
- ensureDependantCachePopulated();
- loadFromTransaction(cache, branch, 1000, SELECT_BRANCH_TRANSACTIONS, branch.getId());
- }
-
- public TransactionRecord loadTransactionRecord(TransactionCache cache, Branch branch, TransactionVersion transactionType) throws OseeCoreException {
- ensureDependantCachePopulated();
- TransactionRecord toReturn = null;
- switch (transactionType) {
- case BASE:
- toReturn = loadFirstTransactionRecord(cache, branch, SELECT_BASE_TRANSACTION, branch.getId());
- break;
- case HEAD:
- toReturn = loadFirstTransactionRecord(cache, branch, SELECT_BRANCH_TRANSACTIONS, branch.getId());
- break;
- default:
- throw new OseeStateException(String.format("Transaction Type [%s] is not supported", transactionType));
- }
- return toReturn;
- }
-
- private TransactionRecord loadFirstTransactionRecord(TransactionCache cache, Branch branch, String query, Object... parameters) throws OseeCoreException {
- ensureDependantCachePopulated();
- return loadFromTransaction(cache, branch, 1, true, query, parameters);
- }
-
- private void loadFromTransaction(TransactionCache cache, Branch branch, int fetchSize, String query, Object... parameters) throws OseeCoreException {
- ensureDependantCachePopulated();
- loadFromTransaction(cache, branch, fetchSize, false, query, parameters);
- }
-
- private TransactionRecord loadFromTransaction(TransactionCache cache, Branch branch, int fetchSize, boolean isOnlyReadFirstResult, String query, Object... parameters) throws OseeCoreException {
- IOseeStatement chStmt = oseeDatabaseProvider.getOseeDatabaseService().getStatement();
- TransactionRecord record = null;
- try {
- chStmt.runPreparedQuery(fetchSize, query, parameters);
- while (chStmt.next()) {
- int branchId = chStmt.getInt("branch_id");
- int transactionNumber = chStmt.getInt("transaction_id");
- String comment = chStmt.getString("osee_comment");
- Date timestamp = chStmt.getTimestamp("time");
- int authorArtId = chStmt.getInt("author");
- int commitArtId = chStmt.getInt("commit_art_id");
- TransactionDetailsType txType = TransactionDetailsType.toEnum(chStmt.getInt("tx_type"));
-
- record =
- prepareTransactionRecord(cache, transactionNumber, branchId, comment, timestamp, authorArtId,
- commitArtId, txType);
- if (isOnlyReadFirstResult) {
- break;
- }
- }
- } finally {
- chStmt.close();
- }
- return record;
- }
-
- private TransactionRecord prepareTransactionRecord(TransactionCache cache, int transactionNumber, int branchId, String comment, Date timestamp, int authorArtId, int commitArtId, TransactionDetailsType txType) throws OseeCoreException {
- TransactionRecordFactory factory = factoryProvider.getOseeFactoryService().getTransactionFactory();
- TransactionRecord record =
- factory.createOrUpdate(cache, transactionNumber, branchId, comment, timestamp, authorArtId, commitArtId,
- txType);
- record.setBranchCache(branchCache);
- record.clearDirty();
- return record;
- }
-
- @Override
- public void load(TransactionCache transactionCache) throws OseeCoreException {
- }
-}
+/*******************************************************************************
+ * 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.core.datastore.cache;
+
+import java.util.Collection;
+import java.util.Date;
+import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
+import org.eclipse.osee.framework.core.enums.TransactionVersion;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeStateException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.TransactionRecord;
+import org.eclipse.osee.framework.core.model.TransactionRecordFactory;
+import org.eclipse.osee.framework.core.model.cache.BranchCache;
+import org.eclipse.osee.framework.core.model.cache.ITransactionDataAccessor;
+import org.eclipse.osee.framework.core.model.cache.TransactionCache;
+import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
+import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.database.core.JoinUtility;
+import org.eclipse.osee.framework.database.core.JoinUtility.IdJoinQuery;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class DatabaseTransactionRecordAccessor implements ITransactionDataAccessor {
+
+ private static final String SELECT_BASE_TRANSACTION =
+ "select txd.* from osee_branch ob, osee_tx_details txd WHERE ob.branch_id = ? AND ob.baseline_transaction_id = txd.transaction_id";
+
+ private static final String SELECT_BY_TRANSACTION = "select * from osee_tx_details WHERE transaction_id = ?";
+
+ private static final String SELECT_BRANCH_TRANSACTIONS =
+ "select * from osee_tx_details where branch_id = ? order by transaction_id DESC";
+
+ private static final String SELECT_TRANSACTIONS_BY_QUERY_ID =
+ "select * from osee_tx_details txd, osee_join_id oji where txd.transaction_id = oji.id and oji.query_id = ?";
+
+ private final IOseeDatabaseServiceProvider oseeDatabaseProvider;
+ private final BranchCache branchCache;
+ private final IOseeModelFactoryServiceProvider factoryProvider;
+
+ public DatabaseTransactionRecordAccessor(IOseeDatabaseServiceProvider oseeDatabaseProvider, IOseeModelFactoryServiceProvider factoryProvider, BranchCache branchCache) {
+ this.oseeDatabaseProvider = oseeDatabaseProvider;
+ this.factoryProvider = factoryProvider;
+ this.branchCache = branchCache;
+ }
+
+ private synchronized void ensureDependantCachePopulated() throws OseeCoreException {
+ branchCache.ensurePopulated();
+ }
+
+ public void loadTransactionRecord(TransactionCache cache, Collection<Integer> transactionIds) throws OseeCoreException {
+ if (transactionIds.isEmpty()) {
+ return;
+ }
+ ensureDependantCachePopulated();
+ if (transactionIds.size() > 1) {
+ IdJoinQuery joinQuery = JoinUtility.createIdJoinQuery();
+ try {
+ for (Integer txNumber : transactionIds) {
+ joinQuery.add(txNumber);
+ }
+ joinQuery.store();
+
+ loadFromTransaction(cache, null, 5000, false, SELECT_TRANSACTIONS_BY_QUERY_ID, joinQuery.getQueryId());
+
+ } finally {
+ joinQuery.delete();
+ }
+ } else {
+ loadFromTransaction(cache, null, 1, SELECT_BY_TRANSACTION, transactionIds.iterator().next());
+ }
+ }
+
+ public void loadTransactionRecord(TransactionCache cache, Branch branch) throws OseeCoreException {
+ ensureDependantCachePopulated();
+ loadFromTransaction(cache, branch, 1000, SELECT_BRANCH_TRANSACTIONS, branch.getId());
+ }
+
+ public TransactionRecord loadTransactionRecord(TransactionCache cache, Branch branch, TransactionVersion transactionType) throws OseeCoreException {
+ ensureDependantCachePopulated();
+ TransactionRecord toReturn = null;
+ switch (transactionType) {
+ case BASE:
+ toReturn = loadFirstTransactionRecord(cache, branch, SELECT_BASE_TRANSACTION, branch.getId());
+ break;
+ case HEAD:
+ toReturn = loadFirstTransactionRecord(cache, branch, SELECT_BRANCH_TRANSACTIONS, branch.getId());
+ break;
+ default:
+ throw new OseeStateException(String.format("Transaction Type [%s] is not supported", transactionType));
+ }
+ return toReturn;
+ }
+
+ private TransactionRecord loadFirstTransactionRecord(TransactionCache cache, Branch branch, String query, Object... parameters) throws OseeCoreException {
+ ensureDependantCachePopulated();
+ return loadFromTransaction(cache, branch, 1, true, query, parameters);
+ }
+
+ private void loadFromTransaction(TransactionCache cache, Branch branch, int fetchSize, String query, Object... parameters) throws OseeCoreException {
+ ensureDependantCachePopulated();
+ loadFromTransaction(cache, branch, fetchSize, false, query, parameters);
+ }
+
+ private TransactionRecord loadFromTransaction(TransactionCache cache, Branch branch, int fetchSize, boolean isOnlyReadFirstResult, String query, Object... parameters) throws OseeCoreException {
+ IOseeStatement chStmt = oseeDatabaseProvider.getOseeDatabaseService().getStatement();
+ TransactionRecord record = null;
+ try {
+ chStmt.runPreparedQuery(fetchSize, query, parameters);
+ while (chStmt.next()) {
+ int branchId = chStmt.getInt("branch_id");
+ int transactionNumber = chStmt.getInt("transaction_id");
+ String comment = chStmt.getString("osee_comment");
+ Date timestamp = chStmt.getTimestamp("time");
+ int authorArtId = chStmt.getInt("author");
+ int commitArtId = chStmt.getInt("commit_art_id");
+ TransactionDetailsType txType = TransactionDetailsType.toEnum(chStmt.getInt("tx_type"));
+
+ record =
+ prepareTransactionRecord(cache, transactionNumber, branchId, comment, timestamp, authorArtId,
+ commitArtId, txType);
+ if (isOnlyReadFirstResult) {
+ break;
+ }
+ }
+ } finally {
+ chStmt.close();
+ }
+ return record;
+ }
+
+ private TransactionRecord prepareTransactionRecord(TransactionCache cache, int transactionNumber, int branchId, String comment, Date timestamp, int authorArtId, int commitArtId, TransactionDetailsType txType) throws OseeCoreException {
+ TransactionRecordFactory factory = factoryProvider.getOseeFactoryService().getTransactionFactory();
+ TransactionRecord record =
+ factory.createOrUpdate(cache, transactionNumber, branchId, comment, timestamp, authorArtId, commitArtId,
+ txType);
+ record.setBranchCache(branchCache);
+ record.clearDirty();
+ return record;
+ }
+
+ @Override
+ public void load(TransactionCache transactionCache) throws OseeCoreException {
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/IBranchUpdateEvent.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/IBranchUpdateEvent.java
index b0323434e6..be80486b7c 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/IBranchUpdateEvent.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/cache/IBranchUpdateEvent.java
@@ -1,23 +1,23 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.core.datastore.cache;
-
-import java.util.Collection;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.Branch;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface IBranchUpdateEvent {
-
- void send(Collection<Branch> branches) throws OseeCoreException;
-}
+/*******************************************************************************
+ * Copyright (c) 2009 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.core.datastore.cache;
+
+import java.util.Collection;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IBranchUpdateEvent {
+
+ void send(Collection<Branch> branches) throws OseeCoreException;
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/Activator.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/Activator.java
index c72b45c015..bda3139614 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/Activator.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/Activator.java
@@ -1,46 +1,46 @@
-/*******************************************************************************
- * 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.core.datastore.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.osee.framework.core.util.AbstractTrackingHandler;
-import org.eclipse.osee.framework.core.util.ServiceDependencyTracker;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class Activator implements BundleActivator {
-
- public static final String PLUGIN_ID = "org.eclipse.osee.framework.core.datastore";
-
- private final List<ServiceDependencyTracker> services;
-
- public Activator() {
- this.services = new ArrayList<ServiceDependencyTracker>();
- }
-
- public void start(BundleContext context) throws Exception {
- createService(context, new OseeCachingServiceRegistrationHandler());
- }
-
- public void stop(BundleContext context) throws Exception {
- for (ServiceDependencyTracker service : services) {
- service.close();
- }
- services.clear();
- }
-
- private void createService(BundleContext context, AbstractTrackingHandler handler) {
- ServiceDependencyTracker service = new ServiceDependencyTracker(context, handler);
- services.add(service);
- service.open();
- }
-}
+/*******************************************************************************
+ * 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.core.datastore.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.osee.framework.core.util.AbstractTrackingHandler;
+import org.eclipse.osee.framework.core.util.ServiceDependencyTracker;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ public static final String PLUGIN_ID = "org.eclipse.osee.framework.core.datastore";
+
+ private final List<ServiceDependencyTracker> services;
+
+ public Activator() {
+ this.services = new ArrayList<ServiceDependencyTracker>();
+ }
+
+ public void start(BundleContext context) throws Exception {
+ createService(context, new OseeCachingServiceRegistrationHandler());
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ for (ServiceDependencyTracker service : services) {
+ service.close();
+ }
+ services.clear();
+ }
+
+ private void createService(BundleContext context, AbstractTrackingHandler handler) {
+ ServiceDependencyTracker service = new ServiceDependencyTracker(context, handler);
+ services.add(service);
+ service.open();
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/CoreOseeSchemaResource.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/CoreOseeSchemaResource.java
index 36218b5194..b4055848ba 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/CoreOseeSchemaResource.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/internal/CoreOseeSchemaResource.java
@@ -8,28 +8,28 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.framework.core.datastore.internal;
-
-import java.io.InputStream;
-import java.net.URL;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.osee.framework.core.datastore.IOseeSchemaResource;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
-import org.osgi.framework.Bundle;
-
-public class CoreOseeSchemaResource implements IOseeSchemaResource {
-
- @Override
- public InputStream getContent() throws OseeCoreException {
- InputStream inputStream = null;
- try {
- Bundle bundle = Platform.getBundle("org.eclipse.osee.framework.core.datastore");
- URL url = bundle.getEntry("support/SKYNET.VERSIONING.SCHEMA.xml");
- inputStream = url.openStream();
- } catch (Exception ex) {
- OseeExceptions.wrapAndThrow(ex);
- }
- return inputStream;
- }
-}
+package org.eclipse.osee.framework.core.datastore.internal;
+
+import java.io.InputStream;
+import java.net.URL;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.osee.framework.core.datastore.IOseeSchemaResource;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.osgi.framework.Bundle;
+
+public class CoreOseeSchemaResource implements IOseeSchemaResource {
+
+ @Override
+ public InputStream getContent() throws OseeCoreException {
+ InputStream inputStream = null;
+ try {
+ Bundle bundle = Platform.getBundle("org.eclipse.osee.framework.core.datastore");
+ URL url = bundle.getEntry("support/SKYNET.VERSIONING.SCHEMA.xml");
+ inputStream = url.openStream();
+ } catch (Exception ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+ return inputStream;
+ }
+}
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 25ec87f413..4e3f83c16b 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
@@ -1,105 +1,105 @@
-/*******************************************************************************
- * 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.core.datastore.internal;
-
-import java.util.Map;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.core.server.IApplicationServerLookup;
-import org.eclipse.osee.framework.core.server.IApplicationServerLookupProvider;
-import org.eclipse.osee.framework.core.server.IApplicationServerManager;
-import org.eclipse.osee.framework.core.services.IOseeCachingService;
-import org.eclipse.osee.framework.core.services.IOseeCachingServiceFactory;
-import org.eclipse.osee.framework.core.services.IOseeModelFactoryService;
-import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
-import org.eclipse.osee.framework.core.translation.IDataTranslationService;
-import org.eclipse.osee.framework.core.translation.IDataTranslationServiceProvider;
-import org.eclipse.osee.framework.core.util.AbstractTrackingHandler;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * @author Roberto E. Escobar
- */
-public class OseeCachingServiceRegistrationHandler extends AbstractTrackingHandler {
-
- private final static Class<?>[] SERVICE_DEPENDENCIES =
- new Class<?>[] {IOseeDatabaseService.class, IOseeModelFactoryService.class, IDataTranslationService.class,
- IApplicationServerLookup.class, IApplicationServerManager.class};
-
- private ServiceRegistration factoryRegistration;
- private ServiceRegistration cachingServiceRegistration;
-
- @Override
- public Class<?>[] getDependencies() {
- return SERVICE_DEPENDENCIES;
- }
-
- @Override
- public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
- IOseeCachingServiceFactory factory = createCachingFactoryService(services);
- IOseeCachingService cachingService = factory.createCachingService();
-
- factoryRegistration = context.registerService(IOseeCachingServiceFactory.class.getName(), factory, null);
- cachingServiceRegistration = context.registerService(IOseeCachingService.class.getName(), cachingService, null);
- }
-
- @Override
- public void onDeActivate() {
- if (factoryRegistration != null) {
- factoryRegistration.unregister();
- }
- if (cachingServiceRegistration != null) {
- cachingServiceRegistration.unregister();
- }
- }
-
- private IOseeCachingServiceFactory createCachingFactoryService(Map<Class<?>, Object> services) {
- final IOseeDatabaseService dbService = getService(IOseeDatabaseService.class, services);
- final IOseeModelFactoryService modelService = getService(IOseeModelFactoryService.class, services);
- final IDataTranslationService translationService = getService(IDataTranslationService.class, services);
- final IApplicationServerLookup lookupService = getService(IApplicationServerLookup.class, services);
- final IApplicationServerManager appManager = getService(IApplicationServerManager.class, services);
- IOseeDatabaseServiceProvider dbProvider = new IOseeDatabaseServiceProvider() {
- @Override
- public IOseeDatabaseService getOseeDatabaseService() throws OseeDataStoreException {
- return dbService;
- }
- };
-
- IOseeModelFactoryServiceProvider modelProvider = new IOseeModelFactoryServiceProvider() {
-
- @Override
- public IOseeModelFactoryService getOseeFactoryService() throws OseeCoreException {
- return modelService;
- }
- };
-
- IDataTranslationServiceProvider txProvider = new IDataTranslationServiceProvider() {
-
- @Override
- public IDataTranslationService getTranslationService() throws OseeCoreException {
- return translationService;
- }
- };
-
- IApplicationServerLookupProvider lookupProvider = new IApplicationServerLookupProvider() {
-
- @Override
- public IApplicationServerLookup getApplicationServerLookupService() throws OseeCoreException {
- return lookupService;
- }
- };
- return new ServerOseeCachingServiceFactory(dbProvider, modelProvider, txProvider, lookupProvider, appManager);
- }
-}
+/*******************************************************************************
+ * 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.core.datastore.internal;
+
+import java.util.Map;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.core.server.IApplicationServerLookup;
+import org.eclipse.osee.framework.core.server.IApplicationServerLookupProvider;
+import org.eclipse.osee.framework.core.server.IApplicationServerManager;
+import org.eclipse.osee.framework.core.services.IOseeCachingService;
+import org.eclipse.osee.framework.core.services.IOseeCachingServiceFactory;
+import org.eclipse.osee.framework.core.services.IOseeModelFactoryService;
+import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
+import org.eclipse.osee.framework.core.translation.IDataTranslationService;
+import org.eclipse.osee.framework.core.translation.IDataTranslationServiceProvider;
+import org.eclipse.osee.framework.core.util.AbstractTrackingHandler;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class OseeCachingServiceRegistrationHandler extends AbstractTrackingHandler {
+
+ private final static Class<?>[] SERVICE_DEPENDENCIES =
+ new Class<?>[] {IOseeDatabaseService.class, IOseeModelFactoryService.class, IDataTranslationService.class,
+ IApplicationServerLookup.class, IApplicationServerManager.class};
+
+ private ServiceRegistration factoryRegistration;
+ private ServiceRegistration cachingServiceRegistration;
+
+ @Override
+ public Class<?>[] getDependencies() {
+ return SERVICE_DEPENDENCIES;
+ }
+
+ @Override
+ public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
+ IOseeCachingServiceFactory factory = createCachingFactoryService(services);
+ IOseeCachingService cachingService = factory.createCachingService();
+
+ factoryRegistration = context.registerService(IOseeCachingServiceFactory.class.getName(), factory, null);
+ cachingServiceRegistration = context.registerService(IOseeCachingService.class.getName(), cachingService, null);
+ }
+
+ @Override
+ public void onDeActivate() {
+ if (factoryRegistration != null) {
+ factoryRegistration.unregister();
+ }
+ if (cachingServiceRegistration != null) {
+ cachingServiceRegistration.unregister();
+ }
+ }
+
+ private IOseeCachingServiceFactory createCachingFactoryService(Map<Class<?>, Object> services) {
+ final IOseeDatabaseService dbService = getService(IOseeDatabaseService.class, services);
+ final IOseeModelFactoryService modelService = getService(IOseeModelFactoryService.class, services);
+ final IDataTranslationService translationService = getService(IDataTranslationService.class, services);
+ final IApplicationServerLookup lookupService = getService(IApplicationServerLookup.class, services);
+ final IApplicationServerManager appManager = getService(IApplicationServerManager.class, services);
+ IOseeDatabaseServiceProvider dbProvider = new IOseeDatabaseServiceProvider() {
+ @Override
+ public IOseeDatabaseService getOseeDatabaseService() throws OseeDataStoreException {
+ return dbService;
+ }
+ };
+
+ IOseeModelFactoryServiceProvider modelProvider = new IOseeModelFactoryServiceProvider() {
+
+ @Override
+ public IOseeModelFactoryService getOseeFactoryService() throws OseeCoreException {
+ return modelService;
+ }
+ };
+
+ IDataTranslationServiceProvider txProvider = new IDataTranslationServiceProvider() {
+
+ @Override
+ public IDataTranslationService getTranslationService() throws OseeCoreException {
+ return translationService;
+ }
+ };
+
+ IApplicationServerLookupProvider lookupProvider = new IApplicationServerLookupProvider() {
+
+ @Override
+ public IApplicationServerLookup getApplicationServerLookupService() throws OseeCoreException {
+ return lookupService;
+ }
+ };
+ return new ServerOseeCachingServiceFactory(dbProvider, modelProvider, txProvider, lookupProvider, appManager);
+ }
+}
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 a181b0b45c..9972eb9f65 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
@@ -1,82 +1,82 @@
-/*******************************************************************************
- * 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.core.datastore.internal;
-
-import org.eclipse.osee.framework.core.datastore.cache.BranchUpdateEventImpl;
-import org.eclipse.osee.framework.core.datastore.cache.DatabaseArtifactTypeAccessor;
-import org.eclipse.osee.framework.core.datastore.cache.DatabaseAttributeTypeAccessor;
-import org.eclipse.osee.framework.core.datastore.cache.DatabaseBranchAccessor;
-import org.eclipse.osee.framework.core.datastore.cache.DatabaseOseeEnumTypeAccessor;
-import org.eclipse.osee.framework.core.datastore.cache.DatabaseRelationTypeAccessor;
-import org.eclipse.osee.framework.core.datastore.cache.DatabaseTransactionRecordAccessor;
-import org.eclipse.osee.framework.core.datastore.cache.IBranchUpdateEvent;
-import org.eclipse.osee.framework.core.model.OseeCachingService;
-import org.eclipse.osee.framework.core.model.cache.ArtifactTypeCache;
-import org.eclipse.osee.framework.core.model.cache.AttributeTypeCache;
-import org.eclipse.osee.framework.core.model.cache.BranchCache;
-import org.eclipse.osee.framework.core.model.cache.IOseeDataAccessor;
-import org.eclipse.osee.framework.core.model.cache.OseeEnumTypeCache;
-import org.eclipse.osee.framework.core.model.cache.RelationTypeCache;
-import org.eclipse.osee.framework.core.model.cache.TransactionCache;
-import org.eclipse.osee.framework.core.model.type.AttributeType;
-import org.eclipse.osee.framework.core.server.IApplicationServerLookupProvider;
-import org.eclipse.osee.framework.core.server.IApplicationServerManager;
-import org.eclipse.osee.framework.core.services.IOseeCachingService;
-import org.eclipse.osee.framework.core.services.IOseeCachingServiceFactory;
-import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
-import org.eclipse.osee.framework.core.translation.IDataTranslationServiceProvider;
-import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ServerOseeCachingServiceFactory implements IOseeCachingServiceFactory {
-
- private final IOseeDatabaseServiceProvider databaseProvider;
- private final IOseeModelFactoryServiceProvider factoryProvider;
- private final IDataTranslationServiceProvider txProvider;
- private final IApplicationServerLookupProvider serverLookUpProvider;
- private final IApplicationServerManager appManager;
-
- public ServerOseeCachingServiceFactory(IOseeDatabaseServiceProvider databaseProvider, IOseeModelFactoryServiceProvider factoryProvider, IDataTranslationServiceProvider txProvider, IApplicationServerLookupProvider serverLookUpProvider, IApplicationServerManager appManager) {
- this.databaseProvider = databaseProvider;
- this.factoryProvider = factoryProvider;
- this.txProvider = txProvider;
- this.serverLookUpProvider = serverLookUpProvider;
- this.appManager = appManager;
- }
-
- public IOseeCachingService createCachingService() {
- OseeEnumTypeCache oseeEnumTypeCache =
- new OseeEnumTypeCache(new DatabaseOseeEnumTypeAccessor(databaseProvider, factoryProvider));
-
- IOseeDataAccessor<AttributeType> attrAccessor =
- new DatabaseAttributeTypeAccessor(databaseProvider, factoryProvider, oseeEnumTypeCache);
-
- AttributeTypeCache attributeCache = new AttributeTypeCache(attrAccessor);
-
- TransactionCache txCache = new TransactionCache();
- IBranchUpdateEvent branchEventSender = new BranchUpdateEventImpl(txProvider, appManager, serverLookUpProvider);
- BranchCache branchCache =
- new BranchCache(new DatabaseBranchAccessor(databaseProvider, factoryProvider, branchEventSender, txCache));
- txCache.setAccessor(new DatabaseTransactionRecordAccessor(databaseProvider, factoryProvider, branchCache));
-
- ArtifactTypeCache artifactCache =
- new ArtifactTypeCache(new DatabaseArtifactTypeAccessor(databaseProvider, factoryProvider, branchCache,
- attributeCache));
-
- RelationTypeCache relationCache =
- new RelationTypeCache(new DatabaseRelationTypeAccessor(databaseProvider, factoryProvider, artifactCache));
-
- return new OseeCachingService(branchCache, txCache, artifactCache, attributeCache, relationCache,
- oseeEnumTypeCache);
- }
-}
+/*******************************************************************************
+ * 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.core.datastore.internal;
+
+import org.eclipse.osee.framework.core.datastore.cache.BranchUpdateEventImpl;
+import org.eclipse.osee.framework.core.datastore.cache.DatabaseArtifactTypeAccessor;
+import org.eclipse.osee.framework.core.datastore.cache.DatabaseAttributeTypeAccessor;
+import org.eclipse.osee.framework.core.datastore.cache.DatabaseBranchAccessor;
+import org.eclipse.osee.framework.core.datastore.cache.DatabaseOseeEnumTypeAccessor;
+import org.eclipse.osee.framework.core.datastore.cache.DatabaseRelationTypeAccessor;
+import org.eclipse.osee.framework.core.datastore.cache.DatabaseTransactionRecordAccessor;
+import org.eclipse.osee.framework.core.datastore.cache.IBranchUpdateEvent;
+import org.eclipse.osee.framework.core.model.OseeCachingService;
+import org.eclipse.osee.framework.core.model.cache.ArtifactTypeCache;
+import org.eclipse.osee.framework.core.model.cache.AttributeTypeCache;
+import org.eclipse.osee.framework.core.model.cache.BranchCache;
+import org.eclipse.osee.framework.core.model.cache.IOseeDataAccessor;
+import org.eclipse.osee.framework.core.model.cache.OseeEnumTypeCache;
+import org.eclipse.osee.framework.core.model.cache.RelationTypeCache;
+import org.eclipse.osee.framework.core.model.cache.TransactionCache;
+import org.eclipse.osee.framework.core.model.type.AttributeType;
+import org.eclipse.osee.framework.core.server.IApplicationServerLookupProvider;
+import org.eclipse.osee.framework.core.server.IApplicationServerManager;
+import org.eclipse.osee.framework.core.services.IOseeCachingService;
+import org.eclipse.osee.framework.core.services.IOseeCachingServiceFactory;
+import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
+import org.eclipse.osee.framework.core.translation.IDataTranslationServiceProvider;
+import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ServerOseeCachingServiceFactory implements IOseeCachingServiceFactory {
+
+ private final IOseeDatabaseServiceProvider databaseProvider;
+ private final IOseeModelFactoryServiceProvider factoryProvider;
+ private final IDataTranslationServiceProvider txProvider;
+ private final IApplicationServerLookupProvider serverLookUpProvider;
+ private final IApplicationServerManager appManager;
+
+ public ServerOseeCachingServiceFactory(IOseeDatabaseServiceProvider databaseProvider, IOseeModelFactoryServiceProvider factoryProvider, IDataTranslationServiceProvider txProvider, IApplicationServerLookupProvider serverLookUpProvider, IApplicationServerManager appManager) {
+ this.databaseProvider = databaseProvider;
+ this.factoryProvider = factoryProvider;
+ this.txProvider = txProvider;
+ this.serverLookUpProvider = serverLookUpProvider;
+ this.appManager = appManager;
+ }
+
+ public IOseeCachingService createCachingService() {
+ OseeEnumTypeCache oseeEnumTypeCache =
+ new OseeEnumTypeCache(new DatabaseOseeEnumTypeAccessor(databaseProvider, factoryProvider));
+
+ IOseeDataAccessor<AttributeType> attrAccessor =
+ new DatabaseAttributeTypeAccessor(databaseProvider, factoryProvider, oseeEnumTypeCache);
+
+ AttributeTypeCache attributeCache = new AttributeTypeCache(attrAccessor);
+
+ TransactionCache txCache = new TransactionCache();
+ IBranchUpdateEvent branchEventSender = new BranchUpdateEventImpl(txProvider, appManager, serverLookUpProvider);
+ BranchCache branchCache =
+ new BranchCache(new DatabaseBranchAccessor(databaseProvider, factoryProvider, branchEventSender, txCache));
+ txCache.setAccessor(new DatabaseTransactionRecordAccessor(databaseProvider, factoryProvider, branchCache));
+
+ ArtifactTypeCache artifactCache =
+ new ArtifactTypeCache(new DatabaseArtifactTypeAccessor(databaseProvider, factoryProvider, branchCache,
+ attributeCache));
+
+ RelationTypeCache relationCache =
+ new RelationTypeCache(new DatabaseRelationTypeAccessor(databaseProvider, factoryProvider, artifactCache));
+
+ return new OseeCachingService(branchCache, txCache, artifactCache, attributeCache, relationCache,
+ oseeEnumTypeCache);
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/data/ConstraintElement.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/data/ConstraintElement.java
index 8d7d0fa436..3ff1d10bb0 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/data/ConstraintElement.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/data/ConstraintElement.java
@@ -1,141 +1,141 @@
-/*******************************************************************************
- * 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.core.datastore.schema.data;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.TableSections;
-import org.eclipse.osee.framework.jdk.core.persistence.Xmlizable;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ConstraintElement implements Xmlizable {
-
- public enum ConstraintFields {
- id, schema, type, appliesTo, deferrable
- };
-
- private final ConstraintTypes constraintType;
- private final boolean deferrable;
- private String schema;
- private String id;
- private final List<String> columns;
-
- public ConstraintElement(ConstraintTypes constraintType, String schema, String id, boolean deferrable) {
- this.schema = schema.toUpperCase();
- this.schema = this.schema.trim();
- this.id = id.toUpperCase();
- this.id = this.id.trim();
- this.deferrable = deferrable;
- this.constraintType = constraintType;
- this.columns = new ArrayList<String>();
- }
-
- public List<String> getColumns() {
- return columns;
- }
-
- public String getId() {
- return id;
- }
-
- public String getSchema() {
- return schema;
- }
-
- public void addColumn(String columnName) {
- columnName = columnName.toUpperCase();
- columnName = columnName.trim();
- this.columns.add(columnName);
- }
-
- public void setId(String id) {
- id = id.toUpperCase();
- id = id.trim();
- this.id = id;
- }
-
- public void setSchema(String schema) {
- schema = schema.toUpperCase();
- schema = schema.trim();
- this.schema = schema;
- }
-
- public String getFullyQualifiedId() {
- if (schema != null && !schema.equals("")) {
- return schema + "." + id;
- } else {
- return id;
- }
- }
-
- /**
- * @return Returns the deferrable.
- */
- public boolean isDeferrable() {
- return deferrable;
- }
-
- public ConstraintTypes getConstraintType() {
- return constraintType;
- }
-
- public String getCommaSeparatedColumnsList() {
- return org.eclipse.osee.framework.jdk.core.util.Collections.toString(columns, ",");
- }
-
- @Override
- public String toString() {
- String toReturn = TableSections.Constraint + ": ";
- toReturn += "\t" + ConstraintFields.schema + "[" + schema + "]";
- toReturn += "\t" + ConstraintFields.id + "[" + id + "]";
- toReturn += "\t" + ConstraintFields.type + "[" + constraintType.toString() + "]";
- toReturn += "\t" + ConstraintFields.appliesTo + "[" + getCommaSeparatedColumnsList() + "]";
- toReturn += "\t" + ConstraintFields.deferrable + "[" + Boolean.toString(deferrable) + "]";
- return toReturn;
- }
-
- public Element toXml(Document doc) {
- Element constraintElement = doc.createElement(TableSections.Constraint.toString());
- constraintElement.setAttribute(ConstraintFields.schema.name(), schema);
- constraintElement.setAttribute(ConstraintFields.id.name(), id);
- constraintElement.setAttribute(ConstraintFields.type.name(), constraintType.toString());
- constraintElement.setAttribute(ConstraintFields.appliesTo.name(), getCommaSeparatedColumnsList());
- constraintElement.setAttribute(ConstraintFields.deferrable.name(), Boolean.toString(deferrable));
- return constraintElement;
- }
-
- @Override
- public boolean equals(Object otherObject) {
- if (otherObject instanceof ConstraintElement == false) {
- return false;
- }
- if (this == otherObject) {
- return true;
- }
- ConstraintElement that = (ConstraintElement) otherObject;
- return new EqualsBuilder().appendSuper(super.equals(otherObject)).append(this.constraintType,
- that.getConstraintType()).append(this.schema, that.getSchema()).append(this.id, that.getId()).append(
- this.columns, that.getColumns()).append(this.deferrable, that.deferrable).isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(37, 11).append(constraintType).append(schema).append(id).append(columns).append(
- deferrable).toHashCode();
- }
-}
+/*******************************************************************************
+ * 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.core.datastore.schema.data;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.TableSections;
+import org.eclipse.osee.framework.jdk.core.persistence.Xmlizable;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ConstraintElement implements Xmlizable {
+
+ public enum ConstraintFields {
+ id, schema, type, appliesTo, deferrable
+ };
+
+ private final ConstraintTypes constraintType;
+ private final boolean deferrable;
+ private String schema;
+ private String id;
+ private final List<String> columns;
+
+ public ConstraintElement(ConstraintTypes constraintType, String schema, String id, boolean deferrable) {
+ this.schema = schema.toUpperCase();
+ this.schema = this.schema.trim();
+ this.id = id.toUpperCase();
+ this.id = this.id.trim();
+ this.deferrable = deferrable;
+ this.constraintType = constraintType;
+ this.columns = new ArrayList<String>();
+ }
+
+ public List<String> getColumns() {
+ return columns;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getSchema() {
+ return schema;
+ }
+
+ public void addColumn(String columnName) {
+ columnName = columnName.toUpperCase();
+ columnName = columnName.trim();
+ this.columns.add(columnName);
+ }
+
+ public void setId(String id) {
+ id = id.toUpperCase();
+ id = id.trim();
+ this.id = id;
+ }
+
+ public void setSchema(String schema) {
+ schema = schema.toUpperCase();
+ schema = schema.trim();
+ this.schema = schema;
+ }
+
+ public String getFullyQualifiedId() {
+ if (schema != null && !schema.equals("")) {
+ return schema + "." + id;
+ } else {
+ return id;
+ }
+ }
+
+ /**
+ * @return Returns the deferrable.
+ */
+ public boolean isDeferrable() {
+ return deferrable;
+ }
+
+ public ConstraintTypes getConstraintType() {
+ return constraintType;
+ }
+
+ public String getCommaSeparatedColumnsList() {
+ return org.eclipse.osee.framework.jdk.core.util.Collections.toString(columns, ",");
+ }
+
+ @Override
+ public String toString() {
+ String toReturn = TableSections.Constraint + ": ";
+ toReturn += "\t" + ConstraintFields.schema + "[" + schema + "]";
+ toReturn += "\t" + ConstraintFields.id + "[" + id + "]";
+ toReturn += "\t" + ConstraintFields.type + "[" + constraintType.toString() + "]";
+ toReturn += "\t" + ConstraintFields.appliesTo + "[" + getCommaSeparatedColumnsList() + "]";
+ toReturn += "\t" + ConstraintFields.deferrable + "[" + Boolean.toString(deferrable) + "]";
+ return toReturn;
+ }
+
+ public Element toXml(Document doc) {
+ Element constraintElement = doc.createElement(TableSections.Constraint.toString());
+ constraintElement.setAttribute(ConstraintFields.schema.name(), schema);
+ constraintElement.setAttribute(ConstraintFields.id.name(), id);
+ constraintElement.setAttribute(ConstraintFields.type.name(), constraintType.toString());
+ constraintElement.setAttribute(ConstraintFields.appliesTo.name(), getCommaSeparatedColumnsList());
+ constraintElement.setAttribute(ConstraintFields.deferrable.name(), Boolean.toString(deferrable));
+ return constraintElement;
+ }
+
+ @Override
+ public boolean equals(Object otherObject) {
+ if (otherObject instanceof ConstraintElement == false) {
+ return false;
+ }
+ if (this == otherObject) {
+ return true;
+ }
+ ConstraintElement that = (ConstraintElement) otherObject;
+ return new EqualsBuilder().appendSuper(super.equals(otherObject)).append(this.constraintType,
+ that.getConstraintType()).append(this.schema, that.getSchema()).append(this.id, that.getId()).append(
+ this.columns, that.getColumns()).append(this.deferrable, that.deferrable).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(37, 11).append(constraintType).append(schema).append(id).append(columns).append(
+ deferrable).toHashCode();
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/data/ReferenceClause.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/data/ReferenceClause.java
index 17cbc88c5e..0ada2a5ab8 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/data/ReferenceClause.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/data/ReferenceClause.java
@@ -1,154 +1,154 @@
-/*******************************************************************************
- * 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.core.datastore.schema.data;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.eclipse.osee.framework.jdk.core.persistence.Xmlizable;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ReferenceClause implements Xmlizable {
- public static final String REFERENCES_TAG = "References";
-
- public enum ReferencesFields {
- schema, table, column, onUpdate, onDelete;
- }
-
- public enum OnDeleteEnum {
- NO_ACTION, RESTRICT, CASCADE, SET_NULL, UNSPECIFIED;
-
- @Override
- public String toString() {
- String toReturn = super.toString();
- toReturn = toReturn.replaceAll("_", " ");
- return toReturn;
- }
- }
-
- public enum OnUpdateEnum {
- NO_ACTION, RESTRICT, UNSPECIFIED;
-
- @Override
- public String toString() {
- String toReturn = super.toString();
- toReturn = toReturn.replaceAll("_", " ");
- return toReturn;
- }
- }
-
- private String schema;
- private String table;
- List<String> columns;
- OnDeleteEnum onDeleteAction;
- OnUpdateEnum onUpdateAction;
-
- public ReferenceClause(String schema, String table) {
- this.schema = schema.toUpperCase();
- this.schema = this.schema.trim();
- this.table = table.toUpperCase();
- this.table = this.table.trim();
- this.columns = new ArrayList<String>();
- this.onDeleteAction = OnDeleteEnum.UNSPECIFIED;
- this.onUpdateAction = OnUpdateEnum.UNSPECIFIED;
- }
-
- public void setSchema(String schema) {
- this.schema = schema;
- }
-
- public OnDeleteEnum getOnDeleteAction() {
- return onDeleteAction;
- }
-
- public OnUpdateEnum getOnUpdateAction() {
- return onUpdateAction;
- }
-
- public void setOnDeleteAction(OnDeleteEnum onDeleteAction) {
- this.onDeleteAction = onDeleteAction;
- }
-
- public void setOnUpdateAction(OnUpdateEnum onUpdateAction) {
- this.onUpdateAction = onUpdateAction;
- }
-
- public void addColumn(String column) {
- column = column.toUpperCase();
- column = column.trim();
- columns.add(column);
- }
-
- public String getFullyQualifiedTableName() {
- return schema + "." + table;
- }
-
- public List<String> getColumns() {
- return columns;
- }
-
- public String getCommaSeparatedColumnsList() {
- return org.eclipse.osee.framework.jdk.core.util.Collections.toString(columns, ",");
- }
-
- @Override
- public String toString() {
- String toReturn = REFERENCES_TAG + ": " + getFullyQualifiedTableName();
- toReturn += "\t[";
- for (String column : columns) {
- toReturn += column + " ";
- }
- toReturn += "]";
- return toReturn;
- }
-
- public Element toXml(Document doc) {
- Element refElement = doc.createElement(REFERENCES_TAG);
- refElement.setAttribute(ReferencesFields.schema.name(), schema);
- refElement.setAttribute(ReferencesFields.table.name(), table);
- refElement.setAttribute(ReferencesFields.column.name(), getCommaSeparatedColumnsList());
-
- if (!onDeleteAction.equals(OnDeleteEnum.UNSPECIFIED)) {
- refElement.setAttribute(ReferencesFields.onDelete.name(), onDeleteAction.toString());
- }
-
- if (!onUpdateAction.equals(OnUpdateEnum.UNSPECIFIED)) {
- refElement.setAttribute(ReferencesFields.onUpdate.name(), onUpdateAction.toString());
- }
- return refElement;
- }
-
- @Override
- public boolean equals(Object otherObject) {
- if (otherObject instanceof ReferenceClause == false) {
- return false;
- }
- if (this == otherObject) {
- return true;
- }
- ReferenceClause that = (ReferenceClause) otherObject;
- return new EqualsBuilder().appendSuper(super.equals(otherObject)).append(this.getFullyQualifiedTableName(),
- that.getFullyQualifiedTableName()).append(this.columns, that.getColumns()).append(this.onDeleteAction,
- that.getOnDeleteAction()).append(this.onUpdateAction, that.getOnUpdateAction()).isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(113, 67).append(schema).append(table).append(columns).append(onDeleteAction).append(
- onUpdateAction).toHashCode();
- }
-}
+/*******************************************************************************
+ * 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.core.datastore.schema.data;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.eclipse.osee.framework.jdk.core.persistence.Xmlizable;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ReferenceClause implements Xmlizable {
+ public static final String REFERENCES_TAG = "References";
+
+ public enum ReferencesFields {
+ schema, table, column, onUpdate, onDelete;
+ }
+
+ public enum OnDeleteEnum {
+ NO_ACTION, RESTRICT, CASCADE, SET_NULL, UNSPECIFIED;
+
+ @Override
+ public String toString() {
+ String toReturn = super.toString();
+ toReturn = toReturn.replaceAll("_", " ");
+ return toReturn;
+ }
+ }
+
+ public enum OnUpdateEnum {
+ NO_ACTION, RESTRICT, UNSPECIFIED;
+
+ @Override
+ public String toString() {
+ String toReturn = super.toString();
+ toReturn = toReturn.replaceAll("_", " ");
+ return toReturn;
+ }
+ }
+
+ private String schema;
+ private String table;
+ List<String> columns;
+ OnDeleteEnum onDeleteAction;
+ OnUpdateEnum onUpdateAction;
+
+ public ReferenceClause(String schema, String table) {
+ this.schema = schema.toUpperCase();
+ this.schema = this.schema.trim();
+ this.table = table.toUpperCase();
+ this.table = this.table.trim();
+ this.columns = new ArrayList<String>();
+ this.onDeleteAction = OnDeleteEnum.UNSPECIFIED;
+ this.onUpdateAction = OnUpdateEnum.UNSPECIFIED;
+ }
+
+ public void setSchema(String schema) {
+ this.schema = schema;
+ }
+
+ public OnDeleteEnum getOnDeleteAction() {
+ return onDeleteAction;
+ }
+
+ public OnUpdateEnum getOnUpdateAction() {
+ return onUpdateAction;
+ }
+
+ public void setOnDeleteAction(OnDeleteEnum onDeleteAction) {
+ this.onDeleteAction = onDeleteAction;
+ }
+
+ public void setOnUpdateAction(OnUpdateEnum onUpdateAction) {
+ this.onUpdateAction = onUpdateAction;
+ }
+
+ public void addColumn(String column) {
+ column = column.toUpperCase();
+ column = column.trim();
+ columns.add(column);
+ }
+
+ public String getFullyQualifiedTableName() {
+ return schema + "." + table;
+ }
+
+ public List<String> getColumns() {
+ return columns;
+ }
+
+ public String getCommaSeparatedColumnsList() {
+ return org.eclipse.osee.framework.jdk.core.util.Collections.toString(columns, ",");
+ }
+
+ @Override
+ public String toString() {
+ String toReturn = REFERENCES_TAG + ": " + getFullyQualifiedTableName();
+ toReturn += "\t[";
+ for (String column : columns) {
+ toReturn += column + " ";
+ }
+ toReturn += "]";
+ return toReturn;
+ }
+
+ public Element toXml(Document doc) {
+ Element refElement = doc.createElement(REFERENCES_TAG);
+ refElement.setAttribute(ReferencesFields.schema.name(), schema);
+ refElement.setAttribute(ReferencesFields.table.name(), table);
+ refElement.setAttribute(ReferencesFields.column.name(), getCommaSeparatedColumnsList());
+
+ if (!onDeleteAction.equals(OnDeleteEnum.UNSPECIFIED)) {
+ refElement.setAttribute(ReferencesFields.onDelete.name(), onDeleteAction.toString());
+ }
+
+ if (!onUpdateAction.equals(OnUpdateEnum.UNSPECIFIED)) {
+ refElement.setAttribute(ReferencesFields.onUpdate.name(), onUpdateAction.toString());
+ }
+ return refElement;
+ }
+
+ @Override
+ public boolean equals(Object otherObject) {
+ if (otherObject instanceof ReferenceClause == false) {
+ return false;
+ }
+ if (this == otherObject) {
+ return true;
+ }
+ ReferenceClause that = (ReferenceClause) otherObject;
+ return new EqualsBuilder().appendSuper(super.equals(otherObject)).append(this.getFullyQualifiedTableName(),
+ that.getFullyQualifiedTableName()).append(this.columns, that.getColumns()).append(this.onDeleteAction,
+ that.getOnDeleteAction()).append(this.onUpdateAction, that.getOnUpdateAction()).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(113, 67).append(schema).append(table).append(columns).append(onDeleteAction).append(
+ onUpdateAction).toHashCode();
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/CreateSchemaOperation.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/CreateSchemaOperation.java
index c0987f3063..1dd59f8d1c 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/CreateSchemaOperation.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/CreateSchemaOperation.java
@@ -1,58 +1,58 @@
-/*******************************************************************************
- * 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.core.datastore.schema.operations;
-
-import java.sql.DatabaseMetaData;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.datastore.internal.Activator;
-import org.eclipse.osee.framework.core.datastore.schema.data.SchemaData;
-import org.eclipse.osee.framework.core.datastore.schema.sql.SchemaSqlUtil;
-import org.eclipse.osee.framework.core.datastore.schema.sql.SqlFactory;
-import org.eclipse.osee.framework.core.datastore.schema.sql.SqlManager;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
-import org.eclipse.osee.framework.database.core.AbstractDbTxOperation;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.framework.database.core.SupportedDatabase;
-
-/**
- * @author Roberto E. Escobar
- */
-public class CreateSchemaOperation extends AbstractDbTxOperation {
- private final Map<String, SchemaData> userSchema;
- private final Map<String, SchemaData> dbSchema;
-
- public CreateSchemaOperation(IOseeDatabaseServiceProvider provider, Map<String, SchemaData> userSchema, Map<String, SchemaData> dbSchema) {
- super(provider, "Create Schema", Activator.PLUGIN_ID);
- this.userSchema = userSchema;
- this.dbSchema = dbSchema;
- }
-
- @Override
- protected void doTxWork(IProgressMonitor monitor, OseeConnection connection) throws OseeCoreException {
- DatabaseMetaData metaData = connection.getMetaData();
- SqlManager sqlManager = SqlFactory.getSqlManager(metaData);
- SchemaSqlUtil dbInit = new SchemaSqlUtil(sqlManager);
-
- Set<String> schemas = userSchema.keySet();
- dbInit.dropIndices(schemas, userSchema, dbSchema);
- dbInit.dropTables(schemas, userSchema, dbSchema);
- if (SupportedDatabase.isDatabaseType(metaData, SupportedDatabase.postgresql)) {
- dbInit.dropSchema(schemas);
- dbInit.createSchema(schemas);
- }
- dbInit.addTables(schemas, userSchema);
- dbInit.addIndices(schemas, userSchema);
- }
-
-}
+/*******************************************************************************
+ * 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.core.datastore.schema.operations;
+
+import java.sql.DatabaseMetaData;
+import java.util.Map;
+import java.util.Set;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.datastore.internal.Activator;
+import org.eclipse.osee.framework.core.datastore.schema.data.SchemaData;
+import org.eclipse.osee.framework.core.datastore.schema.sql.SchemaSqlUtil;
+import org.eclipse.osee.framework.core.datastore.schema.sql.SqlFactory;
+import org.eclipse.osee.framework.core.datastore.schema.sql.SqlManager;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
+import org.eclipse.osee.framework.database.core.AbstractDbTxOperation;
+import org.eclipse.osee.framework.database.core.OseeConnection;
+import org.eclipse.osee.framework.database.core.SupportedDatabase;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class CreateSchemaOperation extends AbstractDbTxOperation {
+ private final Map<String, SchemaData> userSchema;
+ private final Map<String, SchemaData> dbSchema;
+
+ public CreateSchemaOperation(IOseeDatabaseServiceProvider provider, Map<String, SchemaData> userSchema, Map<String, SchemaData> dbSchema) {
+ super(provider, "Create Schema", Activator.PLUGIN_ID);
+ this.userSchema = userSchema;
+ this.dbSchema = dbSchema;
+ }
+
+ @Override
+ protected void doTxWork(IProgressMonitor monitor, OseeConnection connection) throws OseeCoreException {
+ DatabaseMetaData metaData = connection.getMetaData();
+ SqlManager sqlManager = SqlFactory.getSqlManager(metaData);
+ SchemaSqlUtil dbInit = new SchemaSqlUtil(sqlManager);
+
+ Set<String> schemas = userSchema.keySet();
+ dbInit.dropIndices(schemas, userSchema, dbSchema);
+ dbInit.dropTables(schemas, userSchema, dbSchema);
+ if (SupportedDatabase.isDatabaseType(metaData, SupportedDatabase.postgresql)) {
+ dbInit.dropSchema(schemas);
+ dbInit.createSchema(schemas);
+ }
+ dbInit.addTables(schemas, userSchema);
+ dbInit.addIndices(schemas, userSchema);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/DatabaseDataImporter.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/DatabaseDataImporter.java
index 41db0cac92..c2e311f197 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/DatabaseDataImporter.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/DatabaseDataImporter.java
@@ -1,255 +1,255 @@
-/*******************************************************************************
- * 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.core.datastore.schema.operations;
-
-import java.io.File;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.logging.Level;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import org.eclipse.osee.framework.core.datastore.internal.Activator;
-import org.eclipse.osee.framework.core.datastore.schema.data.ColumnDbData;
-import org.eclipse.osee.framework.core.datastore.schema.data.ColumnMetadata;
-import org.eclipse.osee.framework.core.datastore.schema.data.TableElement;
-import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.ColumnFields;
-import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.TableDescriptionFields;
-import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.TableTags;
-import org.eclipse.osee.framework.core.datastore.schema.sql.SqlManager;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.logging.OseeLog;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * @author Roberto E. Escobar
- */
-public class DatabaseDataImporter {
- private final File directory;
- private final SqlManager sqlManager;
- private List<String> tableOrder;
- private String schemaToImportTo;
- private final Set<String> tableFilter;
-
- private class TableData extends TableElement {
- private final List<List<ColumnDbData>> rowData;
-
- public TableData() {
- rowData = new ArrayList<List<ColumnDbData>>();
- }
-
- public void addRow(List<ColumnDbData> row) {
- rowData.add(row);
- }
-
- public List<List<ColumnDbData>> getRows() {
- return rowData;
- }
- }
-
- public DatabaseDataImporter(File directory, SqlManager sqlManager) {
- this.directory = directory;
- this.sqlManager = sqlManager;
- this.tableFilter = new TreeSet<String>();
- }
-
- public void setImportOrder(List<String> tableOrder) {
- this.tableOrder = tableOrder;
- }
-
- public void setSchemaToImportTo(String schema) {
- this.schemaToImportTo = schema;
- }
-
- public void addToTableFilter(String fullyQualifiedTableName) {
- this.tableFilter.add(fullyQualifiedTableName);
- }
-
- public void clearTableFilter() {
- this.tableFilter.clear();
- }
-
- public List<File> orderFilesByImportOrder(Map<String, File> toOrder) {
- List<File> orderedSet = new ArrayList<File>();
- if (tableOrder != null && tableOrder.size() != 0) {
- for (String tableName : tableOrder) {
- String fileName = tableName + FileUtility.DB_DATA_EXTENSION;
- File file = toOrder.get(fileName);
- if (file != null) {
- orderedSet.add(file);
- }
- }
- } else {
- Set<String> keys = toOrder.keySet();
- for (String key : keys) {
- orderedSet.add(toOrder.get(key));
- }
- }
- return orderedSet;
- }
-
- public Map<String, File> filterDataToImport(Map<String, File> toProcess) {
- Map<String, File> filteredList = new HashMap<String, File>();
- if (tableFilter != null && tableFilter.size() != 0) {
- for (String tableName : tableFilter) {
- String fileName = tableName + FileUtility.DB_DATA_EXTENSION;
- File file = toProcess.get(fileName);
- if (file != null) {
- filteredList.put(fileName, file);
- }
- }
- } else {
- return toProcess;
- }
- return filteredList;
- }
-
- public void importDataIntoDatabase() {
- if (FileUtility.isValidDirectory(directory)) {
- Map<String, File> filesToProcess = getFilesToProcess();
- Map<String, File> filteredFiles = filterDataToImport(filesToProcess);
- List<File> files = orderFilesByImportOrder(filteredFiles);
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder;
- Document document;
- for (File file : files) {
- try {
- builder = factory.newDocumentBuilder();
- document = builder.parse(file);
- processData(parseXMLDbDataFile(document));
- } catch (ParserConfigurationException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, "Unable to Parse File. ", ex);
- } catch (Exception ex) {
- OseeLog.log(Activator.class, Level.SEVERE, "Exception: \n", ex);
- }
- }
- }
- }
-
- private Map<String, File> getFilesToProcess() {
- Map<String, File> toReturn = new HashMap<String, File>();
- List<File> files = FileUtility.getDBDataFileList(directory);
- for (File fileName : files) {
- toReturn.put(fileName.getName(), new File(directory + File.separator + fileName.getName()));
- }
- return toReturn;
- }
-
- private void processData(List<TableData> tables) throws OseeDataStoreException, ParseException {
- if (tables.size() != 0) {
- for (TableData tableData : tables) {
- OseeLog.log(Activator.class, Level.INFO, "Populating: [ " + tableData.getFullyQualifiedTableName() + "]\n");
- List<List<ColumnDbData>> rows = tableData.getRows();
- if (!rows.isEmpty()) {
- for (List<ColumnDbData> rowData : rows) {
- sqlManager.insertData(rowData, tableData);
- }
- }
- }
- }
- }
-
- private void parseColumnMetadata(Element tableElement, TableData tableData) {
- NodeList columnElements = tableElement.getElementsByTagName(TableTags.ColumnInfo.name());
- if (columnElements != null) {
- for (int index = 0; index < columnElements.getLength(); index++) {
- Element columnElement = (Element) columnElements.item(index);
- if (columnElement != null) {
-
- NamedNodeMap attributeMap = columnElement.getAttributes();
- if (attributeMap != null && attributeMap.getLength() != 0) {
- ColumnMetadata columnMetaData = new ColumnMetadata("");
- for (int attributeIndex = 0; attributeIndex < attributeMap.getLength(); attributeIndex++) {
- Node node = attributeMap.item(attributeIndex);
- String nodeName = node.getNodeName();
- String nodeValue = node.getTextContent();
- if (nodeName != null && !nodeName.equals("")) {
- columnMetaData.addColumnField(ColumnFields.valueOf(nodeName),
- (nodeValue != null ? nodeValue : ""));
- }
- }
- tableData.addColumn(columnMetaData);
- }
- }
- }
- }
- }
-
- private void parseRowInformation(Element tableElement, TableData tableData) {
- NodeList rowElements = tableElement.getElementsByTagName(TableTags.Row.name());
- if (rowElements != null) {
- for (int rowIndex = 0; rowIndex < rowElements.getLength(); rowIndex++) {
- Element row = (Element) rowElements.item(rowIndex);
- if (row != null) {
- NamedNodeMap attributeMap = row.getAttributes();
- if (attributeMap != null && attributeMap.getLength() != 0) {
- List<ColumnDbData> rowData = new ArrayList<ColumnDbData>();
- tableData.addRow(rowData);
- for (int attributeIndex = 0; attributeIndex < attributeMap.getLength(); attributeIndex++) {
- Node node = attributeMap.item(attributeIndex);
- String nodeName = node.getNodeName();
- String nodeValue = node.getTextContent();
- if (nodeName != null && !nodeName.equals("")) {
- rowData.add(new ColumnDbData(nodeName, (nodeValue != null ? nodeValue : "")));
- }
- }
- }
- }
- }
- }
- }
-
- private List<TableData> parseXMLDbDataFile(Document document) {
- NodeList tableElements = document.getElementsByTagName(TableTags.Table.name());
- List<TableData> tables = new ArrayList<TableData>();
- for (int index = 0; index < tableElements.getLength(); index++) {
- Element tableXmlElement = (Element) tableElements.item(index);
- if (tableXmlElement != null) {
- NamedNodeMap map = tableXmlElement.getAttributes();
- if (map != null && map.getLength() != 0) {
- Node tableName = map.getNamedItem(TableDescriptionFields.name.name());
- Node tableAddress = map.getNamedItem(TableDescriptionFields.schema.name());
- String tableNameString = "";
- String tableAddressString = "";
- if (tableName != null) {
- tableNameString = tableName.getTextContent();
- }
- if (tableAddress != null) {
- tableAddressString = tableAddress.getTextContent();
- }
-
- if (tableNameString != null && !tableNameString.equals("") && tableAddressString != null && !tableAddressString.equals("")) {
- TableData tableData = new TableData();
- tableData.addTableDescription(TableDescriptionFields.name, tableNameString);
- if (this.schemaToImportTo != null && !this.schemaToImportTo.equals("")) {
- tableData.addTableDescription(TableDescriptionFields.schema, schemaToImportTo);
- } else {
- tableData.addTableDescription(TableDescriptionFields.schema, tableAddressString);
- }
- parseRowInformation(tableXmlElement, tableData);
- parseColumnMetadata(tableXmlElement, tableData);
- tables.add(tableData);
- }
- }
- }
- }
- return tables;
- }
-}
+/*******************************************************************************
+ * 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.core.datastore.schema.operations;
+
+import java.io.File;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.logging.Level;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import org.eclipse.osee.framework.core.datastore.internal.Activator;
+import org.eclipse.osee.framework.core.datastore.schema.data.ColumnDbData;
+import org.eclipse.osee.framework.core.datastore.schema.data.ColumnMetadata;
+import org.eclipse.osee.framework.core.datastore.schema.data.TableElement;
+import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.ColumnFields;
+import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.TableDescriptionFields;
+import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.TableTags;
+import org.eclipse.osee.framework.core.datastore.schema.sql.SqlManager;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class DatabaseDataImporter {
+ private final File directory;
+ private final SqlManager sqlManager;
+ private List<String> tableOrder;
+ private String schemaToImportTo;
+ private final Set<String> tableFilter;
+
+ private class TableData extends TableElement {
+ private final List<List<ColumnDbData>> rowData;
+
+ public TableData() {
+ rowData = new ArrayList<List<ColumnDbData>>();
+ }
+
+ public void addRow(List<ColumnDbData> row) {
+ rowData.add(row);
+ }
+
+ public List<List<ColumnDbData>> getRows() {
+ return rowData;
+ }
+ }
+
+ public DatabaseDataImporter(File directory, SqlManager sqlManager) {
+ this.directory = directory;
+ this.sqlManager = sqlManager;
+ this.tableFilter = new TreeSet<String>();
+ }
+
+ public void setImportOrder(List<String> tableOrder) {
+ this.tableOrder = tableOrder;
+ }
+
+ public void setSchemaToImportTo(String schema) {
+ this.schemaToImportTo = schema;
+ }
+
+ public void addToTableFilter(String fullyQualifiedTableName) {
+ this.tableFilter.add(fullyQualifiedTableName);
+ }
+
+ public void clearTableFilter() {
+ this.tableFilter.clear();
+ }
+
+ public List<File> orderFilesByImportOrder(Map<String, File> toOrder) {
+ List<File> orderedSet = new ArrayList<File>();
+ if (tableOrder != null && tableOrder.size() != 0) {
+ for (String tableName : tableOrder) {
+ String fileName = tableName + FileUtility.DB_DATA_EXTENSION;
+ File file = toOrder.get(fileName);
+ if (file != null) {
+ orderedSet.add(file);
+ }
+ }
+ } else {
+ Set<String> keys = toOrder.keySet();
+ for (String key : keys) {
+ orderedSet.add(toOrder.get(key));
+ }
+ }
+ return orderedSet;
+ }
+
+ public Map<String, File> filterDataToImport(Map<String, File> toProcess) {
+ Map<String, File> filteredList = new HashMap<String, File>();
+ if (tableFilter != null && tableFilter.size() != 0) {
+ for (String tableName : tableFilter) {
+ String fileName = tableName + FileUtility.DB_DATA_EXTENSION;
+ File file = toProcess.get(fileName);
+ if (file != null) {
+ filteredList.put(fileName, file);
+ }
+ }
+ } else {
+ return toProcess;
+ }
+ return filteredList;
+ }
+
+ public void importDataIntoDatabase() {
+ if (FileUtility.isValidDirectory(directory)) {
+ Map<String, File> filesToProcess = getFilesToProcess();
+ Map<String, File> filteredFiles = filterDataToImport(filesToProcess);
+ List<File> files = orderFilesByImportOrder(filteredFiles);
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder;
+ Document document;
+ for (File file : files) {
+ try {
+ builder = factory.newDocumentBuilder();
+ document = builder.parse(file);
+ processData(parseXMLDbDataFile(document));
+ } catch (ParserConfigurationException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, "Unable to Parse File. ", ex);
+ } catch (Exception ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, "Exception: \n", ex);
+ }
+ }
+ }
+ }
+
+ private Map<String, File> getFilesToProcess() {
+ Map<String, File> toReturn = new HashMap<String, File>();
+ List<File> files = FileUtility.getDBDataFileList(directory);
+ for (File fileName : files) {
+ toReturn.put(fileName.getName(), new File(directory + File.separator + fileName.getName()));
+ }
+ return toReturn;
+ }
+
+ private void processData(List<TableData> tables) throws OseeDataStoreException, ParseException {
+ if (tables.size() != 0) {
+ for (TableData tableData : tables) {
+ OseeLog.log(Activator.class, Level.INFO, "Populating: [ " + tableData.getFullyQualifiedTableName() + "]\n");
+ List<List<ColumnDbData>> rows = tableData.getRows();
+ if (!rows.isEmpty()) {
+ for (List<ColumnDbData> rowData : rows) {
+ sqlManager.insertData(rowData, tableData);
+ }
+ }
+ }
+ }
+ }
+
+ private void parseColumnMetadata(Element tableElement, TableData tableData) {
+ NodeList columnElements = tableElement.getElementsByTagName(TableTags.ColumnInfo.name());
+ if (columnElements != null) {
+ for (int index = 0; index < columnElements.getLength(); index++) {
+ Element columnElement = (Element) columnElements.item(index);
+ if (columnElement != null) {
+
+ NamedNodeMap attributeMap = columnElement.getAttributes();
+ if (attributeMap != null && attributeMap.getLength() != 0) {
+ ColumnMetadata columnMetaData = new ColumnMetadata("");
+ for (int attributeIndex = 0; attributeIndex < attributeMap.getLength(); attributeIndex++) {
+ Node node = attributeMap.item(attributeIndex);
+ String nodeName = node.getNodeName();
+ String nodeValue = node.getTextContent();
+ if (nodeName != null && !nodeName.equals("")) {
+ columnMetaData.addColumnField(ColumnFields.valueOf(nodeName),
+ (nodeValue != null ? nodeValue : ""));
+ }
+ }
+ tableData.addColumn(columnMetaData);
+ }
+ }
+ }
+ }
+ }
+
+ private void parseRowInformation(Element tableElement, TableData tableData) {
+ NodeList rowElements = tableElement.getElementsByTagName(TableTags.Row.name());
+ if (rowElements != null) {
+ for (int rowIndex = 0; rowIndex < rowElements.getLength(); rowIndex++) {
+ Element row = (Element) rowElements.item(rowIndex);
+ if (row != null) {
+ NamedNodeMap attributeMap = row.getAttributes();
+ if (attributeMap != null && attributeMap.getLength() != 0) {
+ List<ColumnDbData> rowData = new ArrayList<ColumnDbData>();
+ tableData.addRow(rowData);
+ for (int attributeIndex = 0; attributeIndex < attributeMap.getLength(); attributeIndex++) {
+ Node node = attributeMap.item(attributeIndex);
+ String nodeName = node.getNodeName();
+ String nodeValue = node.getTextContent();
+ if (nodeName != null && !nodeName.equals("")) {
+ rowData.add(new ColumnDbData(nodeName, (nodeValue != null ? nodeValue : "")));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private List<TableData> parseXMLDbDataFile(Document document) {
+ NodeList tableElements = document.getElementsByTagName(TableTags.Table.name());
+ List<TableData> tables = new ArrayList<TableData>();
+ for (int index = 0; index < tableElements.getLength(); index++) {
+ Element tableXmlElement = (Element) tableElements.item(index);
+ if (tableXmlElement != null) {
+ NamedNodeMap map = tableXmlElement.getAttributes();
+ if (map != null && map.getLength() != 0) {
+ Node tableName = map.getNamedItem(TableDescriptionFields.name.name());
+ Node tableAddress = map.getNamedItem(TableDescriptionFields.schema.name());
+ String tableNameString = "";
+ String tableAddressString = "";
+ if (tableName != null) {
+ tableNameString = tableName.getTextContent();
+ }
+ if (tableAddress != null) {
+ tableAddressString = tableAddress.getTextContent();
+ }
+
+ if (tableNameString != null && !tableNameString.equals("") && tableAddressString != null && !tableAddressString.equals("")) {
+ TableData tableData = new TableData();
+ tableData.addTableDescription(TableDescriptionFields.name, tableNameString);
+ if (this.schemaToImportTo != null && !this.schemaToImportTo.equals("")) {
+ tableData.addTableDescription(TableDescriptionFields.schema, schemaToImportTo);
+ } else {
+ tableData.addTableDescription(TableDescriptionFields.schema, tableAddressString);
+ }
+ parseRowInformation(tableXmlElement, tableData);
+ parseColumnMetadata(tableXmlElement, tableData);
+ tables.add(tableData);
+ }
+ }
+ }
+ }
+ return tables;
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/OperationFactory.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/OperationFactory.java
index db96701cbc..0f3315b33a 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/OperationFactory.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/OperationFactory.java
@@ -8,44 +8,44 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.framework.core.datastore.schema.operations;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import org.eclipse.osee.framework.core.datastore.IOseeSchemaProvider;
-import org.eclipse.osee.framework.core.datastore.SchemaCreationOptions;
-import org.eclipse.osee.framework.core.datastore.internal.Activator;
-import org.eclipse.osee.framework.core.datastore.schema.data.SchemaData;
-import org.eclipse.osee.framework.core.operation.CompositeOperation;
-import org.eclipse.osee.framework.core.operation.IOperation;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
-
-/**
- * @author Roberto E. Escobar
- */
-public final class OperationFactory {
-
- private OperationFactory() {
- }
-
- public static IOperation createDbSchema(final IOseeDatabaseService databaseService, IOseeSchemaProvider schemaProvider, SchemaCreationOptions options) {
- Map<String, SchemaData> userSpecifiedConfig = new HashMap<String, SchemaData>();
- Map<String, SchemaData> currentDatabaseConfig = new HashMap<String, SchemaData>();
-
- Collection<IOperation> ops = new ArrayList<IOperation>();
- ops.add(new LoadUserSchemasOperation(userSpecifiedConfig, schemaProvider, options));
- ops.add(new ExtractDatabaseSchemaOperation(databaseService, userSpecifiedConfig.keySet(), currentDatabaseConfig));
- ops.add(new CreateSchemaOperation(new IOseeDatabaseServiceProvider() {
-
- @Override
- public IOseeDatabaseService getOseeDatabaseService() {
- return databaseService;
- }
- }, userSpecifiedConfig, currentDatabaseConfig));
-
- return new CompositeOperation("Create OSEE Schema", Activator.PLUGIN_ID, ops);
- }
-}
+package org.eclipse.osee.framework.core.datastore.schema.operations;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.osee.framework.core.datastore.IOseeSchemaProvider;
+import org.eclipse.osee.framework.core.datastore.SchemaCreationOptions;
+import org.eclipse.osee.framework.core.datastore.internal.Activator;
+import org.eclipse.osee.framework.core.datastore.schema.data.SchemaData;
+import org.eclipse.osee.framework.core.operation.CompositeOperation;
+import org.eclipse.osee.framework.core.operation.IOperation;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class OperationFactory {
+
+ private OperationFactory() {
+ }
+
+ public static IOperation createDbSchema(final IOseeDatabaseService databaseService, IOseeSchemaProvider schemaProvider, SchemaCreationOptions options) {
+ Map<String, SchemaData> userSpecifiedConfig = new HashMap<String, SchemaData>();
+ Map<String, SchemaData> currentDatabaseConfig = new HashMap<String, SchemaData>();
+
+ Collection<IOperation> ops = new ArrayList<IOperation>();
+ ops.add(new LoadUserSchemasOperation(userSpecifiedConfig, schemaProvider, options));
+ ops.add(new ExtractDatabaseSchemaOperation(databaseService, userSpecifiedConfig.keySet(), currentDatabaseConfig));
+ ops.add(new CreateSchemaOperation(new IOseeDatabaseServiceProvider() {
+
+ @Override
+ public IOseeDatabaseService getOseeDatabaseService() {
+ return databaseService;
+ }
+ }, userSpecifiedConfig, currentDatabaseConfig));
+
+ return new CompositeOperation("Create OSEE Schema", Activator.PLUGIN_ID, ops);
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/DerbySqlManager.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/DerbySqlManager.java
index b4a60793ca..57659760da 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/DerbySqlManager.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/DerbySqlManager.java
@@ -1,121 +1,121 @@
-/*******************************************************************************
- * 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.core.datastore.schema.sql;
-
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.core.datastore.internal.Activator;
-import org.eclipse.osee.framework.core.datastore.schema.data.ConstraintElement;
-import org.eclipse.osee.framework.core.datastore.schema.data.ForeignKey;
-import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause;
-import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause.OnDeleteEnum;
-import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause.OnUpdateEnum;
-import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.ColumnFields;
-import org.eclipse.osee.framework.database.core.SQL3DataType;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Roberto E. Escobar
- */
-public class DerbySqlManager extends SqlManagerImpl {
-
- /**
- * @param logger
- * @param sqlDataType
- */
- public DerbySqlManager(SqlDataType sqlDataType) {
- super(sqlDataType);
- }
-
- @Override
- public String constraintDataToSQL(ConstraintElement constraint, String tableID) {
- StringBuilder toReturn = new StringBuilder();
- String id = formatQuotedString(constraint.getId(), "\\.");
- String type = constraint.getConstraintType().toString();
- String appliesTo = formatQuotedString(constraint.getCommaSeparatedColumnsList(), ",");
-
- if (id != null && !id.equals("") && appliesTo != null && !appliesTo.equals("")) {
- toReturn.append("CONSTRAINT " + id + " " + type + " (" + appliesTo + ")");
-
- if (constraint instanceof ForeignKey) {
- ForeignKey fk = (ForeignKey) constraint;
- List<ReferenceClause> refs = fk.getReferences();
-
- for (ReferenceClause ref : refs) {
- String refTable = formatQuotedString(ref.getFullyQualifiedTableName(), "\\.");
- String refColumns = formatQuotedString(ref.getCommaSeparatedColumnsList(), ",");
-
- String onUpdate = "";
- if (!ref.getOnUpdateAction().equals(OnUpdateEnum.UNSPECIFIED)) {
- onUpdate = "ON UPDATE " + ref.getOnUpdateAction().toString();
- }
-
- String onDelete = "";
- if (!ref.getOnDeleteAction().equals(OnDeleteEnum.UNSPECIFIED)) {
- onDelete = "ON DELETE " + ref.getOnDeleteAction().toString();
- }
-
- if (refTable != null && refColumns != null && !refTable.equals("") && !refColumns.equals("")) {
- toReturn.append(" REFERENCES " + refTable + " (" + refColumns + ")");
- if (!onUpdate.equals("")) {
- toReturn.append(" " + onUpdate);
- }
-
- if (!onDelete.equals("")) {
- toReturn.append(" " + onDelete);
- }
-
- // Not Supported in Derby ?
- // if (constraint.isDeferrable()) {
- // toReturn.append(" DEFERRABLE");
- // }
- }
-
- else {
- OseeLog.log(Activator.class, Level.WARNING,
- "Skipping CONSTRAINT at Table: " + tableID + "\n\t " + fk.toString());
- }
-
- }
- }
- } else {
- OseeLog.log(Activator.class, Level.WARNING,
- "Skipping CONSTRAINT at Table: " + tableID + "\n\t " + constraint.toString());
- }
- return toReturn.toString();
- }
-
- @Override
- public String columnDataToSQL(Map<ColumnFields, String> column) {
- StringBuilder toReturn = new StringBuilder();
-
- String columnLimits = column.get(ColumnFields.limits);
- String defaultValue = column.get(ColumnFields.defaultValue);
-
- SQL3DataType dataType = SQL3DataType.valueOf(column.get(ColumnFields.type));
- columnLimits = sqlDataType.getLimit(dataType, columnLimits);
- toReturn.append("\"");
- toReturn.append(column.get(ColumnFields.id));
- toReturn.append("\"");
- toReturn.append(" ");
- toReturn.append(sqlDataType.getType(dataType));
-
- if (columnLimits != null && !columnLimits.equals("")) {
- toReturn.append(" (" + columnLimits + ")");
- }
- if (defaultValue != null && !defaultValue.equals("")) {
- toReturn.append(" " + defaultValue);
- }
- return toReturn.toString();
- }
-}
+/*******************************************************************************
+ * 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.core.datastore.schema.sql;
+
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.datastore.internal.Activator;
+import org.eclipse.osee.framework.core.datastore.schema.data.ConstraintElement;
+import org.eclipse.osee.framework.core.datastore.schema.data.ForeignKey;
+import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause;
+import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause.OnDeleteEnum;
+import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause.OnUpdateEnum;
+import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.ColumnFields;
+import org.eclipse.osee.framework.database.core.SQL3DataType;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class DerbySqlManager extends SqlManagerImpl {
+
+ /**
+ * @param logger
+ * @param sqlDataType
+ */
+ public DerbySqlManager(SqlDataType sqlDataType) {
+ super(sqlDataType);
+ }
+
+ @Override
+ public String constraintDataToSQL(ConstraintElement constraint, String tableID) {
+ StringBuilder toReturn = new StringBuilder();
+ String id = formatQuotedString(constraint.getId(), "\\.");
+ String type = constraint.getConstraintType().toString();
+ String appliesTo = formatQuotedString(constraint.getCommaSeparatedColumnsList(), ",");
+
+ if (id != null && !id.equals("") && appliesTo != null && !appliesTo.equals("")) {
+ toReturn.append("CONSTRAINT " + id + " " + type + " (" + appliesTo + ")");
+
+ if (constraint instanceof ForeignKey) {
+ ForeignKey fk = (ForeignKey) constraint;
+ List<ReferenceClause> refs = fk.getReferences();
+
+ for (ReferenceClause ref : refs) {
+ String refTable = formatQuotedString(ref.getFullyQualifiedTableName(), "\\.");
+ String refColumns = formatQuotedString(ref.getCommaSeparatedColumnsList(), ",");
+
+ String onUpdate = "";
+ if (!ref.getOnUpdateAction().equals(OnUpdateEnum.UNSPECIFIED)) {
+ onUpdate = "ON UPDATE " + ref.getOnUpdateAction().toString();
+ }
+
+ String onDelete = "";
+ if (!ref.getOnDeleteAction().equals(OnDeleteEnum.UNSPECIFIED)) {
+ onDelete = "ON DELETE " + ref.getOnDeleteAction().toString();
+ }
+
+ if (refTable != null && refColumns != null && !refTable.equals("") && !refColumns.equals("")) {
+ toReturn.append(" REFERENCES " + refTable + " (" + refColumns + ")");
+ if (!onUpdate.equals("")) {
+ toReturn.append(" " + onUpdate);
+ }
+
+ if (!onDelete.equals("")) {
+ toReturn.append(" " + onDelete);
+ }
+
+ // Not Supported in Derby ?
+ // if (constraint.isDeferrable()) {
+ // toReturn.append(" DEFERRABLE");
+ // }
+ }
+
+ else {
+ OseeLog.log(Activator.class, Level.WARNING,
+ "Skipping CONSTRAINT at Table: " + tableID + "\n\t " + fk.toString());
+ }
+
+ }
+ }
+ } else {
+ OseeLog.log(Activator.class, Level.WARNING,
+ "Skipping CONSTRAINT at Table: " + tableID + "\n\t " + constraint.toString());
+ }
+ return toReturn.toString();
+ }
+
+ @Override
+ public String columnDataToSQL(Map<ColumnFields, String> column) {
+ StringBuilder toReturn = new StringBuilder();
+
+ String columnLimits = column.get(ColumnFields.limits);
+ String defaultValue = column.get(ColumnFields.defaultValue);
+
+ SQL3DataType dataType = SQL3DataType.valueOf(column.get(ColumnFields.type));
+ columnLimits = sqlDataType.getLimit(dataType, columnLimits);
+ toReturn.append("\"");
+ toReturn.append(column.get(ColumnFields.id));
+ toReturn.append("\"");
+ toReturn.append(" ");
+ toReturn.append(sqlDataType.getType(dataType));
+
+ if (columnLimits != null && !columnLimits.equals("")) {
+ toReturn.append(" (" + columnLimits + ")");
+ }
+ if (defaultValue != null && !defaultValue.equals("")) {
+ toReturn.append(" " + defaultValue);
+ }
+ return toReturn.toString();
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/MysqlSqlManager.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/MysqlSqlManager.java
index 6e9afb8f3f..18411b259e 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/MysqlSqlManager.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/MysqlSqlManager.java
@@ -1,158 +1,158 @@
-/*******************************************************************************
- * 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.core.datastore.schema.sql;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-import org.apache.commons.lang.StringUtils;
-import org.eclipse.osee.framework.core.datastore.internal.Activator;
-import org.eclipse.osee.framework.core.datastore.schema.data.ColumnMetadata;
-import org.eclipse.osee.framework.core.datastore.schema.data.ConstraintElement;
-import org.eclipse.osee.framework.core.datastore.schema.data.ForeignKey;
-import org.eclipse.osee.framework.core.datastore.schema.data.IndexElement;
-import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause;
-import org.eclipse.osee.framework.core.datastore.schema.data.TableElement;
-import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause.OnDeleteEnum;
-import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause.OnUpdateEnum;
-import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.ColumnFields;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.database.core.ConnectionHandler;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public class MysqlSqlManager extends SqlManagerImpl {
-
- /**
- * @param sqlDataType
- */
- public MysqlSqlManager(SqlDataType sqlDataType) {
- super(sqlDataType);
- }
-
- private String handleColumnCreationSection(OseeConnection connection, Map<String, ColumnMetadata> columns) {
- List<String> lines = new ArrayList<String>();
- Set<String> keys = columns.keySet();
- for (String key : keys) {
- Map<ColumnFields, String> column = columns.get(key).getColumnFields();
- lines.add(columnDataToSQL(column));
- }
- String toExecute = org.eclipse.osee.framework.jdk.core.util.Collections.toString(lines, ",\n");
- return toExecute;
- }
-
- public void createTable(OseeConnection connection, TableElement tableDef) throws OseeDataStoreException {
- String toExecute = "CREATE TABLE " + tableDef.getFullyQualifiedTableName() + " ( \n";
- toExecute += handleColumnCreationSection(connection, tableDef.getColumns());
- toExecute += handleConstraintCreationSection(tableDef.getConstraints(), tableDef.getFullyQualifiedTableName());
- toExecute +=
- handleConstraintCreationSection(tableDef.getForeignKeyConstraints(), tableDef.getFullyQualifiedTableName());
- toExecute += " \n)\n";
- OseeLog.log(Activator.class, Level.INFO, "Creating Table: [ " + tableDef.getFullyQualifiedTableName() + "]");
- ConnectionHandler.runPreparedUpdate(connection, toExecute);
- }
-
- @Override
- public void dropTable(TableElement tableDef) throws OseeDataStoreException {
- String toExecute = "DROP TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(), "\\.");
- OseeLog.log(Activator.class, Level.INFO, "Dropping Table: [ " + tableDef.getFullyQualifiedTableName() + "]");
- ConnectionHandler.runPreparedUpdate(toExecute);
- }
-
- @Override
- protected String formatQuotedString(String value, String splitAt) {
- String[] array = value.split(splitAt);
- for (int index = 0; index < array.length; index++) {
- array[index] = array[index];
- }
- return StringUtils.join(array, splitAt.replaceAll("\\\\", ""));
- }
-
- @Override
- public void dropIndex(TableElement tableDef) throws OseeDataStoreException {
- List<IndexElement> tableIndices = tableDef.getIndexData();
- String tableName = tableDef.getFullyQualifiedTableName();
- for (IndexElement iData : tableIndices) {
- if (iData.ignoreMySql()) {
- continue;
- }
- OseeLog.log(Activator.class, Level.INFO, String.format("Dropping Index: [%s] FROM [%s]",
- iData.getId(), tableName));
- if (iData.getId().equals("PRIMARY")) {
- ConnectionHandler.runPreparedUpdate("ALTER TABLE " + tableDef.getFullyQualifiedTableName() + " DROP PRIMARY KEY");
- } else {
- ConnectionHandler.runPreparedUpdate("ALTER TABLE " + tableDef.getFullyQualifiedTableName() + " DROP INDEX " + iData.getId());
- }
- }
- }
-
- @Override
- public String constraintDataToSQL(ConstraintElement constraint, String tableID) {
- StringBuilder toReturn = new StringBuilder();
- String id = formatQuotedString(constraint.getId(), "\\.");
- String type = constraint.getConstraintType().toString();
- String appliesTo = formatQuotedString(constraint.getCommaSeparatedColumnsList(), ",");
-
- if (id != null && !id.equals("") && appliesTo != null && !appliesTo.equals("")) {
- toReturn.append("CONSTRAINT " + id + " " + type + " (" + appliesTo + ")");
-
- if (constraint instanceof ForeignKey) {
- ForeignKey fk = (ForeignKey) constraint;
- List<ReferenceClause> refs = fk.getReferences();
-
- for (ReferenceClause ref : refs) {
- String refTable = formatQuotedString(ref.getFullyQualifiedTableName(), "\\.");
- String refColumns = formatQuotedString(ref.getCommaSeparatedColumnsList(), ",");
-
- String onUpdate = "";
- if (!ref.getOnUpdateAction().equals(OnUpdateEnum.UNSPECIFIED)) {
- onUpdate = "ON UPDATE " + ref.getOnUpdateAction().toString();
- }
-
- String onDelete = "";
- if (!ref.getOnDeleteAction().equals(OnDeleteEnum.UNSPECIFIED)) {
- onDelete = "ON DELETE " + ref.getOnDeleteAction().toString();
- }
-
- if (refTable != null && refColumns != null && !refTable.equals("") && !refColumns.equals("")) {
- toReturn.append(" REFERENCES " + refTable + " (" + refColumns + ")");
- if (!onUpdate.equals("")) {
- toReturn.append(" " + onUpdate);
- }
-
- if (!onDelete.equals("")) {
- toReturn.append(" " + onDelete);
- }
-
- // if (constraint.isDeferrable()) {
- // toReturn.append(" DEFERRABLE");
- // }
- }
-
- else {
- OseeLog.log(Activator.class, Level.WARNING,
- "Skipping CONSTRAINT at Table: " + tableID + "\n\t " + fk.toString());
- }
-
- }
- }
- } else {
- OseeLog.log(Activator.class, Level.WARNING,
- "Skipping CONSTRAINT at Table: " + tableID + "\n\t " + constraint.toString());
- }
- return toReturn.toString();
- }
-}
+/*******************************************************************************
+ * 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.core.datastore.schema.sql;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.osee.framework.core.datastore.internal.Activator;
+import org.eclipse.osee.framework.core.datastore.schema.data.ColumnMetadata;
+import org.eclipse.osee.framework.core.datastore.schema.data.ConstraintElement;
+import org.eclipse.osee.framework.core.datastore.schema.data.ForeignKey;
+import org.eclipse.osee.framework.core.datastore.schema.data.IndexElement;
+import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause;
+import org.eclipse.osee.framework.core.datastore.schema.data.TableElement;
+import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause.OnDeleteEnum;
+import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause.OnUpdateEnum;
+import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.ColumnFields;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.database.core.ConnectionHandler;
+import org.eclipse.osee.framework.database.core.OseeConnection;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Andrew M. Finkbeiner
+ */
+public class MysqlSqlManager extends SqlManagerImpl {
+
+ /**
+ * @param sqlDataType
+ */
+ public MysqlSqlManager(SqlDataType sqlDataType) {
+ super(sqlDataType);
+ }
+
+ private String handleColumnCreationSection(OseeConnection connection, Map<String, ColumnMetadata> columns) {
+ List<String> lines = new ArrayList<String>();
+ Set<String> keys = columns.keySet();
+ for (String key : keys) {
+ Map<ColumnFields, String> column = columns.get(key).getColumnFields();
+ lines.add(columnDataToSQL(column));
+ }
+ String toExecute = org.eclipse.osee.framework.jdk.core.util.Collections.toString(lines, ",\n");
+ return toExecute;
+ }
+
+ public void createTable(OseeConnection connection, TableElement tableDef) throws OseeDataStoreException {
+ String toExecute = "CREATE TABLE " + tableDef.getFullyQualifiedTableName() + " ( \n";
+ toExecute += handleColumnCreationSection(connection, tableDef.getColumns());
+ toExecute += handleConstraintCreationSection(tableDef.getConstraints(), tableDef.getFullyQualifiedTableName());
+ toExecute +=
+ handleConstraintCreationSection(tableDef.getForeignKeyConstraints(), tableDef.getFullyQualifiedTableName());
+ toExecute += " \n)\n";
+ OseeLog.log(Activator.class, Level.INFO, "Creating Table: [ " + tableDef.getFullyQualifiedTableName() + "]");
+ ConnectionHandler.runPreparedUpdate(connection, toExecute);
+ }
+
+ @Override
+ public void dropTable(TableElement tableDef) throws OseeDataStoreException {
+ String toExecute = "DROP TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(), "\\.");
+ OseeLog.log(Activator.class, Level.INFO, "Dropping Table: [ " + tableDef.getFullyQualifiedTableName() + "]");
+ ConnectionHandler.runPreparedUpdate(toExecute);
+ }
+
+ @Override
+ protected String formatQuotedString(String value, String splitAt) {
+ String[] array = value.split(splitAt);
+ for (int index = 0; index < array.length; index++) {
+ array[index] = array[index];
+ }
+ return StringUtils.join(array, splitAt.replaceAll("\\\\", ""));
+ }
+
+ @Override
+ public void dropIndex(TableElement tableDef) throws OseeDataStoreException {
+ List<IndexElement> tableIndices = tableDef.getIndexData();
+ String tableName = tableDef.getFullyQualifiedTableName();
+ for (IndexElement iData : tableIndices) {
+ if (iData.ignoreMySql()) {
+ continue;
+ }
+ OseeLog.log(Activator.class, Level.INFO, String.format("Dropping Index: [%s] FROM [%s]",
+ iData.getId(), tableName));
+ if (iData.getId().equals("PRIMARY")) {
+ ConnectionHandler.runPreparedUpdate("ALTER TABLE " + tableDef.getFullyQualifiedTableName() + " DROP PRIMARY KEY");
+ } else {
+ ConnectionHandler.runPreparedUpdate("ALTER TABLE " + tableDef.getFullyQualifiedTableName() + " DROP INDEX " + iData.getId());
+ }
+ }
+ }
+
+ @Override
+ public String constraintDataToSQL(ConstraintElement constraint, String tableID) {
+ StringBuilder toReturn = new StringBuilder();
+ String id = formatQuotedString(constraint.getId(), "\\.");
+ String type = constraint.getConstraintType().toString();
+ String appliesTo = formatQuotedString(constraint.getCommaSeparatedColumnsList(), ",");
+
+ if (id != null && !id.equals("") && appliesTo != null && !appliesTo.equals("")) {
+ toReturn.append("CONSTRAINT " + id + " " + type + " (" + appliesTo + ")");
+
+ if (constraint instanceof ForeignKey) {
+ ForeignKey fk = (ForeignKey) constraint;
+ List<ReferenceClause> refs = fk.getReferences();
+
+ for (ReferenceClause ref : refs) {
+ String refTable = formatQuotedString(ref.getFullyQualifiedTableName(), "\\.");
+ String refColumns = formatQuotedString(ref.getCommaSeparatedColumnsList(), ",");
+
+ String onUpdate = "";
+ if (!ref.getOnUpdateAction().equals(OnUpdateEnum.UNSPECIFIED)) {
+ onUpdate = "ON UPDATE " + ref.getOnUpdateAction().toString();
+ }
+
+ String onDelete = "";
+ if (!ref.getOnDeleteAction().equals(OnDeleteEnum.UNSPECIFIED)) {
+ onDelete = "ON DELETE " + ref.getOnDeleteAction().toString();
+ }
+
+ if (refTable != null && refColumns != null && !refTable.equals("") && !refColumns.equals("")) {
+ toReturn.append(" REFERENCES " + refTable + " (" + refColumns + ")");
+ if (!onUpdate.equals("")) {
+ toReturn.append(" " + onUpdate);
+ }
+
+ if (!onDelete.equals("")) {
+ toReturn.append(" " + onDelete);
+ }
+
+ // if (constraint.isDeferrable()) {
+ // toReturn.append(" DEFERRABLE");
+ // }
+ }
+
+ else {
+ OseeLog.log(Activator.class, Level.WARNING,
+ "Skipping CONSTRAINT at Table: " + tableID + "\n\t " + fk.toString());
+ }
+
+ }
+ }
+ } else {
+ OseeLog.log(Activator.class, Level.WARNING,
+ "Skipping CONSTRAINT at Table: " + tableID + "\n\t " + constraint.toString());
+ }
+ return toReturn.toString();
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/OracleSqlManager.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/OracleSqlManager.java
index f00c016f4e..343feae7a3 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/OracleSqlManager.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/OracleSqlManager.java
@@ -1,82 +1,82 @@
-/*******************************************************************************
- * 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.core.datastore.schema.sql;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.core.datastore.internal.Activator;
-import org.eclipse.osee.framework.core.datastore.schema.data.ColumnMetadata;
-import org.eclipse.osee.framework.core.datastore.schema.data.IndexElement;
-import org.eclipse.osee.framework.core.datastore.schema.data.TableElement;
-import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.ColumnFields;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.database.core.ConnectionHandler;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Roberto E. Escobar
- */
-public class OracleSqlManager extends SqlManager {
-
- public OracleSqlManager(SqlDataType sqlDataType) {
- super(sqlDataType);
- }
-
- protected String handleColumnCreationSection(Map<String, ColumnMetadata> columns) {
- List<String> lines = new ArrayList<String>();
- Set<String> keys = columns.keySet();
- for (String key : keys) {
- Map<ColumnFields, String> column = columns.get(key).getColumnFields();
- lines.add(columnDataToSQL(column));
- }
- String toExecute = org.eclipse.osee.framework.jdk.core.util.Collections.toString(lines, ",\n");
- return toExecute;
- }
-
- @Override
- public void createTable(TableElement tableDef) throws OseeDataStoreException {
- StringBuilder toExecute = new StringBuilder();
- toExecute.append(SqlManager.CREATE_STRING + " TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(),
- "\\.") + " ( \n");
- toExecute.append(handleColumnCreationSection(tableDef.getColumns()));
- toExecute.append(handleConstraintCreationSection(tableDef.getConstraints(), tableDef.getFullyQualifiedTableName()));
- toExecute.append(handleConstraintCreationSection(tableDef.getForeignKeyConstraints(),
- tableDef.getFullyQualifiedTableName()));
- toExecute.append(" \n)");
- toExecute.append(" tablespace ");
- toExecute.append(tableDef.getTablespace());
- toExecute.append("\n");
- OseeLog.log(Activator.class, Level.FINE,
- "Creating Table: [ " + tableDef.getFullyQualifiedTableName() + "]");
- ConnectionHandler.runPreparedUpdate(toExecute.toString());
- }
-
- @Override
- protected String createIndexPostProcess(IndexElement indexElement, String original) {
- StringBuilder buffer = new StringBuilder(original);
- buffer.append(" tablespace ");
- buffer.append(indexElement.getTablespace());
- return buffer.toString();
- }
-
- @Override
- public void dropTable(TableElement tableDef) throws OseeDataStoreException {
- StringBuilder toExecute = new StringBuilder();
- toExecute.append(SqlManager.DROP_STRING + " TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(),
- "\\.") + " cascade constraints purge");
- OseeLog.log(Activator.class, Level.FINE,
- "Dropping Table: [ " + tableDef.getFullyQualifiedTableName() + "]");
- ConnectionHandler.runPreparedUpdate(toExecute.toString());
- }
-}
+/*******************************************************************************
+ * 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.core.datastore.schema.sql;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.datastore.internal.Activator;
+import org.eclipse.osee.framework.core.datastore.schema.data.ColumnMetadata;
+import org.eclipse.osee.framework.core.datastore.schema.data.IndexElement;
+import org.eclipse.osee.framework.core.datastore.schema.data.TableElement;
+import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.ColumnFields;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.database.core.ConnectionHandler;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class OracleSqlManager extends SqlManager {
+
+ public OracleSqlManager(SqlDataType sqlDataType) {
+ super(sqlDataType);
+ }
+
+ protected String handleColumnCreationSection(Map<String, ColumnMetadata> columns) {
+ List<String> lines = new ArrayList<String>();
+ Set<String> keys = columns.keySet();
+ for (String key : keys) {
+ Map<ColumnFields, String> column = columns.get(key).getColumnFields();
+ lines.add(columnDataToSQL(column));
+ }
+ String toExecute = org.eclipse.osee.framework.jdk.core.util.Collections.toString(lines, ",\n");
+ return toExecute;
+ }
+
+ @Override
+ public void createTable(TableElement tableDef) throws OseeDataStoreException {
+ StringBuilder toExecute = new StringBuilder();
+ toExecute.append(SqlManager.CREATE_STRING + " TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(),
+ "\\.") + " ( \n");
+ toExecute.append(handleColumnCreationSection(tableDef.getColumns()));
+ toExecute.append(handleConstraintCreationSection(tableDef.getConstraints(), tableDef.getFullyQualifiedTableName()));
+ toExecute.append(handleConstraintCreationSection(tableDef.getForeignKeyConstraints(),
+ tableDef.getFullyQualifiedTableName()));
+ toExecute.append(" \n)");
+ toExecute.append(" tablespace ");
+ toExecute.append(tableDef.getTablespace());
+ toExecute.append("\n");
+ OseeLog.log(Activator.class, Level.FINE,
+ "Creating Table: [ " + tableDef.getFullyQualifiedTableName() + "]");
+ ConnectionHandler.runPreparedUpdate(toExecute.toString());
+ }
+
+ @Override
+ protected String createIndexPostProcess(IndexElement indexElement, String original) {
+ StringBuilder buffer = new StringBuilder(original);
+ buffer.append(" tablespace ");
+ buffer.append(indexElement.getTablespace());
+ return buffer.toString();
+ }
+
+ @Override
+ public void dropTable(TableElement tableDef) throws OseeDataStoreException {
+ StringBuilder toExecute = new StringBuilder();
+ toExecute.append(SqlManager.DROP_STRING + " TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(),
+ "\\.") + " cascade constraints purge");
+ OseeLog.log(Activator.class, Level.FINE,
+ "Dropping Table: [ " + tableDef.getFullyQualifiedTableName() + "]");
+ ConnectionHandler.runPreparedUpdate(toExecute.toString());
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/PostgreSqlManager.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/PostgreSqlManager.java
index 9036b5cd7c..cd78abf526 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/PostgreSqlManager.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/PostgreSqlManager.java
@@ -1,201 +1,201 @@
-/*******************************************************************************
- * 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.core.datastore.schema.sql;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-import org.apache.commons.lang.StringUtils;
-import org.eclipse.osee.framework.core.datastore.internal.Activator;
-import org.eclipse.osee.framework.core.datastore.schema.data.AppliesToClause;
-import org.eclipse.osee.framework.core.datastore.schema.data.ColumnMetadata;
-import org.eclipse.osee.framework.core.datastore.schema.data.ConstraintElement;
-import org.eclipse.osee.framework.core.datastore.schema.data.ForeignKey;
-import org.eclipse.osee.framework.core.datastore.schema.data.IndexElement;
-import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause;
-import org.eclipse.osee.framework.core.datastore.schema.data.TableElement;
-import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause.OnDeleteEnum;
-import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause.OnUpdateEnum;
-import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.ColumnFields;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.database.core.ConnectionHandler;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public class PostgreSqlManager extends SqlManagerImpl {
- /**
- * @param sqlDataType
- */
- public PostgreSqlManager(SqlDataType sqlDataType) {
- super(sqlDataType);
- }
-
- private String handleColumnCreationSection(OseeConnection connection, Map<String, ColumnMetadata> columns) {
- List<String> lines = new ArrayList<String>();
- Set<String> keys = columns.keySet();
- for (String key : keys) {
- Map<ColumnFields, String> column = columns.get(key).getColumnFields();
- lines.add(columnDataToSQL(column));
- }
- String toExecute = org.eclipse.osee.framework.jdk.core.util.Collections.toString(lines, ",\n");
- return toExecute;
- }
-
- public void createTable(OseeConnection connection, TableElement tableDef) throws OseeDataStoreException {
- String toExecute = "CREATE TABLE " + tableDef.getFullyQualifiedTableName() + " ( \n";
- toExecute += handleColumnCreationSection(connection, tableDef.getColumns());
- toExecute += handleConstraintCreationSection(tableDef.getConstraints(), tableDef.getFullyQualifiedTableName());
- toExecute +=
- handleConstraintCreationSection(tableDef.getForeignKeyConstraints(), tableDef.getFullyQualifiedTableName());
- toExecute += " \n)\n";
- OseeLog.log(Activator.class, Level.FINE,
- "Creating Table: [ " + tableDef.getFullyQualifiedTableName() + "]");
- ConnectionHandler.runPreparedUpdate(connection, toExecute);
- }
-
- @Override
- public void dropTable(TableElement tableDef) throws OseeDataStoreException {
- String toExecute = "DROP TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(), "\\.") + " CASCADE";
- OseeLog.log(Activator.class, Level.FINE,
- "Dropping Table: [ " + tableDef.getFullyQualifiedTableName() + "]");
- ConnectionHandler.runPreparedUpdate(toExecute);
- }
-
- @Override
- protected String formatQuotedString(String value, String splitAt) {
- String[] array = value.split(splitAt);
- for (int index = 0; index < array.length; index++) {
- array[index] = array[index];
- }
- return StringUtils.join(array, splitAt.replaceAll("\\\\", ""));
- }
-
- public void dropIndex(OseeConnection connection, TableElement tableDef) throws OseeDataStoreException {
- List<IndexElement> tableIndices = tableDef.getIndexData();
- String tableName = tableDef.getFullyQualifiedTableName();
- for (IndexElement iData : tableIndices) {
- if (iData.ignoreMySql()) {
- continue;
- }
- OseeLog.log(Activator.class, Level.FINE, String.format("Dropping Index: [%s] FROM [%s]\n",
- iData.getId(), tableName));
- if (iData.getId().equals("PRIMARY")) {
- ConnectionHandler.runPreparedUpdate(connection,
- "ALTER TABLE " + tableDef.getFullyQualifiedTableName() + " DROP PRIMARY KEY");
- } else {
- ConnectionHandler.runPreparedUpdate(connection,
- "ALTER TABLE " + tableDef.getFullyQualifiedTableName() + " DROP INDEX " + iData.getId());
- }
- }
- }
-
- @Override
- public String constraintDataToSQL(ConstraintElement constraint, String tableID) {
- StringBuilder toReturn = new StringBuilder();
- String id = formatQuotedString(constraint.getId(), "\\.");
- String type = constraint.getConstraintType().toString();
- String appliesTo = formatQuotedString(constraint.getCommaSeparatedColumnsList(), ",");
-
- if (id != null && !id.equals("") && appliesTo != null && !appliesTo.equals("")) {
- toReturn.append("CONSTRAINT " + id + " " + type + " (" + appliesTo + ")");
-
- if (constraint instanceof ForeignKey) {
- ForeignKey fk = (ForeignKey) constraint;
- List<ReferenceClause> refs = fk.getReferences();
-
- for (ReferenceClause ref : refs) {
- String refTable = formatQuotedString(ref.getFullyQualifiedTableName(), "\\.");
- String refColumns = formatQuotedString(ref.getCommaSeparatedColumnsList(), ",");
-
- String onUpdate = "";
- if (!ref.getOnUpdateAction().equals(OnUpdateEnum.UNSPECIFIED)) {
- onUpdate = "ON UPDATE " + ref.getOnUpdateAction().toString();
- }
-
- String onDelete = "";
- if (!ref.getOnDeleteAction().equals(OnDeleteEnum.UNSPECIFIED)) {
- onDelete = "ON DELETE " + ref.getOnDeleteAction().toString();
- }
-
- if (refTable != null && refColumns != null && !refTable.equals("") && !refColumns.equals("")) {
- toReturn.append(" REFERENCES " + refTable + " (" + refColumns + ")");
- if (!onUpdate.equals("")) {
- toReturn.append(" " + onUpdate);
- }
-
- if (!onDelete.equals("")) {
- toReturn.append(" " + onDelete);
- }
-
- if (constraint.isDeferrable()) {
- toReturn.append(" DEFERRABLE");
- }
- }
-
- else {
- OseeLog.log(Activator.class, Level.WARNING,
- "Skipping CONSTRAINT at Table: " + tableID + "\n\t " + fk.toString());
- }
-
- }
- }
- } else {
- OseeLog.log(Activator.class, Level.WARNING,
- "Skipping CONSTRAINT at Table: " + tableID + "\n\t " + constraint.toString());
- }
- return toReturn.toString();
- }
-
- public void createIndex(OseeConnection connection, TableElement tableDef) throws OseeDataStoreException {
- List<IndexElement> tableIndices = tableDef.getIndexData();
- String indexId = null;
- StringBuilder appliesTo = new StringBuilder();
- String tableName = formatQuotedString(tableDef.getFullyQualifiedTableName(), "\\.");
- for (IndexElement iData : tableIndices) {
- if (iData.ignoreMySql()) {
- continue;
- }
- indexId = iData.getId();
- appliesTo.delete(0, appliesTo.length());
-
- List<AppliesToClause> appliesToList = iData.getAppliesToList();
- for (int index = 0; index < appliesToList.size(); index++) {
- AppliesToClause record = appliesToList.get(index);
- appliesTo.append(record.getColumnName());
-
- // switch (record.getOrderType()) {
- // case Ascending:
- // appliesTo.append(" ASC");
- // break;
- // case Descending:
- // appliesTo.append(" DESC");
- // break;
- // default:
- // break;
- // }
- if (index + 1 < appliesToList.size()) {
- appliesTo.append(", ");
- }
- }
- String toExecute =
- String.format(CREATE_STRING + " " + iData.getIndexType() + " INDEX %s ON %s (%s)", indexId, tableName,
- appliesTo);
- OseeLog.log(Activator.class, Level.FINE, toExecute);
- ConnectionHandler.runPreparedUpdate(connection, toExecute);
- }
- }
-
-}
+/*******************************************************************************
+ * 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.core.datastore.schema.sql;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.osee.framework.core.datastore.internal.Activator;
+import org.eclipse.osee.framework.core.datastore.schema.data.AppliesToClause;
+import org.eclipse.osee.framework.core.datastore.schema.data.ColumnMetadata;
+import org.eclipse.osee.framework.core.datastore.schema.data.ConstraintElement;
+import org.eclipse.osee.framework.core.datastore.schema.data.ForeignKey;
+import org.eclipse.osee.framework.core.datastore.schema.data.IndexElement;
+import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause;
+import org.eclipse.osee.framework.core.datastore.schema.data.TableElement;
+import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause.OnDeleteEnum;
+import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause.OnUpdateEnum;
+import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.ColumnFields;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.database.core.ConnectionHandler;
+import org.eclipse.osee.framework.database.core.OseeConnection;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Andrew M. Finkbeiner
+ */
+public class PostgreSqlManager extends SqlManagerImpl {
+ /**
+ * @param sqlDataType
+ */
+ public PostgreSqlManager(SqlDataType sqlDataType) {
+ super(sqlDataType);
+ }
+
+ private String handleColumnCreationSection(OseeConnection connection, Map<String, ColumnMetadata> columns) {
+ List<String> lines = new ArrayList<String>();
+ Set<String> keys = columns.keySet();
+ for (String key : keys) {
+ Map<ColumnFields, String> column = columns.get(key).getColumnFields();
+ lines.add(columnDataToSQL(column));
+ }
+ String toExecute = org.eclipse.osee.framework.jdk.core.util.Collections.toString(lines, ",\n");
+ return toExecute;
+ }
+
+ public void createTable(OseeConnection connection, TableElement tableDef) throws OseeDataStoreException {
+ String toExecute = "CREATE TABLE " + tableDef.getFullyQualifiedTableName() + " ( \n";
+ toExecute += handleColumnCreationSection(connection, tableDef.getColumns());
+ toExecute += handleConstraintCreationSection(tableDef.getConstraints(), tableDef.getFullyQualifiedTableName());
+ toExecute +=
+ handleConstraintCreationSection(tableDef.getForeignKeyConstraints(), tableDef.getFullyQualifiedTableName());
+ toExecute += " \n)\n";
+ OseeLog.log(Activator.class, Level.FINE,
+ "Creating Table: [ " + tableDef.getFullyQualifiedTableName() + "]");
+ ConnectionHandler.runPreparedUpdate(connection, toExecute);
+ }
+
+ @Override
+ public void dropTable(TableElement tableDef) throws OseeDataStoreException {
+ String toExecute = "DROP TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(), "\\.") + " CASCADE";
+ OseeLog.log(Activator.class, Level.FINE,
+ "Dropping Table: [ " + tableDef.getFullyQualifiedTableName() + "]");
+ ConnectionHandler.runPreparedUpdate(toExecute);
+ }
+
+ @Override
+ protected String formatQuotedString(String value, String splitAt) {
+ String[] array = value.split(splitAt);
+ for (int index = 0; index < array.length; index++) {
+ array[index] = array[index];
+ }
+ return StringUtils.join(array, splitAt.replaceAll("\\\\", ""));
+ }
+
+ public void dropIndex(OseeConnection connection, TableElement tableDef) throws OseeDataStoreException {
+ List<IndexElement> tableIndices = tableDef.getIndexData();
+ String tableName = tableDef.getFullyQualifiedTableName();
+ for (IndexElement iData : tableIndices) {
+ if (iData.ignoreMySql()) {
+ continue;
+ }
+ OseeLog.log(Activator.class, Level.FINE, String.format("Dropping Index: [%s] FROM [%s]\n",
+ iData.getId(), tableName));
+ if (iData.getId().equals("PRIMARY")) {
+ ConnectionHandler.runPreparedUpdate(connection,
+ "ALTER TABLE " + tableDef.getFullyQualifiedTableName() + " DROP PRIMARY KEY");
+ } else {
+ ConnectionHandler.runPreparedUpdate(connection,
+ "ALTER TABLE " + tableDef.getFullyQualifiedTableName() + " DROP INDEX " + iData.getId());
+ }
+ }
+ }
+
+ @Override
+ public String constraintDataToSQL(ConstraintElement constraint, String tableID) {
+ StringBuilder toReturn = new StringBuilder();
+ String id = formatQuotedString(constraint.getId(), "\\.");
+ String type = constraint.getConstraintType().toString();
+ String appliesTo = formatQuotedString(constraint.getCommaSeparatedColumnsList(), ",");
+
+ if (id != null && !id.equals("") && appliesTo != null && !appliesTo.equals("")) {
+ toReturn.append("CONSTRAINT " + id + " " + type + " (" + appliesTo + ")");
+
+ if (constraint instanceof ForeignKey) {
+ ForeignKey fk = (ForeignKey) constraint;
+ List<ReferenceClause> refs = fk.getReferences();
+
+ for (ReferenceClause ref : refs) {
+ String refTable = formatQuotedString(ref.getFullyQualifiedTableName(), "\\.");
+ String refColumns = formatQuotedString(ref.getCommaSeparatedColumnsList(), ",");
+
+ String onUpdate = "";
+ if (!ref.getOnUpdateAction().equals(OnUpdateEnum.UNSPECIFIED)) {
+ onUpdate = "ON UPDATE " + ref.getOnUpdateAction().toString();
+ }
+
+ String onDelete = "";
+ if (!ref.getOnDeleteAction().equals(OnDeleteEnum.UNSPECIFIED)) {
+ onDelete = "ON DELETE " + ref.getOnDeleteAction().toString();
+ }
+
+ if (refTable != null && refColumns != null && !refTable.equals("") && !refColumns.equals("")) {
+ toReturn.append(" REFERENCES " + refTable + " (" + refColumns + ")");
+ if (!onUpdate.equals("")) {
+ toReturn.append(" " + onUpdate);
+ }
+
+ if (!onDelete.equals("")) {
+ toReturn.append(" " + onDelete);
+ }
+
+ if (constraint.isDeferrable()) {
+ toReturn.append(" DEFERRABLE");
+ }
+ }
+
+ else {
+ OseeLog.log(Activator.class, Level.WARNING,
+ "Skipping CONSTRAINT at Table: " + tableID + "\n\t " + fk.toString());
+ }
+
+ }
+ }
+ } else {
+ OseeLog.log(Activator.class, Level.WARNING,
+ "Skipping CONSTRAINT at Table: " + tableID + "\n\t " + constraint.toString());
+ }
+ return toReturn.toString();
+ }
+
+ public void createIndex(OseeConnection connection, TableElement tableDef) throws OseeDataStoreException {
+ List<IndexElement> tableIndices = tableDef.getIndexData();
+ String indexId = null;
+ StringBuilder appliesTo = new StringBuilder();
+ String tableName = formatQuotedString(tableDef.getFullyQualifiedTableName(), "\\.");
+ for (IndexElement iData : tableIndices) {
+ if (iData.ignoreMySql()) {
+ continue;
+ }
+ indexId = iData.getId();
+ appliesTo.delete(0, appliesTo.length());
+
+ List<AppliesToClause> appliesToList = iData.getAppliesToList();
+ for (int index = 0; index < appliesToList.size(); index++) {
+ AppliesToClause record = appliesToList.get(index);
+ appliesTo.append(record.getColumnName());
+
+ // switch (record.getOrderType()) {
+ // case Ascending:
+ // appliesTo.append(" ASC");
+ // break;
+ // case Descending:
+ // appliesTo.append(" DESC");
+ // break;
+ // default:
+ // break;
+ // }
+ if (index + 1 < appliesToList.size()) {
+ appliesTo.append(", ");
+ }
+ }
+ String toExecute =
+ String.format(CREATE_STRING + " " + iData.getIndexType() + " INDEX %s ON %s (%s)", indexId, tableName,
+ appliesTo);
+ OseeLog.log(Activator.class, Level.FINE, toExecute);
+ ConnectionHandler.runPreparedUpdate(connection, toExecute);
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/SqlManager.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/SqlManager.java
index cc3cbb295b..5fa3c79af5 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/SqlManager.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/SqlManager.java
@@ -1,308 +1,308 @@
-/*******************************************************************************
- * 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.core.datastore.schema.sql;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.math.BigDecimal;
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import org.apache.commons.lang.StringUtils;
-import org.eclipse.osee.framework.core.datastore.internal.Activator;
-import org.eclipse.osee.framework.core.datastore.schema.data.AppliesToClause;
-import org.eclipse.osee.framework.core.datastore.schema.data.ColumnDbData;
-import org.eclipse.osee.framework.core.datastore.schema.data.ColumnMetadata;
-import org.eclipse.osee.framework.core.datastore.schema.data.ConstraintElement;
-import org.eclipse.osee.framework.core.datastore.schema.data.ForeignKey;
-import org.eclipse.osee.framework.core.datastore.schema.data.IndexElement;
-import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause;
-import org.eclipse.osee.framework.core.datastore.schema.data.SchemaDataLookup;
-import org.eclipse.osee.framework.core.datastore.schema.data.TableElement;
-import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause.OnDeleteEnum;
-import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause.OnUpdateEnum;
-import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.ColumnFields;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.database.core.ConnectionHandler;
-import org.eclipse.osee.framework.database.core.SQL3DataType;
-import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Roberto E. Escobar
- */
-public abstract class SqlManager {
- protected SqlDataType sqlDataType;
- public static final String CREATE_STRING = "CREATE";
- public static final String DROP_STRING = "DROP";
-
- public SqlManager(SqlDataType sqlDataType) {
- this.sqlDataType = sqlDataType;
- }
-
- public abstract void createTable(TableElement tableDef) throws OseeDataStoreException;
-
- public abstract void dropTable(TableElement tableDef) throws OseeDataStoreException;
-
- public void insertData(List<ColumnDbData> rowData, TableElement tableMetadata) throws OseeDataStoreException {
- List<String> columnNames = new ArrayList<String>();
- List<String> placeHolders = new ArrayList<String>();
- List<String> columnValues = new ArrayList<String>();
- List<SQL3DataType> columnTypes = new ArrayList<SQL3DataType>();
-
- for (ColumnDbData dbData : rowData) {
- String columnId = dbData.getColumnName();
- String columnValue = dbData.getColumnValue();
-
- ColumnMetadata columnMetadata = SchemaDataLookup.getColumnDefinition(tableMetadata.getColumns(), columnId);
- SQL3DataType type = SQL3DataType.valueOf(columnMetadata.getColumnField(ColumnFields.type));
-
- columnNames.add("\"" + columnId + "\"");
- placeHolders.add("?");
- columnValues.add(columnValue);
- columnTypes.add(type);
- }
-
- String toExecute =
- "INSERT INTO " + formatQuotedString(tableMetadata.getFullyQualifiedTableName(), "\\.") + " (\n";
- toExecute += StringUtils.join(columnNames, ",");
- toExecute += "\n) VALUES (\n";
- toExecute += StringUtils.join(placeHolders, ",");
- toExecute += ")\n";
-
- Object[] data = new Object[columnNames.size()];
- for (int index = 0; index < columnNames.size(); index++) {
- data[index] = preparedStatementHelper(columnTypes.get(index), columnValues.get(index));
- }
- ConnectionHandler.runPreparedUpdate(toExecute, data);
- }
-
- public Object preparedStatementHelper(SQL3DataType columnType, String value) throws OseeDataStoreException {
- switch (columnType) {
- case BINARY:
- case BIT:
- return value != null && !value.equals("") ? Byte.parseByte(value) : 0;
- case TINYINT:
- case SMALLINT:
- return value != null && !value.equals("") ? Short.valueOf(value) : 0;
- case INTEGER:
- return value != null && !value.equals("") ? Integer.valueOf(value) : 0;
- case BIGINT:
- return value != null && !value.equals("") ? BigDecimal.valueOf(Double.valueOf(value)) : new BigDecimal(0);
- case FLOAT:
- return value != null && !value.equals("") ? Float.valueOf(value) : 0.0f;
- case NUMERIC:
- case DECIMAL:
- case REAL:
- case DOUBLE:
- return value != null && !value.equals("") ? Double.valueOf(value) : 0.0;
- case CHAR:
- case VARCHAR:
- case LONGVARCHAR:
- return value;
- case DATE:
- return value == null || value.equals("") ? SQL3DataType.DATE : Date.valueOf(value);
- case TIMESTAMP:
- return value != null && !value.equals("") ? Timestamp.valueOf(value) : GlobalTime.GreenwichMeanTimestamp();
- case TIME:
- return value == null || value.equals("") ? SQL3DataType.TIME : Time.valueOf(value);
- case VARBINARY:
- case LONGVARBINARY:
- return value.getBytes();
- case BLOB:
- return new BufferedInputStream(new ByteArrayInputStream(value.getBytes()));
- case CLOB:
- return new BufferedInputStream(new ByteArrayInputStream(value.getBytes()));
- case BOOLEAN:
- return value == null || value.equals("") ? false : Boolean.parseBoolean(value);
- default:
- throw new OseeDataStoreException("unexpected column type: " + columnType);
- }
- }
-
- public String getType(SQL3DataType dataType) {
- return sqlDataType.getType(dataType);
- }
-
- public String columnDataToSQL(Map<ColumnFields, String> column) {
- StringBuilder toReturn = new StringBuilder();
-
- String columnLimits = column.get(ColumnFields.limits);
- String defaultValue = column.get(ColumnFields.defaultValue);
-
- SQL3DataType dataType = SQL3DataType.valueOf(column.get(ColumnFields.type));
- columnLimits = sqlDataType.getLimit(dataType, columnLimits);
- toReturn.append(column.get(ColumnFields.id));
- toReturn.append(" ");
- toReturn.append(sqlDataType.getType(dataType));
-
- if (columnLimits != null && !columnLimits.equals("")) {
- toReturn.append(" (" + columnLimits + ")");
- }
- if (defaultValue != null && !defaultValue.equals("")) {
- toReturn.append(" " + defaultValue);
- }
- return toReturn.toString();
- }
-
- @SuppressWarnings("unchecked")
- protected String handleConstraintCreationSection(List constraints, String tableId) {
- List<String> constraintStatements = new ArrayList<String>();
- for (Object object : constraints) {
- ConstraintElement constraint = (ConstraintElement) object;
- constraintStatements.add(constraintDataToSQL(constraint, tableId));
- }
- StringBuilder toExecute = new StringBuilder();
- toExecute.append((constraintStatements.size() != 0 ? ",\n" : ""));
- toExecute.append(StringUtils.join(constraintStatements, ",\n"));
- return toExecute.toString();
- }
-
- protected String formatQuotedString(String value, String splitAt) {
- String[] array = value.split(splitAt);
- for (int index = 0; index < array.length; index++) {
- array[index] = "\"" + array[index] + "\"";
- }
- return StringUtils.join(array, splitAt.replaceAll("\\\\", ""));
- }
-
- public String constraintDataToSQL(ConstraintElement constraint, String tableID) {
- StringBuilder toReturn = new StringBuilder();
- String id = formatQuotedString(constraint.getId(), "\\.");
- String type = constraint.getConstraintType().toString();
- String appliesTo = formatQuotedString(constraint.getCommaSeparatedColumnsList(), ",");
-
- if (id != null && !id.equals("") && appliesTo != null && !appliesTo.equals("")) {
- toReturn.append("CONSTRAINT " + id + " " + type + " (" + appliesTo + ")");
-
- if (constraint instanceof ForeignKey) {
- ForeignKey fk = (ForeignKey) constraint;
- List<ReferenceClause> refs = fk.getReferences();
-
- for (ReferenceClause ref : refs) {
- String refTable = formatQuotedString(ref.getFullyQualifiedTableName(), "\\.");
- String refColumns = formatQuotedString(ref.getCommaSeparatedColumnsList(), ",");
-
- String onUpdate = "";
- if (!ref.getOnUpdateAction().equals(OnUpdateEnum.UNSPECIFIED)) {
- onUpdate = "ON UPDATE " + ref.getOnUpdateAction().toString();
- }
-
- String onDelete = "";
- if (!ref.getOnDeleteAction().equals(OnDeleteEnum.UNSPECIFIED)) {
- onDelete = "ON DELETE " + ref.getOnDeleteAction().toString();
- }
-
- if (refTable != null && refColumns != null && !refTable.equals("") && !refColumns.equals("")) {
- toReturn.append(" REFERENCES " + refTable + " (" + refColumns + ")");
- if (!onUpdate.equals("")) {
- toReturn.append(" " + onUpdate);
- }
-
- if (!onDelete.equals("")) {
- toReturn.append(" " + onDelete);
- }
-
- if (constraint.isDeferrable()) {
- toReturn.append(" DEFERRABLE");
- }
- }
-
- else {
- OseeLog.log(Activator.class, Level.WARNING,
- "Skipping CONSTRAINT at Table: " + tableID + "\n\t " + fk.toString());
- }
-
- }
- }
- } else {
- OseeLog.log(Activator.class, Level.WARNING,
- "Skipping CONSTRAINT at Table: " + tableID + "\n\t " + constraint.toString());
- }
- return toReturn.toString();
- }
-
- public void createSchema(String schema) throws OseeDataStoreException {
- ConnectionHandler.runPreparedUpdate(CREATE_STRING + " SCHEMA \"" + schema + "\"");
- }
-
- public void dropSchema(String schema) throws OseeDataStoreException {
- ConnectionHandler.runPreparedUpdate(DROP_STRING + " SCHEMA \"" + schema + "\" CASCADE");
- }
-
- protected String insertDataToSQL(String fullyQualifiedTableName, List<String> columns, List<String> columnData) {
- StringBuilder toExecute = new StringBuilder();
- toExecute.append("INSERT INTO " + formatQuotedString(fullyQualifiedTableName, "\\.") + " (\n");
- toExecute.append(StringUtils.join(columns, ","));
- toExecute.append("\n) VALUES (\n");
- toExecute.append(StringUtils.join(columnData, ","));
- toExecute.append(")\n");
- return toExecute.toString();
- }
-
- public void createIndex(TableElement tableDef) throws OseeDataStoreException {
- List<IndexElement> tableIndices = tableDef.getIndexData();
- String indexId = null;
- StringBuilder appliesTo = new StringBuilder();
- String tableName = formatQuotedString(tableDef.getFullyQualifiedTableName(), "\\.");
- for (IndexElement iData : tableIndices) {
- if (iData.ignoreMySql()) {
- continue;
- }
- indexId = iData.getId();
- appliesTo.delete(0, appliesTo.length());
-
- List<AppliesToClause> appliesToList = iData.getAppliesToList();
- for (int index = 0; index < appliesToList.size(); index++) {
- AppliesToClause record = appliesToList.get(index);
- appliesTo.append(record.getColumnName());
-
- switch (record.getOrderType()) {
- case Ascending:
- appliesTo.append(" ASC");
- break;
- case Descending:
- appliesTo.append(" DESC");
- break;
- default:
- break;
- }
- if (index + 1 < appliesToList.size()) {
- appliesTo.append(", ");
- }
- }
- String toExecute =
- String.format("%s %s INDEX %s ON %s (%s)", CREATE_STRING, iData.getIndexType(), indexId, tableName,
- appliesTo);
- toExecute = createIndexPostProcess(iData, toExecute);
- OseeLog.log(Activator.class, Level.FINE, toExecute);
- ConnectionHandler.runPreparedUpdate(toExecute);
- }
- }
-
- protected String createIndexPostProcess(IndexElement indexElement, String original) {
- return original;
- }
-
- public void dropIndex(TableElement tableDef) throws OseeDataStoreException {
- List<IndexElement> tableIndices = tableDef.getIndexData();
- String tableName = tableDef.getFullyQualifiedTableName();
- for (IndexElement iData : tableIndices) {
- OseeLog.log(Activator.class, Level.FINE, String.format("Dropping Index: [%s] FROM [%s]\n",
- iData.getId(), tableName));
- ConnectionHandler.runPreparedUpdate(DROP_STRING + " INDEX " + iData.getId());
- }
- }
-}
+/*******************************************************************************
+ * 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.core.datastore.schema.sql;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.math.BigDecimal;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.osee.framework.core.datastore.internal.Activator;
+import org.eclipse.osee.framework.core.datastore.schema.data.AppliesToClause;
+import org.eclipse.osee.framework.core.datastore.schema.data.ColumnDbData;
+import org.eclipse.osee.framework.core.datastore.schema.data.ColumnMetadata;
+import org.eclipse.osee.framework.core.datastore.schema.data.ConstraintElement;
+import org.eclipse.osee.framework.core.datastore.schema.data.ForeignKey;
+import org.eclipse.osee.framework.core.datastore.schema.data.IndexElement;
+import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause;
+import org.eclipse.osee.framework.core.datastore.schema.data.SchemaDataLookup;
+import org.eclipse.osee.framework.core.datastore.schema.data.TableElement;
+import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause.OnDeleteEnum;
+import org.eclipse.osee.framework.core.datastore.schema.data.ReferenceClause.OnUpdateEnum;
+import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.ColumnFields;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.database.core.ConnectionHandler;
+import org.eclipse.osee.framework.database.core.SQL3DataType;
+import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public abstract class SqlManager {
+ protected SqlDataType sqlDataType;
+ public static final String CREATE_STRING = "CREATE";
+ public static final String DROP_STRING = "DROP";
+
+ public SqlManager(SqlDataType sqlDataType) {
+ this.sqlDataType = sqlDataType;
+ }
+
+ public abstract void createTable(TableElement tableDef) throws OseeDataStoreException;
+
+ public abstract void dropTable(TableElement tableDef) throws OseeDataStoreException;
+
+ public void insertData(List<ColumnDbData> rowData, TableElement tableMetadata) throws OseeDataStoreException {
+ List<String> columnNames = new ArrayList<String>();
+ List<String> placeHolders = new ArrayList<String>();
+ List<String> columnValues = new ArrayList<String>();
+ List<SQL3DataType> columnTypes = new ArrayList<SQL3DataType>();
+
+ for (ColumnDbData dbData : rowData) {
+ String columnId = dbData.getColumnName();
+ String columnValue = dbData.getColumnValue();
+
+ ColumnMetadata columnMetadata = SchemaDataLookup.getColumnDefinition(tableMetadata.getColumns(), columnId);
+ SQL3DataType type = SQL3DataType.valueOf(columnMetadata.getColumnField(ColumnFields.type));
+
+ columnNames.add("\"" + columnId + "\"");
+ placeHolders.add("?");
+ columnValues.add(columnValue);
+ columnTypes.add(type);
+ }
+
+ String toExecute =
+ "INSERT INTO " + formatQuotedString(tableMetadata.getFullyQualifiedTableName(), "\\.") + " (\n";
+ toExecute += StringUtils.join(columnNames, ",");
+ toExecute += "\n) VALUES (\n";
+ toExecute += StringUtils.join(placeHolders, ",");
+ toExecute += ")\n";
+
+ Object[] data = new Object[columnNames.size()];
+ for (int index = 0; index < columnNames.size(); index++) {
+ data[index] = preparedStatementHelper(columnTypes.get(index), columnValues.get(index));
+ }
+ ConnectionHandler.runPreparedUpdate(toExecute, data);
+ }
+
+ public Object preparedStatementHelper(SQL3DataType columnType, String value) throws OseeDataStoreException {
+ switch (columnType) {
+ case BINARY:
+ case BIT:
+ return value != null && !value.equals("") ? Byte.parseByte(value) : 0;
+ case TINYINT:
+ case SMALLINT:
+ return value != null && !value.equals("") ? Short.valueOf(value) : 0;
+ case INTEGER:
+ return value != null && !value.equals("") ? Integer.valueOf(value) : 0;
+ case BIGINT:
+ return value != null && !value.equals("") ? BigDecimal.valueOf(Double.valueOf(value)) : new BigDecimal(0);
+ case FLOAT:
+ return value != null && !value.equals("") ? Float.valueOf(value) : 0.0f;
+ case NUMERIC:
+ case DECIMAL:
+ case REAL:
+ case DOUBLE:
+ return value != null && !value.equals("") ? Double.valueOf(value) : 0.0;
+ case CHAR:
+ case VARCHAR:
+ case LONGVARCHAR:
+ return value;
+ case DATE:
+ return value == null || value.equals("") ? SQL3DataType.DATE : Date.valueOf(value);
+ case TIMESTAMP:
+ return value != null && !value.equals("") ? Timestamp.valueOf(value) : GlobalTime.GreenwichMeanTimestamp();
+ case TIME:
+ return value == null || value.equals("") ? SQL3DataType.TIME : Time.valueOf(value);
+ case VARBINARY:
+ case LONGVARBINARY:
+ return value.getBytes();
+ case BLOB:
+ return new BufferedInputStream(new ByteArrayInputStream(value.getBytes()));
+ case CLOB:
+ return new BufferedInputStream(new ByteArrayInputStream(value.getBytes()));
+ case BOOLEAN:
+ return value == null || value.equals("") ? false : Boolean.parseBoolean(value);
+ default:
+ throw new OseeDataStoreException("unexpected column type: " + columnType);
+ }
+ }
+
+ public String getType(SQL3DataType dataType) {
+ return sqlDataType.getType(dataType);
+ }
+
+ public String columnDataToSQL(Map<ColumnFields, String> column) {
+ StringBuilder toReturn = new StringBuilder();
+
+ String columnLimits = column.get(ColumnFields.limits);
+ String defaultValue = column.get(ColumnFields.defaultValue);
+
+ SQL3DataType dataType = SQL3DataType.valueOf(column.get(ColumnFields.type));
+ columnLimits = sqlDataType.getLimit(dataType, columnLimits);
+ toReturn.append(column.get(ColumnFields.id));
+ toReturn.append(" ");
+ toReturn.append(sqlDataType.getType(dataType));
+
+ if (columnLimits != null && !columnLimits.equals("")) {
+ toReturn.append(" (" + columnLimits + ")");
+ }
+ if (defaultValue != null && !defaultValue.equals("")) {
+ toReturn.append(" " + defaultValue);
+ }
+ return toReturn.toString();
+ }
+
+ @SuppressWarnings("unchecked")
+ protected String handleConstraintCreationSection(List constraints, String tableId) {
+ List<String> constraintStatements = new ArrayList<String>();
+ for (Object object : constraints) {
+ ConstraintElement constraint = (ConstraintElement) object;
+ constraintStatements.add(constraintDataToSQL(constraint, tableId));
+ }
+ StringBuilder toExecute = new StringBuilder();
+ toExecute.append((constraintStatements.size() != 0 ? ",\n" : ""));
+ toExecute.append(StringUtils.join(constraintStatements, ",\n"));
+ return toExecute.toString();
+ }
+
+ protected String formatQuotedString(String value, String splitAt) {
+ String[] array = value.split(splitAt);
+ for (int index = 0; index < array.length; index++) {
+ array[index] = "\"" + array[index] + "\"";
+ }
+ return StringUtils.join(array, splitAt.replaceAll("\\\\", ""));
+ }
+
+ public String constraintDataToSQL(ConstraintElement constraint, String tableID) {
+ StringBuilder toReturn = new StringBuilder();
+ String id = formatQuotedString(constraint.getId(), "\\.");
+ String type = constraint.getConstraintType().toString();
+ String appliesTo = formatQuotedString(constraint.getCommaSeparatedColumnsList(), ",");
+
+ if (id != null && !id.equals("") && appliesTo != null && !appliesTo.equals("")) {
+ toReturn.append("CONSTRAINT " + id + " " + type + " (" + appliesTo + ")");
+
+ if (constraint instanceof ForeignKey) {
+ ForeignKey fk = (ForeignKey) constraint;
+ List<ReferenceClause> refs = fk.getReferences();
+
+ for (ReferenceClause ref : refs) {
+ String refTable = formatQuotedString(ref.getFullyQualifiedTableName(), "\\.");
+ String refColumns = formatQuotedString(ref.getCommaSeparatedColumnsList(), ",");
+
+ String onUpdate = "";
+ if (!ref.getOnUpdateAction().equals(OnUpdateEnum.UNSPECIFIED)) {
+ onUpdate = "ON UPDATE " + ref.getOnUpdateAction().toString();
+ }
+
+ String onDelete = "";
+ if (!ref.getOnDeleteAction().equals(OnDeleteEnum.UNSPECIFIED)) {
+ onDelete = "ON DELETE " + ref.getOnDeleteAction().toString();
+ }
+
+ if (refTable != null && refColumns != null && !refTable.equals("") && !refColumns.equals("")) {
+ toReturn.append(" REFERENCES " + refTable + " (" + refColumns + ")");
+ if (!onUpdate.equals("")) {
+ toReturn.append(" " + onUpdate);
+ }
+
+ if (!onDelete.equals("")) {
+ toReturn.append(" " + onDelete);
+ }
+
+ if (constraint.isDeferrable()) {
+ toReturn.append(" DEFERRABLE");
+ }
+ }
+
+ else {
+ OseeLog.log(Activator.class, Level.WARNING,
+ "Skipping CONSTRAINT at Table: " + tableID + "\n\t " + fk.toString());
+ }
+
+ }
+ }
+ } else {
+ OseeLog.log(Activator.class, Level.WARNING,
+ "Skipping CONSTRAINT at Table: " + tableID + "\n\t " + constraint.toString());
+ }
+ return toReturn.toString();
+ }
+
+ public void createSchema(String schema) throws OseeDataStoreException {
+ ConnectionHandler.runPreparedUpdate(CREATE_STRING + " SCHEMA \"" + schema + "\"");
+ }
+
+ public void dropSchema(String schema) throws OseeDataStoreException {
+ ConnectionHandler.runPreparedUpdate(DROP_STRING + " SCHEMA \"" + schema + "\" CASCADE");
+ }
+
+ protected String insertDataToSQL(String fullyQualifiedTableName, List<String> columns, List<String> columnData) {
+ StringBuilder toExecute = new StringBuilder();
+ toExecute.append("INSERT INTO " + formatQuotedString(fullyQualifiedTableName, "\\.") + " (\n");
+ toExecute.append(StringUtils.join(columns, ","));
+ toExecute.append("\n) VALUES (\n");
+ toExecute.append(StringUtils.join(columnData, ","));
+ toExecute.append(")\n");
+ return toExecute.toString();
+ }
+
+ public void createIndex(TableElement tableDef) throws OseeDataStoreException {
+ List<IndexElement> tableIndices = tableDef.getIndexData();
+ String indexId = null;
+ StringBuilder appliesTo = new StringBuilder();
+ String tableName = formatQuotedString(tableDef.getFullyQualifiedTableName(), "\\.");
+ for (IndexElement iData : tableIndices) {
+ if (iData.ignoreMySql()) {
+ continue;
+ }
+ indexId = iData.getId();
+ appliesTo.delete(0, appliesTo.length());
+
+ List<AppliesToClause> appliesToList = iData.getAppliesToList();
+ for (int index = 0; index < appliesToList.size(); index++) {
+ AppliesToClause record = appliesToList.get(index);
+ appliesTo.append(record.getColumnName());
+
+ switch (record.getOrderType()) {
+ case Ascending:
+ appliesTo.append(" ASC");
+ break;
+ case Descending:
+ appliesTo.append(" DESC");
+ break;
+ default:
+ break;
+ }
+ if (index + 1 < appliesToList.size()) {
+ appliesTo.append(", ");
+ }
+ }
+ String toExecute =
+ String.format("%s %s INDEX %s ON %s (%s)", CREATE_STRING, iData.getIndexType(), indexId, tableName,
+ appliesTo);
+ toExecute = createIndexPostProcess(iData, toExecute);
+ OseeLog.log(Activator.class, Level.FINE, toExecute);
+ ConnectionHandler.runPreparedUpdate(toExecute);
+ }
+ }
+
+ protected String createIndexPostProcess(IndexElement indexElement, String original) {
+ return original;
+ }
+
+ public void dropIndex(TableElement tableDef) throws OseeDataStoreException {
+ List<IndexElement> tableIndices = tableDef.getIndexData();
+ String tableName = tableDef.getFullyQualifiedTableName();
+ for (IndexElement iData : tableIndices) {
+ OseeLog.log(Activator.class, Level.FINE, String.format("Dropping Index: [%s] FROM [%s]\n",
+ iData.getId(), tableName));
+ ConnectionHandler.runPreparedUpdate(DROP_STRING + " INDEX " + iData.getId());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/SqlManagerImpl.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/SqlManagerImpl.java
index 3c06692ceb..cd710f4025 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/SqlManagerImpl.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/SqlManagerImpl.java
@@ -1,68 +1,68 @@
-/*******************************************************************************
- * 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.core.datastore.schema.sql;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.core.datastore.internal.Activator;
-import org.eclipse.osee.framework.core.datastore.schema.data.ColumnMetadata;
-import org.eclipse.osee.framework.core.datastore.schema.data.TableElement;
-import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.ColumnFields;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.database.core.ConnectionHandler;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Roberto E. Escobar
- */
-public class SqlManagerImpl extends SqlManager {
-
- public SqlManagerImpl(SqlDataType sqlDataType) {
- super(sqlDataType);
- }
-
- private String handleColumnCreationSection(Map<String, ColumnMetadata> columns) {
- List<String> lines = new ArrayList<String>();
- Set<String> keys = columns.keySet();
- for (String key : keys) {
- Map<ColumnFields, String> column = columns.get(key).getColumnFields();
- lines.add(columnDataToSQL(column));
- }
- String toExecute = org.eclipse.osee.framework.jdk.core.util.Collections.toString(lines, ",\n");
- return toExecute;
- }
-
- @Override
- public void createTable(TableElement tableDef) throws OseeDataStoreException {
- StringBuilder toExecute = new StringBuilder();
- toExecute.append(SqlManager.CREATE_STRING + " TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(),
- "\\.") + " ( \n");
- toExecute.append(handleColumnCreationSection(tableDef.getColumns()));
- toExecute.append(handleConstraintCreationSection(tableDef.getConstraints(), tableDef.getFullyQualifiedTableName()));
- toExecute.append(handleConstraintCreationSection(tableDef.getForeignKeyConstraints(),
- tableDef.getFullyQualifiedTableName()));
- toExecute.append(" \n)\n");
- OseeLog.log(Activator.class, Level.FINE, "Creating Table: [ " + tableDef.getFullyQualifiedTableName() + "]");
- ConnectionHandler.runPreparedUpdate(toExecute.toString());
- }
-
- @Override
- public void dropTable(TableElement tableDef) throws OseeDataStoreException {
- StringBuilder toExecute = new StringBuilder();
- toExecute.append(SqlManager.DROP_STRING + " TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(),
- "\\."));
- OseeLog.log(Activator.class, Level.FINE, "Dropping Table: [ " + tableDef.getFullyQualifiedTableName() + "]");
- ConnectionHandler.runPreparedUpdate(toExecute.toString());
- }
-}
+/*******************************************************************************
+ * 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.core.datastore.schema.sql;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.datastore.internal.Activator;
+import org.eclipse.osee.framework.core.datastore.schema.data.ColumnMetadata;
+import org.eclipse.osee.framework.core.datastore.schema.data.TableElement;
+import org.eclipse.osee.framework.core.datastore.schema.data.TableElement.ColumnFields;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.database.core.ConnectionHandler;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class SqlManagerImpl extends SqlManager {
+
+ public SqlManagerImpl(SqlDataType sqlDataType) {
+ super(sqlDataType);
+ }
+
+ private String handleColumnCreationSection(Map<String, ColumnMetadata> columns) {
+ List<String> lines = new ArrayList<String>();
+ Set<String> keys = columns.keySet();
+ for (String key : keys) {
+ Map<ColumnFields, String> column = columns.get(key).getColumnFields();
+ lines.add(columnDataToSQL(column));
+ }
+ String toExecute = org.eclipse.osee.framework.jdk.core.util.Collections.toString(lines, ",\n");
+ return toExecute;
+ }
+
+ @Override
+ public void createTable(TableElement tableDef) throws OseeDataStoreException {
+ StringBuilder toExecute = new StringBuilder();
+ toExecute.append(SqlManager.CREATE_STRING + " TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(),
+ "\\.") + " ( \n");
+ toExecute.append(handleColumnCreationSection(tableDef.getColumns()));
+ toExecute.append(handleConstraintCreationSection(tableDef.getConstraints(), tableDef.getFullyQualifiedTableName()));
+ toExecute.append(handleConstraintCreationSection(tableDef.getForeignKeyConstraints(),
+ tableDef.getFullyQualifiedTableName()));
+ toExecute.append(" \n)\n");
+ OseeLog.log(Activator.class, Level.FINE, "Creating Table: [ " + tableDef.getFullyQualifiedTableName() + "]");
+ ConnectionHandler.runPreparedUpdate(toExecute.toString());
+ }
+
+ @Override
+ public void dropTable(TableElement tableDef) throws OseeDataStoreException {
+ StringBuilder toExecute = new StringBuilder();
+ toExecute.append(SqlManager.DROP_STRING + " TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(),
+ "\\."));
+ OseeLog.log(Activator.class, Level.FINE, "Dropping Table: [ " + tableDef.getFullyQualifiedTableName() + "]");
+ ConnectionHandler.runPreparedUpdate(toExecute.toString());
+ }
+}

Back to the top