Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2011-10-04 16:31:46 +0000
committerRoberto E. Escobar2011-10-04 16:31:46 +0000
commit9529790380ae416579c95e05acb56adfbc785bb0 (patch)
tree3f3e2b1d5f4aecfae4b550ff41b2a33a72f932e6
parent5c1fa34b33e434944f4fdc0b1688bd248783bc1f (diff)
downloadorg.eclipse.osee-9529790380ae416579c95e05acb56adfbc785bb0.tar.gz
org.eclipse.osee-9529790380ae416579c95e05acb56adfbc785bb0.tar.xz
org.eclipse.osee-9529790380ae416579c95e05acb56adfbc785bb0.zip
feature[ats_Q9NLC]: Refactor attribute model
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/META-INF/MANIFEST.MF7
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeClassResolverTest.java147
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactoryTest.java42
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeRowMapperTest.java40
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/TestRelationLoading.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/mocks/MockArtifactQuery.java (renamed from plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/MockArtifactQuery.java)15
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/mocks/MockLog.java (renamed from plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/MockLog.java)15
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/mocks/MockSessionContext.java31
-rw-r--r--plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF14
-rw-r--r--plugins/org.eclipse.osee.orcs.core/OSGI-INF/attribute.class.resolver.xml6
-rw-r--r--plugins/org.eclipse.osee.orcs.core/OSGI-INF/primitive.attribute.class.provider.xml7
-rw-r--r--plugins/org.eclipse.osee.orcs.core/build.properties3
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/AttributeClassProvider.java22
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/annotations/OseeAttribute.java26
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeContainer.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeRowHandler.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/Artifact.java8
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/Attribute.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeClassResolver.java92
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeCollection.java18
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeContainerImpl.java8
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactory.java66
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeRowMapper.java39
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/BooleanAttribute.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/CompressedContentAttribute.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/DateAttribute.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/EnumeratedAttribute.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/FloatingPointAttribute.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/IntegerAttribute.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/JavaObjectAttribute.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/PrimitiveAttributeClassProvider.java39
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/StringAttribute.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/build.properties3
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/AttributeLoader.java18
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/AbstractDataSourceProxy.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/ClobDataProxy.java (renamed from plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/SizeManagedCharacterDataProxy.java)22
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/ResourceDataProxyFactory.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/ResourceHandler.java74
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/Storage.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/UriDataProxy.java26
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/BinaryContentUtils.java84
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/ByteStreamResource.java58
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ReadableAttribute.java2
44 files changed, 789 insertions, 186 deletions
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 79f40d9344d..faf749b2441 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,6 +6,9 @@ Bundle-Version: 0.9.9.qualifier
Bundle-Vendor: Eclipse Open System Engineering Environment
Fragment-Host: org.eclipse.osee.orcs.core
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Import-Package: org.eclipse.core.runtime;version="3.4.0",
+Import-Package: junit.framework;version="4.8.2",
+ org.eclipse.core.runtime;version="3.4.0",
org.eclipse.osee.framework.core.model.cache,
- org.junit;version="4.8.2"
+ org.junit;version="4.8.2",
+ org.junit.runner;version="4.8.2",
+ org.junit.runners;version="4.8.2"
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeClassResolverTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeClassResolverTest.java
new file mode 100644
index 00000000000..4dde5602781
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeClassResolverTest.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * 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.attribute;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.type.AttributeType;
+import org.eclipse.osee.orcs.core.AttributeClassProvider;
+import org.eclipse.osee.orcs.core.internal.attribute.primitives.BooleanAttribute;
+import org.eclipse.osee.orcs.core.internal.attribute.primitives.CompressedContentAttribute;
+import org.eclipse.osee.orcs.core.internal.attribute.primitives.DateAttribute;
+import org.eclipse.osee.orcs.core.internal.attribute.primitives.EnumeratedAttribute;
+import org.eclipse.osee.orcs.core.internal.attribute.primitives.FloatingPointAttribute;
+import org.eclipse.osee.orcs.core.internal.attribute.primitives.IntegerAttribute;
+import org.eclipse.osee.orcs.core.internal.attribute.primitives.JavaObjectAttribute;
+import org.eclipse.osee.orcs.core.internal.attribute.primitives.PrimitiveAttributeClassProvider;
+import org.eclipse.osee.orcs.core.internal.attribute.primitives.StringAttribute;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * Test Case for {@link AttributeClassResolver}
+ *
+ * @author Roberto E. Escobar
+ */
+@RunWith(Parameterized.class)
+public class AttributeClassResolverTest {
+
+ private final String alias;
+ private final Class<? extends Attribute<?>> expected;
+ private AttributeClassResolver resolver;
+
+ public AttributeClassResolverTest(String alias, Class<? extends Attribute<?>> expected) {
+ this.alias = alias;
+ this.expected = expected;
+ }
+
+ @Before
+ public void setup() {
+ resolver = new AttributeClassResolver();
+ PrimitiveAttributeClassProvider provider = new PrimitiveAttributeClassProvider();
+ resolver.addProvider(provider);
+ }
+
+ @Test
+ public void testGetBaseClazzByAlias() {
+ Class<? extends Attribute<?>> actual = resolver.getBaseClazz(alias);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testGetBaseClazzByType() {
+ AttributeType type = createType(alias);
+ Class<? extends Attribute<?>> actual = resolver.getBaseClazz(type);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testRemoveProvider() {
+ Class<? extends Attribute<?>> actual1 = resolver.getBaseClazz(alias);
+ Assert.assertNotNull(actual1);
+
+ AttributeType type = createType(alias);
+ Class<? extends Attribute<?>> actual2 = resolver.getBaseClazz(type);
+
+ Assert.assertNotNull(actual2);
+ Assert.assertEquals(actual1, actual2);
+
+ resolver.removeProvider(new AttributeClassProvider() {
+
+ @Override
+ public List<Class<? extends Attribute<?>>> getClasses() {
+ return Collections.<Class<? extends Attribute<?>>> singletonList(expected);
+ }
+ });
+
+ actual1 = resolver.getBaseClazz(alias);
+ Assert.assertNull(actual1);
+
+ actual2 = resolver.getBaseClazz(type);
+ Assert.assertNull(actual2);
+ }
+
+ @Test(expected = OseeCoreException.class)
+ public void testIsBaseCompatibleException1() throws OseeCoreException {
+ AttributeType type = createType(alias);
+ resolver.isBaseTypeCompatible(null, type);
+ }
+
+ @Test(expected = OseeCoreException.class)
+ public void testIsBaseCompatibleException2() throws OseeCoreException {
+ resolver.isBaseTypeCompatible(expected, null);
+ }
+
+ @Test(expected = OseeCoreException.class)
+ public void testIsBaseCompatibleException3() throws OseeCoreException {
+ AttributeType type2 = createType(alias + "1");
+ resolver.isBaseTypeCompatible(expected, type2);
+ }
+
+ @Test
+ public void testIsBaseCompatible() throws OseeCoreException {
+ AttributeType type1 = createType(alias);
+ boolean result1 = resolver.isBaseTypeCompatible(expected, type1);
+ Assert.assertTrue(result1);
+
+ String other = !alias.equals("BooleanAttribute") ? "BooleanAttribute" : "StringAttribute";
+ AttributeType type2 = createType(other);
+ boolean result2 = resolver.isBaseTypeCompatible(expected, type2);
+ Assert.assertFalse(result2);
+ }
+
+ private static AttributeType createType(String baseType) {
+ return new AttributeType(1L, "dummy", baseType, "", "", "", 1, 1, "", "");
+ }
+
+ @Parameters
+ public static Collection<Object[]> data() {
+ Collection<Object[]> data = new ArrayList<Object[]>();
+
+ data.add(new Object[] {"BooleanAttribute", BooleanAttribute.class});
+ data.add(new Object[] {"CompressedContentAttribute", CompressedContentAttribute.class});
+ data.add(new Object[] {"DateAttribute", DateAttribute.class});
+ data.add(new Object[] {"EnumeratedAttribute", EnumeratedAttribute.class});
+ data.add(new Object[] {"FloatingPointAttribute", FloatingPointAttribute.class});
+ data.add(new Object[] {"IntegerAttribute", IntegerAttribute.class});
+ data.add(new Object[] {"JavaObjectAttribute", JavaObjectAttribute.class});
+ data.add(new Object[] {"StringAttribute", StringAttribute.class});
+
+ return data;
+ }
+}
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
new file mode 100644
index 00000000000..69ce7226602
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactoryTest.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.core.internal.attribute;
+
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.cache.AttributeTypeCache;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.core.ds.AttributeContainer;
+import org.eclipse.osee.orcs.core.ds.AttributeRow;
+import org.eclipse.osee.orcs.core.mocks.MockLog;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Test Case for {@link AttributeFactory}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AttributeFactoryTest {
+
+ @Test
+ @Ignore
+ public void test() throws OseeCoreException {
+ Log logger = new MockLog();
+ AttributeTypeCache cache = null;
+ AttributeClassResolver resolver = null;
+ AttributeFactory factory = new AttributeFactory(logger, resolver, cache);
+
+ AttributeContainer container = null;
+
+ AttributeRow row = new AttributeRow();
+ factory.loadAttribute(container, row);
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeRowMapperTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeRowMapperTest.java
new file mode 100644
index 00000000000..a7827e1bb00
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeRowMapperTest.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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.attribute;
+
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.core.ds.AttributeRow;
+import org.eclipse.osee.orcs.core.internal.SessionContext;
+import org.eclipse.osee.orcs.core.mocks.MockLog;
+import org.eclipse.osee.orcs.core.mocks.MockSessionContext;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Test Case for {@link AttributeRowMapper}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AttributeRowMapperTest {
+
+ @Test
+ @Ignore
+ public void test() throws OseeCoreException {
+ Log logger = new MockLog();
+ SessionContext context = new MockSessionContext();
+ AttributeFactory factory = null;
+ AttributeRow row = new AttributeRow();
+
+ AttributeRowMapper mapper = new AttributeRowMapper(logger, context, factory);
+ mapper.onRow(row);
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/TestRelationLoading.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/TestRelationLoading.java
index 0a6c80360fa..924e4cb3e5f 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/TestRelationLoading.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/TestRelationLoading.java
@@ -16,6 +16,7 @@ import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.core.ds.RelationRow;
+import org.eclipse.osee.orcs.core.mocks.MockLog;
import org.junit.Assert;
import org.junit.Test;
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/MockArtifactQuery.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/mocks/MockArtifactQuery.java
index 48d7ff4d9cc..a906819bdb0 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/MockArtifactQuery.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/mocks/MockArtifactQuery.java
@@ -1,9 +1,14 @@
-/*
- * Created on Sep 30, 2011
+/*******************************************************************************
+ * 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
*
- * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
- */
-package org.eclipse.osee.orcs.core.internal.relation;
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.core.mocks;
import java.util.List;
import java.util.concurrent.Callable;
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/MockLog.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/mocks/MockLog.java
index 16a7bfdd74a..569c28f5f09 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/MockLog.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/mocks/MockLog.java
@@ -1,9 +1,14 @@
-/*
- * Created on Sep 29, 2011
+/*******************************************************************************
+ * 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
*
- * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
- */
-package org.eclipse.osee.orcs.core.internal.relation;
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.core.mocks;
import org.eclipse.osee.logger.Log;
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/mocks/MockSessionContext.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/mocks/MockSessionContext.java
new file mode 100644
index 00000000000..55e666d720e
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/mocks/MockSessionContext.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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.mocks;
+
+import org.eclipse.osee.orcs.core.ds.AttributeContainer;
+import org.eclipse.osee.orcs.core.internal.SessionContext;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class MockSessionContext implements SessionContext {
+
+ @Override
+ public <T extends AttributeContainer> T getHistorical(int artId, int stripeId) {
+ return null;
+ }
+
+ @Override
+ public <T extends AttributeContainer> T getActive(int artId, int branchId) {
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF
index 2531d1e6ed6..7511db0b9d2 100644
--- a/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF
@@ -5,22 +5,18 @@ Bundle-SymbolicName: org.eclipse.osee.orcs.core
Bundle-Version: 0.9.9.qualifier
Bundle-Vendor: Eclipse Open System Engineering Environment
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-<<<<<<< HEAD
+Service-Component: OSGI-INF/*.xml
Import-Package: org.eclipse.osee.framework.core.data,
org.eclipse.osee.framework.core.enums,
org.eclipse.osee.framework.core.exception,
org.eclipse.osee.framework.core.model,
+ org.eclipse.osee.framework.core.model.cache,
org.eclipse.osee.framework.core.model.type,
org.eclipse.osee.framework.core.util,
+ org.eclipse.osee.framework.jdk.core.type,
org.eclipse.osee.framework.jdk.core.util,
org.eclipse.osee.logger,
- org.eclipse.osee.orcs
+ org.eclipse.osee.orcs,
+ org.eclipse.osee.orcs.data
Export-Package: org.eclipse.osee.orcs.core,
org.eclipse.osee.orcs.core.ds
-=======
-Import-Package: org.osgi.framework;version="1.3.0"
-Require-Bundle: org.eclipse.osee.framework.core,
- org.eclipse.osee.orcs,
- org.eclipse.osee.framework.core.model,
- org.eclipse.osee.framework.jdk.core
->>>>>>> bd229ed... feature[ats_8KF8L]: Get programs and builds web backend
diff --git a/plugins/org.eclipse.osee.orcs.core/OSGI-INF/attribute.class.resolver.xml b/plugins/org.eclipse.osee.orcs.core/OSGI-INF/attribute.class.resolver.xml
new file mode 100644
index 00000000000..bea44d27e1b
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/OSGI-INF/attribute.class.resolver.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" name="org.eclipse.osee.orcs.core.internal.attribute.AttributeClassResolver">
+ <implementation class="org.eclipse.osee.orcs.core.internal.attribute.AttributeClassResolver"/>
+ <reference interface="org.eclipse.osee.logger.Log" name="Log" cardinality="1..1" policy="static" bind="setLogger" />
+ <reference bind="addProvider" cardinality="1..n" interface="org.eclipse.osee.orcs.core.AttributeClassProvider" name="AttributeClassProvider" policy="dynamic" unbind="removeProvider"/>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.orcs.core/OSGI-INF/primitive.attribute.class.provider.xml b/plugins/org.eclipse.osee.orcs.core/OSGI-INF/primitive.attribute.class.provider.xml
new file mode 100644
index 00000000000..ac00b374bee
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/OSGI-INF/primitive.attribute.class.provider.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.osee.orcs.core.internal.attribute.primitives.PrimitiveAttributeClassProvider">
+ <implementation class="org.eclipse.osee.orcs.core.internal.attribute.primitives.PrimitiveAttributeClassProvider"/>
+ <service>
+ <provide interface="org.eclipse.osee.orcs.core.AttributeClassProvider"/>
+ </service>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.orcs.core/build.properties b/plugins/org.eclipse.osee.orcs.core/build.properties
index 3073692d885..d50d24b6ac0 100644
--- a/plugins/org.eclipse.osee.orcs.core/build.properties
+++ b/plugins/org.eclipse.osee.orcs.core/build.properties
@@ -1,7 +1,8 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
- .
+ .,\
+ OSGI-INF/
additional.bundles = org.eclipse.osee.logger,\
org.eclipse.osee.orcs,\
org.eclipse.osee.framework.core,\
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/AttributeClassProvider.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/AttributeClassProvider.java
new file mode 100644
index 00000000000..ed157901724
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/AttributeClassProvider.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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;
+
+import java.util.List;
+import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface AttributeClassProvider {
+
+ List<Class<? extends Attribute<?>>> getClasses();
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/annotations/OseeAttribute.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/annotations/OseeAttribute.java
new file mode 100644
index 00000000000..03f5f255a86
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/annotations/OseeAttribute.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface OseeAttribute {
+
+ String value();
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeContainer.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeContainer.java
index cfae9b497a9..25796f6fd04 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeContainer.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeContainer.java
@@ -15,6 +15,7 @@ import java.util.List;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
+import org.eclipse.osee.orcs.data.ReadableAttribute;
/**
* @author Roberto E. Escobar
@@ -27,7 +28,9 @@ public interface AttributeContainer {
Collection<IAttributeType> getAttributeTypes() throws OseeCoreException;
- <T> List<Attribute<T>> getAttributes(IAttributeType attributeType) throws OseeCoreException;
+ <T> List<ReadableAttribute<T>> getAttributes(IAttributeType attributeType) throws OseeCoreException;
+
+ <T> ReadableAttribute<T> getSoleAttribute(IAttributeType attributeType) throws OseeCoreException;
//TODO is this needed
boolean isLoaded();
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeRowHandler.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeRowHandler.java
index 16d2b8bdc3a..acb2d986f9e 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeRowHandler.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeRowHandler.java
@@ -10,12 +10,11 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.ds;
-import java.util.List;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
/**
* @author Roberto E. Escobar
*/
public interface AttributeRowHandler {
- void onRow(List<AttributeRow> rows) throws OseeCoreException;
+ void onRow(AttributeRow row) throws OseeCoreException;
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/Artifact.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/Artifact.java
index d6676e042f1..a3045d69a88 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/Artifact.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/Artifact.java
@@ -17,6 +17,7 @@ import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.orcs.core.ds.AttributeContainer;
import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
+import org.eclipse.osee.orcs.data.ReadableAttribute;
public class Artifact implements AttributeContainer {
// Place-holder
@@ -44,7 +45,7 @@ public class Artifact implements AttributeContainer {
}
@Override
- public <T> List<Attribute<T>> getAttributes(IAttributeType attributeType) throws OseeCoreException {
+ public <T> List<ReadableAttribute<T>> getAttributes(IAttributeType attributeType) throws OseeCoreException {
return null;
}
@@ -56,4 +57,9 @@ public class Artifact implements AttributeContainer {
@Override
public void setLoaded(boolean value) {
}
+
+ @Override
+ public <T> ReadableAttribute<T> getSoleAttribute(IAttributeType attributeType) throws OseeCoreException {
+ return null;
+ }
}
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 5a49ce915b3..e5bd995c391 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
@@ -222,6 +222,7 @@ public abstract class Attribute<T> implements Comparable<Attribute<T>>, Writable
*
* @return whether this attribute's type or any of its super-types are the specified type
*/
+ @Override
public boolean isOfType(IAttributeType otherAttributeType) {
return getAttributeType().equals(otherAttributeType);
}
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
new file mode 100644
index 00000000000..1cbe5f9ee4a
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeClassResolver.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * 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.attribute;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.type.AttributeType;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.core.AttributeClassProvider;
+import org.eclipse.osee.orcs.core.annotations.OseeAttribute;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AttributeClassResolver {
+
+ private final Map<String, Class<? extends Attribute<?>>> map =
+ new ConcurrentHashMap<String, Class<? extends Attribute<?>>>();
+
+ private Log logger;
+
+ public void setLogger(Log logger) {
+ this.logger = logger;
+ }
+
+ public Log getLogger() {
+ return logger;
+ }
+
+ public void start() {
+ // Nothing yet;
+ }
+
+ public void stop() {
+ // Nothing yet;
+ }
+
+ public void addProvider(AttributeClassProvider provider) {
+ for (Class<? extends Attribute<?>> clazz : provider.getClasses()) {
+ String alias = toAlias(clazz);
+ map.put(alias, clazz);
+ }
+ }
+
+ public void removeProvider(AttributeClassProvider provider) {
+ for (Class<? extends Attribute<?>> clazz : provider.getClasses()) {
+ String alias = toAlias(clazz);
+ map.remove(alias);
+ }
+ }
+
+ private String toAlias(Class<? extends Attribute<?>> clazz) {
+ OseeAttribute annotation = clazz.getAnnotation(OseeAttribute.class);
+ String toReturn;
+ if (annotation != null) {
+ toReturn = annotation.value();
+ } else {
+ toReturn = clazz.getSimpleName();
+ logger.warn("Unable to find OseeAttribute annotation for [%s] - registering using clazz simple name [%s]",
+ clazz, toReturn);
+ }
+ return toReturn;
+ }
+
+ public Class<? extends Attribute<?>> getBaseClazz(String alias) {
+ return map.get(alias);
+ }
+
+ public Class<? extends Attribute<?>> getBaseClazz(AttributeType attributeType) {
+ String alias = attributeType.getBaseAttributeTypeId();
+ return getBaseClazz(alias);
+ }
+
+ public boolean isBaseTypeCompatible(Class<? extends Attribute<?>> baseType, AttributeType attributeType) throws OseeCoreException {
+ Conditions.checkNotNull(baseType, "baseType", "Unable to determine base type from null");
+ Conditions.checkNotNull(attributeType, "attributeType");
+ Class<? extends Attribute<?>> clazz = getBaseClazz(attributeType);
+ Conditions.checkNotNull(clazz, "base attribute type class", "Unable to find base attribute type class for [%s]",
+ attributeType);
+ return baseType.isAssignableFrom(clazz);
+ }
+}
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 face1edcfd8..89cf6cf6528 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
@@ -1,8 +1,13 @@
-/*
- * Created on Oct 3, 2011
+/*******************************************************************************
+ * 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
*
- * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
- */
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
package org.eclipse.osee.orcs.core.internal.attribute;
import java.util.ArrayList;
@@ -16,6 +21,9 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.HashCollection;
import org.eclipse.osee.framework.jdk.core.util.Collections;
+/**
+ * @author Roberto E. Escobar
+ */
public class AttributeCollection {
private final HashCollection<IAttributeType, Attribute<?>> attributes =
@@ -49,7 +57,7 @@ public class AttributeCollection {
return filteredList;
}
- public <T> List<Attribute<T>> getCurrentAttributesFor(IAttributeType type) throws OseeCoreException {
+ public <T> List<T> getCurrentAttributesFor(IAttributeType type) throws OseeCoreException {
return Collections.castAll(getAttributesByModificationType(type, ModificationType.getCurrentModTypes()));
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeContainerImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeContainerImpl.java
index 4d115e9bfb4..5a9c33ee3ba 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeContainerImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeContainerImpl.java
@@ -15,6 +15,7 @@ import java.util.List;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.orcs.core.ds.AttributeContainer;
+import org.eclipse.osee.orcs.data.ReadableAttribute;
/**
* @author Roberto E. Escobar
@@ -59,7 +60,7 @@ public class AttributeContainerImpl implements AttributeContainer {
}
@Override
- public <T> List<Attribute<T>> getAttributes(IAttributeType type) throws OseeCoreException {
+ public <T> List<ReadableAttribute<T>> getAttributes(IAttributeType type) throws OseeCoreException {
ensureAttributesLoaded();
return collection.getCurrentAttributesFor(type);
}
@@ -69,4 +70,9 @@ public class AttributeContainerImpl implements AttributeContainer {
// ArtifactLoader.loadArtifactData(this, LoadLevel.ATTRIBUTE);
// }
}
+
+ @Override
+ public <T> ReadableAttribute<T> getSoleAttribute(IAttributeType attributeType) throws OseeCoreException {
+ return null;
+ }
}
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 321988c6c3a..eb1bcce4b1c 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
@@ -12,70 +12,54 @@ package org.eclipse.osee.orcs.core.internal.attribute;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
-import java.util.HashMap;
-import java.util.Map;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
-import org.eclipse.osee.framework.core.model.cache.AttributeTypeCache;
+import org.eclipse.osee.framework.core.model.cache.IOseeCache;
import org.eclipse.osee.framework.core.model.type.AttributeType;
+import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.core.ds.AttributeContainer;
import org.eclipse.osee.orcs.core.ds.AttributeRow;
import org.eclipse.osee.orcs.core.ds.DataProxy;
-import org.eclipse.osee.orcs.core.internal.attribute.primitives.BooleanAttribute;
-import org.eclipse.osee.orcs.core.internal.attribute.primitives.CompressedContentAttribute;
-import org.eclipse.osee.orcs.core.internal.attribute.primitives.DateAttribute;
-import org.eclipse.osee.orcs.core.internal.attribute.primitives.EnumeratedAttribute;
-import org.eclipse.osee.orcs.core.internal.attribute.primitives.FloatingPointAttribute;
-import org.eclipse.osee.orcs.core.internal.attribute.primitives.IntegerAttribute;
-import org.eclipse.osee.orcs.core.internal.attribute.primitives.JavaObjectAttribute;
-import org.eclipse.osee.orcs.core.internal.attribute.primitives.StringAttribute;
/**
* @author Roberto E. Escobar
*/
public class AttributeFactory {
- private final Map<String, Class<? extends Attribute<?>>> primitiveAttributes =
- new HashMap<String, Class<? extends Attribute<?>>>();
+ private final AttributeClassResolver classResolver;
+ private final IOseeCache<Long, AttributeType> cache;
- private final AttributeTypeCache attributeTypeCache;
-
- public AttributeFactory(Log logger, AttributeTypeCache attributeTypeCache) {
- this.attributeTypeCache = attributeTypeCache;
-
- primitiveAttributes.put("", BooleanAttribute.class);
- primitiveAttributes.put("", IntegerAttribute.class);
- primitiveAttributes.put("", FloatingPointAttribute.class);
- primitiveAttributes.put("", StringAttribute.class);
- primitiveAttributes.put("", DateAttribute.class);
- primitiveAttributes.put("", EnumeratedAttribute.class);
- primitiveAttributes.put("", JavaObjectAttribute.class);
- primitiveAttributes.put("", CompressedContentAttribute.class);
+ public AttributeFactory(Log logger, AttributeClassResolver classResolver, IOseeCache<Long, AttributeType> cache) {
+ this.classResolver = classResolver;
+ this.cache = cache;
}
public <T> void loadAttribute(AttributeContainer container, AttributeRow row) throws OseeCoreException {
- AttributeType attributeType = attributeTypeCache.getByGuid(row.getAttrTypeUuid());
+ AttributeType type = cache.getByGuid(row.getAttrTypeUuid());
+ Conditions.checkNotNull(type, "attributeType", "Cannot find attribute type with uuid[%s]", row.getAttrTypeUuid());
+
boolean markDirty = false;
- Class<? extends Attribute<T>> attributeClass = null;
+ Class<? extends Attribute<?>> attributeClass = classResolver.getBaseClazz(type);
Attribute<T> attribute = createAttribute(attributeClass);
- container.add(attributeType, attribute);
- Reference<AttributeContainer> artifactRef = new WeakReference<AttributeContainer>(container);
- DataProxy proxy = row.getDataProxy();
- attribute.internalInitialize(attributeType, proxy, artifactRef, row.getModType(), row.getAttrId(),
- row.getGammaId(), markDirty, false);
+ DataProxy proxy = row.getDataProxy();
+ Reference<AttributeContainer> artifactRef = new WeakReference<AttributeContainer>(container);
+ attribute.internalInitialize(type, proxy, artifactRef, row.getModType(), row.getAttrId(), row.getGammaId(),
+ markDirty, false);
+ container.add(type, attribute);
}
/**
* Creates an instance of <code>Attribute</code> of the given attribute type. This method should not be called by
* applications. Use addAttribute() instead
*/
- private <T> Attribute<T> createAttribute(Class<? extends Attribute<T>> attributeClass) throws OseeCoreException {
+ @SuppressWarnings("unchecked")
+ private <T> Attribute<T> createAttribute(Class<? extends Attribute<?>> attributeClass) throws OseeCoreException {
Attribute<T> attribute = null;
try {
- attribute = attributeClass.newInstance();
+ attribute = (Attribute<T>) attributeClass.newInstance();
} catch (InstantiationException ex) {
OseeExceptions.wrapAndThrow(ex);
} catch (IllegalAccessException ex) {
@@ -83,16 +67,4 @@ public class AttributeFactory {
}
return attribute;
}
-
- // public static boolean isBaseTypeCompatible(Class<? extends Attribute> baseType, IAttributeType attributeType) throws OseeCoreException {
- // return baseType.isAssignableFrom(getAttributeBaseClass(attributeType));
- // }
- //
- // public static Class<? extends Attribute<?>> getAttributeBaseClass(IAttributeType attributeType) throws OseeCoreException {
- // return AttributeExtensionManager.getAttributeClassFor(getType(attributeType).getBaseAttributeTypeId());
- // }
- //
- // public static Class<? extends IAttributeDataProvider> getAttributeProviderClass(AttributeType attributeType) throws OseeCoreException {
- // return AttributeExtensionManager.getAttributeProviderClassFor(attributeType.getAttributeProviderId());
- // }
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeRowMapper.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeRowMapper.java
index 294ec5d2882..de215d0d0bf 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeRowMapper.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeRowMapper.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.attribute;
-import java.util.List;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.core.ds.AttributeContainer;
@@ -47,28 +46,28 @@ public class AttributeRowMapper implements AttributeRowHandler {
}
@Override
- public void onRow(List<AttributeRow> rows) throws OseeCoreException {
- AttributeContainer container = getContainer(rows.get(0));
+ public void onRow(AttributeRow row) throws OseeCoreException {
+ AttributeContainer container = getContainer(row);
if (container == null) {
return; // If the artifact is null, it means the attributes are orphaned.
}
- AttributeRow previous = new AttributeRow();
- synchronized (container) {
- if (!container.isLoaded()) {
- // int maxTransactionId = Integer.MIN_VALUE;
- for (AttributeRow current : rows) {
- if (previous.isSameAttribute(current)) {
- handleMultipleVersions(previous, current);
- } else {
- factory.loadAttribute(container, current);
- }
- previous = current;
- // maxTransactionId = Math.max(maxTransactionId, current.getTransactionId());
- }
- // getContainer().setTransactionId(maxTransactionId);
- container.setLoaded(true);
- }
- }
+ // AttributeRow previous = new AttributeRow();
+ // synchronized (container) {
+ // if (!container.isLoaded()) {
+ // // int maxTransactionId = Integer.MIN_VALUE;
+ // for (AttributeRow current : rows) {
+ // if (previous.isSameAttribute(current)) {
+ // handleMultipleVersions(previous, current);
+ // } else {
+ // factory.loadAttribute(container, current);
+ // }
+ // previous = current;
+ // // maxTransactionId = Math.max(maxTransactionId, current.getTransactionId());
+ // }
+ // // getContainer().setTransactionId(maxTransactionId);
+ // container.setLoaded(true);
+ // }
+ // }
}
private void handleMultipleVersions(AttributeRow previous, AttributeRow current) {
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/BooleanAttribute.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/BooleanAttribute.java
index 4cfc1703b9d..f4fe07e553e 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/BooleanAttribute.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/BooleanAttribute.java
@@ -11,11 +11,13 @@
package org.eclipse.osee.orcs.core.internal.attribute.primitives;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.core.annotations.OseeAttribute;
import org.eclipse.osee.orcs.core.internal.attribute.CharacterBackedAttribute;
/**
* @author Ryan D. Brooks
*/
+@OseeAttribute("BooleanAttribute")
public class BooleanAttribute extends CharacterBackedAttribute<Boolean> {
public static final String[] booleanChoices = new String[] {"yes", "no"};
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/CompressedContentAttribute.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/CompressedContentAttribute.java
index c0d47ffa173..f0e14ae07bd 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/CompressedContentAttribute.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/CompressedContentAttribute.java
@@ -17,7 +17,9 @@ import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.orcs.core.annotations.OseeAttribute;
+@OseeAttribute("CompressedContentAttribute")
public final class CompressedContentAttribute extends BinaryAttribute<InputStream> {
@Override
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/DateAttribute.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/DateAttribute.java
index f52d1070a6b..9d488b39c1d 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/DateAttribute.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/DateAttribute.java
@@ -16,12 +16,14 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.orcs.core.annotations.OseeAttribute;
import org.eclipse.osee.orcs.core.internal.attribute.CharacterBackedAttribute;
/**
* @author Robert A. Fisher
* @author Ryan D. Brooks
*/
+@OseeAttribute("DateAttribute")
public class DateAttribute extends CharacterBackedAttribute<Date> {
public static final DateFormat MMDDYY = new SimpleDateFormat("MM/dd/yyyy");
public static final DateFormat HHMM = new SimpleDateFormat("hh:mm");
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/EnumeratedAttribute.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/EnumeratedAttribute.java
index b81e706e904..7cbd40e2e23 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/EnumeratedAttribute.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/EnumeratedAttribute.java
@@ -12,10 +12,12 @@ package org.eclipse.osee.orcs.core.internal.attribute.primitives;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.orcs.core.annotations.OseeAttribute;
/**
* @author Ryan D. Brooks
*/
+@OseeAttribute("EnumeratedAttribute")
public class EnumeratedAttribute extends StringAttribute {
// When an enumerated attribute is required for an artifact, yet doesn't exist yet, it is created upon
// init of the artifact and given the "Unspecified" value
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/FloatingPointAttribute.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/FloatingPointAttribute.java
index e6cda3a63b7..12ead44af38 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/FloatingPointAttribute.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/FloatingPointAttribute.java
@@ -13,11 +13,13 @@ package org.eclipse.osee.orcs.core.internal.attribute.primitives;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.orcs.core.annotations.OseeAttribute;
import org.eclipse.osee.orcs.core.internal.attribute.CharacterBackedAttribute;
/**
* @author Ryan D. Brooks
*/
+@OseeAttribute("FloatingPointAttribute")
public class FloatingPointAttribute extends CharacterBackedAttribute<Double> {
private static final Double DEFAULT_DOUBLE = Double.MIN_VALUE;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/IntegerAttribute.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/IntegerAttribute.java
index 7fdc93c8392..1629ee9f500 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/IntegerAttribute.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/IntegerAttribute.java
@@ -13,11 +13,13 @@ package org.eclipse.osee.orcs.core.internal.attribute.primitives;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.orcs.core.annotations.OseeAttribute;
import org.eclipse.osee.orcs.core.internal.attribute.CharacterBackedAttribute;
/**
* @author Ryan D. Brooks
*/
+@OseeAttribute("IntegerAttribute")
public class IntegerAttribute extends CharacterBackedAttribute<Integer> {
private static final Integer DEFAULT_INTEGER = Integer.MIN_VALUE;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/JavaObjectAttribute.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/JavaObjectAttribute.java
index 869cf0904b4..f8801d74a46 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/JavaObjectAttribute.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/JavaObjectAttribute.java
@@ -18,7 +18,9 @@ import java.io.ObjectOutputStream;
import java.nio.ByteBuffer;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.orcs.core.annotations.OseeAttribute;
+@OseeAttribute("JavaObjectAttribute")
public final class JavaObjectAttribute extends BinaryAttribute<Object> {
@Override
public Object getValue() throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/PrimitiveAttributeClassProvider.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/PrimitiveAttributeClassProvider.java
new file mode 100644
index 00000000000..0fcbe00b402
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/PrimitiveAttributeClassProvider.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * 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.attribute.primitives;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.osee.orcs.core.AttributeClassProvider;
+import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class PrimitiveAttributeClassProvider implements AttributeClassProvider {
+
+ @Override
+ public List<Class<? extends Attribute<?>>> getClasses() {
+ List<Class<? extends Attribute<?>>> clazzes = new ArrayList<Class<? extends Attribute<?>>>();
+
+ clazzes.add(BooleanAttribute.class);
+ clazzes.add(IntegerAttribute.class);
+ clazzes.add(FloatingPointAttribute.class);
+ clazzes.add(StringAttribute.class);
+ clazzes.add(DateAttribute.class);
+ clazzes.add(EnumeratedAttribute.class);
+ clazzes.add(JavaObjectAttribute.class);
+ clazzes.add(CompressedContentAttribute.class);
+ // primitiveAttributes.put("WordAttribute", WordAttribute.class);
+
+ return clazzes;
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/StringAttribute.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/StringAttribute.java
index f841d1f192a..20bea28ee8f 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/StringAttribute.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/primitives/StringAttribute.java
@@ -11,11 +11,13 @@
package org.eclipse.osee.orcs.core.internal.attribute.primitives;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.core.annotations.OseeAttribute;
import org.eclipse.osee.orcs.core.internal.attribute.CharacterBackedAttribute;
/**
* @author Ryan D. Brooks
*/
+@OseeAttribute("StringAttribute")
public class StringAttribute extends CharacterBackedAttribute<String> {
@Override
public String getValue() throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF
index df0c2b0a395..d1d57960b4c 100644
--- a/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF
@@ -7,6 +7,7 @@ Bundle-Vendor: Eclipse Open System Engineering Environment
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Service-Component: OSGI-INF/*.xml
Import-Package: org.eclipse.core.runtime;version="3.4.0",
+ org.eclipse.osee.framework.core.data,
org.eclipse.osee.framework.core.enums,
org.eclipse.osee.framework.core.exception,
org.eclipse.osee.framework.core.model.cache,
@@ -21,4 +22,5 @@ Import-Package: org.eclipse.core.runtime;version="3.4.0",
org.eclipse.osee.logger,
org.eclipse.osee.orcs.core,
org.eclipse.osee.orcs.core.ds,
+ org.eclipse.osee.orcs.data,
org.osgi.framework;version="1.6.0"
diff --git a/plugins/org.eclipse.osee.orcs.db/build.properties b/plugins/org.eclipse.osee.orcs.db/build.properties
index c75b69b4df3..3cb0a58364f 100644
--- a/plugins/org.eclipse.osee.orcs.db/build.properties
+++ b/plugins/org.eclipse.osee.orcs.db/build.properties
@@ -9,4 +9,5 @@ additional.bundles = org.eclipse.osee.framework.database,\
org.eclipse.osee.framework.jdk.core,\
org.eclipse.osee.framework.core,\
org.eclipse.osee.framework.resource.management,\
- org.eclipse.osee.framework.core.model
+ org.eclipse.osee.framework.core.model,\
+ org.eclipse.osee.orcs
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/AttributeLoader.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/AttributeLoader.java
index a17a07bc4c7..e959cee4d06 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/AttributeLoader.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/AttributeLoader.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.loader;
-import java.util.ArrayList;
-import java.util.List;
import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.services.IdentityService;
@@ -70,12 +68,7 @@ public class AttributeLoader {
try {
chStmt.runPreparedQuery(fetchSize, sql, queryId);
- AttributeRow previousAttr = new AttributeRow();
-
- List<AttributeRow> currentAttributes = new ArrayList<AttributeRow>();
while (chStmt.next()) {
- int modId = chStmt.getInt("mod_type");
-
AttributeRow nextAttr = new AttributeRow();
nextAttr.setArtifactId(chStmt.getInt("art_id"));
nextAttr.setBranchId(chStmt.getInt("branch_id"));
@@ -83,6 +76,8 @@ public class AttributeLoader {
nextAttr.setGammaId(chStmt.getInt("gamma_id"));
nextAttr.setTransactionId(chStmt.getInt("transaction_id"));
nextAttr.setAttrTypeUuid(toUuid(chStmt.getInt("attr_type_id")));
+
+ int modId = chStmt.getInt("mod_type");
nextAttr.setModType(ModificationType.getMod(modId));
nextAttr.setHistorical(options.isHistorical());
@@ -95,15 +90,8 @@ public class AttributeLoader {
if (options.isHistorical()) {
nextAttr.setStripeId(chStmt.getInt("stripe_transaction_id"));
}
-
- if (!previousAttr.isSameArtifact(nextAttr)) {
- handler.onRow(currentAttributes);
- currentAttributes.clear();
- }
- currentAttributes.add(nextAttr);
- previousAttr = nextAttr;
+ handler.onRow(nextAttr);
}
- handler.onRow(currentAttributes);
} finally {
chStmt.close();
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/AbstractDataSourceProxy.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/AbstractDataSourceProxy.java
index 69d4ccfb9ca..bff1f5e2526 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/AbstractDataSourceProxy.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/AbstractDataSourceProxy.java
@@ -16,14 +16,14 @@ import org.eclipse.osee.orcs.core.ds.DataProxy;
* @author Roberto E. Escobar
*/
public abstract class AbstractDataSourceProxy implements DataProxy {
- private final Storage dataStore;
+ private final Storage storage;
- public AbstractDataSourceProxy(Storage dataStore) {
+ public AbstractDataSourceProxy(Storage storage) {
super();
- this.dataStore = dataStore;
+ this.storage = storage;
}
- protected Storage getDataStore() {
- return dataStore;
+ protected Storage getStorage() {
+ return storage;
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/SizeManagedCharacterDataProxy.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/ClobDataProxy.java
index 13a4a4319f3..bfc3c79be27 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/SizeManagedCharacterDataProxy.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/ClobDataProxy.java
@@ -20,13 +20,13 @@ import org.eclipse.osee.orcs.core.ds.CharacterDataProxy;
/**
* @author Roberto E. Escobar
*/
-public class SizeManagedCharacterDataProxy extends AbstractDataSourceProxy implements CharacterDataProxy {
+public class ClobDataProxy extends AbstractDataSourceProxy implements CharacterDataProxy {
public static final int MAX_VARCHAR_LENGTH = 4000;
private String rawStringValue;
- public SizeManagedCharacterDataProxy(Storage dataStore) {
- super(dataStore);
+ public ClobDataProxy(Storage storage) {
+ super(storage);
this.rawStringValue = "";
}
@@ -45,7 +45,7 @@ public class SizeManagedCharacterDataProxy extends AbstractDataSourceProxy imple
String fromStorage = null;
byte[] data = null;
try {
- data = getDataStore().getContent();
+ data = getStorage().getContent();
if (data != null) {
data = Lib.decompressBytes(new ByteArrayInputStream(data));
fromStorage = new String(data, "UTF-8");
@@ -73,38 +73,38 @@ public class SizeManagedCharacterDataProxy extends AbstractDataSourceProxy imple
if (value != null && value.length() > MAX_VARCHAR_LENGTH) {
try {
byte[] compressed =
- Lib.compressStream(new ByteArrayInputStream(value.getBytes("UTF-8")), getDataStore().getFileName());
- getDataStore().setContent(compressed, "zip", "application/zip", "ISO-8859-1");
+ Lib.compressStream(new ByteArrayInputStream(value.getBytes("UTF-8")), getStorage().getFileName());
+ getStorage().setContent(compressed, "zip", "application/zip", "ISO-8859-1");
this.rawStringValue = "";
} catch (IOException ex) {
OseeExceptions.wrapAndThrow(ex);
}
} else {
this.rawStringValue = value;
- getDataStore().clear();
+ getStorage().clear();
}
}
@Override
public Object[] getData() {
- return new Object[] {rawStringValue, getDataStore().getLocator()};
+ return new Object[] {rawStringValue, getStorage().getLocator()};
}
@Override
public void loadData(Object... objects) throws OseeCoreException {
if (objects != null && objects.length > 1) {
storeValue((String) objects[0]);
- getDataStore().setLocator((String) objects[1]);
+ getStorage().setLocator((String) objects[1]);
}
}
@Override
public void persist(int storageId) throws OseeCoreException {
- getDataStore().persist(storageId);
+ getStorage().persist(storageId);
}
@Override
public void purge() throws OseeCoreException {
- getDataStore().purge();
+ getStorage().purge();
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/ResourceDataProxyFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/ResourceDataProxyFactory.java
index 7020ad61dd6..9c3601ba41a 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/ResourceDataProxyFactory.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/ResourceDataProxyFactory.java
@@ -74,8 +74,8 @@ public class ResourceDataProxyFactory implements DataProxyFactory {
}
Conditions.checkNotNull(factoryAliases, "PROXY_FACTORY_ALIAS");
- proxyClassMap.put("DefaultAttributeDataProvider", SizeManagedCharacterDataProxy.class);
- proxyClassMap.put("ClobAttributeDataProvider", SizeManagedCharacterDataProxy.class);
+ proxyClassMap.put("DefaultAttributeDataProvider", ClobDataProxy.class);
+ proxyClassMap.put("ClobAttributeDataProvider", ClobDataProxy.class);
proxyClassMap.put("UriAttributeDataProvider", UriDataProxy.class);
proxyClassMap.put("MappedAttributeDataProvider", MappedFileDataProxy.class);
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/ResourceHandler.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/ResourceHandler.java
index a94afc54773..d401b8454f2 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/ResourceHandler.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/ResourceHandler.java
@@ -14,13 +14,16 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URLConnection;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.resource.management.IResource;
import org.eclipse.osee.framework.resource.management.IResourceLocator;
import org.eclipse.osee.framework.resource.management.IResourceLocatorManager;
import org.eclipse.osee.framework.resource.management.IResourceManager;
+import org.eclipse.osee.orcs.db.internal.util.ByteStreamResource;
/**
* @author Roberto E. Escobar
@@ -40,25 +43,29 @@ public class ResourceHandler implements DataHandler {
@Override
public byte[] acquire(DataResource dataResource) throws OseeCoreException {
String path = dataResource.getLocator();
+ Conditions.checkNotNull(path, "resource path");
+
IResourceLocator locator = resourceLocator.getResourceLocator(path);
- IResource resource = resourceManager.acquire(locator, DEFAULT_OPTIONS);
+ Conditions.checkNotNull(locator, "resource locator", "Unable to locate resource: [%s]", dataResource.getName());
- dataResource.setEncoding("ISO-8859-1");
+ IResource resource = resourceManager.acquire(locator, DEFAULT_OPTIONS);
+ resource.getName();
InputStream inputStream = resource.getContent();
try {
String mimeType = URLConnection.guessContentTypeFromStream(inputStream);
if (mimeType == null) {
- mimeType = URLConnection.guessContentTypeFromName(resource.getLocation().toString());
+ mimeType = URLConnection.guessContentTypeFromName(resource.getLocation().toASCIIString());
if (mimeType == null) {
mimeType = "application/*";
}
}
dataResource.setContentType(mimeType);
-
+ dataResource.setEncoding("ISO-8859-1");
return Lib.inputStreamToBytes(inputStream);
} catch (IOException ex) {
- throw OseeExceptions.wrap(ex);
+ throw new OseeCoreException(ex, "Error acquiring resource - name[%s] locator[%s]", dataResource.getName(),
+ dataResource.getLocator());
} finally {
Lib.close(inputStream);
}
@@ -66,27 +73,35 @@ public class ResourceHandler implements DataHandler {
@Override
public void save(int storageId, DataResource dataResource, byte[] rawContent) throws OseeCoreException {
- // Map<String, String> parameterMap = new HashMap<String, String>();
- // parameterMap.put("seed", Integer.toString(gammaId));
- // parameterMap.put("name", artifactGuid);
- // if (Strings.isValid(extension) != false) {
- // parameterMap.put("extension", extension);
- // }
-
- int gammaId = -1;
+ String name = dataResource.getName();
+ String extension = dataResource.getExtension();
+ if (Strings.isValid(extension)) {
+ name += "." + extension;
+ }
+ boolean isCompressed = false;
- String name = "";
- String seed = Integer.toString(gammaId);
+ String seed = Integer.toString(storageId);
IResourceLocator locatorHint = resourceLocator.generateResourceLocator("attr", seed, name);
- IResource resource = null;
+
+ IResource resource = new ByteStreamResource(locatorHint, rawContent, isCompressed);
IResourceLocator locator = resourceManager.save(locatorHint, resource, DEFAULT_OPTIONS);
+ Conditions.checkNotNull(locator, "locator", "Error saving resource [%s]", locatorHint.getRawPath());
+
dataResource.setLocator(locator.getLocation().toASCIIString());
}
@Override
public void purge(DataResource dataResource) throws OseeCoreException {
- IResourceLocator locator = resourceLocator.getResourceLocator(dataResource.getLocator());
- resourceManager.delete(locator);
+ String path = dataResource.getLocator();
+ Conditions.checkNotNull(path, "resource path");
+
+ IResourceLocator locator = resourceLocator.getResourceLocator(path);
+ Conditions.checkNotNull(locator, "resource locator", "Unable to locate resource: [%s]", dataResource.getName());
+
+ int result = resourceManager.delete(locator);
+ if (IResourceManager.OK != result) {
+ throw new OseeDataStoreException("Error deleting resource located at [%s]", dataResource.getLocator());
+ }
}
// public static PropertyStore getOptions(HttpServletRequest request) {
@@ -96,24 +111,5 @@ public class ResourceHandler implements DataHandler {
// options.put(StandardOptions.DecompressOnAquire.name(), request.getParameter(DECOMPRESS_ON_ACQUIRE));
// options.put(StandardOptions.Overwrite.name(), request.getParameter(IS_OVERWRITE_ALLOWED));
// return options;
- // }
-
- //
- // public void acquire(DataStore dataStore) throws OseeCoreException {
- // URL url = getAcquireURL(dataStore);
- // ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- // try {
- // AcquireResult result = HttpProcessor.acquire(url, outputStream);
- // int code = result.getCode();
- // if (code == HttpURLConnection.HTTP_OK) {
- // dataStore.setContent(outputStream.toByteArray(), "", result.getContentType(), result.getEncoding());
- // } else {
- // throw new OseeDataStoreException("Error acquiring resource: [%s] - status code: [%s]; %s",
- // dataStore.getLocator(), code, new String(outputStream.toByteArray()));
- // }
- // } catch (Exception ex) {
- // OseeExceptions.wrapAndThrow(ex);
- // }
- // }
-
+ //}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/Storage.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/Storage.java
index da090ecdc60..5d08b3c49b8 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/Storage.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/Storage.java
@@ -96,7 +96,6 @@ public class Storage {
this.rawContent = rawContent;
this.resource.setContentType(contentType);
this.resource.setEncoding(encoding);
- // this.resource.setExtension(extension);
}
public void copyTo(Storage other) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/UriDataProxy.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/UriDataProxy.java
index 652223db467..10888d70625 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/UriDataProxy.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/proxy/UriDataProxy.java
@@ -27,8 +27,8 @@ import org.eclipse.osee.orcs.core.ds.CharacterDataProxy;
public class UriDataProxy extends AbstractDataSourceProxy implements CharacterDataProxy, BinaryDataProxy {
private String displayable;
- public UriDataProxy(Storage dataStore) {
- super(dataStore);
+ public UriDataProxy(Storage storage) {
+ super(storage);
this.displayable = "";
}
@@ -46,16 +46,16 @@ public class UriDataProxy extends AbstractDataSourceProxy implements CharacterDa
public boolean setValue(ByteBuffer data) throws OseeCoreException {
boolean response = false;
try {
- if (!Arrays.equals(getDataStore().getContent(), data != null ? data.array() : null)) {
+ if (!Arrays.equals(getStorage().getContent(), data != null ? data.array() : null)) {
if (data != null) {
byte[] compressed;
- compressed = Lib.compressStream(Lib.byteBufferToInputStream(data), getDataStore().getFileName());
- getDataStore().setContent(compressed, "zip", "application/zip", "ISO-8859-1");
+ compressed = Lib.compressStream(Lib.byteBufferToInputStream(data), getStorage().getFileName());
+ getStorage().setContent(compressed, "zip", "application/zip", "ISO-8859-1");
response = true;
} else {
- String loc = getDataStore().getLocator();
- getDataStore().clear();
- getDataStore().setLocator(loc);
+ String loc = getStorage().getLocator();
+ getStorage().clear();
+ getStorage().setLocator(loc);
}
}
} catch (IOException ex) {
@@ -67,7 +67,7 @@ public class UriDataProxy extends AbstractDataSourceProxy implements CharacterDa
@Override
public ByteBuffer getValueAsBytes() throws OseeCoreException {
ByteBuffer decompressed = null;
- byte[] rawData = getDataStore().getContent();
+ byte[] rawData = getStorage().getContent();
if (rawData != null) {
try {
decompressed = ByteBuffer.wrap(Lib.decompressBytes(new ByteArrayInputStream(rawData)));
@@ -111,23 +111,23 @@ public class UriDataProxy extends AbstractDataSourceProxy implements CharacterDa
@Override
public Object[] getData() {
- return new Object[] {"", getDataStore().getLocator()};
+ return new Object[] {"", getStorage().getLocator()};
}
@Override
public void loadData(Object... objects) {
if (objects != null && objects.length > 1) {
- getDataStore().setLocator((String) objects[1]);
+ getStorage().setLocator((String) objects[1]);
}
}
@Override
public void persist(int storageId) throws OseeCoreException {
- getDataStore().persist(storageId);
+ getStorage().persist(storageId);
}
@Override
public void purge() throws OseeCoreException {
- getDataStore().purge();
+ getStorage().purge();
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/BinaryContentUtils.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/BinaryContentUtils.java
new file mode 100644
index 00000000000..1ff35d801a4
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/BinaryContentUtils.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * 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.db.internal.util;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLConnection;
+import java.net.URLEncoder;
+import org.eclipse.osee.framework.core.data.Identity;
+import org.eclipse.osee.framework.core.data.NamedIdentity;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+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.GUID;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.orcs.data.ReadableAttribute;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class BinaryContentUtils {
+
+ private final static int MAX_NAME_SIZE = 60;
+
+ public static String getContentType(String extension) {
+ String contentType = null;
+ if (Strings.isValid(extension)) {
+ contentType = URLConnection.guessContentTypeFromName("dummy." + extension);
+ } else {
+ contentType = "application/*";
+ }
+ return contentType;
+ }
+
+ public static String generateFileName(NamedIdentity<String> identity, String fileTypeExtension) throws OseeCoreException {
+ StringBuilder builder = new StringBuilder();
+ try {
+ String name = identity.getName();
+ if (name.length() > MAX_NAME_SIZE) {
+ name = name.substring(0, MAX_NAME_SIZE);
+ }
+ builder.append(URLEncoder.encode(name, "UTF-8"));
+ builder.append(".");
+ } catch (UnsupportedEncodingException ex) {
+ // Do Nothing - this is not important
+ }
+
+ builder.append(getStorageName(identity));
+
+ if (Strings.isValid(fileTypeExtension)) {
+ builder.append(".");
+ builder.append(fileTypeExtension);
+ }
+ return builder.toString();
+ }
+
+ private static String getStorageName(Identity<String> identity) throws OseeCoreException {
+ String guid = identity.getGuid();
+ Conditions.checkExpressionFailOnTrue(!GUID.isValid(guid), "Item has an invalid guid [%s]", guid);
+ return guid;
+ }
+
+ private static String getExtension(ReadableAttribute<String> attribute) throws OseeCoreException {
+ AttributeType attributeType = (AttributeType) attribute.getAttributeType();
+
+ String fileTypeExtension = null;
+ if (attributeType.equals(CoreAttributeTypes.NativeContent)) {
+ fileTypeExtension = attribute.getValue();
+ }
+ if (!Strings.isValid(fileTypeExtension)) {
+ fileTypeExtension = attributeType.getFileTypeExtension();
+ }
+ return fileTypeExtension;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/ByteStreamResource.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/ByteStreamResource.java
new file mode 100644
index 00000000000..f7f0b97e04b
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/ByteStreamResource.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.db.internal.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.net.URI;
+import org.eclipse.osee.framework.resource.management.IResource;
+import org.eclipse.osee.framework.resource.management.IResourceLocator;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ByteStreamResource implements IResource {
+
+ private final IResourceLocator locator;
+ private final byte[] rawContent;
+ private final boolean isCompressed;
+
+ public ByteStreamResource(IResourceLocator locator, byte[] rawContent, boolean isCompressed) {
+ this.locator = locator;
+ this.rawContent = rawContent;
+ this.isCompressed = isCompressed;
+ }
+
+ @Override
+ public InputStream getContent() {
+ return new ByteArrayInputStream(rawContent);
+ }
+
+ @Override
+ public URI getLocation() {
+ return locator.getLocation();
+ }
+
+ @Override
+ public String getName() {
+ String path = locator.getLocation().toASCIIString();
+ int index = path.lastIndexOf("/");
+ if (index != -1 && index + 1 < path.length()) {
+ path = path.substring(index + 1, path.length());
+ }
+ return path;
+ }
+
+ @Override
+ public boolean isCompressed() {
+ return isCompressed;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ReadableAttribute.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ReadableAttribute.java
index 029a35f0900..0492469419c 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ReadableAttribute.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ReadableAttribute.java
@@ -23,6 +23,8 @@ public interface ReadableAttribute<T> extends Readable, HasVersion {
IAttributeType getAttributeType();
+ boolean isOfType(IAttributeType otherAttributeType);
+
T getValue() throws OseeCoreException;
String getDisplayableString() throws OseeCoreException;

Back to the top