/// <summary> /// Cleans all text fields in this element /// </summary> /// <param name="obj"></param> /// <param name="visitSubNodes"></param> public override void visit(Generated.Dictionary obj, bool visitSubNodes) { if ( obj.getXsi() != null ) { obj.setXsi(obj.getXsi().Trim()); } if ( obj.getXsiLocation() != null ) { obj.setXsiLocation(obj.getXsiLocation().Trim()); } base.visit(obj, visitSubNodes); }
/// <summary> /// Compares two Dictionary and annotates the differences on the first one /// </summary> /// <param name="obj"></param> /// <param name="other"></param> public static void compareDictionary(Generated.Dictionary obj, Generated.Dictionary other, VersionDiff diff) { if ( other == null ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "", "", obj.Name ) ); return; } if ( obj.allSpecifications() != null ) { if ( other.allSpecifications() != null ) { foreach ( Generated.Specification subElement in obj.allSpecifications() ) { bool compared = false; foreach ( Generated.Specification otherElement in other.allSpecifications() ) { if ( subElement.Guid == otherElement.Guid ) { compareSpecification ( subElement, otherElement, diff ); compared = true; break; } } if ( !compared ) { diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "Specifications", "", subElement.Name ) ); } } foreach ( Generated.Specification otherElement in other.allSpecifications() ) { bool found = false; foreach ( Generated.Specification subElement in obj.allSpecifications() ) { if ( subElement.Guid == otherElement.Guid ) { found = true; break; } } if ( !found ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "Specifications", otherElement.Name) ); } } } else { foreach ( Generated.Specification subElement in obj.allSpecifications() ) { diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "Specifications", "", subElement.Name ) ); } } } else { if ( other.allSpecifications() != null ) { foreach ( Generated.Specification otherElement in other.allSpecifications() ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "Specifications", otherElement.Name) ); } } } if ( obj.allRequirementSets() != null ) { if ( other.allRequirementSets() != null ) { foreach ( Generated.RequirementSet subElement in obj.allRequirementSets() ) { bool compared = false; foreach ( Generated.RequirementSet otherElement in other.allRequirementSets() ) { if ( subElement.Guid == otherElement.Guid ) { compareRequirementSet ( subElement, otherElement, diff ); compared = true; break; } } if ( !compared ) { diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "RequirementSets", "", subElement.Name ) ); } } foreach ( Generated.RequirementSet otherElement in other.allRequirementSets() ) { bool found = false; foreach ( Generated.RequirementSet subElement in obj.allRequirementSets() ) { if ( subElement.Guid == otherElement.Guid ) { found = true; break; } } if ( !found ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "RequirementSets", otherElement.Name) ); } } } else { foreach ( Generated.RequirementSet subElement in obj.allRequirementSets() ) { diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "RequirementSets", "", subElement.Name ) ); } } } else { if ( other.allRequirementSets() != null ) { foreach ( Generated.RequirementSet otherElement in other.allRequirementSets() ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "RequirementSets", otherElement.Name) ); } } } if ( obj.allRuleDisablings() != null ) { if ( other.allRuleDisablings() != null ) { foreach ( Generated.RuleDisabling subElement in obj.allRuleDisablings() ) { bool compared = false; foreach ( Generated.RuleDisabling otherElement in other.allRuleDisablings() ) { if ( subElement.Guid == otherElement.Guid ) { compareRuleDisabling ( subElement, otherElement, diff ); compared = true; break; } } if ( !compared ) { diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "RuleDisablings", "", subElement.Name ) ); } } foreach ( Generated.RuleDisabling otherElement in other.allRuleDisablings() ) { bool found = false; foreach ( Generated.RuleDisabling subElement in obj.allRuleDisablings() ) { if ( subElement.Guid == otherElement.Guid ) { found = true; break; } } if ( !found ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "RuleDisablings", otherElement.Name) ); } } } else { foreach ( Generated.RuleDisabling subElement in obj.allRuleDisablings() ) { diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "RuleDisablings", "", subElement.Name ) ); } } } else { if ( other.allRuleDisablings() != null ) { foreach ( Generated.RuleDisabling otherElement in other.allRuleDisablings() ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "RuleDisablings", otherElement.Name) ); } } } if ( obj.allNameSpaces() != null ) { if ( other.allNameSpaces() != null ) { foreach ( Generated.NameSpace subElement in obj.allNameSpaces() ) { bool compared = false; foreach ( Generated.NameSpace otherElement in other.allNameSpaces() ) { if ( subElement.Guid == otherElement.Guid ) { compareNameSpace ( subElement, otherElement, diff ); compared = true; break; } } if ( !compared ) { diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "NameSpaces", "", subElement.Name ) ); } } foreach ( Generated.NameSpace otherElement in other.allNameSpaces() ) { bool found = false; foreach ( Generated.NameSpace subElement in obj.allNameSpaces() ) { if ( subElement.Guid == otherElement.Guid ) { found = true; break; } } if ( !found ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "NameSpaces", otherElement.Name) ); } } } else { foreach ( Generated.NameSpace subElement in obj.allNameSpaces() ) { diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "NameSpaces", "", subElement.Name ) ); } } } else { if ( other.allNameSpaces() != null ) { foreach ( Generated.NameSpace otherElement in other.allNameSpaces() ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "NameSpaces", otherElement.Name) ); } } } if ( obj.allNameSpaceRefs() != null ) { if ( other.allNameSpaceRefs() != null ) { foreach ( Generated.NameSpaceRef subElement in obj.allNameSpaceRefs() ) { bool compared = false; foreach ( Generated.NameSpaceRef otherElement in other.allNameSpaceRefs() ) { if ( subElement.Guid == otherElement.Guid ) { compareNameSpaceRef ( subElement, otherElement, diff ); compared = true; break; } } if ( !compared ) { diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "NameSpaceRefs", "", subElement.Name ) ); } } foreach ( Generated.NameSpaceRef otherElement in other.allNameSpaceRefs() ) { bool found = false; foreach ( Generated.NameSpaceRef subElement in obj.allNameSpaceRefs() ) { if ( subElement.Guid == otherElement.Guid ) { found = true; break; } } if ( !found ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "NameSpaceRefs", otherElement.Name) ); } } } else { foreach ( Generated.NameSpaceRef subElement in obj.allNameSpaceRefs() ) { diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "NameSpaceRefs", "", subElement.Name ) ); } } } else { if ( other.allNameSpaceRefs() != null ) { foreach ( Generated.NameSpaceRef otherElement in other.allNameSpaceRefs() ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "NameSpaceRefs", otherElement.Name) ); } } } if ( obj.allTests() != null ) { if ( other.allTests() != null ) { foreach ( Generated.Frame subElement in obj.allTests() ) { bool compared = false; foreach ( Generated.Frame otherElement in other.allTests() ) { if ( subElement.Guid == otherElement.Guid ) { compareFrame ( subElement, otherElement, diff ); compared = true; break; } } if ( !compared ) { diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "Tests", "", subElement.Name ) ); } } foreach ( Generated.Frame otherElement in other.allTests() ) { bool found = false; foreach ( Generated.Frame subElement in obj.allTests() ) { if ( subElement.Guid == otherElement.Guid ) { found = true; break; } } if ( !found ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "Tests", otherElement.Name) ); } } } else { foreach ( Generated.Frame subElement in obj.allTests() ) { diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "Tests", "", subElement.Name ) ); } } } else { if ( other.allTests() != null ) { foreach ( Generated.Frame otherElement in other.allTests() ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "Tests", otherElement.Name) ); } } } if ( obj.allTestRefs() != null ) { if ( other.allTestRefs() != null ) { foreach ( Generated.FrameRef subElement in obj.allTestRefs() ) { bool compared = false; foreach ( Generated.FrameRef otherElement in other.allTestRefs() ) { if ( subElement.Guid == otherElement.Guid ) { compareFrameRef ( subElement, otherElement, diff ); compared = true; break; } } if ( !compared ) { diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "TestRefs", "", subElement.Name ) ); } } foreach ( Generated.FrameRef otherElement in other.allTestRefs() ) { bool found = false; foreach ( Generated.FrameRef subElement in obj.allTestRefs() ) { if ( subElement.Guid == otherElement.Guid ) { found = true; break; } } if ( !found ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "TestRefs", otherElement.Name) ); } } } else { foreach ( Generated.FrameRef subElement in obj.allTestRefs() ) { diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "TestRefs", "", subElement.Name ) ); } } } else { if ( other.allTestRefs() != null ) { foreach ( Generated.FrameRef otherElement in other.allTestRefs() ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "TestRefs", otherElement.Name) ); } } } if ( obj.getTranslationDictionary() == null ) { if ( other.getTranslationDictionary() != null ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "TranslationDictionary", "" ) ); } } else { compareTranslationDictionary ( obj.getTranslationDictionary(), other.getTranslationDictionary(), diff ); } if ( obj.getShortcutDictionary() == null ) { if ( other.getShortcutDictionary() != null ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "ShortcutDictionary", "" ) ); } } else { compareShortcutDictionary ( obj.getShortcutDictionary(), other.getShortcutDictionary(), diff ); } if ( !CompareUtil.canonicalStringEquality(obj.getXsi(), other.getXsi()) ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "Xsi", other.getXsi(), obj.getXsi()) ); } if ( !CompareUtil.canonicalStringEquality(obj.getXsiLocation(), other.getXsiLocation()) ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "XsiLocation", other.getXsiLocation(), obj.getXsiLocation()) ); } }
/// <summary> /// Duplicates a source Dictionary into its target /// </summary> /// <param name="source"></param> /// <param name="target"></param> public static void DuplicateDictionary(Generated.Dictionary source, Generated.Dictionary target) { if ( source != null && target != null ) { target.setXsi(source.getXsi()); target.setXsiLocation(source.getXsiLocation()); } }
/// <summary> /// Searches a specific string in Dictionary and updates the list /// of model element with all the elements in which that string is found /// </summary> /// <param name="obj"></param> /// <param name="obj">The string to search for</param> /// <param name="occurences">The list of model elements which hold the searched string</param> public static void searchDictionary(Generated.Dictionary obj, string searchString, List<ModelElement> occurences) { if ( obj.allSpecifications() != null ) { foreach ( Generated.Specification subElement in obj.allSpecifications() ) { searchSpecification ( subElement, searchString, occurences ); } } if ( obj.allRequirementSets() != null ) { foreach ( Generated.RequirementSet subElement in obj.allRequirementSets() ) { searchRequirementSet ( subElement, searchString, occurences ); } } if ( obj.allRuleDisablings() != null ) { foreach ( Generated.RuleDisabling subElement in obj.allRuleDisablings() ) { searchRuleDisabling ( subElement, searchString, occurences ); } } if ( obj.allNameSpaces() != null ) { foreach ( Generated.NameSpace subElement in obj.allNameSpaces() ) { searchNameSpace ( subElement, searchString, occurences ); } } if ( obj.allNameSpaceRefs() != null ) { foreach ( Generated.NameSpaceRef subElement in obj.allNameSpaceRefs() ) { searchNameSpaceRef ( subElement, searchString, occurences ); } } if ( obj.allTests() != null ) { foreach ( Generated.Frame subElement in obj.allTests() ) { searchFrame ( subElement, searchString, occurences ); } } if ( obj.allTestRefs() != null ) { foreach ( Generated.FrameRef subElement in obj.allTestRefs() ) { searchFrameRef ( subElement, searchString, occurences ); } } if ( obj.getTranslationDictionary() != null ) { searchTranslationDictionary ( obj.getTranslationDictionary(), searchString, occurences ); } if ( obj.getShortcutDictionary() != null ) { searchShortcutDictionary ( obj.getShortcutDictionary(), searchString, occurences ); } if ( obj.getXsi() != null && obj.getXsi().Contains (searchString) ) { occurences.Add ( obj ); } if ( obj.getXsiLocation() != null && obj.getXsiLocation().Contains (searchString) ) { occurences.Add ( obj ); } }