Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2012-06-26 22:33:22 +0000
committerRoberto E. Escobar2012-07-20 21:25:48 +0000
commitedef9514c3a3fd9171e9f1416112ecc8b40cdfc9 (patch)
tree48279c6bd756f6c97bcccd848ce3989be91e2ddc /plugins
parentd3398b90f5663ed2e9e59bd31b07ca481198e1ad (diff)
downloadorg.eclipse.osee-edef9514c3a3fd9171e9f1416112ecc8b40cdfc9.tar.gz
org.eclipse.osee-edef9514c3a3fd9171e9f1416112ecc8b40cdfc9.tar.xz
org.eclipse.osee-edef9514c3a3fd9171e9f1416112ecc8b40cdfc9.zip
feature[ats_M5LLE]: Add ORCS tests and refactor
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/ArtifactTypeCache.java2
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/ArtifactType.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core.integration.test/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.osee.orcs.core.integration.test/OrcsIntegrationTestSuite.launch11
-rw-r--r--plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/OrcsIntegrationRule.java (renamed from plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/mock/Utility.java)46
-rw-r--r--plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/OrcsIntegrationTestSuite.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsAttributeLoadingTest.java11
-rw-r--r--plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsAttributeSearchTest.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsBranchTest.java13
-rw-r--r--plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsQueryTest.java16
-rw-r--r--plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsRelationLoadingTest.java22
-rw-r--r--plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsTransactionTest.java104
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/META-INF/MANIFEST.MF6
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/InternalTestSuite.java8
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactoryTest.java120
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactTestSuite.java23
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeCollectionTest.java53
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeTestSuite.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/RelationLoadingTest.java32
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionImplTest.java91
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionTestSuite.java20
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactTransactionData.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsData.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsVisitor.java (renamed from plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/AbstractSqlProvider.java)23
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionData.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/data/ArtifactTxDataImpl.java69
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java7
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactory.java92
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactImpl.java26
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/AttributeManager.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/WritableArtifactProxy.java17
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/Attribute.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeClassResolver.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeCollection.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactory.java21
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeManagerImpl.java92
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeOwner.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionImpl.java12
-rw-r--r--plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/OsgiRule.java73
-rw-r--r--plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/OsgiService.java (renamed from plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/InsertDataCollector.java)22
-rw-r--r--plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/OsgiUtil.java (renamed from plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/OsgiUtil.java)2
-rw-r--r--plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/TestDatabase.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/InternalJunitTestSuite.java8
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/accessor/OseeInfoDataAccessorTest.java24
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/ArtifactLoaderTest.java19
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/AttributeLoaderTest.java15
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/RelationLoaderTest.java25
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/DaoToSqlTest.java118
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/InsertVistorTest.java71
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionTestSuite.java (renamed from plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/SqlProvider.java)17
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderTest.java52
-rw-r--r--plugins/org.eclipse.osee.orcs.db/build.properties4
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/OrcsDataStoreImpl.java18
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchDataStoreImpl.java24
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/AttributeDataProxyFactory.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataModuleFactory.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/IdFactory.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/RelationalConstants.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/IdFactoryImpl.java21
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectImpl.java9
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/ArtifactSqlProvider.java34
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/AttributeSqlProvider.java83
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/BinaryStoreTx.java42
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/CommitTransactionDatabaseTxCallable.java (renamed from plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitTransactionDatabaseTxCallable.java)99
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/DaoToSql.java81
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/InsertVisitor.java132
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/RelationSqlProvider.java34
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilder.java87
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchResource.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/HtmlWriter.java23
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TxResource.java53
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TxsResource.java64
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsApi.java3
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/Tester.java72
75 files changed, 1618 insertions, 727 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/ArtifactTypeCache.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/ArtifactTypeCache.java
index 8a6df0c2940..5eb0b6636b0 100644
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/ArtifactTypeCache.java
+++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/ArtifactTypeCache.java
@@ -16,7 +16,7 @@ import org.eclipse.osee.framework.core.model.type.ArtifactType;
/**
* @author Roberto E. Escobar
*/
-public final class ArtifactTypeCache extends AbstractOseeCache<Long, ArtifactType> {
+public class ArtifactTypeCache extends AbstractOseeCache<Long, ArtifactType> {
public ArtifactTypeCache(IOseeDataAccessor<Long, ArtifactType> dataAccessor) {
super(OseeCacheEnum.ARTIFACT_TYPE_CACHE, dataAccessor, true);
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/ArtifactType.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/ArtifactType.java
index e41f1130ec6..a5e9b24725b 100644
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/ArtifactType.java
+++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/ArtifactType.java
@@ -30,7 +30,7 @@ import org.eclipse.osee.framework.core.model.internal.fields.ArtifactTypeAttribu
/**
* @author Robert A. Fisher
*/
-public final class ArtifactType extends AbstractOseeType<Long> implements IArtifactType {
+public class ArtifactType extends AbstractOseeType<Long> implements IArtifactType {
public static final String ARTIFACT_IS_ABSTRACT_FIELD_KEY = "osee.artifact.type.is.abstract.field";
public static final String ARTIFACT_INHERITANCE_FIELD_KEY = "osee.artifact.type.inheritance.field";
diff --git a/plugins/org.eclipse.osee.orcs.core.integration.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.core.integration.test/META-INF/MANIFEST.MF
index 1aa799f013a..c7a106eee50 100644
--- a/plugins/org.eclipse.osee.orcs.core.integration.test/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.core.integration.test/META-INF/MANIFEST.MF
@@ -22,4 +22,6 @@ Import-Package: junit.framework;version="4.8.2",
org.junit.runners;version="4.8.2",
org.osgi.service.event;version="1.3.0"
Require-Bundle: org.eclipse.osee.event.osgi,
- org.eclipse.equinox.event
+ org.eclipse.equinox.event,
+ org.eclipse.osee.orcs,
+ org.junit
diff --git a/plugins/org.eclipse.osee.orcs.core.integration.test/OrcsIntegrationTestSuite.launch b/plugins/org.eclipse.osee.orcs.core.integration.test/OrcsIntegrationTestSuite.launch
index c6e425654c3..15e903d4f7a 100644
--- a/plugins/org.eclipse.osee.orcs.core.integration.test/OrcsIntegrationTestSuite.launch
+++ b/plugins/org.eclipse.osee.orcs.core.integration.test/OrcsIntegrationTestSuite.launch
@@ -21,6 +21,9 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
+</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
@@ -29,14 +32,14 @@
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -console"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.osee.orcs.core.integration.test"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx384m &#13;&#10;-Dosee.log.default=ALL&#13;&#10;-Dlogback.configurationFile=logback-dev.xml &quot;-Xbootclasspath/a:C:/UserData/workspaces/osee/ws_oseeWeb/.metadata/.plugins/com.mountainminds.eclemma.core/.launch/18987a21.jar;C:\Documents and Settings\b1528444\.eclipse\osee.platform_0.9.9.v201109070002\org.eclipse.osgi\bundles\17\1\.cp\emma.jar&quot;"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx384m &#13;&#10;-Dosee.log.default=ALL&#13;&#10;-Dlogback.configurationFile=logback-dev.xml&#13;&#10;-Dosgi.noShutdown=true"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="lba.ote.outfile.conversion.app.convert"/>
<booleanAttribute key="run_in_ui_thread" value="true"/>
-<stringAttribute key="selected_target_plugins" value="ch.qos.logback.classic@default:default,ch.qos.logback.core@default:default,ch.qos.logback.slf4j@default:false,com.google.collect@default:default,com.google.inject@default:default,javax.servlet@default:default,javax.xml@default:default,org.antlr.runtime@default:default,org.aopalliance@default:default,org.apache.commons.codec@default:default,org.apache.commons.httpclient@default:default,org.apache.commons.lang@default:default,org.apache.commons.logging@default:default,org.apache.log4j@default:default,org.apache.xerces@default:default,org.apache.xml.resolver@default:default,org.apache.xml.serializer@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.net.win32.x86@default:false,org.eclipse.core.net@default:default,org.eclipse.core.runtime.compatibility.auth@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.core.runtime@default:true,org.eclipse.emf.common@default:default,org.eclipse.emf.compare.diff@default:default,org.eclipse.emf.compare.match@default:default,org.eclipse.emf.compare@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.emf.edit@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.security.win32.x86@default:false,org.eclipse.equinox.security@default:default,org.eclipse.equinox.servletbridge.extensionbundle@default:false,org.eclipse.equinox.transforms.hook@default:false,org.eclipse.equinox.util@default:default,org.eclipse.equinox.weaving.hook@default:false,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.xtext.logging@default:false,org.eclipse.xtext.util@default:default,org.eclipse.xtext@default:default,org.h2@default:default,org.hamcrest.core@default:default,org.junit*4.8.2.v4_8_2_v20110321-1705@default:default,org.slf4j.api@default:default,org.slf4j.jcl@default:default"/>
-<stringAttribute key="selected_workspace_plugins" value="org.eclipse.osee.event.osgi@default:default,org.eclipse.osee.event@default:default,org.eclipse.osee.executor.admin@default:default,org.eclipse.osee.framework.core.dsl.integration.test@default:false,org.eclipse.osee.framework.core.dsl.integration@default:default,org.eclipse.osee.framework.core.dsl@default:default,org.eclipse.osee.framework.core.model.test@default:false,org.eclipse.osee.framework.core.model@default:default,org.eclipse.osee.framework.core.test@default:false,org.eclipse.osee.framework.core@default:default,org.eclipse.osee.framework.database.test@default:false,org.eclipse.osee.framework.database@default:default,org.eclipse.osee.framework.h2@default:default,org.eclipse.osee.framework.jdk.core.test@default:false,org.eclipse.osee.framework.jdk.core@default:default,org.eclipse.osee.framework.logging.test@default:false,org.eclipse.osee.framework.logging@default:default,org.eclipse.osee.framework.resource.management.test@default:false,org.eclipse.osee.framework.resource.management@default:default,org.eclipse.osee.logback.config@default:false,org.eclipse.osee.logger.slf4j@default:default,org.eclipse.osee.logger@default:true,org.eclipse.osee.orcs.core.integration.test@default:false,org.eclipse.osee.orcs.core.test@default:false,org.eclipse.osee.orcs.core@default:default,org.eclipse.osee.orcs.db.mock@default:default,org.eclipse.osee.orcs.db.test@default:false,org.eclipse.osee.orcs.db@default:default,org.eclipse.osee.orcs@default:default"/>
+<stringAttribute key="selected_target_plugins" value="ch.qos.logback.classic@default:default,ch.qos.logback.core@default:default,ch.qos.logback.slf4j@default:false,com.google.collect@default:default,com.google.inject@default:default,javax.servlet@default:default,javax.xml@default:default,org.antlr.runtime@default:default,org.aopalliance@default:default,org.apache.commons.codec@default:default,org.apache.commons.httpclient@default:default,org.apache.commons.lang@default:default,org.apache.commons.logging*1.0.4.v201101211617@default:default,org.apache.commons.logging*1.1.1.v201101211721@default:default,org.apache.log4j@default:default,org.apache.xerces@default:default,org.apache.xml.resolver@default:default,org.apache.xml.serializer@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem.win32.x86_64@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.net.win32.x86_64@default:false,org.eclipse.core.net@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime.compatibility.auth@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.core.runtime@default:true,org.eclipse.emf.common@default:default,org.eclipse.emf.compare.diff@default:default,org.eclipse.emf.compare.match@default:default,org.eclipse.emf.compare@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.emf.edit@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.security.win32.x86_64@default:false,org.eclipse.equinox.security@default:default,org.eclipse.equinox.servletbridge.extensionbundle@default:false,org.eclipse.equinox.transforms.hook@default:false,org.eclipse.equinox.util@default:default,org.eclipse.equinox.weaving.hook@default:false,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.team.core@default:default,org.eclipse.xtext.logging@default:false,org.eclipse.xtext.util@default:default,org.eclipse.xtext@default:default,org.h2@default:default,org.hamcrest.core@default:default,org.junit*4.8.2.v4_8_2_v20110321-1705@default:default,org.slf4j.api@default:default,org.slf4j.jcl@default:default"/>
+<stringAttribute key="selected_workspace_plugins" value="org.eclipse.osee.console.admin.test@default:false,org.eclipse.osee.console.admin@default:default,org.eclipse.osee.database.schema@default:default,org.eclipse.osee.event.osgi@default:default,org.eclipse.osee.event@default:default,org.eclipse.osee.executor.admin.test@default:false,org.eclipse.osee.executor.admin@default:default,org.eclipse.osee.framework.core.dsl.integration.test@default:false,org.eclipse.osee.framework.core.dsl.integration@default:default,org.eclipse.osee.framework.core.dsl@default:default,org.eclipse.osee.framework.core.model.test@default:false,org.eclipse.osee.framework.core.model@default:default,org.eclipse.osee.framework.core.test@default:false,org.eclipse.osee.framework.core@default:default,org.eclipse.osee.framework.database.test@default:false,org.eclipse.osee.framework.database@default:default,org.eclipse.osee.framework.h2@default:default,org.eclipse.osee.framework.jdk.core.test@default:false,org.eclipse.osee.framework.jdk.core@default:default,org.eclipse.osee.framework.logging.test@default:false,org.eclipse.osee.framework.logging@default:default,org.eclipse.osee.framework.resource.management.test@default:false,org.eclipse.osee.framework.resource.management@default:default,org.eclipse.osee.logback.config@default:false,org.eclipse.osee.logger.slf4j@default:default,org.eclipse.osee.logger@default:true,org.eclipse.osee.orcs.core.integration.test@default:false,org.eclipse.osee.orcs.core.test@default:false,org.eclipse.osee.orcs.core@default:default,org.eclipse.osee.orcs.db.mock@default:default,org.eclipse.osee.orcs.db.test@default:false,org.eclipse.osee.orcs.db@default:default,org.eclipse.osee.orcs@default:default,org.mockito@default:default,org.objenesis@default:default"/>
<booleanAttribute key="show_selected_only" value="false"/>
-<stringAttribute key="timestamp" value="1331670502667"/>
+<stringAttribute key="timestamp" value="1340740345144"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
<booleanAttribute key="useDefaultConfig" value="true"/>
diff --git a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/mock/Utility.java b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/OrcsIntegrationRule.java
index c37b58a0fc3..3b611e28715 100644
--- a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/mock/Utility.java
+++ b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/OrcsIntegrationRule.java
@@ -8,11 +8,10 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.core.mock;
+package org.eclipse.osee.orcs.core;
import org.eclipse.osee.event.EventService;
import org.eclipse.osee.executor.admin.ExecutorAdmin;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.services.IOseeCachingService;
import org.eclipse.osee.framework.core.services.IOseeModelFactoryService;
import org.eclipse.osee.framework.core.services.IOseeModelingService;
@@ -21,36 +20,37 @@ import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.DataStoreTypeCache;
import org.eclipse.osee.orcs.core.SystemPreferences;
-import org.eclipse.osee.orcs.core.ds.DataLoader;
-import org.eclipse.osee.orcs.core.ds.QueryEngine;
+import org.eclipse.osee.orcs.core.ds.OrcsDataStore;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeClassResolver;
-import org.eclipse.osee.orcs.db.mock.OsgiUtil;
+import org.eclipse.osee.orcs.db.mock.OsgiRule;
+import org.eclipse.osee.orcs.db.mock.OsgiService;
import org.osgi.service.event.EventAdmin;
/**
* @author Roberto E. Escobar
*/
-public final class Utility {
+public class OrcsIntegrationRule extends OsgiRule {
- private Utility() {
- // Utility Class
+ public OrcsIntegrationRule(Object testObject) {
+ super(new CheckServices(), testObject);
}
- public static void checkRequiredServices() throws OseeCoreException {
- OsgiUtil.getService(Log.class);
- OsgiUtil.getService(SystemPreferences.class);
- OsgiUtil.getService(IdentityService.class);
- OsgiUtil.getService(IOseeDatabaseService.class);
- OsgiUtil.getService(IOseeModelFactoryService.class);
- OsgiUtil.getService(IOseeModelingService.class);
- OsgiUtil.getService(EventAdmin.class);
- OsgiUtil.getService(EventService.class);
- OsgiUtil.getService(ExecutorAdmin.class);
- OsgiUtil.getService(IOseeCachingService.class);
- OsgiUtil.getService(QueryEngine.class);
- OsgiUtil.getService(DataStoreTypeCache.class);
- OsgiUtil.getService(DataLoader.class);
- OsgiUtil.getService(AttributeClassResolver.class);
+ public static class CheckServices {
+ // @formatter:off
+ @OsgiService public Log log;
+ @OsgiService public SystemPreferences preferences;
+ @OsgiService public IdentityService idService;
+ @OsgiService public IOseeDatabaseService dbService;
+ @OsgiService public IOseeModelFactoryService modelFactory;
+ @OsgiService public IOseeModelingService modelService;
+ @OsgiService public EventAdmin eventAdmin;
+ @OsgiService public EventService eventService;
+ @OsgiService public ExecutorAdmin executorAdmin;
+ @OsgiService public IOseeCachingService cachingService;
+ @OsgiService public OrcsDataStore dataStore;
+ @OsgiService public DataStoreTypeCache typeCache;
+ @OsgiService public AttributeClassResolver resolver;
+ // @formatter:on
}
}
diff --git a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/OrcsIntegrationTestSuite.java b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/OrcsIntegrationTestSuite.java
index 3948d77e21b..8d5b57e40ad 100644
--- a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/OrcsIntegrationTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/OrcsIntegrationTestSuite.java
@@ -15,6 +15,7 @@ import org.eclipse.osee.orcs.core.internal.OrcsAttributeSearchTest;
import org.eclipse.osee.orcs.core.internal.OrcsBranchTest;
import org.eclipse.osee.orcs.core.internal.OrcsQueryTest;
import org.eclipse.osee.orcs.core.internal.OrcsRelationLoadingTest;
+import org.eclipse.osee.orcs.core.internal.OrcsTransactionTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -27,7 +28,8 @@ import org.junit.runners.Suite;
OrcsAttributeSearchTest.class,
OrcsBranchTest.class,
OrcsQueryTest.class,
- OrcsRelationLoadingTest.class})
+ OrcsRelationLoadingTest.class,
+ OrcsTransactionTest.class})
public class OrcsIntegrationTestSuite {
// Test Suite
}
diff --git a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsAttributeLoadingTest.java b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsAttributeLoadingTest.java
index b3e2af6f374..3bec8e18bd8 100644
--- a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsAttributeLoadingTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsAttributeLoadingTest.java
@@ -22,9 +22,10 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
import org.eclipse.osee.orcs.ApplicationContext;
import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.core.OrcsIntegrationRule;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.db.mock.OseeDatabase;
-import org.eclipse.osee.orcs.db.mock.OsgiUtil;
+import org.eclipse.osee.orcs.db.mock.OsgiService;
import org.eclipse.osee.orcs.search.Operator;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
@@ -36,12 +37,16 @@ import org.junit.Rule;
public class OrcsAttributeLoadingTest {
@Rule
+ public OrcsIntegrationRule osgi = new OrcsIntegrationRule(this);
+
+ @Rule
public OseeDatabase db = new OseeDatabase("osee.demo.h2");
+ @OsgiService
+ OrcsApi orcsApi;
+
@org.junit.Test
public void testAttributeLoading() throws Exception {
- OrcsApi orcsApi = OsgiUtil.getService(OrcsApi.class);
-
ApplicationContext context = null; // TODO use real application context
QueryFactory queryFactory = orcsApi.getQueryFactory(context);
diff --git a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsAttributeSearchTest.java b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsAttributeSearchTest.java
index d076fd2df6f..ac4c5e31c53 100644
--- a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsAttributeSearchTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsAttributeSearchTest.java
@@ -22,9 +22,10 @@ import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
import org.eclipse.osee.orcs.ApplicationContext;
import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.core.OrcsIntegrationRule;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.db.mock.OseeDatabase;
-import org.eclipse.osee.orcs.db.mock.OsgiUtil;
+import org.eclipse.osee.orcs.db.mock.OsgiService;
import org.eclipse.osee.orcs.search.CaseType;
import org.eclipse.osee.orcs.search.Operator;
import org.eclipse.osee.orcs.search.QueryBuilder;
@@ -38,11 +39,16 @@ import org.junit.Rule;
public class OrcsAttributeSearchTest {
@Rule
+ public OrcsIntegrationRule osgi = new OrcsIntegrationRule(this);
+
+ @Rule
public OseeDatabase db1 = new OseeDatabase("osee.demo.h2");
+ @OsgiService
+ OrcsApi orcsApi;
+
@org.junit.Test
public void runGodMethod() throws OseeCoreException {
- OrcsApi orcsApi = OsgiUtil.getService(OrcsApi.class);
ApplicationContext context = null; // TODO use real application context
QueryFactory queryFactory = orcsApi.getQueryFactory(context);
diff --git a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsBranchTest.java b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsBranchTest.java
index b4f959e0cfc..bc44dca4304 100644
--- a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsBranchTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsBranchTest.java
@@ -17,10 +17,11 @@ import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.orcs.ApplicationContext;
import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.OrcsBranch;
+import org.eclipse.osee.orcs.core.OrcsIntegrationRule;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.CreateBranchData;
import org.eclipse.osee.orcs.db.mock.OseeDatabase;
-import org.eclipse.osee.orcs.db.mock.OsgiUtil;
+import org.eclipse.osee.orcs.db.mock.OsgiService;
import org.eclipse.osee.orcs.search.QueryFactory;
import org.junit.Assert;
import org.junit.Before;
@@ -34,22 +35,24 @@ import org.junit.Test;
public class OrcsBranchTest {
@Rule
+ public OrcsIntegrationRule osgi = new OrcsIntegrationRule(this);
+
+ @Rule
public OseeDatabase db = new OseeDatabase("osee.demo.h2");
- private OrcsApi orcsApi = null;
private OrcsBranch branchInterface = null;
private final ApplicationContext context = null; // TODO use real application context
private final static String ARTIFACT_NAME = "Joe Smith";
+ @OsgiService
+ OrcsApi orcsApi;
+
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
-
- orcsApi = OsgiUtil.getService(OrcsApi.class);
-
branchInterface = orcsApi.getBranchOps(context);
}
diff --git a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsQueryTest.java b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsQueryTest.java
index 76d4ac1bc81..0aac520c756 100644
--- a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsQueryTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsQueryTest.java
@@ -25,12 +25,12 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.orcs.ApplicationContext;
import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.core.OrcsIntegrationRule;
import org.eclipse.osee.orcs.core.mock.TestBranches;
-import org.eclipse.osee.orcs.core.mock.Utility;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
import org.eclipse.osee.orcs.db.mock.OseeDatabase;
-import org.eclipse.osee.orcs.db.mock.OsgiUtil;
+import org.eclipse.osee.orcs.db.mock.OsgiService;
import org.eclipse.osee.orcs.search.CaseType;
import org.eclipse.osee.orcs.search.Match;
import org.eclipse.osee.orcs.search.Operator;
@@ -49,18 +49,20 @@ import org.junit.Test;
public class OrcsQueryTest {
@Rule
+ public OrcsIntegrationRule osgi = new OrcsIntegrationRule(this);
+
+ @Rule
public OseeDatabase db = new OseeDatabase("osee.demo.h2");
private final boolean includeMatchLocationTests = false;
+ @OsgiService
+ OrcsApi orcsApi;
+
@Test
public void testQueries() throws OseeCoreException {
- Utility.checkRequiredServices();
-
- OrcsApi oseeApi = OsgiUtil.getService(OrcsApi.class);
-
ApplicationContext context = null; // TODO use real application context
- QueryFactory factory = oseeApi.getQueryFactory(null);
+ QueryFactory factory = orcsApi.getQueryFactory(null);
checkQueryByIds(factory);
diff --git a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsRelationLoadingTest.java b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsRelationLoadingTest.java
index 10d5c8acfd1..13f9753b15e 100644
--- a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsRelationLoadingTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsRelationLoadingTest.java
@@ -21,11 +21,11 @@ import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.orcs.ApplicationContext;
import org.eclipse.osee.orcs.OrcsApi;
-import org.eclipse.osee.orcs.core.mock.Utility;
+import org.eclipse.osee.orcs.core.OrcsIntegrationRule;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.GraphReadable;
import org.eclipse.osee.orcs.db.mock.OseeDatabase;
-import org.eclipse.osee.orcs.db.mock.OsgiUtil;
+import org.eclipse.osee.orcs.db.mock.OsgiService;
import org.eclipse.osee.orcs.search.Operator;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
@@ -40,20 +40,22 @@ import org.junit.Rule;
public class OrcsRelationLoadingTest {
@Rule
+ public OrcsIntegrationRule osgi = new OrcsIntegrationRule(this);
+
+ @Rule
public OseeDatabase db = new OseeDatabase("osee.demo.h2");
+ @OsgiService
+ OrcsApi orcsApi;
+
@org.junit.Test
public void testSearchById() throws Exception {
- Utility.checkRequiredServices();
-
- OrcsApi oseeApi = OsgiUtil.getService(OrcsApi.class);
-
ApplicationContext context = null; // TODO use real application context
- QueryFactory queryFactory = oseeApi.getQueryFactory(context);
- GraphReadable graph = oseeApi.getGraph(context);
- checkRelationsForCommonBranch(oseeApi, queryFactory, graph, context);
- checkRelationsForSawBranch(oseeApi, queryFactory, graph, context);
+ QueryFactory queryFactory = orcsApi.getQueryFactory(context);
+ GraphReadable graph = orcsApi.getGraph(context);
+ checkRelationsForCommonBranch(orcsApi, queryFactory, graph, context);
+ checkRelationsForSawBranch(orcsApi, queryFactory, graph, context);
}
diff --git a/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsTransactionTest.java b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsTransactionTest.java
new file mode 100644
index 00000000000..00cc364c758
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core.integration.test/src/org/eclipse/osee/orcs/core/internal/OrcsTransactionTest.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.orcs.core.internal;
+
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.SystemUser;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.ApplicationContext;
+import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.core.OrcsIntegrationRule;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.eclipse.osee.orcs.data.ArtifactWriteable;
+import org.eclipse.osee.orcs.db.mock.OseeDatabase;
+import org.eclipse.osee.orcs.db.mock.OsgiService;
+import org.eclipse.osee.orcs.transaction.OrcsTransaction;
+import org.eclipse.osee.orcs.transaction.TransactionFactory;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class OrcsTransactionTest {
+
+ @Rule
+ public OrcsIntegrationRule osgi = new OrcsIntegrationRule(this);
+
+ @Rule
+ public OseeDatabase db = new OseeDatabase("osee.demo.h2");
+
+ @OsgiService
+ private OrcsApi orcsApi;
+
+ private final ApplicationContext context = null; // TODO use real application context
+ private TransactionFactory txFactory;
+ private ArtifactReadable userArtifact;
+
+ @Before
+ public void setUp() throws Exception {
+ txFactory = orcsApi.getTransactionFactory(context);
+ userArtifact = getSystemUser();
+ }
+
+ @Test
+ public void testCreateArtifact() throws OseeCoreException {
+ String comment = "Test Artifact Write";
+ OrcsTransaction tx = txFactory.createTransaction(CoreBranches.COMMON, userArtifact, comment);
+
+ String name = "Create A Folder";
+ ArtifactWriteable writeable = tx.createArtifact(CoreArtifactTypes.Folder, "Create A Folder");
+ Assert.assertEquals(name, writeable.getName());
+
+ tx.commit();
+ }
+
+ private ArtifactReadable getSystemUser() throws OseeCoreException {
+ return orcsApi.getQueryFactory(context).fromBranch(CoreBranches.COMMON).andIds(SystemUser.OseeSystem).getResults().getExactlyOne();
+ }
+
+ // public static void main(String[] args) throws Exception {
+ // Tester x = new Tester();
+ //
+ // ArtifactReadable artifact1 = null;
+ // ArtifactReadable artifact2 = null;
+ //
+ // x.modifyOneArtifact(artifact1);
+ //
+ // GraphReadable readableGraph = x.getApi().getGraph(null);
+ //
+ // OrcsTransaction tx = x.getTransaction(); // branch and user and comment
+ //
+ // GraphWriteable wGraph = tx.asWriteableGraph(readableGraph);
+ //
+ // ArtifactWriteable wArt1 = tx.asWritable(artifact1);
+ // ArtifactWriteable wArt2 = tx.asWritable(artifact2);
+ //
+ // for (ArtifactWriteable child : wGraph.getWriteableChildren(wArt1)) {
+ // child.setName("George");
+ // }
+ //
+ // List<AttributeWriteable<String>> attributes = wArt1.getWriteableAttributes();
+ // for (AttributeWriteable<String> attribute : attributes) {
+ // attribute.setValue("Hello");
+ // }
+ //
+ // wArt1.setName("Name");
+ // wArt1.setSoleAttributeValue(CoreAttributeTypes.Annotation, "hello");
+ //
+ // wArt2.setName("Shawn");
+ //
+ // tx.commit();
+ // }
+}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.core.test/META-INF/MANIFEST.MF
index 2ca4a3e521d..59ec5dd344f 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.core.test/META-INF/MANIFEST.MF
@@ -6,12 +6,12 @@ Bundle-Version: 0.10.1.qualifier
Bundle-Vendor: Eclipse Open System Engineering Environment
Fragment-Host: org.eclipse.osee.orcs.core
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Import-Package: junit.framework;version="4.8.2",
- org.eclipse.core.runtime,
+Import-Package: org.eclipse.core.runtime,
org.eclipse.osee.framework.core.enums,
org.eclipse.osee.framework.core.model.cache,
org.eclipse.osee.framework.core.model.mocks,
org.junit;version="4.8.2",
org.junit.runner;version="4.8.2",
org.junit.runners;version="4.8.2"
-Require-Bundle: org.junit
+Require-Bundle: org.junit,
+ org.mockito
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/InternalTestSuite.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/InternalTestSuite.java
index e4ff80fb1ae..f436c20a35e 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/InternalTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/InternalTestSuite.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal;
+import org.eclipse.osee.orcs.core.internal.artifact.ArtifactTestSuite;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeTestSuite;
import org.eclipse.osee.orcs.core.internal.branch.BranchTestSuite;
import org.eclipse.osee.orcs.core.internal.relation.RelationTestSuite;
@@ -21,7 +22,12 @@ import org.junit.runners.Suite;
* @author Roberto E. Escobar
*/
@RunWith(Suite.class)
-@Suite.SuiteClasses({AttributeTestSuite.class, BranchTestSuite.class, RelationTestSuite.class, QueryTestSuite.class})
+@Suite.SuiteClasses({
+ ArtifactTestSuite.class,
+ AttributeTestSuite.class,
+ BranchTestSuite.class,
+ RelationTestSuite.class,
+ QueryTestSuite.class})
public class InternalTestSuite {
// Test Suite
}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactoryTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactoryTest.java
new file mode 100644
index 00000000000..5db6a0f505c
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactoryTest.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.orcs.core.internal.artifact;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.*;
+import java.util.Collection;
+import java.util.List;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+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.BranchCache;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.eclipse.osee.orcs.core.ds.ArtifactData;
+import org.eclipse.osee.orcs.core.ds.ArtifactDataFactory;
+import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData;
+import org.eclipse.osee.orcs.core.ds.AttributeData;
+import org.eclipse.osee.orcs.core.ds.VersionData;
+import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory;
+import org.eclipse.osee.orcs.core.internal.relation.RelationFactory;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+public class ArtifactFactoryTest {
+
+ // @formatter:off
+ @Mock private Branch branch;
+ @Mock private ArtifactType artifactType;
+ @Mock private ArtifactData artifactData;
+ @Mock private RelationContainer relationContainer;
+ // @formatter:on
+
+ private final String guid = GUID.create();
+
+ private ArtifactFactory artifactFactory;
+
+ @Before
+ public void init() throws OseeCoreException {
+ MockitoAnnotations.initMocks(this);
+ AttributeFactory attributeFactory = mock(AttributeFactory.class);
+ RelationFactory relationFactory = mock(RelationFactory.class);
+ ArtifactTypeCache artifactTypeCache = mock(ArtifactTypeCache.class);
+ BranchCache branchCache = mock(BranchCache.class);
+ ArtifactDataFactory factory = mock(ArtifactDataFactory.class);
+ artifactFactory = new ArtifactFactory(factory, attributeFactory, relationFactory, artifactTypeCache, branchCache);
+ when(artifactTypeCache.getByGuid(anyLong())).thenReturn(artifactType);
+ when(branchCache.getById(anyInt())).thenReturn(branch);
+ VersionData version = mock(VersionData.class);
+ when(artifactData.getVersion()).thenReturn(version);
+ when(relationFactory.createRelationContainer(anyInt())).thenReturn(relationContainer);
+ when(factory.create(branch, artifactType, guid)).thenReturn(artifactData);
+ when(factory.copy(branch, artifactData)).thenReturn(artifactData);
+ when(artifactData.getGuid()).thenReturn(guid);
+ }
+
+ @Test
+ public void testCreateWriteableArtifact() throws OseeCoreException {
+ ArtifactReadable artifact = artifactFactory.createWriteableArtifact(artifactData);
+ assertEquals(artifactType, artifact.getArtifactType());
+ assertEquals(guid, artifact.getGuid());
+
+ artifact = artifactFactory.createWriteableArtifact(branch, artifactType, guid);
+ assertEquals(artifactType, artifact.getArtifactType());
+ assertEquals(guid, artifact.getGuid());
+ }
+
+ @Test
+ public void testCreateReadableArtifact() throws OseeCoreException {
+ ArtifactReadable artifact = artifactFactory.createReadableArtifact(artifactData);
+ assertEquals(artifactType, artifact.getArtifactType());
+ assertEquals(guid, artifact.getGuid());
+ }
+
+ @Test
+ @Ignore
+ public void testCopyArtifact() throws OseeCoreException {
+ WritableArtifactProxy source = mock(WritableArtifactProxy.class);
+ Collection<? extends IAttributeType> types = mock(Collection.class);
+ ArtifactImpl impl = mock(ArtifactImpl.class);
+ when(source.getProxiedObject()).thenReturn(impl);
+ when(impl.getOrcsData()).thenReturn(artifactData);
+ artifactFactory.copyArtifact(source, types, branch);
+ }
+
+ @Test
+ public void testSetBackingData() throws OseeCoreException {
+ WritableArtifactProxy writeable = mock(WritableArtifactProxy.class);
+ ArtifactImpl original = mock(ArtifactImpl.class);
+ ArtifactImpl proxied = mock(ArtifactImpl.class);
+ List<AttributeData> attrData = mock(List.class);
+ ArtifactTransactionData data = mock(ArtifactTransactionData.class);
+
+ when(writeable.getOriginal()).thenReturn(original);
+ when(writeable.getProxiedObject()).thenReturn(proxied);
+ when(data.getArtifactData()).thenReturn(artifactData);
+ when(data.getAttributeData()).thenReturn(attrData);
+
+ artifactFactory.setBackingData(writeable, data);
+
+ verify(original).setOrcsData(artifactData);
+ verify(original).setBackingData(attrData);
+ verify(proxied).setOrcsData(artifactData);
+ verify(proxied).setBackingData(attrData);
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactTestSuite.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactTestSuite.java
new file mode 100644
index 00000000000..27f6c0b5d5d
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactTestSuite.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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.orcs.core.internal.artifact;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({ArtifactFactoryTest.class,})
+public class ArtifactTestSuite {
+ // Test Suite
+}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeCollectionTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeCollectionTest.java
new file mode 100644
index 00000000000..dfcde694c83
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeCollectionTest.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.orcs.core.internal.attribute;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.DeletionFlag;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+public class AttributeCollectionTest {
+
+ // @formatter:off
+ @Mock private AttributeExceptionFactory exceptionFactory;
+ // @formatter:on
+
+ private AttributeCollection attributeCollection;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ attributeCollection = new AttributeCollection(exceptionFactory);
+ }
+
+ @Test
+ @SuppressWarnings("unchecked")
+ public void testGetAttributesDirty() {
+ Attribute<String> dirtyAttr = mock(Attribute.class);
+ Attribute<String> cleanAttr = mock(Attribute.class);
+ when(dirtyAttr.isDirty()).thenReturn(true);
+ attributeCollection.addAttribute(CoreAttributeTypes.Country, dirtyAttr);
+ attributeCollection.addAttribute(CoreAttributeTypes.Country, cleanAttr);
+ assertEquals(1, attributeCollection.getAttributesDirty().size());
+ assertEquals(dirtyAttr, attributeCollection.getAttributesDirty().iterator().next());
+ }
+
+ @Test
+ public void testGetAttributeSetFromString() throws OseeCoreException {
+ attributeCollection.getAttributeSetFromString(CoreAttributeTypes.Country, DeletionFlag.EXCLUDE_DELETED, "test");
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeTestSuite.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeTestSuite.java
index 880a84e550c..6cc5d2305b6 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeTestSuite.java
@@ -17,7 +17,11 @@ import org.junit.runners.Suite;
* @author Roberto E. Escobar
*/
@RunWith(Suite.class)
-@Suite.SuiteClasses({AttributeClassResolverTest.class, AttributeFactoryTest.class, AttributeFactoryTest.class})
+@Suite.SuiteClasses({
+ AttributeClassResolverTest.class,
+ AttributeFactoryTest.class,
+ AttributeFactoryTest.class,
+ AttributeCollectionTest.class})
public class AttributeTestSuite {
// Test Suite
}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/RelationLoadingTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/RelationLoadingTest.java
index c4cff085dab..113eef06457 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/RelationLoadingTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/RelationLoadingTest.java
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.core.enums.RelationTypeMultiplicity;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
@@ -25,9 +26,11 @@ import org.eclipse.osee.framework.core.model.cache.RelationTypeCache;
import org.eclipse.osee.framework.core.model.mocks.MockOseeDataAccessor;
import org.eclipse.osee.framework.core.model.type.RelationType;
import org.eclipse.osee.orcs.core.ds.RelationData;
+import org.eclipse.osee.orcs.core.ds.VersionData;
import org.eclipse.osee.orcs.core.internal.artifact.RelationContainer;
import org.junit.Assert;
import org.junit.Test;
+import org.mockito.Mockito;
/**
* @author Andrew M. Finkbeiner
@@ -132,18 +135,23 @@ public class RelationLoadingTest {
if (row.length != 9) {
Assert.assertTrue("Data file is not formatted correctly", false);
}
- // TX_TODO
- // RelationData relationRow = new RelationData();
- // relationRow.setParentId(Integer.parseInt(row[0]));
- // relationRow.setArtIdA(Integer.parseInt(row[1]));
- // relationRow.setArtIdB(Integer.parseInt(row[2]));
- // relationRow.setBranch(Integer.parseInt(row[3]));
- // relationRow.setGammaId(Integer.parseInt(row[4]));
- // relationRow.setModType(ModificationType.valueOf(row[5]));
- // relationRow.setRationale(row[6]);
- // relationRow.setRelationId(Integer.parseInt(row[7]));
- // relationRow.setRelationTypeId(Integer.parseInt(row[8]));
- // data.add(relationRow);
+
+ VersionData version = Mockito.mock(VersionData.class);
+ version.setBranchId(Integer.parseInt(row[3]));
+ version.setGammaId(Integer.parseInt(row[4]));
+
+ RelationData relationRow = Mockito.mock(RelationData.class);
+
+ Mockito.when(relationRow.getParentId()).thenReturn(Integer.parseInt(row[0]));
+ Mockito.when(relationRow.getArtIdA()).thenReturn(Integer.parseInt(row[1]));
+ Mockito.when(relationRow.getArtIdB()).thenReturn(Integer.parseInt(row[2]));
+ Mockito.when(relationRow.getModType()).thenReturn(ModificationType.valueOf(row[5]));
+ Mockito.when(relationRow.getRationale()).thenReturn(row[6]);
+ Mockito.when(relationRow.getLocalId()).thenReturn(Integer.parseInt(row[7]));
+ Mockito.when(relationRow.getTypeUuid()).thenReturn(Long.parseLong(row[8]));
+ Mockito.when(relationRow.getVersion()).thenReturn(version);
+
+ data.add(relationRow);
}
}
}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionImplTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionImplTest.java
index 55bb1471263..df33b368903 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionImplTest.java
@@ -12,63 +12,106 @@ package org.eclipse.osee.orcs.core.internal.transaction;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
+import java.util.Collection;
+import org.eclipse.osee.framework.core.data.IArtifactToken;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.type.AttributeType;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.core.ds.BranchDataStore;
-import org.eclipse.osee.orcs.core.ds.DataFactory;
import org.eclipse.osee.orcs.core.internal.SessionContext;
import org.eclipse.osee.orcs.core.internal.artifact.ArtifactFactory;
-import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.ArtifactWriteable;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
/**
* @author John Misinco
*/
public class OrcsTransactionImplTest {
- @Mock
- private Log logger;
- @Mock
- private SessionContext sessionContext;
- @Mock
- private BranchDataStore dataStore;
- @Mock
- private ArtifactFactory artifactFactory;
- @Mock
- private AttributeFactory attributeFactory;
- @Mock
- private IOseeBranch branch;
- @Mock
- private DataFactory dataFactory;
- @Mock
- private ArtifactWriteable expected;
+ // @formatter:off
+ @Mock private Log logger;
+ @Mock private SessionContext sessionContext;
+ @Mock private BranchDataStore dataStore;
+ @Mock private ArtifactFactory artifactFactory;
+ @Mock private IOseeBranch branch;
+ @Mock private ArtifactWriteable expected;
+ // @formatter:on
+
private OrcsTransactionImpl transaction;
+ private String guid;
+ private final IArtifactType artType = CoreArtifactTypes.Artifact;
@Before
public void init() {
MockitoAnnotations.initMocks(this);
transaction = new OrcsTransactionImpl(logger, sessionContext, dataStore, artifactFactory, branch);
+ guid = GUID.create();
+ when(expected.getGuid()).thenReturn(guid);
}
@Test
public void testCreateArtifact() throws OseeCoreException {
- String guid = "guid";
- when(expected.getGuid()).thenReturn(guid);
- when(artifactFactory.createWriteableArtifact(branch, CoreArtifactTypes.Artifact, guid)).thenReturn(expected);
- ArtifactWriteable artifact = transaction.createArtifact(CoreArtifactTypes.Artifact, "test", guid);
+ String name = "testCreateArtifact";
+ when(artifactFactory.createWriteableArtifact(branch, artType, guid)).thenReturn(expected);
+
+ ArtifactWriteable artifact = transaction.createArtifact(artType, name, guid);
- verify(expected).setName("test");
+ verify(expected).setName(name);
+ verify(artifactFactory).createWriteableArtifact(branch, artType, guid);
assertNotNull(artifact);
}
@Test
- public void testDuplicateArtifact() {
+ public void testCreateArtifactFromToken() throws OseeCoreException {
+ IArtifactToken token = mock(IArtifactToken.class);
+ String name = "testCreateArtifactFromToken";
+ when(token.getName()).thenReturn(name);
+ when(token.getArtifactType()).thenReturn(artType);
+ when(token.getGuid()).thenReturn(guid);
+ when(artifactFactory.createWriteableArtifact(branch, artType, guid)).thenReturn(expected);
+
+ ArtifactWriteable artifact = transaction.createArtifact(token);
+
+ verify(expected).setName(name);
+ verify(artifactFactory).createWriteableArtifact(branch, artType, guid);
+ assertNotNull(artifact);
+ }
+
+ @Test
+ public void testDuplicateArtifact() throws OseeCoreException {
+ ArtifactReadable source = mock(ArtifactReadable.class);
+ final Collection<AttributeType> types = mock(Collection.class);
+ when(source.getGuid()).thenReturn(guid);
+ when(source.getExistingAttributeTypes()).thenAnswer(new Answer<Collection<? extends IAttributeType>>() {
+
+ @Override
+ public Collection<? extends IAttributeType> answer(InvocationOnMock invocation) throws Throwable {
+ return types;
+ }
+ });
+ when(artifactFactory.copyArtifact(source, types, branch)).thenReturn(expected);
+
+ transaction.duplicateArtifact(source);
+ verify(artifactFactory.copyArtifact(source, types, branch));
+ }
+
+ @Test
+ public void testIntroduceArtifact() throws OseeCoreException {
+ ArtifactReadable source = mock(ArtifactReadable.class);
+ when(artifactFactory.introduceArtifact(source, branch)).thenReturn(expected);
+ transaction.introduceArtifact(source);
+ verify(artifactFactory.introduceArtifact(source, branch));
}
}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionTestSuite.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionTestSuite.java
new file mode 100644
index 00000000000..0326a71240e
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionTestSuite.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.orcs.core.internal.transaction;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({OrcsTransactionImplTest.class})
+public class TransactionTestSuite {
+ // Test Suite
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactTransactionData.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactTransactionData.java
index 96b45e38ca5..bf1c7d49cca 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactTransactionData.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactTransactionData.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.orcs.core.ds;
import java.util.List;
import org.eclipse.osee.framework.core.data.Identity;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
public interface ArtifactTransactionData extends Identity<String> {
@@ -24,4 +25,6 @@ public interface ArtifactTransactionData extends Identity<String> {
List<RelationData> getRelationData();
+ void accept(OrcsVisitor visitor) throws OseeCoreException;
+
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsData.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsData.java
index 92aabf2165e..9462b7d0432 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsData.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsData.java
@@ -29,4 +29,5 @@ public interface OrcsData extends HasLocalId, HasVersion {
ModificationType getLoadedModType();
+ boolean isStorageAllowed();
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/AbstractSqlProvider.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsVisitor.java
index e838916207f..33a57becde7 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/AbstractSqlProvider.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsVisitor.java
@@ -8,22 +8,19 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.db.internal.transaction;
+package org.eclipse.osee.orcs.core.ds;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.core.ds.OrcsData;
-import org.eclipse.osee.orcs.db.internal.loader.IdFactory;
-public abstract class AbstractSqlProvider {
+/**
+ * @author Roberto E. Escobar
+ */
+public interface OrcsVisitor {
- private final IdFactory idFactory;
+ void visit(ArtifactData data) throws OseeCoreException;
- protected AbstractSqlProvider(IdFactory idFactory) {
- super();
- this.idFactory = idFactory;
- }
+ void visit(AttributeData data) throws OseeCoreException;
- long getGammaId(OrcsData data) throws OseeCoreException {
- return idFactory.getNextGammaId(data);
- }
-}
+ void visit(RelationData data) throws OseeCoreException;
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionData.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionData.java
index 4b02d9655d3..490bbeb0454 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionData.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionData.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.ds;
-import java.util.Collection;
+import java.util.List;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.orcs.data.ArtifactReadable;
@@ -23,5 +23,5 @@ public interface TransactionData {
String getComment();
- Collection<ArtifactTransactionData> getArtifactTransactionData() throws OseeCoreException;
+ List<ArtifactTransactionData> getArtifactTransactionData() throws OseeCoreException;
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/data/ArtifactTxDataImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/data/ArtifactTxDataImpl.java
new file mode 100644
index 00000000000..e4831fbae37
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/data/ArtifactTxDataImpl.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.orcs.core.ds.data;
+
+import java.util.LinkedList;
+import java.util.List;
+import org.eclipse.osee.framework.core.data.AbstractIdentity;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.core.ds.ArtifactData;
+import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData;
+import org.eclipse.osee.orcs.core.ds.AttributeData;
+import org.eclipse.osee.orcs.core.ds.OrcsVisitor;
+import org.eclipse.osee.orcs.core.ds.RelationData;
+
+/**
+ * @author John Misinco
+ */
+public class ArtifactTxDataImpl extends AbstractIdentity<String> implements ArtifactTransactionData {
+
+ private final ArtifactData artifactData;
+ private final List<AttributeData> attributeData;
+ private final List<RelationData> relationData = new LinkedList<RelationData>();
+
+ public ArtifactTxDataImpl(ArtifactData artifactData, List<AttributeData> attributeData) {
+ super();
+ this.artifactData = artifactData;
+ this.attributeData = attributeData;
+ }
+
+ @Override
+ public String getGuid() {
+ return getArtifactData().getGuid();
+ }
+
+ @Override
+ public ArtifactData getArtifactData() {
+ return artifactData;
+ }
+
+ @Override
+ public List<AttributeData> getAttributeData() {
+ return attributeData;
+ }
+
+ @Override
+ public List<RelationData> getRelationData() {
+ return relationData;
+ }
+
+ @Override
+ public void accept(OrcsVisitor visitor) throws OseeCoreException {
+ visitor.visit(getArtifactData());
+ for (AttributeData attributeData : getAttributeData()) {
+ visitor.visit(attributeData);
+ }
+ for (RelationData relationData : getRelationData()) {
+ visitor.visit(relationData);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java
index 39346b26646..10be5156c34 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.orcs.core.internal;
import org.eclipse.osee.executor.admin.ExecutorAdmin;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
+import org.eclipse.osee.framework.core.model.cache.TransactionCache;
import org.eclipse.osee.framework.core.services.IOseeCachingService;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.logger.Log;
@@ -122,6 +123,11 @@ public class OrcsApiImpl implements OrcsApi {
}
@Override
+ public TransactionCache getTxsCache() {
+ return cacheService.getTransactionCache();
+ }
+
+ @Override
public BranchCache getBranchCache() {
return cacheService.getBranchCache();
}
@@ -174,4 +180,5 @@ public class OrcsApiImpl implements OrcsApi {
String sessionId = GUID.create(); // TODO context.getSessionId() attach to application context
return new SessionContextImpl(sessionId);
}
+
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactory.java
index 65c1f2f7be7..4d694e0cdcb 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactory.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactory.java
@@ -12,10 +12,8 @@ package org.eclipse.osee.orcs.core.internal.artifact;
import java.util.Collection;
import java.util.HashSet;
-import java.util.LinkedList;
import java.util.List;
import java.util.Set;
-import org.eclipse.osee.framework.core.data.AbstractIdentity;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.data.IOseeBranch;
@@ -32,7 +30,7 @@ import org.eclipse.osee.orcs.core.ds.ArtifactData;
import org.eclipse.osee.orcs.core.ds.ArtifactDataFactory;
import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData;
import org.eclipse.osee.orcs.core.ds.AttributeData;
-import org.eclipse.osee.orcs.core.ds.RelationData;
+import org.eclipse.osee.orcs.core.ds.data.ArtifactTxDataImpl;
import org.eclipse.osee.orcs.core.internal.AbstractProxy;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory;
import org.eclipse.osee.orcs.core.internal.relation.RelationFactory;
@@ -64,13 +62,15 @@ public class ArtifactFactory {
public ArtifactWriteable createWriteableArtifact(ArtifactData artifactData) throws OseeCoreException {
//TODO implement an artifact class resolver for specific artifact types
ArtifactImpl artifact = createArtifact(artifactData);
- WritableArtifactProxy proxy = new WritableArtifactProxy(artifact);
+ artifact.setLoaded(true);
+ WritableArtifactProxy proxy = new WritableArtifactProxy(this, artifact);
return proxy;
}
public ArtifactWriteable createWriteableArtifact(IOseeBranch branch, IArtifactType artifactType, String guid) throws OseeCoreException {
ArtifactImpl artifact = createArtifact(branch, artifactType, guid);
- WritableArtifactProxy proxy = new WritableArtifactProxy(artifact);
+ artifact.setLoaded(true);
+ WritableArtifactProxy proxy = new WritableArtifactProxy(this, artifact);
return proxy;
}
@@ -81,17 +81,25 @@ public class ArtifactFactory {
}
public ArtifactWriteable copyArtifact(ArtifactReadable source, Collection<? extends IAttributeType> types, IOseeBranch ontoBranch) throws OseeCoreException {
- ArtifactImpl artifact = copyArtifactHelper(source, types, ontoBranch);
- WritableArtifactProxy proxy = new WritableArtifactProxy(artifact);
+ ArtifactImpl artifact = copyArtifactHelperTypeChecked(asArtifactImpl(source), ontoBranch, types);
+ artifact.setLoaded(true);
+ WritableArtifactProxy proxy = new WritableArtifactProxy(this, artifact);
return proxy;
}
public ArtifactWriteable introduceArtifact(ArtifactReadable source, IOseeBranch ontoBranch) throws OseeCoreException {
- ArtifactImpl artifact = introduceArtifactHelper(source, ontoBranch);
- WritableArtifactProxy proxy = new WritableArtifactProxy(artifact);
+ ArtifactImpl artifact = introduceArtifactHelper(asArtifactImpl(source), ontoBranch);
+ artifact.setLoaded(true);
+ WritableArtifactProxy proxy = new WritableArtifactProxy(this, artifact);
return proxy;
}
+ public ArtifactImpl clone(ArtifactImpl source) throws OseeCoreException {
+ ArtifactImpl copy = copyAllHelper(source);
+ copy.setLoaded(true);
+ return copy;
+ }
+
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
@@ -111,8 +119,19 @@ public class ArtifactFactory {
return artifact;
}
- private ArtifactImpl copyArtifactHelper(ArtifactReadable source, Collection<? extends IAttributeType> types, IOseeBranch ontoBranch) throws OseeCoreException {
- ArtifactData artifactData = factory.copy(ontoBranch, getOrcsData(source));
+ private ArtifactImpl copyAllHelper(ArtifactImpl source) throws OseeCoreException {
+ ArtifactData artifactData = factory.copy(source.getBranch(), source.getOrcsData());
+ ArtifactImpl artifact = createArtifact(artifactData);
+ for (IAttributeType attributeType : source.getExistingAttributeTypes()) {
+ for (AttributeReadable<?> attributeSource : source.getAttributes(attributeType)) {
+ attributeFactory.copyAttribute(attributeSource, source.getBranch(), artifact);
+ }
+ }
+ return artifact;
+ }
+
+ private ArtifactImpl copyArtifactHelperTypeChecked(ArtifactImpl source, IOseeBranch ontoBranch, Collection<? extends IAttributeType> types) throws OseeCoreException {
+ ArtifactData artifactData = factory.copy(ontoBranch, source.getOrcsData());
ArtifactImpl artifact = createArtifact(artifactData);
Collection<? extends IAttributeType> typeToCopy = getAllowedTypes(artifact, types);
for (IAttributeType attributeType : typeToCopy) {
@@ -123,11 +142,11 @@ public class ArtifactFactory {
return artifact;
}
- private ArtifactImpl introduceArtifactHelper(ArtifactReadable source, IOseeBranch ontoBranch) throws OseeCoreException {
+ private ArtifactImpl introduceArtifactHelper(ArtifactImpl source, IOseeBranch ontoBranch) throws OseeCoreException {
Conditions.checkExpressionFailOnTrue(ontoBranch.equals(source.getBranch()),
"Source artifact is on the same branch as transaction [%s]", ontoBranch);
- ArtifactData artifactData = factory.introduce(ontoBranch, getOrcsData(source));
+ ArtifactData artifactData = factory.introduce(ontoBranch, source.getOrcsData());
ArtifactImpl artifact = createArtifact(artifactData);
Collection<? extends IAttributeType> typeToCopy = getAllowedTypes(artifact, source.getExistingAttributeTypes());
for (IAttributeType attributeType : typeToCopy) {
@@ -159,9 +178,9 @@ public class ArtifactFactory {
toReturn = (WritableArtifactProxy) readable;
} else if (readable instanceof ReadableArtifactProxy) {
ArtifactImpl artifact = asArtifactImpl(readable);
- toReturn = new WritableArtifactProxy(artifact);
+ toReturn = new WritableArtifactProxy(this, artifact);
} else if (readable instanceof ArtifactImpl) {
- toReturn = new WritableArtifactProxy((ArtifactImpl) readable);
+ toReturn = new WritableArtifactProxy(this, (ArtifactImpl) readable);
} else {
throw new OseeStateException("Unable to convert from [%s] to ArtifactWriteable ",
readable != null ? readable.getClass().getName() : "null");
@@ -175,16 +194,13 @@ public class ArtifactFactory {
if (readable instanceof AbstractProxy) {
AbstractProxy<? extends ArtifactImpl> proxy = (AbstractProxy<? extends ArtifactImpl>) readable;
toReturn = proxy.getProxiedObject();
+ } else if (readable instanceof ArtifactImpl) {
+ toReturn = (ArtifactImpl) readable;
}
return toReturn;
}
- private ArtifactData getOrcsData(ArtifactReadable item) {
- return asArtifactImpl(item).getOrcsData();
- }
-
/////////////////////////////////////////////
-
public void setBackingData(ArtifactWriteable writeable, ArtifactTransactionData data) throws OseeCoreException {
// TX_TODO In Case of exception restore all to original ?
if (writeable instanceof WritableArtifactProxy) {
@@ -218,44 +234,12 @@ public class ArtifactFactory {
ArtifactTxDataImpl toReturn = null;
ArtifactImpl impl = asArtifactImpl(artifact);
if (artifact.isDirty()) {
- ArtifactData artifactData = factory.clone(impl.getOrcsData());
+ ArtifactData artData = impl.getOrcsData();
+ ArtifactData artifactData = factory.clone(artData);
List<AttributeData> attributes = attributeFactory.getChangeData(impl);
toReturn = new ArtifactTxDataImpl(artifactData, attributes);
}
return toReturn;
}
- private static class ArtifactTxDataImpl extends AbstractIdentity<String> implements ArtifactTransactionData {
-
- private final ArtifactData artifactData;
- private final List<AttributeData> attributeData;
- private final List<RelationData> relationData = new LinkedList<RelationData>();
-
- public ArtifactTxDataImpl(ArtifactData artifactData, List<AttributeData> attributeData) {
- super();
- this.artifactData = artifactData;
- this.attributeData = attributeData;
- }
-
- @Override
- public String getGuid() {
- return getArtifactData().getGuid();
- }
-
- @Override
- public ArtifactData getArtifactData() {
- return artifactData;
- }
-
- @Override
- public List<AttributeData> getAttributeData() {
- return attributeData;
- }
-
- @Override
- public List<RelationData> getRelationData() {
- return relationData;
- }
-
- }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactImpl.java
index d0898311d2d..2adcc56b8f9 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactImpl.java
@@ -21,12 +21,11 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.type.ArtifactType;
import org.eclipse.osee.orcs.core.ds.ArtifactData;
-import org.eclipse.osee.orcs.core.ds.HasOrcsData;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeManagerImpl;
import org.eclipse.osee.orcs.data.ArtifactWriteable;
-public class ArtifactImpl extends AttributeManagerImpl implements HasOrcsData<ArtifactData>, ArtifactWriteable, Cloneable {
+public class ArtifactImpl extends AttributeManagerImpl implements ArtifactWriteable {
private final RelationContainer relationContainer;
private final ArtifactType artifactType;
@@ -35,7 +34,7 @@ public class ArtifactImpl extends AttributeManagerImpl implements HasOrcsData<Ar
private ArtifactData artifactData;
public ArtifactImpl(ArtifactType artifactType, Branch branch, ArtifactData artifactData, AttributeFactory attributeFactory, RelationContainer relationContainer) {
- super(artifactData, attributeFactory);
+ super(attributeFactory);
this.artifactData = artifactData;
this.artifactType = artifactType;
this.branch = branch;
@@ -101,6 +100,7 @@ public class ArtifactImpl extends AttributeManagerImpl implements HasOrcsData<Ar
public void setArtifactType(IArtifactType artifactType) {
if (!this.artifactType.equals(artifactType)) {
objectEditState = EditState.ARTIFACT_TYPE_MODIFIED;
+ getOrcsData().setTypeUuid(artifactType.getGuid());
if (getOrcsData().getVersion().isInStorage()) {
// lastValidModType = modType;
getOrcsData().setModType(ModificationType.MODIFIED);
@@ -132,24 +132,6 @@ public class ArtifactImpl extends AttributeManagerImpl implements HasOrcsData<Ar
}
@Override
- public ArtifactImpl clone() throws CloneNotSupportedException {
- // ArtifactImpl otherObject = (ArtifactImpl) super.clone();
- // otherObject.humandReadableId = this.humandReadableId;
- // otherObject.historical = this.historical;
- // otherObject.branch = this.branch;
- // otherObject.artifactType = this.artifactType;
-
- // TODO finish copying
- // otherObject.relationProxy = this.relationProxy;
- // otherObject.attributeContainer = new AttributeContainerImpl(otherObject);
-
- // for (AttributeReadable<?> attribute : this.attributeContainer.getAttributes()) {
- // attributeContainer.add(attribute.getAttributeType(), attribute.);
- // }
- throw new CloneNotSupportedException("Implementation not finished");
- }
-
- @Override
public boolean isDeleted() {
return getModificationType().isDeleted();
}
@@ -166,7 +148,7 @@ public class ArtifactImpl extends AttributeManagerImpl implements HasOrcsData<Ar
@Override
public String getExceptionString() {
- return String.format("artifact [%s] guid[%s] on branch[%s]", getName(), getGuid(), getBranch());
+ return String.format("artifact type [%s] guid[%s] on branch[%s]", getArtifactType(), getGuid(), getBranch());
}
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/AttributeManager.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/AttributeManager.java
index 0cb13d4efd0..28ebed3676a 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/AttributeManager.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/AttributeManager.java
@@ -35,7 +35,7 @@ public interface AttributeManager extends Named, Identity<String> {
boolean isLoaded();
- void setLoaded(boolean value);
+ void setLoaded(boolean value) throws OseeCoreException;
/////////////////////////////////////////////////////////////////
@@ -47,6 +47,10 @@ public interface AttributeManager extends Named, Identity<String> {
int getAttributeCount(IAttributeType type) throws OseeCoreException;
+ int getMaximumAttributeTypeAllowed(IAttributeType attributeType) throws OseeCoreException;
+
+ int getMinimumAttributeTypeAllowed(IAttributeType attributeType) throws OseeCoreException;
+
boolean isAttributeTypeValid(IAttributeType attributeType) throws OseeCoreException;
Collection<? extends IAttributeType> getValidAttributeTypes() throws OseeCoreException;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/WritableArtifactProxy.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/WritableArtifactProxy.java
index 7e008ea7dd1..44c9f3a61a4 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/WritableArtifactProxy.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/WritableArtifactProxy.java
@@ -17,7 +17,6 @@ import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.exception.OseeAccessDeniedException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
import org.eclipse.osee.orcs.core.internal.transaction.WriteableProxy;
import org.eclipse.osee.orcs.data.ArtifactWriteable;
import org.eclipse.osee.orcs.data.AttributeWriteable;
@@ -25,11 +24,13 @@ import org.eclipse.osee.orcs.data.AttributeWriteable;
public class WritableArtifactProxy extends ReadableArtifactProxy implements ArtifactWriteable, WriteableProxy {
private boolean isCopyRequired;
+ private final ArtifactFactory artifactFactory;
private ArtifactImpl original;
private volatile boolean isWriteAllowed;
- public WritableArtifactProxy(ArtifactImpl originalArtifact) {
+ public WritableArtifactProxy(ArtifactFactory artifactFactory, ArtifactImpl originalArtifact) {
super(originalArtifact);
+ this.artifactFactory = artifactFactory;
isWriteAllowed = true;
}
@@ -59,12 +60,14 @@ public class WritableArtifactProxy extends ReadableArtifactProxy implements Arti
throw new OseeAccessDeniedException("The artifact being accessed has been invalidated");
}
if (isCopyRequired) {
+ boolean successful = false;
try {
- ArtifactImpl copy = getOriginal().clone();
+ ArtifactImpl copy = artifactFactory.clone(getOriginal());
super.setProxiedObject(copy);
isCopyRequired = false;
- } catch (CloneNotSupportedException ex) {
- OseeExceptions.wrapAndThrow(ex);
+ successful = true;
+ } finally {
+ setWriteState(successful);
}
}
return getProxiedObject();
@@ -147,11 +150,11 @@ public class WritableArtifactProxy extends ReadableArtifactProxy implements Arti
@Override
public boolean isDirty() throws OseeCoreException {
- return getObjectForWrite().isDirty();
+ return getProxiedObject().isDirty();
}
@Override
public boolean isDeleted() throws OseeCoreException {
- return getObjectForWrite().isDeleted();
+ return getProxiedObject().isDeleted();
}
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/Attribute.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/Attribute.java
index f34846782fd..d4c2f44d48a 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/Attribute.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/Attribute.java
@@ -61,7 +61,7 @@ public abstract class Attribute<T> implements HasOrcsData<AttributeData>, Compar
@Override
public void setOrcsData(AttributeData data) {
- attributeData = data;
+ this.attributeData = data;
}
/**
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeClassResolver.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeClassResolver.java
index af63b129910..852bbffb936 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeClassResolver.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeClassResolver.java
@@ -35,6 +35,14 @@ public class AttributeClassResolver {
this.logger = logger;
}
+ public void start() {
+ //
+ }
+
+ public void stop() {
+ //
+ }
+
public void addProvider(AttributeClassProvider provider) {
for (Class<? extends Attribute<?>> clazz : provider.getClasses()) {
String alias = toAlias(clazz);
@@ -66,7 +74,7 @@ public class AttributeClassResolver {
return map.get(alias);
}
- Class<? extends Attribute<?>> getBaseClazz(AttributeType attributeType) {
+ protected Class<? extends Attribute<?>> getBaseClazz(AttributeType attributeType) {
String alias = attributeType.getBaseAttributeTypeId();
if (alias.contains(".")) {
alias = Lib.getExtension(alias);
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeCollection.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeCollection.java
index 20a3cf104c6..5545fd5fc92 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeCollection.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeCollection.java
@@ -40,7 +40,7 @@ public class AttributeCollection {
this.exceptionFactory = exceptionFactory;
}
- public void setBackingData(List<AttributeData> datas) throws OseeCoreException {
+ public void setBackingData(List<AttributeData> datas) {
Map<Integer, Attribute<?>> attrById = new HashMap<Integer, Attribute<?>>();
for (Attribute<?> attribute : attributes.getValues()) {
attrById.put(attribute.getId(), attribute);
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactory.java
index f991523eea1..cb4175b68d3 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactory.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactory.java
@@ -125,28 +125,13 @@ public class AttributeFactory {
Attribute<T> toReturn = null;
if (readable instanceof Attribute) {
toReturn = (Attribute<T>) readable;
+ } else if (readable instanceof AttributeWritableProxy) {
+ toReturn = ((AttributeWritableProxy<T>) readable).getProxiedObject();
}
return toReturn;
}
- public static enum MultiplicityState {
- IS_VALID,
- MAX_VIOLATION,
- MIN_VIOLATION;
- }
-
- public MultiplicityState getAttributeMuliplicityState(IAttributeType attributeType, int count) throws OseeCoreException {
- MultiplicityState state = MultiplicityState.IS_VALID;
- AttributeType fullType = getAttribeType(attributeType);
- if (count > fullType.getMaxOccurrences()) {
- state = MultiplicityState.MAX_VIOLATION;
- } else if (count < fullType.getMinOccurrences()) {
- state = MultiplicityState.MIN_VIOLATION;
- }
- return state;
- }
-
- private AttributeType getAttribeType(IAttributeType token) throws OseeCoreException {
+ public AttributeType getAttribeType(IAttributeType token) throws OseeCoreException {
return token instanceof AttributeType ? (AttributeType) token : cache.get(token);
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeManagerImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeManagerImpl.java
index 42a5105f0ee..d325b009fa0 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeManagerImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeManagerImpl.java
@@ -28,12 +28,11 @@ import org.eclipse.osee.framework.core.exception.MultipleAttributesExist;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
import org.eclipse.osee.framework.core.exception.OseeStateException;
+import org.eclipse.osee.framework.core.model.type.AttributeType;
import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.orcs.core.ds.ArtifactData;
import org.eclipse.osee.orcs.core.ds.AttributeData;
import org.eclipse.osee.orcs.core.internal.artifact.AttributeManager;
-import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory.MultiplicityState;
import org.eclipse.osee.orcs.data.AttributeReadable;
import org.eclipse.osee.orcs.data.AttributeWriteable;
@@ -47,13 +46,12 @@ public abstract class AttributeManagerImpl extends AbstractIdentity<String> impl
private final AttributeCollection attributes;
private boolean isLoaded;
- private final ArtifactData artifactData;
private final AttributeFactory attributeFactory;
- public AttributeManagerImpl(ArtifactData artifactData, AttributeFactory attributeFactory) {
- this.attributes = new AttributeCollection(this);
- this.artifactData = artifactData;
+ protected AttributeManagerImpl(AttributeFactory attributeFactory) {
+ super();
this.attributeFactory = attributeFactory;
+ this.attributes = new AttributeCollection(this);
}
@Override
@@ -77,7 +75,7 @@ public abstract class AttributeManagerImpl extends AbstractIdentity<String> impl
}
@Override
- public void setLoaded(boolean value) {
+ public void setLoaded(boolean value) throws OseeCoreException {
this.isLoaded = value;
if (value == true) {
onLoaded();
@@ -122,6 +120,26 @@ public abstract class AttributeManagerImpl extends AbstractIdentity<String> impl
}
@Override
+ public int getMaximumAttributeTypeAllowed(IAttributeType attributeType) throws OseeCoreException {
+ int result = -1;
+ if (isAttributeTypeValid(attributeType)) {
+ AttributeType fullType = attributeFactory.getAttribeType(attributeType);
+ result = fullType.getMaxOccurrences();
+ }
+ return result;
+ }
+
+ @Override
+ public int getMinimumAttributeTypeAllowed(IAttributeType attributeType) throws OseeCoreException {
+ int result = -1;
+ if (isAttributeTypeValid(attributeType)) {
+ AttributeType fullType = attributeFactory.getAttribeType(attributeType);
+ result = fullType.getMinOccurrences();
+ }
+ return result;
+ }
+
+ @Override
public Collection<? extends IAttributeType> getExistingAttributeTypes() throws OseeCoreException {
ensureAttributesLoaded();
return attributes.getExistingTypes(DeletionFlag.EXCLUDE_DELETED);
@@ -272,11 +290,12 @@ public abstract class AttributeManagerImpl extends AbstractIdentity<String> impl
}
private void deleteAttribute(Attribute<?> attribute) throws OseeCoreException {
- checkMultiplicityCanDelete(attribute.getAttributeType());
+ IAttributeType attributeType = attribute.getAttributeType();
+ checkMultiplicityCanDelete(attributeType);
if (attribute.isInDb()) {
attribute.delete();
} else {
- attributes.removeAttribute(attribute.getAttributeType(), attribute);
+ attributes.removeAttribute(attributeType, attribute);
}
}
@@ -301,7 +320,7 @@ public abstract class AttributeManagerImpl extends AbstractIdentity<String> impl
private <T> Attribute<T> createAttributeHelper(IAttributeType attributeType) throws OseeCoreException {
checkTypeValid(attributeType);
checkMultiplicityCanAdd(attributeType);
- return attributeFactory.createAttribute(this, artifactData, attributeType);
+ return attributeFactory.createAttribute(this, getOrcsData(), attributeType);
}
private <T> Attribute<T> getOrCreateSoleAttribute(IAttributeType attributeType) throws OseeCoreException {
@@ -443,8 +462,10 @@ public abstract class AttributeManagerImpl extends AbstractIdentity<String> impl
//////////////////////////////////////////////////////////////
private void checkTypeValid(IAttributeType attributeType) throws OseeCoreException {
- Conditions.checkExpressionFailOnTrue(!isAttributeTypeValid(attributeType),
- "The attribute type [%s] is not valid for artifacts [%s]", attributeType, getExceptionString());
+ if (!CoreAttributeTypes.Name.equals(attributeType)) {
+ Conditions.checkExpressionFailOnTrue(!isAttributeTypeValid(attributeType),
+ "The attribute type [%s] is not valid for artifacts [%s]", attributeType, getExceptionString());
+ }
}
private void checkMultiplicityCanAdd(IAttributeType attributeType) throws OseeCoreException {
@@ -456,7 +477,7 @@ public abstract class AttributeManagerImpl extends AbstractIdentity<String> impl
}
private void checkMultiplicity(IAttributeType attributeType, int count) throws OseeCoreException {
- MultiplicityState state = attributeFactory.getAttributeMuliplicityState(attributeType, count);
+ MultiplicityState state = getAttributeMuliplicityState(attributeType, count);
switch (state) {
case MAX_VIOLATION:
throw new OseeStateException("Attribute type [%s] exceeds max occurrence rule on artifacts [%s]",
@@ -469,30 +490,49 @@ public abstract class AttributeManagerImpl extends AbstractIdentity<String> impl
}
}
+ private static enum MultiplicityState {
+ IS_VALID,
+ MAX_VIOLATION,
+ MIN_VIOLATION;
+ }
+
+ private MultiplicityState getAttributeMuliplicityState(IAttributeType attributeType, int count) throws OseeCoreException {
+ MultiplicityState state = MultiplicityState.IS_VALID;
+ AttributeType fullType = attributeFactory.getAttribeType(attributeType);
+ if (count > fullType.getMaxOccurrences()) {
+ state = MultiplicityState.MAX_VIOLATION;
+ } else if (count < fullType.getMinOccurrences()) {
+ state = MultiplicityState.MIN_VIOLATION;
+ }
+ return state;
+ }
+
//////////////////////////////////////////////////////////////
- private void onLoaded() {
+ private void onLoaded() throws OseeCoreException {
// computeLastDateModified();
- // artifact.meetMinimumAttributeCounts(false);
+ meetMinimumAttributes();
}
- @SuppressWarnings("unused")
- private void ensureAttributesLoaded() throws OseeCoreException {
+ private void ensureAttributesLoaded() {
// if (!isLoaded() && isInDb()) {
// ArtifactLoader.loadArtifactData(this, LoadLevel.ATTRIBUTE);
// }
- meetMinimumAttributes();
}
- // @Override
private void meetMinimumAttributes() throws OseeCoreException {
- // for (IAttributeType attributeType : getValidAttributeTypes()) {
- // int missingCount = artifact.getMinOccurrences(attributeType) - artifact.getAttributeCount(attributeType);
- // for (int i = 0; i < missingCount; i++) {
- // Attribute<Object> attr = attributeFactory.createAttribute(artifact, artifact.getOrcsData(), attributeType);
- // attr.clearDirty();
- // }
- // }
+ for (IAttributeType attributeType : getValidAttributeTypes()) {
+ int missingCount = getRemainingAttributeCount(attributeType);
+ for (int i = 0; i < missingCount; i++) {
+ Attribute<Object> attr = attributeFactory.createAttribute(this, getOrcsData(), attributeType);
+ attr.clearDirty();
+ }
+ }
+ }
+
+ private final int getRemainingAttributeCount(IAttributeType token) throws OseeCoreException {
+ AttributeType attributeType = attributeFactory.getAttribeType(token);
+ return attributeType.getMinOccurrences() - getAttributeCount(attributeType);
}
//////////////////////////////////////////////////////////////
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeOwner.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeOwner.java
index 28c7192bf7c..e5738b7b792 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeOwner.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeOwner.java
@@ -13,11 +13,13 @@ package org.eclipse.osee.orcs.core.internal.attribute;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.data.Identity;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.core.ds.ArtifactData;
+import org.eclipse.osee.orcs.core.ds.HasOrcsData;
/**
* @author Roberto E. Escobar
*/
-public interface AttributeOwner extends Identity<String> {
+public interface AttributeOwner extends Identity<String>, HasOrcsData<ArtifactData> {
boolean isAttributeTypeValid(IAttributeType attributeType) throws OseeCoreException;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionImpl.java
index fdfd7f2a586..50072470b2a 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionImpl.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.orcs.core.internal.transaction;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
@@ -80,8 +81,8 @@ public class OrcsTransactionImpl implements OrcsTransaction, TransactionData {
}
@Override
- public Collection<ArtifactTransactionData> getArtifactTransactionData() throws OseeCoreException {
- Collection<ArtifactTransactionData> data = new ArrayList<ArtifactTransactionData>();
+ public List<ArtifactTransactionData> getArtifactTransactionData() throws OseeCoreException {
+ List<ArtifactTransactionData> data = new LinkedList<ArtifactTransactionData>();
for (ArtifactWriteable writeable : writeableArtifacts.values()) {
data.add(artifactFactory.getChangeData(writeable));
}
@@ -204,13 +205,14 @@ public class OrcsTransactionImpl implements OrcsTransaction, TransactionData {
@Override
public GraphWriteable asWriteableGraph(GraphReadable readableGraph) throws OseeCoreException {
- //TX_TODO
- return null;
+ //TX_TODO Relation Stuff?
+ throw new UnsupportedOperationException();
}
@Override
public void deleteArtifact(ArtifactWriteable artifact) throws OseeCoreException {
- //TX_TODO
+ //TX_TODO Delete artifact and relation stuff
+ throw new UnsupportedOperationException();
// public static void deleteArtifact(SkynetTransaction transaction, boolean overrideDeleteCheck, final Artifact... artifacts) throws OseeCoreException {
// deleteArtifactCollection(transaction, overrideDeleteCheck, Arrays.asList(artifacts));
// }
diff --git a/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/OsgiRule.java b/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/OsgiRule.java
new file mode 100644
index 00000000000..dda89ed83f6
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/OsgiRule.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.orcs.db.mock;
+
+import java.lang.reflect.Field;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.db.mock.internal.OsgiUtil;
+import org.junit.rules.TestWatchman;
+import org.junit.runners.model.FrameworkMethod;
+
+public class OsgiRule extends TestWatchman {
+
+ private final Object[] objects;
+
+ public OsgiRule(Object... objects) {
+ this.objects = objects;
+ }
+
+ @Override
+ public void starting(FrameworkMethod method) {
+ try {
+ for (Object object : objects) {
+ initAnnotations(object);
+ }
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public static void initAnnotations(Object testClass) throws Exception {
+ if (testClass == null) {
+ throw new OseeCoreException(
+ "testClass cannot be null. For info how to use @OsgiService annotations see examples");
+ }
+
+ Class<?> clazz = testClass.getClass();
+ while (clazz != Object.class) {
+ scan(testClass, clazz);
+ clazz = clazz.getSuperclass();
+ }
+ }
+
+ private static void scan(Object object, Class<?> clazz) throws Exception {
+ Field[] fields = clazz.getDeclaredFields();
+ for (Field field : fields) {
+ if (field.isAnnotationPresent(OsgiService.class)) {
+ OsgiService annotation = field.getAnnotation(OsgiService.class);
+ injectToFields(annotation, object, field);
+ }
+ }
+ }
+
+ private static void injectToFields(OsgiService annotation, Object object, Field field) throws Exception {
+ boolean wasAccessible = field.isAccessible();
+ field.setAccessible(true);
+ try {
+ Object service = OsgiUtil.getService(field.getType());
+ field.set(object, service);
+ } catch (IllegalAccessException e) {
+ throw new Exception("Problems injecting dependencies in " + field.getName(), e);
+ } finally {
+ field.setAccessible(wasAccessible);
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/InsertDataCollector.java b/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/OsgiService.java
index 7c865070114..a99385233e4 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/InsertDataCollector.java
+++ b/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/OsgiService.java
@@ -8,19 +8,17 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.db.internal.transaction;
+package org.eclipse.osee.orcs.db.mock;
-import org.eclipse.osee.orcs.db.internal.sql.OseeSql;
+import static java.lang.annotation.ElementType.FIELD;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
-public interface InsertDataCollector {
-
- // int getTransactionNumber();
+@Target({FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface OsgiService {
//
- // int getBranchId();
-
- void addBinaryStore(BinaryStoreTx binaryTx);
-
- void addInsertToBatch(int insertPriority, String insertSql, Object... data);
-
- void addTxNotCurrentToBatch(OseeSql insertSql, Object... data);
}
diff --git a/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/OsgiUtil.java b/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/OsgiUtil.java
index b4de3ece327..df0e92d49b9 100644
--- a/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/OsgiUtil.java
+++ b/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/OsgiUtil.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.db.mock;
+package org.eclipse.osee.orcs.db.mock.internal;
import java.util.Dictionary;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
diff --git a/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/TestDatabase.java b/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/TestDatabase.java
index a1fa6261d51..66499902f08 100644
--- a/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/TestDatabase.java
+++ b/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/TestDatabase.java
@@ -23,7 +23,6 @@ import org.eclipse.osee.framework.h2.H2DbServer;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.network.PortUtil;
import org.eclipse.osee.orcs.db.mock.OseeDatabase;
-import org.eclipse.osee.orcs.db.mock.OsgiUtil;
import org.junit.Assert;
import org.junit.runners.model.FrameworkMethod;
import org.osgi.framework.Bundle;
diff --git a/plugins/org.eclipse.osee.orcs.db.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.db.test/META-INF/MANIFEST.MF
index 821599cf69f..21643840661 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.db.test/META-INF/MANIFEST.MF
@@ -19,4 +19,5 @@ Import-Package: org.eclipse.osee.framework.core.data,
org.junit.rules;version="4.8.2",
org.junit.runner;version="4.8.2",
org.junit.runners;version="4.8.2"
-Require-Bundle: org.eclipse.osee.framework.core
+Require-Bundle: org.eclipse.osee.framework.core,
+ org.mockito
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/InternalJunitTestSuite.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/InternalJunitTestSuite.java
index f94e773ed6a..38632d95cec 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/InternalJunitTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/InternalJunitTestSuite.java
@@ -14,6 +14,7 @@ import org.eclipse.osee.orcs.db.internal.exchange.ExchangeTestSuite;
import org.eclipse.osee.orcs.db.internal.proxy.ProxyTestSuite;
import org.eclipse.osee.orcs.db.internal.resource.ResourceTestSuite;
import org.eclipse.osee.orcs.db.internal.search.SearchTestSuite;
+import org.eclipse.osee.orcs.db.internal.transaction.TransactionTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -21,7 +22,12 @@ import org.junit.runners.Suite;
* @author Roberto E. Escobar
*/
@RunWith(Suite.class)
-@Suite.SuiteClasses({ExchangeTestSuite.class, ProxyTestSuite.class, ResourceTestSuite.class, SearchTestSuite.class})
+@Suite.SuiteClasses({
+ ExchangeTestSuite.class,
+ ProxyTestSuite.class,
+ ResourceTestSuite.class,
+ TransactionTestSuite.class,
+ SearchTestSuite.class})
public class InternalJunitTestSuite {
// Test Suite
}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/accessor/OseeInfoDataAccessorTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/accessor/OseeInfoDataAccessorTest.java
index b280f8c20da..c00f377df30 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/accessor/OseeInfoDataAccessorTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/accessor/OseeInfoDataAccessorTest.java
@@ -20,7 +20,8 @@ import org.eclipse.osee.orcs.core.ds.DataStoreConstants;
import org.eclipse.osee.orcs.db.internal.SqlProvider;
import org.eclipse.osee.orcs.db.internal.resource.ResourceConstants;
import org.eclipse.osee.orcs.db.mock.OseeDatabase;
-import org.eclipse.osee.orcs.db.mock.OsgiUtil;
+import org.eclipse.osee.orcs.db.mock.OsgiRule;
+import org.eclipse.osee.orcs.db.mock.OsgiService;
import org.eclipse.osee.orcs.db.mocks.MockLog;
import org.junit.Assert;
import org.junit.Rule;
@@ -33,12 +34,16 @@ import org.junit.Rule;
public class OseeInfoDataAccessorTest {
@Rule
+ public OsgiRule osgi = new OsgiRule(this);
+
+ @Rule
public OseeDatabase db = new OseeDatabase("osee.demo.h2");
+ @OsgiService
+ IOseeDatabaseService dbService;
+
@org.junit.Test
public void testGetSetValue() throws OseeCoreException {
- IOseeDatabaseService dbService = OsgiUtil.getService(IOseeDatabaseService.class);
-
OseeInfoDataAccessor accessor = new OseeInfoDataAccessor();
accessor.setLogger(new MockLog());
accessor.setDatabaseService(dbService);
@@ -55,8 +60,6 @@ public class OseeInfoDataAccessorTest {
@org.junit.Test(expected = OseeStateException.class)
public void testSetBinaryDataPath() throws OseeCoreException {
- IOseeDatabaseService dbService = OsgiUtil.getService(IOseeDatabaseService.class);
-
OseeInfoDataAccessor accessor = new OseeInfoDataAccessor();
accessor.setLogger(new MockLog());
accessor.setDatabaseService(dbService);
@@ -66,8 +69,6 @@ public class OseeInfoDataAccessorTest {
@org.junit.Test
public void testGetBinaryDataPath() throws OseeCoreException {
- IOseeDatabaseService dbService = OsgiUtil.getService(IOseeDatabaseService.class);
-
OseeInfoDataAccessor accessor = new OseeInfoDataAccessor();
accessor.setLogger(new MockLog());
accessor.setDatabaseService(dbService);
@@ -86,8 +87,6 @@ public class OseeInfoDataAccessorTest {
@org.junit.Test(expected = OseeStateException.class)
public void testSetDatabaseHintsSupported() throws OseeCoreException {
- IOseeDatabaseService dbService = OsgiUtil.getService(IOseeDatabaseService.class);
-
OseeInfoDataAccessor accessor = new OseeInfoDataAccessor();
accessor.setLogger(new MockLog());
accessor.setDatabaseService(dbService);
@@ -97,8 +96,6 @@ public class OseeInfoDataAccessorTest {
@org.junit.Test
public void testGetDatabaseHintsSupported() throws OseeCoreException {
- IOseeDatabaseService dbService = OsgiUtil.getService(IOseeDatabaseService.class);
-
OseeInfoDataAccessor accessor = new OseeInfoDataAccessor();
accessor.setLogger(new MockLog());
accessor.setDatabaseService(dbService);
@@ -118,8 +115,6 @@ public class OseeInfoDataAccessorTest {
@org.junit.Test(expected = OseeStateException.class)
public void testSetCheckTagQueueOnStartupAllowed() throws OseeCoreException {
- IOseeDatabaseService dbService = OsgiUtil.getService(IOseeDatabaseService.class);
-
OseeInfoDataAccessor accessor = new OseeInfoDataAccessor();
accessor.setLogger(new MockLog());
accessor.setDatabaseService(dbService);
@@ -129,8 +124,6 @@ public class OseeInfoDataAccessorTest {
@org.junit.Test
public void testGetCheckTagQueueOnStartupAllowed() throws OseeCoreException {
- IOseeDatabaseService dbService = OsgiUtil.getService(IOseeDatabaseService.class);
-
OseeInfoDataAccessor accessor = new OseeInfoDataAccessor();
accessor.setLogger(new MockLog());
accessor.setDatabaseService(dbService);
@@ -149,7 +142,6 @@ public class OseeInfoDataAccessorTest {
@org.junit.Test
public void testGetKeys() throws OseeCoreException {
- IOseeDatabaseService dbService = OsgiUtil.getService(IOseeDatabaseService.class);
OseeInfoDataAccessor accessor = new OseeInfoDataAccessor();
accessor.setLogger(new MockLog());
accessor.setDatabaseService(dbService);
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/ArtifactLoaderTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/ArtifactLoaderTest.java
index 90fd2fe83ae..4348f95042f 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/ArtifactLoaderTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/ArtifactLoaderTest.java
@@ -31,7 +31,8 @@ import org.eclipse.osee.orcs.db.internal.loader.data.OrcsObjectFactoryImpl;
import org.eclipse.osee.orcs.db.internal.loader.data.VersionDataImpl;
import org.eclipse.osee.orcs.db.internal.sql.StaticSqlProvider;
import org.eclipse.osee.orcs.db.mock.OseeDatabase;
-import org.eclipse.osee.orcs.db.mock.OsgiUtil;
+import org.eclipse.osee.orcs.db.mock.OsgiRule;
+import org.eclipse.osee.orcs.db.mock.OsgiService;
import org.eclipse.osee.orcs.db.mocks.MockLog;
import org.eclipse.osee.orcs.db.mocks.MockSystemPreferences;
import org.junit.AfterClass;
@@ -47,11 +48,20 @@ import org.junit.Rule;
public class ArtifactLoaderTest {
@Rule
+ public OsgiRule osgi = new OsgiRule(this);
+
+ @Rule
public OseeDatabase db = new OseeDatabase("osee.demo.h2");
private static StaticSqlProvider sqlProvider;
private static Log log;
+ @OsgiService
+ IOseeDatabaseService oseeDbService;
+
+ @OsgiService
+ IdentityService identityService;
+
@BeforeClass
public static void setUp() {
log = new MockLog();
@@ -67,9 +77,6 @@ public class ArtifactLoaderTest {
@org.junit.Test
public void testArtifactLoadingData() throws OseeCoreException {
- IOseeDatabaseService oseeDbService = OsgiUtil.getService(IOseeDatabaseService.class);
- IdentityService identityService = OsgiUtil.getService(IdentityService.class);
-
OrcsObjectFactoryImpl factory = new OrcsObjectFactoryImpl(null, identityService);
ArtifactLoader loader = new ArtifactLoader(log, sqlProvider, oseeDbService, factory);
@@ -117,10 +124,6 @@ public class ArtifactLoaderTest {
@org.junit.Test
public void testDeletedArtifactLoadingData() throws OseeCoreException {
-
- IOseeDatabaseService oseeDbService = OsgiUtil.getService(IOseeDatabaseService.class);
- IdentityService identityService = OsgiUtil.getService(IdentityService.class);
-
OrcsObjectFactoryImpl factory = new OrcsObjectFactoryImpl(null, identityService);
ArtifactLoader loader = new ArtifactLoader(log, sqlProvider, oseeDbService, factory);
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/AttributeLoaderTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/AttributeLoaderTest.java
index 1fe0f3df908..090a2d6794f 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/AttributeLoaderTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/AttributeLoaderTest.java
@@ -31,7 +31,8 @@ import org.eclipse.osee.orcs.db.internal.loader.data.OrcsObjectFactoryImpl;
import org.eclipse.osee.orcs.db.internal.loader.data.VersionDataImpl;
import org.eclipse.osee.orcs.db.internal.sql.StaticSqlProvider;
import org.eclipse.osee.orcs.db.mock.OseeDatabase;
-import org.eclipse.osee.orcs.db.mock.OsgiUtil;
+import org.eclipse.osee.orcs.db.mock.OsgiRule;
+import org.eclipse.osee.orcs.db.mock.OsgiService;
import org.eclipse.osee.orcs.db.mocks.MockDataProxy;
import org.eclipse.osee.orcs.db.mocks.MockLog;
import org.eclipse.osee.orcs.db.mocks.MockSystemPreferences;
@@ -48,10 +49,19 @@ import org.junit.Rule;
public class AttributeLoaderTest {
@Rule
+ public OsgiRule osgi = new OsgiRule(this);
+
+ @Rule
public OseeDatabase db = new OseeDatabase("osee.demo.h2");
private static StaticSqlProvider sqlProvider;
+ @OsgiService
+ IOseeDatabaseService oseeDbService;
+
+ @OsgiService
+ IdentityService identityService;
+
@BeforeClass
public static void setUp() {
sqlProvider = new StaticSqlProvider();
@@ -66,9 +76,6 @@ public class AttributeLoaderTest {
@org.junit.Test
public void testAttributeLoadingData() throws OseeCoreException {
- IOseeDatabaseService oseeDbService = OsgiUtil.getService(IOseeDatabaseService.class);
- IdentityService identityService = OsgiUtil.getService(IdentityService.class);
-
final List<AttributeData> actuals = new ArrayList<AttributeData>();
ProxyDataFactory proxyFactory = new ProxyDataFactory() {
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/RelationLoaderTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/RelationLoaderTest.java
index 3cfd1bb9c02..5199aba04fd 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/RelationLoaderTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/RelationLoaderTest.java
@@ -23,15 +23,16 @@ import org.eclipse.osee.framework.database.core.ArtifactJoinQuery;
import org.eclipse.osee.framework.database.core.JoinUtility;
import org.eclipse.osee.framework.database.core.OseeConnection;
import org.eclipse.osee.orcs.core.ds.LoadOptions;
-import org.eclipse.osee.orcs.core.ds.VersionData;
import org.eclipse.osee.orcs.core.ds.RelationData;
import org.eclipse.osee.orcs.core.ds.RelationDataHandler;
+import org.eclipse.osee.orcs.core.ds.VersionData;
import org.eclipse.osee.orcs.db.internal.loader.data.OrcsObjectFactoryImpl;
import org.eclipse.osee.orcs.db.internal.loader.data.RelationDataImpl;
import org.eclipse.osee.orcs.db.internal.loader.data.VersionDataImpl;
import org.eclipse.osee.orcs.db.internal.sql.StaticSqlProvider;
import org.eclipse.osee.orcs.db.mock.OseeDatabase;
-import org.eclipse.osee.orcs.db.mock.OsgiUtil;
+import org.eclipse.osee.orcs.db.mock.OsgiRule;
+import org.eclipse.osee.orcs.db.mock.OsgiService;
import org.eclipse.osee.orcs.db.mocks.MockLog;
import org.eclipse.osee.orcs.db.mocks.MockSystemPreferences;
import org.junit.AfterClass;
@@ -47,10 +48,19 @@ import org.junit.Rule;
public class RelationLoaderTest {
@Rule
+ public OsgiRule osgi = new OsgiRule(this);
+
+ @Rule
public OseeDatabase db = new OseeDatabase("osee.demo.h2");
private static StaticSqlProvider sqlProvider;
+ @OsgiService
+ IOseeDatabaseService oseeDbService;
+
+ @OsgiService
+ IdentityService identityService;
+
@BeforeClass
public static void setUp() {
sqlProvider = new StaticSqlProvider();
@@ -65,10 +75,6 @@ public class RelationLoaderTest {
@org.junit.Test
public void testRelationLoadingData() throws OseeCoreException {
-
- IOseeDatabaseService oseeDbService = OsgiUtil.getService(IOseeDatabaseService.class);
- IdentityService identityService = OsgiUtil.getService(IdentityService.class);
-
OrcsObjectFactoryImpl factory = new OrcsObjectFactoryImpl(null, identityService);
RelationLoader relationLoader = new RelationLoader(new MockLog(), sqlProvider, oseeDbService, factory);
@@ -107,10 +113,6 @@ public class RelationLoaderTest {
@org.junit.Test
public void testNoRelationsFound() throws OseeCoreException {
-
- IOseeDatabaseService oseeDbService = OsgiUtil.getService(IOseeDatabaseService.class);
- IdentityService identityService = OsgiUtil.getService(IdentityService.class);
-
OrcsObjectFactoryImpl factory = new OrcsObjectFactoryImpl(null, identityService);
RelationLoader relationLoader = new RelationLoader(new MockLog(), sqlProvider, oseeDbService, factory);
@@ -138,9 +140,6 @@ public class RelationLoaderTest {
@org.junit.Test
public void testHistoricalLoad() throws OseeCoreException {
- IOseeDatabaseService oseeDbService = OsgiUtil.getService(IOseeDatabaseService.class);
- IdentityService identityService = OsgiUtil.getService(IdentityService.class);
-
OrcsObjectFactoryImpl factory = new OrcsObjectFactoryImpl(null, identityService);
RelationLoader relationLoader = new RelationLoader(new MockLog(), sqlProvider, oseeDbService, factory);
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/DaoToSqlTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/DaoToSqlTest.java
new file mode 100644
index 00000000000..9a167260f67
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/DaoToSqlTest.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.orcs.db.internal.transaction;
+
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.core.ds.DataProxy;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test Case for {@link DaoToSql}
+ *
+ * @author Roberto E. Escobar
+ */
+public class DaoToSqlTest {
+
+ @Mock
+ DataProxy proxy;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testGetGammaIdAndIsNewGammaId() {
+ boolean isNewGammaId = true;
+ long gammaId = 2345L;
+
+ DaoToSql dao1 = new DaoToSql(gammaId, proxy, isNewGammaId);
+ Assert.assertEquals(gammaId, dao1.getGammaId());
+ Assert.assertEquals(true, dao1.hasNewGammaId());
+
+ DaoToSql dao2 = new DaoToSql(1234L, proxy, false);
+ Assert.assertEquals(1234L, dao2.getGammaId());
+ Assert.assertEquals(false, dao2.hasNewGammaId());
+ }
+
+ @Test
+ public void testGetUriAndValue() throws OseeCoreException {
+ String value = "theValue";
+ String uri = "theUri";
+ Object[] data = new Object[] {value, uri};
+
+ Mockito.when(proxy.getData()).thenReturn(data);
+
+ DaoToSql dao = new DaoToSql(1234L, proxy, false);
+ Assert.assertEquals(uri, dao.getUri());
+ Assert.assertEquals(value, dao.getValue());
+ }
+
+ @Test
+ public void testValueAndUriNull() throws OseeCoreException {
+ String value = "theValue";
+ String uri = null;
+ Object[] data = new Object[] {value, uri};
+
+ Mockito.when(proxy.getData()).thenReturn(data);
+
+ DaoToSql dao = new DaoToSql(1234L, proxy, false);
+ Assert.assertEquals("", dao.getUri());
+ Assert.assertEquals(value, dao.getValue());
+ }
+
+ @Test
+ public void testUriAndValueNull() throws OseeCoreException {
+ String value = "theValue";
+ String uri = null;
+ Object[] data = new Object[] {value, uri};
+
+ Mockito.when(proxy.getData()).thenReturn(data);
+
+ DaoToSql dao = new DaoToSql(1234L, proxy, false);
+ Assert.assertEquals("", dao.getUri());
+ Assert.assertEquals(value, dao.getValue());
+ }
+
+ @Test
+ public void testPersist() throws OseeCoreException {
+ long gammaId = 2345L;
+ DaoToSql dao = new DaoToSql(gammaId, proxy, true);
+ dao.persist();
+ Mockito.verify(proxy).persist(gammaId);
+
+ Mockito.reset(proxy);
+
+ DaoToSql dao2 = new DaoToSql(gammaId, proxy, false);
+ dao2.persist();
+ Mockito.verifyZeroInteractions(proxy);
+ }
+
+ @Test
+ public void testPurge() throws OseeCoreException {
+ long gammaId = 2345L;
+ DaoToSql dao = new DaoToSql(gammaId, proxy, true);
+ dao.rollBack();
+ Mockito.verify(proxy).purge();
+
+ Mockito.reset(proxy);
+
+ DaoToSql dao2 = new DaoToSql(gammaId, proxy, false);
+ dao2.rollBack();
+ Mockito.verifyZeroInteractions(proxy);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/InsertVistorTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/InsertVistorTest.java
new file mode 100644
index 00000000000..3453b8fd6ab
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/InsertVistorTest.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.orcs.db.internal.transaction;
+
+import org.eclipse.osee.orcs.core.ds.VersionData;
+import org.eclipse.osee.orcs.db.internal.loader.IdFactory;
+import org.eclipse.osee.orcs.db.internal.loader.data.VersionDataImpl;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test Case for {@link TxSqlBuilder}
+ *
+ * @author Roberto E. Escobar
+ */
+public class InsertVistorTest {
+
+ @Mock
+ IdFactory idFactory;
+
+ private InsertVisitor visitor;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ // visitor = new InsertVisitor(idFactory);
+ }
+
+ @Test
+ public void testAcceptArtifact() {
+ VersionData vData = new VersionDataImpl();
+ // vData.setBranchId(branchId);
+ // vData.setGammaId(gamma);
+ // vData.setTransactionId(txId);
+ //
+ // ArtifactData data = new ArtifactDataImpl(vData);
+ // data.setGuid(guid);
+ // data.setHumanReadableId(humanReadableId);
+ // data.setLoadedModType(modType);
+ // data.setLocalId(localId);
+ // data.setModType(modType);
+ // data.setTypeUuid(typeUuid);
+ //
+ // visitor.accept(data);
+
+ }
+
+ @Test
+ public void testAcceptAttribute() {
+ // visitor.accept(data);
+ // visitor.accept(data);
+ // visitor.accept(data);
+ }
+
+ @Test
+ public void testAcceptRelation() {
+ // visitor.accept(data);
+ // visitor.accept(data);
+ // visitor.accept(data);
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/SqlProvider.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionTestSuite.java
index 8aa4df5343c..3bd868e6817 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/SqlProvider.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionTestSuite.java
@@ -10,11 +10,14 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.transaction;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.core.ds.OrcsData;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-public interface SqlProvider<T extends OrcsData> {
-
- void getInsertData(InsertDataCollector collector, T data) throws OseeCoreException;
-
-} \ No newline at end of file
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({DaoToSqlTest.class, TxSqlBuilderTest.class})
+public class TransactionTestSuite {
+ // Test Suite
+}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderTest.java
new file mode 100644
index 00000000000..d3439b83f0d
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderTest.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.orcs.db.internal.transaction;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData;
+import org.eclipse.osee.orcs.db.internal.loader.IdFactory;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test Case for {@link TxSqlBuilder}
+ *
+ * @author Roberto E. Escobar
+ */
+public class TxSqlBuilderTest {
+
+ @Mock
+ IdFactory idFactory;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testGetGammaIdAndIsNewGammaId() {
+ List<ArtifactTransactionData> txData = new ArrayList<ArtifactTransactionData>();
+ // TxSqlBuilder builder = new TxSqlBuilder(idFactory, txData);
+ // builder.build();
+
+ // builder.getBinaryTxs();
+ //
+ // builder.getObjectSql();
+ // builder.getObjectParameters();
+ //
+ // builder.getTxParameters(sqlKey);
+ // builder.getTxSql();
+
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.db/build.properties b/plugins/org.eclipse.osee.orcs.db/build.properties
index 84f5166f881..2d2fa010adc 100644
--- a/plugins/org.eclipse.osee.orcs.db/build.properties
+++ b/plugins/org.eclipse.osee.orcs.db/build.properties
@@ -2,9 +2,7 @@ output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
- schema/,\
- OSGI-INF/data.store.admin.xml,\
- OSGI-INF/branch.data.store.xml
+ schema/
source.. = src/
additional.bundles = org.eclipse.osee.framework.database,\
org.eclipse.osee.logger,\
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/OrcsDataStoreImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/OrcsDataStoreImpl.java
index e67279a511e..65299b85ea1 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/OrcsDataStoreImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/OrcsDataStoreImpl.java
@@ -30,7 +30,9 @@ import org.eclipse.osee.orcs.core.ds.QueryEngineIndexer;
import org.eclipse.osee.orcs.db.internal.branch.BranchDataStoreImpl;
import org.eclipse.osee.orcs.db.internal.loader.DataModuleFactory;
import org.eclipse.osee.orcs.db.internal.loader.DataProxyFactoryProvider;
+import org.eclipse.osee.orcs.db.internal.loader.IdFactory;
import org.eclipse.osee.orcs.db.internal.loader.OrcsObjectFactory;
+import org.eclipse.osee.orcs.db.internal.loader.data.IdFactoryImpl;
import org.eclipse.osee.orcs.db.internal.search.QueryModuleFactory;
import org.eclipse.osee.orcs.db.internal.search.tagger.TaggingEngine;
import org.eclipse.osee.orcs.db.internal.sql.StaticSqlProvider;
@@ -106,22 +108,22 @@ public class OrcsDataStoreImpl implements OrcsDataStore {
}
public void start() {
+ StaticSqlProvider sqlProvider = new StaticSqlProvider();
+ sqlProvider.setLogger(logger);
+ sqlProvider.setPreferences(preferences);
+
+ IdFactory idFactory = new IdFactoryImpl(dbService, cacheService.getBranchCache());
+
branchStore =
new BranchDataStoreImpl(logger, dbService, identityService, cacheService, preferences, executorAdmin,
- resourceManager, modelFactory, typeModelService);
+ resourceManager, modelFactory, typeModelService, sqlProvider, idFactory);
dataStoreAdmin = new DataStoreAdminImpl(logger, dbService, identityService, branchStore, preferences);
- StaticSqlProvider sqlProvider = new StaticSqlProvider();
- sqlProvider.setLogger(logger);
- sqlProvider.setPreferences(preferences);
-
DataModuleFactory dataModuleFactory = new DataModuleFactory(logger, dbService, identityService);
OrcsObjectFactory rowDataFactory =
dataModuleFactory.createOrcsObjectFactory(proxyProvider, cacheService.getAttributeTypeCache());
- dataFactory =
- dataModuleFactory.createDataFactory(rowDataFactory, cacheService.getBranchCache(),
- cacheService.getArtifactTypeCache());
+ dataFactory = dataModuleFactory.createDataFactory(rowDataFactory, idFactory, cacheService.getArtifactTypeCache());
dataLoader = dataModuleFactory.createDataLoader(sqlProvider, rowDataFactory);
QueryModuleFactory factory = new QueryModuleFactory(logger, dbService, identityService, executorAdmin);
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchDataStoreImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchDataStoreImpl.java
index 570fe91637b..5f1c74e5d16 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchDataStoreImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchDataStoreImpl.java
@@ -34,6 +34,7 @@ import org.eclipse.osee.orcs.core.ds.TransactionData;
import org.eclipse.osee.orcs.core.ds.TransactionResult;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.CreateBranchData;
+import org.eclipse.osee.orcs.db.internal.SqlProvider;
import org.eclipse.osee.orcs.db.internal.callable.BranchCopyTxCallable;
import org.eclipse.osee.orcs.db.internal.callable.CheckBranchExchangeIntegrityCallable;
import org.eclipse.osee.orcs.db.internal.callable.CommitBranchDatabaseCallable;
@@ -43,6 +44,8 @@ import org.eclipse.osee.orcs.db.internal.callable.ExportBranchDatabaseCallable;
import org.eclipse.osee.orcs.db.internal.callable.ImportBranchDatabaseCallable;
import org.eclipse.osee.orcs.db.internal.callable.PurgeBranchDatabaseCallable;
import org.eclipse.osee.orcs.db.internal.exchange.ExportItemFactory;
+import org.eclipse.osee.orcs.db.internal.loader.IdFactory;
+import org.eclipse.osee.orcs.db.internal.transaction.CommitTransactionDatabaseTxCallable;
/**
* @author Roberto E. Escobar
@@ -60,7 +63,10 @@ public class BranchDataStoreImpl implements BranchDataStore {
private final IOseeModelFactoryService modelFactory;
private final IOseeModelingService typeModelService;
- public BranchDataStoreImpl(Log logger, IOseeDatabaseService dbService, IdentityService identityService, IOseeCachingService cachingService, SystemPreferences preferences, ExecutorAdmin executorAdmin, IResourceManager resourceManager, IOseeModelFactoryService modelFactory, IOseeModelingService typeModelService) {
+ private final SqlProvider sqlProvider;
+ private final IdFactory idFactory;
+
+ public BranchDataStoreImpl(Log logger, IOseeDatabaseService dbService, IdentityService identityService, IOseeCachingService cachingService, SystemPreferences preferences, ExecutorAdmin executorAdmin, IResourceManager resourceManager, IOseeModelFactoryService modelFactory, IOseeModelingService typeModelService, SqlProvider sqlProvider, IdFactory idFactory) {
super();
this.logger = logger;
this.dbService = dbService;
@@ -71,6 +77,8 @@ public class BranchDataStoreImpl implements BranchDataStore {
this.resourceManager = resourceManager;
this.modelFactory = modelFactory;
this.typeModelService = typeModelService;
+ this.sqlProvider = sqlProvider;
+ this.idFactory = idFactory;
}
@Override
@@ -132,16 +140,10 @@ public class BranchDataStoreImpl implements BranchDataStore {
}
@Override
- public Callable<TransactionResult> commitTransaction(TransactionData transaction) {
- /////
- // TODO:
- // 1. Make this whole method a critical region on a per branch basis - can only write to a branch on one thread at time
- // 2. This is where we will eventually check that the gammaIds have not changed from under us for: attributes, artifacts and relations
- // 3. Don't burn transaction ID until now
- // 4.
- // delete new DeleteRelationDatabaseCallable(logger, dbService, identityService, cachingService.getBranchCache(), branch, relationType, aArtId, bArtId, artUserId, comment);
- ////
- return null;
+ public Callable<TransactionResult> commitTransaction(TransactionData data) {
+ return new CommitTransactionDatabaseTxCallable(logger, dbService, identityService, sqlProvider, idFactory,
+ cachingService.getBranchCache(), cachingService.getTransactionCache(), modelFactory.getTransactionFactory(),
+ data);
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/AttributeDataProxyFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/AttributeDataProxyFactory.java
index afcdf6fdc15..996ec547309 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/AttributeDataProxyFactory.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/AttributeDataProxyFactory.java
@@ -35,7 +35,7 @@ public class AttributeDataProxyFactory implements ProxyDataFactory {
@Override
public DataProxy createProxy(long typeUuid, String value, String uri) throws OseeCoreException {
- return createProxy(typeUuid, value, uri);
+ return createProxy(typeUuid, (Object) value, (Object) uri);
}
private boolean isEnumOrBoolean(AttributeType attributeType) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataModuleFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataModuleFactory.java
index 91b2009530b..75268658b15 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataModuleFactory.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataModuleFactory.java
@@ -12,14 +12,12 @@ package org.eclipse.osee.orcs.db.internal.loader;
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.services.IdentityService;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.core.ds.DataFactory;
import org.eclipse.osee.orcs.core.ds.DataLoader;
import org.eclipse.osee.orcs.db.internal.SqlProvider;
-import org.eclipse.osee.orcs.db.internal.loader.data.IdFactoryImpl;
import org.eclipse.osee.orcs.db.internal.loader.data.OrcsObjectFactoryImpl;
/**
@@ -43,8 +41,7 @@ public class DataModuleFactory {
return new OrcsObjectFactoryImpl(dataProxyFactory, identityService);
}
- public DataFactory createDataFactory(OrcsObjectFactory factory, BranchCache branchCache, ArtifactTypeCache artifactTypeCache) {
- IdFactory idFactory = new IdFactoryImpl(dbService, branchCache);
+ public DataFactory createDataFactory(OrcsObjectFactory factory, IdFactory idFactory, ArtifactTypeCache artifactTypeCache) {
return new DataFactoryImpl(idFactory, factory, artifactTypeCache);
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/IdFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/IdFactory.java
index d062b6a7381..78f7b35eb95 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/IdFactory.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/IdFactory.java
@@ -12,7 +12,6 @@ package org.eclipse.osee.orcs.db.internal.loader;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.core.ds.OrcsData;
/**
* @author Roberto E. Escobar
@@ -31,6 +30,6 @@ public interface IdFactory {
String getUniqueHumanReadableId(String humanReadableId) throws OseeCoreException;
- long getNextGammaId(OrcsData data) throws OseeCoreException;
+ long getNextGammaId() throws OseeCoreException;
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/RelationalConstants.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/RelationalConstants.java
index 55639593ace..1649b322bcc 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/RelationalConstants.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/RelationalConstants.java
@@ -32,7 +32,7 @@ public final class RelationalConstants {
public static final int DEFAULT_ITEM_ID = -1;
public static final long DEFAULT_TYPE_UUID = -1L;
- public static final ModificationType DEFAULT_MODIFICATION_TYPE = null;
+ public static final ModificationType DEFAULT_MODIFICATION_TYPE = ModificationType.NEW;
public static final String DEFAULT_GUID = null;
public static final String HUMAN_READABLE_ID = null;
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/IdFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/IdFactoryImpl.java
index 70a1f97120d..998a4133381 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/IdFactoryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/IdFactoryImpl.java
@@ -18,9 +18,7 @@ import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.database.core.IOseeSequence;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.framework.jdk.core.util.HumanReadableId;
-import org.eclipse.osee.orcs.core.ds.OrcsData;
import org.eclipse.osee.orcs.db.internal.loader.IdFactory;
-import org.eclipse.osee.orcs.db.internal.loader.RelationalConstants;
/**
* @author Roberto E. Escobar
@@ -61,6 +59,11 @@ public class IdFactoryImpl implements IdFactory {
}
@Override
+ public long getNextGammaId() throws OseeCoreException {
+ return getSequence().getNextGammaId();
+ }
+
+ @Override
public String getUniqueGuid(String guid) {
String toReturn = guid;
if (toReturn == null) {
@@ -85,18 +88,4 @@ public class IdFactoryImpl implements IdFactory {
return dbService.runPreparedQueryFetchObject(0L, DUPLICATE_HRID_SEARCH, id) <= 0;
}
- @Override
- public long getNextGammaId(OrcsData data) throws OseeCoreException {
- long toReturn = data.getVersion().getGammaId();
- if (RelationalConstants.GAMMA_SENTINEL == toReturn || isGammaCreationAllowed(data)) {
- toReturn = getSequence().getNextGammaId();
- } else {
- toReturn = data.getVersion().getGammaId();
- }
- return toReturn;
- }
-
- protected boolean isGammaCreationAllowed(OrcsData data) {
- return !data.getModType().isExistingVersionUsed();
- }
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectImpl.java
index bfb72e05203..5cb90c75142 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectImpl.java
@@ -78,6 +78,15 @@ public abstract class OrcsObjectImpl implements OrcsData {
}
@Override
+ public boolean isStorageAllowed() {
+ boolean persist = true;
+ if (getModType().isDeleted() && !getVersion().isInStorage()) {
+ persist = false;
+ }
+ return persist;
+ }
+
+ @Override
public int hashCode() {
final int prime = 31;
int result = 1;
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/ArtifactSqlProvider.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/ArtifactSqlProvider.java
deleted file mode 100644
index 5fb9fd89d65..00000000000
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/ArtifactSqlProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.orcs.db.internal.transaction;
-
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.core.ds.ArtifactData;
-import org.eclipse.osee.orcs.db.internal.loader.IdFactory;
-import org.eclipse.osee.orcs.db.internal.sql.OseeSql;
-
-public class ArtifactSqlProvider extends AbstractSqlProvider implements SqlProvider<ArtifactData> {
-
- private static final String INSERT_ARTIFACT =
- "INSERT INTO osee_artifact (gamma_id, art_id, art_type_id, guid, human_readable_id) VALUES (?,?,?,?,?)";
-
- public ArtifactSqlProvider(IdFactory idFactory) {
- super(idFactory);
- }
-
- @Override
- public void getInsertData(InsertDataCollector collector, ArtifactData data) throws OseeCoreException {
- collector.addInsertToBatch(1, INSERT_ARTIFACT, getGammaId(data), data.getLocalId(), data.getTypeUuid(),
- data.getGuid(), data.getHumanReadableId());
- collector.addTxNotCurrentToBatch(OseeSql.TX_GET_PREVIOUS_TX_NOT_CURRENT_ARTIFACTS, data.getLocalId(),
- data.getModType());
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/AttributeSqlProvider.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/AttributeSqlProvider.java
deleted file mode 100644
index 6e28b390fcb..00000000000
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/AttributeSqlProvider.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.orcs.db.internal.transaction;
-
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.core.ds.AttributeData;
-import org.eclipse.osee.orcs.core.ds.DataProxy;
-import org.eclipse.osee.orcs.db.internal.loader.IdFactory;
-import org.eclipse.osee.orcs.db.internal.sql.OseeSql;
-
-public class AttributeSqlProvider extends AbstractSqlProvider implements SqlProvider<AttributeData> {
-
- private static final String INSERT_ATTRIBUTE =
- "INSERT INTO osee_attribute (art_id, attr_id, attr_type_id, value, gamma_id, uri) VALUES (?, ?, ?, ?, ?, ?)";
-
- private final DAOToSQL daoToSql = new DAOToSQL();
-
- public AttributeSqlProvider(IdFactory idFactory) {
- super(idFactory);
- }
-
- @Override
- public void getInsertData(InsertDataCollector collector, AttributeData data) throws OseeCoreException {
- long gammaId = getGammaId(data);
- DataProxy dataProxy = data.getDataProxy();
-
- collector.addBinaryStore(new BinaryStoreTx(gammaId, dataProxy));
- daoToSql.setData(dataProxy.getData());
-
- collector.addInsertToBatch(3, INSERT_ATTRIBUTE, data.getArtifactId(), data.getLocalId(), data.getTypeUuid(),
- daoToSql.getValue(), gammaId, daoToSql.getUri());
-
- collector.addTxNotCurrentToBatch(OseeSql.TX_GET_PREVIOUS_TX_NOT_CURRENT_ATTRIBUTES, data.getLocalId(),
- data.getModType());
- }
-
- private static final class DAOToSQL {
- private String uri;
- private String value;
-
- public DAOToSQL(Object... data) {
- if (data != null) {
- setData(data);
- } else {
- uri = null;
- value = null;
- }
- }
-
- public void setData(Object... data) {
- this.uri = getItemAt(1, data);
- this.value = getItemAt(0, data);
- }
-
- private String getItemAt(int index, Object... data) {
- String toReturn = null;
- if (data != null && data.length > index) {
- Object obj = data[index];
- if (obj != null) {
- toReturn = obj.toString();
- }
- }
- return toReturn;
- }
-
- public String getUri() {
- return uri != null ? uri : "";
- }
-
- public String getValue() {
- return value != null ? value : "";
- }
- }
-
-}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/BinaryStoreTx.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/BinaryStoreTx.java
deleted file mode 100644
index 1d91dd68fa4..00000000000
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/BinaryStoreTx.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.eclipse.osee.orcs.db.internal.transaction;
-
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.core.ds.DataProxy;
-
-public class BinaryStoreTx {
- private final long gammaId;
- private final DataProxy proxy;
-
- public BinaryStoreTx(long gammaId, DataProxy proxy) {
- super();
- this.gammaId = gammaId;
- this.proxy = proxy;
- }
-
- public long getGammaId() {
- return gammaId;
- }
-
- public DataProxy getProxy() {
- return proxy;
- }
-
- public void persist() throws OseeCoreException {
- proxy.persist(gammaId);
- }
-
- public void rollBack() throws OseeCoreException {
- //TX_TODO
- // @Override
- // protected void internalOnRollBack() throws OseeCoreException {
- // if (!useExistingBackingData() && Strings.isValid(daoToSql.getUri())) {
- // try {
- // HttpProcessor.delete(AttributeURL.getDeleteURL(daoToSql.getUri()));
- // } catch (Exception ex) {
- // OseeExceptions.wrapAndThrow(ex);
- // }
- // }
- // }
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitTransactionDatabaseTxCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/CommitTransactionDatabaseTxCallable.java
index 4fd793aaf53..6d31208ebeb 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitTransactionDatabaseTxCallable.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/CommitTransactionDatabaseTxCallable.java
@@ -8,14 +8,14 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.db.internal.callable;
+package org.eclipse.osee.orcs.db.internal.transaction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import org.eclipse.osee.database.schema.DatabaseTxCallable;
-import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.data.ITransaction;
import org.eclipse.osee.framework.core.enums.BranchState;
import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
import org.eclipse.osee.framework.core.enums.TxChange;
@@ -25,6 +25,7 @@ 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.TransactionCache;
+import org.eclipse.osee.framework.core.services.IdentityService;
import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.database.core.IOseeStatement;
@@ -33,21 +34,18 @@ import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData;
import org.eclipse.osee.orcs.core.ds.TransactionData;
+import org.eclipse.osee.orcs.core.ds.TransactionResult;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.db.internal.SqlProvider;
+import org.eclipse.osee.orcs.db.internal.loader.IdFactory;
import org.eclipse.osee.orcs.db.internal.sql.OseeSql;
-import org.eclipse.osee.orcs.db.internal.transaction.BinaryStoreTx;
-import org.eclipse.osee.orcs.db.internal.transaction.TxSqlBuilder;
/**
* @author Roberto E. Escobar
* @author Ryan D. Brooks
* @author Jeff C. Phillips
*/
-public final class CommitTransactionDatabaseTxCallable extends DatabaseTxCallable<TransactionRecord> {
-
- private static final String INSERT_INTO_TRANSACTION_TABLE =
- "INSERT INTO osee_txs (transaction_id, gamma_id, mod_type, tx_current, branch_id) VALUES (?, ?, ?, ?, ?)";
+public final class CommitTransactionDatabaseTxCallable extends DatabaseTxCallable<TransactionResult> {
private static final String INSERT_INTO_TRANSACTION_DETAIL =
"INSERT INTO osee_tx_details (transaction_id, osee_comment, time, author, branch_id, tx_type) VALUES (?, ?, ?, ?, ?, ?)";
@@ -55,25 +53,43 @@ public final class CommitTransactionDatabaseTxCallable extends DatabaseTxCallabl
private static final String UPDATE_TXS_NOT_CURRENT =
"UPDATE osee_txs SET tx_current = " + TxChange.NOT_CURRENT.getValue() + " WHERE branch_id = ? AND transaction_id = ? AND gamma_id = ?";
+ private final SqlProvider sqlProvider;
+ private final IdFactory idFactory;
+ private final IdentityService identityService;
private final BranchCache branchCache;
- private final TransactionRecordFactory factory = null;
- private final TransactionCache transactionCache = null;
- private SqlProvider sqlProvider;
-
+ private final TransactionRecordFactory factory;
+ private final TransactionCache transactionCache;
private final TransactionData transactionData;
- private List<BinaryStoreTx> binaryStores;
- public CommitTransactionDatabaseTxCallable(Log logger, IOseeDatabaseService dbService, BranchCache branchCache, IOseeBranch branch, TransactionData transactionData) {
+ private List<DaoToSql> binaryStores;
+
+ public CommitTransactionDatabaseTxCallable(Log logger, IOseeDatabaseService dbService, IdentityService identityService, SqlProvider sqlProvider, IdFactory idFactory, BranchCache branchCache, TransactionCache transactionCache, TransactionRecordFactory factory, TransactionData transactionData) {
super(logger, dbService, String.format("Committing Transaction: [%s] for branch [%s]",
transactionData.getComment(), transactionData.getBranch()));
+ this.sqlProvider = sqlProvider;
+ this.idFactory = idFactory;
+ this.identityService = identityService;
this.branchCache = branchCache;
+ this.factory = factory;
+ this.transactionCache = transactionCache;
this.transactionData = transactionData;
}
- @Override
- protected TransactionRecord handleTxWork(OseeConnection connection) throws OseeCoreException {
- Collection<ArtifactTransactionData> txData = transactionData.getArtifactTransactionData();
+ private void checkPreconditions(Collection<ArtifactTransactionData> txData) throws OseeCoreException {
Conditions.checkNotNullOrEmpty(txData, "artifacts modified");
+ }
+
+ @Override
+ protected TransactionResult handleTxWork(OseeConnection connection) throws OseeCoreException {
+ /////
+ // TODO:
+ // 1. Make this whole method a critical region on a per branch basis - can only write to a branch on one thread at time
+ // 2. This is where we will eventually check that the gammaIds have not changed from under us for: attributes, artifacts and relations
+ // 3. Don't burn transaction ID until now
+ // 4.
+ ////
+ List<ArtifactTransactionData> txData = transactionData.getArtifactTransactionData();
+ checkPreconditions(txData);
Branch branch = branchCache.get(transactionData.getBranch());
TransactionRecord txRecord =
@@ -88,28 +104,27 @@ public final class CommitTransactionDatabaseTxCallable extends DatabaseTxCallabl
branch.setBranchState(BranchState.MODIFIED);
branchCache.storeItems(branch);
}
- return txRecord;
+ return new TransactionResultImpl(txRecord, txData);
}
@Override
protected void handleTxException(Exception ex) {
super.handleTxException(ex);
- for (BinaryStoreTx tx : binaryStores) {
+ for (DaoToSql tx : binaryStores) {
try {
tx.rollBack();
} catch (OseeCoreException ex1) {
- //TX_TODO
- getLogger().error(ex1, "Error during rollback");
+ getLogger().error(ex1, "Error during binary rollback [%s]", tx);
}
}
}
private void executeTransactionDataItems(Collection<ArtifactTransactionData> txData, OseeConnection connection, Branch branch) throws OseeCoreException {
- TxSqlBuilder builder = new TxSqlBuilder(txData);
+ TxSqlBuilder builder = new TxSqlBuilder(idFactory, identityService, txData);
builder.build();
binaryStores = builder.getBinaryTxs();
- for (BinaryStoreTx tx : binaryStores) {
+ for (DaoToSql tx : binaryStores) {
tx.persist();
}
@@ -119,12 +134,6 @@ public final class CommitTransactionDatabaseTxCallable extends DatabaseTxCallabl
fetchTxNotCurrent(connection, branch, txNotCurrentData, sql, params);
}
}
- // // Collect inserts for attribute, relation, artifact, and artifact version tables
- // transactionData.addInsertToBatch(this);
- //
- // // Collect stale tx currents for batch update
- // fetchTxNotCurrent(connection, branch, transactionData, txNotCurrentData);
- // }
// Insert into data tables - i.e. attribute, relation and artifact version tables
for (String sql : builder.getObjectSql()) {
@@ -135,15 +144,6 @@ public final class CommitTransactionDatabaseTxCallable extends DatabaseTxCallabl
getDatabaseService().runBatchUpdate(connection, UPDATE_TXS_NOT_CURRENT, txNotCurrentData);
}
- // private void x(int transactionNumber, int branchId) {
- // long gammaId = getGammaId();
- // ModificationType modTypeToStore = getAdjustedModificationType();
- // TxChange txChange = TxChange.getCurrent(modTypeToStore);
- //
- // internalAddInsertToBatch(collector, Integer.MAX_VALUE, INSERT_INTO_TRANSACTION_TABLE, transactionNumber, gammaId,
- // modTypeToStore.getValue(), txChange.getValue(), branchId);
- // }
-
@SuppressWarnings("unchecked")
private void persistTx(OseeConnection connection, TransactionRecord transactionRecord) throws OseeCoreException {
getDatabaseService().runPreparedUpdate(connection, INSERT_INTO_TRANSACTION_DETAIL, transactionRecord.getId(),
@@ -169,7 +169,6 @@ public final class CommitTransactionDatabaseTxCallable extends DatabaseTxCallabl
IOseeStatement chStmt = getDatabaseService().getStatement(connection);
try {
String query = sqlProvider.getSql(sql);
-
chStmt.runPreparedQuery(query, params);
while (chStmt.next()) {
results.add(new Object[] {branch.getId(), chStmt.getInt("transaction_id"), chStmt.getLong("gamma_id")});
@@ -179,6 +178,28 @@ public final class CommitTransactionDatabaseTxCallable extends DatabaseTxCallabl
}
}
+ private final class TransactionResultImpl implements TransactionResult {
+
+ private final ITransaction tx;
+ private final List<ArtifactTransactionData> data;
+
+ public TransactionResultImpl(ITransaction tx, List<ArtifactTransactionData> data) {
+ super();
+ this.tx = tx;
+ this.data = data;
+ }
+
+ @Override
+ public ITransaction getTransaction() {
+ return tx;
+ }
+
+ @Override
+ public List<ArtifactTransactionData> getData() {
+ return data;
+ }
+
+ }
// private void updateModifiedCachedObject() throws OseeCoreException {
// ArtifactEvent artifactEvent = new ArtifactEvent(transactionRecord.getBranch());
// artifactEvent.setTransactionId(getTransactionNumber());
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/DaoToSql.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/DaoToSql.java
new file mode 100644
index 00000000000..7cd04a4f42c
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/DaoToSql.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.orcs.db.internal.transaction;
+
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.core.ds.DataProxy;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class DaoToSql {
+ private final long gammaId;
+ private final DataProxy proxy;
+ private final boolean isNewGammaId;
+
+ public DaoToSql(long gammaId, DataProxy proxy, boolean isNewGammaId) {
+ super();
+ this.gammaId = gammaId;
+ this.proxy = proxy;
+ this.isNewGammaId = isNewGammaId;
+ }
+
+ public boolean hasNewGammaId() {
+ return isNewGammaId;
+ }
+
+ public long getGammaId() {
+ return gammaId;
+ }
+
+ private DataProxy getProxy() {
+ return proxy;
+ }
+
+ public String getUri() throws OseeCoreException {
+ String uri = getItemAt(1, getProxy().getData());
+ return uri != null ? uri : "";
+ }
+
+ public String getValue() throws OseeCoreException {
+ String value = getItemAt(0, getProxy().getData());
+ return value != null ? value : "";
+ }
+
+ public void persist() throws OseeCoreException {
+ if (isNewGammaId) {
+ proxy.persist(gammaId);
+ }
+ }
+
+ public void rollBack() throws OseeCoreException {
+ if (isNewGammaId) {
+ getProxy().purge();
+ }
+ }
+
+ private String getItemAt(int index, Object... data) {
+ String toReturn = null;
+ if (data != null && data.length > index) {
+ Object obj = data[index];
+ if (obj != null) {
+ toReturn = obj.toString();
+ }
+ }
+ return toReturn;
+ }
+
+ @Override
+ public String toString() {
+ return "DAOToSQL [gammaId=" + gammaId + ", isNewGammaId=" + isNewGammaId + ", proxy=" + proxy + "]";
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/InsertVisitor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/InsertVisitor.java
new file mode 100644
index 00000000000..155ba70d278
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/InsertVisitor.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.orcs.db.internal.transaction;
+
+import java.util.List;
+import java.util.Map;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.services.IdentityService;
+import org.eclipse.osee.framework.jdk.core.type.HashCollection;
+import org.eclipse.osee.orcs.core.ds.ArtifactData;
+import org.eclipse.osee.orcs.core.ds.AttributeData;
+import org.eclipse.osee.orcs.core.ds.DataProxy;
+import org.eclipse.osee.orcs.core.ds.OrcsData;
+import org.eclipse.osee.orcs.core.ds.OrcsVisitor;
+import org.eclipse.osee.orcs.core.ds.RelationData;
+import org.eclipse.osee.orcs.db.internal.loader.IdFactory;
+import org.eclipse.osee.orcs.db.internal.loader.RelationalConstants;
+import org.eclipse.osee.orcs.db.internal.sql.OseeSql;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class InsertVisitor implements OrcsVisitor {
+
+ private static final String INSERT_ARTIFACT =
+ "INSERT INTO osee_artifact (gamma_id, art_id, art_type_id, guid, human_readable_id) VALUES (?,?,?,?,?)";
+
+ private static final String INSERT_ATTRIBUTE =
+ "INSERT INTO osee_attribute (art_id, attr_id, attr_type_id, value, gamma_id, uri) VALUES (?, ?, ?, ?, ?, ?)";
+
+ private static final String INSERT_RELATION_TABLE =
+ "INSERT INTO osee_relation_link (rel_link_id, rel_link_type_id, a_art_id, b_art_id, rationale, gamma_id) VALUES (?,?,?,?,?,?)";
+
+ private final IdFactory idFactory;
+ private final IdentityService identityService;
+
+ private final HashCollection<String, Object[]> dataItemInserts;
+ private final HashCollection<OseeSql, Object[]> txNotCurrents;
+ private final List<DaoToSql> binaryStores;
+
+ private final Map<Integer, String> dataInsertOrder;
+
+ public InsertVisitor(IdFactory idFactory, IdentityService identityService, HashCollection<String, Object[]> dataItemInserts, HashCollection<OseeSql, Object[]> txNotCurrents, List<DaoToSql> binaryStores, Map<Integer, String> dataInsertOrder) {
+ super();
+ this.idFactory = idFactory;
+ this.identityService = identityService;
+ this.dataItemInserts = dataItemInserts;
+ this.txNotCurrents = txNotCurrents;
+ this.binaryStores = binaryStores;
+ this.dataInsertOrder = dataInsertOrder;
+ }
+
+ private int getLocalTypeId(long typeUuidId) throws OseeCoreException {
+ return identityService.getLocalId(typeUuidId);
+ }
+
+ @Override
+ public void visit(ArtifactData data) throws OseeCoreException {
+ if (data.isStorageAllowed()) {
+ int localTypeId = getLocalTypeId(data.getTypeUuid());
+ addInsertToBatch(1, INSERT_ARTIFACT, getGammaId(data), data.getLocalId(), localTypeId, data.getGuid(),
+ data.getHumanReadableId());
+ addTxNotCurrentToBatch(OseeSql.TX_GET_PREVIOUS_TX_NOT_CURRENT_ARTIFACTS, data.getLocalId(), data.getModType());
+ }
+ }
+
+ @Override
+ public void visit(AttributeData data) throws OseeCoreException {
+ if (data.isStorageAllowed()) {
+ long gammaId = getGammaId(data);
+ int localTypeId = getLocalTypeId(data.getTypeUuid());
+ DataProxy dataProxy = data.getDataProxy();
+
+ DaoToSql daoToSql = new DaoToSql(gammaId, dataProxy, !useExistingBackingData(data));
+ addBinaryStore(daoToSql);
+ addInsertToBatch(2, INSERT_ATTRIBUTE, data.getArtifactId(), data.getLocalId(), localTypeId,
+ daoToSql.getValue(), gammaId, daoToSql.getUri());
+
+ addTxNotCurrentToBatch(OseeSql.TX_GET_PREVIOUS_TX_NOT_CURRENT_ATTRIBUTES, data.getLocalId(), data.getModType());
+ }
+ }
+
+ @Override
+ public void visit(RelationData data) throws OseeCoreException {
+ if (data.isStorageAllowed()) {
+ int localTypeId = getLocalTypeId(data.getTypeUuid());
+ addInsertToBatch(3, INSERT_RELATION_TABLE, data.getLocalId(), localTypeId, data.getArtIdA(), data.getArtIdB(),
+ data.getRationale(), getGammaId(data));
+
+ addTxNotCurrentToBatch(OseeSql.TX_GET_PREVIOUS_TX_NOT_CURRENT_RELATIONS, data.getLocalId(), data.getModType());
+ }
+ }
+
+ private long getGammaId(OrcsData data) throws OseeCoreException {
+ long toReturn = data.getVersion().getGammaId();
+ if (RelationalConstants.GAMMA_SENTINEL == toReturn || isGammaCreationAllowed(data)) {
+ toReturn = idFactory.getNextGammaId();
+ } else {
+ toReturn = data.getVersion().getGammaId();
+ }
+ return toReturn;
+ }
+
+ protected boolean isGammaCreationAllowed(OrcsData data) {
+ return !useExistingBackingData(data);
+ }
+
+ private boolean useExistingBackingData(OrcsData data) {
+ return data.getModType().isExistingVersionUsed();
+ }
+
+ private void addInsertToBatch(int insertPriority, String insertSql, Object... data) {
+ dataItemInserts.put(insertSql, data);
+ dataInsertOrder.put(insertPriority, insertSql);
+ }
+
+ private void addTxNotCurrentToBatch(OseeSql insertSql, Object... data) {
+ txNotCurrents.put(insertSql, data);
+ }
+
+ private void addBinaryStore(DaoToSql binaryTx) {
+ binaryStores.add(binaryTx);
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/RelationSqlProvider.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/RelationSqlProvider.java
deleted file mode 100644
index 3aa91095dd0..00000000000
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/RelationSqlProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.orcs.db.internal.transaction;
-
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.core.ds.RelationData;
-import org.eclipse.osee.orcs.db.internal.loader.IdFactory;
-import org.eclipse.osee.orcs.db.internal.sql.OseeSql;
-
-public class RelationSqlProvider extends AbstractSqlProvider implements SqlProvider<RelationData> {
-
- private static final String INSERT_INTO_RELATION_TABLE =
- "INSERT INTO osee_relation_link (rel_link_id, rel_link_type_id, a_art_id, b_art_id, rationale, gamma_id) VALUES (?,?,?,?,?,?)";
-
- public RelationSqlProvider(IdFactory idFactory) {
- super(idFactory);
- }
-
- @Override
- public void getInsertData(InsertDataCollector collector, RelationData data) throws OseeCoreException {
- collector.addInsertToBatch(4, INSERT_INTO_RELATION_TABLE, data.getLocalId(), data.getTypeUuid(),
- data.getArtIdA(), data.getArtIdB(), data.getRationale(), getGammaId(data));
- collector.addTxNotCurrentToBatch(OseeSql.TX_GET_PREVIOUS_TX_NOT_CURRENT_RELATIONS, data.getLocalId(),
- data.getModType());
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilder.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilder.java
index fe7843f60bb..82ac875155d 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilder.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilder.java
@@ -17,28 +17,31 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.services.IdentityService;
import org.eclipse.osee.framework.jdk.core.type.HashCollection;
-import org.eclipse.osee.orcs.core.ds.ArtifactData;
import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData;
-import org.eclipse.osee.orcs.core.ds.AttributeData;
-import org.eclipse.osee.orcs.core.ds.OrcsData;
-import org.eclipse.osee.orcs.core.ds.RelationData;
+import org.eclipse.osee.orcs.db.internal.loader.IdFactory;
import org.eclipse.osee.orcs.db.internal.sql.OseeSql;
+/**
+ * @author Roberto E. Escobar
+ */
public class TxSqlBuilder {
+
private final HashCollection<String, Object[]> dataItemInserts = new HashCollection<String, Object[]>();
private final HashCollection<OseeSql, Object[]> txNotCurrents = new HashCollection<OseeSql, Object[]>();
- private final List<BinaryStoreTx> binaryStores = new ArrayList<BinaryStoreTx>();
+ private final List<DaoToSql> binaryStores = new ArrayList<DaoToSql>();
private List<String> orderedSql;
+ private final Map<Integer, String> dataInsertOrder = new HashMap<Integer, String>();
- private SqlProvider<ArtifactData> artifactDataProvider;
- private SqlProvider<AttributeData> attributeDataProvider;
- private SqlProvider<RelationData> relationDataProvider;
-
+ private final IdFactory idFactory;
+ private final IdentityService identityService;
private final Collection<ArtifactTransactionData> artifactTransactionData;
- public TxSqlBuilder(Collection<ArtifactTransactionData> artifactTransactionData) {
+ public TxSqlBuilder(IdFactory idFactory, IdentityService identityService, Collection<ArtifactTransactionData> artifactTransactionData) {
super();
+ this.idFactory = idFactory;
+ this.identityService = identityService;
this.artifactTransactionData = artifactTransactionData;
}
@@ -58,66 +61,26 @@ public class TxSqlBuilder {
return (List<Object[]>) txNotCurrents.getValues(sqlKey);
}
- public List<BinaryStoreTx> getBinaryTxs() {
+ public List<DaoToSql> getBinaryTxs() {
return binaryStores;
}
public void build() throws OseeCoreException {
- DataCollector collector = new DataCollector();
+ InsertVisitor visitor =
+ new InsertVisitor(idFactory, identityService, dataItemInserts, txNotCurrents, binaryStores, dataInsertOrder);
for (ArtifactTransactionData txData : artifactTransactionData) {
- if (isStorageAllowed(txData.getArtifactData())) {
- artifactDataProvider.getInsertData(collector, txData.getArtifactData());
- for (AttributeData attributeData : txData.getAttributeData()) {
- attributeDataProvider.getInsertData(collector, attributeData);
- }
- for (RelationData relationData : txData.getRelationData()) {
- relationDataProvider.getInsertData(collector, relationData);
- }
- }
+ txData.accept(visitor);
}
- orderedSql = collector.getOrderedSql();
+ orderedSql = getOrderedSql();
}
- private boolean isStorageAllowed(ArtifactData data) {
- boolean persist = true;
- if (data.getModType().isDeleted() && !data.getVersion().isInStorage()) {
- persist = false;
+ private List<String> getOrderedSql() {
+ List<String> orderedSql = new ArrayList<String>(dataInsertOrder.size());
+ List<Integer> keys = new ArrayList<Integer>(dataInsertOrder.keySet());
+ Collections.sort(keys);
+ for (int priority : keys) {
+ orderedSql.add(dataInsertOrder.get(priority));
}
- return persist;
- }
-
- protected boolean useExistingBackingData(OrcsData data) {
- return data.getModType().isExistingVersionUsed();
+ return orderedSql;
}
-
- private final class DataCollector implements InsertDataCollector {
- private final Map<Integer, String> dataInsertOrder = new HashMap<Integer, String>();
-
- public List<String> getOrderedSql() {
- List<String> orderedSql = new ArrayList<String>(dataInsertOrder.size());
- List<Integer> keys = new ArrayList<Integer>(dataInsertOrder.keySet());
- Collections.sort(keys);
- for (int priority : keys) {
- orderedSql.add(dataInsertOrder.get(priority));
- }
- return orderedSql;
- }
-
- @Override
- public void addInsertToBatch(int insertPriority, String insertSql, Object... data) {
- dataItemInserts.put(insertSql, data);
- dataInsertOrder.put(insertPriority, insertSql);
- }
-
- @Override
- public void addTxNotCurrentToBatch(OseeSql insertSql, Object... data) {
- txNotCurrents.put(insertSql, data);
- }
-
- @Override
- public void addBinaryStore(BinaryStoreTx binaryTx) {
- binaryStores.add(binaryTx);
- }
- }
-
}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchResource.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchResource.java
index 9d7e876372b..971c815a947 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchResource.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchResource.java
@@ -46,6 +46,11 @@ public class BranchResource {
return new ArtifactsResource(uriInfo, request, branchUuid);
}
+ @Path("txs")
+ public TxsResource getTransactions() {
+ return new TxsResource(uriInfo, request, branchUuid);
+ }
+
@GET
@Produces(MediaType.TEXT_HTML)
public String getAsHtml() throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/HtmlWriter.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/HtmlWriter.java
index 37dc245e454..f8fd1e02739 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/HtmlWriter.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/HtmlWriter.java
@@ -20,6 +20,7 @@ import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
import org.eclipse.osee.orcs.data.GraphReadable;
@@ -45,6 +46,9 @@ public class HtmlWriter {
} else if (object instanceof ArtifactReadable) {
ArtifactReadable artifact = (ArtifactReadable) object;
addTable(builder, toData(artifact));
+ } else if (object instanceof TransactionRecord) {
+ TransactionRecord tx = (TransactionRecord) object;
+ addTable(builder, toData(tx));
} else {
Map<String, Object> unhandled = new LinkedHashMap<String, Object>();
unhandled.put("Class", object.getClass().getSimpleName());
@@ -130,6 +134,24 @@ public class HtmlWriter {
return data;
}
+ public Map<String, Object> toData(TransactionRecord txRecord) throws OseeCoreException {
+ Map<String, Object> data = new LinkedHashMap<String, Object>();
+ data.put("TxId", txRecord.getId());
+ data.put("TxType", txRecord.getTxType());
+ data.put("Date", txRecord.getTimeStamp());
+ data.put("Comment", txRecord.getComment());
+ data.put("Author", txRecord.getAuthor());
+ IOseeBranch parent = txRecord.getBranch();
+ URI uri;
+ if (isAtEndOfPath(uriInfo.getPath(), "branch")) {
+ uri = uriInfo.getAbsolutePathBuilder().path("{uuid}").build(parent.getGuid());
+ } else {
+ uri = uriInfo.getAbsolutePathBuilder().path("../{uuid}").build(parent.getGuid());
+ }
+ data.put("Branch", asLink(uri.toASCIIString(), parent.getName()));
+ return data;
+ }
+
public String asLink(String url, String text) {
return String.format("<a href=\"%s\">%s</a>", url, text);
}
@@ -153,4 +175,5 @@ public class HtmlWriter {
}
return toCheck.endsWith(value);
}
+
}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TxResource.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TxResource.java
new file mode 100644
index 00000000000..1517e1ce31d
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TxResource.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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.orcs.rest.internal;
+
+import java.util.Collections;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriInfo;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.TransactionRecord;
+import org.eclipse.osee.framework.core.model.cache.TransactionCache;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class TxResource {
+
+ // Allows to insert contextual objects into the class,
+ // e.g. ServletContext, Request, Response, UriInfo
+ @Context
+ UriInfo uriInfo;
+ @Context
+ Request request;
+
+ String branchUuid;
+ int txId;
+
+ public TxResource(UriInfo uriInfo2, Request request2, String branchUuid, int txId) {
+ this.uriInfo = uriInfo;
+ this.request = request;
+ this.branchUuid = branchUuid;
+ this.txId = txId;
+ }
+
+ @Produces(MediaType.TEXT_HTML)
+ public String getAsHtml() throws OseeCoreException {
+ TransactionCache txCache = OrcsApplication.getOrcsApi().getTxsCache();
+ TransactionRecord txRecord = txCache.getOrLoad(txId);
+ HtmlWriter writer = new HtmlWriter(uriInfo);
+ return writer.toHtml(Collections.singleton(txRecord));
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TxsResource.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TxsResource.java
new file mode 100644
index 00000000000..000c5e24c1a
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TxsResource.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.orcs.rest.internal;
+
+import java.util.Arrays;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriInfo;
+import org.eclipse.osee.framework.core.enums.TransactionVersion;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.TransactionRecord;
+import org.eclipse.osee.framework.core.model.cache.TransactionCache;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class TxsResource {
+
+ @Context
+ UriInfo uriInfo;
+ @Context
+ Request request;
+
+ String branchUuid;
+
+ public TxsResource(UriInfo uriInfo, Request request, String branchUuid) {
+ this.uriInfo = uriInfo;
+ this.request = request;
+ this.branchUuid = branchUuid;
+ }
+
+ @Path("{txId}")
+ public TxResource getTransaction(@PathParam("txId") int txId) {
+ return new TxResource(uriInfo, request, branchUuid, txId);
+ }
+
+ @GET
+ @Produces(MediaType.TEXT_HTML)
+ public String getAsHtml() throws OseeCoreException {
+
+ TransactionCache txCache = OrcsApplication.getOrcsApi().getTxsCache();
+ Branch branch = OrcsApplication.getOrcsApi().getBranchCache().getByGuid(branchUuid);
+
+ TransactionRecord txBase = txCache.getTransaction(branch, TransactionVersion.BASE);
+ TransactionRecord txHead = txCache.getTransaction(branch, TransactionVersion.HEAD);
+
+ HtmlWriter writer = new HtmlWriter(uriInfo);
+ return writer.toHtml(Arrays.asList(txBase, txHead));
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsApi.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsApi.java
index 0b64b0c81cc..3f57e979618 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsApi.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsApi.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.orcs;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
+import org.eclipse.osee.framework.core.model.cache.TransactionCache;
import org.eclipse.osee.orcs.data.GraphReadable;
import org.eclipse.osee.orcs.search.QueryFacade;
import org.eclipse.osee.orcs.search.QueryFactory;
@@ -42,4 +43,6 @@ public interface OrcsApi {
// TODO remove this call
BranchCache getBranchCache();
+ // TODO remove this call
+ TransactionCache getTxsCache();
}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/Tester.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/Tester.java
deleted file mode 100644
index ff6f27bd7db..00000000000
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/Tester.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.orcs.transaction;
-
-import java.util.List;
-import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.OrcsApi;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.data.ArtifactWriteable;
-import org.eclipse.osee.orcs.data.AttributeWriteable;
-import org.eclipse.osee.orcs.data.GraphReadable;
-import org.eclipse.osee.orcs.data.GraphWriteable;
-
-public class Tester {
-
- OrcsTransaction getTransaction() {
- return null;
- }
-
- OrcsApi getApi() {
- return null;
- }
-
- public static void main(String[] args) throws Exception {
- Tester x = new Tester();
-
- ArtifactReadable artifact1 = null;
- ArtifactReadable artifact2 = null;
-
- x.modifyOneArtifact(artifact1);
-
- GraphReadable readableGraph = x.getApi().getGraph(null);
-
- OrcsTransaction tx = x.getTransaction(); // branch and user and comment
-
- GraphWriteable wGraph = tx.asWriteableGraph(readableGraph);
-
- ArtifactWriteable wArt1 = tx.asWritable(artifact1);
- ArtifactWriteable wArt2 = tx.asWritable(artifact2);
-
- for (ArtifactWriteable child : wGraph.getWriteableChildren(wArt1)) {
- child.setName("George");
- }
-
- List<AttributeWriteable<String>> attributes = wArt1.getWriteableAttributes();
- for (AttributeWriteable<String> attribute : attributes) {
- attribute.setValue("Hello");
- }
-
- wArt1.setName("Name");
- wArt1.setSoleAttributeValue(CoreAttributeTypes.Annotation, "hello");
-
- wArt2.setName("Shawn");
-
- tx.commit();
- }
-
- private void modifyOneArtifact(ArtifactReadable artifact1) throws OseeCoreException {
- OrcsTransaction tx = getTransaction(); // branch and user and comment
- tx.asWritable(artifact1).setName("new Name");
- tx.commit();
- }
-}

Back to the top