Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-09-08 16:10:37 -0400
committerRoberto E. Escobar2014-09-08 16:10:37 -0400
commit860a6342cf8088e23f5e3917bd652c01c536b8d8 (patch)
tree60c03f99ec63b676452fd25d8c29331f2b79dc63
parentf20aa839c65026b9d36ae5de279501af9e8e59fb (diff)
downloadorg.eclipse.osee-860a6342cf8088e23f5e3917bd652c01c536b8d8.tar.gz
org.eclipse.osee-860a6342cf8088e23f5e3917bd652c01c536b8d8.tar.xz
org.eclipse.osee-860a6342cf8088e23f5e3917bd652c01c536b8d8.zip
bug[ats_ATS103637]: Initialize Activity Log Types on server side0.18.0.v201409090342_RC
-rw-r--r--plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/ActivityStorage.java2
-rw-r--r--plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityLogImpl.java23
-rw-r--r--plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/DatabaseActivityStorage.java6
3 files changed, 31 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/ActivityStorage.java b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/ActivityStorage.java
index 26da8cc848..495c2557ee 100644
--- a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/ActivityStorage.java
+++ b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/ActivityStorage.java
@@ -27,6 +27,8 @@ public interface ActivityStorage {
void addActivityTypes(ActivityType... types);
+ void addActivityTypes(Iterable<ActivityType> types);
+
void selectTypes(ActivityTypeDataHandler handler);
void selectType(Long typeId, ActivityTypeDataHandler handler);
diff --git a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityLogImpl.java b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityLogImpl.java
index 696702c9a0..a7a77a7035 100644
--- a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityLogImpl.java
+++ b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityLogImpl.java
@@ -20,9 +20,11 @@ import static org.eclipse.osee.activity.ActivityConstants.DEFAULT_ACTIVITY_LOGGE
import static org.eclipse.osee.activity.internal.ActivityUtil.captureStackTrace;
import static org.eclipse.osee.activity.internal.ActivityUtil.get;
import static org.eclipse.osee.framework.database.IOseeDatabaseService.MAX_VARCHAR_LENGTH;
+import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.osee.activity.ActivityStorage;
import org.eclipse.osee.activity.api.Activity;
import org.eclipse.osee.activity.api.ActivityLog;
@@ -67,6 +69,7 @@ public class ActivityLogImpl implements ActivityLog, Callable<Void> {
private ExecutorAdmin executorAdmin;
private ActivityStorage storage;
+ private final AtomicBoolean initialized = new AtomicBoolean(false);
private ActivityMonitorImpl activityMonitor;
private volatile long freshnessMillis;
private volatile int exceptionLineCount;
@@ -253,6 +256,9 @@ public class ActivityLogImpl implements ActivityLog, Callable<Void> {
@Override
public Void call() {
+ if (!initialized.getAndSet(true)) {
+ initialize();
+ }
if (!newEntities.isEmpty()) {
try {
storage.addEntries(new DrainingIterator<Object[]>(newEntities.values().iterator()));
@@ -283,6 +289,23 @@ public class ActivityLogImpl implements ActivityLog, Callable<Void> {
}
}
+ private void initialize() {
+ final Map<Long, ActivityType> types = new HashMap<Long, ActivityType>(4);
+ for (Activity type : Activity.values()) {
+ types.put(type.getTypeId(), type);
+ }
+ storage.selectTypes(new ActivityTypeDataHandler() {
+
+ @Override
+ public void onData(Long typeId, Long logLevel, String module, String messageFormat) {
+ types.remove(typeId);
+ }
+ });
+ if (!types.isEmpty()) {
+ storage.addActivityTypes(types.values());
+ }
+ }
+
@Override
public void completeEntry(Long entryId) {
updateEntry(entryId, COMPLETE_STATUS);
diff --git a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/DatabaseActivityStorage.java b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/DatabaseActivityStorage.java
index 5057e7c9a0..0b40d59040 100644
--- a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/DatabaseActivityStorage.java
+++ b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/DatabaseActivityStorage.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.activity.internal;
+import java.util.Arrays;
import org.eclipse.osee.activity.ActivityStorage;
import org.eclipse.osee.activity.api.ActivityLog.ActivityDataHandler;
import org.eclipse.osee.activity.api.ActivityLog.ActivityTypeDataHandler;
@@ -116,6 +117,11 @@ public class DatabaseActivityStorage implements ActivityStorage {
@Override
public void addActivityTypes(ActivityType... types) {
+ addActivityTypes(Arrays.asList(types));
+ }
+
+ @Override
+ public void addActivityTypes(Iterable<ActivityType> types) {
for (ActivityType type : types) {
addLogType(type);
}

Back to the top