diff options
author | jmisinco | 2012-02-08 21:38:48 +0000 |
---|---|---|
committer | Ryan D. Brooks | 2012-02-08 21:38:48 +0000 |
commit | 837f2e5008b6fe00e23e0ad3b05d45cacd25ee76 (patch) | |
tree | f69dbdde4535ea016abc972abbc7f475365bb6f0 | |
parent | 41a6c79ec8789caa6007fc97c07d6dfdb3fee46c (diff) | |
download | org.eclipse.osee-837f2e5008b6fe00e23e0ad3b05d45cacd25ee76.tar.gz org.eclipse.osee-837f2e5008b6fe00e23e0ad3b05d45cacd25ee76.tar.xz org.eclipse.osee-837f2e5008b6fe00e23e0ad3b05d45cacd25ee76.zip |
refactor[ats_P8RTT]: Update reports to use imported traceability
-rw-r--r-- | plugins/org.eclipse.osee.ats/plugin.xml | 7 | ||||
-rw-r--r-- | plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatusBlam.java | 594 | ||||
-rw-r--r-- | plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatusOld.java (renamed from plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatus.java) | 17 | ||||
-rw-r--r-- | plugins/org.eclipse.osee.ats/ui/DetailedTestStatusUi.xml | 18 | ||||
-rw-r--r-- | plugins/org.eclipse.osee.define/META-INF/MANIFEST.MF | 5 | ||||
-rw-r--r-- | plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemFullTraceReport.java | 90 |
6 files changed, 695 insertions, 36 deletions
diff --git a/plugins/org.eclipse.osee.ats/plugin.xml b/plugins/org.eclipse.osee.ats/plugin.xml index 5009dae505c..41c3d8465cb 100644 --- a/plugins/org.eclipse.osee.ats/plugin.xml +++ b/plugins/org.eclipse.osee.ats/plugin.xml @@ -475,8 +475,13 @@ </UserNavigateItem> </extension> <extension + id="DetailedTestStatusOld" name="DetailedTestStatusOld" + point="org.eclipse.osee.framework.ui.skynet.BlamOperation"> + <Operation className="org.eclipse.osee.ats.operation.DetailedTestStatusOld"/> + </extension> + <extension id="DetailedTestStatus" name="DetailedTestStatus" point="org.eclipse.osee.framework.ui.skynet.BlamOperation"> - <Operation className="org.eclipse.osee.ats.operation.DetailedTestStatus"/> + <Operation className="org.eclipse.osee.ats.operation.DetailedTestStatusBlam"/> </extension> </plugin> diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatusBlam.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatusBlam.java new file mode 100644 index 00000000000..4420df2dd32 --- /dev/null +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatusBlam.java @@ -0,0 +1,594 @@ +/******************************************************************************* + * Copyright (c) 2011 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.ats.operation; + +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.logging.Level; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.osee.ats.core.config.IAtsProgram; +import org.eclipse.osee.ats.core.task.TaskArtifact; +import org.eclipse.osee.ats.core.team.TeamState; +import org.eclipse.osee.ats.core.team.TeamWorkFlowArtifact; +import org.eclipse.osee.ats.core.type.AtsAttributeTypes; +import org.eclipse.osee.ats.core.util.AtsUtilCore; +import org.eclipse.osee.ats.core.version.VersionArtifact; +import org.eclipse.osee.ats.core.workflow.PercentCompleteTotalUtil; +import org.eclipse.osee.ats.internal.Activator; +import org.eclipse.osee.ats.util.widgets.XAtsProgramComboWidget; +import org.eclipse.osee.define.traceability.BranchTraceabilityOperation; +import org.eclipse.osee.define.traceability.RequirementTraceabilityData; +import org.eclipse.osee.define.traceability.TraceabilityProviderOperation; +import org.eclipse.osee.define.traceability.report.RequirementStatus; +import org.eclipse.osee.framework.core.data.IOseeBranch; +import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; +import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; +import org.eclipse.osee.framework.core.enums.DeletionFlag; +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.core.model.Branch; +import org.eclipse.osee.framework.core.model.IBasicUser; +import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap; +import org.eclipse.osee.framework.jdk.core.type.HashCollection; +import org.eclipse.osee.framework.jdk.core.util.Collections; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.Strings; +import org.eclipse.osee.framework.jdk.core.util.io.CharBackedInputStream; +import org.eclipse.osee.framework.jdk.core.util.io.xml.ExcelXmlWriter; +import org.eclipse.osee.framework.jdk.core.util.io.xml.ISheetWriter; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.plugin.core.util.AIFile; +import org.eclipse.osee.framework.plugin.core.util.OseeData; +import org.eclipse.osee.framework.skynet.core.artifact.Artifact; +import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; +import org.eclipse.osee.framework.skynet.core.utility.Artifacts; +import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam; +import org.eclipse.osee.framework.ui.skynet.blam.VariableMap; +import org.eclipse.osee.framework.ui.skynet.widgets.XArtifactList; +import org.eclipse.osee.framework.ui.skynet.widgets.XBranchSelectWidget; +import org.eclipse.osee.framework.ui.skynet.widgets.XModifiedListener; +import org.eclipse.osee.framework.ui.skynet.widgets.XWidget; +import org.eclipse.osee.framework.ui.skynet.widgets.util.DynamicXWidgetLayout; +import org.eclipse.osee.framework.ui.swt.Displays; +import org.eclipse.osee.ote.define.artifacts.TestRunOperator; +import org.eclipse.swt.program.Program; +import org.eclipse.ui.forms.widgets.FormToolkit; + +/** + * @author Ryan D. Brooks + */ +public class DetailedTestStatusBlam extends AbstractBlam { + private static final Pattern taskNamePattern = Pattern.compile("(?:\"([^\"]+)\")? for \"([^\"]+)\""); + private static final SimpleDateFormat dateFormatter = new SimpleDateFormat("E MMM dd HH:mm:ss z yyyy"); + private final Matcher taskNameMatcher = taskNamePattern.matcher(""); + private CharBackedInputStream charBak; + private ISheetWriter excelWriter; + // reqName legacyId + private final CompositeKeyHashMap<String, String, RequirementStatus> reqTaskMap = + new CompositeKeyHashMap<String, String, RequirementStatus>(); + private final StringBuilder sumFormula = new StringBuilder(500); + private HashCollection<Artifact, String> requirementToCodeUnitsMap; + private final HashMap<String, String> testProcedureInfo = new HashMap<String, String>(); + private final HashCollection<String, IBasicUser> legacyIdToImplementers = new HashCollection<String, IBasicUser>(); + private final HashMap<String, Artifact> testRunArtifacts = new HashMap<String, Artifact>(); + private final HashMap<String, String> scriptCategories = new HashMap<String, String>(); + private final HashSet<IBasicUser> testPocs = new HashSet<IBasicUser>(); + private final HashSet<String> requirementPocs = new HashSet<String>(); + private final ArrayList<String[]> statusLines = new ArrayList<String[]>(); + private final ArrayList<RequirementStatus> statuses = new ArrayList<RequirementStatus>(100); + private HashCollection<String, Artifact> requirementNameToTestProcedures; + private Collection<VersionArtifact> versions; + + private XBranchSelectWidget reportBranchWidget; + private XArtifactList versionsListViewer; + + private IOseeBranch selectedBranch; + private IAtsProgram selectedProgram; + + private enum Index { + Category, + TEST_POC, + PARTITION, + SUBSYSTEM, + REQUIREMENT_NAME, + QUALIFICATION_METHOD, + REQUIREMENT_POC, + SW_ENHANCEMENT, + TEST_PROCEDURE, + TEST_SCRIPT, + RUN_DATE, + TOTAL_TP, + FAILED_TP, + HOURS_REMAINING + }; + + private class BranchChangeListener implements ISelectionChangedListener { + @Override + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection versionArtifactSelection = + (IStructuredSelection) event.getSelectionProvider().getSelection(); + Iterator<?> iter = versionArtifactSelection.iterator(); + if (iter.hasNext()) { + VersionArtifact versionArtifact = (VersionArtifact) iter.next(); + + try { + selectedBranch = versionArtifact.getBaselineBranch(); + + reportBranchWidget.setSelection(selectedBranch); + } catch (OseeCoreException ex) { + log(ex); + } + } + } + } + private final BranchChangeListener branchSelectionListener = new BranchChangeListener(); + + private class ProgramSelectionListener implements ISelectionChangedListener { + @Override + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection selection = (IStructuredSelection) event.getSelectionProvider().getSelection(); + + Iterator<?> iter = selection.iterator(); + if (iter.hasNext()) { + selectedProgram = (IAtsProgram) iter.next(); + selectedBranch = null; + + try { + Collection<VersionArtifact> versionArtifacts = + selectedProgram.getTeamDefHoldingVersions().getVersionsArtifacts(); + versionsListViewer.setInputArtifacts(versionArtifacts); + + reportBranchWidget.setSelection(null); + + versionsListViewer.addSelectionChangedListener(branchSelectionListener); + } catch (OseeCoreException ex) { + log(ex); + } + } + } + } + + private void init() throws IOException { + charBak = new CharBackedInputStream(); + excelWriter = new ExcelXmlWriter(charBak.getWriter()); + reqTaskMap.clear(); + testRunArtifacts.clear(); + testProcedureInfo.clear(); + legacyIdToImplementers.clear(); + } + + private String getScriptName(String scriptPath) { + return scriptPath.substring(scriptPath.lastIndexOf(File.separatorChar) + 1, + scriptPath.length() - ".java".length()); + } + + private void loadTestRunArtifacts(IOseeBranch scriptsBranch) throws OseeCoreException { + Collection<Artifact> testRuns = + ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.TestRun, scriptsBranch, DeletionFlag.EXCLUDE_DELETED); + + for (Artifact testRun : testRuns) { + String shortName = testRun.getName(); + shortName = shortName.substring(shortName.lastIndexOf('.') + 1); + Artifact previousTestRun = testRunArtifacts.put(shortName, testRun); + + if (previousTestRun != null) { + Date date = new TestRunOperator(testRun).getEndDate(); + Date previousDate = new TestRunOperator(previousTestRun).getEndDate(); + if (previousDate.after(date)) { + testRunArtifacts.put(shortName, previousTestRun); + } + } + } + } + + @Override + public void runOperation(VariableMap variableMap, final IProgressMonitor monitor) throws Exception { + if (!blamReadyToExecute()) { + monitor.setCanceled(true); + return; + } + + IOseeBranch reportBranch = variableMap.getBranch("Requirements Branch"); + IOseeBranch resultsBranch = variableMap.getBranch("Test Results Branch"); + versions = variableMap.getCollection(VersionArtifact.class, "Versions"); + init(); + + loadTestRunArtifacts(resultsBranch); + + // Load Requirements Data + TraceabilityProviderOperation provider = null; + provider = new BranchTraceabilityOperation((Branch) reportBranch); + RequirementTraceabilityData traceabilityData = + new RequirementTraceabilityData(reportBranch, reportBranch, provider); + + IStatus status = traceabilityData.initialize(monitor); + switch (status.getSeverity()) { + case IStatus.OK: + requirementToCodeUnitsMap = traceabilityData.getRequirementsToCodeUnits(); + requirementNameToTestProcedures = traceabilityData.getRequirementNameToTestProcedures(); + + loadReqTaskMap(); + + writeStatusSheet(traceabilityData.getAllSwRequirements()); + + writeTestScriptSheet(traceabilityData.getCodeUnits()); + + excelWriter.endWorkbook(); + IFile iFile = OseeData.getIFile("Detailed_Test_Status_" + Lib.getDateTimeString() + ".xml"); + AIFile.writeToFile(iFile, charBak); + Program.launch(iFile.getLocation().toOSString()); + break; + case IStatus.CANCEL: + monitor.setCanceled(true); + break; + default: + throw new OseeCoreException(status.getMessage(), status.getException()); + } + } + + private boolean blamReadyToExecute() { + final List<String> items = new ArrayList<String>(); + + if (selectedProgram == null) { + items.add("program"); + } + if (selectedBranch == null) { + items.add("branch"); + } + + boolean ready = items.isEmpty(); + if (!ready) { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + MessageDialog.openInformation(Displays.getActiveShell(), "Problem", + String.format("Select a %s ...", Strings.buildStatment(items))); + } + }); + } + return ready; + } + + private void writeTestScriptSheet(Set<String> scripts) throws IOException, OseeCoreException { + excelWriter.startSheet("Scripts", 8); + excelWriter.writeRow("Category", CoreArtifactTypes.TestCase.getName(), "Run Date", "Total Test Points", + "Failed Test Points", "Duration", "Aborted", "Last Author"); + + for (String scriptPath : scripts) { + String scriptName = getScriptName(scriptPath); + Artifact testRunArtifact = testRunArtifacts.get(scriptName); + String totalTestPoints = null; + String failedTestPoints = null; + String category = scriptCategories.get(scriptPath); + String runDate = null; + String duration = null; + String aborated = null; + String lastAuthor = null; + if (testRunArtifact != null) { + TestRunOperator runOperator = new TestRunOperator(testRunArtifact); + try { + runDate = dateFormatter.format(runOperator.getEndDate()); + } catch (Exception ex) { + OseeLog.log(Activator.class, Level.SEVERE, ex); + } + totalTestPoints = String.valueOf(runOperator.getTotalTestPoints()); + failedTestPoints = String.valueOf(runOperator.getTestPointsFailed()); + duration = runOperator.getRunDuration(); + aborated = runOperator.wasAborted() ? "aborted" : null; + lastAuthor = runOperator.getLastAuthor(); + } + + excelWriter.writeRow(category, scriptName, runDate, totalTestPoints, failedTestPoints, duration, aborated, + lastAuthor); + } + + excelWriter.endSheet(); + } + + private void writeStatusSheet(Collection<Artifact> requirements) throws IOException, OseeCoreException { + excelWriter.startSheet("SW Req Status", 256); + excelWriter.writeRow(null, null, null, null, "Hours per UI per RPCR", "=4"); + excelWriter.writeRow(null, null, null, null, "Hours to integrate all scripts for a UI", "=11"); + excelWriter.writeRow(null, null, null, null, "Hours to develop a new script", "=20"); + excelWriter.writeRow(); + excelWriter.writeRow(); + excelWriter.writeRow("Category", "Test POCs", CoreAttributeTypes.Partition.getName(), + CoreAttributeTypes.Subsystem.getName(), "Requirement Name", CoreAttributeTypes.QualificationMethod.getName(), + "Requirement POCs", "SW Enhancement", CoreArtifactTypes.TestProcedure.getName(), + CoreArtifactTypes.TestCase.getName(), "Run Date", "Total Test Points", "Failed Test Points", + "Hours Remaining", "RPCR", "Hours", "Resolution by Partition"); + + for (Artifact requirement : requirements) { + writeRequirementStatusLines(requirement); + } + + excelWriter.endSheet(); + } + + private void setScriptCategories(Artifact requirement, Collection<String> scripts) { + try { + String reqCategory = requirement.getSoleAttributeValue(CoreAttributeTypes.Category, ""); + + for (String scriptPath : scripts) { + String scriptCategory = scriptCategories.get(scriptPath); + if (scriptCategory == null || scriptCategory.compareTo(reqCategory) > 0) { + scriptCategories.put(scriptPath, reqCategory); + } + } + } catch (Exception ex) { + // really don't care because we handle unknown priorities later + } + } + + private void processRpcrStatuses(Artifact requirement, String[] statusLine) { + int columnIndex = Index.HOURS_REMAINING.ordinal() + 1; + + sumFormula.append(","); + for (String requirementName : getAliases(requirement)) { + Collection<RequirementStatus> tempStatuses = reqTaskMap.getValues(requirementName); + + if (tempStatuses != null) { + statuses.clear(); + statuses.addAll(tempStatuses); + java.util.Collections.sort(statuses); + for (int i = statuses.size() - 1; i >= 0; i--) { + RequirementStatus status = statuses.get(i); + statusLine[columnIndex++] = status.getLegacyId(); + statusLine[columnIndex++] = "=R1C6*(100-" + status.getRolledupPercentComplete() + ")/100"; + + sumFormula.append("RC"); + sumFormula.append(columnIndex); + sumFormula.append(","); + + statusLine[columnIndex++] = status.getPartitionStatuses(); + + Collection<IBasicUser> implementers = legacyIdToImplementers.getValues(status.getLegacyId()); + if (implementers != null) { + for (IBasicUser implementer : implementers) { + requirementPocs.add(implementer.getName()); + } + } + testPocs.addAll(status.getTestPocs()); + } + } + } + + sumFormula.setCharAt(sumFormula.length() - 1, ')'); + } + + private void processTestScriptsAndProcedures(Artifact requirement, String[] statusLine) throws OseeCoreException { + Collection<String> scripts = requirementToCodeUnitsMap.getValues(requirement); + if (scripts == null) { + if (requirement.isOfType(CoreArtifactTypes.IndirectSoftwareRequirement)) { + statusLine[Index.TEST_SCRIPT.ordinal()] = requirement.getArtifactTypeName(); + sumFormula.insert(0, "=sum(0"); + statusLine[Index.HOURS_REMAINING.ordinal()] = sumFormula.toString(); + } else { + statusLine[Index.TEST_SCRIPT.ordinal()] = "No script found"; + statusLine[Index.HOURS_REMAINING.ordinal()] = "=R3C6"; + } + statusLines.add(statusLine); + } else { + setScriptCategories(requirement, scripts); + int testPointTotalForScripts = 0; + int testPointFailsForScripts = 0; + + for (String script : scripts) { + String scriptName = getScriptName(script); + statusLine[Index.TEST_SCRIPT.ordinal()] = scriptName; + Artifact testRunArtifact = testRunArtifacts.get(scriptName); + if (testRunArtifact != null) { + TestRunOperator runOperator = new TestRunOperator(testRunArtifact); + + try { + statusLine[Index.RUN_DATE.ordinal()] = dateFormatter.format(runOperator.getEndDate()); + } catch (Exception ex) { + log(ex); + } + if (runOperator.wasAborted()) { + statusLine[Index.TOTAL_TP.ordinal()] = "Aborted"; + statusLine[Index.FAILED_TP.ordinal()] = "Aborted"; + } else { + int individualTestPointsFailed = runOperator.getTestPointsFailed(); + int individualTestPointTotal = runOperator.getTotalTestPoints(); + + statusLine[Index.TOTAL_TP.ordinal()] = String.valueOf(individualTestPointTotal); + statusLine[Index.FAILED_TP.ordinal()] = String.valueOf(individualTestPointsFailed); + + testPointFailsForScripts += individualTestPointsFailed; + testPointTotalForScripts += individualTestPointTotal; + } + } + statusLines.add(statusLine); + String[] oldStatusLine = statusLine; + statusLine = new String[100]; + initStatusLine(oldStatusLine, statusLine); + } + + String failRatio = "1"; + if (testPointTotalForScripts != 0) { + failRatio = testPointFailsForScripts + "/" + testPointTotalForScripts; + } + sumFormula.insert(0, "=sum(R2C6*" + failRatio); + statusLines.get(0)[Index.HOURS_REMAINING.ordinal()] = sumFormula.toString(); + } + + addTestProcedureNames(requirement.getName()); + } + + private void writeRequirementStatusLines(Artifact requirement) throws OseeCoreException, IOException { + statusLines.clear(); + testPocs.clear(); + requirementPocs.clear(); + sumFormula.delete(0, 99999); + String[] statusLine = new String[100]; + + processRpcrStatuses(requirement, statusLine); + + statusLine[Index.Category.ordinal()] = requirement.getSoleAttributeValue(CoreAttributeTypes.Category, ""); + if (requirement.isOfType(CoreArtifactTypes.IndirectSoftwareRequirement)) { + statusLine[Index.Category.ordinal()] = "I"; + } + + statusLine[Index.TEST_POC.ordinal()] = Artifacts.toString("; ", testPocs); + statusLine[Index.PARTITION.ordinal()] = requirement.getAttributesToString(CoreAttributeTypes.Partition); + statusLine[Index.SUBSYSTEM.ordinal()] = requirement.getSoleAttributeValue(CoreAttributeTypes.Subsystem, ""); + statusLine[Index.REQUIREMENT_NAME.ordinal()] = requirement.getName(); + statusLine[Index.QUALIFICATION_METHOD.ordinal()] = + requirement.getAttributesToStringSorted(CoreAttributeTypes.QualificationMethod); + statusLine[Index.REQUIREMENT_POC.ordinal()] = Collections.toString(",", requirementPocs); + + Collection<RequirementStatus> reqStats = reqTaskMap.getValues(requirement.getName()); + statusLine[Index.SW_ENHANCEMENT.ordinal()] = + reqStats.isEmpty() ? "" : reqStats.iterator().next().getSwEnhancement(); + + processTestScriptsAndProcedures(requirement, statusLine); + + for (String[] line : statusLines) { + excelWriter.writeRow(line); + } + } + + private void addTestProcedureNames(String requirementName) { + Collection<Artifact> testProcedures = requirementNameToTestProcedures.getValues(requirementName); + if (testProcedures != null) { + int index = 0; + String[] firstStatusLine = statusLines.get(index); + String lastTestProcedure = null; + for (Artifact testProcedure : testProcedures) { + if (index < statusLines.size()) { + statusLines.get(index++)[Index.TEST_PROCEDURE.ordinal()] = testProcedure.getName(); + lastTestProcedure = testProcedure.getName(); + } else { + String[] statusLine = new String[Index.RUN_DATE.ordinal()]; + initStatusLine(firstStatusLine, statusLine); + statusLine[Index.TEST_PROCEDURE.ordinal()] = testProcedure.getName(); + statusLines.add(statusLine); + } + } + while (index < statusLines.size()) { + statusLines.get(index++)[Index.TEST_PROCEDURE.ordinal()] = lastTestProcedure; + } + } + } + + private void initStatusLine(String[] oldStatusLine, String[] newStatusLine) { + System.arraycopy(oldStatusLine, 0, newStatusLine, 0, Index.RUN_DATE.ordinal()); + } + + private void loadReqTaskMap() throws Exception { + for (VersionArtifact version : versions) { + for (TeamWorkFlowArtifact workflow : version.getTargetedForTeamArtifacts()) { + loadTasksFromWorkflow(workflow); + } + } + } + + @Override + public void widgetCreating(XWidget xWidget, FormToolkit toolkit, Artifact art, DynamicXWidgetLayout dynamicXWidgetLayout, XModifiedListener modListener, boolean isEditable) { + String widgetLabel = xWidget.getLabel(); + + if (widgetLabel.equals("Versions")) { + versionsListViewer = (XArtifactList) xWidget; + } else if (widgetLabel.equals("Requirements Branch")) { + reportBranchWidget = (XBranchSelectWidget) xWidget; + } + } + + @Override + public void widgetCreated(XWidget xWidget, FormToolkit toolkit, Artifact art, DynamicXWidgetLayout dynamicXWidgetLayout, XModifiedListener modListener, boolean isEditable) { + String widgetName = xWidget.getLabel(); + if (widgetName.equals("Program")) { + XAtsProgramComboWidget programWidget = (XAtsProgramComboWidget) xWidget; + programWidget.getComboViewer().addSelectionChangedListener(new ProgramSelectionListener()); + } + } + + private void loadTasksFromWorkflow(TeamWorkFlowArtifact workflow) throws OseeCoreException { + Collection<TaskArtifact> tasks = workflow.getTaskArtifacts(TeamState.Implement); + String legacyId = workflow.getSoleAttributeValue(AtsAttributeTypes.LegacyPcrId, ""); + + List<IBasicUser> implementers = workflow.getImplementers(); + legacyIdToImplementers.put(legacyId, implementers); + + for (TaskArtifact task : tasks) { + + taskNameMatcher.reset(task.getName()); + if (taskNameMatcher.find()) { + String requirementName = taskNameMatcher.group(2); + RequirementStatus requirementStatus = reqTaskMap.get(requirementName, legacyId); + if (requirementStatus == null) { + requirementStatus = + new RequirementStatus(requirementName, legacyId, workflow.getSoleAttributeValueAsString( + AtsAttributeTypes.SwEnhancement, "")); + reqTaskMap.put(requirementName, legacyId, requirementStatus); + } + + int percentComplete = PercentCompleteTotalUtil.getPercentCompleteTotal(task); + requirementStatus.addPartitionStatus(percentComplete, taskNameMatcher.group(1), + AtsUtilCore.getStateName(task)); + requirementStatus.setTestPocs(task.getImplementers()); + } else { + logf("odd task: [%s]", task.getName()); + } + } + } + + /* + * returns a collection of all the names the given artifact has ever had + */ + private Collection<String> getAliases(Artifact artifact) { + // TODO: this method should return history of names + ArrayList<String> aliases = new ArrayList<String>(1); + aliases.add(artifact.getName()); + return aliases; + } + + @Override + public String getXWidgetsXml() { + StringBuilder sb = new StringBuilder(); + sb.append("<xWidgets>"); + sb.append("<XWidget xwidgetType=\"XAtsProgramComboWidget\" horizontalLabel=\"true\" displayName=\"Program\" />"); + sb.append("<XWidget xwidgetType=\"XArtifactList\" displayName=\"Versions\" multiSelect=\"true\" />"); + sb.append("<XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"Requirements Branch\" toolTip=\"Select a requirements branch.\" />"); + sb.append("<XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"Test Results Branch\" toolTip=\"Select a scripts results branch.\" />"); + sb.append("</xWidgets>"); + return sb.toString(); + } + + @Override + public String getDescriptionUsage() { + return "Generates an excel spreadsheet with detailed test status for scripts and procedures"; + } + + @Override + public Collection<String> getCategories() { + return Arrays.asList("OTE"); + } +} diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatus.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatusOld.java index 32d0d870088..268853e0199 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatus.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatusOld.java @@ -84,7 +84,7 @@ import org.eclipse.ui.forms.widgets.FormToolkit; /** * @author Ryan D. Brooks */ -public class DetailedTestStatus extends AbstractBlam { +public class DetailedTestStatusOld extends AbstractBlam { private static final Pattern taskNamePattern = Pattern.compile("(?:\"([^\"]+)\")? for \"([^\"]+)\""); private static final SimpleDateFormat dateFormatter = new SimpleDateFormat("E MMM dd HH:mm:ss z yyyy"); private final Matcher taskNameMatcher = taskNamePattern.matcher(""); @@ -594,8 +594,19 @@ public class DetailedTestStatus extends AbstractBlam { } @Override - public String getXWidgetsXml() throws OseeCoreException { - return getXWidgetsXmlFromUiFile(getClass().getSimpleName(), Activator.PLUGIN_ID); + public String getXWidgetsXml() { + StringBuilder sb = new StringBuilder(); + sb.append("<xWidgets>"); + sb.append("<XWidget xwidgetType=\"XAtsProgramComboWidget\" horizontalLabel=\"true\" displayName=\"Program\" />"); + sb.append("<XWidget xwidgetType=\"XArtifactList\" displayName=\"Versions\" multiSelect=\"true\" />"); + sb.append("<XWidget xwidgetType=\"XText\" displayName=\"Script Root Directory\" defaultValue=\"C:/UserData/workspaceScripts\" />"); + sb.append("<XWidget xwidgetType=\"XLabel\" displayName=\"or (Note: If traceability branch is selected, requirements branch is not used as they will be pulled from the traceability branch)\"/>"); + sb.append("<XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"Traceability Branch\" toolTip=\"Select a requirements branch.\" />"); + sb.append("<XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"Requirements Branch\" toolTip=\"Select a requirements branch.\" />"); + sb.append("<XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"Test Results Branch\" toolTip=\"Select a scripts results branch.\" />"); + sb.append("<XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"Test Procedure Branch\" toolTip=\"Select a test procedures branch.\" />"); + sb.append("</xWidgets>"); + return sb.toString(); } @Override diff --git a/plugins/org.eclipse.osee.ats/ui/DetailedTestStatusUi.xml b/plugins/org.eclipse.osee.ats/ui/DetailedTestStatusUi.xml deleted file mode 100644 index 17a0c8b1397..00000000000 --- a/plugins/org.eclipse.osee.ats/ui/DetailedTestStatusUi.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<xWidgets> - <XWidget xwidgetType="XAtsProgramComboWidget" horizontalLabel="true" - displayName="Program" /> - <XWidget xwidgetType="XArtifactList" displayName="Versions" - multiSelect="true" /> - <XWidget xwidgetType="XText" displayName="Script Root Directory" - defaultValue="C:/UserData/workspaceScripts" /> - <XWidget xwidgetType="XLabel" displayName="or (Note: If traceability branch is selected, requirements branch is not used as they will be pulled from the traceability branch)"/> - <XWidget xwidgetType="XBranchSelectWidget" displayName="Traceability Branch" - toolTip="Select a requirements branch." /> - <XWidget xwidgetType="XBranchSelectWidget" displayName="Requirements Branch" - toolTip="Select a requirements branch." /> - <XWidget xwidgetType="XBranchSelectWidget" displayName="Test Results Branch" - toolTip="Select a scripts results branch." /> - <XWidget xwidgetType="XBranchSelectWidget" displayName="Test Procedure Branch" - toolTip="Select a test procedures branch." /> -</xWidgets>
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.define/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.define/META-INF/MANIFEST.MF index fa0ac873f7c..2bd2ce503b3 100644 --- a/plugins/org.eclipse.osee.define/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.define/META-INF/MANIFEST.MF @@ -73,10 +73,13 @@ Import-Package: org.apache.commons.lang;version="2.4.0", org.eclipse.osee.framework.ui.skynet.skywalker.arttype, org.eclipse.osee.framework.ui.skynet.templates, org.eclipse.osee.framework.ui.skynet.util, + org.eclipse.osee.framework.ui.skynet.widgets, + org.eclipse.osee.framework.ui.skynet.widgets.util, org.eclipse.osee.framework.ui.skynet.widgets.xBranch, org.eclipse.osee.framework.ui.skynet.widgets.xHistory, org.eclipse.osee.framework.ui.swt, org.eclipse.osee.framework.ui.ws, org.eclipse.osee.ote.define.artifacts, - org.eclipse.ui.forms.editor + org.eclipse.ui.forms.editor, + org.eclipse.ui.forms.widgets Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemFullTraceReport.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemFullTraceReport.java index 6315021d868..190d1b57a19 100644 --- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemFullTraceReport.java +++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemFullTraceReport.java @@ -37,9 +37,20 @@ import org.eclipse.osee.framework.plugin.core.util.AIFile; import org.eclipse.osee.framework.plugin.core.util.OseeData; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.Attribute; +import org.eclipse.osee.framework.skynet.core.utility.Artifacts; import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam; import org.eclipse.osee.framework.ui.skynet.blam.VariableMap; +import org.eclipse.osee.framework.ui.skynet.widgets.XCheckBox; +import org.eclipse.osee.framework.ui.skynet.widgets.XModifiedListener; +import org.eclipse.osee.framework.ui.skynet.widgets.XText; +import org.eclipse.osee.framework.ui.skynet.widgets.XWidget; +import org.eclipse.osee.framework.ui.skynet.widgets.util.DynamicXWidgetLayout; +import org.eclipse.osee.framework.ui.swt.Displays; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.program.Program; +import org.eclipse.ui.forms.widgets.FormToolkit; /** * @author Ryan D. Brooks @@ -52,6 +63,11 @@ public class SubsystemFullTraceReport extends AbstractBlam { private static int TEST_INDEX = 13; private final ArrayList<String> tests = new ArrayList<String>(50); + private final String SCRIPT_ROOT_DIR = "Script Root Directory"; + private final String USE_TRACE_IN_OSEE = "Use traceability from Subsystem Requirements"; + private XCheckBox useTraceInOsee; + private XText scriptDir; + @Override public String getName() { return "Subsystem Full Trace Report"; @@ -69,15 +85,19 @@ public class SubsystemFullTraceReport extends AbstractBlam { throw new OseeArgumentException("must specify a set of artifacts"); } IOseeBranch branch = artifacts.get(0).getBranch(); - String scriptPath = variableMap.getString("Script Root Directory"); init(); - - if (!scriptPath.equals("")) { - File scriptDir = new File(variableMap.getString("Script Root Directory")); - ScriptTraceabilityOperation traceOperation = new ScriptTraceabilityOperation(scriptDir, branch, false); - Operations.executeWorkAndCheckStatus(traceOperation, monitor); - requirementsToCodeUnits = traceOperation.getRequirementToCodeUnitsMap(); + String scriptDir = variableMap.getString(SCRIPT_ROOT_DIR); + Boolean checked = variableMap.getBoolean(USE_TRACE_IN_OSEE); + + if (!checked) { + File dir = new File(scriptDir); + if (dir.exists()) { + ScriptTraceabilityOperation traceOperation = + new ScriptTraceabilityOperation(dir.getParentFile(), branch, false); + Operations.executeWorkAndCheckStatus(traceOperation, monitor); + requirementsToCodeUnits = traceOperation.getRequirementToCodeUnitsMap(); + } } writeMainSheet(prepareSubsystemRequirements(artifacts)); @@ -159,12 +179,17 @@ public class SubsystemFullTraceReport extends AbstractBlam { for (Artifact testProcedure : softwareRequirement.getRelatedArtifacts(CoreRelationTypes.Validation__Validator)) { tests.add(testProcedure.getName()); } + Collection<String> testScripts = null; if (requirementsToCodeUnits != null) { - Collection<String> testScripts = requirementsToCodeUnits.getValues(softwareRequirement); - if (testScripts != null) { - for (String testScript : testScripts) { - tests.add(new File(testScript).getName()); - } + testScripts = requirementsToCodeUnits.getValues(softwareRequirement); + } else { + List<Artifact> relatedArtifacts = + softwareRequirement.getRelatedArtifacts(CoreRelationTypes.Verification__Verifier); + testScripts = Artifacts.getNames(relatedArtifacts); + } + if (testScripts != null) { + for (String testScript : testScripts) { + tests.add(new File(testScript).getName()); } } writer.writeCell(Collections.toString(", ", tests), TEST_INDEX); @@ -173,7 +198,13 @@ public class SubsystemFullTraceReport extends AbstractBlam { @Override public String getXWidgetsXml() { - return "<xWidgets><XWidget xwidgetType=\"XText\" displayName=\"Script Root Directory\" defaultValue=\"C:/UserData/workspaceScripts\" toolTip=\"Leave blank if test script traceability is not needed.\" /><XWidget xwidgetType=\"XListDropViewer\" displayName=\"Subsystem Requirements\" /></xWidgets>"; + StringBuilder sb = new StringBuilder(); + sb.append("<xWidgets>"); + sb.append("<XWidget xwidgetType=\"XCheckBox\" displayName=\"" + USE_TRACE_IN_OSEE + "\" defaultValue=\"true\" labelAfter=\"true\" horizontalLabel=\"true\" />"); + sb.append("<XWidget xwidgetType=\"XText\" displayName=\"" + SCRIPT_ROOT_DIR + "\" defaultValue=\"C:/UserData/workspaceScripts\" toolTip=\"Leave blank if test script traceability is not needed.\" />"); + sb.append("<XWidget xwidgetType=\"XListDropViewer\" displayName=\"Subsystem Requirements\" />"); + sb.append("</xWidgets>"); + return sb.toString(); } @Override @@ -185,4 +216,37 @@ public class SubsystemFullTraceReport extends AbstractBlam { public Collection<String> getCategories() { return Arrays.asList("Define.Trace"); } + + @Override + public void widgetCreated(XWidget widget, FormToolkit toolkit, Artifact art, DynamicXWidgetLayout dynamicXWidgetLayout, XModifiedListener modListener, boolean isEditable) throws OseeCoreException { + super.widgetCreated(widget, toolkit, art, dynamicXWidgetLayout, modListener, isEditable); + + if (widget.getLabel().equals(SCRIPT_ROOT_DIR)) { + scriptDir = (XText) widget; + scriptDir.setEnabled(false); + scriptDir.getControl().setBackground(Displays.getSystemColor(SWT.COLOR_GRAY)); + } + + if (widget.getLabel().equals(USE_TRACE_IN_OSEE)) { + useTraceInOsee = (XCheckBox) widget; + useTraceInOsee.addSelectionListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent e) { + if (useTraceInOsee.isChecked()) { + scriptDir.setEnabled(false); + scriptDir.getControl().setBackground(Displays.getSystemColor(SWT.COLOR_GRAY)); + } else { + scriptDir.setEnabled(true); + scriptDir.getControl().setBackground(Displays.getSystemColor(SWT.COLOR_WHITE)); + } + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + //Do Nothing + } + }); + } + } }
\ No newline at end of file |