Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-08-03 21:13:46 +0000
committerrescobar2010-08-03 21:13:46 +0000
commit89b8c8054171a7dc1b8e2efddf26088791675885 (patch)
treeeb378f4b172ae504e1e0b3acb8a18bd8effa83a3 /plugins/org.eclipse.osee.framework.core.dsl.integration
parentfee8a93ec9a4aa9ea461e94f2341b7898e063127 (diff)
downloadorg.eclipse.osee-89b8c8054171a7dc1b8e2efddf26088791675885.tar.gz
org.eclipse.osee-89b8c8054171a7dc1b8e2efddf26088791675885.tar.xz
org.eclipse.osee-89b8c8054171a7dc1b8e2efddf26088791675885.zip
"Team Workflow" - YGHW1 - "Block changes to requirements unless done under an appropriate action."
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.dsl.integration')
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/AccessModelInterpreter.java6
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeAccessModelInterpreter.java199
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeDslToAccessDataOperation.java23
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeToXtextOperation.java23
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeUtil.java26
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/RestrictionHandler.java25
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/XTextToOseeTypeOperation.java28
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterImpl.java90
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterServiceRegHandler.java61
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/Activator.java13
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactInstanceRestrictionHandler.java51
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandler.java56
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AttributeTypeRestrictionHandler.java66
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/RelationTypeRestrictionHandler.java82
14 files changed, 502 insertions, 247 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/AccessModelInterpreter.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/AccessModelInterpreter.java
index de9371b7bb..20ea0572ca 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/AccessModelInterpreter.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/AccessModelInterpreter.java
@@ -21,8 +21,12 @@ import org.eclipse.osee.framework.core.model.access.AccessDetail;
*/
public interface AccessModelInterpreter {
+ public static interface AccessDetailCollector {
+ void collect(AccessDetail<?> accessDetail) throws OseeCoreException;
+ }
+
AccessContext getContext(Collection<AccessContext> contexts, AccessContextId contextId) throws OseeCoreException;
- void computeAccessDetails(AccessContext context, Object objectToCheck, Collection<AccessDetail<?>> details) throws OseeCoreException;
+ void computeAccessDetails(AccessDetailCollector collector, AccessContext context, Object objectToCheck) throws OseeCoreException;
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeAccessModelInterpreter.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeAccessModelInterpreter.java
deleted file mode 100644
index 6e5af8118d..0000000000
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeAccessModelInterpreter.java
+++ /dev/null
@@ -1,199 +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;
-
-import java.util.Collection;
-import org.eclipse.osee.framework.core.data.AccessContextId;
-import org.eclipse.osee.framework.core.data.IArtifactType;
-import org.eclipse.osee.framework.core.data.IAttributeType;
-import org.eclipse.osee.framework.core.data.IRelationType;
-import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactData;
-import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessContext;
-import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactInstanceRestriction;
-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.HierarchyRestriction;
-import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction;
-import org.eclipse.osee.framework.core.dsl.oseeDsl.RelationTypeRestriction;
-import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactRef;
-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.enums.PermissionEnum;
-import org.eclipse.osee.framework.core.enums.RelationSide;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.IBasicArtifact;
-import org.eclipse.osee.framework.core.model.RelationTypeSide;
-import org.eclipse.osee.framework.core.model.access.AccessDetail;
-import org.eclipse.osee.framework.core.model.type.ArtifactType;
-import org.eclipse.osee.framework.core.model.type.RelationType;
-
-/**
- * @author Roberto E. Escobar
- */
-public class OseeAccessModelInterpreter implements AccessModelInterpreter {
-
- private final ArtifactDataProvider provider;
-
- public OseeAccessModelInterpreter(ArtifactDataProvider provider) {
- this.provider = provider;
- }
-
- @Override
- public AccessContext getContext(Collection<AccessContext> contexts, AccessContextId contextId) {
- AccessContext toReturn = null;
- for (AccessContext accessContext : contexts) {
- if (contextId.getGuid().equals(accessContext.getGuid())) {
- toReturn = accessContext;
- }
- }
- return toReturn;
- }
-
- @Override
- public void computeAccessDetails(AccessContext context, Object objectToCheck, Collection<AccessDetail<?>> details) throws OseeCoreException {
- if (provider.isApplicable(objectToCheck)) {
- ArtifactData data = provider.asCastedObject(objectToCheck);
- collectApplicable(context, data, details);
- }
- }
-
- private void collectApplicable(AccessContext context, ArtifactData artifactData, Collection<AccessDetail<?>> details) throws OseeCoreException {
- processContext(context, artifactData, details);
- for (AccessContext superContext : context.getSuperAccessContexts()) {
- collectApplicable(superContext, artifactData, details);
- }
- }
-
- private void processContext(AccessContext context, ArtifactData artifactData, Collection<AccessDetail<?>> details) throws OseeCoreException {
- collectRestrictions(artifactData, context.getAccessRules(), details);
- Collection<HierarchyRestriction> restrictions = context.getHierarchyRestrictions();
-
- Collection<String> guidHierarchy = artifactData.getHierarchy();
-
- for (HierarchyRestriction hierarchy : restrictions) {
- XArtifactRef artifactRef = hierarchy.getArtifact();
- boolean isInHierarchy = guidHierarchy.contains(artifactRef.getGuid());
- if (isInHierarchy) {
- collectRestrictions(artifactData, hierarchy.getAccessRules(), details);
- }
- }
- }
-
- private void collectRestrictions(ArtifactData artifactData, Collection<ObjectRestriction> restrictions, Collection<AccessDetail<?>> details) throws OseeCoreException {
- for (ObjectRestriction objectRestriction : restrictions) {
- AccessDetail<?> access = getAccess(objectRestriction, artifactData);
- if (access != null) {
- if (!details.contains(access)) {
- details.add(access);
- }
- }
- }
- }
-
- private AccessDetail<?> getAccess(ObjectRestriction restriction, ArtifactData artifactData) throws OseeCoreException {
- AccessDetail<?> toReturn = null;
- if (restriction instanceof ArtifactInstanceRestriction) {
- toReturn = toAccessDetail((ArtifactInstanceRestriction) restriction, artifactData);
- } else if (restriction instanceof ArtifactTypeRestriction) {
- toReturn = toAccessDetail((ArtifactTypeRestriction) restriction, artifactData);
- } else if (restriction instanceof AttributeTypeRestriction) {
- toReturn = toAccessDetail((AttributeTypeRestriction) restriction, artifactData);
- } else if (restriction instanceof RelationTypeRestriction) {
- toReturn = toAccessDetail((RelationTypeRestriction) restriction, artifactData);
- }
- return toReturn;
- }
-
- private AccessDetail<?> toAccessDetail(ArtifactInstanceRestriction restriction, ArtifactData artifactData) throws OseeCoreException {
- AccessDetail<?> toReturn = null;
- XArtifactRef artifactRef = restriction.getArtifactRef();
- if (artifactRef.getGuid().equals(artifactData.getGuid())) {
- PermissionEnum premission = OseeUtil.getPermission(restriction);
- toReturn = new AccessDetail<IBasicArtifact<?>>(artifactData.getObject(), premission);
- }
- return toReturn;
- }
-
- private AccessDetail<?> toAccessDetail(ArtifactTypeRestriction restriction, ArtifactData artifactData) throws OseeCoreException {
- AccessDetail<?> toReturn = null;
- XArtifactType artifactTypeRef = restriction.getArtifactTypeRef();
- IArtifactType typeToMatch = OseeUtil.toToken(artifactTypeRef);
-
- ArtifactType artifactType = artifactData.getArtifactType();
- boolean isOfType = artifactType != null && artifactType.inheritsFrom(typeToMatch);
- if (isOfType) {
- PermissionEnum premission = OseeUtil.getPermission(restriction);
- toReturn = new AccessDetail<IArtifactType>(artifactType, premission);
- }
- return toReturn;
- }
-
- private AccessDetail<?> toAccessDetail(AttributeTypeRestriction restriction, ArtifactData artifactData) throws OseeCoreException {
- AccessDetail<?> toReturn = null;
- XAttributeType attributeTypeRef = restriction.getAttributeTypeRef();
- IAttributeType attributeTypeToMatch = OseeUtil.toToken(attributeTypeRef);
- boolean isApplicable = artifactData.isAttributeTypeValid(attributeTypeToMatch);
- if (isApplicable) {
- XArtifactType artifactTypeRef = restriction.getArtifactTypeRef();
- if (artifactTypeRef != null) {
- isApplicable = false;
- IArtifactType typeToMatch = OseeUtil.toToken(artifactTypeRef);
- ArtifactType artifactType = artifactData.getArtifactType();
- isApplicable = artifactType.inheritsFrom(typeToMatch);
- }
- }
-
- if (isApplicable) {
- PermissionEnum premission = OseeUtil.getPermission(restriction);
- toReturn = new AccessDetail<IAttributeType>(attributeTypeToMatch, premission);
- }
- return toReturn;
- }
-
- private AccessDetail<?> toAccessDetail(RelationTypeRestriction restriction, ArtifactData artifactData) throws OseeCoreException {
- AccessDetail<?> toReturn = null;
-
- XRelationType relationTypeRef = restriction.getRelationTypeRef();
- XRelationSideEnum restrictedSide = restriction.getRestrictedToSide();
-
- IRelationType typeToMatch = OseeUtil.toToken(relationTypeRef);
- RelationType relationType = getRelationTypes(typeToMatch, artifactData);
- if (relationType != null) {
- ArtifactType artifactType = artifactData.getArtifactType();
- for (RelationSide relationSide : RelationSide.values()) {
- if (OseeUtil.isRestrictedSide(restrictedSide, relationSide)) {
-
- boolean isApplicable = relationType.isArtifactTypeAllowed(relationSide, artifactType);
- if (isApplicable) {
- PermissionEnum premission = OseeUtil.getPermission(restriction);
- toReturn =
- new AccessDetail<RelationTypeSide>(new RelationTypeSide(relationType, relationSide), premission);
- }
- }
- }
- }
- return toReturn;
- }
-
- private RelationType getRelationTypes(IRelationType typeToMatch, ArtifactData artifact) throws OseeCoreException {
- RelationType toReturn = null;
- Collection<RelationType> relationTypes = artifact.getValidRelationTypes();
- for (RelationType relationType : relationTypes) {
- if (relationType.equals(typeToMatch)) {
- toReturn = relationType;
- break;
- }
- }
- return toReturn;
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeDslToAccessDataOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeDslToAccessDataOperation.java
index df9f88c6aa..cf42c543f6 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeDslToAccessDataOperation.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeDslToAccessDataOperation.java
@@ -14,6 +14,7 @@ import java.util.Collection;
import java.util.HashSet;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osee.framework.core.data.AccessContextId;
+import org.eclipse.osee.framework.core.dsl.integration.AccessModelInterpreter.AccessDetailCollector;
import org.eclipse.osee.framework.core.dsl.integration.internal.Activator;
import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessContext;
import org.eclipse.osee.framework.core.model.access.AccessData;
@@ -54,10 +55,30 @@ public class OseeDslToAccessDataOperation extends AbstractOperation {
for (Object objectToCheck : objectsToCheck) {
checkForCancelledStatus(monitor);
Collection<AccessDetail<?>> accessDetail = new HashSet<AccessDetail<?>>();
- interpreter.computeAccessDetails(context, objectToCheck, accessDetail);
+
+ AccessDetailCollector collector = new AccessDataCollector(accessDetail);
+ interpreter.computeAccessDetails(collector, context, objectToCheck);
accessData.addAll(objectToCheck, accessDetail);
monitor.worked(step);
}
}
}
+
+ private static final class AccessDataCollector implements AccessDetailCollector {
+ private final Collection<AccessDetail<?>> accessDetails;
+
+ public AccessDataCollector(Collection<AccessDetail<?>> accessDetails) {
+ this.accessDetails = accessDetails;
+ }
+
+ @Override
+ public void collect(AccessDetail<?> accessDetail) {
+ if (accessDetail != null) {
+ if (!accessDetails.contains(accessDetail)) {
+ accessDetails.add(accessDetail);
+ }
+ }
+ }
+
+ }
}
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 a6b2baefe7..5817833ccf 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
@@ -26,8 +26,6 @@ import org.eclipse.osee.framework.core.dsl.oseeDsl.XAttributeTypeRef;
import org.eclipse.osee.framework.core.dsl.oseeDsl.XOseeEnumEntry;
import org.eclipse.osee.framework.core.dsl.oseeDsl.XOseeEnumType;
import org.eclipse.osee.framework.core.dsl.oseeDsl.XRelationType;
-import org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes;
-import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.OseeEnumEntry;
@@ -36,6 +34,7 @@ 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
@@ -96,7 +95,7 @@ public class OseeToXtextOperation extends AbstractOperation {
OseeDsl model = getModelByNamespace(getNamespace(enumType.getName()));
model.getEnumTypes().add(modelType);
- modelType.setName(asQuoted(enumType.getName()));
+ modelType.setName(Strings.quote(enumType.getName()));
modelType.setTypeGuid(enumType.getGuid());
for (OseeEnumEntry entry : enumType.values()) {
@@ -104,7 +103,7 @@ public class OseeToXtextOperation extends AbstractOperation {
XOseeEnumEntry entryModelType = getFactory().createXOseeEnumEntry();
modelType.getEnumEntries().add(entryModelType);
- entryModelType.setName(asQuoted(entry.getName()));
+ entryModelType.setName(Strings.quote(entry.getName()));
entryModelType.setOrdinal(String.valueOf(entry.ordinal()));
}
}
@@ -121,7 +120,7 @@ public class OseeToXtextOperation extends AbstractOperation {
OseeDsl model = getModelByNamespace(getNamespace(attributeType.getName()));
model.getAttributeTypes().add(modelType);
- modelType.setName(asQuoted(attributeType.getName()));
+ modelType.setName(Strings.quote(attributeType.getName()));
modelType.setTypeGuid(attributeType.getGuid());
modelType.setBaseAttributeType(asPrimitiveType(attributeType.getBaseAttributeTypeId()));
modelType.setDataProvider(asPrimitiveType(attributeType.getAttributeProviderId()));
@@ -161,7 +160,7 @@ public class OseeToXtextOperation extends AbstractOperation {
OseeDsl model = getModelByNamespace(getNamespace(artifactType.getName()));
model.getArtifactTypes().add(modelType);
- modelType.setName(asQuoted(artifactType.getName()));
+ modelType.setName(Strings.quote(artifactType.getName()));
modelType.setTypeGuid(artifactType.getGuid());
}
@@ -232,10 +231,10 @@ public class OseeToXtextOperation extends AbstractOperation {
OseeDsl model = getModelByNamespace(getNamespace(relationType.getName()));
model.getRelationTypes().add(modelType);
- modelType.setName(asQuoted(relationType.getName()));
+ modelType.setName(Strings.quote(relationType.getName()));
modelType.setTypeGuid(relationType.getGuid());
- modelType.setDefaultOrderType(getRelationOrderType(relationType.getDefaultOrderTypeGuid()));
+ modelType.setDefaultOrderType(OseeUtil.getRelationOrderType(relationType.getDefaultOrderTypeGuid()));
modelType.setMultiplicity(RelationMultiplicityEnum.getByName(relationType.getMultiplicity().name()));
modelType.setSideAName(relationType.getSideAName());
@@ -265,12 +264,4 @@ public class OseeToXtextOperation extends AbstractOperation {
return null;
}
- private String getRelationOrderType(String guid) throws OseeArgumentException {
- RelationOrderBaseTypes type = RelationOrderBaseTypes.getFromGuid(guid);
- return type.getName().replaceAll(" ", "_");
- }
-
- private String asQuoted(String name) {
- return "\"" + name + "\"";
- }
}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeUtil.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeUtil.java
index 0e81f08a25..87694b2264 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeUtil.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeUtil.java
@@ -21,9 +21,11 @@ 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.enums.PermissionEnum;
+import org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes;
import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
/**
* @author Roberto E. Escobar
@@ -48,27 +50,26 @@ public final class OseeUtil {
private final static class ArtifactTypeToken extends NamedIdentity implements IArtifactType {
public ArtifactTypeToken(XArtifactType model) {
- super(model.getTypeGuid(), unquote(model.getName()));
+ super(model.getTypeGuid(), Strings.unquote(model.getName()));
}
}
private final static class AttributeTypeToken extends NamedIdentity implements IAttributeType {
public AttributeTypeToken(XAttributeType model) {
- super(model.getTypeGuid(), unquote(model.getName()));
+ super(model.getTypeGuid(), Strings.unquote(model.getName()));
}
}
private final static class RelationTypeToken extends NamedIdentity implements IRelationType {
public RelationTypeToken(XRelationType model) {
- super(model.getTypeGuid(), unquote(model.getName()));
+ super(model.getTypeGuid(), Strings.unquote(model.getName()));
}
}
- private static String unquote(String nameReference) {
- return nameReference != null ? nameReference.substring(1, nameReference.length() - 1) : nameReference;
- }
+ public static boolean isRestrictedSide(XRelationSideEnum relationSideEnum, RelationSide relationSide) throws OseeCoreException {
+ Conditions.checkNotNull(relationSideEnum, "relation side restriction");
+ Conditions.checkNotNull(relationSide, "relation side");
- public static boolean isRestrictedSide(XRelationSideEnum relationSideEnum, RelationSide relationSide) {
boolean toReturn = false;
switch (relationSideEnum) {
case BOTH:
@@ -98,4 +99,15 @@ public final class OseeUtil {
}
return toReturn;
}
+
+ public static String getRelationOrderType(String guid) throws OseeCoreException {
+ RelationOrderBaseTypes type = RelationOrderBaseTypes.getFromGuid(guid);
+ return type.getName().replaceAll(" ", "_");
+ }
+
+ public static String orderTypeNameToGuid(String orderTypeName) throws OseeCoreException {
+ Conditions.checkNotNull(orderTypeName, "orderTypeName");
+ return RelationOrderBaseTypes.getFromOrderTypeName(orderTypeName.replaceAll("_", " ")).getGuid();
+ }
+
}
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
new file mode 100644
index 0000000000..c7d9e0c52d
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/RestrictionHandler.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.osee.framework.core.dsl.integration.AccessModelInterpreter.AccessDetailCollector;
+import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactData;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface RestrictionHandler<T> {
+ public T asCastedObject(ObjectRestriction objectRestriction);
+
+ public void process(ObjectRestriction objectRestriction, ArtifactData artifactData, 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 fd5944c9a7..05b05de900 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
@@ -31,9 +31,7 @@ import org.eclipse.osee.framework.core.dsl.oseeDsl.XOseeEnumEntry;
import org.eclipse.osee.framework.core.dsl.oseeDsl.XOseeEnumOverride;
import org.eclipse.osee.framework.core.dsl.oseeDsl.XOseeEnumType;
import org.eclipse.osee.framework.core.dsl.oseeDsl.XRelationType;
-import org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes;
import org.eclipse.osee.framework.core.enums.RelationTypeMultiplicity;
-import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeStateException;
import org.eclipse.osee.framework.core.model.Branch;
@@ -121,7 +119,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 = removeQuotes(xSuperType.getName());
+ String superTypeName = Strings.unquote(xSuperType.getName());
ArtifactType oseeSuperType = typeCache.getArtifactTypeCache().getUniqueByName(superTypeName);
oseeSuperTypes.add(oseeSuperType);
}
@@ -158,12 +156,8 @@ public class XTextToOseeTypeOperation extends AbstractOperation {
}
}
- private String removeQuotes(String nameReference) {
- return nameReference != null ? nameReference.substring(1, nameReference.length() - 1) : nameReference;
- }
-
private void translateXArtifactType(XArtifactType xArtifactType) throws OseeCoreException {
- String artifactTypeName = removeQuotes(xArtifactType.getName());
+ String artifactTypeName = Strings.unquote(xArtifactType.getName());
ArtifactType oseeArtifactType =
provider.getArtifactTypeFactory().createOrUpdate(typeCache.getArtifactTypeCache(),
@@ -172,7 +166,7 @@ public class XTextToOseeTypeOperation extends AbstractOperation {
}
private void translateXEnumType(XOseeEnumType xEnumType) throws OseeCoreException {
- String enumTypeName = removeQuotes(xEnumType.getName());
+ String enumTypeName = Strings.unquote(xEnumType.getName());
OseeEnumType oseeEnumType =
provider.getOseeEnumTypeFactory().createOrUpdate(typeCache.getEnumTypeCache(), xEnumType.getTypeGuid(),
@@ -181,7 +175,7 @@ public class XTextToOseeTypeOperation extends AbstractOperation {
int lastOrdinal = 0;
List<OseeEnumEntry> oseeEnumEntries = new ArrayList<OseeEnumEntry>();
for (XOseeEnumEntry xEnumEntry : xEnumType.getEnumEntries()) {
- String entryName = removeQuotes(xEnumEntry.getName());
+ String entryName = Strings.unquote(xEnumEntry.getName());
String ordinal = xEnumEntry.getOrdinal();
if (Strings.isValid(ordinal)) {
lastOrdinal = Integer.parseInt(ordinal);
@@ -232,7 +226,7 @@ public class XTextToOseeTypeOperation extends AbstractOperation {
AttributeTypeCache cache = typeCache.getAttributeTypeCache();
AttributeType oseeAttributeType = provider.getAttributeTypeFactory().createOrUpdate(cache, //
xAttributeType.getTypeGuid(), //
- removeQuotes(xAttributeType.getName()), //
+ Strings.unquote(xAttributeType.getName()), //
getQualifiedTypeName(xAttributeType.getBaseAttributeType()), //
getQualifiedTypeName(xAttributeType.getDataProvider()), //
xAttributeType.getFileExtension(), //
@@ -258,8 +252,8 @@ public class XTextToOseeTypeOperation extends AbstractOperation {
RelationTypeMultiplicity multiplicity =
RelationTypeMultiplicity.getFromString(xRelationType.getMultiplicity().name());
- String sideATypeName = removeQuotes(xRelationType.getSideAArtifactType().getName());
- String sideBTypeName = removeQuotes(xRelationType.getSideBArtifactType().getName());
+ String sideATypeName = Strings.unquote(xRelationType.getSideAArtifactType().getName());
+ String sideBTypeName = Strings.unquote(xRelationType.getSideBArtifactType().getName());
ArtifactType sideAType = typeCache.getArtifactTypeCache().getUniqueByName(sideATypeName);
ArtifactType sideBType = typeCache.getArtifactTypeCache().getUniqueByName(sideBTypeName);
@@ -267,20 +261,16 @@ public class XTextToOseeTypeOperation extends AbstractOperation {
RelationType oseeRelationType =
provider.getRelationTypeFactory().createOrUpdate(typeCache.getRelationTypeCache(), //
xRelationType.getTypeGuid(), //
- removeQuotes(xRelationType.getName()), //
+ Strings.unquote(xRelationType.getName()), //
xRelationType.getSideAName(), //
xRelationType.getSideBName(), //
sideAType, //
sideBType, //
multiplicity, //
- convertOrderTypeNameToGuid(xRelationType.getDefaultOrderType()) //
+ OseeUtil.orderTypeNameToGuid(xRelationType.getDefaultOrderType()) //
);
xRelationType.setTypeGuid(oseeRelationType.getGuid());
}
- private String convertOrderTypeNameToGuid(String orderTypeName) throws OseeArgumentException {
- return RelationOrderBaseTypes.getFromOrderTypeName(orderTypeName.replaceAll("_", " ")).getGuid();
- }
-
}
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
new file mode 100644
index 0000000000..a09a0090c1
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterImpl.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * 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.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.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.exception.OseeCoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AccessModelInterpreterImpl implements AccessModelInterpreter {
+
+ private final ArtifactDataProvider provider;
+ private final Collection<RestrictionHandler<?>> restrictionHandlers;
+
+ public AccessModelInterpreterImpl(ArtifactDataProvider provider, RestrictionHandler<?>... restricitionHandlers) {
+ this.provider = provider;
+ this.restrictionHandlers = new HashSet<RestrictionHandler<?>>();
+ for (RestrictionHandler<?> handler : restricitionHandlers) {
+ restrictionHandlers.add(handler);
+ }
+ }
+
+ @Override
+ public AccessContext getContext(Collection<AccessContext> contexts, AccessContextId contextId) {
+ AccessContext toReturn = null;
+ for (AccessContext accessContext : contexts) {
+ if (contextId.getGuid().equals(accessContext.getGuid())) {
+ toReturn = accessContext;
+ }
+ }
+ return toReturn;
+ }
+
+ @Override
+ public void computeAccessDetails(AccessDetailCollector collector, AccessContext context, Object objectToCheck) throws OseeCoreException {
+ if (provider.isApplicable(objectToCheck)) {
+ ArtifactData data = provider.asCastedObject(objectToCheck);
+ collectApplicable(collector, context, data);
+ }
+ }
+
+ private void collectApplicable(AccessDetailCollector collector, AccessContext context, ArtifactData 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 {
+ collectRestrictions(collector, artifactData, context.getAccessRules());
+ Collection<HierarchyRestriction> restrictions = context.getHierarchyRestrictions();
+
+ Collection<String> guidHierarchy = artifactData.getHierarchy();
+
+ for (HierarchyRestriction hierarchy : restrictions) {
+ XArtifactRef artifactRef = hierarchy.getArtifact();
+ boolean isInHierarchy = guidHierarchy.contains(artifactRef.getGuid());
+ if (isInHierarchy) {
+ collectRestrictions(collector, artifactData, hierarchy.getAccessRules());
+ }
+ }
+ }
+
+ private void collectRestrictions(AccessDetailCollector collector, ArtifactData 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
new file mode 100644
index 0000000000..dbb6f6fd23
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterServiceRegHandler.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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.Map;
+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.RestrictionHandler;
+import org.eclipse.osee.framework.core.util.AbstractTrackingHandler;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AccessModelInterpreterServiceRegHandler extends AbstractTrackingHandler {
+
+ private static final Class<?>[] SERVICE_DEPENDENCIES = new Class<?>[] {
+ //
+ ArtifactDataProvider.class, //
+ };
+
+ private ServiceRegistration registration;
+
+ @Override
+ public Class<?>[] getDependencies() {
+ return SERVICE_DEPENDENCIES;
+ }
+
+ @Override
+ 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(), //
+ };
+
+ AccessModelInterpreter service = new AccessModelInterpreterImpl(artifactDataProvider, restrictionHandlers);
+ registration = context.registerService(AccessModelInterpreter.class.getName(), service, null);
+ }
+
+ @Override
+ public void onDeActivate() {
+ if (registration != null) {
+ registration.unregister();
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/Activator.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/Activator.java
index b6946937c5..263d045d44 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/Activator.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/Activator.java
@@ -19,16 +19,21 @@ public class Activator implements BundleActivator {
public static final String PLUGIN_ID = "org.eclipse.osee.framework.core.dsl.integration";
- private ServiceDependencyTracker dependencyTracker;
+ private ServiceDependencyTracker dependencyTracker1;
+ private ServiceDependencyTracker dependencyTracker2;
@Override
public void start(BundleContext context) throws Exception {
- dependencyTracker = new ServiceDependencyTracker(context, new OseeModelingServiceRegHandler());
- dependencyTracker.open();
+ dependencyTracker1 = new ServiceDependencyTracker(context, new OseeModelingServiceRegHandler());
+ dependencyTracker1.open();
+
+ dependencyTracker2 = new ServiceDependencyTracker(context, new AccessModelInterpreterServiceRegHandler());
+ dependencyTracker2.open();
}
@Override
public void stop(BundleContext context) throws Exception {
- Lib.close(dependencyTracker);
+ Lib.close(dependencyTracker1);
+ Lib.close(dependencyTracker2);
}
}
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/ArtifactInstanceRestrictionHandler.java
new file mode 100644
index 0000000000..db981a6fce
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactInstanceRestrictionHandler.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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.AccessModelInterpreter.AccessDetailCollector;
+import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactData;
+import org.eclipse.osee.framework.core.dsl.integration.OseeUtil;
+import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactInstanceRestriction;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction;
+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.IBasicArtifact;
+import org.eclipse.osee.framework.core.model.access.AccessDetail;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ArtifactInstanceRestrictionHandler implements RestrictionHandler<ArtifactInstanceRestriction> {
+
+ @Override
+ public ArtifactInstanceRestriction asCastedObject(ObjectRestriction objectRestriction) {
+ ArtifactInstanceRestriction toReturn = null;
+ if (objectRestriction instanceof ArtifactInstanceRestriction) {
+ toReturn = (ArtifactInstanceRestriction) objectRestriction;
+ }
+ return toReturn;
+ }
+
+ @Override
+ public void process(ObjectRestriction objectRestriction, ArtifactData artifactData, AccessDetailCollector collector) throws OseeCoreException {
+ ArtifactInstanceRestriction restriction = asCastedObject(objectRestriction);
+ if (restriction != null) {
+ XArtifactRef artifactRef = restriction.getArtifactRef();
+ if (artifactRef.getGuid().equals(artifactData.getGuid())) {
+ PermissionEnum permission = OseeUtil.getPermission(restriction);
+ collector.collect(new AccessDetail<IBasicArtifact<?>>(artifactData.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
new file mode 100644
index 0000000000..1b8e479f43
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandler.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.data.IArtifactType;
+import org.eclipse.osee.framework.core.dsl.integration.AccessModelInterpreter.AccessDetailCollector;
+import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactData;
+import org.eclipse.osee.framework.core.dsl.integration.OseeUtil;
+import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactTypeRestriction;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType;
+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;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ArtifactTypeRestrictionHandler implements RestrictionHandler<ArtifactTypeRestriction> {
+
+ @Override
+ public ArtifactTypeRestriction asCastedObject(ObjectRestriction objectRestriction) {
+ ArtifactTypeRestriction toReturn = null;
+ if (objectRestriction instanceof ArtifactTypeRestriction) {
+ toReturn = (ArtifactTypeRestriction) objectRestriction;
+ }
+ return toReturn;
+ }
+
+ @Override
+ public void process(ObjectRestriction objectRestriction, ArtifactData artifactData, AccessDetailCollector collector) throws OseeCoreException {
+ ArtifactTypeRestriction restriction = asCastedObject(objectRestriction);
+ if (restriction != null) {
+ XArtifactType artifactTypeRef = restriction.getArtifactTypeRef();
+ IArtifactType typeToMatch = OseeUtil.toToken(artifactTypeRef);
+
+ ArtifactType artifactType = artifactData.getArtifactType();
+ boolean isOfType = artifactType != null && artifactType.inheritsFrom(typeToMatch);
+ if (isOfType) {
+ PermissionEnum permission = OseeUtil.getPermission(restriction);
+ collector.collect(new AccessDetail<IArtifactType>(artifactType, permission));
+ }
+ }
+ }
+
+}
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
new file mode 100644
index 0000000000..1420a51038
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AttributeTypeRestrictionHandler.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.dsl.integration.AccessModelInterpreter.AccessDetailCollector;
+import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactData;
+import org.eclipse.osee.framework.core.dsl.integration.OseeUtil;
+import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.AttributeTypeRestriction;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XAttributeType;
+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;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AttributeTypeRestrictionHandler implements RestrictionHandler<AttributeTypeRestriction> {
+
+ @Override
+ public AttributeTypeRestriction asCastedObject(ObjectRestriction objectRestriction) {
+ AttributeTypeRestriction toReturn = null;
+ if (objectRestriction instanceof AttributeTypeRestriction) {
+ toReturn = (AttributeTypeRestriction) objectRestriction;
+ }
+ return toReturn;
+ }
+
+ @Override
+ public void process(ObjectRestriction objectRestriction, ArtifactData artifactData, 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);
+ if (isApplicable) {
+ XArtifactType artifactTypeRef = restriction.getArtifactTypeRef();
+ if (artifactTypeRef != null) {
+ isApplicable = false;
+ IArtifactType typeToMatch = OseeUtil.toToken(artifactTypeRef);
+ ArtifactType artifactType = artifactData.getArtifactType();
+ isApplicable = artifactType.inheritsFrom(typeToMatch);
+ }
+ }
+
+ if (isApplicable) {
+ PermissionEnum permission = OseeUtil.getPermission(restriction);
+ collector.collect(new AccessDetail<IAttributeType>(attributeTypeToMatch, permission));
+ }
+ }
+ }
+
+}
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
new file mode 100644
index 0000000000..bf73c2811a
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/RelationTypeRestrictionHandler.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * 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 org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.core.dsl.integration.AccessModelInterpreter.AccessDetailCollector;
+import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactData;
+import org.eclipse.osee.framework.core.dsl.integration.OseeUtil;
+import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.RelationTypeRestriction;
+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.enums.RelationSide;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.RelationTypeSide;
+import org.eclipse.osee.framework.core.model.access.AccessDetail;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+import org.eclipse.osee.framework.core.model.type.RelationType;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class RelationTypeRestrictionHandler implements RestrictionHandler<RelationTypeRestriction> {
+
+ @Override
+ public RelationTypeRestriction asCastedObject(ObjectRestriction objectRestriction) {
+ RelationTypeRestriction toReturn = null;
+ if (objectRestriction instanceof RelationTypeRestriction) {
+ toReturn = (RelationTypeRestriction) objectRestriction;
+ }
+ return toReturn;
+ }
+
+ @Override
+ public void process(ObjectRestriction objectRestriction, ArtifactData artifactData, 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 = getRelationTypes(typeToMatch, artifactData);
+ if (relationType != null) {
+ ArtifactType artifactType = artifactData.getArtifactType();
+ for (RelationSide relationSide : RelationSide.values()) {
+ if (OseeUtil.isRestrictedSide(restrictedSide, relationSide)) {
+
+ boolean isApplicable = relationType.isArtifactTypeAllowed(relationSide, artifactType);
+ if (isApplicable) {
+ PermissionEnum permission = OseeUtil.getPermission(restriction);
+ collector.collect(new AccessDetail<RelationTypeSide>(new RelationTypeSide(relationType,
+ relationSide), permission));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private RelationType getRelationTypes(IRelationType typeToMatch, ArtifactData artifact) throws OseeCoreException {
+ RelationType toReturn = null;
+ Collection<RelationType> relationTypes = artifact.getValidRelationTypes();
+ for (RelationType relationType : relationTypes) {
+ if (relationType.equals(typeToMatch)) {
+ toReturn = relationType;
+ break;
+ }
+ }
+ return toReturn;
+ }
+}

Back to the top