Exemplo n.º 1
0
            /// <summary>
            /// AddRule: typeof(ObjectTypePlaysRole)
            /// </summary>
            private static void ObjectTypePlaysRoleAddedRule(ElementAddedEventArgs e)
            {
                ObjectTypePlaysRole link = e.ModelElement as ObjectTypePlaysRole;
                FactType            factType;

                if (null != (factType = link.PlayedRole.FactType))
                {
                    FrameworkDomainModel.DelayValidateElement(factType, DelayValidateUnaryBinarization);
                }
            }
Exemplo n.º 2
0
        /// <summary>
        /// DeleteRule: typeof(ObjectTypePlaysRole), FireTime=LocalCommit, Priority=ORMCoreDomainModel.BeforeDelayValidateRulePriority;
        /// Ensure that a role player deletion on a subtype results in a deletion
        /// of the subtype itself.
        /// </summary>
        private static void DeleteSubtypeWhenRolePlayerDeletedRule(ElementDeletedEventArgs e)
        {
            ObjectTypePlaysRole link = e.ModelElement as ObjectTypePlaysRole;
            Role role = link.PlayedRole;

            if (role != null && !role.IsDeleted)
            {
                SubtypeFact subtypeFact = role.FactType as SubtypeFact;
                if (subtypeFact != null && !subtypeFact.IsDeleted)
                {
                    subtypeFact.Delete();
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// AddRule: typeof(ObjectTypePlaysRole), FireTime=LocalCommit, Priority=ORMCoreDomainModel.BeforeDelayValidateRulePriority;
        /// Ensure consistent types (EntityType or ValueType) for role
        /// players in a subtyping relationship
        /// </summary>
        private static void EnsureConsistentRolePlayerTypesAddRule(ElementAddedEventArgs e)
        {
            ObjectTypePlaysRole link = e.ModelElement as ObjectTypePlaysRole;
            SubtypeMetaRole     subtypeRole;
            SubtypeFact         subtypeFact;

            if (null != (subtypeRole = link.PlayedRole as SubtypeMetaRole) &&
                null != (subtypeFact = subtypeRole.FactType as SubtypeFact))
            {
                ObjectType superType = subtypeFact.Supertype;
                if (null == superType ||
                    ((superType.DataType == null) != (link.RolePlayer.DataType == null)))
                {
                    ThrowMixedRolePlayerTypesException();
                }
            }
        }
Exemplo n.º 4
0
            /// <summary>
            /// RolePlayerChangeRule: typeof(ORMSolutions.ORMArchitect.Core.ObjectModel.ObjectTypePlaysRole)
            /// Revalidate the model when the <see cref="ObjectType">role player</see> of a <see cref="Role"/>
            /// is changed.
            /// </summary>
            private static void RolePlayerRolePlayerChangedRule(RolePlayerChangedEventArgs e)
            {
                // UNDONE: Incremental changes will not be as severe here. Note that adding
                // and deleting role players already triggers the correct actions in the
                // gateway rules. However, a change where none of the parties are excluded
                // simply needs to regenerate for now.
                ObjectTypePlaysRole link = (ObjectTypePlaysRole)e.ElementLink;

                if (e.DomainRole.Id == ObjectTypePlaysRole.PlayedRoleDomainRoleId)
                {
                    SignificantFactTypeChange(((Role)e.OldRolePlayer).BinarizedFactType);
                }
                else
                {
                    SignificantObjectTypeChange((ObjectType)e.OldRolePlayer);
                }
                SignificantObjectTypeChange(link.RolePlayer);
                SignificantFactTypeChange(link.PlayedRole.BinarizedFactType);
            }
Exemplo n.º 5
0
            /// <summary>
            /// DeleteRule: typeof(ObjectTypePlaysRole)
            /// </summary>
            private static void ObjectTypePlaysRoleDeletedRule(ElementDeletedEventArgs e)
            {
                // After this point, it is unknown whether the FactType was a unary, so we just delete it for now
                ObjectTypePlaysRole link       = e.ModelElement as ObjectTypePlaysRole;
                ObjectType          objectType = link.RolePlayer;
                Role     role;
                FactType factType;

                if (objectType.IsImplicitBooleanValue)
                {
                    if (!(role = link.PlayedRole).IsDeleted &&
                        null != (factType = role.FactType) &&
                        !factType.IsDeleted)
                    {
                        factType.Delete();
                    }
                    if (!objectType.IsDeleted)
                    {
                        objectType.Delete();
                    }
                }
            }
Exemplo n.º 6
0
        /// <summary>
        /// Implements <see cref="IModelErrorActivation.ActivateModelError"/> for
        /// the <see cref="ValueComparisonConstraintOperatorNotSpecifiedError"/>
        /// </summary>
        protected new bool ActivateModelError(ModelError error)
        {
            ValueComparisonConstraintOperatorNotSpecifiedError operatorError;
            ValueComparisonRolesNotComparableError             comparabilityError;
            ValueComparisonConstraint constraint;
            Store store;
            bool  retVal = true;

            if (null != (operatorError = error as ValueComparisonConstraintOperatorNotSpecifiedError))
            {
                store      = Store;
                constraint = operatorError.ValueComparisonConstraint;
                EditorUtility.ActivatePropertyEditor(
                    (store as IORMToolServices).ServiceProvider,
                    DomainTypeDescriptor.CreatePropertyDescriptor(constraint, ValueComparisonConstraint.OperatorDomainPropertyId),
                    true);
            }
            else if (null != (comparabilityError = error as ValueComparisonRolesNotComparableError))
            {
                constraint = comparabilityError.ValueComparisonConstraint;
                LinkedElementCollection <Role> constraintRoles = constraint.RoleCollection;
                Role role1;
                Role role2;
                ObjectTypePlaysRole rolePlayerLink1;
                ObjectTypePlaysRole rolePlayerLink2;
                ObjectType          rolePlayer1 = null;
                ObjectType          rolePlayer2 = null;
                Role[] valueRoles1 = null;
                Role[] valueRoles2 = null;
                // The default behavior is to activate the role sequence
                // for editing. However, if the problem is with a single
                // resolved value type, and the units are correct, then
                // we need to select the first directly detached object.
                if (constraintRoles.Count == 2 &&
                    null != (rolePlayerLink1 = ObjectTypePlaysRole.GetLinkToRolePlayer(role1 = constraintRoles[0])) &&
                    null != (rolePlayerLink2 = ObjectTypePlaysRole.GetLinkToRolePlayer(role2 = constraintRoles[1])) &&
                    (rolePlayerLink1.RolePlayer == rolePlayerLink2.RolePlayer ||
                     (null != (valueRoles1 = role1.GetValueRoles()) &&
                      null != (valueRoles2 = role2.GetValueRoles()) &&
                      DataType.IsComparableValueType(rolePlayer1 = valueRoles1[0].RolePlayer, rolePlayer2 = valueRoles2[0].RolePlayer, !constraint.IsDirectional))))
                {
                    bool verifiedReferenceMode = true;
                    if (valueRoles1 != null)
                    {
                        ORMModel      model          = null;
                        ReferenceMode referenceMode1 = (valueRoles1.Length > 1) ?
                                                       ReferenceMode.FindReferenceModeFromEntityNameAndValueName(rolePlayer1.Name, valueRoles1[1].RolePlayer.Name, model = constraint.ResolvedModel) :
                                                       null;
                        ReferenceMode referenceMode2 = (valueRoles2.Length > 1) ?
                                                       ReferenceMode.FindReferenceModeFromEntityNameAndValueName(rolePlayer2.Name, valueRoles2[1].RolePlayer.Name, model ?? constraint.ResolvedModel) :
                                                       null;
                        bool referenceMode1IsUnit = referenceMode1 != null && referenceMode1.Kind.ReferenceModeType == ReferenceModeType.UnitBased;
                        bool referenceMode2IsUnit = referenceMode2 != null && referenceMode2.Kind.ReferenceModeType == ReferenceModeType.UnitBased;
                        verifiedReferenceMode = referenceMode1IsUnit ? (referenceMode2IsUnit && referenceMode1 == referenceMode2) : !referenceMode2IsUnit;
                    }
                    if (verifiedReferenceMode)
                    {
                        // Find a connected role player
                        foreach (ExternalConstraintLink constraintLink in MultiShapeUtility.GetEffectiveAttachedLinkShapes <ExternalConstraintLink>(this))
                        {
                            FactTypeShape factTypeShape;
                            if (constraintLink.AssociatedConstraintRole.Role == role1 &&
                                null != (factTypeShape = constraintLink.FromShape as FactTypeShape))
                            {
                                foreach (RolePlayerLink rolePlayerLinkShape in MultiShapeUtility.GetEffectiveAttachedLinkShapes <RolePlayerLink>(factTypeShape))
                                {
                                    if (rolePlayerLinkShape.AssociatedRolePlayerLink == rolePlayerLink1)
                                    {
                                        Diagram.ActiveDiagramView.Selection.Set(new DiagramItem(rolePlayerLinkShape.ToShape));
                                        return(true);
                                    }
                                }
                            }
                        }
                    }
                }
                ActivateNewRoleSequenceConnectAction(null);
            }
            else
            {
                retVal = base.ActivateModelError(error);
            }
            return(retVal);
        }
Exemplo n.º 7
0
			private static void ProcessRolePlayerDeleted(ObjectTypePlaysRole link, ObjectType rolePlayer, Role role)
			{
				if (role == null)
				{
					role = link.PlayedRole;
				}
				if (rolePlayer == null)
				{
					rolePlayer = link.RolePlayer;
				}
				FilterModifiedFactType(role.FactType, false);
				RoleProxy proxy = role.Proxy;
				if (proxy != null)
				{
					FilterModifiedFactType(proxy.FactType, false);
				}
				FilterModifiedObjectType(rolePlayer);
			}
Exemplo n.º 8
0
			private static void ProcessRolePlayerAdded(ObjectTypePlaysRole link)
			{
				Role role = link.PlayedRole;
				FilterModifiedFactType(role.FactType, false);
				RoleProxy proxy = role.Proxy;
				if (proxy != null)
				{
					FilterModifiedFactType(proxy.FactType, false);
				}
				FilterModifiedObjectType(link.RolePlayer);
			}