Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2011-02-22 21:57:46 +0000
committerRyan D. Brooks2011-02-22 21:57:46 +0000
commit39b40b9429d4ea96dd43d363c231f034c1c5f225 (patch)
treeaf4b13adb0606cd35ef672baafb5e1768a759685 /plugins
parentb95a49e1a006cac894b18a4d38afb73ee7d30a4e (diff)
downloadorg.eclipse.osee-39b40b9429d4ea96dd43d363c231f034c1c5f225.tar.gz
org.eclipse.osee-39b40b9429d4ea96dd43d363c231f034c1c5f225.tar.xz
org.eclipse.osee-39b40b9429d4ea96dd43d363c231f034c1c5f225.zip
feature[ats_YGHW1]: Integrate artifact matcher
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchInterpreterTest.java321
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchRestrictionHandlerTest.java103
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/InternalTestSuite.java14
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/mocks/DslAsserts.java113
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/internal/ArtifactInstanceRestrictionHandlerTest.java76
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/ModelUtilTest.java113
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/testAccessModel.osee53
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/testTypeModel.osee96
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ArtifactDataProvider.java18
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java51
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/RestrictionHandler.java4
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java23
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterImpl.java27
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterServiceRegHandler.java23
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchInterpreter.java143
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchRestrictionHandler.java (renamed from plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactInstanceRestrictionHandler.java)32
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandler.java6
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AttributeTypeRestrictionHandler.java8
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/RelationTypeRestrictionHandler.java12
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/OseeUtil.java6
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/ArtifactDataAccessor.java79
21 files changed, 1068 insertions, 253 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchInterpreterTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchInterpreterTest.java
new file mode 100644
index 00000000000..ce382b52091
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchInterpreterTest.java
@@ -0,0 +1,321 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.dsl.integration.internal;
+
+import java.util.Collection;
+import java.util.Iterator;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.data.Identity;
+import org.eclipse.osee.framework.core.data.Named;
+import org.eclipse.osee.framework.core.data.TokenFactory;
+import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy;
+import org.eclipse.osee.framework.core.dsl.integration.mocks.DslAsserts;
+import org.eclipse.osee.framework.core.dsl.integration.mocks.MockModel;
+import org.eclipse.osee.framework.core.dsl.integration.util.ModelUtil;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.CompareOp;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.CompoundCondition;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.Condition;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.MatchField;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.SimpleCondition;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactMatcher;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XLogicOperator;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.IBasicArtifact;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+import org.eclipse.osee.framework.core.model.type.RelationType;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.junit.Test;
+
+/**
+ * Test Case for {@link ArtifactMatchInterpreter}
+ *
+ * @author Roberto E. Escobar
+ */
+public class ArtifactMatchInterpreterTest {
+
+ private final ArtifactMatchInterpreter interpreter = new ArtifactMatchInterpreter();
+
+ @Test
+ public void testMatchNoConditions() throws OseeCoreException {
+ XArtifactMatcher matcher = MockModel.createXArtifactMatcherRef("TestArtifact");
+ boolean actual = interpreter.matches(matcher, (ArtifactProxy) null);
+ Assert.assertEquals(false, actual);
+ }
+
+ @Test
+ public void testArtifactNameEq() throws OseeCoreException {
+ XArtifactMatcher matcher = createMatcher("artifactMatcher \"Test\" where artifactName EQ \"Test Artifact\";");
+
+ DslAsserts.assertEquals(matcher.getConditions().iterator().next(), MatchField.ARTIFACT_NAME, CompareOp.EQ,
+ "Test Artifact");
+
+ ArtifactProxy proxy = createProxy(GUID.create(), "test Artifact");
+ boolean actual = interpreter.matches(matcher, proxy);
+ Assert.assertEquals(false, actual);
+
+ proxy = createProxy(GUID.create(), "Test Artifact");
+ actual = interpreter.matches(matcher, proxy);
+ Assert.assertEquals(true, actual);
+ }
+
+ @Test
+ public void testArtifactNameLike() throws OseeCoreException {
+ XArtifactMatcher matcher = createMatcher("artifactMatcher \"Test\" where artifactName LIKE \".*arti.*\";");
+
+ DslAsserts.assertEquals(matcher.getConditions().iterator().next(), MatchField.ARTIFACT_NAME, CompareOp.LIKE,
+ ".*arti.*");
+
+ ArtifactProxy proxy = createProxy(GUID.create(), "9999 arti_121341");
+ boolean actual = interpreter.matches(matcher, proxy);
+ Assert.assertEquals(true, actual);
+ }
+
+ @Test
+ public void testArtifactGuidEq() throws OseeCoreException {
+ String guid = GUID.create();
+ XArtifactMatcher matcher = createMatcher("artifactMatcher \"Test\" where artifactGuid EQ \"" + guid + "\";");
+
+ DslAsserts.assertEquals(matcher.getConditions().iterator().next(), MatchField.ARTIFACT_GUID, CompareOp.EQ, guid);
+
+ ArtifactProxy proxy = createProxy(guid, "");
+ boolean actual = interpreter.matches(matcher, proxy);
+ Assert.assertEquals(true, actual);
+ }
+
+ @Test
+ public void testArtifactGuidLike() throws OseeCoreException {
+ XArtifactMatcher matcher = createMatcher("artifactMatcher \"Test\" where artifactGuid LIKE \"\\w+\";");
+
+ DslAsserts.assertEquals(matcher.getConditions().iterator().next(), MatchField.ARTIFACT_GUID, CompareOp.LIKE,
+ "\\w+");
+
+ ArtifactProxy proxy = createProxy("ABCDEFGHIJK123456789", "");
+ boolean actual = interpreter.matches(matcher, proxy);
+ Assert.assertEquals(true, actual);
+ }
+
+ @Test
+ public void testArtifactBranchNameEq() throws OseeCoreException {
+ XArtifactMatcher matcher = createMatcher("artifactMatcher \"Test\" where branchName EQ \"branch1\";");
+
+ DslAsserts.assertEquals(matcher.getConditions().iterator().next(), MatchField.BRANCH_NAME, CompareOp.EQ,
+ "branch1");
+
+ ArtifactProxy proxy = createProxy(GUID.create(), "art1", GUID.create(), "branch2");
+ boolean actual = interpreter.matches(matcher, proxy);
+ Assert.assertEquals(false, actual);
+
+ proxy = createProxy(GUID.create(), "art1", GUID.create(), "branch1");
+ actual = interpreter.matches(matcher, proxy);
+ Assert.assertEquals(true, actual);
+ }
+
+ @Test
+ public void testArtifactBranchNameLike() throws OseeCoreException {
+ XArtifactMatcher matcher = createMatcher("artifactMatcher \"Test\" where branchName LIKE \".*hello.*\";");
+
+ DslAsserts.assertEquals(matcher.getConditions().iterator().next(), MatchField.BRANCH_NAME, CompareOp.LIKE,
+ ".*hello.*");
+
+ ArtifactProxy proxy = createProxy(GUID.create(), "art1", GUID.create(), "this is the hello branch");
+ boolean actual = interpreter.matches(matcher, proxy);
+ Assert.assertEquals(true, actual);
+ }
+
+ @Test
+ public void testArtifactBranchGuidEq() throws OseeCoreException {
+ String guid = GUID.create();
+ XArtifactMatcher matcher = createMatcher("artifactMatcher \"Test\" where branchGuid EQ \"" + guid + "\";");
+
+ DslAsserts.assertEquals(matcher.getConditions().iterator().next(), MatchField.BRANCH_GUID, CompareOp.EQ, guid);
+
+ ArtifactProxy proxy = createProxy(GUID.create(), "art1", guid, "");
+ boolean actual = interpreter.matches(matcher, proxy);
+ Assert.assertEquals(true, actual);
+ }
+
+ @Test
+ public void testArtifactBranchGuidLike() throws OseeCoreException {
+ XArtifactMatcher matcher = createMatcher("artifactMatcher \"Test\" where branchGuid LIKE \"\\w+\";");
+
+ DslAsserts.assertEquals(matcher.getConditions().iterator().next(), MatchField.BRANCH_GUID, CompareOp.LIKE,
+ "\\w+");
+
+ ArtifactProxy proxy = createProxy(GUID.create(), "art1", "ABCDEFGHIJK123456789", "");
+ boolean actual = interpreter.matches(matcher, proxy);
+ Assert.assertEquals(true, actual);
+ }
+
+ @Test
+ public void testCompoundCondition1() throws OseeCoreException {
+ XArtifactMatcher andMatcher =
+ createMatcher("artifactMatcher \"Test\" where artifactGuid EQ \"ABCDEFGHIJK123456789\" AND artifactName EQ \"myArtifact\";");
+
+ Iterator<Condition> iterator = andMatcher.getConditions().iterator();
+ DslAsserts.assertEquals(iterator.next(), MatchField.ARTIFACT_GUID, CompareOp.EQ, "ABCDEFGHIJK123456789");
+ DslAsserts.assertEquals(iterator.next(), MatchField.ARTIFACT_NAME, CompareOp.EQ, "myArtifact");
+
+ Assert.assertEquals(1, andMatcher.getOperators().size());
+ Assert.assertEquals(XLogicOperator.AND, andMatcher.getOperators().iterator().next());
+
+ XArtifactMatcher orMatcher =
+ createMatcher("artifactMatcher \"Test\" where artifactGuid EQ \"ABCDEFGHIJK123456789\" OR artifactName EQ \"myArtifact\";");
+
+ Iterator<Condition> iterator2 = orMatcher.getConditions().iterator();
+ DslAsserts.assertEquals(iterator2.next(), MatchField.ARTIFACT_GUID, CompareOp.EQ, "ABCDEFGHIJK123456789");
+ DslAsserts.assertEquals(iterator2.next(), MatchField.ARTIFACT_NAME, CompareOp.EQ, "myArtifact");
+
+ Assert.assertEquals(1, orMatcher.getOperators().size());
+ Assert.assertEquals(XLogicOperator.OR, orMatcher.getOperators().iterator().next());
+
+ ArtifactProxy proxy1 = createProxy("1BCDEFGHIJK123456789", "xArtifact");
+ ArtifactProxy proxy2 = createProxy("1BCDEFGHIJK123456789", "myArtifact");
+ ArtifactProxy proxy3 = createProxy("ABCDEFGHIJK123456789", "xArtifact");
+ ArtifactProxy proxy4 = createProxy("ABCDEFGHIJK123456789", "myArtifact");
+
+ Assert.assertEquals(false, interpreter.matches(andMatcher, proxy1));
+ Assert.assertEquals(false, interpreter.matches(andMatcher, proxy2));
+ Assert.assertEquals(false, interpreter.matches(andMatcher, proxy3));
+ Assert.assertEquals(true, interpreter.matches(andMatcher, proxy4));
+
+ Assert.assertEquals(false, interpreter.matches(orMatcher, proxy1));
+ Assert.assertEquals(true, interpreter.matches(orMatcher, proxy2));
+ Assert.assertEquals(true, interpreter.matches(orMatcher, proxy3));
+ Assert.assertEquals(true, interpreter.matches(orMatcher, proxy4));
+ }
+
+ @Test
+ public void testCompoundCondition2() throws OseeCoreException {
+ XArtifactMatcher matcher =
+ createMatcher("artifactMatcher \"Test\" where artifactGuid EQ \"ABCDEFGHIJK123456789\" AND (branchName EQ \"myArtifact\" OR branchGuid EQ \"123456789101112131415\");");
+
+ Assert.assertEquals(2, matcher.getConditions().size());
+ Iterator<Condition> iterator = matcher.getConditions().iterator();
+ DslAsserts.assertEquals(iterator.next(), MatchField.ARTIFACT_GUID, CompareOp.EQ, "ABCDEFGHIJK123456789");
+
+ Assert.assertEquals(1, matcher.getOperators().size());
+ Assert.assertEquals(XLogicOperator.AND, matcher.getOperators().iterator().next());
+
+ Condition condition = iterator.next();
+
+ Assert.assertTrue(condition instanceof CompoundCondition);
+ CompoundCondition compoundCondition = (CompoundCondition) condition;
+
+ Assert.assertEquals(2, compoundCondition.getConditions().size());
+
+ Iterator<SimpleCondition> iterator2 = compoundCondition.getConditions().iterator();
+ DslAsserts.assertEquals(iterator2.next(), MatchField.BRANCH_NAME, CompareOp.EQ, "myArtifact");
+ DslAsserts.assertEquals(iterator2.next(), MatchField.BRANCH_GUID, CompareOp.EQ, "123456789101112131415");
+
+ Assert.assertEquals(1, compoundCondition.getOperators().size());
+ Assert.assertEquals(XLogicOperator.OR, compoundCondition.getOperators().iterator().next());
+
+ String badArtGuid = "1BCDEFGHIJK123456789";
+ String badBranchGuid = "ABCDEFGHIJK123456789";
+ String badBranchName = "xArtifact";
+
+ String goodArtGuid = "ABCDEFGHIJK123456789";
+ String goodBranchGuid = "123456789101112131415";
+ String goodBranchName = "myArtifact";
+
+ ArtifactProxy proxy1 = createProxy(badArtGuid, "", badBranchGuid, badBranchName);
+ ArtifactProxy proxy2 = createProxy(badArtGuid, "", badBranchGuid, goodBranchName);
+ ArtifactProxy proxy3 = createProxy(badArtGuid, "", goodBranchGuid, badBranchName);
+ ArtifactProxy proxy4 = createProxy(badArtGuid, "", goodBranchGuid, goodBranchName);
+ ArtifactProxy proxy5 = createProxy(goodArtGuid, "", badBranchGuid, badBranchName);
+ ArtifactProxy proxy6 = createProxy(goodArtGuid, "", badBranchGuid, goodBranchName);
+ ArtifactProxy proxy7 = createProxy(goodArtGuid, "", goodBranchGuid, badBranchName);
+ ArtifactProxy proxy8 = createProxy(goodArtGuid, "", goodBranchGuid, goodBranchName);
+
+ Assert.assertEquals(false, interpreter.matches(matcher, proxy1));
+ Assert.assertEquals(false, interpreter.matches(matcher, proxy2));
+ Assert.assertEquals(false, interpreter.matches(matcher, proxy3));
+ Assert.assertEquals(false, interpreter.matches(matcher, proxy4));
+
+ Assert.assertEquals(false, interpreter.matches(matcher, proxy5));
+ Assert.assertEquals(true, interpreter.matches(matcher, proxy6));
+ Assert.assertEquals(true, interpreter.matches(matcher, proxy7));
+ Assert.assertEquals(true, interpreter.matches(matcher, proxy8));
+ }
+
+ private static XArtifactMatcher createMatcher(String rawXTextData) throws OseeCoreException {
+ OseeDsl model = ModelUtil.loadModel("osee:/text.osee", rawXTextData);
+ return model.getArtifactMatchRefs().iterator().next();
+ }
+
+ private static ArtifactProxy createProxy(String artGuid, String artifactName) {
+ return createProxy(artGuid, artifactName, GUID.create(), "dummy");
+ }
+
+ private static ArtifactProxy createProxy(final String artGuid, final String artifactName, final String branchGuid, final String branchName) {
+ return new ArtifactProxy() {
+
+ @Override
+ public boolean matches(Identity... identities) {
+ return false;
+ }
+
+ @Override
+ public String getUnqualifiedName() {
+ return null;
+ }
+
+ @Override
+ public int compareTo(Named o) {
+ return 0;
+ }
+
+ @Override
+ public IOseeBranch getBranch() {
+ return TokenFactory.createBranch(branchGuid, branchName);
+ }
+
+ @Override
+ public String getName() {
+ return artifactName;
+ }
+
+ @Override
+ public String getGuid() {
+ return artGuid;
+ }
+
+ @Override
+ public ArtifactType getArtifactType() {
+ return null;
+ }
+
+ @Override
+ public boolean isAttributeTypeValid(IAttributeType attributeType) {
+ return false;
+ }
+
+ @Override
+ public Collection<RelationType> getValidRelationTypes() {
+ return null;
+ }
+
+ @Override
+ public Collection<ArtifactProxy> getHierarchy() {
+ return null;
+ }
+
+ @Override
+ public IBasicArtifact<?> getObject() {
+ return null;
+ }
+
+ };
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchRestrictionHandlerTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchRestrictionHandlerTest.java
new file mode 100644
index 00000000000..43287201196
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchRestrictionHandlerTest.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.dsl.integration.internal;
+
+import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy;
+import org.eclipse.osee.framework.core.dsl.integration.mocks.DslAsserts;
+import org.eclipse.osee.framework.core.dsl.integration.mocks.MockArtifactProxy;
+import org.eclipse.osee.framework.core.dsl.integration.mocks.MockModel;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessPermissionEnum;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactMatchRestriction;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactMatcher;
+import org.eclipse.osee.framework.core.enums.PermissionEnum;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.DefaultBasicArtifact;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test Case for {@link ArtifactMatchRestrictionHandler}
+ *
+ * @author Roberto E. Escobar
+ */
+public class ArtifactMatchRestrictionHandlerTest extends BaseRestrictionHandlerTest<ArtifactMatchRestriction> {
+
+ private static final MockArtifactMatchInterpreter matcher = new MockArtifactMatchInterpreter();
+
+ public ArtifactMatchRestrictionHandlerTest() {
+ super(new ArtifactMatchRestrictionHandler(matcher), MockModel.createArtifactMatchRestriction(),
+ MockModel.createAttributeTypeRestriction());
+ }
+
+ @Test
+ public void testProcessDataNotMatchesRestriction() throws OseeCoreException {
+ XArtifactMatcher artifactRef = MockModel.createXArtifactMatcherRef("TestArtifact");
+
+ ArtifactMatchRestriction restriction = MockModel.createArtifactMatchRestriction();
+ restriction.setPermission(AccessPermissionEnum.ALLOW);
+ restriction.setArtifactMatcherRef(artifactRef);
+
+ matcher.setMatchesResult(false);
+
+ MockArtifactProxy artData = new MockArtifactProxy(GUID.create(), null);
+ DslAsserts.assertNullAccessDetail(getRestrictionHandler(), restriction, artData);
+
+ Assert.assertEquals(artifactRef, matcher.getMatcher());
+ Assert.assertEquals(artData, matcher.getProxy());
+ }
+
+ @Test
+ public void testProcessCreateAccessDetail() throws OseeCoreException {
+ XArtifactMatcher artifactRef = MockModel.createXArtifactMatcherRef("TestArtifact");
+
+ ArtifactMatchRestriction restriction = MockModel.createArtifactMatchRestriction();
+ restriction.setPermission(AccessPermissionEnum.ALLOW);
+ restriction.setArtifactMatcherRef(artifactRef);
+
+ matcher.setMatchesResult(true);
+ DefaultBasicArtifact expectedAccessObject = new DefaultBasicArtifact(1, GUID.create(), "Another Artifact");
+ MockArtifactProxy artData = new MockArtifactProxy(expectedAccessObject);
+
+ DslAsserts.assertAccessDetail(getRestrictionHandler(), restriction, artData, expectedAccessObject,
+ PermissionEnum.WRITE);
+
+ Assert.assertEquals(artifactRef, matcher.getMatcher());
+ Assert.assertEquals(artData, matcher.getProxy());
+ }
+
+ private static final class MockArtifactMatchInterpreter extends ArtifactMatchInterpreter {
+
+ private boolean matchesResult;
+ private ArtifactProxy proxy;
+ private XArtifactMatcher matcher;
+
+ @Override
+ public boolean matches(XArtifactMatcher matcher, ArtifactProxy proxy) {
+ this.matcher = matcher;
+ this.proxy = proxy;
+ return matchesResult;
+ }
+
+ public ArtifactProxy getProxy() {
+ return proxy;
+ }
+
+ public XArtifactMatcher getMatcher() {
+ return matcher;
+ }
+
+ public void setMatchesResult(boolean matchesResult) {
+ this.matchesResult = matchesResult;
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/InternalTestSuite.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/InternalTestSuite.java
index 4e8cd5fd3ee..d195059bd18 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/InternalTestSuite.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/InternalTestSuite.java
@@ -17,13 +17,13 @@ import org.junit.runners.Suite;
* @author Roberto E. Escobar
*/
@RunWith(Suite.class)
-@Suite.SuiteClasses({ //
-ArtifactInstanceRestrictionHandlerTest.class, //
- ArtifactTypeRestrictionHandlerTest.class, //
- AttributeTypeRestrictionHandlerTest.class, //
- RelationTypeRestrictionHandlerTest.class, //
- AccessModelInterpreterImplTest.class, //
-})
+@Suite.SuiteClasses({
+ AccessModelInterpreterImplTest.class,
+ ArtifactMatchInterpreterTest.class,
+ ArtifactMatchRestrictionHandlerTest.class,
+ ArtifactTypeRestrictionHandlerTest.class,
+ AttributeTypeRestrictionHandlerTest.class,
+ RelationTypeRestrictionHandlerTest.class})
public class InternalTestSuite {
// Test Suite
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/mocks/DslAsserts.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/mocks/DslAsserts.java
index 6d4c453d5d1..d345bfb1c0d 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/mocks/DslAsserts.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/mocks/DslAsserts.java
@@ -13,8 +13,25 @@ package org.eclipse.osee.framework.core.dsl.integration.mocks;
import junit.framework.Assert;
import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy;
import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessContext;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessPermissionEnum;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactTypeRestriction;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.AttributeTypeRestriction;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.CompareOp;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.Condition;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.HierarchyRestriction;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.MatchField;
import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction;
import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.RelationMultiplicityEnum;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.RelationTypeRestriction;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.SimpleCondition;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactMatcher;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XAttributeType;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XAttributeTypeRef;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XRelationSideEnum;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XRelationType;
import org.eclipse.osee.framework.core.enums.PermissionEnum;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.access.AccessDetail;
@@ -56,4 +73,100 @@ public final class DslAsserts {
Assert.assertEquals(model1.getImports().size(), model2.getImports().size());
Assert.assertEquals(model1.getRelationTypes().size(), model2.getRelationTypes().size());
}
+
+ public static void assertEquals(Condition condition, MatchField expField, CompareOp expOp, String expExpression) {
+ SimpleCondition simpCondition = (SimpleCondition) condition;
+ Assert.assertEquals(expField, simpCondition.getField());
+ Assert.assertEquals(expOp, simpCondition.getOp());
+ Assert.assertEquals(expExpression, simpCondition.getExpression());
+ }
+
+ public static void assertEquals(XArtifactMatcher matcher, String name) {
+ Assert.assertEquals(name, matcher.getName());
+ }
+
+ public static void assertEquals(XArtifactType artifactType, String expName, String expGuid, String[] inheritsFrom, String... attributeNames) {
+ Assert.assertEquals(expName, artifactType.getName());
+ Assert.assertEquals(expGuid, artifactType.getTypeGuid());
+
+ int index = 0;
+ Assert.assertEquals(inheritsFrom.length, artifactType.getSuperArtifactTypes().size());
+ for (XArtifactType ref : artifactType.getSuperArtifactTypes()) {
+ Assert.assertEquals(inheritsFrom[index++], ref.getName());
+ }
+
+ index = 0;
+ Assert.assertEquals(attributeNames.length, artifactType.getValidAttributeTypes().size());
+ for (XAttributeTypeRef ref : artifactType.getValidAttributeTypes()) {
+ Assert.assertEquals(attributeNames[index++], ref.getValidAttributeType().getName());
+ }
+ }
+
+ public static void assertEquals(XAttributeType type, String expName, String expGuid, String baseType, String dataProvider, String min, String max, String tagger, String description, String defaultValue, String ext) {
+ Assert.assertEquals(expName, type.getName());
+ Assert.assertEquals(expGuid, type.getTypeGuid());
+
+ Assert.assertEquals(baseType, type.getBaseAttributeType());
+ Assert.assertEquals(dataProvider, type.getDataProvider());
+ Assert.assertEquals(min, type.getMin());
+ Assert.assertEquals(max, type.getMax());
+ Assert.assertEquals(tagger, type.getTaggerId());
+ Assert.assertEquals(description, type.getDescription());
+ Assert.assertEquals(defaultValue, type.getDefaultValue());
+ Assert.assertEquals(ext, type.getFileExtension());
+ }
+
+ public static void assertEquals(XRelationType type, String expName, String expGuid, String sideA, String aName, String aGuid, String sideB, String bName, String bGuid, String orderType, RelationMultiplicityEnum mult) {
+ Assert.assertEquals(expName, type.getName());
+ Assert.assertEquals(expGuid, type.getTypeGuid());
+
+ XArtifactType aArt = type.getSideAArtifactType();
+ Assert.assertEquals(sideA, type.getSideAName());
+ Assert.assertEquals(aName, aArt.getName());
+ Assert.assertEquals(aGuid, aArt.getTypeGuid());
+
+ XArtifactType bArt = type.getSideBArtifactType();
+ Assert.assertEquals(sideB, type.getSideBName());
+ Assert.assertEquals(bName, bArt.getName());
+ Assert.assertEquals(bGuid, bArt.getTypeGuid());
+
+ Assert.assertEquals(orderType, type.getDefaultOrderType());
+ Assert.assertEquals(mult, type.getMultiplicity());
+ }
+
+ public static void assertEquals(AccessContext context, String expName, String expGuid, String[] inheritsFrom) {
+ Assert.assertEquals(expName, context.getName());
+ Assert.assertEquals(expGuid, context.getGuid());
+
+ int index = 0;
+ Assert.assertEquals(inheritsFrom.length, context.getSuperAccessContexts().size());
+ for (AccessContext ref : context.getSuperAccessContexts()) {
+ Assert.assertEquals(inheritsFrom[index++], ref.getName());
+ }
+ }
+
+ public static void assertEquals(ArtifactTypeRestriction restriction, AccessPermissionEnum permission, String artTypeName) {
+ Assert.assertEquals(permission, restriction.getPermission());
+ XArtifactType ref = restriction.getArtifactTypeRef();
+ Assert.assertEquals(artTypeName, ref.getName());
+ }
+
+ public static void assertEquals(AttributeTypeRestriction restriction, AccessPermissionEnum permission, String attrTypeName, String artTypeName) {
+ Assert.assertEquals(permission, restriction.getPermission());
+
+ Assert.assertEquals(attrTypeName, restriction.getAttributeTypeRef().getName());
+
+ XArtifactType ref = restriction.getArtifactTypeRef();
+ Assert.assertEquals(artTypeName, ref.getName());
+ }
+
+ public static void assertEquals(RelationTypeRestriction restriction, AccessPermissionEnum permission, String relType, XRelationSideEnum sideEnum) {
+ Assert.assertEquals(permission, restriction.getPermission());
+ Assert.assertEquals(relType, restriction.getRelationTypeRef().getName());
+ Assert.assertEquals(sideEnum, restriction.getRestrictedToSide());
+ }
+
+ public static void assertEquals(HierarchyRestriction restriction, String matcherName) {
+ Assert.assertEquals(matcherName, restriction.getArtifactMatcherRef().getName());
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/internal/ArtifactInstanceRestrictionHandlerTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/internal/ArtifactInstanceRestrictionHandlerTest.java
deleted file mode 100644
index 6c3be5dc35c..00000000000
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/test/internal/ArtifactInstanceRestrictionHandlerTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.dsl.integration.test.internal;
-
-import junit.framework.Assert;
-import org.eclipse.osee.framework.core.dsl.integration.internal.ArtifactInstanceRestrictionHandler;
-import org.eclipse.osee.framework.core.dsl.integration.test.mocks.DslAsserts;
-import org.eclipse.osee.framework.core.dsl.integration.test.mocks.MockArtifactData;
-import org.eclipse.osee.framework.core.dsl.integration.test.mocks.MockModel;
-import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessPermissionEnum;
-import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactInstanceRestriction;
-import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactRef;
-import org.eclipse.osee.framework.core.enums.PermissionEnum;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.DefaultBasicArtifact;
-import org.eclipse.osee.framework.jdk.core.util.GUID;
-import org.junit.Test;
-
-/**
- * Test Case for {@link ArtifactInstanceRestrictionHandler}
- *
- * @author Roberto E. Escobar
- */
-public class ArtifactInstanceRestrictionHandlerTest extends BaseRestrictionHandlerTest<ArtifactInstanceRestriction> {
-
- public ArtifactInstanceRestrictionHandlerTest() {
- super(new ArtifactInstanceRestrictionHandler(), MockModel.createArtifactInstanceRestriction(),
- MockModel.createAttributeTypeRestriction());
- }
-
- @Test
- public void testProcessDataNotMatchesRestriction() throws OseeCoreException {
-
- String guid1 = GUID.create();
-
- XArtifactRef artifactRef = MockModel.createXArtifactRef(guid1, "TestArtifact");
-
- ArtifactInstanceRestriction restriction = MockModel.createArtifactInstanceRestriction();
- restriction.setPermission(AccessPermissionEnum.ALLOW);
- restriction.setArtifactRef(artifactRef);
-
- String guid2 = GUID.create();
-
- Assert.assertFalse(guid1.equals(guid2));
- MockArtifactData artData = new MockArtifactData(guid2, null);
-
- DslAsserts.assertNullAccessDetail(getRestrictionHandler(), restriction, artData);
- }
-
- @Test
- public void testProcessCreateAccessDetail() throws OseeCoreException {
- String guid1 = GUID.create();
-
- XArtifactRef artifactRef = MockModel.createXArtifactRef(guid1, "TestArtifact");
-
- ArtifactInstanceRestriction restriction = MockModel.createArtifactInstanceRestriction();
- restriction.setPermission(AccessPermissionEnum.ALLOW);
- restriction.setArtifactRef(artifactRef);
-
- DefaultBasicArtifact expectedAccessObject = new DefaultBasicArtifact(1, guid1, "Another Artifact");
-
- MockArtifactData artData = new MockArtifactData(expectedAccessObject);
-
- DslAsserts.assertAccessDetail(getRestrictionHandler(), restriction, artData, expectedAccessObject,
- PermissionEnum.WRITE);
- }
-
-}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/ModelUtilTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/ModelUtilTest.java
index 6ca819d4683..831aab383cf 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/ModelUtilTest.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/ModelUtilTest.java
@@ -8,15 +8,31 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.framework.core.dsl.integration.test.util;
+package org.eclipse.osee.framework.core.dsl.integration.util;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import org.eclipse.osee.framework.core.dsl.integration.test.mocks.DslAsserts;
-import org.eclipse.osee.framework.core.dsl.integration.util.ModelUtil;
+import java.util.Iterator;
+import java.util.List;
+import org.eclipse.osee.framework.core.dsl.integration.mocks.DslAsserts;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessContext;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessPermissionEnum;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactTypeRestriction;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.AttributeTypeRestriction;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.CompareOp;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.HierarchyRestriction;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.MatchField;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction;
import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.RelationMultiplicityEnum;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.RelationTypeRestriction;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactMatcher;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XAttributeType;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XRelationSideEnum;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XRelationType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.junit.Assert;
@@ -47,14 +63,41 @@ public class ModelUtilTest {
String rawXTextData = getRawXTextData(TYPE_TEST_INPUT);
OseeDsl model1 = ModelUtil.loadModel("osee:/text.osee", rawXTextData);
+
Assert.assertEquals(5, model1.getArtifactTypes().size());
+ Iterator<XArtifactType> type1 = model1.getArtifactTypes().iterator();
+ // @formatter:off
+ DslAsserts.assertEquals(type1.next(), "Artifact", "AAMFDh6S7gRLupAMwywA", new String[0], "Name", "Annotation");
+ DslAsserts.assertEquals(type1.next(), "Requirement", "BOm4NmAq+HC1O2hkMagA", new String[] {"Artifact"}, "WordML");
+ DslAsserts.assertEquals(type1.next(), "Software Requirement", "BOm+AIG2snNbAM5FFcwA", new String[] {"Requirement"});
+ DslAsserts.assertEquals(type1.next(), "System Requirement", "BOnAaYTBOG68_Tw5Y_AA", new String[] {"Requirement"});
+ DslAsserts.assertEquals(type1.next(), "SubSystem Requirement", "BOnBhJ1XAFGKcrku3LgA", new String[] {"Requirement"});
+ // @formatter:on
+
Assert.assertEquals(3, model1.getAttributeTypes().size());
+ Iterator<XAttributeType> type2 = model1.getAttributeTypes().iterator();
+ DslAsserts.assertEquals(type2.next(), "Name", "AAMFEcF1AzV7PKuHmxwA", "StringAttribute",
+ "DefaultAttributeDataProvider", "1", "1", "DefaultAttributeTaggerProvider", //
+ "Descriptive Name", "unnamed", null);
+ DslAsserts.assertEquals(type2.next(), "Annotation", "AAMFEcWy0xc4e3tcemQA", "CompressedContentAttribute",
+ "UriAttributeDataProvider", "0", "unlimited", "DefaultAttributeTaggerProvider", //
+ "the version \'1.0\' is this \"1.2.0\"", null, null);
+ DslAsserts.assertEquals(type2.next(), "WordML", "AAMFEcfcGS2V3SqQN2wA", "WordAttribute",
+ "UriAttributeDataProvider", "0", "1", "XmlAttributeTaggerProvider",
+ "value must comply with WordML xml schema",
+ "<w:p xmlns:w=\"http://schemas.microsoft.com/office/word/2003/wordml\"><w:r><w:t></w:t></w:r></w:p>", "xml");
+
Assert.assertEquals(1, model1.getRelationTypes().size());
+ Iterator<XRelationType> type3 = model1.getRelationTypes().iterator();
+ DslAsserts.assertEquals(type3.next(), "Requirement Relation", "BOkzi3U9VTe2fcUz_9gA", "requirement-sideA",
+ "Requirement", "BOm4NmAq+HC1O2hkMagA", "subsystem-sideB", "SubSystem Requirement", "BOnBhJ1XAFGKcrku3LgA",
+ "Lexicographical_Ascending", RelationMultiplicityEnum.ONE_TO_MANY);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ModelUtil.saveModel(model1, "osee:/text.osee", outputStream, false);
outputStream.flush();
String value = outputStream.toString("UTF-8");
+ Assert.assertEquals(rawXTextData, value);
OseeDsl model2 = ModelUtil.loadModel("osee:/text2.osee", value);
DslAsserts.assertEquals(model1, model2);
@@ -66,23 +109,73 @@ public class ModelUtilTest {
OseeDsl model1 = ModelUtil.loadModel("osee:/text.osee", rawXTextData);
Assert.assertEquals(2, model1.getArtifactTypes().size());
+ Iterator<XArtifactType> type1 = model1.getArtifactTypes().iterator();
+ DslAsserts.assertEquals(type1.next(), "Artifact", "BZOUrxO35x+LBZkEYzAA", new String[0]);
+ DslAsserts.assertEquals(type1.next(), "Software Requirement", "BZO4PuM+Oz58hpAcTGwA", new String[] {"Artifact"});
+
Assert.assertEquals(1, model1.getAttributeTypes().size());
- Assert.assertEquals(0, model1.getRelationTypes().size());
+ Iterator<XAttributeType> type2 = model1.getAttributeTypes().iterator();
+ DslAsserts.assertEquals(type2.next(), "Qualification Method", "BZPB25t9fRVnLuII6+wA", "StringAttribute",
+ "DefaultAttributeDataProvider", "0", "1", null, null, "test", null);
+
+ Assert.assertEquals(1, model1.getRelationTypes().size());
+ Iterator<XRelationType> type3 = model1.getRelationTypes().iterator();
+ DslAsserts.assertEquals(type3.next(), "Requirement Relation", "BOkzi3U9VTe2fcUz_9gA", "requirement-sideA",
+ "Software Requirement", "BZO4PuM+Oz58hpAcTGwA", "artifact-sideB", "Artifact", "BZOUrxO35x+LBZkEYzAA",
+ "Lexicographical_Ascending", RelationMultiplicityEnum.ONE_TO_MANY);
+
+ Assert.assertEquals(3, model1.getArtifactMatchRefs().size());
+ Iterator<XArtifactMatcher> type4 = model1.getArtifactMatchRefs().iterator();
+ // @formatter:off
+ XArtifactMatcher matcher = type4.next();
+ DslAsserts.assertEquals(matcher, "Software Items");
+ DslAsserts.assertEquals(matcher.getConditions().get(0), MatchField.ARTIFACT_GUID, CompareOp.EQ, "AAMFEcWy0xc4e3tcem99");
+ matcher = type4.next();
+ DslAsserts.assertEquals(matcher, "Systems");
+ DslAsserts.assertEquals(matcher.getConditions().get(0), MatchField.BRANCH_NAME, CompareOp.LIKE, "\\w+");
+ matcher = type4.next();
+ DslAsserts.assertEquals(matcher, "SubSystems");
+ DslAsserts.assertEquals(matcher.getConditions().get(0), MatchField.ARTIFACT_NAME, CompareOp.EQ, "xx");
+ // @formatter:on
- Assert.assertEquals(3, model1.getArtifactRefs().size());
Assert.assertEquals(2, model1.getAccessDeclarations().size());
+ Iterator<AccessContext> type5 = model1.getAccessDeclarations().iterator();
+ AccessContext context1 = type5.next();
+ DslAsserts.assertEquals(context1, "System Context", "AAMFEcWy0xc4e3tcem11", new String[0]);
+ List<ObjectRestriction> restrictions1 = context1.getAccessRules();
+ Assert.assertEquals(1, restrictions1.size());
+ DslAsserts.assertEquals(((ArtifactTypeRestriction) restrictions1.iterator().next()), AccessPermissionEnum.DENY,
+ "Artifact");
+
+ List<HierarchyRestriction> hierarchy1 = context1.getHierarchyRestrictions();
+ Assert.assertEquals(3, hierarchy1.size());
+
+ Iterator<HierarchyRestriction> heirar = hierarchy1.iterator();
+ DslAsserts.assertEquals(heirar.next(), "Software Items");
+ DslAsserts.assertEquals(heirar.next(), "Systems");
+ DslAsserts.assertEquals(heirar.next(), "SubSystems");
+
+ AccessContext context2 = type5.next();
+ DslAsserts.assertEquals(context2, "subsystem.requirement.writer", "AAMFEcWy0xc4e3tcem22",
+ new String[] {"System Context"});
+ List<ObjectRestriction> restrictions2 = context2.getAccessRules();
+ Assert.assertEquals(4, restrictions2.size());
+ Iterator<ObjectRestriction> restIt = restrictions2.iterator();
+ // @formatter:off
+ DslAsserts.assertEquals(((AttributeTypeRestriction) restIt.next()), AccessPermissionEnum.DENY, "Qualification Method", "Software Requirement");
+ DslAsserts.assertEquals(((AttributeTypeRestriction) restIt.next()), AccessPermissionEnum.ALLOW, "Qualification Method", "Software Requirement");
+ DslAsserts.assertEquals(((AttributeTypeRestriction) restIt.next()), AccessPermissionEnum.ALLOW, "Qualification Method", "Software Requirement");
+ DslAsserts.assertEquals(((RelationTypeRestriction) restIt.next()), AccessPermissionEnum.DENY, "Requirement Relation", XRelationSideEnum.SIDE_A);
+
+ // @formatter:on
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ModelUtil.saveModel(model1, "osee:/text.osee", outputStream, false);
outputStream.flush();
String value = outputStream.toString("UTF-8");
+ Assert.assertEquals(rawXTextData, value);
OseeDsl model2 = ModelUtil.loadModel("osee:/text2.osee", value);
DslAsserts.assertEquals(model1, model2);
-
- // String modelRep =
- // ModelUtil.modelToStringXText(model1, "osee:/text.osee", Collections.<String, Boolean> emptyMap());
- // OseeDsl model3 = ModelUtil.loadModel("osee:/text3.osee", modelRep);
- // DslAsserts.assertEquals(model1, model3);
}
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/testAccessModel.osee b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/testAccessModel.osee
new file mode 100644
index 00000000000..e208601500c
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/testAccessModel.osee
@@ -0,0 +1,53 @@
+attributeType "Qualification Method" extends StringAttribute {
+ guid "BZPB25t9fRVnLuII6+wA"
+ dataProvider DefaultAttributeDataProvider
+ min 0
+ max 1
+ defaultValue "test"
+}
+
+relationType "Requirement Relation" {
+ guid "BOkzi3U9VTe2fcUz_9gA"
+ sideAName "requirement-sideA"
+ sideAArtifactType "Software Requirement"
+ sideBName "artifact-sideB"
+ sideBArtifactType "Artifact"
+ defaultOrderType Lexicographical_Ascending
+ multiplicity ONE_TO_MANY
+}
+
+artifactType "Artifact" {
+ guid "BZOUrxO35x+LBZkEYzAA"
+}
+
+artifactType "Software Requirement" extends "Artifact" {
+ guid "BZO4PuM+Oz58hpAcTGwA"
+}
+
+artifactMatcher "Software Items" where artifactGuid EQ "AAMFEcWy0xc4e3tcem99";
+artifactMatcher "Systems" where branchName LIKE "\\w+";
+artifactMatcher "SubSystems" where artifactName EQ "xx";
+accessContext "System Context" {
+ guid "AAMFEcWy0xc4e3tcem11";
+ childrenOf "Software Items" {
+ DENY edit artifactType "Artifact";
+ }
+
+ childrenOf "Systems" {
+ DENY edit artifactType "Artifact";
+ }
+
+ childrenOf "SubSystems" {
+ DENY edit artifactType "Artifact";
+ }
+
+ DENY edit artifactType "Artifact";
+}
+
+accessContext "subsystem.requirement.writer" extends "System Context" {
+ guid "AAMFEcWy0xc4e3tcem22";
+ DENY edit attributeType "Qualification Method" of artifactType "Software Requirement";
+ ALLOW edit attributeType "Qualification Method" of artifactType "Software Requirement";
+ ALLOW edit attributeType "Qualification Method" of artifactType "Software Requirement";
+ DENY edit relationType "Requirement Relation" SIDE_A;
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/testTypeModel.osee b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/testTypeModel.osee
index 3d989ddd5be..a723659c77b 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/testTypeModel.osee
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/util/testTypeModel.osee
@@ -1,60 +1,62 @@
+attributeType "Name" extends StringAttribute {
+ guid "AAMFEcF1AzV7PKuHmxwA"
+ dataProvider DefaultAttributeDataProvider
+ min 1
+ max 1
+ taggerId DefaultAttributeTaggerProvider
+ description "Descriptive Name"
+ defaultValue "unnamed"
+}
+
+attributeType "Annotation" extends CompressedContentAttribute {
+ guid "AAMFEcWy0xc4e3tcemQA"
+ dataProvider UriAttributeDataProvider
+ min 0
+ max unlimited
+ taggerId DefaultAttributeTaggerProvider
+ description "the version \'1.0\' is this \"1.2.0\""
+}
+
+attributeType "WordML" extends WordAttribute {
+ guid "AAMFEcfcGS2V3SqQN2wA"
+ dataProvider UriAttributeDataProvider
+ min 0
+ max 1
+ taggerId XmlAttributeTaggerProvider
+ description "value must comply with WordML xml schema"
+ defaultValue "<w:p xmlns:w=\"http://schemas.microsoft.com/office/word/2003/wordml\"><w:r><w:t></w:t></w:r></w:p>"
+ fileExtension "xml"
+}
+
+relationType "Requirement Relation" {
+ guid "BOkzi3U9VTe2fcUz_9gA"
+ sideAName "requirement-sideA"
+ sideAArtifactType "Requirement"
+ sideBName "subsystem-sideB"
+ sideBArtifactType "SubSystem Requirement"
+ defaultOrderType Lexicographical_Ascending
+ multiplicity ONE_TO_MANY
+}
+
artifactType "Artifact" {
- guid "AAMFDh6S7gRLupAMwywA"
- attribute "Name"
- attribute "Annotation"
+ guid "AAMFDh6S7gRLupAMwywA"
+ attribute "Name"
+ attribute "Annotation"
}
abstract artifactType "Requirement" extends "Artifact" {
- guid "BOm4NmAq+HC1O2hkMagA"
- attribute "Qualification Method"
+ guid "BOm4NmAq+HC1O2hkMagA"
+ attribute "WordML"
}
artifactType "Software Requirement" extends "Requirement" {
- guid "BOm+AIG2snNbAM5FFcwA"
+ guid "BOm+AIG2snNbAM5FFcwA"
}
artifactType "System Requirement" extends "Requirement" {
- guid "BOnAaYTBOG68_Tw5Y_AA"
+ guid "BOnAaYTBOG68_Tw5Y_AA"
}
artifactType "SubSystem Requirement" extends "Requirement" {
- guid "BOnBhJ1XAFGKcrku3LgA"
-}
-
-attributeType "Name" extends StringAttribute {
- guid "AAMFEcF1AzV7PKuHmxwA"
- dataProvider DefaultAttributeDataProvider
- min 1
- max 1
- taggerId DefaultAttributeTaggerProvider
- description "Descriptive Name"
- defaultValue "unnamed"
-}
-
-attributeType "Annotation" extends StringAttribute {
- guid "AAMFEcWy0xc4e3tcemQA"
- dataProvider DefaultAttributeDataProvider
- min 0
- max unlimited
- taggerId DefaultAttributeTaggerProvider
-}
-
-attributeType "Qualification Method" extends StringAttribute {
- guid "BOk_ZLyYxyTYArzi63QA"
- dataProvider DefaultAttributeDataProvider
- min 0
- max unlimited
- taggerId DefaultAttributeTaggerProvider
-}
-
-relationType "Requirement Relation" {
- guid "BOkzi3U9VTe2fcUz_9gA"
- sideAName "requirement-sideA"
- sideAArtifactType "Requirement"
- sideBName "subsystem-sideB"
- sideBArtifactType "SubSystem Requirement"
- defaultOrderType Lexicographical_Ascending
- multiplicity ONE_TO_MANY
-}
-
-
+ guid "BOnBhJ1XAFGKcrku3LgA"
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ArtifactDataProvider.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ArtifactDataProvider.java
index 30e7e675e2c..66f1463703f 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ArtifactDataProvider.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ArtifactDataProvider.java
@@ -11,7 +11,10 @@
package org.eclipse.osee.framework.core.dsl.integration;
import java.util.Collection;
+import org.eclipse.osee.framework.core.data.HasBranch;
+import org.eclipse.osee.framework.core.data.IArtifactToken;
import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.IBasicArtifact;
import org.eclipse.osee.framework.core.model.type.ArtifactType;
@@ -22,21 +25,30 @@ import org.eclipse.osee.framework.core.model.type.RelationType;
*/
public interface ArtifactDataProvider {
- public static interface ArtifactData {
+ public static interface ArtifactProxy extends IArtifactToken, HasBranch {
+
+ @Override
+ IOseeBranch getBranch();
+
+ @Override
+ String getName();
+
+ @Override
String getGuid();
+ @Override
ArtifactType getArtifactType();
boolean isAttributeTypeValid(IAttributeType attributeType) throws OseeCoreException;
Collection<RelationType> getValidRelationTypes() throws OseeCoreException;
- Collection<String> getHierarchy();
+ Collection<ArtifactProxy> getHierarchy();
IBasicArtifact<?> getObject();
}
boolean isApplicable(Object object);
- ArtifactData asCastedObject(Object object) throws OseeCoreException;
+ ArtifactProxy asCastedObject(Object object) throws OseeCoreException;
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java
index db852e5f276..0a0b4dfda7b 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java
@@ -16,7 +16,6 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.dsl.integration.internal.Activator;
import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil;
@@ -37,7 +36,6 @@ import org.eclipse.osee.framework.core.model.type.AttributeType;
import org.eclipse.osee.framework.core.model.type.OseeEnumType;
import org.eclipse.osee.framework.core.model.type.RelationType;
import org.eclipse.osee.framework.core.operation.AbstractOperation;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
/**
* @author Roberto E. Escobar
@@ -98,7 +96,7 @@ public class OseeToXtextOperation extends AbstractOperation {
OseeDsl model = getModelByNamespace(getNamespace(enumType.getName()));
model.getEnumTypes().add(modelType);
- modelType.setName(Strings.quote(enumType.getName()));
+ modelType.setName(enumType.getName());
modelType.setTypeGuid(enumType.getGuid());
for (OseeEnumEntry entry : enumType.values()) {
@@ -106,7 +104,7 @@ public class OseeToXtextOperation extends AbstractOperation {
XOseeEnumEntry entryModelType = getFactory().createXOseeEnumEntry();
modelType.getEnumEntries().add(entryModelType);
- entryModelType.setName(Strings.quote(entry.getName()));
+ entryModelType.setName(entry.getName());
entryModelType.setOrdinal(String.valueOf(entry.ordinal()));
}
}
@@ -123,7 +121,7 @@ public class OseeToXtextOperation extends AbstractOperation {
OseeDsl model = getModelByNamespace(getNamespace(attributeType.getName()));
model.getAttributeTypes().add(modelType);
- modelType.setName(Strings.quote(attributeType.getName()));
+ modelType.setName(attributeType.getName());
modelType.setTypeGuid(attributeType.getGuid());
modelType.setBaseAttributeType(asPrimitiveType(attributeType.getBaseAttributeTypeId()));
modelType.setDataProvider(asPrimitiveType(attributeType.getAttributeProviderId()));
@@ -143,27 +141,17 @@ public class OseeToXtextOperation extends AbstractOperation {
monitor.worked(calculateWork(workPercentage));
}
- private XOseeEnumType toModelEnumType(OseeDsl model, OseeEnumType oseeEnumType) {
- String guid = oseeEnumType.getGuid();
- for (XOseeEnumType type : model.getEnumTypes()) {
- if (guid.equals(type.getTypeGuid())) {
- return type;
- }
- }
- return null;
- }
-
private void populateArtifactTypes(IProgressMonitor monitor, double workPercentage) throws OseeCoreException {
monitor.setTaskName("Artifact Types");
- Collection<? extends IArtifactType> artifactTypes = cache.getArtifactTypeCache().getAll();
- for (IArtifactType artifactType : artifactTypes) {
+ Collection<ArtifactType> artifactTypes = cache.getArtifactTypeCache().getAll();
+ for (ArtifactType artifactType : artifactTypes) {
checkForCancelledStatus(monitor);
XArtifactType modelType = getFactory().createXArtifactType();
OseeDsl model = getModelByNamespace(getNamespace(artifactType.getName()));
model.getArtifactTypes().add(modelType);
- modelType.setName(Strings.quote(artifactType.getName()));
+ modelType.setName(artifactType.getName());
modelType.setTypeGuid(artifactType.getGuid());
}
@@ -234,7 +222,7 @@ public class OseeToXtextOperation extends AbstractOperation {
OseeDsl model = getModelByNamespace(getNamespace(relationType.getName()));
model.getRelationTypes().add(modelType);
- modelType.setName(Strings.quote(relationType.getName()));
+ modelType.setName(relationType.getName());
modelType.setTypeGuid(relationType.getGuid());
modelType.setDefaultOrderType(OseeUtil.getRelationOrderType(relationType.getDefaultOrderTypeGuid()));
@@ -250,18 +238,31 @@ public class OseeToXtextOperation extends AbstractOperation {
}
private XArtifactType getArtifactType(OseeDsl model, String guid) {
- for (XArtifactType artifactType : model.getArtifactTypes()) {
- if (guid.equals(artifactType.getTypeGuid())) {
- return artifactType;
+ for (XArtifactType type : model.getArtifactTypes()) {
+ String normalizedGuid = type.getTypeGuid();
+ if (guid.equals(normalizedGuid)) {
+ return type;
}
}
return null;
}
private XAttributeType getAttributeType(OseeDsl model, String guid) {
- for (XAttributeType attributeType : model.getAttributeTypes()) {
- if (guid.equals(attributeType.getTypeGuid())) {
- return attributeType;
+ for (XAttributeType type : model.getAttributeTypes()) {
+ String normalizedGuid = type.getTypeGuid();
+ if (guid.equals(normalizedGuid)) {
+ return type;
+ }
+ }
+ return null;
+ }
+
+ private XOseeEnumType toModelEnumType(OseeDsl model, OseeEnumType oseeEnumType) {
+ String guid = oseeEnumType.getGuid();
+ for (XOseeEnumType type : model.getEnumTypes()) {
+ String normalizedGuid = type.getTypeGuid();
+ if (guid.equals(normalizedGuid)) {
+ return type;
}
}
return null;
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/RestrictionHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/RestrictionHandler.java
index ce6fee56aa4..c5f961d6752 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/RestrictionHandler.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/RestrictionHandler.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.framework.core.dsl.integration;
-import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactData;
+import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy;
import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.access.AccessDetailCollector;
@@ -21,5 +21,5 @@ import org.eclipse.osee.framework.core.model.access.AccessDetailCollector;
public interface RestrictionHandler<T> {
public T asCastedObject(ObjectRestriction objectRestriction);
- public void process(ObjectRestriction objectRestriction, ArtifactData artifactData, AccessDetailCollector collector) throws OseeCoreException;
+ public void process(ObjectRestriction objectRestriction, ArtifactProxy artifactProxy, AccessDetailCollector collector) throws OseeCoreException;
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java
index aa1791a312e..4585cd0f089 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java
@@ -19,7 +19,6 @@ import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osee.framework.core.data.BranchToken;
-import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.dsl.integration.internal.Activator;
import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil;
@@ -123,7 +122,7 @@ public class XTextToOseeTypeOperation extends AbstractOperation {
private void translateSuperTypes(ArtifactType targetArtifactType, XArtifactType xArtifactType) throws OseeCoreException {
Set<ArtifactType> oseeSuperTypes = new HashSet<ArtifactType>();
for (XArtifactType xSuperType : xArtifactType.getSuperArtifactTypes()) {
- String superTypeName = Strings.unquote(xSuperType.getName());
+ String superTypeName = xSuperType.getName();
ArtifactType oseeSuperType = typeCache.getArtifactTypeCache().getUniqueByName(superTypeName);
oseeSuperTypes.add(oseeSuperType);
}
@@ -168,16 +167,16 @@ public class XTextToOseeTypeOperation extends AbstractOperation {
}
private void translateXArtifactType(XArtifactType xArtifactType) throws OseeCoreException {
- String artifactTypeName = Strings.unquote(xArtifactType.getName());
+ String artifactTypeName = xArtifactType.getName();
- IArtifactType oseeArtifactType =
+ ArtifactType oseeArtifactType =
provider.getArtifactTypeFactory().createOrUpdate(typeCache.getArtifactTypeCache(),
xArtifactType.getTypeGuid(), xArtifactType.isAbstract(), artifactTypeName);
xArtifactType.setTypeGuid(oseeArtifactType.getGuid());
}
private void translateXEnumType(XOseeEnumType xEnumType) throws OseeCoreException {
- String enumTypeName = Strings.unquote(xEnumType.getName());
+ String enumTypeName = xEnumType.getName();
OseeEnumType oseeEnumType =
provider.getOseeEnumTypeFactory().createOrUpdate(typeCache.getEnumTypeCache(), xEnumType.getTypeGuid(),
@@ -186,7 +185,7 @@ public class XTextToOseeTypeOperation extends AbstractOperation {
int lastOrdinal = 0;
List<OseeEnumEntry> oseeEnumEntries = new ArrayList<OseeEnumEntry>();
for (XOseeEnumEntry xEnumEntry : xEnumType.getEnumEntries()) {
- String entryName = Strings.unquote(xEnumEntry.getName());
+ String entryName = xEnumEntry.getName();
String ordinal = xEnumEntry.getOrdinal();
if (Strings.isValid(ordinal)) {
lastOrdinal = Integer.parseInt(ordinal);
@@ -237,7 +236,7 @@ public class XTextToOseeTypeOperation extends AbstractOperation {
AttributeTypeCache cache = typeCache.getAttributeTypeCache();
AttributeType oseeAttributeType = provider.getAttributeTypeFactory().createOrUpdate(cache, //
xAttributeType.getTypeGuid(), //
- Strings.unquote(xAttributeType.getName()), //
+ xAttributeType.getName(), //
getQualifiedTypeName(xAttributeType.getBaseAttributeType()), //
getQualifiedTypeName(xAttributeType.getDataProvider()), //
xAttributeType.getFileExtension(), //
@@ -263,16 +262,16 @@ public class XTextToOseeTypeOperation extends AbstractOperation {
RelationTypeMultiplicity multiplicity =
RelationTypeMultiplicity.getFromString(xRelationType.getMultiplicity().name());
- String sideATypeName = Strings.unquote(xRelationType.getSideAArtifactType().getName());
- String sideBTypeName = Strings.unquote(xRelationType.getSideBArtifactType().getName());
+ String sideATypeName = xRelationType.getSideAArtifactType().getName();
+ String sideBTypeName = xRelationType.getSideBArtifactType().getName();
- IArtifactType sideAType = typeCache.getArtifactTypeCache().getUniqueByName(sideATypeName);
- IArtifactType sideBType = typeCache.getArtifactTypeCache().getUniqueByName(sideBTypeName);
+ ArtifactType sideAType = typeCache.getArtifactTypeCache().getUniqueByName(sideATypeName);
+ ArtifactType sideBType = typeCache.getArtifactTypeCache().getUniqueByName(sideBTypeName);
RelationType oseeRelationType =
provider.getRelationTypeFactory().createOrUpdate(typeCache.getRelationTypeCache(), //
xRelationType.getTypeGuid(), //
- Strings.unquote(xRelationType.getName()), //
+ xRelationType.getName(), //
xRelationType.getSideAName(), //
xRelationType.getSideBName(), //
sideAType, //
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterImpl.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterImpl.java
index 7919401f6e8..40345721e8f 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterImpl.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterImpl.java
@@ -15,15 +15,16 @@ import java.util.HashSet;
import org.eclipse.osee.framework.core.data.AccessContextId;
import org.eclipse.osee.framework.core.dsl.integration.AccessModelInterpreter;
import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider;
-import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactData;
+import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy;
import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler;
import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessContext;
import org.eclipse.osee.framework.core.dsl.oseeDsl.HierarchyRestriction;
import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction;
-import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactRef;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactMatcher;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.access.AccessDetailCollector;
import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
/**
* @author Roberto E. Escobar
@@ -31,10 +32,12 @@ import org.eclipse.osee.framework.core.util.Conditions;
public class AccessModelInterpreterImpl implements AccessModelInterpreter {
private final ArtifactDataProvider provider;
+ private final ArtifactMatchInterpreter matcher;
private final Collection<RestrictionHandler<?>> restrictionHandlers;
- public AccessModelInterpreterImpl(ArtifactDataProvider provider, RestrictionHandler<?>... restricitionHandlers) {
+ public AccessModelInterpreterImpl(ArtifactDataProvider provider, ArtifactMatchInterpreter matcher, RestrictionHandler<?>... restricitionHandlers) {
this.provider = provider;
+ this.matcher = matcher;
this.restrictionHandlers = new HashSet<RestrictionHandler<?>>();
for (RestrictionHandler<?> handler : restricitionHandlers) {
restrictionHandlers.add(handler);
@@ -47,7 +50,7 @@ public class AccessModelInterpreterImpl implements AccessModelInterpreter {
Conditions.checkNotNull(contextId, "accessContextId");
AccessContext toReturn = null;
for (AccessContext accessContext : contexts) {
- if (contextId.getGuid().equals(accessContext.getGuid())) {
+ if (contextId.getGuid().equals(Strings.unquote(accessContext.getGuid()))) {
toReturn = accessContext;
}
}
@@ -61,7 +64,7 @@ public class AccessModelInterpreterImpl implements AccessModelInterpreter {
Conditions.checkNotNull(objectToCheck, "objectToCheck");
if (provider.isApplicable(objectToCheck)) {
- ArtifactData data = provider.asCastedObject(objectToCheck);
+ ArtifactProxy data = provider.asCastedObject(objectToCheck);
Conditions.checkNotNull(data, "artifactData",
"artifact data provider returned null - provider has an isApplicable error");
@@ -69,33 +72,33 @@ public class AccessModelInterpreterImpl implements AccessModelInterpreter {
}
}
- private void collectApplicable(AccessDetailCollector collector, AccessContext context, ArtifactData artifactData) throws OseeCoreException {
+ private void collectApplicable(AccessDetailCollector collector, AccessContext context, ArtifactProxy artifactData) throws OseeCoreException {
processContext(collector, context, artifactData);
for (AccessContext superContext : context.getSuperAccessContexts()) {
collectApplicable(collector, superContext, artifactData);
}
}
- private void processContext(AccessDetailCollector collector, AccessContext context, ArtifactData artifactData) throws OseeCoreException {
+ private void processContext(AccessDetailCollector collector, AccessContext context, ArtifactProxy artifactData) throws OseeCoreException {
collectRestrictions(collector, artifactData, context.getAccessRules());
Collection<HierarchyRestriction> restrictions = context.getHierarchyRestrictions();
- Collection<String> guidHierarchy = artifactData.getHierarchy();
+ Collection<ArtifactProxy> proxyHierarchy = artifactData.getHierarchy();
for (HierarchyRestriction hierarchy : restrictions) {
- XArtifactRef artifactRef = hierarchy.getArtifact();
- boolean isInHierarchy = guidHierarchy.contains(artifactRef.getGuid());
- if (isInHierarchy) {
+ XArtifactMatcher artifactRef = hierarchy.getArtifactMatcherRef();
+ if (matcher.matches(artifactRef, proxyHierarchy)) {
collectRestrictions(collector, artifactData, hierarchy.getAccessRules());
}
}
}
- private void collectRestrictions(AccessDetailCollector collector, ArtifactData artifactData, Collection<ObjectRestriction> restrictions) throws OseeCoreException {
+ private void collectRestrictions(AccessDetailCollector collector, ArtifactProxy artifactData, Collection<ObjectRestriction> restrictions) throws OseeCoreException {
for (ObjectRestriction objectRestriction : restrictions) {
for (RestrictionHandler<?> restrictionHandler : restrictionHandlers) {
restrictionHandler.process(objectRestriction, artifactData, collector);
}
}
}
+
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterServiceRegHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterServiceRegHandler.java
index 8d494faf3c4..805f173dba6 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterServiceRegHandler.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterServiceRegHandler.java
@@ -23,10 +23,7 @@ import org.osgi.framework.ServiceRegistration;
*/
public class AccessModelInterpreterServiceRegHandler extends AbstractTrackingHandler {
- private static final Class<?>[] SERVICE_DEPENDENCIES = new Class<?>[] {
- //
- ArtifactDataProvider.class, //
- };
+ private static final Class<?>[] SERVICE_DEPENDENCIES = new Class<?>[] {ArtifactDataProvider.class};
private ServiceRegistration registration;
@@ -39,15 +36,17 @@ public class AccessModelInterpreterServiceRegHandler extends AbstractTrackingHan
public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
ArtifactDataProvider artifactDataProvider = getService(ArtifactDataProvider.class, services);
- RestrictionHandler<?>[] restrictionHandlers = new RestrictionHandler<?>[] {
- //
- new ArtifactInstanceRestrictionHandler(), //
- new ArtifactTypeRestrictionHandler(), //
- new AttributeTypeRestrictionHandler(), //
- new RelationTypeRestrictionHandler(), //
- };
+ ArtifactMatchInterpreter matcher = new ArtifactMatchInterpreter();
- AccessModelInterpreter service = new AccessModelInterpreterImpl(artifactDataProvider, restrictionHandlers);
+ RestrictionHandler<?>[] restrictionHandlers =
+ new RestrictionHandler<?>[] {
+ new ArtifactMatchRestrictionHandler(matcher),
+ new ArtifactTypeRestrictionHandler(),
+ new AttributeTypeRestrictionHandler(),
+ new RelationTypeRestrictionHandler()};
+
+ AccessModelInterpreter service =
+ new AccessModelInterpreterImpl(artifactDataProvider, matcher, restrictionHandlers);
registration = context.registerService(AccessModelInterpreter.class.getName(), service, null);
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchInterpreter.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchInterpreter.java
new file mode 100644
index 00000000000..cc03dc79b59
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchInterpreter.java
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.dsl.integration.internal;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.CompareOp;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.CompoundCondition;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.Condition;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.MatchField;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.SimpleCondition;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactMatcher;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XLogicOperator;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+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;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ArtifactMatchInterpreter {
+
+ public boolean matches(XArtifactMatcher matcher, Collection<ArtifactProxy> proxies) throws OseeCoreException {
+ boolean matched = false;
+ Iterator<ArtifactProxy> iterator = proxies.iterator();
+ while (iterator.hasNext() && !matched) {
+ matched = matches(matcher, iterator.next());
+ if (matched) {
+ break;
+ }
+ }
+ return matched;
+ }
+
+ public boolean matches(XArtifactMatcher matcher, ArtifactProxy proxy) throws OseeCoreException {
+ List<Condition> conditions = matcher.getConditions();
+ List<XLogicOperator> operators = matcher.getOperators();
+ return evaluate(conditions, operators, proxy);
+ }
+
+ boolean evaluate(List<? extends Condition> conditions, List<? extends XLogicOperator> operators, ArtifactProxy proxy) throws OseeCoreException {
+ boolean result = false;
+ Iterator<? extends Condition> iteratorConds = conditions.iterator();
+ Iterator<? extends XLogicOperator> iteratorOps = operators.iterator();
+ if (iteratorConds.hasNext()) {
+ Condition lastCondition = iteratorConds.next();
+ if (iteratorOps.hasNext()) {
+ while (iteratorOps.hasNext() && iteratorConds.hasNext()) {
+ XLogicOperator op = iteratorOps.next();
+ Condition condition = iteratorConds.next();
+ result = evaluate(op, lastCondition, condition, proxy);
+ }
+ } else {
+ result = evaluate(lastCondition, proxy);
+ }
+ }
+ return result;
+ }
+
+ boolean evaluate(XLogicOperator op, Condition conditionA, Condition conditionB, ArtifactProxy proxy) throws OseeCoreException {
+ boolean result = evaluate(conditionA, proxy);
+ if (op == XLogicOperator.AND) {
+ return result && evaluate(conditionB, proxy);
+ } else if (op == XLogicOperator.OR) {
+ return result || evaluate(conditionB, proxy);
+ }
+ throw new OseeArgumentException("Invalid op defined: %s", op);
+ }
+
+ boolean evaluate(Condition condition, ArtifactProxy proxy) throws OseeCoreException {
+ if (condition instanceof SimpleCondition) {
+ return evaluate((SimpleCondition) condition, proxy);
+ } else if (condition instanceof CompoundCondition) {
+ CompoundCondition group = (CompoundCondition) condition;
+ return evaluate(group.getConditions(), group.getOperators(), proxy);
+ }
+ throw new OseeArgumentException("Invalid Condition defined: %s", condition);
+ }
+
+ boolean evaluate(SimpleCondition condition, ArtifactProxy proxy) throws OseeCoreException {
+ String expression = Strings.unquote(condition.getExpression());
+ Conditions.checkNotNullOrEmpty(expression, "expression");
+
+ String input = null;
+ MatchField field = condition.getField();
+ switch (field) {
+ case ARTIFACT_GUID:
+ input = proxy.getGuid();
+ Conditions.checkExpressionFailOnTrue(!GUID.isValid(input), "guid");
+ break;
+ case BRANCH_GUID:
+ input = proxy.getBranch().getGuid();
+ Conditions.checkExpressionFailOnTrue(!GUID.isValid(input), "guid");
+ break;
+ case ARTIFACT_NAME:
+ input = proxy.getName();
+ break;
+ case BRANCH_NAME:
+ input = proxy.getBranch().getName();
+ break;
+ default:
+ throw new OseeArgumentException("Invalid field [%s]", field);
+ }
+ Conditions.checkNotNullOrEmpty(input, field.getName());
+ CompareOp op = condition.getOp();
+ boolean result = false;
+ if (op == CompareOp.EQ) {
+ result = input.equals(expression);
+ } else if (op == CompareOp.LIKE) {
+ Matcher matcher = expressions.get(expression);
+ if (matcher == null) {
+ Pattern pattern = Pattern.compile(expression);
+ matcher = pattern.matcher("");
+ expressions.put(expression, matcher);
+ }
+ synchronized (matcher) {
+ matcher.reset(input);
+ result = matcher.find();
+ }
+ } else {
+ throw new OseeArgumentException("Invalid CompareOp [%s]", op);
+ }
+ return result;
+ }
+ private final Map<String, Matcher> expressions = new ConcurrentHashMap<String, Matcher>();
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactInstanceRestrictionHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchRestrictionHandler.java
index 78588d98ce8..97e8bf20c29 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactInstanceRestrictionHandler.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchRestrictionHandler.java
@@ -10,12 +10,12 @@
*******************************************************************************/
package org.eclipse.osee.framework.core.dsl.integration.internal;
-import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactData;
+import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy;
import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler;
import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil;
-import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactInstanceRestriction;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactMatchRestriction;
import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction;
-import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactRef;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactMatcher;
import org.eclipse.osee.framework.core.enums.PermissionEnum;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.IBasicArtifact;
@@ -25,25 +25,31 @@ import org.eclipse.osee.framework.core.model.access.AccessDetailCollector;
/**
* @author Roberto E. Escobar
*/
-public class ArtifactInstanceRestrictionHandler implements RestrictionHandler<ArtifactInstanceRestriction> {
+public class ArtifactMatchRestrictionHandler implements RestrictionHandler<ArtifactMatchRestriction> {
+
+ private final ArtifactMatchInterpreter matcherInterpreter;
+
+ public ArtifactMatchRestrictionHandler(ArtifactMatchInterpreter matcherInterpreter) {
+ this.matcherInterpreter = matcherInterpreter;
+ }
@Override
- public ArtifactInstanceRestriction asCastedObject(ObjectRestriction objectRestriction) {
- ArtifactInstanceRestriction toReturn = null;
- if (objectRestriction instanceof ArtifactInstanceRestriction) {
- toReturn = (ArtifactInstanceRestriction) objectRestriction;
+ public ArtifactMatchRestriction asCastedObject(ObjectRestriction objectRestriction) {
+ ArtifactMatchRestriction toReturn = null;
+ if (objectRestriction instanceof ArtifactMatchRestriction) {
+ toReturn = (ArtifactMatchRestriction) objectRestriction;
}
return toReturn;
}
@Override
- public void process(ObjectRestriction objectRestriction, ArtifactData artifactData, AccessDetailCollector collector) throws OseeCoreException {
- ArtifactInstanceRestriction restriction = asCastedObject(objectRestriction);
+ public void process(ObjectRestriction objectRestriction, ArtifactProxy artifactProxy, AccessDetailCollector collector) throws OseeCoreException {
+ ArtifactMatchRestriction restriction = asCastedObject(objectRestriction);
if (restriction != null) {
- XArtifactRef artifactRef = restriction.getArtifactRef();
- if (artifactRef.getGuid().equals(artifactData.getGuid())) {
+ XArtifactMatcher artifactMatcher = restriction.getArtifactMatcherRef();
+ if (matcherInterpreter.matches(artifactMatcher, artifactProxy)) {
PermissionEnum permission = OseeUtil.getPermission(restriction);
- collector.collect(new AccessDetail<IBasicArtifact<?>>(artifactData.getObject(), permission));
+ collector.collect(new AccessDetail<IBasicArtifact<?>>(artifactProxy.getObject(), permission));
}
}
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandler.java
index 28d12e427ab..3e4989464f1 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandler.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandler.java
@@ -11,7 +11,7 @@
package org.eclipse.osee.framework.core.dsl.integration.internal;
import org.eclipse.osee.framework.core.data.IArtifactType;
-import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactData;
+import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy;
import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler;
import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil;
import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactTypeRestriction;
@@ -38,13 +38,13 @@ public class ArtifactTypeRestrictionHandler implements RestrictionHandler<Artifa
}
@Override
- public void process(ObjectRestriction objectRestriction, ArtifactData artifactData, AccessDetailCollector collector) throws OseeCoreException {
+ public void process(ObjectRestriction objectRestriction, ArtifactProxy artifactProxy, AccessDetailCollector collector) throws OseeCoreException {
ArtifactTypeRestriction restriction = asCastedObject(objectRestriction);
if (restriction != null) {
XArtifactType artifactTypeRef = restriction.getArtifactTypeRef();
IArtifactType typeToMatch = OseeUtil.toToken(artifactTypeRef);
- ArtifactType artifactType = artifactData.getArtifactType();
+ ArtifactType artifactType = artifactProxy.getArtifactType();
boolean isOfType = artifactType != null && artifactType.inheritsFrom(typeToMatch);
if (isOfType) {
PermissionEnum permission = OseeUtil.getPermission(restriction);
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AttributeTypeRestrictionHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AttributeTypeRestrictionHandler.java
index eae91a504a5..681210bdf8f 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AttributeTypeRestrictionHandler.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AttributeTypeRestrictionHandler.java
@@ -12,7 +12,7 @@ package org.eclipse.osee.framework.core.dsl.integration.internal;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IAttributeType;
-import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactData;
+import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy;
import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler;
import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil;
import org.eclipse.osee.framework.core.dsl.oseeDsl.AttributeTypeRestriction;
@@ -40,18 +40,18 @@ public class AttributeTypeRestrictionHandler implements RestrictionHandler<Attri
}
@Override
- public void process(ObjectRestriction objectRestriction, ArtifactData artifactData, AccessDetailCollector collector) throws OseeCoreException {
+ public void process(ObjectRestriction objectRestriction, ArtifactProxy artifactProxy, AccessDetailCollector collector) throws OseeCoreException {
AttributeTypeRestriction restriction = asCastedObject(objectRestriction);
if (restriction != null) {
XAttributeType attributeTypeRef = restriction.getAttributeTypeRef();
IAttributeType attributeTypeToMatch = OseeUtil.toToken(attributeTypeRef);
- boolean isApplicable = artifactData.isAttributeTypeValid(attributeTypeToMatch);
+ boolean isApplicable = artifactProxy.isAttributeTypeValid(attributeTypeToMatch);
if (isApplicable) {
XArtifactType artifactTypeRef = restriction.getArtifactTypeRef();
if (artifactTypeRef != null) {
isApplicable = false;
IArtifactType typeToMatch = OseeUtil.toToken(artifactTypeRef);
- ArtifactType artifactType = artifactData.getArtifactType();
+ ArtifactType artifactType = artifactProxy.getArtifactType();
isApplicable = artifactType.inheritsFrom(typeToMatch);
}
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/RelationTypeRestrictionHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/RelationTypeRestrictionHandler.java
index c9845ec92f8..7cc814b8b78 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/RelationTypeRestrictionHandler.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/RelationTypeRestrictionHandler.java
@@ -12,7 +12,7 @@ package org.eclipse.osee.framework.core.dsl.integration.internal;
import java.util.Collection;
import org.eclipse.osee.framework.core.data.IRelationType;
-import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactData;
+import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy;
import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler;
import org.eclipse.osee.framework.core.dsl.integration.util.OseeUtil;
import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction;
@@ -43,16 +43,16 @@ public class RelationTypeRestrictionHandler implements RestrictionHandler<Relati
}
@Override
- public void process(ObjectRestriction objectRestriction, ArtifactData artifactData, AccessDetailCollector collector) throws OseeCoreException {
+ public void process(ObjectRestriction objectRestriction, ArtifactProxy artifactProxy, AccessDetailCollector collector) throws OseeCoreException {
RelationTypeRestriction restriction = asCastedObject(objectRestriction);
if (restriction != null) {
XRelationType relationTypeRef = restriction.getRelationTypeRef();
XRelationSideEnum restrictedSide = restriction.getRestrictedToSide();
IRelationType typeToMatch = OseeUtil.toToken(relationTypeRef);
- RelationType relationType = getRelationType(typeToMatch, artifactData);
+ RelationType relationType = getRelationType(typeToMatch, artifactProxy);
if (relationType != null) {
- ArtifactType artifactType = artifactData.getArtifactType();
+ ArtifactType artifactType = artifactProxy.getArtifactType();
for (RelationSide relationSide : RelationSide.values()) {
if (OseeUtil.isRestrictedSide(restrictedSide, relationSide)) {
@@ -68,9 +68,9 @@ public class RelationTypeRestrictionHandler implements RestrictionHandler<Relati
}
}
- private RelationType getRelationType(IRelationType typeToMatch, ArtifactData artifact) throws OseeCoreException {
+ private RelationType getRelationType(IRelationType typeToMatch, ArtifactProxy artifactProxy) throws OseeCoreException {
RelationType toReturn = null;
- Collection<RelationType> relationTypes = artifact.getValidRelationTypes();
+ Collection<RelationType> relationTypes = artifactProxy.getValidRelationTypes();
for (RelationType relationType : relationTypes) {
if (relationType.equals(typeToMatch)) {
toReturn = relationType;
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/OseeUtil.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/OseeUtil.java
index c43b9034878..c53c05d2609 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/OseeUtil.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/util/OseeUtil.java
@@ -37,15 +37,15 @@ public final class OseeUtil {
}
public static IArtifactType toToken(XArtifactType model) {
- return TokenFactory.createArtifactType(model.getTypeGuid(), Strings.unquote(model.getName()));
+ return TokenFactory.createArtifactType(Strings.unquote(model.getTypeGuid()), Strings.unquote(model.getName()));
}
public static IAttributeType toToken(XAttributeType model) {
- return TokenFactory.createAttributeType(model.getTypeGuid(), Strings.unquote(model.getName()));
+ return TokenFactory.createAttributeType(Strings.unquote(model.getTypeGuid()), Strings.unquote(model.getName()));
}
public static IRelationType toToken(XRelationType model) {
- return TokenFactory.createRelationType(model.getTypeGuid(), Strings.unquote(model.getName()));
+ return TokenFactory.createRelationType(Strings.unquote(model.getTypeGuid()), Strings.unquote(model.getName()));
}
public static boolean isRestrictedSide(XRelationSideEnum relationSideEnum, RelationSide relationSide) throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/ArtifactDataAccessor.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/ArtifactDataAccessor.java
index 69c7afa6d5c..5d6ae1c27c2 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/ArtifactDataAccessor.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/ArtifactDataAccessor.java
@@ -14,6 +14,9 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.logging.Level;
import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.data.Identity;
+import org.eclipse.osee.framework.core.data.Named;
import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
@@ -38,58 +41,58 @@ public final class ArtifactDataAccessor implements ArtifactDataProvider {
}
@Override
- public ArtifactData asCastedObject(Object object) throws OseeCoreException {
- ArtifactData wrapper = null;
+ public ArtifactProxy asCastedObject(Object object) throws OseeCoreException {
+ XArtifactProxy proxy = null;
if (object instanceof Artifact) {
final Artifact artifact = (Artifact) object;
- wrapper = new ArtifactWrapper(artifact);
+ proxy = new XArtifactProxy(artifact);
} else if (object instanceof Branch) {
Branch branch = (Branch) object;
final Artifact artifact = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(branch);
- wrapper = new ArtifactWrapper(artifact);
+ proxy = new XArtifactProxy(artifact);
}
- return wrapper;
+ return proxy;
}
- private final class ArtifactWrapper implements ArtifactData {
- private final Artifact artifact;
+ private final class XArtifactProxy implements ArtifactProxy {
+ private final Artifact self;
- public ArtifactWrapper(Artifact artifact) {
- this.artifact = artifact;
+ public XArtifactProxy(Artifact self) {
+ this.self = self;
}
@Override
public String getGuid() {
- return artifact.getGuid();
+ return self.getGuid();
}
@Override
public ArtifactType getArtifactType() {
- return artifact.getArtifactType();
+ return self.getArtifactType();
}
@Override
public boolean isAttributeTypeValid(IAttributeType attributeType) throws OseeCoreException {
- return artifact.isAttributeTypeValid(attributeType);
+ return self.isAttributeTypeValid(attributeType);
}
@Override
public Collection<RelationType> getValidRelationTypes() throws OseeCoreException {
- return artifact.getValidRelationTypes();
+ return self.getValidRelationTypes();
}
@Override
public IBasicArtifact<?> getObject() {
- return artifact;
+ return self;
}
@Override
- public Collection<String> getHierarchy() {
- Collection<String> hierarchy = new HashSet<String>();
+ public Collection<ArtifactProxy> getHierarchy() {
+ Collection<ArtifactProxy> hierarchy = new HashSet<ArtifactProxy>();
try {
- Artifact artifactPtr = artifact;
+ Artifact artifactPtr = self;
while (artifactPtr != null) {
- hierarchy.add(artifactPtr.getGuid());
+ hierarchy.add(new XArtifactProxy(artifactPtr));
artifactPtr = artifactPtr.getParent();
}
} catch (OseeCoreException ex) {
@@ -97,5 +100,45 @@ public final class ArtifactDataAccessor implements ArtifactDataProvider {
}
return hierarchy;
}
+
+ @Override
+ public boolean matches(Identity... identities) {
+ return self.matches(identities);
+ }
+
+ @Override
+ public String getUnqualifiedName() {
+ return self.getUnqualifiedName();
+ }
+
+ @Override
+ public int compareTo(Named other) {
+ return self.compareTo(other);
+ }
+
+ @Override
+ public IOseeBranch getBranch() {
+ return self.getBranch();
+ }
+
+ @Override
+ public String getName() {
+ return self.getName();
+ }
+
+ @Override
+ public int hashCode() {
+ return self.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return self.equals(obj);
+ }
+
+ @Override
+ public String toString() {
+ return self.toString();
+ }
}
} \ No newline at end of file

Back to the top