/// <summary> /// Compares two Action and annotates the differences on the first one /// </summary> /// <param name="obj"></param> /// <param name="other"></param> public static void compareAction(Generated.Action obj, Generated.Action other, VersionDiff diff) { if ( other == null ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "", "", obj.Name ) ); return; } if ( !CompareUtil.canonicalStringEquality(obj.getExpression(), other.getExpression()) ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "Expression", other.getExpression(), obj.getExpression()) ); } if ( !CompareUtil.canonicalStringEquality(obj.getComment(), other.getComment()) ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "Comment", other.getComment(), obj.getComment()) ); } }
/// <summary> /// Cleans all text fields in this element /// </summary> /// <param name="obj"></param> /// <param name="visitSubNodes"></param> public override void visit(Generated.Action obj, bool visitSubNodes) { if ( obj.getExpression() != null ) { obj.setExpression(obj.getExpression().Trim()); } if ( obj.getComment() != null ) { obj.setComment(obj.getComment().Trim()); } base.visit(obj, visitSubNodes); }
/// <summary> /// Compares two Case and annotates the differences on the first one /// </summary> /// <param name="obj"></param> /// <param name="other"></param> public static void compareCase(Generated.Case obj, Generated.Case other, VersionDiff diff) { if ( other == null ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "", "", obj.Name ) ); return; } compareNamable (obj, other, diff); if ( obj.allPreConditions() != null ) { if ( other.allPreConditions() != null ) { int i = 0; while ( i < obj.countPreConditions() && i < other.countPreConditions() ) { Generated.PreCondition element = obj.getPreConditions( i ); Generated.PreCondition otherElement = other.getPreConditions( i ); comparePreCondition ( element, otherElement, diff ); i += 1; } while ( i < obj.countPreConditions() ) { diff.appendChanges ( new Diff(obj.getPreConditions(i), HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "PreConditions", "", obj.getPreConditions( i ).Name ) ); i += 1; } while ( i < other.countPreConditions() ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove, "PreConditions", other.getPreConditions( i ).Name) ); i += 1; } } else { foreach ( Generated.PreCondition subElement in obj.allPreConditions() ) { diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "PreConditions", "", subElement.Name ) ); } } } else { if ( other.allPreConditions() != null ) { foreach ( Generated.PreCondition otherElement in other.allPreConditions() ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "PreConditions", otherElement.Name) ); } } } if ( !CompareUtil.canonicalStringEquality(obj.getExpression(), other.getExpression()) ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "Expression", other.getExpression(), obj.getExpression()) ); } if ( !CompareUtil.canonicalStringEquality(obj.getComment(), other.getComment()) ) { diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "Comment", other.getComment(), obj.getComment()) ); } }
/// <summary> /// Duplicates a source Case into its target /// </summary> /// <param name="source"></param> /// <param name="target"></param> public static void DuplicateCase(Generated.Case source, Generated.Case target) { if ( source != null && target != null ) { DuplicateNamable (source, target); target.setExpression(source.getExpression()); target.setComment(source.getComment()); } }
/// <summary> /// Duplicates a source Action into its target /// </summary> /// <param name="source"></param> /// <param name="target"></param> public static void DuplicateAction(Generated.Action source, Generated.Action target) { if ( source != null && target != null ) { target.setExpression(source.getExpression()); target.setComment(source.getComment()); } }
/// <summary> /// Searches a specific string in Case 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 searchCase(Generated.Case obj, string searchString, List<ModelElement> occurences) { searchNamable (obj, searchString, occurences); if ( obj.allPreConditions() != null ) { foreach ( Generated.PreCondition subElement in obj.allPreConditions() ) { searchPreCondition ( subElement, searchString, occurences ); } } if ( obj.getExpression() != null && obj.getExpression().Contains (searchString) ) { occurences.Add ( obj ); } if ( obj.getComment() != null && obj.getComment().Contains (searchString) ) { occurences.Add ( obj ); } }
/// <summary> /// Searches a specific string in Action 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 searchAction(Generated.Action obj, string searchString, List<ModelElement> occurences) { if ( obj.getExpression() != null && obj.getExpression().Contains (searchString) ) { occurences.Add ( obj ); } if ( obj.getComment() != null && obj.getComment().Contains (searchString) ) { occurences.Add ( obj ); } }