Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-07-29 02:36:24 +0000
committerrescobar2010-07-29 02:36:24 +0000
commitc001a829049fa6d98b24483decb9b15444423d40 (patch)
tree747816426b519a997f081d545b1c79f50316f2bc /plugins/org.eclipse.osee.framework.core.dsl.integration
parentf1479c0c6dfc4efe9392768bc39b06bd6a9c294e (diff)
downloadorg.eclipse.osee-c001a829049fa6d98b24483decb9b15444423d40.tar.gz
org.eclipse.osee-c001a829049fa6d98b24483decb9b15444423d40.tar.xz
org.eclipse.osee-c001a829049fa6d98b24483decb9b15444423d40.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.java1
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ArtifactDataProvider.java42
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ModelUtil.java2
-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/OseeUtil.java101
5 files changed, 345 insertions, 0 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 0ae280b2600..de9371b7bb7 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
@@ -24,4 +24,5 @@ public interface AccessModelInterpreter {
AccessContext getContext(Collection<AccessContext> contexts, AccessContextId contextId) throws OseeCoreException;
void computeAccessDetails(AccessContext context, Object objectToCheck, Collection<AccessDetail<?>> details) throws OseeCoreException;
+
}
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
new file mode 100644
index 00000000000..b717080881b
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ArtifactDataProvider.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.dsl.integration;
+
+import java.util.Collection;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+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;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface ArtifactDataProvider {
+
+ public static interface ArtifactData {
+ String getGuid();
+
+ ArtifactType getArtifactType();
+
+ boolean isAttributeTypeValid(IAttributeType attributeType) throws OseeCoreException;
+
+ Collection<RelationType> getValidRelationTypes() throws OseeCoreException;
+
+ Collection<String> getHierarchy();
+
+ IBasicArtifact<?> getObject();
+ }
+
+ boolean isApplicable(Object object);
+
+ ArtifactData asCastedObject(Object object);
+} \ 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/ModelUtil.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ModelUtil.java
index 6f0d6e93bee..df1a5314a3c 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ModelUtil.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/ModelUtil.java
@@ -42,6 +42,7 @@ import com.google.inject.Injector;
public final class ModelUtil {
private ModelUtil() {
+ // Utility Class
}
// private void loadDependencies(OseeTypeModel baseModel, List<OseeTypeModel> models) throws OseeCoreException, URISyntaxException {
@@ -186,4 +187,5 @@ public final class ModelUtil {
}
return snapshot;
}
+
}
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
new file mode 100644
index 00000000000..6e5af8118d6
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeAccessModelInterpreter.java
@@ -0,0 +1,199 @@
+/*******************************************************************************
+ * 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/OseeUtil.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeUtil.java
new file mode 100644
index 00000000000..0e81f08a251
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeUtil.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * 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.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.core.data.NamedIdentity;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessPermissionEnum;
+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.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.util.Conditions;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class OseeUtil {
+
+ private OseeUtil() {
+ // Utility Class
+ }
+
+ public static IArtifactType toToken(XArtifactType model) {
+ return new ArtifactTypeToken(model);
+ }
+
+ public static IAttributeType toToken(XAttributeType model) {
+ return new AttributeTypeToken(model);
+ }
+
+ public static IRelationType toToken(XRelationType model) {
+ return new RelationTypeToken(model);
+ }
+
+ private final static class ArtifactTypeToken extends NamedIdentity implements IArtifactType {
+ public ArtifactTypeToken(XArtifactType model) {
+ super(model.getTypeGuid(), unquote(model.getName()));
+ }
+ }
+
+ private final static class AttributeTypeToken extends NamedIdentity implements IAttributeType {
+ public AttributeTypeToken(XAttributeType model) {
+ super(model.getTypeGuid(), unquote(model.getName()));
+ }
+ }
+
+ private final static class RelationTypeToken extends NamedIdentity implements IRelationType {
+ public RelationTypeToken(XRelationType model) {
+ super(model.getTypeGuid(), 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) {
+ boolean toReturn = false;
+ switch (relationSideEnum) {
+ case BOTH:
+ toReturn = true;
+ break;
+ case SIDE_A:
+ toReturn = relationSide.isSideA();
+ break;
+ case SIDE_B:
+ toReturn = !relationSide.isSideA();
+ break;
+ default:
+ break;
+ }
+ return toReturn;
+ }
+
+ public static PermissionEnum getPermission(ObjectRestriction restriction) throws OseeCoreException {
+ Conditions.checkNotNull(restriction, "restriction");
+ AccessPermissionEnum modelPermission = restriction.getPermission();
+ Conditions.checkNotNull(modelPermission, "restriction permission");
+ PermissionEnum toReturn;
+ if (modelPermission == AccessPermissionEnum.ALLOW) {
+ toReturn = PermissionEnum.WRITE;
+ } else {
+ toReturn = PermissionEnum.READ;
+ }
+ return toReturn;
+ }
+}

Back to the top