/// <exception cref="MappingError"><c>MappingError</c>.</exception>
        private void CreateChildren(Entry entry, IAcc acc)
        {
            foreach (Entry subEntry in entry.SubEntries)
            {
                IBcc bcc = GetBcc(acc, subEntry.Name);

                if (bcc != null)
                {
                    AddToIndex(subEntry, bcc);
                    CreateChildren(subEntry, bcc.Cdt);
                }
                else
                {
                    IAscc ascc = GetAscc(acc, subEntry.Name);
                    if (ascc != null)
                    {
                        AddToIndex(subEntry, ascc);
                        CreateChildren(subEntry, ascc.AssociatedAcc);
                    }
                    else
                    {
                        throw new MappingError("BCC or ASCC '" + subEntry.Name + "' not found.");
                    }
                }
            }
        }
 public AttributeOrSimpleElementOrComplexElementToBccMapping(SourceItem sourceElement, IBcc targetBcc, IMapping bccTypeMapping)
     : base(sourceElement)
 {
     BccTypeMapping = bccTypeMapping;
     Bcc            = targetBcc;
     Acc            = Bcc.Acc;
     ElementName    = sourceElement.Name;
 }
Ejemplo n.º 3
0
        public CandidateBcc(IBcc originalBcc)
        {
            mChecked        = false;
            mOriginalBcc    = originalBcc;
            mSelected       = false;
            mPotentialBbies = null;

            mItemReadOnly  = true;
            mItemCursor    = Cursors.Arrow;
            mItemFocusable = false;
        }
        /// <exception cref="MappingError">Simple typed element mapped to non-BCC CCTS element.</exception>
        private ElementMapping MapElement(SourceItem sourceElement, string path, Stack <XmlQualifiedName> parentComplexTypeNames)
        {
            if (sourceElement.HasSimpleType())
            {
                if (!sourceElement.IsMapped)
                {
                    // ignore element
                    return(ElementMapping.NullElementMapping);
                }
                if (IsMappedToBcc(sourceElement))
                {
                    SimpleTypeToCdtMapping simpleTypeToCdtMapping = MapSimpleType(sourceElement);
                    return(new AttributeOrSimpleElementOrComplexElementToBccMapping(sourceElement, (IBcc)GetTargetElement(sourceElement), simpleTypeToCdtMapping));
                }
                if (IsMappedToSup(sourceElement))
                {
                    return(new AttributeOrSimpleElementToSupMapping(sourceElement, (ICdtSup)GetTargetElement(sourceElement)));
                }
                if (IsMappedToSplitFunction(sourceElement))
                {
                    List <SimpleTypeToCdtMapping> simpleTypeToCdtMappings = new List <SimpleTypeToCdtMapping>();
                    MappingFunction splitFunction = GetMappingFunction(sourceElement);
                    foreach (IBcc targetBcc in splitFunction.TargetCcs)
                    {
                        simpleTypeToCdtMappings.Add(MapSimpleType(sourceElement, targetBcc));
                    }
                    return(new SplitMapping(sourceElement, splitFunction.TargetCcs.Convert(cc => (IBcc)cc), simpleTypeToCdtMappings));
                }
                throw new MappingError("Simple typed element '" + path + "' mapped to non-BCC CCTS element.");
            }

            if (sourceElement.HasComplexType())
            {
                MapComplexType(sourceElement, path, parentComplexTypeNames);

                if (!sourceElement.IsMapped)
                {
                    return(new AsmaMapping(sourceElement));
                }
                if (IsMappedToAscc(sourceElement))
                {
                    IAscc targetAscc = (IAscc)GetTargetElement(sourceElement);
                    return(new ComplexElementToAsccMapping(sourceElement, targetAscc));
                }
                if (IsMappedToBcc(sourceElement))
                {
                    IBcc targetBcc = (IBcc)GetTargetElement(sourceElement);
                    return(new AttributeOrSimpleElementOrComplexElementToBccMapping(sourceElement, targetBcc, null));
                }

                throw new MappingError("Complex typed element '" + path + "' not mapped to either a BCC or an ASCC.");
            }
            throw new Exception("Source element '" + path + "' has neither simple nor complex type.");
        }
Ejemplo n.º 5
0
        public SimpleTypeToCdtMapping GetCdtMappingForTargetBcc(IBcc targetBcc)
        {
            ICdt cdt = targetBcc.Cdt;

            foreach (SimpleTypeToCdtMapping cdtMapping in CdtMappings)
            {
                if (cdtMapping.TargetCDT.Id == cdt.Id)
                {
                    return(cdtMapping);
                }
            }
            return(null);
        }
 public static BbieSpec CloneBcc(IBcc bcc, IBdt bdt)
 {
     return(new BbieSpec
     {
         Name = bcc.Name,
         Bdt = bdt,
         LowerBound = bcc.LowerBound,
         UpperBound = bcc.UpperBound,
         BusinessTerms = new List <string>(bcc.BusinessTerms),
         Definition = bcc.Definition,
         LanguageCode = bcc.LanguageCode,
         SequencingKey = bcc.SequencingKey,
         UsageRules = new List <string>(bcc.UsageRules),
     });
 }
Ejemplo n.º 7
0
 public static BccSpec CloneBcc(IBcc bcc)
 {
     return(new BccSpec
     {
         Name = bcc.Name,
         UpperBound = bcc.UpperBound,
         LowerBound = bcc.LowerBound,
         Cdt = bcc.Cdt,
         BusinessTerms = new List <string>(bcc.BusinessTerms),
         Definition = bcc.Definition,
         LanguageCode = bcc.LanguageCode,
         SequencingKey = bcc.SequencingKey,
         VersionIdentifier = bcc.VersionIdentifier,
         UsageRules = new List <string>(bcc.UsageRules),
     });
 }
        private SimpleTypeToCdtMapping MapSimpleType(SourceItem sourceElement, IBcc targetBcc)
        {
            var simpleTypeName = sourceElement.XsdTypeName;
            var cdt            = targetBcc.Cdt;

            foreach (SimpleTypeToCdtMapping simpleTypeMapping in simpleTypeMappings)
            {
                if (simpleTypeMapping.SimpleTypeName == simpleTypeName && simpleTypeMapping.TargetCDT.Id == cdt.Id)
                {
                    return(simpleTypeMapping);
                }
            }
            SimpleTypeToCdtMapping newMapping = new SimpleTypeToCdtMapping(simpleTypeName, cdt);

            simpleTypeMappings.Add(newMapping);
            return(newMapping);
        }
        ///<summary>
        ///</summary>
        ///<param name="bbie"></param>
        ///<returns></returns>
        public static XmlSchemaAnnotation GetBCCAnnotation(IBcc bcc)
        {
            // Contains all the documentation items such as DictionaryEntryName
            IList <XmlNode> documentation = new List <XmlNode>();

            AddDocumentation(documentation, "UniqueID", bcc.UniqueIdentifier);
            AddDocumentation(documentation, "VersionID", bcc.VersionIdentifier);
            AddDocumentation(documentation, "Cardinality", bcc.LowerBound + ".." + bcc.UpperBound);
            AddDocumentation(documentation, "SequencingKey", bcc.SequencingKey);
            AddDocumentation(documentation, "DictionaryEntryName", bcc.DictionaryEntryName);
            AddDocumentation(documentation, "Definition", bcc.Definition);
            AddDocumentation(documentation, "BusinessTermName", bcc.BusinessTerms);
            AddDocumentation(documentation, "PropertyTermName", bcc.Name);
            AddDocumentation(documentation, "RepresentationTermName", bcc.Cdt.Name);
            AddDocumentation(documentation, "AcronymCode", "BCC");

            XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();

            annotation.Items.Add(new XmlSchemaDocumentation {
                Language = "en", Markup = documentation.ToArray()
            });

            return(annotation);
        }
        /// <summary>
        /// Retrieves the BDT based on the given CDT from the BDT library. If the BDT does not yet exist, it is created.
        /// </summary>
        /// <param name="splitMapping"></param>
        /// <param name="targetBcc"></param>
        /// <returns></returns>
        private IBdt GetBdt(SplitMapping splitMapping, IBcc targetBcc)
        {
            SimpleTypeToCdtMapping cdtMapping = splitMapping.GetCdtMappingForTargetBcc(targetBcc);

            return(bdtLibrary.GetBdtByName(cdtMapping.BIEName));
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Updates a(n) BCC to match the given <paramref name="specification"/>.
 /// <param name="bcc">A(n) BCC.</param>
 /// <param name="specification">A new specification for the given BCC.</param>
 /// <returns>The updated BCC. Depending on the implementation, this might be the same updated instance or a new instance!</returns>
 /// </summary>
 public IBcc UpdateBcc(IBcc bcc, BccSpec specification)
 {
     return(new UpccBcc(UmlClass.UpdateAttribute(((UpccBcc)bcc).UmlAttribute, BccSpecConverter.Convert(specification, Name)), this));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Removes a(n) BCC from this ACC.
 /// <param name="bcc">A(n) BCC.</param>
 /// </summary>
 public void RemoveBcc(IBcc bcc)
 {
     UmlClass.RemoveAttribute(((UpccBcc)bcc).UmlAttribute);
 }
Ejemplo n.º 13
0
 public string GetBbieName(IBcc targetBcc)
 {
     return(SourceItem.Name + "_" + targetBcc.Name);
 }
Ejemplo n.º 14
0
 public static string GenerateBCCName(IBcc bcc)
 {
     return(GenerateBCCOrBBIEName(bcc.Name, bcc.Cdt.Name, bcc.DictionaryEntryName));
 }
        private void ShouldContainTargetBccElement(TargetElementStore targetElementStore, string name, IBcc referencedBcc)
        {
            object targetCc = ShouldContainTargetCc(name, targetElementStore, referencedBcc);

            Assert.IsTrue(targetCc is IBcc);
            Assert.That(((IBcc)targetCc).Id, Is.EqualTo(referencedBcc.Id));
        }