Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormegumi.telles2016-05-04 21:40:07 +0000
committerAngel Avila2016-05-04 21:40:07 +0000
commitc810cc78356e28992f68a1de1e970e10e2e8694a (patch)
tree50576a6aa1e39f68ba95ace782b9f0dd349b3c39 /plugins/org.eclipse.osee.orcs.db
parente32704ad3c29bb0dd2336b409e2454891dd9da9f (diff)
downloadorg.eclipse.osee-c810cc78356e28992f68a1de1e970e10e2e8694a.tar.gz
org.eclipse.osee-c810cc78356e28992f68a1de1e970e10e2e8694a.tar.xz
org.eclipse.osee-c810cc78356e28992f68a1de1e970e10e2e8694a.zip
bug[ats_ATS282539]: Fix quick search not returning expected results
-- Update the tagger to also tag the name of those values in form {GUID} -- Upon search, replace the {GUID} with the name Change-Id: I64364845f83f401c24b668d3dbd91fa9f5e83221
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.db')
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/AttributeDataProxyFactory.java7
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoaderModule.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/data/GammaQueueIndexerDataSourceLoader.java57
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/AttributeDataUtil.java71
4 files changed, 132 insertions, 5 deletions
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/AttributeDataProxyFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/AttributeDataProxyFactory.java
index f4a16333f8f..7852be6cbce 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/AttributeDataProxyFactory.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/AttributeDataProxyFactory.java
@@ -15,9 +15,11 @@ import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.jdbc.JdbcClient;
import org.eclipse.osee.orcs.core.ds.DataProxy;
import org.eclipse.osee.orcs.core.ds.DataProxyFactory;
import org.eclipse.osee.orcs.data.AttributeTypes;
+import org.eclipse.osee.orcs.db.internal.util.AttributeDataUtil;
/**
* @author Roberto E. Escobar
@@ -26,11 +28,13 @@ public class AttributeDataProxyFactory implements ProxyDataFactory {
private final DataProxyFactoryProvider proxyProvider;
private final AttributeTypes attributeTypeCache;
+ private final JdbcClient jdbcClient;
- public AttributeDataProxyFactory(DataProxyFactoryProvider proxyProvider, AttributeTypes attributeTypes) {
+ public AttributeDataProxyFactory(DataProxyFactoryProvider proxyProvider, JdbcClient jdbcClient, AttributeTypes attributeTypes) {
super();
this.proxyProvider = proxyProvider;
this.attributeTypeCache = attributeTypes;
+ this.jdbcClient = jdbcClient;
}
@Override
@@ -58,6 +62,7 @@ public class AttributeDataProxyFactory implements ProxyDataFactory {
if (isEnumOrBoolean(attributeType)) {
value = intern(value);
}
+ value = AttributeDataUtil.replaceGuidsWithName(original, jdbcClient);
return value;
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoaderModule.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoaderModule.java
index 1a73b2d4c2a..13062c5791e 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoaderModule.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoaderModule.java
@@ -49,7 +49,7 @@ public class LoaderModule {
}
public ProxyDataFactory createProxyDataFactory(AttributeTypes attributeTypes) {
- return new AttributeDataProxyFactory(proxyProvider, attributeTypes);
+ return new AttributeDataProxyFactory(proxyProvider, jdbcClient, attributeTypes);
}
public OrcsObjectFactory createOrcsObjectFactory(ProxyDataFactory proxyFactory) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/data/GammaQueueIndexerDataSourceLoader.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/data/GammaQueueIndexerDataSourceLoader.java
index 4360fcd1b26..04cb9e77f77 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/data/GammaQueueIndexerDataSourceLoader.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/data/GammaQueueIndexerDataSourceLoader.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.search.indexer.data;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.function.Consumer;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.resource.management.IResourceManager;
@@ -20,6 +22,7 @@ import org.eclipse.osee.orcs.core.ds.IndexedResource;
import org.eclipse.osee.orcs.core.ds.OrcsDataHandler;
import org.eclipse.osee.orcs.db.internal.search.indexer.IndexedResourceLoader;
import org.eclipse.osee.orcs.db.internal.search.indexer.IndexerConstants;
+import org.eclipse.osee.orcs.db.internal.util.AttributeDataUtil;
/**
* @author Roberto E. Escobar
@@ -40,17 +43,27 @@ public class GammaQueueIndexerDataSourceLoader implements IndexedResourceLoader
}
private int loadData(OrcsDataHandler<IndexedResource> handler, int tagQueueQueryId) throws OseeCoreException {
+ Collection<AttributeData> attrData = new HashSet<>();
Consumer<JdbcStatement> consumer = stmt -> {
int itemId = stmt.getInt("attr_id");
long typeUuid = stmt.getLong("attr_type_id");
long gammaId = stmt.getLong("gamma_id");
String uri = stmt.getString("uri");
String value = stmt.getString("value");
+ attrData.add(new AttributeData(itemId, typeUuid, gammaId, uri, value));
+ };
+
+ int loaded = jdbcClient.runQuery(consumer, LOAD_ATTRIBUTE, tagQueueQueryId);
- IndexedResource data = createData(itemId, typeUuid, gammaId, value, uri);
+ for (AttributeData attributeData : attrData) {
+ StringBuffer sb = new StringBuffer();
+ sb = sb.append(attributeData.getValue());
+ sb = sb.append(AttributeDataUtil.getNameByGuid(attributeData.getValue(), jdbcClient));
+ IndexedResource data = createData(attributeData.getItemId(), attributeData.getTypeUuid(),
+ attributeData.getGammaId(), sb.toString(), attributeData.getUri());
handler.onData(data);
- };
- return jdbcClient.runQuery(consumer, LOAD_ATTRIBUTE, tagQueueQueryId);
+ }
+ return loaded;
}
@Override
@@ -74,4 +87,42 @@ public class GammaQueueIndexerDataSourceLoader implements IndexedResourceLoader
private IndexedResource createData(int localId, long typeUuid, long gammaId, String value, String uri) {
return new IndexerDataSourceImpl(resourceManager, localId, typeUuid, gammaId, value, uri);
}
+
+ private class AttributeData {
+
+ private final int itemId;
+ private final long typeUuid;
+ private final long gammaId;
+ private final String uri;
+ private final String value;
+
+ public AttributeData(int itemId, long typeUuid, long gammaId, String uri, String value) {
+ this.itemId = itemId;
+ this.typeUuid = typeUuid;
+ this.gammaId = gammaId;
+ this.uri = uri;
+ this.value = value;
+ }
+
+ public int getItemId() {
+ return itemId;
+ }
+
+ public long getTypeUuid() {
+ return typeUuid;
+ }
+
+ public long getGammaId() {
+ return gammaId;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ }
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/AttributeDataUtil.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/AttributeDataUtil.java
new file mode 100644
index 00000000000..3e9b942d5f8
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/AttributeDataUtil.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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.db.internal.util;
+
+import java.util.function.Consumer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.eclipse.osee.jdbc.JdbcClient;
+import org.eclipse.osee.jdbc.JdbcStatement;
+
+/**
+ * @author Megumi Telles
+ */
+public class AttributeDataUtil {
+
+ private static final String NAME_FROM_GUID =
+ "select attr.value from osee_artifact art, osee_attribute attr where art.guid=? and art.art_id = attr.art_id and attr.attr_type_id = 1152921504606847088";
+ private final static Pattern guidPattern = Pattern.compile("(\\{)([0-9A-Za-z\\+_=]{20,22})(\\})");
+
+ private AttributeDataUtil() {
+ // Utility class
+ }
+
+ public static String getNameByGuid(String value, JdbcClient jdbcClient) {
+ if (value != null) {
+ StringBuffer sb = new StringBuffer();
+ Matcher matcher = guidPattern.matcher(value);
+ while (matcher.find()) {
+ String guid = matcher.group(2);
+ sb.append(getName(guid, jdbcClient));
+ }
+ return sb.toString();
+ }
+ return null;
+ }
+
+ public static String replaceGuidsWithName(String value, JdbcClient jdbcClient) {
+ if (value != null) {
+ StringBuffer sb = new StringBuffer();
+ Matcher matcher = guidPattern.matcher(value);
+ while (matcher.find()) {
+ String guid = matcher.group(2);
+ String name = getName(guid, jdbcClient);
+ if (name != null) {
+ matcher.appendReplacement(sb, name.substring(0, name.indexOf('}') + 1));
+ }
+ }
+ matcher.appendTail(sb);
+ return sb.toString();
+ }
+ return null;
+ }
+
+ public static String getName(String guid, JdbcClient jdbcClient) {
+ final StringBuffer sb = new StringBuffer();
+ Consumer<JdbcStatement> consumer = stmt -> {
+ sb.append(stmt.getString("value"));
+ };
+ jdbcClient.runQuery(consumer, NAME_FROM_GUID, guid);
+ return sb.toString();
+ }
+
+}

Back to the top