Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2018-06-27 16:20:58 -0400
committerRyan D. Brooks2018-07-10 18:08:12 -0400
commitac244c0bc5e3c935a2e0c1d7f655f21278def2fd (patch)
treee920c33eec6759458e2d4fb224bf4e6c1ec8783d
parent316ca74a2d1f696101e487e1ea754352512be73c (diff)
downloadorg.eclipse.osee-ac244c0bc5e3c935a2e0c1d7f655f21278def2fd.tar.gz
org.eclipse.osee-ac244c0bc5e3c935a2e0c1d7f655f21278def2fd.tar.xz
org.eclipse.osee-ac244c0bc5e3c935a2e0c1d7f655f21278def2fd.zip
refactor: Move framework access model populate to server
-rw-r--r--plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/AddDbInitDemoChoice.java1
-rw-r--r--plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddClientDemoInitConfig.java1
-rw-r--r--plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/dsl/ui/integration/OseeDslRoleContextProviderTest.java24
-rw-r--r--plugins/org.eclipse.osee.framework.access.provider/build.properties4
-rw-r--r--plugins/org.eclipse.osee.framework.access.provider/plugin.xml13
-rw-r--r--plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/config/FrameworkAccessConfig.java57
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java12
-rw-r--r--plugins/org.eclipse.osee.orcs.core/OSEE-INF/access/OseeAccess_FrameworkAccess.osee (renamed from plugins/org.eclipse.osee.framework.access.provider/OSEE-INF/access/OseeAccess_FrameworkAccess.osee)0
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/CreateSystemBranches.java17
9 files changed, 35 insertions, 94 deletions
diff --git a/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/AddDbInitDemoChoice.java b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/AddDbInitDemoChoice.java
index 8ba2064d6c..837b68c6f9 100644
--- a/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/AddDbInitDemoChoice.java
+++ b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/AddDbInitDemoChoice.java
@@ -27,7 +27,6 @@ public class AddDbInitDemoChoice implements IAddDbInitChoice {
@Override
public void addDbInitChoice(IGroupSelector groupSelection) {
DatabaseInitConfiguration config = new DatabaseInitConfiguration();
- config.addTask("org.eclipse.osee.framework.access.provider.FrameworkAccessConfig");
config.addTask("org.eclipse.osee.ats.client.demo.AtsConfigAddDemoUsers");
config.addTask("org.eclipse.osee.framework.database.init.SimpleTemplateProviderTask");
config.addTask("org.eclipse.osee.ats.AtsDatabaseConfig");
diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddClientDemoInitConfig.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddClientDemoInitConfig.java
index abd2f25a4f..b794f77ba4 100644
--- a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddClientDemoInitConfig.java
+++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddClientDemoInitConfig.java
@@ -25,7 +25,6 @@ public class AddClientDemoInitConfig implements IAddDbInitChoice {
@Override
public void addDbInitChoice(IGroupSelector groupSelection) {
DatabaseInitConfiguration config = new DatabaseInitConfiguration();
- config.addTask("org.eclipse.osee.framework.access.provider.FrameworkAccessConfig");
config.addTask(asLocalExtensionId("AddDemoUsers"));
config.addTask(DefaultDbInitTasks.SIMPLE_TEMPLATE_PROVIDER.getExtensionId());
diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/dsl/ui/integration/OseeDslRoleContextProviderTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/dsl/ui/integration/OseeDslRoleContextProviderTest.java
index 47a0554f17..28774c4d53 100644
--- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/dsl/ui/integration/OseeDslRoleContextProviderTest.java
+++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/dsl/ui/integration/OseeDslRoleContextProviderTest.java
@@ -11,6 +11,8 @@
package org.eclipse.osee.client.integration.tests.integration.dsl.ui.integration;
import static org.eclipse.osee.client.demo.DemoChoice.OSEE_CLIENT_DEMO;
+import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.Artifact;
+import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
@@ -21,11 +23,12 @@ import org.eclipse.osee.framework.core.data.IAccessContextId;
import org.eclipse.osee.framework.core.dsl.OseeDslResourceUtil;
import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl;
import org.eclipse.osee.framework.core.dsl.ui.integration.operations.OseeDslRoleContextProvider;
-import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
-import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTokens;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.SystemUser;
import org.eclipse.osee.framework.jdk.core.util.Lib;
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.Assert;
import org.junit.Rule;
@@ -62,9 +65,10 @@ public class OseeDslRoleContextProviderTest {
public void testGetContextIdExtended() throws Exception {
Long contextId1 = Lib.generateArtifactIdAsInt();
Long contextId2 = Lib.generateArtifactIdAsInt();
- Long role2Id = Lib.generateArtifactIdAsInt();
Artifact user = ArtifactQuery.getArtifactFromToken(SystemUser.Anonymous);
- String testSheet = getTestSheet2(contextId1, user.getId(), contextId2, role2Id);
+ Artifact role2User = ArtifactTypeManager.addArtifact(Artifact, COMMON, "Role 2 user");
+
+ String testSheet = getTestSheet2(contextId1, user.getId(), contextId2, role2User);
OseeDsl model = OseeDslResourceUtil.loadModel("osee:/text.osee", testSheet).getModel();
MockDslProvider dslProvider = new MockDslProvider(model);
OseeDslRoleContextProvider contextProvider = new OseeDslRoleContextProvider(dslProvider);
@@ -73,7 +77,6 @@ public class OseeDslRoleContextProviderTest {
Assert.assertEquals(1, contextIds.size());
Assert.assertEquals(contextId1, contextIds.iterator().next().getId());
- Artifact role2User = ArtifactQuery.getOrCreate(role2Id, CoreArtifactTypes.Artifact, CoreBranches.COMMON);
role2User.persist("Test User");
contextIds = contextProvider.getContextId(role2User);
@@ -88,6 +91,13 @@ public class OseeDslRoleContextProviderTest {
role2User.deleteAndPersist();
}
+ @Test
+ public void testDbInitCreationOfAccessModel() throws Exception {
+ Artifact model = ArtifactQuery.getArtifactFromToken(CoreArtifactTokens.FrameworkAccessModel);
+ String xtext = model.getSoleAttributeValue(CoreAttributeTypes.GeneralStringData);
+ Assert.assertTrue(xtext.contains("guest.context"));
+ }
+
private String getTestSheet1(Long contextId, Long role1Id) {
StringBuilder sb = new StringBuilder();
sb.append("role \"role1\" {\n");
@@ -106,11 +116,11 @@ public class OseeDslRoleContextProviderTest {
return sb.toString();
}
- private String getTestSheet2(Long context1, Long role1Id, Long context2, Long role2Id) {
+ private String getTestSheet2(Long context1, Long role1Id, Long context2, Artifact role2) {
StringBuilder sb = new StringBuilder(getTestSheet1(context1, role1Id));
sb.append("\nrole \"role2\" extends \"role1\" {\n");
sb.append(" id ");
- sb.append(role2Id);
+ sb.append(role2.getIdString());
sb.append(";\n");
sb.append(" accessContext \"role2.context\";\n");
sb.append("}\n\n");
diff --git a/plugins/org.eclipse.osee.framework.access.provider/build.properties b/plugins/org.eclipse.osee.framework.access.provider/build.properties
index 12098c556c..6210e849b5 100644
--- a/plugins/org.eclipse.osee.framework.access.provider/build.properties
+++ b/plugins/org.eclipse.osee.framework.access.provider/build.properties
@@ -1,7 +1,5 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
- plugin.xml,\
- OSGI-INF/,\
- OSEE-INF/
+ OSGI-INF/
source.. = src/
diff --git a/plugins/org.eclipse.osee.framework.access.provider/plugin.xml b/plugins/org.eclipse.osee.framework.access.provider/plugin.xml
deleted file mode 100644
index 5774acb0c1..0000000000
--- a/plugins/org.eclipse.osee.framework.access.provider/plugin.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <extension
- id="FrameworkAccessConfig"
- name="FrameworkAccessConfig"
- point="org.eclipse.osee.framework.database.init.DatabaseInitializationTask">
- <DatabaseInitializationTask
- classname="org.eclipse.osee.framework.access.provider.internal.config.FrameworkAccessConfig">
- </DatabaseInitializationTask>
- </extension>
-
-</plugin>
diff --git a/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/config/FrameworkAccessConfig.java b/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/config/FrameworkAccessConfig.java
deleted file mode 100644
index dee061f159..0000000000
--- a/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/config/FrameworkAccessConfig.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.access.provider.internal.config;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import org.eclipse.osee.framework.core.enums.CoreArtifactTokens;
-import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
-import org.eclipse.osee.framework.core.enums.CoreBranches;
-import org.eclipse.osee.framework.core.util.OseeInf;
-import org.eclipse.osee.framework.database.init.IDbInitializationTask;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-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.transaction.SkynetTransaction;
-import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
-
-/**
- * @author John R. Misinco
- */
-public class FrameworkAccessConfig implements IDbInitializationTask {
-
- @Override
- public void run() {
- importFrameworkAccessModel();
- }
-
- private static void importFrameworkAccessModel() {
- URL url = OseeInf.getResourceAsUrl("access/OseeAccess_FrameworkAccess.osee", FrameworkAccessConfig.class);
-
- InputStream inputStream = null;
- try {
- inputStream = new BufferedInputStream(url.openStream());
- SkynetTransaction transaction =
- TransactionManager.createTransaction(CoreBranches.COMMON, "Add Framework Access Model");
- Artifact artifact = ArtifactTypeManager.addArtifact(CoreArtifactTokens.FrameworkAccessModel);
- artifact.setSoleAttributeFromStream(CoreAttributeTypes.GeneralStringData, inputStream);
- artifact.persist(transaction);
- transaction.execute();
- } catch (IOException ex) {
- OseeCoreException.wrapAndThrow(ex);
- } finally {
- Lib.close(inputStream);
- }
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
index 62a7b386fa..bc2bb84544 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
@@ -574,18 +574,6 @@ public class ArtifactQuery {
return reloadedArts;
}
- public static Artifact getOrCreate(Long id, ArtifactTypeId type, BranchId branch) {
- Artifact artifact = ArtifactQuery.checkArtifactFromId(ArtifactId.valueOf(id), branch, EXCLUDE_DELETED);
-
- if (artifact == null) {
- artifact = ArtifactTypeManager.addArtifact(type, branch, null, id);
- }
- if (artifact == null) {
- throw new ArtifactDoesNotExist("Artifact of type [%s] does not exist on branch [%s]", type, branch);
- }
- return artifact;
- }
-
public static Artifact getOrCreate(String guid, ArtifactTypeId type, BranchId branch) {
Artifact artifact = ArtifactQuery.checkArtifactFromId(guid, branch, EXCLUDE_DELETED);
diff --git a/plugins/org.eclipse.osee.framework.access.provider/OSEE-INF/access/OseeAccess_FrameworkAccess.osee b/plugins/org.eclipse.osee.orcs.core/OSEE-INF/access/OseeAccess_FrameworkAccess.osee
index 8143e555f2..8143e555f2 100644
--- a/plugins/org.eclipse.osee.framework.access.provider/OSEE-INF/access/OseeAccess_FrameworkAccess.osee
+++ b/plugins/org.eclipse.osee.orcs.core/OSEE-INF/access/OseeAccess_FrameworkAccess.osee
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/CreateSystemBranches.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/CreateSystemBranches.java
index 0f613c7520..dd7005dffb 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/CreateSystemBranches.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/CreateSystemBranches.java
@@ -11,6 +11,9 @@
package org.eclipse.osee.orcs.core.internal;
import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.List;
import java.util.Map;
import org.eclipse.osee.framework.core.data.ArtifactId;
@@ -24,6 +27,7 @@ import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.core.enums.CoreTupleTypes;
import org.eclipse.osee.framework.core.enums.SystemUser;
import org.eclipse.osee.framework.core.util.OseeInf;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.OrcsTopicEvents;
@@ -96,9 +100,22 @@ public class CreateSystemBranches {
createOrcsTypesArtifacts(typeModel);
+ addFrameworkAccessModel(tx);
+
tx.commit();
}
+ private void addFrameworkAccessModel(TransactionBuilder tx) {
+ InputStream inputStream = OseeInf.getResourceAsStream("access/OseeAccess_FrameworkAccess.osee", getClass());
+
+ try (InputStream stream = new BufferedInputStream(inputStream)) {
+ ArtifactId accessModel = tx.createArtifact(CoreArtifactTokens.FrameworkAccessModel);
+ tx.setSoleAttributeFromStream(accessModel, CoreAttributeTypes.GeneralStringData, stream);
+ } catch (IOException ex) {
+ throw OseeCoreException.wrap(ex);
+ }
+ }
+
private void createUsers(TransactionBuilder tx, Iterable<UserToken> users) {
List<? extends ArtifactId> defaultGroups =
query.and(CoreAttributeTypes.DefaultGroup, "true").getResultsIds().getList();

Back to the top