internal static UmlAttributeSpec Convert(BbieSpec bbieSpec, string className)
        {
            var type             = ((UpccBdt)bbieSpec.Bdt).UmlClass;
            var umlAttributeSpec = new UmlAttributeSpec
            {
                Stereotype   = "BBIE",
                Name         = bbieSpec.Name,
                Type         = type,
                UpperBound   = bbieSpec.UpperBound,
                LowerBound   = bbieSpec.LowerBound,
                TaggedValues = new[]
                {
                    new UmlTaggedValueSpec("businessTerm", bbieSpec.BusinessTerms),
                    new UmlTaggedValueSpec("definition", bbieSpec.Definition),
                    new UmlTaggedValueSpec("dictionaryEntryName", bbieSpec.DictionaryEntryName)
                    {
                        DefaultValue = GenerateDictionaryEntryNameDefaultValue(bbieSpec, className)
                    },
                    new UmlTaggedValueSpec("languageCode", bbieSpec.LanguageCode),
                    new UmlTaggedValueSpec("sequencingKey", bbieSpec.SequencingKey),
                    new UmlTaggedValueSpec("uniqueIdentifier", bbieSpec.UniqueIdentifier)
                    {
                        DefaultValue = GenerateUniqueIdentifierDefaultValue(bbieSpec, className)
                    },
                    new UmlTaggedValueSpec("versionIdentifier", bbieSpec.VersionIdentifier),
                    new UmlTaggedValueSpec("usageRule", bbieSpec.UsageRules),
                },
            };

            return(umlAttributeSpec);
        }
 private IEnumerable <BbieSpec> GenerateBbieSpecs(IEnumerable <AttributeOrSimpleElementOrComplexElementToBccMapping> bccMappings)
 {
     foreach (var bccMapping in bccMappings)
     {
         var bcc      = bccMapping.Bcc;
         var bbieSpec = BbieSpec.CloneBcc(bcc, GetBdt(bccMapping));
         bbieSpec.Name = bccMapping.BIEName;
         yield return(bbieSpec);
     }
 }
        ///<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);
        }
 private IEnumerable <BbieSpec> GenerateBbieSpecs(IEnumerable <SplitMapping> splitMappings, IAcc targetAcc)
 {
     foreach (var splitMapping in splitMappings)
     {
         foreach (IBcc bcc in splitMapping.TargetBccs)
         {
             if (bcc.Acc.Id == targetAcc.Id)
             {
                 var bbieSpec = BbieSpec.CloneBcc(bcc, GetBdt(splitMapping, bcc));
                 bbieSpec.Name = splitMapping.GetBbieName(bcc);
                 yield return(bbieSpec);
             }
         }
     }
 }
        ///<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);
        }
Example #6
0
 /// <summary>
 /// Updates a(n) BBIE to match the given <paramref name="specification"/>.
 /// <param name="bbie">A(n) BBIE.</param>
 /// <param name="specification">A new specification for the given BBIE.</param>
 /// <returns>The updated BBIE. Depending on the implementation, this might be the same updated instance or a new instance!</returns>
 /// </summary>
 public IBbie UpdateBbie(IBbie bbie, BbieSpec specification)
 {
     return(new UpccBbie(UmlClass.UpdateAttribute(((UpccBbie)bbie).UmlAttribute, BbieSpecConverter.Convert(specification, Name)), this));
 }
Example #7
0
 /// <summary>
 /// Creates a(n) BBIE based on the given <paramref name="specification"/>.
 /// <param name="specification">A specification for a(n) BBIE.</param>
 /// <returns>The newly created BBIE.</returns>
 /// </summary>
 public IBbie CreateBbie(BbieSpec specification)
 {
     return(new UpccBbie(UmlClass.CreateAttribute(BbieSpecConverter.Convert(specification, Name)), this));
 }
 private static string GenerateDictionaryEntryNameDefaultValue(BbieSpec bbieSpec, string className)
 {
     return(className + ". " + bbieSpec.Name + ". " + bbieSpec.Bdt.Name);
 }
 private static string GenerateUniqueIdentifierDefaultValue(BbieSpec bbieSpec, string className)
 {
     return(Guid.NewGuid().ToString());
 }