Esempio n. 1
0
 public WordLink(RelationItem anItem, WordItem sChild)
 {
     m_sChild      = new RegistryWord(sChild);
     m_bAuto       = anItem.IsAuto;
     m_eLinkType   = (WordLinkType)anItem.RelationType;
     m_nRelGroupId = (short?)anItem.RelationTypeGroup;
 }
Esempio n. 2
0
        public void AddTotbl_RelationsTest()
        {
            SemanticDBEntities target       = new SemanticDBEntities(); // TODO: Initialize to an appropriate value
            RelationItem       relationItem = null;                     // TODO: Initialize to an appropriate value

            target.AddTotbl_RelationItems(relationItem);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
Esempio n. 3
0
        public void ChildIdTest()
        {
            RelationItem target   = new RelationItem(); // TODO: Initialize to an appropriate value
            int          expected = 0;                  // TODO: Initialize to an appropriate value
            int          actual;

            target.ChildId = expected;
            actual         = target.ChildId;
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Esempio n. 4
0
        public void RelationTypeGroupTest()
        {
            RelationItem     target   = new RelationItem();     // TODO: Initialize to an appropriate value
            Nullable <short> expected = new Nullable <short>(); // TODO: Initialize to an appropriate value
            Nullable <short> actual;

            target.RelationTypeGroup = expected;
            actual = target.RelationTypeGroup;
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Esempio n. 5
0
        public void IsAutoTest()
        {
            RelationItem target   = new RelationItem(); // TODO: Initialize to an appropriate value
            bool         expected = false;              // TODO: Initialize to an appropriate value
            bool         actual;

            target.IsAuto = expected;
            actual        = target.IsAuto;
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Esempio n. 6
0
        public void CreateRelationItemTest()
        {
            int          parentId = 0;     // TODO: Initialize to an appropriate value
            int          childId  = 0;     // TODO: Initialize to an appropriate value
            bool         isAuto   = false; // TODO: Initialize to an appropriate value
            RelationItem expected = null;  // TODO: Initialize to an appropriate value
            RelationItem actual;

            actual = RelationItem.CreateRelationItem(parentId, childId, isAuto, (short)RelationType.Normal, 0);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Esempio n. 7
0
        public void GetItemTest()
        {
            PrivateObject           param0 = null;                                // TODO: Initialize to an appropriate value
            DatabaseHelper_Accessor target = new DatabaseHelper_Accessor(param0); // TODO: Initialize to an appropriate value
            string       sParent           = string.Empty;                        // TODO: Initialize to an appropriate value
            string       sChild            = string.Empty;                        // TODO: Initialize to an appropriate value
            RelationItem expected          = null;                                // TODO: Initialize to an appropriate value
            RelationItem actual;

            actual = target.GetRelationItem(sParent, sChild);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Esempio n. 8
0
        public void AddRelationTest()
        {
            string sConnectionString = string.Empty;                                                     // TODO: Initialize to an appropriate value

            DatabaseHelper.DatabaseHelper target = new DatabaseHelper.DatabaseHelper(sConnectionString); // TODO: Initialize to an appropriate value
            string       sParent     = string.Empty;                                                     // TODO: Initialize to an appropriate value
            string       sChild      = string.Empty;                                                     // TODO: Initialize to an appropriate value
            bool         isTentative = false;                                                            // TODO: Initialize to an appropriate value
            RelationItem expected    = null;                                                             // TODO: Initialize to an appropriate value
            RelationItem actual;

            actual = target.AddRelation(sParent, sChild, RelationType.Normal, 0);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Esempio n. 9
0
 /// <summary>
 /// обновляет или добавляет связи в БД для данной семантической ветви
 /// </summary>
 /// <param name="aLink">семантическая ветвь, данные о которой надо добавить или обновить</param>
 public void UpdateRelations(WordSemanticBranch aLink)
 {
     foreach (WordLink link in aLink.Children)
     {
         RelationItem anItem = m_dbHelper.GetRelationItem(aLink.ParentWord.Word, link.Child.Word);
         if (anItem == null)
         {
             m_dbHelper.AddRelation(aLink.ParentWord.Word, link.Child.Word, (RelationType)link.RelationType, link.RelationGroupId);
         }
         else
         {
             anItem.RelationType      = (short)link.RelationType;
             anItem.RelationTypeGroup = link.RelationGroupId;
             m_dbHelper.UpdateRelation(anItem);
         }
     }
 }
Esempio n. 10
0
        public static ItemViewModel GetItemViewModel(RelationItem relationItem)
        {
            switch (relationItem.Item)
            {
            case Product p:
                return(new ProductViewModel(relationItem));

            case Module m:
                return(new ModuleViewModel(relationItem));

            case Block b:
                return(new BlockViewModel(relationItem));

            default:
                throw new ArgumentException("Could determine RelationItem");
            }
        }
Esempio n. 11
0
        public static RelationItem RetrieveRelationItem(this ApiController apiController, HttpRequestMessage request, Guid id, Relation relation)
        {
            var          getRelationItem = new GetObject <RelationItem>();
            RelationItem relationItem    = getRelationItem.Execute(id);

            if (relationItem == null)
            {
                var response = request.CreateErrorResponse(HttpStatusCode.NotFound, String.Format("Relation item with id '{0}' does not exist", id));
                throw new HttpResponseException(response);
            }

            if (relationItem.RelationId != relation.Id)
            {
                var response = request.CreateErrorResponse(
                    HttpStatusCode.BadRequest,
                    String.Format("Relation item with id '{0}' does not belong to the relation with id '{1}'", relationItem.Id, relation.Id));
                throw new HttpResponseException(response);
            }

            return(relationItem);
        }
Esempio n. 12
0
        /// <summary>
        /// находит все исходные формы слова
        /// </summary>
        /// <param name="sParent">слово родитель</param>
        /// <param name="sAnyFormWord">слово из правой части словарной статьи</param>
        /// <param name="explChannel">канал толкового словаря</param>
        /// <param name="relGroupId">номер группы отношений. используется если одно слово имеет несколько равнозначных исходных форм</param>
        /// <returns>список потомков с снайденным типом связи</returns>
        List <WordLink> GetChildren(string sParent, string sAnyFormWord, IExplDic explChannel, short relGroupId)
        {
            Ilib5           wordFormsChannel = null;
            List <WordLink> listChildren     = null;

            try
            {
                listChildren = new List <WordLink>();
                if (sAnyFormWord.Length == 0)
                {
                    return(listChildren);
                }

                wordFormsChannel = CreateWordFormsChannel();

                WordUniAndPartAndOmon[] forms = wordFormsChannel.getAllFirstWFormsWithParts(sAnyFormWord);

                foreach (WordUniAndPartAndOmon form in forms)
                {
                    string s             = form.part;
                    string sOriginalForm = form.forma;
                    if (IsNoun(form.part))
                    {
                        sOriginalForm = RemoveAccents(sOriginalForm);
                        if (sOriginalForm.Length > 0)
                        {
                            //can this be equal to zero?
                            int nVal = explChannel.ExplCheckReestr(sOriginalForm, form.omon, m_LsId);
                            if (nVal < 0 && form.omon != 0)
                            {
                                nVal          = explChannel.ExplCheckReestr(sOriginalForm, 0, m_LsId);
                                sOriginalForm = RegistryWord.CreateNameWithHomonym(sOriginalForm, string.Empty);
                            }
                            else
                            {
                                sOriginalForm = RegistryWord.CreateNameWithHomonym(sOriginalForm, form.omon == 0 ? string.Empty : form.omon.ToString());
                            }

                            lock (m_dbHelper)
                            {
                                RelationItem newItem = m_dbHelper.GetRelationItem(sParent, sOriginalForm);
                                if (newItem == null)
                                {
                                    RelationType relType = (nVal < 0) ? RelationType.Absent : (listChildren.Count > 0 ? RelationType.Tentative : RelationType.Normal);
                                    newItem = m_dbHelper.AddRelation(sParent, sOriginalForm, relType, relGroupId);
                                }
                                WordItem aWord = m_dbHelper.GetWord(sOriginalForm);
                                WordLink aLink = new WordLink(newItem, aWord);
                                if (!listChildren.Contains(aLink))
                                {
                                    listChildren.Add(aLink);
                                }
                            }
                        }
                    }
                }

                ((IClientChannel)wordFormsChannel).Close();
            }
            catch (Exception ex)
            {
                if (wordFormsChannel != null)
                {
                    ((IClientChannel)wordFormsChannel).Abort();
                }
                MessageBox.Show(string.Format("{0} {1}", "GetChildren", ex.Message));
            }

            return(listChildren);
        }
        public void TryGetRelationAddresses()
        {
            IContactAgent agent = ContactAgentFactory.CreateContactAgent();

            List <DocumentItem>         documentItemsSaved;
            List <AddressItem>          addressItemsSaved;
            RelationItem                relationItemSaved;
            List <RelationAddressItem>  relationAddressItemsSaved;
            List <RelationDocumentItem> relationDocumentItemsSaved;
            List <CountryItem>          countryItemsSaved;

            AddressItem[] addressItems;
            int           count = 0;

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    Debug.WriteLine("Creating all objects on " + DateTime.Now);
                    List <AddressItem>          addressItemsNew          = GetAddressItems(2);
                    List <CountryItem>          countryItemsNew          = GetCountryItems(2);
                    List <DocumentItem>         documentItemsNew         = GetDocumentItems(2);
                    RelationItem                relationItemNew          = GetRelationItem();
                    List <RelationAddressItem>  relationAddressItemsNew  = GetRelationAddressItems(2);
                    List <RelationDocumentItem> relationDocumentItemsNew = GetRelationDocumentItems(2);

                    Debug.WriteLine("All objects in memory on {0}", DateTime.Now);

                    Debug.WriteLine("Saving all objects");

                    count             = countryItemsNew.Count;
                    countryItemsSaved = new List <CountryItem>(count);
                    Debug.WriteLine("Saving countries objects");
                    for (int i = 0; i < count; i++)
                    {
                        CountryItem countryItemSaved = agent.SaveCountryItem(countryItemsNew[i]);
                        Debug.WriteLine("CountryItem {0} / {1} saved {2}on {3}", (i + 1), count, (countryItemSaved.HasErrors ? "with errors " : ""), DateTime.Now);
                        countryItemsSaved.Add(countryItemSaved);
                    }

                    count = documentItemsNew.Count;
                    documentItemsSaved = new List <DocumentItem>(count);
                    Debug.WriteLine("Saving documents objects");
                    for (int i = 0; i < count; i++)
                    {
                        DocumentItem documentItemSaved = agent.SaveDocumentItem(documentItemsNew[i]);
                        Debug.WriteLine("DocumentItem {0} / {1} saved {2}on {3}", (i + 1), count, (documentItemSaved.HasErrors ? "with errors " : ""), DateTime.Now);
                        documentItemsSaved.Add(documentItemSaved);
                    }

                    relationItemSaved = agent.SaveRelationItem(relationItemNew);
                    Debug.WriteLine("AddressItem saved {0}on {1}", (relationItemSaved.HasErrors ? "with errors " : ""), DateTime.Now);

                    count             = addressItemsNew.Count;
                    addressItemsSaved = new List <AddressItem>(count);
                    Debug.WriteLine("Saving addresses objects");
                    for (int i = 0; i < count; i++)
                    {
                        AddressItem addressItemSaved = agent.SaveAddressItem(addressItemsNew[i]);
                        Debug.WriteLine("CountryItem {0} / {1} saved {2}on {3}", (i + 1), count, (addressItemSaved.HasErrors ? "with errors " : ""), DateTime.Now);
                        addressItemsSaved.Add(addressItemSaved);
                    }

                    count = relationAddressItemsNew.Count;
                    relationAddressItemsSaved = new List <RelationAddressItem>(count);
                    Debug.WriteLine("Saving RelationAddress objects");
                    for (int i = 0; i < count; i++)
                    {
                        RelationAddressItem relationAddressItemSaved = agent.SaveRelationAddressItem(relationAddressItemsNew[i]);
                        Debug.WriteLine("RelationAddressItem {0} / {1} saved {2}on {3}", (i + 1), count, (relationAddressItemSaved.HasErrors ? "with errors " : ""), DateTime.Now);
                        relationAddressItemsSaved.Add(relationAddressItemSaved);
                    }

                    count = relationDocumentItemsNew.Count;
                    relationDocumentItemsSaved = new List <RelationDocumentItem>(count);
                    Debug.WriteLine("Saving RelationDocument objects");
                    for (int i = 0; i < count; i++)
                    {
                        RelationDocumentItem relationDocumentItemSaved = agent.SaveRelationDocumentItem(relationDocumentItemsNew[i]);
                        Debug.WriteLine("RelationDocumentItem {0} / {1} saved {2}on {3}", (i + 1), count, (relationDocumentItemSaved.HasErrors ? "with errors " : ""), DateTime.Now);
                        relationDocumentItemsSaved.Add(relationDocumentItemSaved);
                    }

                    Debug.WriteLine("All objects saved");

                    Debug.WriteLine("Before commiting transaction");
                    scope.Complete();
                    Debug.WriteLine("Commit transaction completed");
                }
                addressItems = agent.GetAddressItemsForRelation(ContactTestFixtureData.Keys.Relation[1]);
            }
            catch (Exception e)
            {
                Debug.WriteLine("Error(s) occured\n" + e.Message);
            }
        }
Esempio n. 14
0
 public ProductViewModel(RelationItem relationItem) : base(relationItem)
 {
 }
 public ItemViewModel(RelationItem relationItem)
 {
     RelationItem = relationItem;
     ItemModel    = RelationItem.Item;
 }
 public BlockViewModel(RelationItem relationItem) : base(relationItem)
 {
 }
Esempio n. 17
0
        public void RelationItemConstructorTest()
        {
            RelationItem target = new RelationItem();

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
Esempio n. 18
0
        public ContainerViewModel(RelationItem relationItem) : base(relationItem)
        {
            ContainerModel = relationItem.Item as Container;

            ItemViewModels = new ObservableCollection <ItemViewModel>(ContainerModel.ContainerItems.Select(i => ItemViewModelFactory.GetItemViewModel(i)));
        }
 public ModuleViewModel(RelationItem relationItem) : base(relationItem)
 {
 }