Exemple #1
0
        async public Task SetCookies(IAcc acc)
        {
            L.Trace();
            string        json        = acc.Cookies.Value;
            JArray        ja          = JArray.Parse(json);
            List <Cookie> cookiesList = new List <Cookie>();

            foreach (var cookie in ja)
            {
                double expires  = Double.Parse(cookie["Expires"].ToString());
                bool   secure   = (cookie["Secure"].ToString() == "true") ? true : false;
                bool   httpOnly = (cookie["HttpOnly"].ToString() == "true") ? true : false;

                var setCookie = await chromeSession.SendAsync(new SetCookieCommand
                {
                    Name     = cookie["Name"].ToString(),
                    Value    = cookie["Value"].ToString(),
                    Domain   = cookie["Domain"].ToString(),
                    Path     = cookie["Path"].ToString(),
                    Secure   = secure,
                    HttpOnly = httpOnly,
                    SameSite = cookie["SameSite"].ToString(),
                    Expires  = expires
                });
            }
        }
        public void ShouldGetAndCacheParticularCcFromCcLibrary()
        {
            // Setup
            var accMockPerson = new Mock <IAcc>();

            accMockPerson.SetupGet(a => a.Name).Returns("Person");
            var accMockAddress = new Mock <IAcc>();

            accMockAddress.SetupGet(a => a.Name).Returns("Address");

            var ccLibraryMock = new Mock <ICcLibrary>();

            IAcc[] expectedAccs = new[] { accMockAddress.Object, accMockPerson.Object };
            ccLibraryMock.SetupGet(l => l.Name).Returns("cclib1");
            ccLibraryMock.SetupGet(l => l.Accs).Returns(expectedAccs);

            var cctsRepositoryMock = new Mock <ICctsRepository>();

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

            // Events
            CcCache ccCache = CcCache.GetInstance(cctsRepositoryMock.Object);
            IAcc    acc     = ccCache.GetCcFromCcLibrary("cclib1", "Address");

            ccCache.GetCcFromCcLibrary("cclib1", "Address");

            // Assertion and Verification
            Assert.That(acc, Is.SameAs(accMockAddress.Object));
            ccLibraryMock.VerifyGet(l => l.Accs, Times.Exactly(1));
        }
        /// <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 CandidateAcc(IAcc originalAcc)
 {
     mOriginalAcc    = originalAcc;
     mSelected       = false;
     mCandidateBccs  = null;
     mCandidateAbies = null;
 }
 public IEnumerable <AttributeOrSimpleElementOrComplexElementToBccMapping> BccMappings(IAcc targetACC)
 {
     foreach (AttributeOrSimpleElementOrComplexElementToBccMapping bccMapping in Children.FilterByType <ElementMapping, AttributeOrSimpleElementOrComplexElementToBccMapping>())
     {
         IAcc acc = bccMapping.Acc;
         if (targetACC.Id == acc.Id)
         {
             yield return(bccMapping);
         }
     }
 }
 private static IAscc GetAscc(IAcc acc, string name)
 {
     foreach (IAscc ascc in acc.Asccs)
     {
         if (name == NDR.GenerateASCCName(ascc))
         {
             return(ascc);
         }
     }
     return(null);
 }
 public IEnumerable <ComplexElementToAsccMapping> AsccMappings(IAcc targetACC)
 {
     foreach (ComplexElementToAsccMapping asccMapping in Children.FilterByType <ElementMapping, ComplexElementToAsccMapping>())
     {
         IAcc acc = asccMapping.Acc;
         if (targetACC.Id == acc.Id)
         {
             yield return(asccMapping);
         }
     }
 }
        ///<summary>
        ///</summary>
        ///<param name="acc">
        ///</param>
        ///<param name="asbieName">
        ///</param>
        ///<param name="associatedAbie">
        ///</param>
        ///<returns>
        ///</returns>
        private static AsbieSpec MatchAsbieToAscc(IAcc acc, string asbieName, IAbie associatedAbie)
        {
            foreach (IAscc ascc in acc.Asccs)
            {
                if (ascc.Name.Equals(asbieName))
                {
                    return(AsbieSpec.CloneAscc(ascc, asbieName, associatedAbie));
                }
            }

            return(null);
        }
Exemple #9
0
 public static AccSpec CloneAcc(IAcc acc)
 {
     return(new AccSpec
     {
         Name = acc.Name,
         IsEquivalentTo = acc.IsEquivalentTo,
         Bccs = new List <BccSpec>(acc.Bccs.Convert(o => BccSpec.CloneBcc(o))),
         Asccs = new List <AsccSpec>(acc.Asccs.Convert(o => AsccSpec.CloneAscc(o))),
         BusinessTerms = new List <string>(acc.BusinessTerms),
         Definition = acc.Definition,
         LanguageCode = acc.LanguageCode,
         VersionIdentifier = acc.VersionIdentifier,
         UsageRules = new List <string>(acc.UsageRules),
     });
 }
Exemple #10
0
        public void LoadASCCs(ICctsRepository repository, IDictionary <string, cBIELibrary> biels)
        {
            // TODO: temporarily disabled to forace ASCCs
            //if (!HasASCCs())
            //{
            ASCCs.Clear();

            IAcc acc = repository.GetAccById(Id);

            foreach (IAscc ascc in acc.Asccs)
            {
                IDictionary <string, cABIE> relevantABIEs = new Dictionary <string, cABIE>();

                foreach (cBIELibrary biel in biels.Values)
                {
                    foreach (cABIE abie in biel.ABIEs.Values)
                    {
                        if (abie.BasedOn == ascc.AssociatedAcc.Id)
                        {
                            relevantABIEs.Add(abie.Name, new cABIE(abie.Name, abie.Id, abie.BasedOn));
                        }
                    }
                }

                if (relevantABIEs.Count > 0)
                {
                    if (!(ascc.Name.Equals("")))
                    {
                        if (!ASCCs.ContainsKey(ascc.Name))
                        {
                            //todo: change Checkstate to real state of potential ASBIE
                            ASCCs.Add(ascc.Name, new cASCC(ascc.Name, ascc.Id, CheckState.Unchecked, relevantABIEs));
                        }
                        else
                        {
                            throw new CacheException("The wizard encountered two ASCCs having identical target role names. Please make sure that all ASCCs for a particular ACC have unique target role names before proceeding with the wizard.");
                        }
                    }
                    else
                    {
                        throw new CacheException("The wizard encountered an association whose target role name is not set properly. Please make sure that all ASCC's target names are set properly before proceeding with the wizard.");
                    }
                }
            }
            //}
        }
        private IBcc GetBcc(IAcc acc, string name)
        {
            List <IBcc> bccsForAcc;

            if (!bccsByAccId.TryGetValue(acc.Id, out bccsForAcc))
            {
                bccsForAcc          = new List <IBcc>(acc.Bccs);
                bccsByAccId[acc.Id] = bccsForAcc;
            }
            foreach (IBcc bcc in bccsForAcc)
            {
                if (name == NDR.GenerateBCCName(bcc))
                {
                    return(bcc);
                }
            }
            return(null);
        }
        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);
        }
        public override bool ResolveTypeMapping(SchemaMapping schemaMapping)
        {
            ComplexTypeMapping complexTypeMapping = schemaMapping.GetComplexTypeMapping(SourceItem.XsdType);

            if (!complexTypeMapping.IsMappedToSingleACC)
            {
                throw new MappingError("Complex typed element '" + SourceItem.Path +
                                       "' mapped to ASCC, but the complex type is not mapped to a single ACC: TargetACCs: [" + string.Join(", ", complexTypeMapping.TargetACCs.Select(acc => acc.Name).ToArray()) + "], number of children mapped to ASMAs: " + complexTypeMapping.AsmaMappings.Count() + ".");
            }
            IAcc complexTypeACC = complexTypeMapping.TargetACCs.ElementAt(0);

            if (complexTypeACC.Id != Ascc.AssociatedAcc.Id)
            {
                throw new MappingError("Complex typed element '" + SourceItem.Path +
                                       "' mapped to ASCC with associated ACC other than the target ACC for the complex type.");
            }
            TargetMapping = complexTypeMapping;
            return(true);
        }
        public TargetElementStore(MapForceMapping mapForceMapping, ICcLibrary ccLibrary, ICctsRepository cctsRepository)
        {
            cache = CcCache.GetInstance(cctsRepository);

            IEnumerable <SchemaComponent> targetSchemaComponents = mapForceMapping.GetTargetSchemaComponents();

            foreach (SchemaComponent component in targetSchemaComponents)
            {
                Entry entry = component.RootEntry;

                IAcc acc = cache.GetCcFromCcLibrary(ccLibrary.Name, entry.Name);

                if (acc == null)
                {
                    throw new MappingError("ACC '" + entry.Name + "' not found.");
                }
                AddToIndex(entry, acc);
                CreateChildren(entry, acc);
            }
        }
        ///<summary>
        ///</summary>
        ///<param name="abie"></param>
        public static XmlSchemaAnnotation GetACCAnnotation(IAcc acc)
        {
            // Contains all the documentation items such as DictionaryEntryName
            IList <XmlNode> documentation = new List <XmlNode>();

            AddDocumentation(documentation, "UniqueID", acc.UniqueIdentifier);
            AddDocumentation(documentation, "VersionID", acc.VersionIdentifier);
            AddDocumentation(documentation, "ObjectClassQualifierName", getObjectClassQualifier(acc.Name));
            AddDocumentation(documentation, "ObjectClassTermName", getObjectClassTerm(acc.Name));
            AddDocumentation(documentation, "DictionaryEntryName", acc.DictionaryEntryName);
            AddDocumentation(documentation, "Definition", acc.Definition);
            AddDocumentation(documentation, "BusinessTermName", acc.BusinessTerms);
            AddDocumentation(documentation, "AcronymCode", "ACC");

            XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();

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

            return(annotation);
        }
Exemple #16
0
        public void LoadBCCsAndCreateDefaults(ICctsRepository repository, IDictionary <string, cBDTLibrary> bdtls)
        {
            if (!HasBCCs())
            {
                IAcc acc = repository.GetAccById(Id);

                foreach (IBcc bcc in acc.Bccs)
                {
                    if (BCCs.ContainsKey(bcc.Name))
                    {
                        BCCs.Clear();
                        throw new CacheException("The wizard encountered two BCCs within one ACC having identical names. Please verify your model!");
                    }

                    BCCs.Add(bcc.Name, new cBCC(bcc.Name, bcc.Id, bcc.Cdt.Id, CheckState.Unchecked));

                    BCCs[bcc.Name].BBIEs.Add(bcc.Name, new cBBIE(bcc.Name, -1, bcc.Cdt.Id, CheckState.Unchecked));

                    BCCs[bcc.Name].BBIEs[bcc.Name].SearchAndAssignRelevantBDTs(bcc.Cdt.Id, bdtls, CheckState.Unchecked);
                }
            }
        }
Exemple #17
0
 public UpccAscc(IUmlAssociation umlAssociation, IAcc associatingAcc)
 {
     UmlAssociation = umlAssociation;
     AssociatingAcc = associatingAcc;
 }
        private void ShouldContainTargetACCElement(TargetElementStore targetElementStore, string name, IAcc referencedAcc)
        {
            object targetCc = ShouldContainTargetCc(name, targetElementStore, referencedAcc);

            Assert.IsTrue(targetCc is IAcc);
            Assert.That(((IAcc)targetCc).Id, Is.EqualTo(referencedAcc.Id));
        }
Exemple #19
0
 public UpccBcc(IUmlAttribute umlAttribute, IAcc acc)
 {
     UmlAttribute = umlAttribute;
     Acc          = acc;
 }
Exemple #20
0
 public UpccBcc(IUmlAttribute umlAttribute, IAcc acc) : base(umlAttribute)
 {
     Acc = acc;
 }
 public UpccAscc(IUmlAssociation umlAssociation, IAcc associatingAcc) : base(umlAssociation, associatingAcc)
 {
 }
 /// <summary>
 /// Removes a ACC from this CCLibrary.
 /// <param name="acc">A ACC.</param>
 /// </summary>
 public void RemoveAcc(IAcc acc)
 {
     UmlPackage.RemoveClass(((UpccAcc)acc).UmlClass);
 }
 /// <summary>
 /// Updates a ACC to match the given <paramref name="specification"/>.
 /// <param name="acc">A ACC.</param>
 /// <param name="specification">A new specification for the given ACC.</param>
 /// <returns>The updated ACC. Depending on the implementation, this might be the same updated instance or a new instance!</returns>
 /// </summary>
 public IAcc UpdateAcc(IAcc acc, AccSpec specification)
 {
     return(new UpccAcc(UmlPackage.UpdateClass(((UpccAcc)acc).UmlClass, AccSpecConverter.Convert(specification))));
 }
 public void RemoveAcc(IAcc acc)
 {
     throw new NotImplementedException();
 }
 internal static XmlSchemaComplexType GenerateComplexTypeACC(GeneratorContext context, XmlSchema schema, IAcc acc)
 {
     return(GenerateComplexTypeACC(context, schema, acc, context.NamespacePrefix));
 }
 public ValuesController(IAcc acc)
 {
     this.acc = acc;
 }
        private static ComplexTypeMapping CreateComplexTypeMappingForChildMappings(IEnumerable <ElementMapping> childMappings, string complexTypeName, string sourceElementName)
        {
            IAcc targetAcc              = null;
            bool hasAsmaMapping         = false;
            bool hasMultipleAccMappings = false;

            if (childMappings.Count() == 0)
            {
                // complex type not mapped
                return(null);
            }

            foreach (ElementMapping child in childMappings)
            {
                if (child is AttributeOrSimpleElementOrComplexElementToBccMapping)
                {
                    if (targetAcc == null)
                    {
                        targetAcc = ((AttributeOrSimpleElementOrComplexElementToBccMapping)child).Acc;
                    }
                    else
                    {
                        if (targetAcc.Id != ((AttributeOrSimpleElementOrComplexElementToBccMapping)child).Acc.Id)
                        {
                            hasMultipleAccMappings = true;
                        }
                    }
                }

                if (child is ComplexElementToAsccMapping)
                {
                    if (targetAcc == null)
                    {
                        targetAcc = ((ComplexElementToAsccMapping)child).Acc;
                    }
                    else
                    {
                        if (targetAcc.Id != ((ComplexElementToAsccMapping)child).Acc.Id)
                        {
                            hasMultipleAccMappings = true;
                        }
                    }
                }

                if (child is AsmaMapping)
                {
                    hasAsmaMapping = true;
                }
            }

            bool hasAccMapping = targetAcc != null;

            if ((hasAccMapping) && (!hasMultipleAccMappings) && (!hasAsmaMapping))
            {
                // ACC
                return(new ComplexTypeToAccMapping(sourceElementName, complexTypeName, childMappings));
            }
            if ((!hasMultipleAccMappings && hasAsmaMapping) || ((hasAccMapping) && hasMultipleAccMappings))
            {
                // MA
                return(new ComplexTypeToMaMapping(sourceElementName, complexTypeName, childMappings));
            }
            throw new MappingError("Unexpected Mapping Error #375. Complex Type Name: " + complexTypeName);
        }
        internal static XmlSchemaComplexType GenerateComplexTypeACC(GeneratorContext context, XmlSchema schema, IAcc acc, string accPrefix)
        {
            // R A4CE, R AF95: a complex type must be defined for each ABIE
            XmlSchemaComplexType complexTypeACC = new XmlSchemaComplexType();

            // R 9D83: the name of the ABIE must be the DictionaryEntryName with all whitespace and separators
            //         removed. The 'Details' suffix is replaced with 'Type'.
            complexTypeACC.Name = acc.Name + "Type";

            if (context.Annotate)
            {
                complexTypeACC.Annotation = GetACCAnnotation(acc);
            }

            // create the sequence for the BBIEs within the ABIE
            XmlSchemaSequence sequenceBCCs = new XmlSchemaSequence();

            foreach (IBcc bcc in acc.Bccs.OrderBy(a => a.Name))
            {
                // R 89A6: for every BBIE a named element must be locally declared
                XmlSchemaElement elementBCC = new XmlSchemaElement();

                // R AEFE, R 96D9, R9A40, R A34A are implemented in GetXsdElementNameFromBbie(...)
                elementBCC.Name = NDR.GenerateBCCName(bcc);

                // R 8B85: every BBIE type must be named the property term and qualifiers and the
                //         representation term of the basic business information entity (BBIE) it represents
                //         with the word 'Type' appended.
                elementBCC.SchemaTypeName =
                    new XmlQualifiedName(NSPREFIX_CDT + ":" + bcc.Cdt.Name + bcc.Cdt.Con.BasicType.Name + "Type");


                // R 90F9: cardinality of elements within the ABIE
                elementBCC.MinOccursString = AdjustLowerBound(bcc.LowerBound);
                elementBCC.MaxOccursString = AdjustUpperBound(bcc.UpperBound);

                if (context.Annotate)
                {
                    elementBCC.Annotation = GetBCCAnnotation(bcc);
                }

                // add the element created to the sequence
                sequenceBCCs.Items.Add(elementBCC);
            }


            foreach (IAscc ascc in acc.Asccs.OrderBy(a => a.Name))
            {
                XmlSchemaElement elementASCC = new XmlSchemaElement();

                // R A08A: name of the ASBIE
                elementASCC.Name           = NDR.GenerateASCCName(ascc);
                elementASCC.SchemaTypeName =
                    new XmlQualifiedName(accPrefix + ":" + ascc.AssociatedAcc.Name + "Type");

                if (context.Annotate)
                {
                    elementASCC.Annotation = GetASCCAnnotiation(ascc);
                }

                // R 9241: for ASBIEs with AggregationKind = shared a global element must be declared.
                // ASCCs are always shared (as defined in UPCC)
                XmlSchemaElement refASCC = new XmlSchemaElement();
                refASCC.RefName = new XmlQualifiedName(accPrefix + ":" + elementASCC.Name);

                // every shared ASCC may only appear once in the XSD file
                if (!globalASCCs.Contains(elementASCC.Name))
                {
                    schema.Items.Add(elementASCC);
                    globalASCCs.Add(elementASCC.Name);
                }
                sequenceBCCs.Items.Add(refASCC);
            }

            // add the sequence created to the complex type
            complexTypeACC.Particle = sequenceBCCs;
            return(complexTypeACC);
        }
 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);
             }
         }
     }
 }
 public IAcc UpdateAcc(IAcc element, AccSpec spec)
 {
     throw new NotImplementedException();
 }