Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2014-04-14 19:16:27 -0400
committerDonald Dunne2014-04-15 16:42:13 -0400
commit8b67040e04993ca15a50c3932542d0b9cd9b8025 (patch)
treed1dc20cb7134af04e11cb42d7237ac58a359a04b /plugins/org.eclipse.osee.framework.core.message/src/org
parent0d0d3e446a1c46db0698134a94ccf8a1af36efdd (diff)
downloadorg.eclipse.osee-8b67040e04993ca15a50c3932542d0b9cd9b8025.tar.gz
org.eclipse.osee-8b67040e04993ca15a50c3932542d0b9cd9b8025.tar.xz
org.eclipse.osee-8b67040e04993ca15a50c3932542d0b9cd9b8025.zip
feature[ats_ATS19845]: Handle branch guids between servers
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.message/src/org')
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchRow.java31
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DatabaseService.java30
2 files changed, 60 insertions, 1 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchRow.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchRow.java
index 2d6b3d45fc..f8e17c0814 100644
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchRow.java
+++ b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchRow.java
@@ -10,10 +10,15 @@
*******************************************************************************/
package org.eclipse.osee.framework.core.message;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.osee.framework.core.enums.BranchArchivedState;
import org.eclipse.osee.framework.core.enums.BranchState;
import org.eclipse.osee.framework.core.enums.BranchType;
import org.eclipse.osee.framework.core.enums.StorageState;
+import org.eclipse.osee.framework.core.message.internal.DatabaseService;
+import org.eclipse.osee.framework.jdk.core.util.Conditions;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
public final class BranchRow {
private final long branchId;
@@ -74,11 +79,35 @@ public final class BranchRow {
public static BranchRow fromArray(String[] data) {
BranchArchivedState archived = BranchArchivedState.valueOf(data[0]);
- long branchId = Long.valueOf(data[1]);
+ long branchId = 0;
+ if (GUID.isValid(data[1])) {
+ branchId = getBranchIdLegacy(data[1]);
+ } else {
+ branchId = Long.valueOf(data[1]);
+ }
String branchName = data[2];
BranchState branchState = BranchState.valueOf(data[3]);
BranchType branchType = BranchType.valueOf(data[4]);
StorageState storageState = StorageState.valueOf(data[5]);
return new BranchRow(branchId, branchName, branchType, branchState, archived, storageState);
}
+ // Temporary cache till all code uses branch uuid. Remove after 0.17.0
+ private static final String SELECT_BRANCH_ID_BY_GUID = "select branch_id from osee_branch where branch_guid = ?";
+ // Temporary cache till all code uses branch uuid. Remove after 0.17.0
+ private static final Map<String, Long> guidToLongCache = new HashMap<String, Long>(50);
+
+ /**
+ * Temporary method till all code uses branch uuid. Remove after 0.17.0
+ */
+ public static long getBranchIdLegacy(String branchGuid) {
+ Long longId = guidToLongCache.get(branchGuid);
+ if (longId == null) {
+ longId =
+ DatabaseService.getDatabaseService().runPreparedQueryFetchObject(0L, SELECT_BRANCH_ID_BY_GUID, branchGuid);
+ Conditions.checkExpressionFailOnTrue(longId <= 0, "Error getting branch_id for branch: [%s]", branchGuid);
+ guidToLongCache.put(branchGuid, longId);
+ }
+ return longId;
+ }
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DatabaseService.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DatabaseService.java
new file mode 100644
index 0000000000..14b41285c1
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DatabaseService.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.message.internal;
+
+/**
+ * Temporary till all code uses branch uuid. Remove after 0.17.0
+ *
+ * @author Donald G Dunne
+ */
+public class DatabaseService {
+
+ public static org.eclipse.osee.framework.database.DatabaseService databaseService;
+
+ public static org.eclipse.osee.framework.database.DatabaseService getDatabaseService() {
+ return databaseService;
+ }
+
+ public static void setDatabaseService(org.eclipse.osee.framework.database.DatabaseService databaseService) {
+ DatabaseService.databaseService = databaseService;
+ }
+
+}

Back to the top