Esempio n. 1
0
 public CandidateCdt(ICdt originalCdt)
 {
     mOriginalCdt   = originalCdt;
     mSelected      = false;
     mPotentialSups = null;
     mPotentialCon  = new PotentialCon(originalCdt.Con);
 }
Esempio n. 2
0
        public void ShouldGetAndCacheParticularCdtFromCdtLibrary()
        {
            // Setup
            var cdtMockText = new Mock <ICdt>();

            cdtMockText.SetupGet(c => c.Name).Returns("Text");
            var cdtMockDate = new Mock <ICdt>();

            cdtMockDate.SetupGet(c => c.Name).Returns("Date");

            var cdtLibraryMock = new Mock <ICdtLibrary>();

            ICdt[] expectedCdts = new[] { cdtMockDate.Object, cdtMockText.Object };
            cdtLibraryMock.SetupGet(l => l.Name).Returns("cdtlib1");
            cdtLibraryMock.SetupGet(l => l.Cdts).Returns(expectedCdts);

            var cctsRepositoryMock = new Mock <ICctsRepository>();

            cctsRepositoryMock.Setup(r => r.GetAllLibraries()).Returns(new[] { cdtLibraryMock.Object });

            // Events
            CcCache ccCache = CcCache.GetInstance(cctsRepositoryMock.Object);
            ICdt    cdt     = ccCache.GetCdtFromCdtLibrary("cdtlib1", "Text");

            ccCache.GetCdtFromCdtLibrary("cdtlib1", "Text");

            // Assertion and Verification
            Assert.That(cdt, Is.SameAs(cdtMockText.Object));
            cdtLibraryMock.VerifyGet(l => l.Cdts, Times.Exactly(1));
        }
Esempio n. 3
0
        private void buttonGenerateBDT_Click(object sender, EventArgs e)
        {
            GatherUserInput();

            if ((cache.PathIsValid(CacheConstants.PATH_CDTs, new[] { selectedCDTLName, selectedCDTName })) &&
                (cache.PathIsValid(CacheConstants.PATH_BDTLs, new[] { selectedBDTLName })))
            {
                ICdt        cdt  = repository.GetCdtById(cache.CDTLs[selectedCDTLName].CDTs[selectedCDTName].Id);
                IBdtLibrary bdtl = repository.GetBdtLibraryById(cache.BDTLs[selectedBDTLName].Id);

                BdtSpec bdtSpec = BdtSpec.CloneCdt(cdt, textBDTName.Text);

                var sups = new List <BdtSupSpec>(bdtSpec.Sups);
                foreach (cSUP sup in cache.CDTLs[selectedCDTLName].CDTs[selectedCDTName].SUPs.Values)
                {
                    if (sup.State == CheckState.Unchecked)
                    {
                        var name = sup.Name;
                        sups.RemoveAll(s => s.Name == name);
                    }
                }
                bdtSpec.Sups = sups;

                IBdt newBDT = bdtl.CreateBdt(bdtSpec);

                cache.BDTLs[selectedBDTLName].BDTs.Add(newBDT.Name, new cBDT(newBDT.Name, newBDT.Id, newBDT.BasedOn.Id, CheckState.Unchecked));

                textBDTName.Text = "";
                textBDTName.Text = newBDT.Name;
            }
        }
Esempio n. 4
0
 public static string getConBasicTypeName(ICdt cdt)
 {
     if (cdt.Con != null && cdt.Con.BasicType != null)
     {
         return(TrimElementName(GetBasicTypeName(cdt.Con as UpccAttribute)));
     }
     return("Error_No_BasicType");
 }
Esempio n. 5
0
 public PotentialBbie(string bbieName, ICdt cdtOfTheBccWhichTheBbieIsBasedOn)
 {
     mName          = bbieName;
     mCdtUsedInBcc  = cdtOfTheBccWhichTheBbieIsBasedOn;
     mChecked       = false;
     mSelected      = false;
     mPotentialBdts = null;
     mItemReadOnly  = false;
     mItemCursor    = Cursors.IBeam;
     mItemFocusable = true;
 }
 private static ICdtSup GetSup(ICdt cdt, string name)
 {
     foreach (ICdtSup sup in cdt.Sups)
     {
         if (name == NDR.GetXsdAttributeNameFromSup(sup))
         {
             return(sup);
         }
     }
     return(null);
 }
Esempio n. 7
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);
        }
Esempio n. 8
0
        public void ShouldOnlyAutoGenerateUnspecifiedTaggedValues()
        {
            ICctsRepository ccRepository = CctsRepositoryFactory.CreateCctsRepository(new CdtLibraryTestRepository());
            ICdtLibrary     cdtLibrary   = ccRepository.GetCdtLibraryByPath(CdtLibraryTestRepository.PathToCdtLibrary());

            CdtSpec cdtSpec = new CdtSpec {
                Name = "cdt1", UniqueIdentifier = "{x-123-456-789-x}", DictionaryEntryName = "shouldNotBeReplaced"
            };
            ICdt cdt = cdtLibrary.CreateCdt(cdtSpec);

            Assert.That(cdt.UniqueIdentifier, Is.EqualTo("{x-123-456-789-x}"));
            Assert.That(cdt.DictionaryEntryName, Is.EqualTo("shouldNotBeReplaced"));
        }
 public static BdtSpec CloneCdt(ICdt cdt, string name)
 {
     return(new BdtSpec
     {
         Name = (String.IsNullOrEmpty(name) ? cdt.Name : name),
         BasedOn = cdt,
         Definition = cdt.Definition,
         LanguageCode = cdt.LanguageCode,
         BusinessTerms = new List <string>(cdt.BusinessTerms),
         UsageRules = new List <string>(cdt.UsageRules),
         Con = CloneCdtCon(cdt.Con),
         Sups = new List <BdtSupSpec>(cdt.Sups.Convert(sup => CloneCdtSup(sup))),
     });
 }
Esempio n. 10
0
        public void CreateBDT()
        {
            string bdtName = GetBdtNameFromXsdType();
            ICdt   cdt     = Context.CDTLibrary.GetCdtByName(GetDataTypeTerm());
            var    bdtSpec = new BdtSpec
            {
                BasedOn = cdt,
                Name    = bdtName,
                Con     = SpecifyCON(),
                Sups    = new List <BdtSupSpec>(SpecifySUPs()),
            };

            BDT = Context.BDTLibrary.CreateBdt(bdtSpec);
        }
Esempio n. 11
0
        public void ShouldAutoGenerateTaggedValues()
        {
            ICctsRepository ccRepository = CctsRepositoryFactory.CreateCctsRepository(new CdtLibraryTestRepository());
            ICdtLibrary     cdtLibrary   = ccRepository.GetCdtLibraryByPath(CdtLibraryTestRepository.PathToCdtLibrary());

            CdtSpec cdtSpec = new CdtSpec {
                Name = "cdt1"
            };
            ICdt cdt = cdtLibrary.CreateCdt(cdtSpec);

            Assert.That(cdt.UniqueIdentifier, Is.Not.Null);
            Assert.That(cdt.UniqueIdentifier, Is.Not.Empty);
            Assert.That(cdt.DictionaryEntryName, Is.EqualTo("cdt1. Type"));
        }
Esempio n. 12
0
 public static CdtSpec CloneCdt(ICdt cdt)
 {
     return(new CdtSpec
     {
         Name = cdt.Name,
         IsEquivalentTo = cdt.IsEquivalentTo,
         Con = CdtConSpec.CloneCdtCon(cdt.Con),
         Sups = new List <CdtSupSpec>(cdt.Sups.Convert(o => CdtSupSpec.CloneCdtSup(o))),
         BusinessTerms = new List <string>(cdt.BusinessTerms),
         Definition = cdt.Definition,
         LanguageCode = cdt.LanguageCode,
         VersionIdentifier = cdt.VersionIdentifier,
         UsageRules = new List <string>(cdt.UsageRules),
     });
 }
        private void CreateChildren(Entry entry, ICdt cdt)
        {
            foreach (Entry subEntry in entry.SubEntries)
            {
                ICdtSup sup = GetSup(cdt, subEntry.Name);

                if (sup != null)
                {
                    AddToIndex(subEntry, sup);
                }
                else
                {
                    throw new MappingError("SUP '" + subEntry.Name + "' not found.");
                }
            }
        }
Esempio n. 14
0
        public void LoadCONAndSUPs(ICctsRepository repository)
        {
            if ((CON.Name.Equals("") && SUPs.Count < 1))
            {
                int  cdtId = Id;
                ICdt cdt   = repository.GetCdtById(cdtId);

                CON.Name  = cdt.Con.Name;
                CON.Id    = cdt.Con.Id;
                CON.State = CheckState.Checked;

                foreach (var sup in cdt.Sups)
                {
                    SUPs.Add(sup.Name, new cSUP(sup.Name, sup.Id, CheckState.Unchecked));
                }
            }
        }
        public void ShouldAutoGenerateClonedTaggedValues()
        {
            ICctsRepository ccRepository = CreateRepository();
            ICdtLibrary     cdtLibrary   = ccRepository.GetCdtLibraryByPath(CdtLibraryTestRepository.PathToCdtLibrary());
            ICdt            cdtText      = ccRepository.GetCdtByPath(CdtLibraryTestRepository.PathToCdtText());

            CdtSpec cdtSpec = CdtSpec.CloneCdt(cdtText);

            cdtSpec.Name = "cdt1";

            ICdt cdt = cdtLibrary.CreateCdt(cdtSpec);

            Assert.That(cdt.UniqueIdentifier, Is.Not.Null);
            Assert.That(cdt.UniqueIdentifier, Is.Not.Empty);
            Assert.That(cdt.UniqueIdentifier, Is.Not.EqualTo(cdtText.UniqueIdentifier));
            Assert.That(cdt.DictionaryEntryName, Is.EqualTo("cdt1. Type"));
        }
Esempio n. 16
0
        public void ShouldNotAutoGenerateSpecifiedTaggedValues()
        {
            ICctsRepository ccRepository = CctsRepositoryFactory.CreateCctsRepository(new CdtLibraryTestRepository());
            ICdtLibrary     cdtLibrary   = ccRepository.GetCdtLibraryByPath(CdtLibraryTestRepository.PathToCdtLibrary());

            ICdt cdtText = ccRepository.GetCdtByPath(CdtLibraryTestRepository.PathToCdtText());

            CdtSpec cdtSpec = CdtSpec.CloneCdt(cdtText);

            cdtSpec.DictionaryEntryName = "cdt1";
            cdtSpec.UniqueIdentifier    = "{1-2-3}";

            ICdt updatedCdt = cdtLibrary.UpdateCdt(cdtText, cdtSpec);

            Assert.That(updatedCdt.UniqueIdentifier, Is.EqualTo("{1-2-3}"));
            Assert.That(updatedCdt.DictionaryEntryName, Is.EqualTo("cdt1"));
        }
        public void ShouldNotUpdateAutoGeneratedTaggedValues()
        {
            ICctsRepository ccRepository = CreateRepository();
            ICdtLibrary     cdtLibrary   = ccRepository.GetCdtLibraryByPath(CdtLibraryTestRepository.PathToCdtLibrary());

            ICdt   cdtText = ccRepository.GetCdtByPath(CdtLibraryTestRepository.PathToCdtText());
            string cdtTextUniqueIdentifier    = cdtText.UniqueIdentifier;
            string cdtTextDictionaryEntryName = cdtText.DictionaryEntryName;

            CdtSpec cdtSpec = CdtSpec.CloneCdt(cdtText);

            cdtSpec.Name = "cdt1";

            ICdt updatedCdt = cdtLibrary.UpdateCdt(cdtText, cdtSpec);

            Assert.That(updatedCdt.UniqueIdentifier, Is.EqualTo(cdtTextUniqueIdentifier));
            Assert.That(updatedCdt.DictionaryEntryName, Is.EqualTo(cdtTextDictionaryEntryName));
        }
        private void MapComplexTypeToCdt(SourceItem sourceElement, Stack <XmlQualifiedName> parentComplexTypeNames, XmlQualifiedName qualifiedComplexTypeName, string complexTypeName, string path)
        {
            ICdt targetCdt = null;
            ComplexTypeMapping    complexTypeMapping;
            List <ElementMapping> childMappings = GetChildMappings(sourceElement, parentComplexTypeNames, qualifiedComplexTypeName, path);

            if (childMappings.Count() > 0)
            {
                foreach (ElementMapping child in childMappings)
                {
                    if (child is AttributeOrSimpleElementToSupMapping)
                    {
                        if (targetCdt == null)
                        {
                            targetCdt = ((AttributeOrSimpleElementToSupMapping)child).Cdt;
                        }
                        else
                        {
                            if (targetCdt.Id != ((AttributeOrSimpleElementToSupMapping)child).Cdt.Id)
                            {
                                throw new MappingError("Complex type mapped to more than one CDTs");
                            }
                        }
                    }
                }

                complexTypeMapping = new ComplexTypeToCdtMapping(sourceElement.Name, complexTypeName, childMappings);
                complexTypeMappings.GetAndCreate(complexTypeName + ((IBcc)GetTargetElement(sourceElement)).Cdt.Name).Add(complexTypeMapping);

                return;
            }

            targetCdt = ((IBcc)GetTargetElement(sourceElement)).Cdt;

            complexTypeMapping = new ComplexTypeToCdtMapping(sourceElement.Name, complexTypeName, childMappings)
            {
                TargetCdt = targetCdt
            };

            complexTypeMappings.GetAndCreate(complexTypeName + ((IBcc)GetTargetElement(sourceElement)).Cdt.Name).Add(complexTypeMapping);
        }
        public void CreateBdt()
        {
            foreach (CandidateBdtLibrary candidateBdtLibrary in mCandidateBdtLibraries)
            {
                if (candidateBdtLibrary.Selected)
                {
                    foreach (IBdt bdt in candidateBdtLibrary.OriginalBdtLibrary.Bdts)
                    {
                        if (bdt.Name.Equals(Prefix + Name))
                        {
                            throw new TemporaryBdtModelException(String.Format("The name of the BDT is invalid since another BDT with the same name already exists. An example for a valid BDT name would be \"New{0}\".", Prefix + Name));
                        }
                    }
                    ICdt    basedOnCdt = GetBasedOnCdt();
                    BdtSpec bdtSpec    = BdtSpec.CloneCdt(basedOnCdt, Prefix + Name);
                    bdtSpec.Sups = GetSelectedSups(bdtSpec);

                    candidateBdtLibrary.OriginalBdtLibrary.CreateBdt(bdtSpec);
                }
            }
        }
        private static XmlSchemaAnnotation GetTypeAnnotation(ICdt cdt)
        {
            var xml = new XmlDocument();
            // Deviation from rule [R BFE5]: Generating only a subset of the defined annotations and added some additional annotations.
            var annNodes = new List <XmlNode>();

            AddAnnotation(xml, annNodes, "UniqueID", cdt.UniqueIdentifier);
            AddAnnotation(xml, annNodes, "VersionID", cdt.VersionIdentifier);
            AddAnnotation(xml, annNodes, "DictionaryEntryName", cdt.DictionaryEntryName);
            AddAnnotation(xml, annNodes, "Definition", cdt.Definition);
            AddAnnotations(xml, annNodes, "BusinessTermName", cdt.BusinessTerms);
            AddAnnotation(xml, annNodes, "PropertyTermName", cdt.Name);
            AddAnnotation(xml, annNodes, "LanguageCode", cdt.LanguageCode);
            AddAnnotation(xml, annNodes, "AcronymCode", "CDT");
            var ann = new XmlSchemaAnnotation();

            ann.Items.Add(new XmlSchemaDocumentation {
                Language = "en", Markup = annNodes.ToArray()
            });
            return(ann);
        }
 /// <summary>
 /// Removes a CDT from this CDTLibrary.
 /// <param name="cdt">A CDT.</param>
 /// </summary>
 public void RemoveCdt(ICdt cdt)
 {
     UmlPackage.RemoveClass(((UpccCdt)cdt).UmlClass);
 }
Esempio n. 22
0
 private static string GetTypeName(ICdt cdt)
 {
     return(cdt.Name + cdt.Con.BasicType.Name + "Type");
 }
Esempio n. 23
0
 public UpccCdtSup(IUmlAttribute umlAttribute, ICdt cdt)
 {
     UmlAttribute = umlAttribute;
     Cdt          = cdt;
 }
 public UpccCdtCon(IUmlAttribute umlAttribute, ICdt cdt) : base(umlAttribute)
 {
     Cdt = cdt;
 }
 private static string GetTypeName(ICdt cdt)
 {
     return(cdt.Name + NDR.getConBasicTypeName(cdt) + "Type");
 }
 /// <summary>
 /// Updates a CDT to match the given <paramref name="specification"/>.
 /// <param name="cdt">A CDT.</param>
 /// <param name="specification">A new specification for the given CDT.</param>
 /// <returns>The updated CDT. Depending on the implementation, this might be the same updated instance or a new instance!</returns>
 /// </summary>
 public ICdt UpdateCdt(ICdt cdt, CdtSpec specification)
 {
     return(new UpccCdt(UmlPackage.UpdateClass(((UpccCdt)cdt).UmlClass, CdtSpecConverter.Convert(specification))));
 }
 public ICdt UpdateCdt(ICdt element, CdtSpec spec)
 {
     throw new NotImplementedException();
 }
 public void RemoveCdt(ICdt cdt)
 {
     throw new NotImplementedException();
 }
Esempio n. 29
0
 public SimpleTypeToCdtMapping(string simpleTypeName, ICdt targetCdt)
 {
     SimpleTypeName = simpleTypeName;
     TargetCDT      = targetCdt;
 }