Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2012-09-10 23:52:06 +0000
committerRoberto E. Escobar2012-09-10 23:52:06 +0000
commit20c4485ba9d498a98412ed4392ab65d3872a095f (patch)
treeb0bd3c1288b960a3006dbcfa3c5079c1cc57211b
parentac0ad07b9f50f828a6320401a35256a4bc1d16dc (diff)
downloadorg.eclipse.osee-20c4485ba9d498a98412ed4392ab65d3872a095f.tar.gz
org.eclipse.osee-20c4485ba9d498a98412ed4392ab65d3872a095f.tar.xz
org.eclipse.osee-20c4485ba9d498a98412ed4392ab65d3872a095f.zip
bug: Add tests and fix DataFactoryImpl and OrcsObjectFactory
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeSequenceImpl.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactoryTest.java14
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactImplTest.java38
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactoryTest.java13
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/ArtifactProxyFactoryTest.java15
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataFactory.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataFactory.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactory.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/AttributeManager.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactory.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeManagerImpl.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/ArtifactProxyFactory.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImplTest.java515
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/LoaderTestSuite.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderTest.java16
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImpl.java53
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectFactoryImpl.java39
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderImpl.java44
18 files changed, 669 insertions, 109 deletions
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeSequenceImpl.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeSequenceImpl.java
index cab31ce9b56..0749cab2782 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeSequenceImpl.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeSequenceImpl.java
@@ -26,7 +26,7 @@ public class OseeSequenceImpl implements IOseeSequence {
private static final String UPDATE_SEQUENCE =
"UPDATE osee_sequence SET last_sequence = ? WHERE sequence_name = ? AND last_sequence = ?";
- private final static HashMap<String, SequenceRange> sequences = new HashMap<String, SequenceRange>(30);
+ private final HashMap<String, SequenceRange> sequences = new HashMap<String, SequenceRange>(30);
private final DatabaseService service;
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
index b1f7834b057..969cb79115e 100644
--- 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
@@ -10,16 +10,14 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.artifact;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
@@ -101,6 +99,10 @@ public class ArtifactFactoryTest {
when(artifactData.getVersion()).thenReturn(artifactVersion);
when(artifactVersion.getBranchId()).thenReturn(23);
+ when(
+ attributeFactory.copyAttribute(any(AttributeData.class), any(IOseeBranch.class), any(AttributeManager.class))).thenReturn(
+ attribute);
+
when(otherArtifactData.getLocalId()).thenReturn(45);
when(otherArtifactData.getGuid()).thenReturn(guid);
when(otherArtifactData.getTypeUuid()).thenReturn(65L);
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactImplTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactImplTest.java
index ffb57d342c7..da4c3f35d18 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactImplTest.java
@@ -10,13 +10,8 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.attribute;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.reset;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.*;
import java.util.List;
import junit.framework.Assert;
import org.eclipse.osee.framework.core.data.IAttributeType;
@@ -31,6 +26,7 @@ import org.eclipse.osee.framework.core.model.type.ArtifactType;
import org.eclipse.osee.framework.core.model.type.AttributeType;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.orcs.core.ds.ArtifactData;
+import org.eclipse.osee.orcs.core.ds.AttributeData;
import org.eclipse.osee.orcs.core.ds.VersionData;
import org.eclipse.osee.orcs.core.internal.artifact.ArtifactImpl;
import org.eclipse.osee.orcs.core.internal.artifact.AttributeManager;
@@ -62,9 +58,12 @@ public class ArtifactImplTest {
@Mock private ArtifactType artifactType;
@Mock private AttributeType attributeType;
@Mock private VersionData version;
+ @Mock private AttributeData attributeData;
@Mock private Branch branch;
@SuppressWarnings("rawtypes")
+ @Mock private Attribute attribute;
+ @SuppressWarnings("rawtypes")
@Mock private Attribute notDeleted;
@SuppressWarnings("rawtypes")
@Mock private Attribute deleted;
@@ -82,17 +81,27 @@ public class ArtifactImplTest {
when(artifactTypeProvider.get()).thenReturn(artifactType);
when(artifactType.isValidAttributeType(any(IAttributeType.class), any(Branch.class))).thenReturn(true);
when(attributeFactory.getAttribeType(any(IAttributeType.class))).thenReturn(attributeType);
+ when(attributeFactory.createAttribute(any(AttributeManager.class), any(AttributeData.class))).thenReturn(
+ attribute);
+ when(
+ attributeFactory.createAttributeWithDefaults(any(AttributeManager.class), any(ArtifactData.class),
+ any(IAttributeType.class))).thenReturn(attribute);
+ when(attribute.getOrcsData()).thenReturn(attributeData);
when(attributeType.getMaxOccurrences()).thenReturn(1);
when(artifactData.getGuid()).thenReturn(guid);
when(artifactData.getVersion()).thenReturn(version);
when(branchProvider.get()).thenReturn(branch);
when(deleted.isDeleted()).thenReturn(true);
+ when(notDeleted.getOrcsData()).thenReturn(attributeData);
+ when(deleted.getOrcsData()).thenReturn(attributeData);
+ when(differentType.getOrcsData()).thenReturn(attributeData);
}
@Test
@SuppressWarnings("unchecked")
public void testAddAndGet() {
Attribute<Object> attribute = mock(Attribute.class);
+ when(attribute.getOrcsData()).thenReturn(attributeData);
Assert.assertEquals(0, artifactImpl.getAllAttributes().size());
artifactImpl.add(CoreAttributeTypes.City, attribute);
Assert.assertTrue(artifactImpl.getAllAttributes().contains(attribute));
@@ -104,6 +113,8 @@ public class ArtifactImplTest {
public void testAddException() throws OseeCoreException {
Attribute one = mock(Attribute.class);
Attribute two = mock(Attribute.class);
+ when(one.getOrcsData()).thenReturn(attributeData);
+ when(two.getOrcsData()).thenReturn(attributeData);
when(attributeType.getMaxOccurrences()).thenReturn(1);
artifactImpl.add(attributeType, one);
artifactImpl.add(attributeType, two);
@@ -114,6 +125,7 @@ public class ArtifactImplTest {
@SuppressWarnings("unchecked")
public void testAreAttributesDirty() {
Attribute<Object> attribute = mock(Attribute.class);
+ when(attribute.getOrcsData()).thenReturn(attributeData);
artifactImpl.add(CoreAttributeTypes.City, attribute);
Assert.assertFalse(artifactImpl.areAttributesDirty());
when(attribute.isDirty()).thenReturn(true);
@@ -180,6 +192,7 @@ public class ArtifactImplTest {
@SuppressWarnings({"rawtypes", "unchecked"})
public void testSetName() throws OseeCoreException {
Attribute attr = mock(Attribute.class);
+ when(attr.getOrcsData()).thenReturn(attributeData);
when(
attributeFactory.createAttributeWithDefaults(any(AttributeManager.class), any(ArtifactData.class),
eq(CoreAttributeTypes.Name))).thenReturn(attr);
@@ -214,6 +227,7 @@ public class ArtifactImplTest {
// add dirty attribute
Attribute dirty = mock(Attribute.class);
+ when(dirty.getOrcsData()).thenReturn(attributeData);
when(dirty.isDirty()).thenReturn(true);
artifactImpl.add(CoreAttributeTypes.Active, dirty);
Assert.assertTrue(artifactImpl.isDirty());
@@ -257,6 +271,8 @@ public class ArtifactImplTest {
public void testSetAttributesNotDirty() {
Attribute one = mock(Attribute.class);
Attribute two = mock(Attribute.class);
+ when(one.getOrcsData()).thenReturn(attributeData);
+ when(two.getOrcsData()).thenReturn(attributeData);
artifactImpl.add(CoreAttributeTypes.AccessContextId, one);
artifactImpl.add(CoreAttributeTypes.AccessContextId, two);
artifactImpl.setAttributesNotDirty();
@@ -271,6 +287,7 @@ public class ArtifactImplTest {
Assert.assertTrue(name.contains("AttributeDoesNotExist"));
Attribute attr = mock(Attribute.class);
+ when(attr.getOrcsData()).thenReturn(attributeData);
when(
attributeFactory.createAttributeWithDefaults(any(AttributeManager.class), any(ArtifactData.class),
eq(CoreAttributeTypes.Name))).thenReturn(attr);
@@ -364,6 +381,8 @@ public class ArtifactImplTest {
public void testGetSoleAttributeAsStringException() throws OseeCoreException {
Attribute one = mock(Attribute.class);
Attribute two = mock(Attribute.class);
+ when(one.getOrcsData()).thenReturn(attributeData);
+ when(two.getOrcsData()).thenReturn(attributeData);
artifactImpl.add(CoreAttributeTypes.AccessContextId, one);
artifactImpl.add(CoreAttributeTypes.AccessContextId, two);
thrown.expect(MultipleAttributesExist.class);
@@ -410,6 +429,9 @@ public class ArtifactImplTest {
Attribute one = mock(Attribute.class);
Attribute two = mock(Attribute.class);
Attribute three = mock(Attribute.class);
+ when(one.getOrcsData()).thenReturn(attributeData);
+ when(two.getOrcsData()).thenReturn(attributeData);
+ when(three.getOrcsData()).thenReturn(attributeData);
when(attributeType.getMaxOccurrences()).thenReturn(3);
when(attributeFactory.createAttributeWithDefaults(eq(artifactImpl), any(ArtifactData.class), eq(attributeType))).thenReturn(
one, two, three);
@@ -424,6 +446,8 @@ public class ArtifactImplTest {
public void testSetAttributesFromStringsCreateOne() throws OseeCoreException {
Attribute one = mock(Attribute.class);
Attribute two = mock(Attribute.class);
+ when(one.getOrcsData()).thenReturn(attributeData);
+ when(two.getOrcsData()).thenReturn(attributeData);
when(attributeType.getMaxOccurrences()).thenReturn(3);
when(attributeFactory.createAttributeWithDefaults(eq(artifactImpl), any(ArtifactData.class), eq(attributeType))).thenReturn(
two);
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactoryTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactoryTest.java
index b2a790dd2f5..3fae804ff07 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactoryTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactoryTest.java
@@ -10,15 +10,9 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.attribute;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNull;
-import static junit.framework.Assert.assertTrue;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static junit.framework.Assert.*;
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.*;
import java.lang.ref.WeakReference;
import junit.framework.Assert;
import org.eclipse.osee.framework.core.data.IAttributeType;
@@ -131,7 +125,6 @@ public class AttributeFactoryTest {
Attribute<Object> actual = factory.createAttributeWithDefaults(container, artifactData, attributeType);
verify(dataFactory).create(artifactData, attributeType);
- verify(attrVersionData).setBranchId(45);
assertTrue(attribute == actual);
verify(proxy).setResolver(resolverCapture.capture());
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/ArtifactProxyFactoryTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/ArtifactProxyFactoryTest.java
index a3c253d2338..ddccc94b631 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/ArtifactProxyFactoryTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/ArtifactProxyFactoryTest.java
@@ -10,12 +10,8 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.proxy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
import java.util.Collection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -76,15 +72,18 @@ public class ArtifactProxyFactoryTest {
String expectedName = "NAME";
when(artifactFactory.createArtifact(branch, artifactType, guid)).thenReturn(artifact);
+ when(artifactFactory.clone(artifact)).thenReturn(otherArtifact);
ArtifactWriteable actual = factory.create(branch, artifactType, guid, expectedName);
verify(artifactFactory).createArtifact(branch, artifactType, guid);
- verify(artifact).setName(expectedName);
+ verify(otherArtifact).setName(expectedName);
+ verify(artifact, times(0)).setName(expectedName);
assertTrue(actual instanceof ProxyWriteable);
assertTrue(ProxyUtil.isProxy(actual));
- assertEquals(artifact, factory.getProxiedObject(actual));
+ assertEquals(otherArtifact, factory.getProxiedObject(actual));
+ assertEquals(artifact, factory.getOriginalObject(actual));
}
@SuppressWarnings("unchecked")
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataFactory.java
index 6b66675d8da..c54c408ac32 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataFactory.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataFactory.java
@@ -13,14 +13,13 @@ package org.eclipse.osee.orcs.core.ds;
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.orcs.data.HasLocalId;
/**
* @author Roberto E. Escobar
*/
public interface AttributeDataFactory {
- AttributeData create(HasLocalId parent, IAttributeType attributeType) throws OseeCoreException;
+ AttributeData create(ArtifactData parent, IAttributeType attributeType) throws OseeCoreException;
AttributeData copy(IOseeBranch destination, AttributeData orcsData) throws OseeCoreException;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataFactory.java
index c1dd5cdeb1b..cc2984e3758 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataFactory.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataFactory.java
@@ -19,7 +19,7 @@ import org.eclipse.osee.orcs.data.HasLocalId;
*/
public interface RelationDataFactory {
- RelationData createRelationData(IRelationType relationType, HasLocalId parent, HasLocalId aArt, HasLocalId bArt, String rationale) throws OseeCoreException;
+ RelationData createRelationData(IRelationType relationType, ArtifactData parent, HasLocalId aArt, HasLocalId bArt, String rationale) throws OseeCoreException;
RelationData clone(RelationData source) throws OseeCoreException;
}
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 a6b007c0d2b..c8640afb73f 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
@@ -77,8 +77,7 @@ public class ArtifactFactory {
for (IAttributeType attributeType : typeToCopy) {
for (AttributeReadable<?> attributeSource : source.getAttributes(attributeType)) {
AttributeData data = getAttributeData(attributeSource);
- Attribute<Object> copyAttribute = attributeFactory.copyAttribute(data, ontoBranch, copy);
- copyAttribute.getOrcsData().setArtifactId(copy.getLocalId());
+ attributeFactory.copyAttribute(data, ontoBranch, copy);
}
}
copy.setLoaded(true);
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 db045e68820..757071dfdbe 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
@@ -16,11 +16,12 @@ import org.eclipse.osee.framework.core.data.Identifiable;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
import org.eclipse.osee.orcs.data.AttributesWriteable;
+import org.eclipse.osee.orcs.data.HasLocalId;
/**
* @author Roberto E. Escobar
*/
-public interface AttributeManager extends Identifiable, AttributesWriteable {
+public interface AttributeManager extends Identifiable, AttributesWriteable, HasLocalId {
void add(IAttributeType type, Attribute<? extends Object> 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 06d95441485..340134faa19 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
@@ -23,7 +23,6 @@ import org.eclipse.osee.orcs.core.ds.AttributeData;
import org.eclipse.osee.orcs.core.ds.AttributeDataFactory;
import org.eclipse.osee.orcs.core.ds.DataProxy;
import org.eclipse.osee.orcs.core.ds.ResourceNameResolver;
-import org.eclipse.osee.orcs.core.ds.VersionData;
import org.eclipse.osee.orcs.core.internal.artifact.AttributeManager;
/**
@@ -43,8 +42,6 @@ public class AttributeFactory {
public <T> Attribute<T> createAttributeWithDefaults(AttributeManager container, ArtifactData artifactData, IAttributeType attributeType) throws OseeCoreException {
AttributeData data = dataFactory.create(artifactData, attributeType);
- VersionData versionData = data.getVersion();
- versionData.setBranchId(artifactData.getVersion().getBranchId());
return createAttribute(container, data, true, true);
}
@@ -63,11 +60,10 @@ public class AttributeFactory {
proxy.setResolver(resolver);
Reference<AttributeManager> artifactRef = new WeakReference<AttributeManager>(container);
+
attribute.internalInitialize(artifactRef, data, type, isDirty, createWithDefaults);
+ container.add(type, attribute);
- synchronized (container) {
- container.add(type, attribute);
- }
return attribute;
}
@@ -79,7 +75,7 @@ public class AttributeFactory {
public <T> Attribute<T> cloneAttribute(AttributeData source, AttributeManager destinationContainer) throws OseeCoreException {
AttributeData attributeData = dataFactory.clone(source);
- Attribute<T> destinationAttribute = createAttribute(destinationContainer, attributeData, true, false);
+ Attribute<T> destinationAttribute = createAttribute(destinationContainer, attributeData, false, false);
return destinationAttribute;
}
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 62003d21c8a..e2c17866ca5 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
@@ -64,11 +64,13 @@ public abstract class AttributeManagerImpl extends AbstractIdentity<String> impl
@Override
public synchronized void add(IAttributeType type, Attribute<? extends Object> attribute) {
attributes.addAttribute(type, attribute);
+ attribute.getOrcsData().setArtifactId(getLocalId());
}
@Override
public void remove(IAttributeType type, Attribute<? extends Object> attribute) {
attributes.removeAttribute(type, attribute);
+ attribute.getOrcsData().setArtifactId(-1);
}
@Override
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/ArtifactProxyFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/ArtifactProxyFactory.java
index c692f7d5d2c..949257b7d20 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/ArtifactProxyFactory.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/ArtifactProxyFactory.java
@@ -37,10 +37,11 @@ public class ArtifactProxyFactory extends ProxyFactory<ArtifactImpl, ArtifactRea
public ArtifactWriteable create(IOseeBranch branch, IArtifactType artifactType, String guid, String name) throws OseeCoreException {
ArtifactImpl toProxy = factory.createArtifact(branch, artifactType, guid);
+ ArtifactWriteable writeable = createWriteable(toProxy);
if (name != null) {
- toProxy.setName(name);
+ writeable.setName(name);
}
- return createWriteable(toProxy);
+ return writeable;
}
public ArtifactWriteable introduce(ArtifactReadable readable, IOseeBranch ontoBranch) throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImplTest.java
new file mode 100644
index 00000000000..e8afbf900ac
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImplTest.java
@@ -0,0 +1,515 @@
+/*******************************************************************************
+ * 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.loader;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotSame;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.ModificationType;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.cache.ArtifactTypeCache;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+import org.eclipse.osee.framework.core.services.IdentityService;
+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.ArtifactData;
+import org.eclipse.osee.orcs.core.ds.AttributeData;
+import org.eclipse.osee.orcs.core.ds.DataFactory;
+import org.eclipse.osee.orcs.core.ds.DataProxy;
+import org.eclipse.osee.orcs.core.ds.RelationData;
+import org.eclipse.osee.orcs.core.ds.VersionData;
+import org.eclipse.osee.orcs.data.HasLocalId;
+import org.eclipse.osee.orcs.db.internal.OrcsObjectFactory;
+import org.eclipse.osee.orcs.db.internal.loader.data.OrcsObjectFactoryImpl;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test Case for {@link DataFactoryImplTest} and {@link OrcsObjectFactoryImpl}
+ *
+ * @author Roberto E. Escobar
+ */
+public class DataFactoryImplTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ //@formatter:off
+ @Mock private IdFactory idFactory;
+ @Mock private ProxyDataFactory proxyFactory;
+ @Mock private IdentityService identityService;
+ @Mock private ArtifactTypeCache artifactCache;
+
+ @Mock private ArtifactData artData;
+ @Mock private AttributeData attrData;
+ @Mock private RelationData relData;
+ @Mock private VersionData verData;
+ @Mock private DataProxy dataProxy;
+ @Mock private DataProxy otherDataProxy;
+
+ @Mock private ArtifactType artifactType;
+ @Mock private IArtifactType artifactTypeToken;
+ //@formatter:on
+
+ private DataFactory dataFactory;
+ private Object[] expectedProxyData;
+ private String guid;
+ private String hrid;
+
+ @Before
+ public void setUp() throws OseeCoreException {
+ MockitoAnnotations.initMocks(this);
+
+ guid = GUID.create();
+ hrid = HumanReadableId.generate();
+
+ OrcsObjectFactory objectFactory = new OrcsObjectFactoryImpl(proxyFactory, identityService);
+ dataFactory = new DataFactoryImpl(idFactory, objectFactory, artifactCache);
+
+ // VERSION
+ when(verData.getBranchId()).thenReturn(11);
+ when(verData.getGammaId()).thenReturn(222L);
+ when(verData.getTransactionId()).thenReturn(333);
+ when(verData.getStripeId()).thenReturn(444);
+ when(verData.isHistorical()).thenReturn(true);
+
+ // ARTIFACT
+ when(artData.getVersion()).thenReturn(verData);
+ when(artData.getLocalId()).thenReturn(555);
+ when(artData.getModType()).thenReturn(ModificationType.MODIFIED);
+ when(artData.getTypeUuid()).thenReturn(666L);
+ when(artData.getLoadedModType()).thenReturn(ModificationType.NEW);
+ when(artData.getLoadedTypeUuid()).thenReturn(777L);
+ when(artData.getGuid()).thenReturn("abcdefg");
+ when(artData.getHumanReadableId()).thenReturn("abc34");
+
+ // ATTRIBUTE
+ when(attrData.getVersion()).thenReturn(verData);
+ when(attrData.getLocalId()).thenReturn(555);
+ when(attrData.getModType()).thenReturn(ModificationType.MODIFIED);
+ when(attrData.getTypeUuid()).thenReturn(666L);
+ when(attrData.getLoadedModType()).thenReturn(ModificationType.NEW);
+ when(attrData.getLoadedTypeUuid()).thenReturn(777L);
+ when(attrData.getArtifactId()).thenReturn(88);
+ when(attrData.getDataProxy()).thenReturn(dataProxy);
+
+ expectedProxyData = new Object[] {45, "hello", "hello"};
+ when(dataProxy.getData()).thenReturn(expectedProxyData);
+ when(proxyFactory.createProxy(666L, expectedProxyData)).thenReturn(otherDataProxy);
+ when(otherDataProxy.getData()).thenReturn(new Object[] {45, "hello", "hello"});
+
+ // RELATION
+ when(relData.getVersion()).thenReturn(verData);
+ when(relData.getLocalId()).thenReturn(555);
+ when(relData.getModType()).thenReturn(ModificationType.MODIFIED);
+ when(relData.getTypeUuid()).thenReturn(666L);
+ when(relData.getLoadedModType()).thenReturn(ModificationType.NEW);
+ when(relData.getLoadedTypeUuid()).thenReturn(777L);
+ when(relData.getArtIdA()).thenReturn(88);
+ when(relData.getArtIdB()).thenReturn(99);
+ when(relData.getParentId()).thenReturn(1111);
+ when(relData.getRationale()).thenReturn("this is the rationale");
+
+ when(idFactory.getBranchId(CoreBranches.COMMON)).thenReturn(657);
+ }
+
+ @Test
+ public void testCreateArtifactDataNullType() throws OseeCoreException {
+ when(artifactTypeToken.toString()).thenReturn("artifactTypeToken");
+ when(artifactCache.get(artifactTypeToken)).thenReturn(null);
+
+ thrown.expect(OseeArgumentException.class);
+ thrown.expectMessage("artifactType cannot be null - Unable to find artifactType matching [artifactTypeToken]");
+ dataFactory.create(CoreBranches.COMMON, artifactTypeToken, guid, hrid);
+ }
+
+ @Test
+ public void testCreateArtifactDataUsingAbstratArtifactType() throws OseeCoreException {
+ when(artifactType.toString()).thenReturn("artifactType");
+ when(artifactCache.get(artifactTypeToken)).thenReturn(artifactType);
+ when(artifactType.isAbstract()).thenReturn(true);
+
+ thrown.expect(OseeArgumentException.class);
+ thrown.expectMessage("Cannot create an instance of abstract type [artifactType]");
+ dataFactory.create(CoreBranches.COMMON, artifactTypeToken, guid, hrid);
+ }
+
+ @Test
+ public void testCreateArtifactDataInvalidGuid() throws OseeCoreException {
+ when(artifactCache.get(artifactTypeToken)).thenReturn(artifactType);
+ when(artifactType.isAbstract()).thenReturn(false);
+ when(artifactType.toString()).thenReturn("artifactType");
+
+ when(idFactory.getUniqueGuid(guid)).thenReturn("123");
+
+ thrown.expect(OseeArgumentException.class);
+ thrown.expectMessage("Invalid guid [123] during artifact creation [type: artifactType]");
+
+ dataFactory.create(CoreBranches.COMMON, artifactTypeToken, guid, hrid);
+ }
+
+ @Test
+ public void testCreateArtifactDataInvalidHrid() throws OseeCoreException {
+ when(artifactCache.get(artifactTypeToken)).thenReturn(artifactType);
+ when(artifactType.isAbstract()).thenReturn(false);
+ when(artifactType.toString()).thenReturn("artifactType");
+
+ when(idFactory.getUniqueGuid(guid)).thenReturn(guid);
+ when(idFactory.getUniqueHumanReadableId(hrid)).thenReturn("123");
+
+ thrown.expect(OseeArgumentException.class);
+ thrown.expectMessage("Invalid human readable id [123] during artifact creation [type: artifactType, guid: " + guid + "]");
+
+ dataFactory.create(CoreBranches.COMMON, artifactTypeToken, guid, hrid);
+ }
+
+ @Test
+ public void testCreateArtifactData() throws OseeCoreException {
+ when(artifactCache.get(artifactTypeToken)).thenReturn(artifactType);
+ when(artifactType.getGuid()).thenReturn(4536L);
+ when(artifactType.isAbstract()).thenReturn(false);
+ when(idFactory.getUniqueGuid(guid)).thenReturn(guid);
+ when(idFactory.getUniqueHumanReadableId(hrid)).thenReturn(hrid);
+ when(idFactory.getNextArtifactId()).thenReturn(987);
+
+ ArtifactData actual = dataFactory.create(CoreBranches.COMMON, artifactTypeToken, guid, hrid);
+ verify(idFactory).getBranchId(CoreBranches.COMMON);
+ verify(idFactory).getUniqueGuid(guid);
+ verify(idFactory).getUniqueHumanReadableId(hrid);
+ verify(idFactory).getNextArtifactId();
+
+ VersionData actualVer = actual.getVersion();
+
+ assertEquals(657, actualVer.getBranchId());
+ assertEquals(RelationalConstants.GAMMA_SENTINEL, actualVer.getGammaId());
+ assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getTransactionId());
+ assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getStripeId());
+ assertEquals(false, actualVer.isHistorical());
+ assertEquals(false, actualVer.isInStorage());
+
+ assertEquals(987, actual.getLocalId());
+ assertEquals(RelationalConstants.DEFAULT_MODIFICATION_TYPE, actual.getModType());
+ assertEquals(4536L, actual.getTypeUuid());
+ assertEquals(RelationalConstants.DEFAULT_MODIFICATION_TYPE, actual.getLoadedModType());
+ assertEquals(4536L, actual.getLoadedTypeUuid());
+ assertEquals(guid, actual.getGuid());
+ assertEquals(hrid, actual.getHumanReadableId());
+ }
+
+ @Test
+ public void testCreateArtifactDataGenerateHrid() throws OseeCoreException {
+ String newHrid = HumanReadableId.generate();
+
+ when(artifactCache.get(artifactTypeToken)).thenReturn(artifactType);
+ when(artifactType.getGuid()).thenReturn(4536L);
+ when(artifactType.isAbstract()).thenReturn(false);
+ when(idFactory.getUniqueGuid(guid)).thenReturn(guid);
+ when(idFactory.getUniqueHumanReadableId(null)).thenReturn(newHrid);
+ when(idFactory.getNextArtifactId()).thenReturn(987);
+
+ ArtifactData actual = dataFactory.create(CoreBranches.COMMON, artifactTypeToken, guid);
+ verify(idFactory).getBranchId(CoreBranches.COMMON);
+ verify(idFactory).getUniqueGuid(guid);
+ verify(idFactory).getUniqueHumanReadableId(null);
+ verify(idFactory).getNextArtifactId();
+
+ VersionData actualVer = actual.getVersion();
+ assertEquals(657, actualVer.getBranchId());
+ assertEquals(RelationalConstants.GAMMA_SENTINEL, actualVer.getGammaId());
+ assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getTransactionId());
+ assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getStripeId());
+ assertEquals(false, actualVer.isHistorical());
+ assertEquals(false, actualVer.isInStorage());
+
+ assertEquals(987, actual.getLocalId());
+ assertEquals(RelationalConstants.DEFAULT_MODIFICATION_TYPE, actual.getModType());
+ assertEquals(4536L, actual.getTypeUuid());
+ assertEquals(RelationalConstants.DEFAULT_MODIFICATION_TYPE, actual.getLoadedModType());
+ assertEquals(4536L, actual.getLoadedTypeUuid());
+ assertEquals(guid, actual.getGuid());
+ assertEquals(newHrid, actual.getHumanReadableId());
+ }
+
+ @Test
+ public void testCreateAttributeData() throws OseeCoreException {
+ IAttributeType attributeType = mock(IAttributeType.class);
+
+ when(attributeType.getGuid()).thenReturn(2389L);
+ when(proxyFactory.createProxy(2389L, "", "")).thenReturn(otherDataProxy);
+ when(otherDataProxy.getData()).thenReturn(new Object[] {2389L, "", ""});
+
+ AttributeData actual = dataFactory.create(artData, attributeType);
+
+ VersionData actualVer = actual.getVersion();
+ assertEquals(11, actualVer.getBranchId());
+ assertEquals(RelationalConstants.GAMMA_SENTINEL, actualVer.getGammaId());
+ assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getTransactionId());
+ assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getStripeId());
+ assertEquals(false, actualVer.isHistorical());
+ assertEquals(false, actualVer.isInStorage());
+
+ assertEquals(RelationalConstants.DEFAULT_ITEM_ID, actual.getLocalId());
+ assertEquals(RelationalConstants.DEFAULT_MODIFICATION_TYPE, actual.getModType());
+ assertEquals(2389L, actual.getTypeUuid());
+ assertEquals(RelationalConstants.DEFAULT_MODIFICATION_TYPE, actual.getLoadedModType());
+ assertEquals(2389L, actual.getLoadedTypeUuid());
+
+ assertEquals(555, actual.getArtifactId());
+ assertNotSame(dataProxy, actual.getDataProxy());
+
+ Object[] objData = actual.getDataProxy().getData();
+ assertEquals(2389L, objData[0]);
+ assertEquals("", objData[1]);
+ assertEquals("", objData[2]);
+ }
+
+ @Test
+ public void testCreateRelationData() throws OseeCoreException {
+ IRelationType relationType = mock(IRelationType.class);
+ HasLocalId localId1 = mock(HasLocalId.class);
+ HasLocalId localId2 = mock(HasLocalId.class);
+
+ when(relationType.getGuid()).thenReturn(2389L);
+ when(localId1.getLocalId()).thenReturn(4562);
+ when(localId2.getLocalId()).thenReturn(9513);
+
+ RelationData actual = dataFactory.createRelationData(relationType, artData, localId1, localId2, "My rationale");
+
+ VersionData actualVer = actual.getVersion();
+ assertEquals(11, actualVer.getBranchId());
+ assertEquals(RelationalConstants.GAMMA_SENTINEL, actualVer.getGammaId());
+ assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getTransactionId());
+ assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getStripeId());
+ assertEquals(false, actualVer.isHistorical());
+ assertEquals(false, actualVer.isInStorage());
+
+ assertEquals(RelationalConstants.DEFAULT_ITEM_ID, actual.getLocalId());
+ assertEquals(RelationalConstants.DEFAULT_MODIFICATION_TYPE, actual.getModType());
+ assertEquals(2389L, actual.getTypeUuid());
+ assertEquals(RelationalConstants.DEFAULT_MODIFICATION_TYPE, actual.getLoadedModType());
+ assertEquals(2389L, actual.getLoadedTypeUuid());
+
+ assertEquals(4562, actual.getArtIdA());
+ assertEquals(9513, actual.getArtIdB());
+ assertEquals(555, actual.getParentId());
+ assertEquals("My rationale", actual.getRationale());
+ }
+
+ @Test
+ public void testIntroduceArtifactData() throws OseeCoreException {
+ ArtifactData actual = dataFactory.introduce(CoreBranches.COMMON, artData);
+ verify(idFactory).getBranchId(CoreBranches.COMMON);
+
+ VersionData actualVer = actual.getVersion();
+ assertNotSame(verData, actualVer);
+ assertEquals(657, actualVer.getBranchId());
+ assertEquals(222L, actualVer.getGammaId());
+ assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getTransactionId());
+ assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getStripeId());
+ assertEquals(false, actualVer.isHistorical());
+ assertEquals(false, actualVer.isInStorage());
+
+ assertEquals(555, actual.getLocalId());
+ assertEquals(ModificationType.INTRODUCED, actual.getModType());
+ assertEquals(666L, actual.getTypeUuid());
+ assertEquals(ModificationType.NEW, actual.getLoadedModType());
+ assertEquals(777L, actual.getLoadedTypeUuid());
+ assertEquals("abcdefg", actual.getGuid());
+ assertEquals("abc34", actual.getHumanReadableId());
+ }
+
+ @Test
+ public void testIntroduceAttributeData() throws OseeCoreException {
+ AttributeData actual = dataFactory.introduce(CoreBranches.COMMON, attrData);
+ verify(idFactory).getBranchId(CoreBranches.COMMON);
+
+ VersionData actualVer = actual.getVersion();
+ assertNotSame(verData, actualVer);
+ assertEquals(657, actualVer.getBranchId());
+ assertEquals(222L, actualVer.getGammaId());
+ assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getTransactionId());
+ assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getStripeId());
+ assertEquals(false, actualVer.isHistorical());
+ assertEquals(false, actualVer.isInStorage());
+
+ assertEquals(555, actual.getLocalId());
+ assertEquals(ModificationType.INTRODUCED, actual.getModType());
+ assertEquals(666L, actual.getTypeUuid());
+ assertEquals(ModificationType.NEW, actual.getLoadedModType());
+ assertEquals(777L, actual.getLoadedTypeUuid());
+
+ assertEquals(88, actual.getArtifactId());
+ assertNotSame(dataProxy, actual.getDataProxy());
+
+ Object[] objData = actual.getDataProxy().getData();
+ assertNotSame(expectedProxyData, objData);
+ assertEquals(expectedProxyData[0], objData[0]);
+ assertEquals(expectedProxyData[1], objData[1]);
+ assertEquals(expectedProxyData[2], objData[2]);
+ }
+
+ @Test
+ public void testCopyArtifactData() throws OseeCoreException {
+ String newGuid = GUID.create();
+ String newHrid = HumanReadableId.generate();
+ when(idFactory.getNextArtifactId()).thenReturn(987);
+ when(idFactory.getUniqueGuid(null)).thenReturn(newGuid);
+ when(idFactory.getUniqueHumanReadableId(null)).thenReturn(newHrid);
+
+ ArtifactData actual = dataFactory.copy(CoreBranches.COMMON, artData);
+ verify(idFactory).getBranchId(CoreBranches.COMMON);
+ verify(idFactory).getUniqueGuid(null);
+ verify(idFactory).getUniqueHumanReadableId(null);
+
+ VersionData actualVer = actual.getVersion();
+ assertNotSame(verData, actualVer);
+ assertEquals(657, actualVer.getBranchId());
+ assertEquals(RelationalConstants.GAMMA_SENTINEL, actualVer.getGammaId());
+ assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getTransactionId());
+ assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getStripeId());
+ assertEquals(false, actualVer.isHistorical());
+ assertEquals(false, actualVer.isInStorage());
+
+ assertEquals(987, actual.getLocalId());
+ assertEquals(ModificationType.NEW, actual.getModType());
+ assertEquals(666L, actual.getTypeUuid());
+ assertEquals(ModificationType.NEW, actual.getLoadedModType());
+ assertEquals(777L, actual.getLoadedTypeUuid());
+ assertEquals(newGuid, actual.getGuid());
+ assertEquals(newHrid, actual.getHumanReadableId());
+ }
+
+ @Test
+ public void testCopyAttributeData() throws OseeCoreException {
+ AttributeData actual = dataFactory.copy(CoreBranches.COMMON, attrData);
+ verify(idFactory).getBranchId(CoreBranches.COMMON);
+
+ VersionData actualVer = actual.getVersion();
+ assertNotSame(verData, actualVer);
+ assertEquals(657, actualVer.getBranchId());
+ assertEquals(RelationalConstants.GAMMA_SENTINEL, actualVer.getGammaId());
+ assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getTransactionId());
+ assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getStripeId());
+ assertEquals(false, actualVer.isHistorical());
+ assertEquals(false, actualVer.isInStorage());
+
+ assertEquals(RelationalConstants.DEFAULT_ITEM_ID, actual.getLocalId());
+ assertEquals(ModificationType.NEW, actual.getModType());
+ assertEquals(666L, actual.getTypeUuid());
+ assertEquals(ModificationType.NEW, actual.getLoadedModType());
+ assertEquals(777L, actual.getLoadedTypeUuid());
+
+ assertEquals(88, actual.getArtifactId());
+ assertNotSame(dataProxy, actual.getDataProxy());
+
+ Object[] objData = actual.getDataProxy().getData();
+ assertNotSame(expectedProxyData, objData);
+ assertEquals(expectedProxyData[0], objData[0]);
+ assertEquals(expectedProxyData[1], objData[1]);
+ assertEquals(expectedProxyData[2], objData[2]);
+ }
+
+ @Test
+ public void testCloneArtifactData() {
+ ArtifactData actual = dataFactory.clone(artData);
+ VersionData actualVer = actual.getVersion();
+
+ assertNotSame(artData, actual);
+ assertNotSame(verData, actualVer);
+
+ assertEquals(11, actualVer.getBranchId());
+ assertEquals(222L, actualVer.getGammaId());
+ assertEquals(333, actualVer.getTransactionId());
+ assertEquals(444, actualVer.getStripeId());
+ assertEquals(true, actualVer.isHistorical());
+ assertEquals(true, actualVer.isInStorage());
+
+ assertEquals(555, actual.getLocalId());
+ assertEquals(ModificationType.MODIFIED, actual.getModType());
+ assertEquals(666L, actual.getTypeUuid());
+ assertEquals(ModificationType.NEW, actual.getLoadedModType());
+ assertEquals(777L, actual.getLoadedTypeUuid());
+ assertEquals("abcdefg", actual.getGuid());
+ assertEquals("abc34", actual.getHumanReadableId());
+ }
+
+ @Test
+ public void testCloneAttributeData() throws OseeCoreException {
+ AttributeData actual = dataFactory.clone(attrData);
+ verify(proxyFactory).createProxy(666L, expectedProxyData);
+
+ VersionData actualVer = actual.getVersion();
+
+ assertNotSame(attrData, actual);
+ assertNotSame(verData, actualVer);
+
+ assertEquals(11, actualVer.getBranchId());
+ assertEquals(222L, actualVer.getGammaId());
+ assertEquals(333, actualVer.getTransactionId());
+ assertEquals(444, actualVer.getStripeId());
+ assertEquals(true, actualVer.isHistorical());
+ assertEquals(true, actualVer.isInStorage());
+
+ assertEquals(555, actual.getLocalId());
+ assertEquals(ModificationType.MODIFIED, actual.getModType());
+ assertEquals(666L, actual.getTypeUuid());
+ assertEquals(ModificationType.NEW, actual.getLoadedModType());
+ assertEquals(777L, actual.getLoadedTypeUuid());
+
+ assertEquals(88, actual.getArtifactId());
+ assertNotSame(dataProxy, actual.getDataProxy());
+
+ Object[] objData = actual.getDataProxy().getData();
+ assertNotSame(expectedProxyData, objData);
+ assertEquals(expectedProxyData[0], objData[0]);
+ assertEquals(expectedProxyData[1], objData[1]);
+ assertEquals(expectedProxyData[2], objData[2]);
+ }
+
+ @Test
+ public void testCloneRelationData() throws OseeCoreException {
+ RelationData actual = dataFactory.clone(relData);
+ VersionData actualVer = actual.getVersion();
+
+ assertNotSame(relData, actual);
+ assertNotSame(verData, actualVer);
+
+ assertEquals(11, actualVer.getBranchId());
+ assertEquals(222L, actualVer.getGammaId());
+ assertEquals(333, actualVer.getTransactionId());
+ assertEquals(444, actualVer.getStripeId());
+ assertEquals(true, actualVer.isHistorical());
+ assertEquals(true, actualVer.isInStorage());
+
+ assertEquals(555, actual.getLocalId());
+ assertEquals(ModificationType.MODIFIED, actual.getModType());
+ assertEquals(666L, actual.getTypeUuid());
+ assertEquals(ModificationType.NEW, actual.getLoadedModType());
+ assertEquals(777L, actual.getLoadedTypeUuid());
+
+ assertEquals(88, actual.getArtIdA());
+ assertEquals(99, actual.getArtIdB());
+ assertEquals(1111, actual.getParentId());
+ assertEquals("this is the rationale", actual.getRationale());
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/LoaderTestSuite.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/LoaderTestSuite.java
index c14fd2a7324..65c2ca782c8 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/LoaderTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/LoaderTestSuite.java
@@ -19,6 +19,7 @@ import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
AttributeDataProxyFactoryTest.class,
+ DataFactoryImplTest.class,
DataLoaderImplTest.class,
LoaderSqlHandlerFactoryImplTest.class})
public class LoaderTestSuite {
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
index ffa85f7669b..a730242af4f 100644
--- 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
@@ -10,9 +10,19 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.transaction;
-import static junit.framework.Assert.*;
-import static org.eclipse.osee.framework.core.enums.ModificationType.*;
-import static org.mockito.Mockito.*;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+import static org.eclipse.osee.framework.core.enums.ModificationType.ARTIFACT_DELETED;
+import static org.eclipse.osee.framework.core.enums.ModificationType.DELETED;
+import static org.eclipse.osee.framework.core.enums.ModificationType.INTRODUCED;
+import static org.eclipse.osee.framework.core.enums.ModificationType.MERGED;
+import static org.eclipse.osee.framework.core.enums.ModificationType.MODIFIED;
+import static org.eclipse.osee.framework.core.enums.ModificationType.NEW;
+import static org.eclipse.osee.framework.core.enums.ModificationType.REPLACED_WITH_VERSION;
+import static org.eclipse.osee.framework.core.enums.ModificationType.UNDELETED;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImpl.java
index 267360e1eec..4617d06f03f 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImpl.java
@@ -24,6 +24,7 @@ import org.eclipse.osee.framework.jdk.core.util.HumanReadableId;
import org.eclipse.osee.orcs.core.ds.ArtifactData;
import org.eclipse.osee.orcs.core.ds.AttributeData;
import org.eclipse.osee.orcs.core.ds.DataFactory;
+import org.eclipse.osee.orcs.core.ds.OrcsData;
import org.eclipse.osee.orcs.core.ds.RelationData;
import org.eclipse.osee.orcs.core.ds.VersionData;
import org.eclipse.osee.orcs.data.HasLocalId;
@@ -55,6 +56,8 @@ public class DataFactoryImpl implements DataFactory {
Conditions.checkNotNull(branch, "branch");
ArtifactType artifactType = artifactCache.get(token);
+ Conditions.checkNotNull(artifactType, "artifactType", "Unable to find artifactType matching [%s]", token);
+
Conditions.checkExpressionFailOnTrue(artifactType.isAbstract(),
"Cannot create an instance of abstract type [%s]", artifactType);
@@ -83,28 +86,24 @@ public class DataFactoryImpl implements DataFactory {
@Override
public ArtifactData copy(IOseeBranch destination, ArtifactData source) throws OseeCoreException {
ArtifactData copy = objectFactory.createCopy(source);
- copy.getVersion().setBranchId(idFactory.getBranchId(destination));
- copy.getVersion().setTransactionId(RelationalConstants.TRANSACTION_SENTINEL);
- copy.setModType(ModificationType.NEW);
- copy.getVersion().setHistorical(false);
+ updateDataForCopy(destination, copy);
+ copy.setGuid(idFactory.getUniqueGuid(null));
+ copy.setHumanReadableId(idFactory.getUniqueHumanReadableId(null));
copy.setLocalId(idFactory.getNextArtifactId());
- copy.setGuid(GUID.create());
return copy;
}
@Override
public AttributeData introduce(IOseeBranch destination, AttributeData source) throws OseeCoreException {
AttributeData newVersion = objectFactory.createCopy(source);
- newVersion.getVersion().setBranchId(idFactory.getBranchId(destination));
- newVersion.getVersion().setTransactionId(RelationalConstants.TRANSACTION_SENTINEL);
- newVersion.setModType(ModificationType.INTRODUCED);
- newVersion.getVersion().setHistorical(false);
+ updateDataForIntroduce(destination, newVersion);
return newVersion;
}
@Override
- public AttributeData create(HasLocalId parent, IAttributeType attributeType) throws OseeCoreException {
+ public AttributeData create(ArtifactData parent, IAttributeType attributeType) throws OseeCoreException {
VersionData version = objectFactory.createDefaultVersionData();
+ version.setBranchId(parent.getVersion().getBranchId());
ModificationType modType = RelationalConstants.DEFAULT_MODIFICATION_TYPE;
int attributeId = RelationalConstants.DEFAULT_ITEM_ID;
return objectFactory.createAttributeData(version, attributeId, attributeType, modType, parent.getLocalId());
@@ -112,12 +111,8 @@ public class DataFactoryImpl implements DataFactory {
@Override
public AttributeData copy(IOseeBranch destination, AttributeData orcsData) throws OseeCoreException {
- int branchId = idFactory.getBranchId(destination);
AttributeData copy = objectFactory.createCopy(orcsData);
- copy.getVersion().setBranchId(branchId);
- copy.getVersion().setTransactionId(RelationalConstants.TRANSACTION_SENTINEL);
- copy.setModType(ModificationType.NEW);
- copy.getVersion().setHistorical(false);
+ updateDataForCopy(destination, copy);
copy.setLocalId(RelationalConstants.DEFAULT_ITEM_ID);
return copy;
}
@@ -125,16 +120,14 @@ public class DataFactoryImpl implements DataFactory {
@Override
public ArtifactData introduce(IOseeBranch destination, ArtifactData source) throws OseeCoreException {
ArtifactData newVersion = objectFactory.createCopy(source);
- newVersion.getVersion().setBranchId(idFactory.getBranchId(destination));
- newVersion.getVersion().setTransactionId(RelationalConstants.TRANSACTION_SENTINEL);
- newVersion.setModType(ModificationType.INTRODUCED);
- newVersion.getVersion().setHistorical(false);
+ updateDataForIntroduce(destination, newVersion);
return newVersion;
}
@Override
- public RelationData createRelationData(IRelationType relationType, HasLocalId parent, HasLocalId aArt, HasLocalId bArt, String rationale) throws OseeCoreException {
+ public RelationData createRelationData(IRelationType relationType, ArtifactData parent, HasLocalId aArt, HasLocalId bArt, String rationale) throws OseeCoreException {
VersionData version = objectFactory.createDefaultVersionData();
+ version.setBranchId(parent.getVersion().getBranchId());
ModificationType modType = RelationalConstants.DEFAULT_MODIFICATION_TYPE;
int relationId = RelationalConstants.DEFAULT_ITEM_ID;
return objectFactory.createRelationData(version, relationId, relationType, modType, parent.getLocalId(),
@@ -156,4 +149,24 @@ public class DataFactoryImpl implements DataFactory {
return objectFactory.createCopy(source);
}
+ private void updateDataForCopy(IOseeBranch destination, OrcsData data) throws OseeCoreException {
+ VersionData version = data.getVersion();
+ version.setBranchId(idFactory.getBranchId(destination));
+ version.setTransactionId(RelationalConstants.TRANSACTION_SENTINEL);
+ version.setStripeId(RelationalConstants.TRANSACTION_SENTINEL);
+ version.setHistorical(false);
+ version.setGammaId(RelationalConstants.GAMMA_SENTINEL);
+
+ data.setModType(ModificationType.NEW);
+ }
+
+ private void updateDataForIntroduce(IOseeBranch destination, OrcsData data) throws OseeCoreException {
+ VersionData version = data.getVersion();
+ version.setBranchId(idFactory.getBranchId(destination));
+ version.setTransactionId(RelationalConstants.TRANSACTION_SENTINEL);
+ version.setStripeId(RelationalConstants.TRANSACTION_SENTINEL);
+ version.setHistorical(false);
+ // do not clear gammaId for introduce case so we reuse the same version
+ data.setModType(ModificationType.INTRODUCED);
+ }
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectFactoryImpl.java
index 9c87dcc4d96..b4648724b9d 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectFactoryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectFactoryImpl.java
@@ -85,27 +85,27 @@ public class OrcsObjectFactoryImpl implements OrcsObjectFactory {
@Override
public ArtifactData createArtifactData(VersionData version, int localId, int localTypeID, ModificationType modType, String guid, String humanReadableId) throws OseeCoreException {
long typeUuid = toUuid(localTypeID);
- return createArtifactFromRow(version, localId, typeUuid, modType, guid, humanReadableId);
+ return createArtifactFromRow(version, localId, typeUuid, modType, typeUuid, modType, guid, humanReadableId);
}
@Override
public ArtifactData createArtifactData(VersionData version, int localId, IArtifactType type, ModificationType modType, String guid, String humanReadableId) {
long typeUuid = type.getGuid();
- return createArtifactFromRow(version, localId, typeUuid, modType, guid, humanReadableId);
+ return createArtifactFromRow(version, localId, typeUuid, modType, typeUuid, modType, guid, humanReadableId);
}
@Override
public ArtifactData createCopy(ArtifactData source) {
VersionData newVersion = createCopy(source.getVersion());
return createArtifactFromRow(newVersion, source.getLocalId(), source.getTypeUuid(), source.getModType(),
- source.getGuid(), source.getHumanReadableId());
+ source.getLoadedTypeUuid(), source.getLoadedModType(), source.getGuid(), source.getHumanReadableId());
}
@Override
public AttributeData createAttributeData(VersionData version, int localId, int localTypeID, ModificationType modType, int artifactId, String value, String uri) throws OseeCoreException {
long typeId = toUuid(localTypeID);
DataProxy proxy = proxyFactory.createProxy(typeId, value, uri);
- return createAttributeFromRow(version, localId, typeId, modType, artifactId, proxy);
+ return createAttributeFromRow(version, localId, typeId, modType, typeId, modType, artifactId, proxy);
}
@Override
@@ -115,59 +115,59 @@ public class OrcsObjectFactoryImpl implements OrcsObjectFactory {
DataProxy sourceProxy = source.getDataProxy();
DataProxy newProxy = proxyFactory.createProxy(typeId, sourceProxy.getData());
return createAttributeFromRow(newVersion, source.getLocalId(), typeId, source.getModType(),
- source.getArtifactId(), newProxy);
+ source.getLoadedTypeUuid(), source.getLoadedModType(), source.getArtifactId(), newProxy);
}
@Override
public AttributeData createAttributeData(VersionData version, int localId, IAttributeType type, ModificationType modType, int artId) throws OseeCoreException {
long typeId = type.getGuid();
DataProxy proxy = proxyFactory.createProxy(typeId, "", "");
- return createAttributeFromRow(version, localId, typeId, modType, artId, proxy);
+ return createAttributeFromRow(version, localId, typeId, modType, typeId, modType, artId, proxy);
}
@Override
public RelationData createRelationData(VersionData version, int localId, int localTypeID, ModificationType modType, int parentId, int aArtId, int bArtId, String rationale) throws OseeCoreException {
long typeId = toUuid(localTypeID);
- return createRelationData(version, localId, typeId, modType, parentId, aArtId, bArtId, rationale);
+ return createRelationData(version, localId, typeId, modType, typeId, modType, parentId, aArtId, bArtId, rationale);
}
@Override
public RelationData createRelationData(VersionData version, int localId, IRelationType type, ModificationType modType, int parentId, int aArtId, int bArtId, String rationale) {
long typeId = type.getGuid();
- return createRelationData(version, localId, typeId, modType, parentId, aArtId, bArtId, rationale);
+ return createRelationData(version, localId, typeId, modType, typeId, modType, parentId, aArtId, bArtId, rationale);
}
- private ArtifactData createArtifactFromRow(VersionData version, int localId, long type, ModificationType modType, String guid, String humanReadableId) {
+ private ArtifactData createArtifactFromRow(VersionData version, int localId, long localTypeID, ModificationType modType, long loadedLocalTypeID, ModificationType loadedModType, String guid, String humanReadableId) {
ArtifactData data = new ArtifactDataImpl(version);
data.setLocalId(localId);
- data.setLoadedTypeUuid(type);
- data.setTypeUuid(type);
+ data.setTypeUuid(localTypeID);
+ data.setLoadedTypeUuid(loadedLocalTypeID);
data.setModType(modType);
- data.setLoadedModType(modType);
+ data.setLoadedModType(loadedModType);
data.setGuid(guid);
data.setHumanReadableId(humanReadableId);
return data;
}
- private AttributeData createAttributeFromRow(VersionData version, int localId, long localTypeID, ModificationType modType, int artifactId, DataProxy proxy) {
+ private AttributeData createAttributeFromRow(VersionData version, int localId, long localTypeID, ModificationType modType, long loadedLocalTypeID, ModificationType loadedModType, int artifactId, DataProxy proxy) {
AttributeData data = new AttributeDataImpl(version);
data.setLocalId(localId);
data.setTypeUuid(localTypeID);
- data.setLoadedTypeUuid(localTypeID);
+ data.setLoadedTypeUuid(loadedLocalTypeID);
data.setModType(modType);
- data.setLoadedModType(modType);
+ data.setLoadedModType(loadedModType);
data.setArtifactId(artifactId);
data.setDataProxy(proxy);
return data;
}
- private RelationData createRelationData(VersionData version, int localId, long localTypeID, ModificationType modType, int parentId, int aArtId, int bArtId, String rationale) {
+ private RelationData createRelationData(VersionData version, int localId, long localTypeID, ModificationType modType, long loadedLocalTypeID, ModificationType loadedModType, int parentId, int aArtId, int bArtId, String rationale) {
RelationData data = new RelationDataImpl(version);
data.setLocalId(localId);
data.setTypeUuid(localTypeID);
- data.setLoadedTypeUuid(localTypeID);
+ data.setLoadedTypeUuid(loadedLocalTypeID);
data.setModType(modType);
- data.setLoadedModType(modType);
+ data.setLoadedModType(loadedModType);
data.setParentId(parentId);
data.setArtIdA(aArtId);
data.setArtIdB(bArtId);
@@ -179,7 +179,8 @@ public class OrcsObjectFactoryImpl implements OrcsObjectFactory {
public RelationData createCopy(RelationData source) {
VersionData newVersion = createCopy(source.getVersion());
return createRelationData(newVersion, source.getLocalId(), source.getTypeUuid(), source.getModType(),
- source.getParentId(), source.getArtIdA(), source.getArtIdB(), source.getRationale());
+ source.getLoadedTypeUuid(), source.getLoadedModType(), source.getParentId(), source.getArtIdA(),
+ source.getArtIdB(), source.getRationale());
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderImpl.java
index 0933918acf4..20fd8972ab2 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderImpl.java
@@ -104,16 +104,18 @@ public class TxSqlBuilderImpl implements OrcsVisitor, TxSqlBuilder {
@Override
public void visit(ArtifactData data) throws OseeCoreException {
- if (!isNewAndDeleted(data) && (!data.getVersion().isInStorage() || data.getLoadedTypeUuid() != data.getTypeUuid() || data.getModType() != data.getLoadedModType() || data.getModType() == ModificationType.REPLACED_WITH_VERSION)) {
- boolean isRowAllowed = isGammaCreationAllowed(data);
- updateTxValues(data);
- if (isRowAllowed) {
- updateGamma(data);
- int localTypeId = getLocalTypeId(data.getTypeUuid());
- addRow(SqlOrderEnum.ARTIFACTS, data.getLocalId(), localTypeId, data.getVersion().getGammaId(),
- data.getGuid(), data.getHumanReadableId());
+ if (!isNewAndDeleted(data)) {
+ if (!data.getVersion().isInStorage() || data.getLoadedTypeUuid() != data.getTypeUuid() || data.getModType() != data.getLoadedModType() || data.getModType() == ModificationType.REPLACED_WITH_VERSION) {
+ boolean isRowAllowed = isGammaCreationAllowed(data);
+ updateTxValues(data);
+ if (isRowAllowed) {
+ updateGamma(data);
+ int localTypeId = getLocalTypeId(data.getTypeUuid());
+ addRow(SqlOrderEnum.ARTIFACTS, data.getLocalId(), localTypeId, data.getVersion().getGammaId(),
+ data.getGuid(), data.getHumanReadableId());
+ }
+ addTxs(SqlOrderEnum.ARTIFACTS, data);
}
- addTxs(SqlOrderEnum.ARTIFACTS, data);
}
}
@@ -143,19 +145,21 @@ public class TxSqlBuilderImpl implements OrcsVisitor, TxSqlBuilder {
@Override
public void visit(RelationData data) throws OseeCoreException {
- boolean isRowAllowed = isGammaCreationAllowed(data);
- updateTxValues(data);
- if (isRowAllowed) {
- updateGamma(data);
- if (RelationalConstants.DEFAULT_ITEM_ID == data.getLocalId()) {
- int localId = idFactory.getNextRelationId();
- data.setLocalId(localId);
+ if (!isNewAndDeleted(data)) {
+ boolean isRowAllowed = isGammaCreationAllowed(data);
+ updateTxValues(data);
+ if (isRowAllowed) {
+ updateGamma(data);
+ if (RelationalConstants.DEFAULT_ITEM_ID == data.getLocalId()) {
+ int localId = idFactory.getNextRelationId();
+ data.setLocalId(localId);
+ }
+ int localTypeId = getLocalTypeId(data.getTypeUuid());
+ addRow(SqlOrderEnum.RELATIONS, data.getLocalId(), localTypeId, data.getVersion().getGammaId(),
+ data.getArtIdA(), data.getArtIdB(), data.getRationale());
}
- int localTypeId = getLocalTypeId(data.getTypeUuid());
- addRow(SqlOrderEnum.RELATIONS, data.getLocalId(), localTypeId, data.getVersion().getGammaId(),
- data.getArtIdA(), data.getArtIdB(), data.getRationale());
+ addTxs(SqlOrderEnum.RELATIONS, data);
}
- addTxs(SqlOrderEnum.RELATIONS, data);
}
private void addTxs(SqlOrderEnum key, OrcsData orcsData) {

Back to the top