Ejemplo n.º 1
0
        /// <summary>
        /// Ensures that two Procedure have matching GUID, and recursively.
        /// obj is the leader for Guid. If other doesn't match obj guid, 
        ///   1. other does not have a guid, in that case, other should have the same guid as obj
        ///   2. other already has a guid. In that case, there is a mismatch between objects, and the process stops here
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="other"></param>
        public static void ensureGuidProcedure(Generated.Procedure obj, Generated.Procedure other)
        {
            if ( obj == null )
            {
                if ( other != null )
                {
                    // Side effect, setup a GUID if needed for the other part (other)
                    string guid = other.Guid;
                }
                return;
            }

            if ( other == null )
            {
                if ( obj != null )
                {
                    // Side effect, setup a GUID if needed for the other part (obj)
                    string guid = obj.Guid;
                }
                return;
            }

            if ( obj.Guid != other.getGuid() )
            {
                if ( string.IsNullOrEmpty(other.getGuid()) || GuidByName && (obj.Name == other.Name) )
                {
                    // These are matching elements, copy the guid from  obj
                    other.setGuid ( obj.Guid );
                }
                else
                {
                    // Elements do not match. Stop the recursive process
                    return;
                }
            }

            ensureGuidReqRelated (obj, other);

            ensureGuidStateMachine ( obj.getStateMachine(), other.getStateMachine() );
            if ( obj.allRules() != null )
            {
                if ( other.allRules() != null )
                {
                    foreach ( Generated.Rule subElement in obj.allRules() )
                    {
                        bool found = false;

                        // Try first to assign Guid to elements which do not have a guid
                        // This helps handling duplicated in lists
                        foreach ( Generated.Rule otherElement in other.allRules() )
                        {
                            if ( CompareUtil.canonicalStringEquality(subElement.Name, otherElement.Name) && otherElement.getGuid() == null )
                            {
                                ensureGuidRule ( subElement, otherElement );
                                found = true;
                                break;
                            }
                        }

                        if ( !found )
                        {
                            foreach ( Generated.Rule otherElement in other.allRules() )
                            {
                                if ( CompareUtil.canonicalStringEquality(subElement.Name, otherElement.Name) )
                                {
                                    ensureGuidRule ( subElement, otherElement );
                                    found = true;
                                    break;
                                }
                            }
                        }

                        if ( !found )
                        {
                            ensureGuidRule ( subElement, null );
                        }
                    }

                    foreach ( Generated.Rule otherElement in other.allRules() )
                    {
                        bool found = false;
                        foreach ( Generated.Rule subElement in obj.allRules() )
                        {
                            if ( CompareUtil.canonicalStringEquality(subElement.Name, otherElement.Name) )
                            {
                                found = true;
                                break;
                            }
                        }

                        if ( !found )
                        {
                            ensureGuidRule ( null, otherElement );
                        }
                    }
                }
                else
                {
                    foreach ( Generated.Rule subElement in obj.allRules() )
                    {
                        ensureGuidRule ( subElement, null );
                    }
                }
            }
            else
            {
                if ( other.allRules() != null )
                {
                    foreach ( Generated.Rule otherElement in other.allRules() )
                    {
                        ensureGuidRule ( null, otherElement );
                    }
                }
            }
            if ( obj.allParameters() != null )
            {
                if ( other.allParameters() != null )
                {
                    foreach ( Generated.Parameter subElement in obj.allParameters() )
                    {
                        bool found = false;

                        // Try first to assign Guid to elements which do not have a guid
                        // This helps handling duplicated in lists
                        foreach ( Generated.Parameter otherElement in other.allParameters() )
                        {
                            if ( CompareUtil.canonicalStringEquality(subElement.Name, otherElement.Name) && otherElement.getGuid() == null )
                            {
                                ensureGuidParameter ( subElement, otherElement );
                                found = true;
                                break;
                            }
                        }

                        if ( !found )
                        {
                            foreach ( Generated.Parameter otherElement in other.allParameters() )
                            {
                                if ( CompareUtil.canonicalStringEquality(subElement.Name, otherElement.Name) )
                                {
                                    ensureGuidParameter ( subElement, otherElement );
                                    found = true;
                                    break;
                                }
                            }
                        }

                        if ( !found )
                        {
                            ensureGuidParameter ( subElement, null );
                        }
                    }

                    foreach ( Generated.Parameter otherElement in other.allParameters() )
                    {
                        bool found = false;
                        foreach ( Generated.Parameter subElement in obj.allParameters() )
                        {
                            if ( CompareUtil.canonicalStringEquality(subElement.Name, otherElement.Name) )
                            {
                                found = true;
                                break;
                            }
                        }

                        if ( !found )
                        {
                            ensureGuidParameter ( null, otherElement );
                        }
                    }
                }
                else
                {
                    foreach ( Generated.Parameter subElement in obj.allParameters() )
                    {
                        ensureGuidParameter ( subElement, null );
                    }
                }
            }
            else
            {
                if ( other.allParameters() != null )
                {
                    foreach ( Generated.Parameter otherElement in other.allParameters() )
                    {
                        ensureGuidParameter ( null, otherElement );
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Compares two State and annotates the differences on the first one
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="other"></param>
        public static void compareState(Generated.State obj, Generated.State other, VersionDiff diff)
        {
            if ( other == null )
            {
                diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "", "", obj.Name ) );
                return;
            }

            compareReqRelated (obj, other, diff);

            if ( obj.getStateMachine() == null )
            {
                if ( other.getStateMachine() != null )
                {
                    diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "StateMachine", "" ) );
                }
            }
            else
            {
                compareStateMachine ( obj.getStateMachine(), other.getStateMachine(), diff );
            }
            if ( obj.getWidth() != other.getWidth() )
            {
                diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "Width", other.getWidth().ToString(), obj.getWidth().ToString()) );
            }
            if ( obj.getHeight() != other.getHeight() )
            {
                diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "Height", other.getHeight().ToString(), obj.getHeight().ToString()) );
            }
            if ( obj.getX() != other.getX() )
            {
                diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "X", other.getX().ToString(), obj.getX().ToString()) );
            }
            if ( obj.getY() != other.getY() )
            {
                diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "Y", other.getY().ToString(), obj.getY().ToString()) );
            }
            if ( obj.getPinned() != other.getPinned() )
            {
                diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "Pinned", other.getPinned().ToString(), obj.getPinned().ToString()) );
            }
            if ( obj.getEnterAction() == null )
            {
                if ( other.getEnterAction() != null )
                {
                    diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "EnterAction", "" ) );
                }
            }
            else
            {
                compareRule ( obj.getEnterAction(), other.getEnterAction(), diff );
            }
            if ( obj.getLeaveAction() == null )
            {
                if ( other.getLeaveAction() != null )
                {
                    diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "LeaveAction", "" ) );
                }
            }
            else
            {
                compareRule ( obj.getLeaveAction(), other.getLeaveAction(), diff );
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Compares two Procedure and annotates the differences on the first one
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="other"></param>
        public static void compareProcedure(Generated.Procedure obj, Generated.Procedure other, VersionDiff diff)
        {
            if ( other == null )
            {
                diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "", "", obj.Name ) );
                return;
            }

            compareReqRelated (obj, other, diff);

            if ( obj.getStateMachine() == null )
            {
                if ( other.getStateMachine() != null )
                {
                    diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "StateMachine", "" ) );
                }
            }
            else
            {
                compareStateMachine ( obj.getStateMachine(), other.getStateMachine(), diff );
            }
            if ( obj.allRules() != null )
            {
                if ( other.allRules() != null )
                {
                    foreach ( Generated.Rule subElement in obj.allRules() )
                    {
                        bool compared = false;
                        foreach ( Generated.Rule otherElement in other.allRules() )
                        {
                            if ( subElement.Guid == otherElement.Guid )
                            {
                                compareRule ( subElement, otherElement, diff );
                                compared = true;
                            break;
                            }
                        }

                        if ( !compared )
                        {
                            diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "Rules", "", subElement.Name ) );
                        }
                    }

                    foreach ( Generated.Rule otherElement in other.allRules() )
                    {
                        bool found = false;
                        foreach ( Generated.Rule subElement in obj.allRules() )
                        {
                            if ( subElement.Guid == otherElement.Guid )
                            {
                                found = true;
                                break;
                            }
                        }

                        if ( !found )
                        {
                            diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "Rules", otherElement.Name) );
                        }
                    }
                }
                else
                {
                    foreach ( Generated.Rule subElement in obj.allRules() )
                    {
                        diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "Rules", "", subElement.Name ) );
                    }
                }
            }
            else
            {
                if ( other.allRules() != null )
                {
                    foreach ( Generated.Rule otherElement in other.allRules() )
                    {
                        diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "Rules", otherElement.Name) );
                    }
                }
            }
            if ( obj.allParameters() != null )
            {
                if ( other.allParameters() != null )
                {
                    foreach ( Generated.Parameter subElement in obj.allParameters() )
                    {
                        bool compared = false;
                        foreach ( Generated.Parameter otherElement in other.allParameters() )
                        {
                            if ( subElement.Guid == otherElement.Guid )
                            {
                                compareParameter ( subElement, otherElement, diff );
                                compared = true;
                            break;
                            }
                        }

                        if ( !compared )
                        {
                            diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "Parameters", "", subElement.Name ) );
                        }
                    }

                    foreach ( Generated.Parameter otherElement in other.allParameters() )
                    {
                        bool found = false;
                        foreach ( Generated.Parameter subElement in obj.allParameters() )
                        {
                            if ( subElement.Guid == otherElement.Guid )
                            {
                                found = true;
                                break;
                            }
                        }

                        if ( !found )
                        {
                            diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "Parameters", otherElement.Name) );
                        }
                    }
                }
                else
                {
                    foreach ( Generated.Parameter subElement in obj.allParameters() )
                    {
                        diff.appendChanges ( new Diff(subElement, HistoricalData.Generated.acceptor.ChangeOperationEnum.aAdd, "Parameters", "", subElement.Name ) );
                    }
                }
            }
            else
            {
                if ( other.allParameters() != null )
                {
                    foreach ( Generated.Parameter otherElement in other.allParameters() )
                    {
                        diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aRemove , "Parameters", otherElement.Name) );
                    }
                }
            }
            if ( obj.getWidth() != other.getWidth() )
            {
                diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "Width", other.getWidth().ToString(), obj.getWidth().ToString()) );
            }
            if ( obj.getHeight() != other.getHeight() )
            {
                diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "Height", other.getHeight().ToString(), obj.getHeight().ToString()) );
            }
            if ( obj.getX() != other.getX() )
            {
                diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "X", other.getX().ToString(), obj.getX().ToString()) );
            }
            if ( obj.getY() != other.getY() )
            {
                diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "Y", other.getY().ToString(), obj.getY().ToString()) );
            }
            if ( obj.getHidden() != other.getHidden() )
            {
                diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "Hidden", other.getHidden().ToString(), obj.getHidden().ToString()) );
            }
            if ( obj.getPinned() != other.getPinned() )
            {
                diff.appendChanges ( new Diff(obj, HistoricalData.Generated.acceptor.ChangeOperationEnum.aChange, "Pinned", other.getPinned().ToString(), obj.getPinned().ToString()) );
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Searches a specific string in State 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 searchState(Generated.State obj, string searchString, List<ModelElement> occurences)
        {
            searchReqRelated (obj, searchString, occurences);

            if ( obj.getStateMachine() != null )
            {
                searchStateMachine ( obj.getStateMachine(), searchString, occurences );
            }
            if ( obj.getEnterAction() != null )
            {
                searchRule ( obj.getEnterAction(), searchString, occurences );
            }
            if ( obj.getLeaveAction() != null )
            {
                searchRule ( obj.getLeaveAction(), searchString, occurences );
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Searches a specific string in Procedure 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 searchProcedure(Generated.Procedure obj, string searchString, List<ModelElement> occurences)
        {
            searchReqRelated (obj, searchString, occurences);

            if ( obj.getStateMachine() != null )
            {
                searchStateMachine ( obj.getStateMachine(), searchString, occurences );
            }
            if ( obj.allRules() != null )
            {
                foreach ( Generated.Rule subElement in obj.allRules() )
                {
                    searchRule ( subElement, searchString, occurences );
                }
            }
            if ( obj.allParameters() != null )
            {
                foreach ( Generated.Parameter subElement in obj.allParameters() )
                {
                    searchParameter ( subElement, searchString, occurences );
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Ensures that two State have matching GUID, and recursively.
        /// obj is the leader for Guid. If other doesn't match obj guid, 
        ///   1. other does not have a guid, in that case, other should have the same guid as obj
        ///   2. other already has a guid. In that case, there is a mismatch between objects, and the process stops here
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="other"></param>
        public static void ensureGuidState(Generated.State obj, Generated.State other)
        {
            if ( obj == null )
            {
                if ( other != null )
                {
                    // Side effect, setup a GUID if needed for the other part (other)
                    string guid = other.Guid;
                }
                return;
            }

            if ( other == null )
            {
                if ( obj != null )
                {
                    // Side effect, setup a GUID if needed for the other part (obj)
                    string guid = obj.Guid;
                }
                return;
            }

            if ( obj.Guid != other.getGuid() )
            {
                if ( string.IsNullOrEmpty(other.getGuid()) || GuidByName && (obj.Name == other.Name) )
                {
                    // These are matching elements, copy the guid from  obj
                    other.setGuid ( obj.Guid );
                }
                else
                {
                    // Elements do not match. Stop the recursive process
                    return;
                }
            }

            ensureGuidReqRelated (obj, other);

            ensureGuidStateMachine ( obj.getStateMachine(), other.getStateMachine() );
            ensureGuidRule ( obj.getEnterAction(), other.getEnterAction() );
            ensureGuidRule ( obj.getLeaveAction(), other.getLeaveAction() );
        }