Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2013-07-15 23:06:03 +0000
committerGerrit Code Review @ Eclipse.org2013-09-13 21:10:49 +0000
commitd67b6ac6ba629e9ec589d8a5eda773430d8b9d3d (patch)
treef0a54a70dd7c7fc48d4ec8796b62f25a44dca32a /plugins
parent3a4a9175493addac6e4adfd8a1f111746b1ed647 (diff)
downloadorg.eclipse.osee-d67b6ac6ba629e9ec589d8a5eda773430d8b9d3d.tar.gz
org.eclipse.osee-d67b6ac6ba629e9ec589d8a5eda773430d8b9d3d.tar.xz
org.eclipse.osee-d67b6ac6ba629e9ec589d8a5eda773430d8b9d3d.zip
feature[ats_7SNLZ]: Create value provider factory
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactoryTest.java16
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactTest.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java7
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/Artifact.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactory.java16
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/util/BranchProvider.java (renamed from plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/BranchProvider.java)8
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/util/OrcsLazyObject.java (renamed from plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/OrcsLazyObject.java)2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/util/ValueProvider.java (renamed from plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ValueProvider.java)7
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/util/ValueProviderFactory.java33
9 files changed, 76 insertions, 29 deletions
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 a510564bb9..920e1a7441 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
@@ -27,17 +27,19 @@ import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.core.model.cache.BranchCache;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.orcs.core.ds.ArtifactData;
import org.eclipse.osee.orcs.core.ds.ArtifactDataFactory;
import org.eclipse.osee.orcs.core.ds.AttributeData;
+import org.eclipse.osee.orcs.core.ds.OrcsData;
import org.eclipse.osee.orcs.core.ds.VersionData;
import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeManager;
import org.eclipse.osee.orcs.core.internal.relation.RelationContainer;
import org.eclipse.osee.orcs.core.internal.relation.RelationFactory;
+import org.eclipse.osee.orcs.core.internal.util.ValueProvider;
+import org.eclipse.osee.orcs.core.internal.util.ValueProviderFactory;
import org.eclipse.osee.orcs.data.ArtifactTypes;
import org.junit.Assert;
import org.junit.Before;
@@ -71,7 +73,8 @@ public class ArtifactFactoryTest {
@Mock private AttributeFactory attributeFactory;
@Mock private RelationFactory relationFactory;
@Mock private ArtifactTypes artifactTypeCache;
- @Mock private BranchCache branchCache;
+ @Mock private ValueProviderFactory providerFactory;
+ @Mock private ValueProvider<Branch, OrcsData> branchProvider;
@Mock private Attribute<Object> attribute;
@Mock private AttributeData attributeData;
@@ -89,7 +92,7 @@ public class ArtifactFactoryTest {
MockitoAnnotations.initMocks(this);
artifactFactory =
- new ArtifactFactory(dataFactory, attributeFactory, relationFactory, branchCache, artifactTypeCache);
+ new ArtifactFactory(dataFactory, attributeFactory, relationFactory, artifactTypeCache, providerFactory);
guid = GUID.create();
@@ -114,7 +117,11 @@ public class ArtifactFactoryTest {
when(otherArtifactData.getVersion()).thenReturn(artifactVersion);
when(relationFactory.createRelationContainer(45)).thenReturn(relationContainer);
- when(branchCache.getById(23)).thenReturn(branch);
+
+ when(providerFactory.createBranchProvider(artifactData)).thenReturn(branchProvider);
+ when(providerFactory.createBranchProvider(otherArtifactData)).thenReturn(branchProvider);
+
+ when(branchProvider.get()).thenReturn(branch);
when(artifactTypeCache.getByUuid(65L)).thenReturn(artifactType);
}
@@ -133,7 +140,6 @@ public class ArtifactFactoryTest {
@Test
public void testCreateArtifactFromArtifactData() throws OseeCoreException {
when(relationFactory.createRelationContainer(45)).thenReturn(relationContainer);
- when(branchCache.getById(23)).thenReturn(branch);
Artifact artifact = artifactFactory.createArtifact(artifactData);
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactTest.java
index aa39659a45..7638227257 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactTest.java
@@ -18,7 +18,6 @@ import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.List;
-import org.junit.Assert;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
@@ -31,15 +30,14 @@ import org.eclipse.osee.framework.core.model.Branch;
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.OrcsData;
import org.eclipse.osee.orcs.core.ds.VersionData;
import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
-import org.eclipse.osee.orcs.core.internal.artifact.ValueProvider;
-import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
-import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory;
-import org.eclipse.osee.orcs.core.internal.attribute.AttributeManager;
import org.eclipse.osee.orcs.core.internal.relation.RelationContainer;
+import org.eclipse.osee.orcs.core.internal.util.ValueProvider;
import org.eclipse.osee.orcs.data.ArtifactTypes;
import org.eclipse.osee.orcs.data.AttributeReadable;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -60,7 +58,7 @@ public class ArtifactTest {
@Mock private ArtifactData artifactData;
@Mock private AttributeFactory attributeFactory;
@Mock private RelationContainer relationContainer;
- @Mock private ValueProvider<Branch, ArtifactData> branchProvider;
+ @Mock private ValueProvider<Branch, OrcsData> branchProvider;
@Mock private ArtifactTypes types;
@Mock private VersionData version;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java
index aaa0d1cb07..c2d1d52813 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java
@@ -53,6 +53,7 @@ import org.eclipse.osee.orcs.core.internal.transaction.TransactionFactoryImpl;
import org.eclipse.osee.orcs.core.internal.transaction.handler.TxDataHandlerFactoryImpl;
import org.eclipse.osee.orcs.core.internal.types.BranchHierarchyProvider;
import org.eclipse.osee.orcs.core.internal.types.OrcsTypesModule;
+import org.eclipse.osee.orcs.core.internal.util.ValueProviderFactory;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.GraphReadable;
import org.eclipse.osee.orcs.search.QueryFactory;
@@ -142,9 +143,11 @@ public class OrcsApiImpl implements OrcsApi {
AttributeFactory attributeFactory =
new AttributeFactory(resolver, module.getDataFactory(), orcsTypes.getAttributeTypes());
+ ValueProviderFactory providerFactory = new ValueProviderFactory(cacheService.getBranchCache());
+
ArtifactFactory artifactFactory =
- new ArtifactFactory(module.getDataFactory(), attributeFactory, relationFactory, cacheService.getBranchCache(),
- orcsTypes.getArtifactTypes());
+ new ArtifactFactory(module.getDataFactory(), attributeFactory, relationFactory, orcsTypes.getArtifactTypes(),
+ providerFactory);
proxyFactory = new ArtifactProxyFactory(artifactFactory);
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 d5d0c8f1de..2a5064ee6b 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
@@ -20,24 +20,26 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.orcs.core.ds.ArtifactData;
+import org.eclipse.osee.orcs.core.ds.OrcsData;
import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeManagerImpl;
import org.eclipse.osee.orcs.core.internal.relation.HasRelationContainer;
import org.eclipse.osee.orcs.core.internal.relation.RelationContainer;
+import org.eclipse.osee.orcs.core.internal.util.ValueProvider;
import org.eclipse.osee.orcs.data.ArtifactTypes;
import org.eclipse.osee.orcs.data.ArtifactWriteable;
public class Artifact extends AttributeManagerImpl implements ArtifactWriteable, HasRelationContainer, ArtifactVisitable {
private final ArtifactTypes artifactTypeCache;
- private final ValueProvider<Branch, ArtifactData> branchProvider;
+ private final ValueProvider<Branch, OrcsData> branchProvider;
private final RelationContainer relationContainer;
private EditState objectEditState;
private ArtifactData artifactData;
- public Artifact(ArtifactTypes artifactTypeCache, ArtifactData artifactData, AttributeFactory attributeFactory, RelationContainer relationContainer, ValueProvider<Branch, ArtifactData> branchProvider) {
+ public Artifact(ArtifactTypes artifactTypeCache, ArtifactData artifactData, AttributeFactory attributeFactory, RelationContainer relationContainer, ValueProvider<Branch, OrcsData> branchProvider) {
super(attributeFactory);
this.artifactTypeCache = artifactTypeCache;
this.artifactData = artifactData;
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 30c0480c87..c434fe545c 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
@@ -18,15 +18,18 @@ 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.OseeCoreException;
-import org.eclipse.osee.framework.core.model.cache.BranchCache;
+import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.orcs.core.ds.ArtifactData;
import org.eclipse.osee.orcs.core.ds.ArtifactDataFactory;
import org.eclipse.osee.orcs.core.ds.AttributeData;
+import org.eclipse.osee.orcs.core.ds.OrcsData;
import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory;
import org.eclipse.osee.orcs.core.internal.relation.RelationContainer;
import org.eclipse.osee.orcs.core.internal.relation.RelationFactory;
+import org.eclipse.osee.orcs.core.internal.util.ValueProvider;
+import org.eclipse.osee.orcs.core.internal.util.ValueProviderFactory;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.ArtifactTypes;
import org.eclipse.osee.orcs.data.AttributeReadable;
@@ -39,25 +42,24 @@ public class ArtifactFactory {
private final ArtifactDataFactory factory;
private final AttributeFactory attributeFactory;
private final RelationFactory relationFactory;
- private final BranchCache branchCache;
private final ArtifactTypes artifactTypeCache;
+ private final ValueProviderFactory providerFactory;
- public ArtifactFactory(ArtifactDataFactory factory, AttributeFactory attributeFactory, RelationFactory relationFactory, BranchCache branchCache, ArtifactTypes artifactTypeCache) {
+ public ArtifactFactory(ArtifactDataFactory factory, AttributeFactory attributeFactory, RelationFactory relationFactory, ArtifactTypes artifactTypeCache, ValueProviderFactory providerFactory) {
super();
this.factory = factory;
this.attributeFactory = attributeFactory;
this.relationFactory = relationFactory;
- this.branchCache = branchCache;
this.artifactTypeCache = artifactTypeCache;
+ this.providerFactory = providerFactory;
}
@SuppressWarnings("unused")
public Artifact createArtifact(ArtifactData artifactData) throws OseeCoreException {
//TODO implement an artifact class resolver for specific artifact types
RelationContainer relationContainer = relationFactory.createRelationContainer(artifactData.getLocalId());
-
- return new Artifact(artifactTypeCache, artifactData, attributeFactory, relationContainer, new BranchProvider(
- branchCache, artifactData));
+ ValueProvider<Branch, OrcsData> branchProvider = providerFactory.createBranchProvider(artifactData);
+ return new Artifact(artifactTypeCache, artifactData, attributeFactory, relationContainer, branchProvider);
}
public Artifact createArtifact(IOseeBranch branch, IArtifactType artifactType, String guid) throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/BranchProvider.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/util/BranchProvider.java
index 9481609f9a..44fda8efcc 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/BranchProvider.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/util/BranchProvider.java
@@ -8,21 +8,21 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.artifact;
+package org.eclipse.osee.orcs.core.internal.util;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
-import org.eclipse.osee.orcs.core.ds.ArtifactData;
+import org.eclipse.osee.orcs.core.ds.OrcsData;
/**
* @author Roberto E. Escobar
*/
-public class BranchProvider extends OrcsLazyObject<Branch, ArtifactData> implements ValueProvider<Branch, ArtifactData> {
+public class BranchProvider extends OrcsLazyObject<Branch, OrcsData> implements ValueProvider<Branch, OrcsData> {
private final BranchCache branchCache;
- public BranchProvider(BranchCache branchCache, ArtifactData data) {
+ public BranchProvider(BranchCache branchCache, OrcsData data) {
super(data);
this.branchCache = branchCache;
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/OrcsLazyObject.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/util/OrcsLazyObject.java
index a17ca59d34..a7ed09968a 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/OrcsLazyObject.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/util/OrcsLazyObject.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.artifact;
+package org.eclipse.osee.orcs.core.internal.util;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ValueProvider.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/util/ValueProvider.java
index be97bb13dd..4f94ee4de8 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ValueProvider.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/util/ValueProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
+ * Copyright (c) 2013 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
@@ -8,12 +8,15 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.artifact;
+package org.eclipse.osee.orcs.core.internal.util;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.orcs.core.ds.HasOrcsData;
import org.eclipse.osee.orcs.core.ds.OrcsData;
+/**
+ * @author Roberto E. Escobar
+ */
public interface ValueProvider<T, D extends OrcsData> extends HasOrcsData<D> {
T get() throws OseeCoreException;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/util/ValueProviderFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/util/ValueProviderFactory.java
new file mode 100644
index 0000000000..58cd4c3590
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/util/ValueProviderFactory.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.util;
+
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.cache.BranchCache;
+import org.eclipse.osee.orcs.core.ds.OrcsData;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ValueProviderFactory {
+
+ private final BranchCache branchCache;
+
+ public ValueProviderFactory(BranchCache branchCache) {
+ super();
+ this.branchCache = branchCache;
+ }
+
+ public ValueProvider<Branch, OrcsData> createBranchProvider(OrcsData data) {
+ return new BranchProvider(branchCache, data);
+ }
+
+} \ No newline at end of file

Back to the top