Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorangel.avila22018-10-04 02:28:10 -0400
committerangel.avila22018-10-04 02:29:29 -0400
commit248f5892931ca53b27218da252b18e989342ddbe (patch)
tree4ab3fd35f76c1c2d185de6d335fb3e207d681485
parent03c045c17959df0d771900ab23e0f51dae6f9cda (diff)
downloadorg.eclipse.osee-248f5892931ca53b27218da252b18e989342ddbe.tar.gz
org.eclipse.osee-248f5892931ca53b27218da252b18e989342ddbe.tar.xz
org.eclipse.osee-248f5892931ca53b27218da252b18e989342ddbe.zip
feature[ats_12345]: first crack not tested
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/MultiEnvCopier.java72
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/coverage/LisFileParser.java147
2 files changed, 168 insertions, 51 deletions
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/MultiEnvCopier.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/MultiEnvCopier.java
new file mode 100644
index 0000000000..d9454faa49
--- /dev/null
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/MultiEnvCopier.java
@@ -0,0 +1,72 @@
+/*
+ * Created on Oct 1, 2018
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.disposition.rest.internal.importer;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import org.eclipse.osee.disposition.model.Discrepancy;
+import org.eclipse.osee.disposition.model.DispoAnnotationData;
+import org.eclipse.osee.disposition.model.DispoItem;
+import org.eclipse.osee.disposition.model.DispoItemData;
+import org.eclipse.osee.disposition.model.OperationReport;
+import org.eclipse.osee.disposition.rest.internal.DispoConnector;
+import org.eclipse.osee.disposition.rest.internal.DispoDataFactory;
+
+public class MultiEnvCopier {
+
+ public List<DispoItem> copy(Map<DispoItemData, Set<DispoItemData>> itemToMultiEnvTwins, OperationReport rerpot) {
+ List<DispoItem> modifiedItems = new ArrayList<>();
+
+ Set<Entry<DispoItemData, Set<DispoItemData>>> entrySet = itemToMultiEnvTwins.entrySet();
+ for (DispoItemData origItem : itemToMultiEnvTwins.keySet()) {
+ Set<DispoItemData> twinItems = itemToMultiEnvTwins.get(origItem);
+
+ copyCoveredLinesToTwins(origItem, twinItems);
+ }
+
+ return modifiedItems;
+ }
+
+ private void copyCoveredLinesToTwins(DispoItemData origItem, Set<DispoItemData> twinItems) {
+ DispoDataFactory factory = new DispoDataFactory();
+ DispoConnector connector = new DispoConnector();
+ Set<String> texts = new HashSet<>();
+
+ for (DispoAnnotationData annotation : origItem.getAnnotationsList()) {
+ if (annotation.getIsDefault()) {
+ texts.add(annotation.getResolution());
+ }
+ }
+
+ for (DispoItemData twinItem : twinItems) {
+ Map<String, Discrepancy> textToDiscrepancy = buildMap(twinItem);
+ for (String text : texts) {
+ Discrepancy discrepancy = textToDiscrepancy.get(text);
+ DispoAnnotationData annotation = new DispoAnnotationData();
+ factory.initAnnotation(annotation);
+ annotation.setResolutionType("NEED TO UPDATE");
+ annotation.setResolution("MULTI ENV");
+ annotation.setLocationRefs(discrepancy.getLocation());
+ connector.connectAnnotation(annotation, twinItem.getDiscrepanciesList());
+ }
+ }
+
+ }
+
+ private Map<String, Discrepancy> buildMap(DispoItemData item) {
+ Map<String, Discrepancy> toReturn = new HashMap<>();
+ for (Discrepancy discrepancy : item.getDiscrepanciesList().values()) {
+ toReturn.put(discrepancy.getText(), discrepancy);
+ }
+ return toReturn;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/coverage/LisFileParser.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/coverage/LisFileParser.java
index 1d0a9e3936..28271ed845 100644
--- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/coverage/LisFileParser.java
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/coverage/LisFileParser.java
@@ -40,6 +40,7 @@ import org.eclipse.osee.disposition.rest.DispoImporterApi;
import org.eclipse.osee.disposition.rest.internal.DispoConnector;
import org.eclipse.osee.disposition.rest.internal.DispoDataFactory;
import org.eclipse.osee.disposition.rest.internal.importer.DispoSetCopier;
+import org.eclipse.osee.disposition.rest.internal.importer.MultiEnvCopier;
import org.eclipse.osee.disposition.rest.util.DispoUtil;
import org.eclipse.osee.framework.core.util.Result;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -80,6 +81,10 @@ public class LisFileParser implements DispoImporterApi {
private final Set<String> datIdsCoveredByException = new HashSet<>();
private final Set<String> alreadyUsedDatIds = new HashSet<>();
private final Set<String> alreadyUsedFileNames = new HashSet<>();
+ // Multi Env
+ private final Map<String, Set<DispoItemData>> nameToMultiEnvItems = new HashMap<>();
+ private final Map<DispoItemData, Set<DispoItemData>> itemsToMultiEnvItems = new HashMap<>();
+ private final Set<String> alreadyLinkedMultiEnvItems = new HashSet<>();
private final DispoConnector dispoConnector;
private final DispoApiConfiguration config;
@@ -111,7 +116,7 @@ public class LisFileParser implements DispoImporterApi {
Collection<VCastResult> results = getResultFiles(dataStore);
for (VCastResult result : results) {
try {
- processResult(result, report);
+ processResults(result, report);
} catch (Exception ex) {
report.addEntry("FAILURE", "VCast Error", ERROR);
}
@@ -124,39 +129,25 @@ public class LisFileParser implements DispoImporterApi {
private List<DispoItem> createItems(Map<String, DispoItem> exisitingItems, OperationReport report) {
List<DispoItem> toReturn;
- Collection<DispoItemData> values = datIdToItem.values();
+ Collection<DispoItemData> items = datIdToItem.values();
- for (DispoItemData item : values) {
+ for (DispoItemData item : items) {
dataFactory.initDispoItem(item);
item.setTotalPoints(String.valueOf(item.getAnnotationsList().size() + item.getDiscrepanciesList().size()));
}
if (!exisitingItems.isEmpty()) {
// This is a reimport so we'll need to copy all the annotations
- DispoSetCopier copier = new DispoSetCopier(dispoConnector);
- List<DispoItemData> itemsFromImport = new ArrayList<>();
- itemsFromImport.addAll(values);
-
- Map<String, Set<DispoItemData>> namesToDestItems = new HashMap<>();
- for (DispoItemData item : itemsFromImport) {
- String name = item.getName();
- Set<DispoItemData> itemsWithSameName = namesToDestItems.get(name);
- if (itemsWithSameName == null) {
- Set<DispoItemData> set = new HashSet<>();
- set.add(item);
- namesToDestItems.put(name, set);
- } else {
- itemsWithSameName.add(item);
- namesToDestItems.put(name, itemsWithSameName);
- }
- }
-
- toReturn = copier.copyAllDispositions(namesToDestItems, exisitingItems.values(), false, null, report);
+ toReturn = runCopier(exisitingItems, report, items);
} else {
toReturn = new ArrayList<>();
- toReturn.addAll(values);
+ toReturn.addAll(items);
}
+ // make a flag for multi env operation, could be time consuming
+ MultiEnvCopier multiEnvCopier = new MultiEnvCopier();
+ multiEnvCopier.copy(itemsToMultiEnvItems, report);
+
for (DispoItem item : toReturn) {
if (item.getStatus().equalsIgnoreCase("incomplete")) {
createPlaceHolderAnnotations((DispoItemData) item, report);
@@ -165,6 +156,30 @@ public class LisFileParser implements DispoImporterApi {
return toReturn;
}
+ private List<DispoItem> runCopier(Map<String, DispoItem> exisitingItems, OperationReport report, Collection<DispoItemData> items) {
+ List<DispoItem> toReturn;
+ DispoSetCopier copier = new DispoSetCopier(dispoConnector);
+ List<DispoItemData> itemsFromImport = new ArrayList<>();
+ itemsFromImport.addAll(items);
+
+ Map<String, Set<DispoItemData>> namesToDestItems = new HashMap<>();
+ for (DispoItemData item : itemsFromImport) {
+ String name = item.getName();
+ Set<DispoItemData> itemsWithSameName = namesToDestItems.get(name);
+ if (itemsWithSameName == null) {
+ Set<DispoItemData> set = new HashSet<>();
+ set.add(item);
+ namesToDestItems.put(name, set);
+ } else {
+ itemsWithSameName.add(item);
+ namesToDestItems.put(name, itemsWithSameName);
+ }
+ }
+
+ toReturn = copier.copyAllDispositions(namesToDestItems, exisitingItems.values(), false, null, report);
+ return toReturn;
+ }
+
private void createPlaceHolderAnnotations(DispoItemData item, OperationReport report) {
List<String> uncovered = dispoConnector.getAllUncoveredDiscprepancies(item);
if (!uncovered.isEmpty()) {
@@ -184,6 +199,7 @@ public class LisFileParser implements DispoImporterApi {
matcher.find();
String itemDatId = matcher.group();
DispoItemData item = datIdToItem.get(itemDatId);
+ // here look for additional items with same name
String line = datId.replaceAll("\\d*:\\d*:", "");
line = line.replaceAll(":", "");
@@ -280,6 +296,16 @@ public class LisFileParser implements DispoImporterApi {
String datId = generateDatId(fileNum, functionNum);
datIdToItem.put(datId, newItem);
+ // Muli Env
+ String name = newItem.getName();
+ Set<DispoItemData> set = nameToMultiEnvItems.get(name);
+ if (set == null) {
+ set = new HashSet<>();
+ }
+ set.add(newItem);
+ nameToMultiEnvItems.put(name, set);
+ // end
+
Collection<VCastStatementCoverage> statementCoverageItems = Collections.emptyList();
try {
@@ -382,7 +408,7 @@ public class LisFileParser implements DispoImporterApi {
return sb.toString();
}
- private void processResult(VCastResult result, OperationReport report) throws Exception {
+ private void processResults(VCastResult result, OperationReport report) throws Exception {
String resultPath = result.getPath();
String resultPathAbs = vCastDir + File.separator + resultPath;
File resultsFile = new File(resultPathAbs);
@@ -432,30 +458,7 @@ public class LisFileParser implements DispoImporterApi {
resultsLine, resultsFile.getName()), WARNING);
} else {
if (!alreadyUsedDatIds.contains(resultsLine)) {
- alreadyUsedDatIds.add(resultsLine);
- StringTokenizer st = new StringTokenizer(resultsLine);
- int count = st.countTokens();
- if (count == 3) {
- Matcher m = fileMethod3LineNumberPattern.matcher(resultsLine);
- if (m.find()) {
- processSingleResult(resultPath, m);
- }
- } else if (count == 4) {
- Matcher m = fileMethod4LineNumberPlusTokenPattern.matcher(resultsLine);
- if (m.find()) {
- processSingleResultBranch(resultPath, m);
- }
- } else if (count == 5) {
- Matcher m = fileMethod5LineNumberPattern.matcher(resultsLine);
- if (m.find()) {
- processMultiResultMCDC(resultPath, m);
- }
- } else {
- report.addEntry("RESULTS FILE PARSE",
- String.format("This line [%s] could not be parsed. In DAT file [%s]", resultsLine,
- resultsFile.getName()),
- WARNING);
- }
+ processDatFileLine(report, resultPath, resultsFile, resultsLine);
}
}
}
@@ -468,6 +471,32 @@ public class LisFileParser implements DispoImporterApi {
}
}
+ private void processDatFileLine(OperationReport report, String resultPath, File resultsFile, String resultsLine) {
+ alreadyUsedDatIds.add(resultsLine);
+ StringTokenizer st = new StringTokenizer(resultsLine);
+ int count = st.countTokens();
+ if (count == 3) {
+ Matcher m = fileMethod3LineNumberPattern.matcher(resultsLine);
+ if (m.find()) {
+ processSingleResult(resultPath, m);
+ }
+ } else if (count == 4) {
+ Matcher m = fileMethod4LineNumberPlusTokenPattern.matcher(resultsLine);
+ if (m.find()) {
+ processSingleResultBranch(resultPath, m);
+ }
+ } else if (count == 5) {
+ Matcher m = fileMethod5LineNumberPattern.matcher(resultsLine);
+ if (m.find()) {
+ processMultiResultMCDC(resultPath, m);
+ }
+ } else {
+ report.addEntry("RESULTS FILE PARSE",
+ String.format("This line [%s] could not be parsed. In DAT file [%s]", resultsLine, resultsFile.getName()),
+ WARNING);
+ }
+ }
+
private boolean isDuplicateFile(File file, OperationReport report) {
String normalizedFileName = file.getName().replaceAll("//....", "");
if (alreadyUsedFileNames.contains(normalizedFileName)) {
@@ -481,23 +510,36 @@ public class LisFileParser implements DispoImporterApi {
private void processSingleResult(String resultPath, Matcher m) {
DispoItemData item = datIdToItem.get(generateDatId(m.group(1), m.group(2)));
+
if (item != null) {
String location = m.group(3);
- String text = "";
+ String discrepancyText = "";
Discrepancy matchingDiscrepancy = matchDiscrepancy(location, item.getDiscrepanciesList());
if (matchingDiscrepancy != null) {
- text = matchingDiscrepancy.getText();
+ discrepancyText = matchingDiscrepancy.getText();
Map<String, Discrepancy> discrepancies = item.getDiscrepanciesList();
discrepancies.remove(matchingDiscrepancy.getId());
item.setDiscrepanciesList(discrepancies);
- addAnnotationForCoveredLine(item, location, Test_Unit_Resolution, resultPath, text);
+ addAnnotationForCoveredLine(item, location, Test_Unit_Resolution, resultPath, discrepancyText);
}
+
+ tryMultiEnv(item);
}
}
+ private void tryMultiEnv(DispoItemData itemFromDatMatch) {
+ if (!alreadyLinkedMultiEnvItems.contains(itemFromDatMatch.getName())) {
+ Set<DispoItemData> multiEnvItems = new HashSet<>();
+ multiEnvItems.addAll(nameToMultiEnvItems.get(itemFromDatMatch.getName()));
+
+ itemsToMultiEnvItems.put(itemFromDatMatch, multiEnvItems);
+ }
+ }
+
private void processSingleResultBranch(String resultPath, Matcher m) {
DispoItemData item = datIdToItem.get(generateDatId(m.group(1), m.group(2)));
+
if (item != null) {
String location = m.group(3) + "." + m.group(4);
Discrepancy matchingDiscrepancy = matchDiscrepancy(location, item.getDiscrepanciesList());
@@ -508,6 +550,8 @@ public class LisFileParser implements DispoImporterApi {
item.setDiscrepanciesList(discrepancies);
addAnnotationForCoveredLine(item, location, Test_Unit_Resolution, resultPath, text);
}
+
+ tryMultiEnv(item);
}
}
@@ -534,6 +578,7 @@ public class LisFileParser implements DispoImporterApi {
addAnnotationForCoveredLine(item, location, Test_Unit_Resolution, resultPath, text);
}
}
+ tryMultiEnv(item);
}
}

Back to the top