///<summary>
        /// The method creates an ABIESpec based on the complex type definition of an ABIE
        /// as it occurs in an XML schema. Therefore, the method requires on input parameter
        /// containing the complex type definition. A corresponding ABIESpec of the complex
        /// type definition is then returned through the return parameter. Realize that the
        /// method does not process any ASBIE declarations. Therefore, only element declarations
        /// representing BBIEs within the ABIE are processed. To distinguish between ASBIEs and
        /// BBIEs the prefix of the type in the element declaration is used. The prefix of the type
        /// used in BBIE element delcarations is assumed to be "bdt". Hence an element declaration
        /// for a BBIE must use the prefix "bdt" in order to be processed properly. Realize that for
        /// processing ASBIEs within a complex type the method CumulateAbiesSpecsFromComplexType
        /// must be used.
        ///</summary>
        ///<param name="abieComplexType">
        /// The input parameter contains the complex type declaration of the ABIE to be processed. An
        /// example of a complex type definition is illustrated in the following.
        /// <code>
        ///   &lt;xsd:complexType name="AddressType"&gt;
        ///     &lt;xsd:sequence&gt;
        ///       &lt;xsd:element name="StreetName" type="bdt:TextStringType" minOccurs="0" maxOccurs="unbounded"/&gt;
        ///       &lt;xsd:element name="ZIP_PostcodeCode" type="bdt:CodeStringType" minOccurs="0" maxOccurs="unbounded"/&gt;
        ///       &lt;xsd:element ref="tns:Included_PersonPerson"/&gt;
        ///     &lt;/xsd:sequence&gt;
        ///   &lt;/xsd:complexType&gt;
        /// </code>
        ///</param>
        ///<returns>
        /// The method returns an ABIESpec for the complex type passed to the method through the
        /// parameter <paramref name="abieComplexType"/>
        ///</returns>
        public static AbieSpec CumulateAbieSpecFromComplexType(ComplexType abieComplexType)
        {
            AbieSpec singleAbieSpec = new AbieSpec();

            string abieName = abieComplexType.Name.Substring(0, abieComplexType.Name.Length - 4);

            singleAbieSpec.Name    = abieName;
            singleAbieSpec.BasedOn = FindBaseACCForABIE(abieName);

            List <BbieSpec> bbieSpecs = new List <BbieSpec>();

            foreach (object ctItem in abieComplexType.Items)
            {
                if (ctItem is Element)
                {
                    Element element = (Element)ctItem;

                    if (element.Ref.Name.Equals(""))
                    {
                        if (element.Type.Prefix.Equals("bdt"))
                        {
                            BbieSpec bbieSpec = new BbieSpec();

                            bbieSpec.Name       = element.Name;
                            bbieSpec.LowerBound = ResolveMinOccurs(element.MinOccurs);
                            bbieSpec.UpperBound = ResolveMaxOccurs(element.MaxOccurs);

                            string bdtName = element.Type.Name.Substring(0, element.Type.Name.Length - 4);

                            foreach (IBdt bdt in ExistingBdts.Bdts)
                            {
                                if ((bdt.Name + bdt.Con.BasicType.DictionaryEntryName).Equals(bdtName))
                                {
                                    bbieSpec.Bdt = bdt;
                                    break;
                                }
                            }

                            if (bbieSpec.Bdt == null)
                            {
                                throw new Exception("Expected BDT not found: " + bdtName);
                            }

                            bbieSpecs.Add(bbieSpec);
                        }
                    }
                }
            }
            singleAbieSpec.Bbies = bbieSpecs;

            return(singleAbieSpec);
        }
        ///<summary>
        /// The method creates an ABIESpec based on the complex type definition of an ABIE
        /// as it occurs in an XML schema. Therefore, the method requires on input parameter
        /// containing the complex type definition. A corresponding ABIESpec of the complex
        /// type definition is then returned through the return parameter. Realize that the
        /// method does not process any ASBIE declarations. Therefore, only element declarations
        /// representing BBIEs within the ABIE are processed. To distinguish between ASBIEs and
        /// BBIEs the prefix of the type in the element declaration is used. The prefix of the type
        /// used in BBIE element delcarations is assumed to be "bdt". Hence an element declaration
        /// for a BBIE must use the prefix "bdt" in order to be processed properly. Realize that for
        /// processing ASBIEs within a complex type the method CumulateAsbieSpecsFromComplexType
        /// must be used.
        ///</summary>
        ///<param name="abieComplexType">
        /// The input parameter contains the complex type declaration of the ABIE to be processed. An
        /// example of a complex type definition is illustrated in the following.
        /// <code>
        ///   &lt;xsd:complexType name="AddressType"&gt;
        ///     &lt;xsd:sequence&gt;
        ///       &lt;xsd:element name="StreetName" type="bdt:TextStringType" minOccurs="0" maxOccurs="unbounded"/&gt;
        ///       &lt;xsd:element name="ZIP_PostcodeCode" type="bdt:CodeStringType" minOccurs="0" maxOccurs="unbounded"/&gt;
        ///       &lt;xsd:element ref="tns:Included_PersonPerson"/&gt;
        ///     &lt;/xsd:sequence&gt;
        ///   &lt;/xsd:complexType&gt;
        /// </code>
        ///</param>
        ///<returns>
        /// The method returns an ABIESpec for the complex type passed to the method through the
        /// parameter <paramref name="abieComplexType"/>
        ///</returns>
        public static AbieSpec CumulateAbieSpecFromComplexType(ComplexType abieComplexType)
        {
            var singleAbieSpec = new AbieSpec();

            string abieName = abieComplexType.Name.Substring(0, abieComplexType.Name.Length - 4);

            singleAbieSpec.Name = abieName;

            var bbieSpecs = new List <BbieSpec>();

            foreach (object ctItem in abieComplexType.Items)
            {
                if (ctItem is Element)
                {
                    var element = (Element)ctItem;

                    if (element.Ref.Name.Equals(""))
                    {
                        if (element.Type.Prefix.Equals("bdt"))
                        {
                            var bbieSpec = new BbieSpec
                            {
                                Name       = element.Name,
                                LowerBound = ResolveMinOccurs(element.MinOccurs),
                                UpperBound = ResolveMaxOccurs(element.MaxOccurs)
                            };

                            string bdtName = element.Type.Name.Substring(0, element.Type.Name.Length - 4);

                            foreach (IBdt bdt in ExistingBdts.Bdts)
                            {
                                if ((bdt.Name + bdt.Con.BasicType.DictionaryEntryName).Equals(bdtName))
                                {
                                    bbieSpec.Bdt = bdt;
                                    break;
                                }
                            }

                            bbieSpecs.Add(bbieSpec);
                        }
                    }
                }
            }
            singleAbieSpec.Bbies = bbieSpecs;

            return(singleAbieSpec);
        }
        private AbieSpec GenerateAbieSpec(ComplexTypeMapping complexTypeMapping, IAcc acc, string name)
        {
            List <BbieSpec> bbieSpecs = new List <BbieSpec>();

            bbieSpecs.AddRange(GenerateBbieSpecs(complexTypeMapping.BccMappings(acc)));
            bbieSpecs.AddRange(GenerateBbieSpecs(complexTypeMapping.SplitMappings(), acc));

            var abieSpec = new AbieSpec
            {
                BasedOn = acc,
                Name    = name,
                Bbies   = bbieSpecs,
            };

            abieSpecs.Add(abieSpec);
            asbiesToGenerate.GetAndCreate(name).AddRange(DetermineAsbiesToGenerate(complexTypeMapping.AsccMappings(acc)));
            return(abieSpec);
        }
Пример #4
0
 /// <summary>
 /// Creates a ABIE based on the given <paramref name="specification"/>.
 /// <param name="specification">A specification for a ABIE.</param>
 /// <returns>The newly created ABIE.</returns>
 /// </summary>
 public IAbie CreateAbie(AbieSpec specification)
 {
     return(new UpccAbie(UmlPackage.CreateClass(AbieSpecConverter.Convert(specification))));
 }
Пример #5
0
 /// <summary>
 /// Updates a ABIE to match the given <paramref name="specification"/>.
 /// <param name="abie">A ABIE.</param>
 /// <param name="specification">A new specification for the given ABIE.</param>
 /// <returns>The updated ABIE. Depending on the implementation, this might be the same updated instance or a new instance!</returns>
 /// </summary>
 public IAbie UpdateAbie(IAbie abie, AbieSpec specification)
 {
     return(new UpccAbie(UmlPackage.UpdateClass(((UpccAbie)abie).UmlClass, AbieSpecConverter.Convert(specification))));
 }
        ///<summary>
        /// The static method imports an XML schema containing Business Information
        /// Entities into an existing BIE library. The method has one input parameter
        /// of type ImporterContext specifying different settings utilized while
        /// importing the XML schema.
        ///</summary>
        ///<param name="context">
        /// The parameter provides the necessary context information required by the
        /// BIE XML schema importer. An example would be the directory location where
        /// all XML schemas to be imported are located, and the repository which contains
        /// the BIE library that all ABIEs should be imported into. Fore more information
        /// plese refer to the documentation of the ImporterContext class.
        /// </param>
        public static void ImportXSD(ImporterContext context)
        {
            #region Import Preparation

            // TODO: ACC, BDT and BIE library should be configurable through the ImporterContext
            InitLibraries(context);

            // Even though the XML schema is stored in the importer context we need to re-read
            // the XML schema. The reason for doing so is that the impoter context pre-read the
            // XML schema using the XML schema reader class from the .net API. However, the XML
            // schema reader dropped information that is required to import the ABIE schema.
            // Instead we want to utilitze the CustomSchemaReader class that requires an XML
            // schema document as an input. Therefore we need to re-read the XML schema file based
            // on the file name and directory location as specified in the importer context.
            XmlDocument bieSchemaDocument = GetBieSchemaDocument(context);

            CustomSchemaReader reader = new CustomSchemaReader(bieSchemaDocument);

            #endregion

            IDictionary <string, string> allElementDefinitions = new Dictionary <string, string>();

            #region Processing Step 1: Cumulate all ABIEs and create them in the BIE library

            foreach (object item in reader.Items)
            {
                if (item is ComplexType)
                {
                    ComplexType abieComplexType = (ComplexType)item;

                    AbieSpec singleAbieSpec = CumulateAbieSpecFromComplexType(abieComplexType);

                    BieLibrary.CreateAbie(singleAbieSpec);
                }

                if (item is Element)
                {
                    Element element = (Element)item;
                    allElementDefinitions.Add(element.Name, element.Type.Name);
                }
            }

            #endregion

            #region Processing Step 2: Update all ABIEs with their ASBIEs

            foreach (object item in reader.Items)
            {
                if (item is ComplexType)
                {
                    ComplexType abieComplexType = (ComplexType)item;

                    string abieName = abieComplexType.Name.Substring(0, abieComplexType.Name.Length - 4);

                    IAbie    abieToBeUpdated = BieLibrary.GetAbieByName(abieName);
                    AbieSpec updatedAbieSpec = AbieSpec.CloneAbie(abieToBeUpdated);

                    updatedAbieSpec.Asbies = new List <AsbieSpec>(CumulateAbiesSpecsFromComplexType(abieComplexType, allElementDefinitions));

                    BieLibrary.UpdateAbie(abieToBeUpdated, updatedAbieSpec);
                }
            }

            #endregion
        }
Пример #7
0
 public IAbie UpdateAbie(IAbie element, AbieSpec spec)
 {
     throw new NotImplementedException();
 }
Пример #8
0
 public IAbie CreateAbie(AbieSpec spec)
 {
     throw new NotImplementedException();
 }
 private static string GenerateDictionaryEntryNameDefaultValue(AbieSpec abieSpec)
 {
     return(abieSpec.Name + ". Details");
 }
 private static string GenerateUniqueIdentifierDefaultValue(AbieSpec abieSpec)
 {
     return(Guid.NewGuid().ToString());
 }
Пример #11
0
        internal static UmlClassSpec Convert(AbieSpec abieSpec)
        {
            var umlClassSpec = new UmlClassSpec
            {
                Stereotype   = "ABIE",
                Name         = abieSpec.Name,
                TaggedValues = new[]
                {
                    new UmlTaggedValueSpec("businessTerm", abieSpec.BusinessTerms),
                    new UmlTaggedValueSpec("definition", abieSpec.Definition),
                    new UmlTaggedValueSpec("dictionaryEntryName", abieSpec.DictionaryEntryName)
                    {
                        DefaultValue = GenerateDictionaryEntryNameDefaultValue(abieSpec)
                    },
                    new UmlTaggedValueSpec("languageCode", abieSpec.LanguageCode),
                    new UmlTaggedValueSpec("uniqueIdentifier", abieSpec.UniqueIdentifier)
                    {
                        DefaultValue = GenerateUniqueIdentifierDefaultValue(abieSpec)
                    },
                    new UmlTaggedValueSpec("versionIdentifier", abieSpec.VersionIdentifier),
                    new UmlTaggedValueSpec("usageRule", abieSpec.UsageRules),
                },
            };

            var dependencySpecs = new List <UmlDependencySpec>();

            if (abieSpec.IsEquivalentTo != null)
            {
                dependencySpecs.Add(new UmlDependencySpec
                {
                    Stereotype = "isEquivalentTo",
                    Target     = ((UpccAbie)abieSpec.IsEquivalentTo).UmlClass,
                    LowerBound = "0",
                    UpperBound = "1",
                });
            }
            if (abieSpec.BasedOn != null)
            {
                dependencySpecs.Add(new UmlDependencySpec
                {
                    Stereotype = "basedOn",
                    Target     = ((UpccAcc)abieSpec.BasedOn).UmlClass,
                    LowerBound = "0",
                    UpperBound = "1",
                });
            }
            umlClassSpec.Dependencies = dependencySpecs;

            var attributeSpecs = new List <UmlAttributeSpec>();

            if (abieSpec.Bbies != null)
            {
                foreach (var bbieSpec in abieSpec.Bbies)
                {
                    attributeSpecs.Add(BbieSpecConverter.Convert(bbieSpec, abieSpec.Name));
                }
            }
            umlClassSpec.Attributes = MakeAttributeNamesUnique(attributeSpecs);

            var associationSpecs = new List <UmlAssociationSpec>();

            if (abieSpec.Asbies != null)
            {
                foreach (var asbieSpec in abieSpec.Asbies)
                {
                    associationSpecs.Add(AsbieSpecConverter.Convert(asbieSpec, abieSpec.Name));
                }
            }
            umlClassSpec.Associations = MakeAssociationNamesUnique(associationSpecs);

            return(umlClassSpec);
        }