diff options
author | kwilk | 2011-07-13 22:32:43 +0000 |
---|---|---|
committer | Ryan D. Brooks | 2011-07-13 22:32:43 +0000 |
commit | 4b5fea671657690dcb4fef8ebf1dba993319b4d9 (patch) | |
tree | dc92f4aa827979841b122eed5ab07fce68186ef5 /plugins/org.eclipse.osee.framework.skynet.core | |
parent | 5e11404d5ec635fdac5ead50ca8d30b648a09ca8 (diff) | |
download | org.eclipse.osee-4b5fea671657690dcb4fef8ebf1dba993319b4d9.tar.gz org.eclipse.osee-4b5fea671657690dcb4fef8ebf1dba993319b4d9.tar.xz org.eclipse.osee-4b5fea671657690dcb4fef8ebf1dba993319b4d9.zip |
bug[ats_4B08V]: Fix allowed attribute types per branch
Diffstat (limited to 'plugins/org.eclipse.osee.framework.skynet.core')
5 files changed, 20 insertions, 18 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java index 94526be52fa..bee1cfdf13f 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java @@ -599,6 +599,10 @@ public class Artifact extends NamedIdentity implements IArtifact, IAdaptable, IB } private <T> Attribute<T> getOrCreateSoleAttribute(IAttributeType attributeType) throws OseeCoreException { + if (!isAttributeTypeValid(attributeType)) { + throw new OseeArgumentException("The attribute type %s is not valid for artifacts of type [%s]", + attributeType, getArtifactTypeName()); + } Attribute<T> attribute = getSoleAttribute(attributeType); if (attribute == null) { attribute = initializeAttribute(attributeType, ModificationType.NEW, true, true); @@ -1331,7 +1335,7 @@ public class Artifact extends NamedIdentity implements IArtifact, IAdaptable, IB private void copyAttributes(Artifact artifact, Collection<IAttributeType> excudeAttributeTypes) throws OseeCoreException { for (Attribute<?> attribute : getAttributes()) { - if (!excudeAttributeTypes.contains(attribute) && isCopyAllowed(attribute)) { + if (!excudeAttributeTypes.contains(attribute) && isCopyAllowed(attribute) && artifact.isAttributeTypeValid(attribute.getAttributeType())) { artifact.addAttribute(attribute.getAttributeType(), attribute.getValue()); } } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/UniversalGroup.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/UniversalGroup.java index ac0a892fd85..3d38b3bb372 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/UniversalGroup.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/UniversalGroup.java @@ -15,12 +15,11 @@ import java.util.Collection; import java.util.HashSet; import java.util.LinkedList; import java.util.logging.Level; - +import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.enums.CoreRelationTypes; 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.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts; import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; @@ -31,7 +30,7 @@ import org.eclipse.osee.framework.skynet.core.internal.Activator; */ public class UniversalGroup { - public static Collection<Artifact> getGroups(Branch branch) { + public static Collection<Artifact> getGroups(IOseeBranch branch) { Collection<Artifact> artifacts = null; try { artifacts = ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.UniversalGroup, branch); @@ -42,7 +41,7 @@ public class UniversalGroup { return artifacts; } - public static Collection<Artifact> getGroupsNotRoot(Branch branch) { + public static Collection<Artifact> getGroupsNotRoot(IOseeBranch branch) { Collection<Artifact> groups = new HashSet<Artifact>(); for (Artifact group : UniversalGroup.getGroups(branch)) { if (!group.getName().equals("Root Artifact")) { @@ -52,7 +51,7 @@ public class UniversalGroup { return groups; } - public static Collection<Artifact> getGroups(String groupName, Branch branch) { + public static Collection<Artifact> getGroups(String groupName, IOseeBranch branch) { try { return ArtifactQuery.getArtifactListFromTypeAndName(CoreArtifactTypes.UniversalGroup, groupName, branch); } catch (OseeCoreException ex) { @@ -61,7 +60,7 @@ public class UniversalGroup { return new ArrayList<Artifact>(); } - public static Artifact addGroup(String name, Branch branch) throws OseeCoreException { + public static Artifact addGroup(String name, IOseeBranch branch) throws OseeCoreException { if (!getGroups(name, branch).isEmpty()) { throw new OseeArgumentException("Group Already Exists"); } @@ -74,7 +73,7 @@ public class UniversalGroup { return groupArt; } - public static Artifact getTopUniversalGroupArtifact(Branch branch) throws OseeCoreException { + public static Artifact getTopUniversalGroupArtifact(IOseeBranch branch) throws OseeCoreException { return ArtifactQuery.getArtifactFromTypeAndName(CoreArtifactTypes.UniversalGroup, OseeSystemArtifacts.ROOT_ARTIFACT_TYPE_NAME, branch); } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/factory/UserArtifactFactory.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/factory/UserArtifactFactory.java index 6f34888d21d..0db1909135d 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/factory/UserArtifactFactory.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/factory/UserArtifactFactory.java @@ -33,7 +33,7 @@ public class UserArtifactFactory extends ArtifactFactory { public @Override Artifact getArtifactInstance(String guid, String humandReadableId, Branch branch, IArtifactType artifactType) throws OseeCoreException { - if (artifactType.getGuid().equals(CoreArtifactTypes.User.getGuid())) { + if (artifactType.equals(CoreArtifactTypes.User)) { return new User(this, guid, humandReadableId, branch, artifactType); } throw new OseeArgumentException("did not recognize the artifact type [%s]", artifactType); diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/ClientArtifactTypeAccessor.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/ClientArtifactTypeAccessor.java index 80f8730ec64..69169821a08 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/ClientArtifactTypeAccessor.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/ClientArtifactTypeAccessor.java @@ -16,6 +16,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map.Entry; import java.util.Set; +import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.CoreTranslatorId; import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.core.message.ArtifactTypeCacheUpdateResponse; @@ -41,7 +42,6 @@ public class ClientArtifactTypeAccessor extends AbstractClientDataAccessor<Artif private final ArtifactTypeFactory artifactTypeFactory; public ClientArtifactTypeAccessor(ArtifactTypeFactory artifactTypeFactory, AbstractOseeCache<AttributeType> attrCache, AbstractOseeCache<Branch> branchCache) { - super(); this.artifactTypeFactory = artifactTypeFactory; this.attrCache = attrCache; this.branchCache = branchCache; @@ -85,21 +85,21 @@ public class ClientArtifactTypeAccessor extends AbstractClientDataAccessor<Artif baseType.setSuperTypes(superTypes); } - CompositeKeyHashMap<ArtifactType, Branch, Collection<AttributeType>> attrs = - new CompositeKeyHashMap<ArtifactType, Branch, Collection<AttributeType>>(); + CompositeKeyHashMap<ArtifactType, IOseeBranch, Collection<AttributeType>> attrs = + new CompositeKeyHashMap<ArtifactType, IOseeBranch, Collection<AttributeType>>(); - for (Triplet<Integer, Integer, Integer> entry : response.getAttributeTypes()) { - ArtifactType key1 = cache.getById(entry.getFirst()); - Branch key2 = branchCache.getById(entry.getSecond()); + for (Triplet<String, String, String> entry : response.getAttributeTypes()) { + ArtifactType key1 = cache.getByGuid(entry.getFirst()); + IOseeBranch key2 = branchCache.getByGuid(entry.getSecond()); Collection<AttributeType> types = attrs.get(key1, key2); if (types == null) { types = new HashSet<AttributeType>(); attrs.put(key1, key2, types); } - types.add(attrCache.getById(entry.getThird())); + types.add(attrCache.getByGuid(entry.getThird())); } - for (Entry<Pair<ArtifactType, Branch>, Collection<AttributeType>> entry : attrs.entrySet()) { + for (Entry<Pair<ArtifactType, IOseeBranch>, Collection<AttributeType>> entry : attrs.entrySet()) { entry.getKey().getFirst().setAttributeTypes(entry.getValue(), entry.getKey().getSecond()); } return updatedItems; diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/ClientBranchAccessor.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/ClientBranchAccessor.java index e553f65825d..529545c82b3 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/ClientBranchAccessor.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/ClientBranchAccessor.java @@ -45,7 +45,6 @@ public class ClientBranchAccessor extends AbstractClientDataAccessor<Branch> { private final BranchFactory branchFactory; public ClientBranchAccessor(BranchFactory branchFactory, TransactionCache transactionCache) { - super(); this.branchFactory = branchFactory; this.transactionCache = transactionCache; } |