Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsAccountStorageTest.java (renamed from plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsAccountStorageImplTest.java)10
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OsgiIntegrationTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/account.factory.xml7
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.account.ds.xml3
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AbstractOrcsStorage.java100
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorage.java (renamed from plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorageImpl.java)92
6 files changed, 132 insertions, 82 deletions
diff --git a/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsAccountStorageImplTest.java b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsAccountStorageTest.java
index 2e693a758f..3fe2164277 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsAccountStorageImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsAccountStorageTest.java
@@ -19,15 +19,14 @@ import static org.mockito.MockitoAnnotations.initMocks;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.osee.account.admin.Account;
-import org.eclipse.osee.account.admin.AccountSession;
-import org.eclipse.osee.account.admin.AccountAdmin;
import org.eclipse.osee.account.admin.AccountPreferences;
+import org.eclipse.osee.account.admin.AccountSession;
import org.eclipse.osee.account.admin.CreateAccountRequest;
import org.eclipse.osee.account.admin.ds.AccountStorage;
import org.eclipse.osee.framework.jdk.core.type.Identifiable;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.framework.jdk.core.util.Compare;
-import org.eclipse.osee.orcs.account.admin.internal.OrcsAccountStorageImpl;
+import org.eclipse.osee.orcs.account.admin.internal.OrcsAccountStorage;
import org.eclipse.osee.orcs.db.mock.OsgiService;
import org.junit.Assert;
import org.junit.Before;
@@ -39,11 +38,11 @@ import org.junit.rules.TestRule;
import org.mockito.Mock;
/**
- * Test Case for {@link AccountAdmin} using {@link OrcsAccountStorageImpl}
+ * Test Case for {@link OrcsAccountStorage}
*
* @author Roberto E. Escobar
*/
-public class OrcsAccountStorageImplTest {
+public class OrcsAccountStorageTest {
@Rule
public TestRule osgi = OrcsIntegrationRule.integrationRule(this, "osee.demo.hsql");
@@ -216,7 +215,6 @@ public class OrcsAccountStorageImplTest {
assertNotNull(actual.getCreatedOn());
assertNotNull(actual.getLastAccessedOn());
- //
ResultSet<AccountSession> result = storage.getAccountSessionBySessionToken(token);
AccountSession actualAccess = result.getExactlyOne();
assertEquals(actual, actualAccess);
diff --git a/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OsgiIntegrationTestSuite.java b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OsgiIntegrationTestSuite.java
index 76b24c91fa..b0cc10a2bd 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OsgiIntegrationTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OsgiIntegrationTestSuite.java
@@ -17,7 +17,7 @@ import org.junit.runners.Suite;
* @author Roberto E. Escobar
*/
@RunWith(Suite.class)
-@Suite.SuiteClasses({OrcsAccountStorageImplTest.class})
+@Suite.SuiteClasses({OrcsAccountStorageTest.class})
public class OsgiIntegrationTestSuite {
// Test Suite
}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/account.factory.xml b/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/account.factory.xml
new file mode 100644
index 0000000000..81721a9d9b
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/account.factory.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
+ <implementation class="org.eclipse.osee.orcs.account.admin.internal.AccountFactory"/>
+ <service>
+ <provide interface="org.eclipse.osee.orcs.account.admin.internal.AccountFactory"/>
+ </service>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.account.ds.xml b/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.account.ds.xml
index e9623c1bed..d4eee76aee 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.account.ds.xml
+++ b/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.account.ds.xml
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop">
- <implementation class="org.eclipse.osee.orcs.account.admin.internal.OrcsAccountStorageImpl"/>
+ <implementation class="org.eclipse.osee.orcs.account.admin.internal.OrcsAccountStorage"/>
<service>
<provide interface="org.eclipse.osee.account.admin.ds.AccountStorage"/>
</service>
<reference bind="setLogger" cardinality="1..1" interface="org.eclipse.osee.logger.Log" name="Log" policy="static"/>
<reference bind="setOrcsApi" cardinality="1..1" interface="org.eclipse.osee.orcs.OrcsApi" name="OrcsApi" policy="static"/>
<reference bind="setDatabaseService" cardinality="1..1" interface="org.eclipse.osee.framework.database.IOseeDatabaseService" name="IOseeDatabaseService" policy="static"/>
+ <reference bind="setAccountFactory" cardinality="1..1" interface="org.eclipse.osee.orcs.account.admin.internal.AccountFactory" name="AccountFactory" policy="static"/>
</scr:component>
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AbstractOrcsStorage.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AbstractOrcsStorage.java
new file mode 100644
index 0000000000..32d078677f
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AbstractOrcsStorage.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.orcs.account.admin.internal;
+
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.SystemUser;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.ApplicationContext;
+import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.eclipse.osee.orcs.search.QueryBuilder;
+import org.eclipse.osee.orcs.search.QueryFactory;
+import org.eclipse.osee.orcs.transaction.TransactionBuilder;
+import org.eclipse.osee.orcs.transaction.TransactionFactory;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public abstract class AbstractOrcsStorage {
+
+ private Log logger;
+ private OrcsApi orcsApi;
+
+ private IOseeBranch storageBranch;
+ private ApplicationContext context;
+ private AccountFactory factory;
+
+ public void setLogger(Log logger) {
+ this.logger = logger;
+ }
+
+ public void setOrcsApi(OrcsApi orcsApi) {
+ this.orcsApi = orcsApi;
+ }
+
+ public void setAccountFactory(AccountFactory factory) {
+ this.factory = factory;
+ }
+
+ public void start() {
+ logger.trace("Starting [%s]...", getClass().getSimpleName());
+ storageBranch = CoreBranches.COMMON;
+
+ String sessionId = SystemUser.OseeSystem.getGuid();
+ context = newApplicationContext(sessionId);
+ }
+
+ public void stop() {
+ logger.trace("Stopping [%s]...", getClass().getSimpleName());
+ storageBranch = null;
+ context = null;
+ }
+
+ private ApplicationContext newApplicationContext(final String sessionId) {
+ return new ApplicationContext() {
+
+ @Override
+ public String getSessionId() {
+ return sessionId;
+ }
+ };
+ }
+
+ private IOseeBranch getBranch() {
+ return storageBranch;
+ }
+
+ protected Log getLogger() {
+ return logger;
+ }
+
+ protected AccountFactory getFactory() {
+ return factory;
+ }
+
+ protected QueryBuilder newQuery() {
+ QueryFactory queryFactory = orcsApi.getQueryFactory(context);
+ return queryFactory.fromBranch(getBranch());
+ }
+
+ @SuppressWarnings("unchecked")
+ protected ArtifactReadable getSystemUser() {
+ return newQuery().andIds(SystemUser.OseeSystem).getResults().getExactlyOne();
+ }
+
+ protected TransactionBuilder newTransaction(String comment) {
+ TransactionFactory transactionFactory = orcsApi.getTransactionFactory(context);
+ return transactionFactory.createTransaction(getBranch(), getSystemUser(), comment);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorageImpl.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorage.java
index 3bdf602a9b..c2fb4d9910 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorageImpl.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorage.java
@@ -15,98 +15,46 @@ import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.osee.account.admin.Account;
-import org.eclipse.osee.account.admin.AccountSession;
import org.eclipse.osee.account.admin.AccountPreferences;
+import org.eclipse.osee.account.admin.AccountSession;
import org.eclipse.osee.account.admin.CreateAccountRequest;
import org.eclipse.osee.account.admin.ds.AccountStorage;
-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.Operator;
-import org.eclipse.osee.framework.core.enums.SystemUser;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.jdk.core.type.Identifiable;
import org.eclipse.osee.framework.jdk.core.type.Identity;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.ApplicationContext;
-import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.data.ArtifactId;
import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.search.QueryBuilder;
-import org.eclipse.osee.orcs.search.QueryFactory;
import org.eclipse.osee.orcs.transaction.TransactionBuilder;
-import org.eclipse.osee.orcs.transaction.TransactionFactory;
import org.eclipse.osee.orcs.utility.OrcsUtil;
/**
* @author Roberto E. Escobar
*/
-public class OrcsAccountStorageImpl implements AccountStorage {
+public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountStorage {
- private Log logger;
- private OrcsApi orcsApi;
private IOseeDatabaseService dbService;
-
- private AccountFactory factory;
- private IOseeBranch storageBranch;
- private ApplicationContext context;
private AccountSessionStorage sessionStore;
public void setDatabaseService(IOseeDatabaseService dbService) {
this.dbService = dbService;
}
- public void setLogger(Log logger) {
- this.logger = logger;
- }
-
- public void setOrcsApi(OrcsApi orcsApi) {
- this.orcsApi = orcsApi;
- }
-
+ @Override
public void start() {
- logger.trace("Starting OrcsAccountStorageImpl...");
- factory = new AccountFactory();
- storageBranch = CoreBranches.COMMON;
-
- String sessionId = SystemUser.OseeSystem.getGuid();
- context = newApplicationContext(sessionId);
-
- sessionStore = new AccountSessionDatabaseStore(logger, dbService, factory);
+ super.start();
+ sessionStore = new AccountSessionDatabaseStore(getLogger(), dbService, getFactory());
}
+ @Override
public void stop() {
- logger.trace("Stopping OrcsAccountStorageImpl...");
- storageBranch = null;
- factory = null;
- }
-
- private ApplicationContext newApplicationContext(final String sessionId) {
- return new ApplicationContext() {
-
- @Override
- public String getSessionId() {
- return sessionId;
- }
- };
- }
-
- private IOseeBranch getBranch() {
- return storageBranch;
- }
-
- private QueryBuilder newQuery() {
- QueryFactory queryFactory = orcsApi.getQueryFactory(context);
- return queryFactory.fromBranch(getBranch());
- }
-
- @SuppressWarnings("unchecked")
- private ArtifactReadable getSystemUser() {
- return newQuery().andIds(SystemUser.OseeSystem).getResults().getExactlyOne();
+ super.stop();
+ sessionStore = null;
}
@Override
@@ -130,60 +78,55 @@ public class OrcsAccountStorageImpl implements AccountStorage {
@Override
public ResultSet<Account> getAllAccounts() {
ResultSet<ArtifactReadable> results = newQuery().andIsOfType(CoreArtifactTypes.User).getResults();
- return factory.newAccountResultSet(results);
+ return getFactory().newAccountResultSet(results);
}
@Override
public ResultSet<Account> getAccountByUserName(String username) {
ResultSet<ArtifactReadable> results =
newQuery().andIsOfType(CoreArtifactTypes.User).and(CoreAttributeTypes.UserId, username).getResults();
- return factory.newAccountResultSet(results);
+ return getFactory().newAccountResultSet(results);
}
@Override
public ResultSet<Account> getAccountByUuid(String accountUuid) {
ResultSet<ArtifactReadable> results =
newQuery().andIsOfType(CoreArtifactTypes.User).andGuid(accountUuid).getResults();
- return factory.newAccountResultSet(results);
+ return getFactory().newAccountResultSet(results);
}
@Override
public ResultSet<Account> getAccountByLocalId(long accountId) {
int id = Long.valueOf(accountId).intValue();
ResultSet<ArtifactReadable> results = newQuery().andIsOfType(CoreArtifactTypes.User).andLocalId(id).getResults();
- return factory.newAccountResultSet(results);
+ return getFactory().newAccountResultSet(results);
}
@Override
public ResultSet<Account> getAccountByEmail(String email) {
ResultSet<ArtifactReadable> results =
newQuery().andIsOfType(CoreArtifactTypes.User).and(CoreAttributeTypes.Email, Operator.EQUAL, email).getResults();
- return factory.newAccountResultSet(results);
+ return getFactory().newAccountResultSet(results);
}
@Override
public ResultSet<Account> getAccountByName(String name) {
ResultSet<ArtifactReadable> results =
newQuery().andIsOfType(CoreArtifactTypes.User).andNameEquals(name).getResults();
- return factory.newAccountResultSet(results);
+ return getFactory().newAccountResultSet(results);
}
@Override
public ResultSet<AccountPreferences> getAccountPreferencesById(long accountId) {
int id = Long.valueOf(accountId).intValue();
ResultSet<ArtifactReadable> results = newQuery().andIsOfType(CoreArtifactTypes.User).andLocalId(id).getResults();
- return factory.newAccountPreferencesResultSet(results);
+ return getFactory().newAccountPreferencesResultSet(results);
}
@Override
public ResultSet<AccountPreferences> getAccountPreferencesByUuid(String uuid) {
ResultSet<ArtifactReadable> results = newQuery().andIsOfType(CoreArtifactTypes.User).andGuid(uuid).getResults();
- return factory.newAccountPreferencesResultSet(results);
- }
-
- private TransactionBuilder newTransaction(String comment) {
- TransactionFactory transactionFactory = orcsApi.getTransactionFactory(context);
- return transactionFactory.createTransaction(getBranch(), getSystemUser(), comment);
+ return getFactory().newAccountPreferencesResultSet(results);
}
@Override
@@ -266,7 +209,8 @@ public class OrcsAccountStorageImpl implements AccountStorage {
@Override
public AccountSession createAccountSession(String sessionToken, Account account, String remoteAddress, String accessDetails) {
- AccountSession session = factory.newAccountSession(account.getId(), sessionToken, remoteAddress, accessDetails);
+ AccountSession session =
+ getFactory().newAccountSession(account.getId(), sessionToken, remoteAddress, accessDetails);
try {
sessionStore.createAccountSession(Collections.singleton(session)).call();
return session;

Back to the top