Ejemplo n.º 1
0
        private static SearchItem CreateSearchItemFromPropertyNode(XmlNode node, string proposedType)
        {
            SearchItem res  = null;
            var        irdi = EclassUtils.GetAttributeByName(node, "id");

            if (irdi == null)
            {
                irdi = EclassUtils.GetAttributeByName(node, "xml:id");
            }
            if (irdi != null)
            {
                var info = "";
                if (node.Name == "ontoml:property" && node.HasChildNodes)
                {
                    var n2 = node.SelectSingleNode("preferred_name");
                    if (n2 != null && n2.HasChildNodes)
                    {
                        foreach (var c2 in n2.ChildNodes)
                        {
                            if (c2 is XmlNode && (c2 as XmlNode).Name == "label")
                            {
                                info = (c2 as XmlNode).InnerText;
                            }
                        }
                    }
                    proposedType = "prop";
                }
                res = new SearchItem(proposedType, irdi, info, node);
            }
            return(res);
        }
Ejemplo n.º 2
0
        private void ButtonSelect_Click(object sender, RoutedEventArgs e)
        {
            if (CheckBoxTwoPass.IsChecked != true)
            {
                // trivial case, take directly
                if (FinalizeSelection())
                {
                    this.DialogResult = true;
                }
                return;
            }

            // OK, search for IRDI first
            var si = EntityList.SelectedItem as EclassUtils.SearchItem;

            if (si != null && si.Entity == "prop" && si.ContentNode != null)
            {
                var irdi = EclassUtils.GetAttributeByName(si.ContentNode, "id");
                if (irdi != null)
                {
                    if (!worker.IsBusy && eclassFullPath != null)
                    {
                        SearchProgress.Value = 0;
                        EntityList.Items.Clear();
                        EntityContent.Text = "";

                        var args = new BackgroundWorkerArgs();
                        args.jobData = InitJobData();
                        args.jobData.searchIRDIs.Add(irdi.Trim().ToLower());
                        args.jobType = 2;

                        worker.RunWorkerAsync(args);
                    }
                }
            }
        }
        private bool FinalizeSelection(EclassUtils.SearchItem si, bool twoPass)
        {
            // access
            if (si == null)
            {
                return(false);
            }

            // simply put the IRDI
            DiaData.ResultIRDI = si.IRDI;

            // special case: unit .. try correct from unit id to unitCodeValue for IRDI
            if (si.Entity == "unit")
            {
                var x = EclassUtils.GetIrdiForUnitSearchItem(si);
                if (x != null)
                {
                    DiaData.ResultIRDI = x;
                }
            }

            // one or two passes?
            if (!twoPass)
            {
                // special case: property selected
                if (si.Entity == "prop" && DiaData.Mode != AnyUiDialogueDataSelectEclassEntity.SelectMode.IRDI)
                {
                    var input = new List <EclassUtils.SearchItem>();
                    input.Add(si);
                    foreach (EclassUtils.SearchItem di in EntityList.Items)
                    {
                        if (di != null && di.Entity == si.Entity && di.IRDI == si.IRDI && si != di)
                        {
                            input.Add(di);
                        }
                    }

                    // own function
                    DiaData.ResultCD = EclassUtils.GenerateConceptDescription(input, si.IRDI);
                }
            }
            else
            {
                if (si.Entity == "prop" && si.ContentNode != null)
                {
                    var irdi = EclassUtils.GetAttributeByName(si.ContentNode, "id");
                    if (irdi != null)
                    {
                        if (!worker.IsBusy && eclassFullPath != null)
                        {
                            SearchProgress.Value = 0;
                            EntityList.Items.Clear();
                            EntityContent.Text = "";

                            var args = new BackgroundWorkerArgs();
                            args.jobData = InitJobData();
                            args.jobData.searchIRDIs.Add(irdi.Trim().ToLower());
                            args.jobType = 2;

                            // start second pass!
                            worker.RunWorkerAsync(args);
                            return(false);
                        }
                    }
                }
            }

            // generally ok
            return(true);
        }