/// <summary>
        /// Check constraint C26
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bev"></param>
        private void checkC26(IValidationContext context, EA.Package bev)
        {
            //Get all business data views
            IList <EA.Package> businessDataViews = Utility.getAllSubPackagesWithGivenStereotypeRecursively(bev,
                                                                                                           new List
                                                                                                           <
                                                                                                               EA.Package
                                                                                                           >(),
                                                                                                           UMM.bDataV.
                                                                                                           ToString());

            //Get all subpackage of the the BusinessEntityView
            IList <EA.Package> allSubpackagesofBEV = Utility.getAllSubPackagesRecursively(bev, new List <EA.Package>());

            //Both counts must be the same, otherwise wrong packages have been found
            if (businessDataViews.Count != allSubpackagesofBEV.Count)
            {
                String wrongPackages = "";
                foreach (EA.Package wrongpackage in allSubpackagesofBEV)
                {
                    if (Utility.getStereoTypeFromPackage(wrongpackage) != UMM.bDataV.ToString())
                    {
                        wrongPackages += " : " + wrongpackage.Name;
                    }
                }

                context.AddValidationMessage(new ValidationMessage("Violation of constraint C26.",
                                                                   "A BusinessEntityView MAY contain zero to many BusinessDataView that describe its conceptual design. \n\nThe following invalid packages have been found: " +
                                                                   wrongPackages, "BRV", ValidationMessage.errorLevelTypes.ERROR,
                                                                   bev.PackageID));
            }
        }
        /// <summary>
        ///
        /// Check constraint C100
        /// A BusinessInformationView MUST contain one to many
        /// InformationEnvelopes or subtypes thereof defined in any other
        /// extension/specialization modile. Furthermore, it MAY contains
        /// any other document modeling artifacts.
        ///
        /// </summary>
        private static void checkC100(IValidationContext context, EA.Package biv)
        {
            var informationEnvelopes = Utility.getAllClasses(biv, new List <EA.Element>());

            var informationEnvelopeFound = false;

            foreach (var e in informationEnvelopes)
            {
                //Is the classifier of type InformationEnvelope?
                if (e.Stereotype == UMM.InfEnvelope.ToString())
                {
                    informationEnvelopeFound = true;
                }
                //Is the classifier a subtype of an InformationEnvelope?
                else
                {
                    foreach (EA.Element el in e.BaseClasses)
                    {
                        if (el.Stereotype == UMM.InfEnvelope.ToString())
                        {
                            informationEnvelopeFound = true;
                            break;
                        }
                    }
                }
            }

            if (!informationEnvelopeFound)
            {
                context.AddValidationMessage(new ValidationMessage("Violation of constraint C100.",
                                                                   "A BusinessInformationView MUST contain one to many InformationEnvelopes (InfEnvelope) or subtypes thereof defined in any other extension/specialization modile. Furthermore, it MAY contains any other document modeling artifacts. \n\nNo InformationEnvelopes or subtypes thereof could be found.",
                                                                   "BIV", ValidationMessage.errorLevelTypes.ERROR, biv.PackageID));
            }
        }
        /// <summary>
        /// Check constraint C27
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bev"></param>
        private void checkC27(IValidationContext context, EA.Package bev)
        {
            //Get all business data views
            IList <EA.Package> businessDataViews = Utility.getAllSubPackagesWithGivenStereotypeRecursively(bev,
                                                                                                           new List
                                                                                                           <
                                                                                                               EA.Package
                                                                                                           >(),
                                                                                                           UMM.bDataV.
                                                                                                           ToString());


            //The parent package of every business data view must be a business entity view
            foreach (EA.Package businessDataView in businessDataViews)
            {
                EA.Package parent = context.Repository.GetPackageByID(businessDataView.ParentID);
                if (Utility.getStereoTypeFromPackage(parent) != UMM.bEntityV.ToString())
                {
                    context.AddValidationMessage(new ValidationMessage("Violation of constraint C27.",
                                                                       "The parent of a BusinessDataView MUST be a BusinessEntityView. \n\nBusinessDataView " +
                                                                       businessDataView.Name +
                                                                       " does not have a BusinessEntityView as parent.", "BRV",
                                                                       ValidationMessage.errorLevelTypes.ERROR, bev.PackageID));
                }
            }
        }
        /// <summary>
        /// Check constraint C28
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bev"></param>
        private void checkC28(IValidationContext context, EA.Package bev)
        {
            //Get all business data views
            IList <EA.Package> businessDataViews = Utility.getAllSubPackagesWithGivenStereotypeRecursively(bev,
                                                                                                           new List
                                                                                                           <
                                                                                                               EA.Package
                                                                                                           >(),
                                                                                                           UMM.bDataV.
                                                                                                           ToString());


            //A BusinessDataView should use a UML Class Diagram
            foreach (EA.Package businessDataView in businessDataViews)
            {
                foreach (EA.Diagram diagram in businessDataView.Diagrams)
                {
                    if (diagram.Type != "Logical")
                    {
                        context.AddValidationMessage(new ValidationMessage("Warning for constraint C28.",
                                                                           "A BusinessDataView SHOULD use a UML Class Diagram to describe the conceptual design of a BusinessEntity. \n\nThe business data view " +
                                                                           businessDataView.Name +
                                                                           " uses a diagram type which is not recommended (" +
                                                                           diagram.Type + ").", "BRV",
                                                                           ValidationMessage.errorLevelTypes.WARN, bev.PackageID));
                    }
                }
            }
        }
Example #5
0
        /// <summary>
        /// A validation scope can either be UMM, UPCC or it is unknown prior to the start
        /// of the validation (e.g. if the user has clicked somewhere in the treeview in order to invoke
        /// a validation
        /// </summary>

        internal override void validate(IValidationContext context, string scope)
        {
            //Validate the entire UMM model
            if (scope == "ROOT_UMM")
            {
                new bCollModelValidator().validate(context, scope);
            }
            //Validate the entire UPCC model
            else if (scope == "ROOT_UPCC")
            {
                new UPCCValidator().validate(context, scope);
            }
            else
            {
                //Try to determine whether that is a UMM or UPCC bottom up validation
                EA.Package p          = context.Repository.GetPackageByID(Int32.Parse(scope));
                String     stereotype = Utility.getStereoTypeFromPackage(p);
                if (Utility.isValidUMMStereotype(stereotype))
                {
                    new bCollModelValidator().validate(context, scope);
                }
                else if (Utility.isValidUPCCStereotype(stereotype))
                {
                    new UPCCValidator().validate(context, scope);
                }
                else
                {
                    context.AddValidationMessage(new ValidationMessage("Unknown or missing stereotype detected.", "The package " + p.Name + " has an unknown or missing stereotype. Validation cannot be started.", "-", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                }
            }
        }
        /// <summary>
        /// Check constraint C22
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bpv"></param>
        private void checkC22(IValidationContext context, EA.Package bpv)
        {
            //Get all Stakeholders from the BusinessPartnerView
            IList <EA.Element> stakeholders = Utility.getAllElements(bpv, new List <EA.Element>(), UMM.Stakeholder.ToString());

            context.AddValidationMessage(new ValidationMessage("Info for constraint C22.", "A BusinessPartnerView MAY contain zero to many Stakeholders.\n\nThe BusinessPartnerView " + bpv.Name + " contains " + stakeholders.Count, "BRV", ValidationMessage.errorLevelTypes.INFO, bpv.PackageID));
        }
        /// <summary>
        /// Check constraint C20
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bdv"></param>
        private void checkC20(IValidationContext context, EA.Package bdv)
        {
            //Get a list with all the BusinessProcesses from the BusinessDomainView
            IList <EA.Element> bps = Utility.getAllElements(bdv, new List <EA.Element>(), UMM.bProcess.ToString());


            //Check which business process contain Activity Partitions
            foreach (EA.Element bp in bps)
            {
                foreach (EA.Element subelement in bp.Elements)
                {
                    if (subelement.Type == "ActivityPartition")
                    {
                        //An ActivityParition MUST not contain SharedBusinessEntityStates
                        foreach (EA.Element partitionElement in subelement.Elements)
                        {
                            if (partitionElement.Stereotype == UMM.bESharedState.ToString())
                            {
                                context.AddValidationMessage(new ValidationMessage("Violation of constraint C20.",
                                                                                   "A SharedBusinessEntityStates MUST NOT be located in an ActivityPartition. (They must be contained within the BusinessProcess even if this BusinessProcess contains ActivityPartitions.) \n\nSharedBusinessEntityState " +
                                                                                   partitionElement.Name +
                                                                                   " is locatdd in an ActivityPartition.", "BRV",
                                                                                   ValidationMessage.errorLevelTypes.ERROR,
                                                                                   bp.PackageID));
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Validate constraint C16
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bdv"></param>
        private void checkC16(IValidationContext context, EA.Package bdv)
        {
            //Get a list with all the BusinessProcessUseCases in this BusinessDomainView
            IList <EA.Element> bpucs = Utility.getAllElements(bdv, new List <EA.Element>(), UMM.bProcessUC.ToString());


            //Check which businessprocessusecase is refined by a UML Sequence Diagram
            foreach (EA.Element bpuc in bpucs)
            {
                int countSequenceDiagrams = 0;
                foreach (EA.Diagram diagram in bpuc.Diagrams)
                {
                    if (diagram.Type == "Sequence")
                    {
                        countSequenceDiagrams++;
                    }
                }

                if (countSequenceDiagrams > 0)
                {
                    context.AddValidationMessage(new ValidationMessage("Info to constraint C16.",
                                                                       "A BusinessProcessUseCase MAY be refined by zero to many UML Sequence Diagrams. \n\nThe BusinessProcessUseCase " +
                                                                       bpuc.Name + " is refined by " + countSequenceDiagrams +
                                                                       " UML Sequence Diagrams.", "BRV",
                                                                       ValidationMessage.errorLevelTypes.INFO, bpuc.PackageID));
                }
            }
        }
        /// <summary>
        /// Check constraint C25
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bev"></param>
        private void checkC25(IValidationContext context, EA.Package bev)
        {
            //Iterate recursively through the element of the business entity view and search for business entities,
            //since we have to consider the possibility, that users structure their entities in subfolders
            IList <EA.Element> elements = Utility.getAllElements(bev, new List <EA.Element>(), UMM.bEntity.ToString());

            //Generate an info message for every business entity that is described by a UML State Diagram
            foreach (EA.Element businessEntity in elements)
            {
                //Is this BusinessEntity refined by a diagram?
                int countDiagram = businessEntity.Diagrams.Count;

                //This constraint only applies if there are UML state diagrams describing the lifecycle of a
                //business entity
                if (countDiagram > 0)
                {
                    int countEntityStates = 0;
                    //There must be at least one business entity state
                    foreach (EA.Element subelement in businessEntity.Elements)
                    {
                        if (subelement.Stereotype == UMM.bEState.ToString())
                        {
                            countEntityStates++;
                        }
                    }


                    //Raise an error if no entity state is found
                    if (countEntityStates < 1)
                    {
                        context.AddValidationMessage(new ValidationMessage("Violation of constraint C25.",
                                                                           "A UML State Diagram describing the lifecycle of a BusinessEntity MUST contain one to many BusinessEntityStates. \n\nThe state diagram underneath the business entity " +
                                                                           businessEntity.Name +
                                                                           " does not contain BusinessEntityStates.", "BRV",
                                                                           ValidationMessage.errorLevelTypes.ERROR, bev.PackageID));
                    }
                    else
                    {
                        context.AddValidationMessage(new ValidationMessage("Info for constraint C25.",
                                                                           "A UML State Diagram describing the lifecycle of a BusinessEntity MUST contain one to many BusinessEntityStates. \n\nThe state diagram underneath the business entity " +
                                                                           businessEntity.Name + " has " + countEntityStates +
                                                                           " BusinessEntityStates.", "BRV",
                                                                           ValidationMessage.errorLevelTypes.INFO, bev.PackageID));
                    }
                }
            }
        }
 public void AddValidationMessage(ValidationMessage message)
 {
     if (message.ErrorLevel == ValidationMessage.errorLevelTypes.ERROR)
     {
         HasError = true;
     }
     parentContext.AddValidationMessage(message);
 }
 /// <summary>
 /// A BDT which is the source of an isEquivalentTo dependency must not be the source of a basedOn dependency.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="p"></param>
 /// <param name="bdts"></param>
 private void checkC564g(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> bdts)
 {
     foreach (KeyValuePair <Int32, EA.Element> e in bdts)
     {
         if (Utility.isEquivalentToAnotherElement(e.Value) && Utility.isBasedOnAnotherElement(e.Value))
         {
             context.AddValidationMessage(new ValidationMessage("BDT is source of isEquivalentTo and basedOn dependency.", " A BDT which is the source of an isEquivalentTo dependency must not be the source of a basedOn dependency. Errorneous BCC " + e.Value.Name + " in BDTLibrary " + p.Name + ".", "BDTLibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
         }
     }
 }
Example #12
0
        /// <summary>
        /// A BCC name and an ASCC name shall not be identical when used in an ACC.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="p"></param>
        /// <param name="accs"></param>
        private void checkC524l(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> accs)
        {
            Dictionary <string, string> names = new Dictionary <string, string>();

            foreach (KeyValuePair <Int32, EA.Element> e in accs)
            {
                //Get all ASCCs
                foreach (EA.Connector con in e.Value.Connectors)
                {
                    //Get all emanating ASCCs of this ACC
                    if (con.Stereotype == UPCC.ASCC.ToString() && con.ClientID == e.Value.ElementID)
                    {
                        //Get the role name of the ASCC
                        String rolename = con.SupplierEnd.Role;


                        if (names.ContainsValue(rolename))
                        {
                            if (rolename == null || rolename == "")
                            {
                                rolename = "No name specified.";
                            }

                            context.AddValidationMessage(new ValidationMessage("Duplicate names of BCCs/ASCCs found.", "A BCC name and an ASCC name shall not be identical when used in an ACC. ACC " + e.Value.Name + " has a BBIE and an ASCC with the same name: " + rolename, "CCLibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                        }
                        names.Add(rolename, rolename);
                    }
                }

                //Get all BCCs
                foreach (EA.Attribute bcc in e.Value.Attributes)
                {
                    if (names.ContainsValue(bcc.Name))
                    {
                        context.AddValidationMessage(new ValidationMessage("Duplicate names of BCCs/ASCCs found.", "A BCC name and an ASCC name shall not be identical when used in an ACC. ACC " + e.Value.Name + " has a BBIE and an ASCC with the same name: " + bcc.Name, "CCLibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                    }
                    names.Add(bcc.Name, bcc.Name);
                }
                names = new Dictionary <string, string>();
            }
        }
        /// <summary>
        /// Check constraint C23
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bev"></param>
        private void checkC23(IValidationContext context, EA.Package bev)
        {
            //Iterate recursively through the element of the business entity view and search for business entities,
            //since we have to consider the possibility, that users structure their entities in subfolders
            IList <EA.Element> elements = Utility.getAllElements(bev, new List <EA.Element>(), UMM.bEntity.ToString());

            //A BusinessEntityView must contain one to many business entities
            if (elements.Count < 1)
            {
                context.AddValidationMessage(new ValidationMessage("Violation of constraint C23.",
                                                                   "A BusinessEntityView MUST contain one to many BusinessEntities. \n\nThe BusinessEntityView " +
                                                                   bev.Name + " does not contain any BusinessEntities.", "BRV",
                                                                   ValidationMessage.errorLevelTypes.ERROR, bev.PackageID));
            }
            else
            {
                context.AddValidationMessage(new ValidationMessage("Info to constraint C23.",
                                                                   "A BusinessEntityView MUST contain one to many BusinessEntities. \n\nThe BusinessEntitiyView " +
                                                                   bev.Name + " contains " + elements.Count + " BusinessEntities.",
                                                                   "BRV", ValidationMessage.errorLevelTypes.INFO, bev.PackageID));
            }
        }
        /// <summary>
        /// Check constraint C14
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bdv"></param>
        private void checkC14(IValidationContext context, EA.Package bdv)
        {
            //Get a list with all the BusinessProcessUseCases in this BusinessDomainView
            IList <EA.Element> bpucs = Utility.getAllElements(bdv, new List <EA.Element>(), UMM.bProcessUC.ToString());


            foreach (EA.Element bpuc in bpucs)
            {
                int parentPackageID = context.Repository.GetPackageByID(bpuc.PackageID).PackageID;

                bool found = false;
                //Is the business process use case refined by a business process?
                foreach (EA.Element subelement in bpuc.Elements)
                {
                    if (subelement.Stereotype == UMM.bProcess.ToString())
                    {
                        found = true;
                        break;
                    }
                }

                //No bProcess found - show a warn message
                if (!found)
                {
                    context.AddValidationMessage(new ValidationMessage("Warning for constraint C 14.",
                                                                       "A BusinessProcessUseCase SHOULD be refined by zero to many BusinessProcesses. \n\nThe BusinessProcessUseCase " +
                                                                       bpuc.Name + " is not refined by a BusinessProcess.", "BRV",
                                                                       ValidationMessage.errorLevelTypes.WARN, parentPackageID));
                }
                else
                {
                    context.AddValidationMessage(new ValidationMessage("Info to constraint C 14.",
                                                                       "A BusinessProcessUseCase SHOULD be refined by zero to many BusinessProcesses. \n\nThe BusinessProcessUseCase " +
                                                                       bpuc.Name + " is refined by a BusinessProcess.", "BRV",
                                                                       ValidationMessage.errorLevelTypes.INFO, parentPackageID));
                }
            }
        }
Example #15
0
        /// <summary>
        /// Each CDT shall have a unique name within the CDT library of which it is part of.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="d"></param>
        /// <param name="cdts"></param>
        private void checkC534a(IValidationContext context, EA.Package d, Dictionary <Int32, EA.Element> cdts)
        {
            Dictionary <Int32, string> names = new Dictionary <int, string>();

            foreach (KeyValuePair <Int32, EA.Element> e in cdts)
            {
                if (names.ContainsValue(e.Value.Name))
                {
                    context.AddValidationMessage(new ValidationMessage("Two CDTs with the same name found.", "Each CDT shall have a unique name within the CDT library of which it is part of. Two CDTs with the name " + e.Value.Name + " found.", "CDTLibrary", ValidationMessage.errorLevelTypes.ERROR, d.PackageID));
                }

                names.Add(e.Value.ElementID, e.Value.Name);
            }
        }
Example #16
0
 /// <summary>
 ///  A BCC shall be typed with a class of stereotype <<CDT>>.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="p"></param>
 /// <param name="accs"></param>
 private void checkC524g(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> accs)
 {
     foreach (KeyValuePair <Int32, EA.Element> e in accs)
     {
         foreach (EA.Attribute bcc in e.Value.AttributesEx)
         {
             //Is there a classifier for the attribute?
             int i = bcc.ClassifierID;
             if (i == 0)
             {
                 context.AddValidationMessage(new ValidationMessage("BCC with invalid type detected.", "A BCC shall be typed with a class of stereotype <<CDT>>. BCC " + bcc.Name + " of ACC " + e.Value.Name + " has an invalid type.", "CCLibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
             }
             else
             {
                 EA.Element classifier = context.Repository.GetElementByID(bcc.ClassifierID);
                 if (classifier.Stereotype != UPCC.CDT.ToString())
                 {
                     context.AddValidationMessage(new ValidationMessage("BCC with invalid type detected.", "A BCC shall be typed with a class of stereotype <<CDT>>. BCC " + bcc.Name + " of ACC " + e.Value.Name + " has an invalid type.", "CCLibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                 }
             }
         }
     }
 }
Example #17
0
        /// <summary>
        /// The name of the content component shall be “Content”.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="p"></param>
        /// <param name="cdts"></param>
        private void checkC534h(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> cdts)
        {
            foreach (KeyValuePair <Int32, EA.Element> e in cdts)
            {
                //The source element of the isEquivalentTo dependency
                EA.Element element = e.Value;

                EA.Attribute cdt = Utility.fetchFirstAttributeFromElement(element, UPCC.CON.ToString());

                if (cdt == null)
                {
                    context.AddValidationMessage(new ValidationMessage("Missing <<CON>> attribute.", "A CDT must contain exactly one attribute stereotyped as <<CON>>.  \nCDT " + element.Name + " does not have an attribute stereotyped as <<CON>>.", "CCLibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                }
                else
                {
                    String name = cdt.Name;
                    if (name != "Content")
                    {
                        context.AddValidationMessage(new ValidationMessage("The name of the content component shall be “Content”.", "A CDT must contain exactly one attribute stereotyped as <<CON>>. The name of the <<CON>> attribute must be 'Content'. \nCDT " + element.Name + " does not have an attribute stereotyped as <<CON>> witht the name 'Content'. Wrong name: " + name, "CDTLibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                    }
                }
            }
        }
Example #18
0
 /// <summary>
 /// A BIELibrary shall only contain ABIEs, BBIEs, and ASBIEs.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="brv"></param>
 private void checkC514c(IValidationContext context, EA.Package d)
 {
     foreach (EA.Element e in d.Elements)
     {
         if (e.Type != EA_Element.Note.ToString())
         {
             String stereotype = e.Stereotype;
             if (stereotype == null || !stereotype.Equals(UPCC.ABIE.ToString()))
             {
                 context.AddValidationMessage(new ValidationMessage("Invalid element found in BIELibrary.", "The element " + e.Name + " has an invalid stereotype (" + stereotype + "). A BIELibrary shall only contain ABIEs, BBIEs, and ASBIEs.", "BIELibrary", ValidationMessage.errorLevelTypes.ERROR, d.PackageID));
             }
         }
     }
 }
Example #19
0
        /// <summary>
        /// For a given BIE library the qualified ABIE name (= qualifiers + name) shall be unique
        /// </summary>
        /// <param name="context"></param>
        /// <param name="p"></param>
        /// <param name="bies"></param>
        private void checkC574d(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> bies)
        {
            Dictionary <Int32, string> names = new Dictionary <int, string>();

            foreach (KeyValuePair <Int32, EA.Element> e in bies)
            {
                if (names.ContainsValue(e.Value.Name))
                {
                    context.AddValidationMessage(new ValidationMessage("Two ABIEs with the same name found.", "Each ABIE shall have a unique name within the BIELibrary of which it is part of. Two ABIEs with the name " + e.Value.Name + " found in BIELibrary " + p.Name + ".", "BIELibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                }

                names.Add(e.Value.ElementID, e.Value.Name);
            }
        }
        /// <summary>
        /// c)	An enumeration type shall either have a tagged value agencyName or agencyIdentifier.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="package"></param>
        /// <param name="enums"></param>
        private void checkC554c(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> enums)
        {
            foreach (KeyValuePair <Int32, EA.Element> e in enums)
            {
                //Check for agencyName or agencyIdentifier tagged value
                EA.TaggedValue agencyName       = Utility.getTaggedValue(e.Value, UPCC_TV.agencyName.ToString());
                EA.TaggedValue agencyIdentifier = Utility.getTaggedValue(e.Value, UPCC_TV.agencyIdentifier.ToString());

                if ((agencyName == null || agencyName.Value == "") && (agencyIdentifier == null || agencyIdentifier.Value == ""))
                {
                    context.AddValidationMessage(new ValidationMessage("Missing agencyIdentifier/agencyName found in ENUM.", "An enumeration type shall either have a tagged value agencyName or agencyIdentifier. ENUM " + e.Value.Name + " found in ENUMLibrary " + p.Name + " does neither have an agencyName tagged value nor an agencyIdentifier tagged value.", "ENUMLibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                }
            }
        }
        /// <summary>
        /// a)	The name of an enumeration type shall be unique for a given ENUM library.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="package"></param>
        /// <param name="enums"></param>
        private void checkC554a(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> enums)
        {
            Dictionary <Int32, string> names = new Dictionary <int, string>();

            foreach (KeyValuePair <Int32, EA.Element> e in enums)
            {
                if (names.ContainsValue(e.Value.Name))
                {
                    context.AddValidationMessage(new ValidationMessage("Two ENUMs with the same name found.", "The name of an enumeration type shall be unique for a given ENUM library. Two ENUMs with the name " + e.Value.Name + " found in ENUMLibrary " + p.Name + ".", "ENUMLibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                }

                names.Add(e.Value.ElementID, e.Value.Name);
            }
        }
        /// <summary>
        /// A BDT shall not contain any attributes other than those of stereotype <<CON>> or <<SUP>>.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="p"></param>
        /// <param name="bdts"></param>
        private void checkC564b(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> bdts)
        {
            foreach (KeyValuePair <Int32, EA.Element> e in bdts)
            {
                EA.Element element = e.Value;

                foreach (EA.Attribute attr in element.Attributes)
                {
                    if (!(attr.Stereotype == UPCC.CON.ToString() || attr.Stereotype == UPCC.SUP.ToString()))
                    {
                        context.AddValidationMessage(new ValidationMessage("Invalid attribute stereotype found in a BDT.", "A BDT must not contain any attributes other than those of stereotype <<CON>> or <<SUP>>. Attribute " + attr.Name + " of BDT " + element.Name + " in BDTLibrary " + p.Name + " has an invalid stereotype.", "BDTLibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                    }
                }
            }
        }
        /// <summary>
        /// Check constraint C95
        /// A BusinessRealization MUST NOT be the
        /// source or target of an include or extends association.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="brv"></param>
        /// <returns></returns>
        private void checkC95(IValidationContext context, EA.Package brv)
        {
            //Get the BusinessRealization
            EA.Element br = Utility.getElementFromPackage(brv, UMM.bRealization.ToString());

            if (br != null)
            {
                foreach (EA.Connector con in br.Connectors)
                {
                    if (con.Stereotype == "extend" || con.Stereotype == "include")
                    {
                        context.AddValidationMessage(new ValidationMessage("Violation of constraint C95.", "A BusinessRealization MUST NOT be the source or target of an include or extends association. \n\nBusinessRealization " + br.Name + " has invalid connectors.", "BCV", ValidationMessage.errorLevelTypes.ERROR, brv.PackageID));
                    }
                }
            }
        }
        /// <summary>
        /// Check constraint C32
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bcv"></param>
        private void checkC32(IValidationContext context, EA.Package bcv)
        {
            int count_brv = 0;

            //Iterate of the different packages of the business choreography view
            foreach (EA.Package p in bcv.Packages)
            {
                String stereotype = Utility.getStereoTypeFromPackage(p);
                if (stereotype == UMM.bRealizationV.ToString())
                {
                    count_brv++;
                }
            }

            //There may be zero to many BRVs
            context.AddValidationMessage(new ValidationMessage("Info for constraint C32.", "A BusinessChoreographyView MAY contain zero to many BusinessRealizationViews\n\n" + count_brv + " BusinessRealizationVies have been found.", "BCV", ValidationMessage.errorLevelTypes.INFO, bcv.PackageID));
        }
        /// <summary>
        /// Check constraint C7
        /// </summary>
        private void checkC7(IValidationContext context, EA.Package package)
        {
            int count = 0;

            foreach (EA.Package p in package.Packages)
            {
                if (Utility.getStereoTypeFromPackage(p) == UMM.bEntityV.ToString())
                {
                    count++;
                }
            }

            context.AddValidationMessage(new ValidationMessage("Information to constraint C7.",
                                                               "A BusinessRequirementsView MAY contain zero to many  BusinessEntityViews. \n\nYour model contains " +
                                                               count + " BusinessEntityViews.", "BRV",
                                                               ValidationMessage.errorLevelTypes.INFO, package.PackageID));
        }
Example #26
0
        /// <summary>
        /// Validate the Stakeholder
        /// </summary>
        /// <param name="context"></param>
        /// <param name="element"></param>
        /// <param name="package"></param>
        private void validateBusinessPartnerAndStakeholder(IValidationContext context, EA.Element element, EA.Package package)
        {
            bool foundInterest = false;

            foreach (EA.TaggedValue tv in element.TaggedValues)
            {
                if (tv.Name == UMMTaggedValues.interest.ToString())
                {
                    foundInterest = true;
                }
            }

            if (!foundInterest)
            {
                context.AddValidationMessage(new ValidationMessage("Missing tagged value.", getElementError("interest", package, element), "BRV", ValidationMessage.errorLevelTypes.WARN, package.PackageID));
            }
        }
        /// <summary>
        /// b)	An enumeraton type shall contain one or more code values.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="package"></param>
        /// <param name="enums"></param>
        private void checkC554b(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> enums)
        {
            foreach (KeyValuePair <Int32, EA.Element> e in enums)
            {
                //Code values are in fact just attributes of a class
                //Check whether the given enum has at least one attribute
                int count = 0;
                foreach (EA.Attribute a in e.Value.Attributes)
                {
                    count++;
                }

                if (count < 1)
                {
                    context.AddValidationMessage(new ValidationMessage("Missing code value in an ENUM found.", "An enumeraton type shall contain one or more code values. ENUM " + e.Value.Name + " found in ENUMLibrary " + p.Name + " does not have any code values..", "ENUMLibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                }
            }
        }
 /// <summary>
 /// An unqualified BDT shall have the same name as the CDT the BDT is based on.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="p"></param>
 /// <param name="bdts"></param>
 private void checkC564k(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> bdts)
 {
     foreach (KeyValuePair <Int32, EA.Element> e in bdts)
     {
         //Determine whether the given BDT is qualified or not
         if (!Utility.isAQualifiedElement(e.Value.Name))
         {
             EA.Element supplier = Utility.getTargetOfisbasedOnDependency(e.Value, context.Repository);
             if (supplier != null)
             {
                 if (supplier.Name.Trim() != e.Value.Name.Trim())
                 {
                     context.AddValidationMessage(new ValidationMessage("Mismatch of names between BDT and underlying CDT.", "An unqualified BDT shall have the same name as the CDT the BDT is based on. BDT " + e.Value.Name + " and the CDT/BDT " + supplier.Name + " do not have the same name.", "BDTLibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                 }
             }
         }
     }
 }
Example #29
0
        /// <summary>
        /// All BBIEs of a given ABIE shall have unique names.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="p"></param>
        /// <param name="bdts"></param>
        private void checkC574k(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> bies)
        {
            Dictionary <Int32, string> names = new Dictionary <int, string>();

            foreach (KeyValuePair <Int32, EA.Element> e in bies)
            {
                foreach (EA.Attribute a in e.Value.Attributes)
                {
                    if (names.ContainsValue(a.Name))
                    {
                        context.AddValidationMessage(new ValidationMessage("Two BBIEs with the same name found.", "Each BBIE shall have a unique name within its ABIE it is contained in. BBIE name " + a.Name + " found in ABIE " + e.Value.Name + " in BIELibrary " + p.Name + " is not unique.", "BIELibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                    }

                    names.Add(a.AttributeID, a.Name);
                }

                names = new Dictionary <int, string>();
            }
        }
 /// <summary>
 /// The source of an isEquivalentTo dependeny must be a BDT.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="p"></param>
 /// <param name="bdts"></param>
 private void checkC564f(IValidationContext context, EA.Package p, Dictionary <Int32, EA.Element> bdts)
 {
     foreach (KeyValuePair <Int32, EA.Element> e in bdts)
     {
         //Search for basedOn dependencies leading for which the given BDT is a source
         foreach (EA.Connector con in e.Value.Connectors)
         {
             if (con.Stereotype == UPCC.isEquivalentTo.ToString() && con.Type == AssociationTypes.Dependency.ToString() && con.SupplierID == e.Value.ElementID)
             {
                 //Get the client (source) of this basedOn dependency
                 EA.Element client = context.Repository.GetElementByID(con.ClientID);
                 if (client.Stereotype != UPCC.BDT.ToString())
                 {
                     context.AddValidationMessage(new ValidationMessage("Invalid stereotype of a source of an isEquivalentTo dependency.", "The source of an isEquivalentTo dependeny must be a BDT. Element " + client.Name + " in BDTLibrary " + p.Name + " has an isEquivalentTo dependency to BDT " + e.Value.Name + " but does not have the stereotype BDT.", "BDTLibrary", ValidationMessage.errorLevelTypes.ERROR, p.PackageID));
                 }
             }
         }
     }
 }