/// <summary> /// Update references to paragraphs /// </summary> /// <param name="obj"></param> /// <param name="visitSubNodes"></param> public override void visit(Generated.ReqRef obj, bool visitSubNodes) { ReqRef reqRef = (ReqRef)obj; if (UpdateGuid) { Specification.Paragraph paragraph = reqRef.Paragraph; if (paragraph != null) { // Updates the paragraph Guid if (paragraph.Guid != reqRef.getId()) { reqRef.setId(paragraph.getGuid()); } // Updates the specification Guid Specification.Specification specification = EnclosingFinder <Specification.Specification> .find(paragraph); if (specification.Guid != reqRef.getSpecId()) { reqRef.setSpecId(specification.Guid); } } } base.visit(obj, visitSubNodes); }
/// <summary> /// Constructor /// </summary> public FunctionalBlock(Paragraph aParagraph) { Paragraphs = new List<Paragraph>(); Paragraphs.Add(aParagraph); Name = aParagraph.getFunctionalBlockName(); ApplicableParagraphs = 0; ImplementedParagraphs = 0; ModelingRate = 6; EstimatedTime = 0; }
public override void visit(Generated.Paragraph obj, bool visitSubNodes) { Specification.Paragraph paragraph = obj as Specification.Paragraph; if (paragraph != null) { switch (paragraph.getImplementationStatus()) { case DataDictionary.Generated.acceptor.SPEC_IMPLEMENTED_ENUM.Impl_Implemented: if (!paragraph.isApplicable()) { paragraph.AddWarning("Paragraph state does not correspond to implementation status (Implemented but not applicable)"); } break; case DataDictionary.Generated.acceptor.SPEC_IMPLEMENTED_ENUM.Impl_NA: case DataDictionary.Generated.acceptor.SPEC_IMPLEMENTED_ENUM.defaultSPEC_IMPLEMENTED_ENUM: if (!paragraph.isApplicable()) { paragraph.AddWarning("Paragraph state does not correspond to implementation status (N/A but not applicable)"); } break; case DataDictionary.Generated.acceptor.SPEC_IMPLEMENTED_ENUM.Impl_NotImplementable: if (paragraph.isApplicable()) { paragraph.AddWarning("Paragraph state does not correspond to implementation status (Not implementable but applicable)"); } break; } if (paragraph.getImplementationStatus() == Generated.acceptor.SPEC_IMPLEMENTED_ENUM.Impl_Implemented) { foreach (ReqRef reqRef in ImplementedParagraphsFinder.INSTANCE.findRefs(paragraph)) { ReqRelated model = reqRef.Enclosing as ReqRelated; if (!model.ImplementationCompleted) { model.AddError("Requirement implementation is complete, while model element implementation is not"); paragraph.AddError("Requirement implementation is complete, while model element implementation is not"); } } } if (paragraph.getScope() != paragraph.SubParagraphsScope && paragraph.getScope() != Generated.acceptor.Paragraph_scope.aOBU_AND_TRACK) { paragraph.AddWarning("Paragraph scope does not correspond to the scope of its sub-paragraphs"); } } base.visit(obj, visitSubNodes); }
/// <summary> /// Provides all the paragraphs associated to this req related /// </summary> /// <param name="paragraphs">The list of paragraphs to be filled</param> /// <returns></returns> public virtual void findRelatedParagraphsRecursively(List <Specification.Paragraph> paragraphs) { // Append the paragraphs related to the req refs of this req related foreach (ReqRef reqRef in Requirements) { Specification.Paragraph paragraph = reqRef.Paragraph; if (paragraph != null) { if (!paragraphs.Contains(paragraph)) { paragraphs.Add(paragraph); } } } }
/// <summary> /// Provides the kind of issue /// </summary> /// <param name="issue"></param> /// <returns></returns> public static IssueKind? GetKind(Paragraph issue) { IssueKind? retVal = null; foreach (RequirementSetReference reference in issue.RequirementSetReferences) { RequirementSet requirementSet = reference.Ref; while (requirementSet != null && retVal == null) { if (requirementSet.Name.Equals(Blocking)) { retVal = IssueKind.Blocking; } else if (requirementSet.Name.Equals(Issue)) { retVal = IssueKind.Issue; } else if (requirementSet.Name.Equals(Comment)) { retVal = IssueKind.Comment; } else if (requirementSet.Name.Equals(Question)) { retVal = IssueKind.Question; } else if (requirementSet.Name.Equals(OutOfScope)) { retVal = IssueKind.OutOfScope; } requirementSet = requirementSet.Enclosing as RequirementSet; } if (retVal != null) { break; } } return retVal; }
/// <summary> /// Performs the delta on the specification provided /// </summary> /// <param name="delta"></param> /// <param name="specifications"></param> private void PerformDelta(DataDictionary.Specification.Specification specifications) { foreach (Paragraph p in NewDocument.ChangedParagraphs) { DataDictionary.Specification.Paragraph par = specifications.FindParagraph(p.Id); if (par != null) { par.Text = p.Text; par.AddInfo("Paragraph has been changed"); par.setImplementationStatus(DataDictionary.Generated.acceptor.SPEC_IMPLEMENTED_ENUM.Impl_NewRevisionAvailable); par.setReviewed(false); foreach (DataDictionary.ReqRef reqRef in par.Implementations) { DataDictionary.ReqRelated reqRelated = reqRef.Model as DataDictionary.ReqRelated; if (reqRelated != null) { reqRelated.setImplemented(false); reqRelated.setVerified(false); } } } else { AddError(specifications, p, "Cannot find paragraph " + p.Id + " for modification"); } } foreach (Paragraph p in NewDocument.NewParagraphs) { DataDictionary.Specification.Paragraph par = specifications.FindParagraph(p.Id); if (par != null) { AddError(specifications, p, "Paragraph " + p.Id + " already exists, whereas it has been detected as a new paragraph in the release"); } else { par = specifications.FindParagraph(p.Id, true); if (par != null) { par.setText(p.Text); par.AddInfo("New paragraph"); } else { AddError(specifications, p, "Paragraph " + p.Id + " cannot be found in the specification"); } } } foreach (Paragraph p in NewDocument.RemovedParagraphs) { DataDictionary.Specification.Paragraph par = specifications.FindParagraph(p.Id); if (par != null) { par.Text = "<Removed in current release>"; par.AddInfo("Paragraph has been removed"); } else { AddError(specifications, p, "Cannot find paragraph " + p.Id + " for removal"); } } }
// For each element in this report, have a Create method that does the paragraphing stuff and a // Generate method, that involves loops and stuff /// <summary> /// Provides the first-level paragraph under a chapter with the provided name /// </summary> /// <param name="aSectionName"></param> /// <param name="dictionary"></param> /// <returns></returns> private Paragraph getSection(string aSectionName, Dictionary dictionary) { Paragraph retVal = new Paragraph(); foreach (Specification specification in dictionary.Specifications) { foreach (Chapter chapter in specification.Chapters) { foreach (Paragraph paragraph in chapter.Paragraphs) { if (paragraph.ExpressionText == aSectionName) { retVal = paragraph; } } } } return retVal; }
/// <summary> /// Builds a dictionary of sequences containing a given test case, from the implementations of a paragraph /// </summary> /// <param name="paragraph"></param> /// <returns></returns> private Dictionary<string, string[]> findSteps(Paragraph paragraph) { Dictionary<string, string[]> retVal = new Dictionary<string, string[]>(); foreach (ReqRef reference in paragraph.Implementations) { Step step = reference.Model as Step; if (step != null) { if (retVal.ContainsKey(step.TestCase.Name)) { string steps = retVal[step.TestCase.Name][0]; string sequences = retVal[step.TestCase.Name][1]; // Only add the subsequence if it is not already in the string if (sequences.IndexOf(step.SubSequence.Name) == -1) { sequences = sequences + "\n" + step.SubSequence.Name; steps = steps + "\n" + stepNumber(step); } else { int line = getLine(sequences, step.SubSequence.Name); if (!stepPresent(line, step, steps)) { steps = steps.Insert(stepIndex(line, steps), ", " + stepNumber(step)); } } retVal[step.TestCase.Name][0] = steps; retVal[step.TestCase.Name][1] = sequences; } else { retVal[step.TestCase.Name] = new string[] {stepNumber(step), step.SubSequence.Name}; } } } return retVal; }
/// <summary> /// Builds the table of implementations of a paragraph /// </summary> /// <param name="subparagraph"></param> private void AddTestCases(Paragraph subparagraph) { Dictionary<string, string[]> TestFeatures = findSteps(subparagraph); if (TestFeatures.Count > 0) { AddTable(new string[] {"Test case", "Sequence", "Steps"}, new int[] {40, 65, 40}); foreach (KeyValuePair<string, string[]> testFT in TestFeatures) { AddRow(new string[] {testFT.Key, testFT.Value[1], testFT.Value[0]}); } } }
private void addImplementations(Paragraph subparagraph) { bool first = true; foreach (ReqRef reference in subparagraph.Implementations) { Translation translation = reference.Model as Translation; if (translation != null) { if (first) { AddTable(new string[] {"Related translations"}, new int[] {100}); first = false; } foreach (SourceText sourceText in translation.SourceTexts) { AddRow(sourceText.ExpressionText); foreach (SourceTextComment comment in sourceText.Comments) { AddRow(comment.ExpressionText); } } } } }
private void addEntry(Paragraph paragraph, string entryType) { if (paragraph.getReviewed() == ReviewedParagraphs) { if (!paragraph.IsTitle) { AddSubParagraph(entryType + " " + paragraph.FullId); AddParagraph(paragraph.ExpressionText); // provide the translations the paragraph references AddTestCases(paragraph); } else { AddSubParagraph(entryType + " " + paragraph.FullId + ": " + paragraph.ExpressionText); } CloseSubParagraph(); } if (paragraph.SubParagraphs.Count > 0) { foreach (Paragraph subParagraph in paragraph.SubParagraphs) { addEntry(subParagraph, entryType); } } }
private void applicableParagraphs(Paragraph paragraph, ICollection<Paragraph> retVal) { if (paragraph.isApplicable()) { retVal.Add(paragraph); } foreach (Paragraph p in paragraph.SubParagraphs) { applicableParagraphs(p, retVal); } }
/// <summary> /// Marks the paragraph /// </summary> /// <param name="paragraph"></param> /// <param name="recursively">Indicates that the paragraph should be marked recursively</param> /// <returns>true if marking recursively was applied</returns> private bool MarkBelongingParagraph(Paragraph paragraph, bool recursively) { if (!NotImplemented) { paragraph.AddInfo("Requirement set " + RequirementSet.Name); } else if (paragraph.getImplementationStatus() != acceptor.SPEC_IMPLEMENTED_ENUM.Impl_Implemented && paragraph.getImplementationStatus() != acceptor.SPEC_IMPLEMENTED_ENUM.Impl_NotImplementable) { if (paragraph.getType() == acceptor.Paragraph_type.aREQUIREMENT) { paragraph.AddInfo("Belongs to Requirement set " + RequirementSet.Name + " but is not implemented"); } } if (recursively) { foreach (Paragraph subParagraph in paragraph.SubParagraphs) { // ReSharper disable once ConditionIsAlwaysTrueOrFalse MarkBelongingParagraph(subParagraph, recursively); } } return recursively; }
/// <summary> /// Replaces the paragraph scope by the corresponding flags /// </summary> /// <param name="obj"></param> /// <param name="visitSubNodes"></param> public override void visit(Paragraph obj, bool visitSubNodes) { Specification.Paragraph paragraph = (Specification.Paragraph)obj; // WARNING : This phase is completed by the next phase to place all requirement in requirement sets // Ensures the scope is located in the flags switch (paragraph.getObsoleteScope()) { case acceptor.Paragraph_scope.aOBU: paragraph.setObsoleteScopeOnBoard(true); break; case acceptor.Paragraph_scope.aTRACK: paragraph.setObsoleteScopeTrackside(true); break; case acceptor.Paragraph_scope.aOBU_AND_TRACK: case acceptor.Paragraph_scope.defaultParagraph_scope: paragraph.setObsoleteScopeOnBoard(true); paragraph.setObsoleteScopeTrackside(true); break; case acceptor.Paragraph_scope.aROLLING_STOCK: paragraph.setObsoleteScopeRollingStock(true); break; } paragraph.setObsoleteScope(acceptor.Paragraph_scope.aFLAGS); // WARNING : do not remove the preceding phase since it still required for previous versions of EFS files // Based on the flag information, place the requirements in their corresponding requirement set // STM was never used, this information is discarded RequirementSet scope = paragraph.Dictionary.findRequirementSet(Dictionary.ScopeName, true); if (paragraph.getObsoleteScopeOnBoard()) { RequirementSet onBoard = scope.findRequirementSet(RequirementSet.OnboardScopeName, false); if (onBoard == null) { onBoard = scope.findRequirementSet(RequirementSet.OnboardScopeName, true); onBoard.setRecursiveSelection(false); onBoard.setDefault(true); } paragraph.AppendToRequirementSet(onBoard); paragraph.setObsoleteScopeOnBoard(false); } if (paragraph.getObsoleteScopeTrackside()) { RequirementSet trackSide = scope.findRequirementSet(RequirementSet.TracksideScopeName, false); if (trackSide == null) { trackSide = scope.findRequirementSet(RequirementSet.TracksideScopeName, true); trackSide.setRecursiveSelection(false); trackSide.setDefault(true); } paragraph.AppendToRequirementSet(trackSide); paragraph.setObsoleteScopeTrackside(false); } if (paragraph.getObsoleteScopeRollingStock()) { RequirementSet rollingStock = scope.findRequirementSet(RequirementSet.RollingStockScopeName, false); if (rollingStock == null) { rollingStock = scope.findRequirementSet(RequirementSet.RollingStockScopeName, true); rollingStock.setRecursiveSelection(false); rollingStock.setDefault(false); } paragraph.AppendToRequirementSet(rollingStock); paragraph.setObsoleteScopeRollingStock(false); } // Updates the functional block information based on the FunctionalBlockName field if (!string.IsNullOrEmpty(paragraph.getObsoleteFunctionalBlockName())) { RequirementSet allFunctionalBlocks = paragraph.Dictionary.findRequirementSet(Dictionary.FunctionalBlockName, true); RequirementSet functionalBlock = allFunctionalBlocks.findRequirementSet(paragraph.getObsoleteFunctionalBlockName(), true); functionalBlock.setRecursiveSelection(true); functionalBlock.setDefault(false); paragraph.AppendToRequirementSet(functionalBlock); paragraph.setObsoleteFunctionalBlockName(null); } base.visit(obj, visitSubNodes); }
/// <summary> /// Adds a paragraph to the list of paragraphs of this functional block /// </summary> /// <param name="aParagraph"></param> public void AddParagraph(Paragraph aParagraph) { Paragraphs.Add(aParagraph); }
private void ComputeStatsForParagraph(Paragraph aParagraph) { switch (aParagraph.getImplementationStatus()) { case DataDictionary.Generated.acceptor.SPEC_IMPLEMENTED_ENUM.Impl_Implemented: ApplicableParagraphs++; ImplementedParagraphs++; break; case DataDictionary.Generated.acceptor.SPEC_IMPLEMENTED_ENUM.Impl_NA: case DataDictionary.Generated.acceptor.SPEC_IMPLEMENTED_ENUM.defaultSPEC_IMPLEMENTED_ENUM: ApplicableParagraphs++; break; } foreach (Paragraph paragraph in aParagraph.SubParagraphs) { ComputeStatsForParagraph(paragraph); } }