summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkwilk2011-04-18 15:47:46 (EDT)
committer Ryan D. Brooks2011-04-18 15:47:46 (EDT)
commit43ff3a28075e1fa63ebc15e9199d236d0eba4dc7 (patch)
tree422083041ce673114aab72d9a5657030b2e2585d
parent029d4a3a90591a90b7c2f75fbf0e6234beaedf20 (diff)
downloadorg.eclipse.osee-43ff3a28075e1fa63ebc15e9199d236d0eba4dc7.zip
org.eclipse.osee-43ff3a28075e1fa63ebc15e9199d236d0eba4dc7.tar.gz
org.eclipse.osee-43ff3a28075e1fa63ebc15e9199d236d0eba4dc7.tar.bz2
feature[ats_3KLYC]: Add DefaultUser group attribute support
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreAttributeTypes.java3
-rw-r--r--plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/AddCommonBranch.java7
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Strings.java8
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/test/ArtifactFactoryTest.java110
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/User.java7
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java4
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactFactory.java31
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/UniversalGroup.java3
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/support/OseeTypes_Framework.osee11
-rw-r--r--plugins/org.eclipse.osee.framework.ui.admin/src/org/eclipse/osee/framework/ui/admin/Group.java1
10 files changed, 163 insertions, 22 deletions
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreAttributeTypes.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreAttributeTypes.java
index 320049a..50fdc68 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreAttributeTypes.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreAttributeTypes.java
@@ -35,6 +35,7 @@ public final class CoreAttributeTypes extends NamedIdentity implements IAttribut
public static final IAttributeType CrossBranchLink = new CoreAttributeTypes("AXUR3KcbcVPqyNCdQmAA", "Cross Branch Link");
public static final IAttributeType Csci = new CoreAttributeTypes("AAMFEXPEnnkY_07EbRgA", "CSCI");
public static final IAttributeType DefaultMailServer = new CoreAttributeTypes("ABMuIC3FejpGilonfAgA", "osee.config.Default Mail Server");
+ public static final IAttributeType DefaultGroup = new CoreAttributeTypes("AA37C8T6J1QyaT0+jBwA", "Default Group");
public static final IAttributeType Description = new CoreAttributeTypes("AAMFEcK+kyOhG8GYvPgA", "Description");
public static final IAttributeType DevelopmentAssuranceLevel = new CoreAttributeTypes("AAMFEVdW8Bdjtx4GvfwA", "Development Assurance Level");
public static final IAttributeType Developmental = new CoreAttributeTypes("AAMFEP8lp3EupVzVp5QA", "Developmental");
@@ -106,4 +107,4 @@ public final class CoreAttributeTypes extends NamedIdentity implements IAttribut
private CoreAttributeTypes(String guid, String name) {
super(guid, name);
}
-} \ No newline at end of file
+}
diff --git a/plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/AddCommonBranch.java b/plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/AddCommonBranch.java
index 2d4aa75..a887c4a 100644
--- a/plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/AddCommonBranch.java
+++ b/plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/AddCommonBranch.java
@@ -13,12 +13,14 @@ package org.eclipse.osee.framework.database.init;
import org.eclipse.osee.framework.core.data.SystemUser;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.GlobalXViewerSettings;
import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts;
import org.eclipse.osee.framework.skynet.core.SystemGroup;
import org.eclipse.osee.framework.skynet.core.UserManager;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
@@ -52,6 +54,11 @@ public abstract class AddCommonBranch implements IDbInitializationTask {
SkynetTransaction transaction = new SkynetTransaction(BranchManager.getCommonBranch(), "Add Common Branch");
+ //create everyone group
+ Artifact everyonGroup = SystemGroup.Everyone.getArtifact();
+ everyonGroup.setSoleAttributeValue(CoreAttributeTypes.DefaultGroup, true);
+ everyonGroup.persist(transaction);
+
// Create Default Users
for (SystemUser userEnum : SystemUser.values()) {
UserManager.createUser(userEnum, transaction);
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Strings.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Strings.java
index abcea87..d56eccf 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Strings.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Strings.java
@@ -33,14 +33,12 @@ public class Strings {
}
public static boolean isValid(String... values) {
- boolean answer = true;
for (String value : values) {
- if (!isValid(value)) {
- answer = false;
- break;
+ if (value == null || value.length() == 0) {
+ return false;
}
}
- return answer;
+ return true;
}
public static boolean isValid(CharSequence value) {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/test/ArtifactFactoryTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/test/ArtifactFactoryTest.java
new file mode 100644
index 0000000..6e61318
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/test/ArtifactFactoryTest.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.skynet.core.artifact.test;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @author Karol M. Wilk
+ */
+public final class ArtifactFactoryTest {
+
+ private static final String[] TEST_DEFAULT_GROUPS = {"Alkali Metals", "Metals"};
+ private static final String[] NEW_USER_NAMES = {"Lithium", "Sodium", "Potassium"};
+
+ @Test
+ public void test_makeNewArtifact_UserArtifactAndDefaultGroups() throws Exception {
+
+ //New User - Yay!
+ Artifact lithium = ArtifactTypeManager.makeNewArtifact(CoreArtifactTypes.User, CoreBranches.COMMON);
+ lithium.setName(NEW_USER_NAMES[0]);
+
+ //We like friends
+ Artifact sodium = ArtifactTypeManager.makeNewArtifact(CoreArtifactTypes.User, CoreBranches.COMMON);
+ sodium.setName(NEW_USER_NAMES[1]);
+
+ //Viral
+ Artifact potassium = ArtifactTypeManager.makeNewArtifact(CoreArtifactTypes.User, CoreBranches.COMMON);
+ potassium.setName(NEW_USER_NAMES[2]);
+
+ Set<Artifact> groups = new HashSet<Artifact>();
+
+ groups.addAll(lithium.getRelatedArtifacts(CoreRelationTypes.Users_Artifact));
+ groups.addAll(sodium.getRelatedArtifacts(CoreRelationTypes.Users_Artifact));
+ groups.addAll(potassium.getRelatedArtifacts(CoreRelationTypes.Users_Artifact));
+
+ Assert.assertTrue(groups.size() > TEST_DEFAULT_GROUPS.length);
+
+ Set<String> verifiedNames = new HashSet<String>();
+ for (Artifact group : groups) {
+ for (String groupName : TEST_DEFAULT_GROUPS) {
+ if (group.getName().equals(groupName)) {
+ verifiedNames.add(groupName);
+ }
+ }
+ }
+
+ Assert.assertFalse("Members were not subscribed to any default groups.", verifiedNames.isEmpty());
+ Assert.assertTrue("Members not subscribed to right groups.", verifiedNames.size() == TEST_DEFAULT_GROUPS.length);
+ }
+
+ @BeforeClass
+ public static void setUpOnce() throws Exception {
+ createSampleDefaultGroups(CoreBranches.COMMON, TEST_DEFAULT_GROUPS);
+ }
+
+ @AfterClass
+ public static void tearDownOnce() throws Exception {
+ deleteSampleDefaultGroups(CoreBranches.COMMON, TEST_DEFAULT_GROUPS);
+ }
+
+ private static void createSampleDefaultGroups(IOseeBranch branch, String... names) throws OseeCoreException {
+ for (String name : names) {
+ //Create artifact
+ Artifact groupArt = ArtifactTypeManager.addArtifact(CoreArtifactTypes.UserGroup, branch, name);
+ groupArt.persist();
+
+ //Default Group Attribute
+ groupArt.addAttribute(CoreAttributeTypes.DefaultGroup, true);
+
+ //Create relation between containing folder and new UserGroup
+ Artifact groupRoot = ArtifactQuery.getArtifactFromTypeAndName(CoreArtifactTypes.Folder, "User Groups", branch);
+ groupRoot.addRelation(CoreRelationTypes.Default_Hierarchical__Child, groupArt);
+ groupRoot.persist();
+ }
+ }
+
+ private static void deleteSampleDefaultGroups(IOseeBranch branch, String... artifactNames) throws OseeCoreException {
+ Collection<Artifact> list = ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.UserGroup, branch);
+ for (Artifact artifact : list) {
+ for (String artifactName : artifactNames) {
+ if (artifact.getName().equals(artifactName)) {
+ artifact.deleteAndPersist();
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/User.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/User.java
index 10de40f..9a6c2cc 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/User.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/User.java
@@ -15,6 +15,7 @@ import java.io.StringReader;
import java.io.StringWriter;
import java.util.Collection;
import java.util.HashSet;
+
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.SystemUser;
import org.eclipse.osee.framework.core.enums.BranchArchivedState;
@@ -35,12 +36,6 @@ import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
public class User extends Artifact {
private PropertyStore userSettings;
- @Override
- public void onBirth() throws OseeCoreException {
- super.onBirth();
- SystemGroup.Everyone.addMember(this);
- }
-
public User(ArtifactFactory parentFactory, String guid, String humanReadableId, Branch branch, IArtifactType artifactType) throws OseeCoreException {
super(parentFactory, guid, humanReadableId, branch, artifactType);
}
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 a347f3f..94526be 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
@@ -12,6 +12,7 @@
package org.eclipse.osee.framework.skynet.core.artifact;
import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Default_Hierarchical__Child;
+
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -24,6 +25,7 @@ import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.regex.Pattern;
+
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
@@ -253,7 +255,7 @@ public class Artifact extends NamedIdentity implements IArtifact, IAdaptable, IB
@SuppressWarnings("unused")
public void onBirth() throws OseeCoreException {
// provided for subclass implementation
- };
+ }
/**
* Called upon completion of the initialization of an artifact when loaded from the persistence layer, and when
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactFactory.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactFactory.java
index 6272cd5..49341f1 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactFactory.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactFactory.java
@@ -15,6 +15,10 @@ import java.util.Collection;
import java.util.Collections;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
@@ -24,6 +28,9 @@ import org.eclipse.osee.framework.database.core.ConnectionHandler;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.framework.jdk.core.util.HumanReadableId;
import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.skynet.core.SystemGroup;
+import org.eclipse.osee.framework.skynet.core.User;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
/**
* @author Ryan D. Brooks
@@ -37,11 +44,6 @@ public abstract class ArtifactFactory {
this.artifactTypeNames = Arrays.asList(artifactTypes);
}
- protected ArtifactFactory() {
- super();
- this.artifactTypeNames = null;
- }
-
public Artifact makeNewArtifact(IOseeBranch branch, IArtifactType artifactTypeToken, String guid, String humandReadableId, ArtifactProcessor earlyArtifactInitialization) throws OseeCoreException {
return makeNewArtifact(branch, artifactTypeToken, null, guid, humandReadableId, earlyArtifactInitialization);
}
@@ -80,7 +82,22 @@ public abstract class ArtifactFactory {
artifact.meetMinimumAttributeCounts(true);
ArtifactCache.cache(artifact);
artifact.setLinksLoaded(true);
- artifact.onBirth();
+
+ if (artifactType.equals(CoreArtifactTypes.User)) {
+
+ SystemGroup.Everyone.addMember((User) artifact);
+
+ Collection<Artifact> userGroups =
+ ArtifactQuery.getArtifactListFromTypeAndAttribute(CoreArtifactTypes.UserGroup,
+ CoreAttributeTypes.DefaultGroup, "yes", CoreBranches.COMMON);
+ for (Artifact userGroup : userGroups) {
+ userGroup.addRelation(CoreRelationTypes.Users_User, artifact);
+ userGroup.persist();
+ }
+ } else {
+ artifact.onBirth();
+ }
+
artifact.onInitializationComplete();
if (Strings.isValid(artifactName)) {
@@ -135,7 +152,7 @@ public abstract class ArtifactFactory {
* Return true if this artifact factory is responsible for creating artifactType.
*/
public boolean isResponsibleFor(IArtifactType artifactType) {
- return artifactTypeNames != null && artifactTypeNames.contains(artifactType);
+ return artifactTypeNames.contains(artifactType);
}
/**
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 223cd12..ac0a892 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,6 +15,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.logging.Level;
+
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
@@ -61,7 +62,7 @@ public class UniversalGroup {
}
public static Artifact addGroup(String name, Branch branch) throws OseeCoreException {
- if (getGroups(name, branch).size() > 0) {
+ if (!getGroups(name, branch).isEmpty()) {
throw new OseeArgumentException("Group Already Exists");
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/support/OseeTypes_Framework.osee b/plugins/org.eclipse.osee.framework.skynet.core/support/OseeTypes_Framework.osee
index 4809b02..9bcb0f6 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/support/OseeTypes_Framework.osee
+++ b/plugins/org.eclipse.osee.framework.skynet.core/support/OseeTypes_Framework.osee
@@ -251,8 +251,19 @@ artifactType "Group Artifact" extends "Artifact" {
guid "ABM4FTvWVzDQsTsM6jQA"
}
+attributeType "Default Group" extends BooleanAttribute {
+ guid "AA37C8T6J1QyaT0+jBwA"
+ dataProvider DefaultAttributeDataProvider
+ min 0
+ max 1
+ taggerId DefaultAttributeTaggerProvider
+ description "Specifies whether to automatically add new users into this group"
+ defaultValue "no"
+}
+
artifactType "User Group" extends "Abstract Access Controlled" , "Group Artifact" {
guid "AAMFDhrEbXqZKPfWkwAA"
+ attribute "Default Group"
}
artifactType "Universal Group" extends "Group Artifact" {
diff --git a/plugins/org.eclipse.osee.framework.ui.admin/src/org/eclipse/osee/framework/ui/admin/Group.java b/plugins/org.eclipse.osee.framework.ui.admin/src/org/eclipse/osee/framework/ui/admin/Group.java
index e50f797..9b18db1 100644
--- a/plugins/org.eclipse.osee.framework.ui.admin/src/org/eclipse/osee/framework/ui/admin/Group.java
+++ b/plugins/org.eclipse.osee.framework.ui.admin/src/org/eclipse/osee/framework/ui/admin/Group.java
@@ -21,7 +21,6 @@ public class Group {
private int numChildrenChecked;
public Group(String groupName, int groupId) {
- super();
this.groupName = groupName;
this.groupId = groupId;
}