Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2018-02-27 21:12:57 +0000
committerdonald.g.dunne2018-02-28 16:30:25 +0000
commit8f3f7e5cfcc1309c2cf91cb1236e3477018d92b1 (patch)
tree8d4291aa1c00fa1d4113e47dd11119238bb367b5
parentb362b4b72f5f50bb44c368b4ff25bc5dba9d9d7a (diff)
downloadorg.eclipse.osee-8f3f7e5cfcc1309c2cf91cb1236e3477018d92b1.tar.gz
org.eclipse.osee-8f3f7e5cfcc1309c2cf91cb1236e3477018d92b1.tar.xz
org.eclipse.osee-8f3f7e5cfcc1309c2cf91cb1236e3477018d92b1.zip
bug[ats_TW7741]: Validate Req Changes slow and erroring
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/validate/ListAndBulletRule.java11
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/validate/UniqueNameRule.java17
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/validate/ValidationReportOperation.java31
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/ElapsedTime.java34
4 files changed, 70 insertions, 23 deletions
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/validate/ListAndBulletRule.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/validate/ListAndBulletRule.java
index ebd1f867b90..24093e9bd4b 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/validate/ListAndBulletRule.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/validate/ListAndBulletRule.java
@@ -15,7 +15,7 @@ import java.util.Collection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.ats.api.config.WorkType;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
@@ -29,10 +29,11 @@ public class ListAndBulletRule extends AbstractValidationRule {
private static final String MORE_ON_FORMATTING =
"https://apache.msc.az.boeing.com/wiki/lba/index.php/OSEE/ATS/LBA/User_Guide#What_is_.22Validate_Requirement_Changes.22.2C_how_do_I_run_it_and_complete_review.3F";
private static final Pattern NORMAL_LIST_BULLET_STYLE = Pattern.compile("<w:pPr><w:listPr>.+?</w:listPr></w:pPr>");
- private final IArtifactType artifactType;
- public ListAndBulletRule(IArtifactType artifactType) {
- this.artifactType = artifactType;
+ private final WorkType workType;
+
+ public ListAndBulletRule(WorkType workType) {
+ this.workType = workType;
}
@Override
@@ -62,7 +63,7 @@ public class ListAndBulletRule extends AbstractValidationRule {
@Override
public String getRuleTitle() {
- return "Formatting Check:";
+ return String.format("Formatting Check for :", workType);
}
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/validate/UniqueNameRule.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/validate/UniqueNameRule.java
index d8d538f922d..171dbc90cd1 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/validate/UniqueNameRule.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/validate/UniqueNameRule.java
@@ -12,10 +12,13 @@ package org.eclipse.osee.ats.util.validate;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.model.type.ArtifactType;
@@ -31,6 +34,7 @@ public class UniqueNameRule extends AbstractValidationRule {
private final IArtifactType artifactType;
private final Collection<UuidPair> uuidPairs = new LinkedList<>();
+ private final Map<IArtifactType, List<Artifact>> artTypeToArtifacts = new HashMap<IArtifactType, List<Artifact>>();
public UniqueNameRule(IArtifactType artifactType) {
this.artifactType = artifactType;
@@ -46,8 +50,7 @@ public class UniqueNameRule extends AbstractValidationRule {
boolean validationPassed = true;
if (hasArtifactType(artToValidate.getArtifactType())) {
// validate that no other artifact of the given Artifact Type has the same name.
- List<Artifact> arts = ArtifactQuery.getArtifactListFromTypeWithInheritence(artifactType,
- artToValidate.getBranch(), DeletionFlag.EXCLUDE_DELETED);
+ List<Artifact> arts = getArtifactsOfType(artToValidate.getBranchToken(), artToValidate.getArtifactType());
for (Artifact art : arts) {
if (art.getName().equalsIgnoreCase(artToValidate.getName()) && !art.getUuid().equals(
artToValidate.getUuid()) && !hasUuidPairAlreadyBeenEvaluated(art.getUuid(), artToValidate.getUuid())) {
@@ -79,6 +82,16 @@ public class UniqueNameRule extends AbstractValidationRule {
return new ValidationResult(errorMessages, validationPassed);
}
+ protected List<Artifact> getArtifactsOfType(IOseeBranch branch, IArtifactType artToValidate) {
+ List<Artifact> arts = artTypeToArtifacts.get(artToValidate);
+ if (arts == null) {
+ arts =
+ ArtifactQuery.getArtifactListFromTypeWithInheritence(artifactType, branch, DeletionFlag.EXCLUDE_DELETED);
+ artTypeToArtifacts.put(artToValidate, arts);
+ }
+ return arts;
+ }
+
private boolean isImplementationDetailsChild(Artifact childArtifact, Artifact parentArtifact) {
return parentArtifact.getArtifactType().equals(CoreArtifactTypes.SoftwareRequirement) && //
(childArtifact.isOfType(CoreArtifactTypes.AbstractImplementationDetails) && //
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/validate/ValidationReportOperation.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/validate/ValidationReportOperation.java
index 04c324c3ea7..2d025275a29 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/validate/ValidationReportOperation.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/validate/ValidationReportOperation.java
@@ -31,6 +31,8 @@ import org.eclipse.osee.framework.core.operation.AbstractOperation;
import org.eclipse.osee.framework.core.operation.OperationLogger;
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.ElapsedTime;
+import org.eclipse.osee.framework.jdk.core.util.ElapsedTime.Units;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.revision.ChangeData;
@@ -53,6 +55,7 @@ public class ValidationReportOperation extends AbstractOperation {
@Override
protected void doWork(IProgressMonitor monitor) throws Exception {
+ ElapsedTime totalTime = new ElapsedTime(getName());
logf("<b>Validating Requirement Changes for %s</b>\n", teamArt.getName());
List<AbstractValidationRule> rulesSorted = new ArrayList<>(rules);
@@ -70,7 +73,7 @@ public class ValidationReportOperation extends AbstractOperation {
changeData.getArtifacts(KindType.ArtifactOrRelation, ModificationType.NEW, ModificationType.MODIFIED);
checkForCancelledStatus(monitor);
- double total = changedArtifacts.size() + rules.size();
+ double total = changedArtifacts.size() * rules.size();
if (total > 0) {
Collection<String> warnings = new ArrayList<>();
@@ -79,6 +82,7 @@ public class ValidationReportOperation extends AbstractOperation {
String lastTitle = "";
int ruleIndex = 1;
for (AbstractValidationRule rule : rulesSorted) {
+ ElapsedTime time = new ElapsedTime("Time Spent");
checkForCancelledStatus(monitor);
//check to see if we should print a header for sorted (and grouped) rule types
@@ -90,30 +94,36 @@ public class ValidationReportOperation extends AbstractOperation {
if (isSkipRelationCheck(rule.getRuleTitle())) {
logf("INFO: Relations Check skipped: detected committed branches.");
+ } else if (isSkipOrphanCheck(rule.getRuleTitle())) {
+ logf("INFO: Orphan Check skipped");
} else {
int artIndex = 1;
for (Artifact art : changedArtifacts) {
- monitor.setTaskName(String.format("Validating: Rule[%s of %s] Artifact[%s of %s]", ruleIndex,
- rules.size(), artIndex, changedArtifacts.size()));
- checkForCancelledStatus(monitor);
+ try {
+ monitor.setTaskName(String.format("Validating: Rule[%s of %s] Artifact[%s of %s]", ruleIndex,
+ rules.size(), artIndex, changedArtifacts.size()));
+ checkForCancelledStatus(monitor);
- ValidationResult result = rule.validate(art, monitor);
- if (!isSkipOrphanCheck(rule.getRuleTitle(), artIndex)) {
+ ValidationResult result = rule.validate(art, monitor);
if (!result.didValidationPass()) {
for (String errorMsg : result.getErrorMessages()) {
- if (art.isOfType(CoreArtifactTypes.DirectSoftwareRequirement,
- CoreArtifactTypes.AbstractImplementationDetails)) {
+ if (art.isOfType(CoreArtifactTypes.DirectSoftwareRequirement)) {
logf("Error: %s", errorMsg);
} else {
warnings.add(String.format("Warning: %s", errorMsg));
}
}
}
+ } catch (Exception ex) {
+ logf("Exception processing artifact %s Exception ex: %s", art.toStringWithId(),
+ ex.getMessage());
}
monitor.worked(workAmount);
artIndex++;
}
}
+ log("\n");
+ log(time.end(Units.MIN, false));
ruleIndex++;
}
@@ -123,6 +133,7 @@ public class ValidationReportOperation extends AbstractOperation {
}
}
+ log(totalTime.end(Units.MIN));
log("\nValidation Complete");
} catch (Exception ex) {
OseeLog.log(Activator.class, Level.SEVERE, ex);
@@ -130,8 +141,8 @@ public class ValidationReportOperation extends AbstractOperation {
}
}
- private boolean isSkipOrphanCheck(String ruleTitle, int index) {
- return ruleTitle.equals("Orphan Validation Checks") && index > 1;
+ private boolean isSkipOrphanCheck(String ruleTitle) {
+ return ruleTitle.equals("Orphan Validation Checks");
}
private boolean isSkipRelationCheck(String ruleTitle) {
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/ElapsedTime.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/ElapsedTime.java
index 6c6a80e6d4c..a18dc2714d4 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/ElapsedTime.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/ElapsedTime.java
@@ -45,7 +45,7 @@ public class ElapsedTime {
public static enum Units {
SEC,
- MSEC
+ MIN
}
public String end() {
@@ -53,12 +53,34 @@ public class ElapsedTime {
}
public String end(Units units) {
+ return end(units, true);
+ }
+
+ public String end(Units units, boolean printToSysErr) {
endDate = new Date();
- long diff = endDate.getTime() - startDate.getTime();
- String str = String.format("%s - elapsed %d %s - start %s - end %s", name,
- units == Units.SEC ? diff / 1000 : diff, units.name(), DateUtil.getDateStr(startDate, DateUtil.HHMMSSSS),
- DateUtil.getDateStr(endDate, DateUtil.HHMMSSSS));
- System.err.println(str + (logStart ? "" : "\n"));
+ long timeSpent = endDate.getTime() - startDate.getTime();
+ long time = timeSpent; // milliseconds
+ String milliseconds = "";
+ if (units == Units.SEC) {
+ time = time / 1000; // convert from milliseconds to seconds
+ milliseconds = "";
+ } else if (units == Units.MIN) {
+ time = time / 60000; // convert from milliseconds to minutes
+ milliseconds = " ( " + timeSpent + " ms ) ";
+ }
+ String str = String.format("%s- elapsed %d %s%s - start %s - end %s", name, time, units.name(), milliseconds,
+ DateUtil.getDateStr(startDate, DateUtil.HHMMSSSS), DateUtil.getDateStr(endDate, DateUtil.HHMMSSSS));
+ if (printToSysErr) {
+ System.err.println(str + (logStart ? "" : "\n"));
+ }
return str;
}
+
+ /**
+ * Milliseconds spent so far. Does not call end().
+ */
+ public Long getTimeSpent() {
+ Date endDate = new Date();
+ return endDate.getTime() - startDate.getTime();
+ }
}

Back to the top