Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AdminWebLimitationAddOrEditKeywordWindow"/> class.
 /// </summary>
 /// <param name="keyword">Keyword.</param>
 public AdminWebLimitationAddOrEditKeywordWindow(IKeyword keyword)
     : this()
 {
     this.keyword      = keyword;
     this.Title        = "Kulcsszó szerkesztése";
     this.txtName.Text = this.keyword.Name;
 }
Esempio n. 2
0
        /// <summary>
        /// Get the Keyword
        /// </summary>
        /// <param name="node">Configuration node</param>
        /// <param name="handler">Orquestation</param>
        /// <returns>Keyword Object</returns>
        public IKeyword GetXOMLKeyword(XmlNode node, OwlHandler handler)
        {
            if (node == null)
            {
                return(null);
            }

            #region Instancia

            // Para las instancias solo se permite Predeterminado, Variable y Reservada
            if (handler.Settings.Instance && (node.Name != "default" && node.Name != "variable" && node.Name != "key"))
            {
                return(null);
            }

            #endregion

            #region Value

            var className = node.Name.XOMLName();
            if (KeywordsList.Contains(className))
            {
                IXOMLObject keywordInstance = (IXOMLObject)Activator.CreateInstance(Type.GetType(string.Format("Fiive.Owl.Core.Keywords.{0}", className)));
                IKeyword    keyword         = (IKeyword)handler.XOMLValidator.GetXOMLObject(keywordInstance, node, handler);

                KeywordsType keywordType = (KeywordsType)Enum.Parse(typeof(KeywordsType), className);
                keyword.KeywordType = keywordType;
                return(keyword);
            }

            #endregion

            return(null);
        }
Esempio n. 3
0
 public void AddOption(IKeyword keyword)
 {
     AddFollowupOptions(new List <IKeyword>()
     {
         keyword
     });
 }
Esempio n. 4
0
        public IKeyword FlushKeyword()
        {
            IKeyword flushedKeyword = KeywordMatchService.GetCompletelyMatched();

            Clear();
            return(flushedKeyword);
        }
        public bool TryGetKeyword(string categoryUriToLookIn, string keywordName, out IKeyword keyword)
        {
            using (var client = new TridionBrokerServiceClient())
            {
                string result = client.GetKeywordHierarchy(categoryUriToLookIn, keywordName);
                if (!string.IsNullOrEmpty(result))
                {
                    XElement keyWord  = XElement.Parse(result);
                    var      tkeyword = new Keyword()
                    {
                        Id         = keyWord.Element("Uri").Value,
                        Title      = keyWord.Element("KeywordName").Value,
                        TaxonomyId = keyWord.Element("TaxonomyUri").Value
                    };
                    foreach (XElement parentElement in keyWord.Element("ParentKeywords").Elements())
                    {
                        tkeyword.ParentKeywords.Add(
                            new Keyword
                        {
                            Id         = parentElement.Attribute("Uri").Value,
                            Title      = parentElement.Value,
                            TaxonomyId = parentElement.Attribute("TaxonomyUri").Value
                        }
                            );
                    }
                    keyword = tkeyword;
                    return(true);
                }
            }

            keyword = null;
            return(false);
        }
        public bool TryGetKeyword(string categoryUriToLookIn, string keywordName, out IKeyword keyword)
        {
            using (var client = new TridionBrokerServiceClient())
            {
                string result = client.GetKeywordHierarchy(categoryUriToLookIn, keywordName);
                if (!string.IsNullOrEmpty(result))
                {
                    XElement keyWord = XElement.Parse(result);
                    var tkeyword = new Keyword()
                    {
                        Id = keyWord.Element("Uri").Value,
                        Title = keyWord.Element("KeywordName").Value,
                        TaxonomyId = keyWord.Element("TaxonomyUri").Value
                    };
                    foreach (XElement parentElement in keyWord.Element("ParentKeywords").Elements())
                    {
                        tkeyword.ParentKeywords.Add(
                            new Keyword
                            {
                                Id = parentElement.Attribute("Uri").Value,
                                Title = parentElement.Value,
                                TaxonomyId = parentElement.Attribute("TaxonomyUri").Value
                            }
                        );
                    }
                    keyword = tkeyword;
                    return true;
                }
            }

            keyword = null;
            return false;
        }
Esempio n. 7
0
        public override IEnumerable GetPropertyValues(IModel modelData, IModelProperty property, IViewModelFactory factory)
        {
            IEnumerable result = null;

            if (modelData != null && modelData is IKeyword)
            {
                result = new IKeyword[] { modelData as IKeyword };
            }
            return(result);
        }
 public bool TryGetKeyword(string categoryUriToLookIn, string keywordName, out IKeyword keyword)
 {
     keyword = null;
     try
     {
         keyword = TaxonomyProvider.GetKeyword(categoryUriToLookIn, keywordName);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        public static object Build(IKeyword source, Type targetType)
        {
            var destinationModel = Activator.CreateInstance(targetType);
            var obj = FieldSetMapper.Build(source.MetadataFields, destinationModel, source);

            if (obj is IKeywordBase)
            {
                obj.GetType().GetProperty("KeywordId").SetValue(obj, source.Id, null);
                obj.GetType().GetProperty("KeywordValue").SetValue(obj, source.Title, null);
                obj.GetType().GetProperty("KeywordKey").SetValue(obj, source.Key, null);
            }
            return(obj);
        }
Esempio n. 10
0
 public bool TryGetKeyword(string categoryUriToLookIn, string keywordName, out IKeyword keyword)
 {
     keyword = null;
     try
     {
         keyword = TaxonomyProvider.GetKeyword(categoryUriToLookIn, keywordName);
         return true;
     }
     catch
     {
         return false;
     }
 }
        public static T Build <T>(IKeyword source) where T : new()
        {
            var destinationModel = new T();
            var obj = (T)FieldSetMapper.Build(source.MetadataFields, destinationModel, source);

            if (obj is IKeywordBase)
            {
                obj.GetType().GetProperty("KeywordId").SetValue(obj, source.Id, null);
                obj.GetType().GetProperty("KeywordValue").SetValue(obj, source.Title, null);
                obj.GetType().GetProperty("KeywordKey").SetValue(obj, source.Key, null);
            }
            return(obj);
        }
Esempio n. 12
0
        public void TestReadKeyword()
        {
            IKeyword v = Reader("\"~:foo\"").Read <IKeyword>();

            Assert.AreEqual("foo", v.ToString());

            IReader r  = Reader("[\"~:foo\",\"^" + (char)WriteCache.BaseCharIdx + "\",\"^" + (char)WriteCache.BaseCharIdx + "\"]");
            IList   v2 = r.Read <IList>();

            Assert.AreEqual("foo", v2[0].ToString());
            Assert.AreEqual("foo", v2[1].ToString());
            Assert.AreEqual("foo", v2[2].ToString());
        }
Esempio n. 13
0
        public void TestKeywordHashCode()
        {
            string s = "foo";

            IKeyword k1     = TransitFactory.Keyword("foo");
            IKeyword k2     = TransitFactory.Keyword("!foo".Substring(1));
            IKeyword k3     = TransitFactory.Keyword("bar");
            ISymbol  symbol = TransitFactory.Symbol("bar");

            Assert.AreEqual(k1.GetHashCode(), k2.GetHashCode());
            Assert.IsFalse(k3.GetHashCode() == k1.GetHashCode());
            Assert.IsFalse(symbol.GetHashCode() == k1.GetHashCode());
            Assert.IsFalse(s.GetHashCode() == k1.GetHashCode());
        }
Esempio n. 14
0
        public void TestSymbolHashCode()
        {
            string s = "foo";

            ISymbol  sym1    = TransitFactory.Symbol("foo");
            ISymbol  sym2    = TransitFactory.Symbol("!foo".Substring(1));
            ISymbol  sym3    = TransitFactory.Symbol("bar");
            IKeyword keyword = TransitFactory.Keyword("bar");

            Assert.AreEqual(sym1.GetHashCode(), sym2.GetHashCode());
            Assert.IsFalse(sym3.GetHashCode() == sym1.GetHashCode());
            Assert.IsFalse(keyword.GetHashCode() == sym1.GetHashCode());
            Assert.IsFalse(s.GetHashCode() == sym1.GetHashCode());
        }
        /// <summary>
        /// Convert.
        /// </summary>
        /// <param name="value">Value.</param>
        /// <param name="targetType">Target type.</param>
        /// <param name="parameter">Parameter.</param>
        /// <param name="culture">Culture.</param>
        /// <returns>Grouping.</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            IKeyword keyword = value as IKeyword;

            this.viewModel = ViewModel.Get();
            var webLimits = this.viewModel.SelectedManagedUser != null?this.viewModel.BL.Database.ReadWebLimitations(x => x.UserID == this.viewModel.SelectedManagedUser.ID && x.KeywordID == keyword.ID) : null;

            if (webLimits != null && keyword != null && webLimits.Where(x => x.KeywordID == keyword.ID).Any())
            {
                return("Tiltott");
            }

            return("Nem tiltott");
        }
Esempio n. 16
0
        public void TestKeywordEquality()
        {
            string s = "foo";

            IKeyword k1 = TransitFactory.Keyword("foo");
            IKeyword k2 = TransitFactory.Keyword("!foo".Substring(1));
            IKeyword k3 = TransitFactory.Keyword("bar");

            Assert.AreEqual(k1, k2);
            Assert.AreEqual(k2, k1);
            Assert.IsFalse(k1.Equals(k3));
            Assert.IsFalse(k3.Equals(k1));
            Assert.IsFalse(s.Equals(k1));
            Assert.IsFalse(k1.Equals(s));
        }
Esempio n. 17
0
        public void TestWriteKeyword()
        {
            Assert.AreEqual(ScalarVerbose("\"~:foo\""), WriteJsonVerbose(TransitFactory.Keyword("foo")));
            Assert.AreEqual(Scalar("\"~:foo\""), WriteJson(TransitFactory.Keyword("foo")));

            IList l = new IKeyword[]
            {
                TransitFactory.Keyword("foo"),
                TransitFactory.Keyword("foo"),
                TransitFactory.Keyword("foo")
            };

            Assert.AreEqual("[\"~:foo\",\"~:foo\",\"~:foo\"]", WriteJsonVerbose(l));
            Assert.AreEqual("[\"~:foo\",\"^0\",\"^0\"]", WriteJson(l));
        }
Esempio n. 18
0
        public override IEnumerable GetPropertyValues(IKeyword keyword, Type propertyType, IViewModelFactory builder)
        {
            IEnumerable value;

            if (propertyType == typeof(TcmUri))
            {
                value = new[] { new TcmUri(keyword.Id) }
            }
            ;
            else
            {
                value = new[] { keyword.Id }
            };

            return(value);
        }
Esempio n. 19
0
        public override object DoRun()
        {
            if (_keyword == null)
            {
                _keyword = ParseInstruction(_instruction, Interpreter);
            }

            var tech         = (_keyword as IHasTechnique);
            var oldTechnique = tech.Technique;

            tech.Technique = Technique.Show;

            var childAnswer = _keyword.Execute() as IInformativeAnswer;

            tech.Technique = oldTechnique;
            return(new SuccessAnswer("Done.").With(childAnswer));
        }
Esempio n. 20
0
        protected string ValidateInlineXOML(string value, OwlHandler handler)
        {
            string[] parts = value.Split(new char[] { ':' }, 2);
            if (parts.Length == 1)
            {
                return(value);
            }
            else
            {
                IKeyword keyword = handler.KeywordsManager.GetInlineKeyword(parts, handler);
                if (keyword != null)
                {
                    return(keyword.GetValue(handler));
                }
            }

            return(value);
        }
Esempio n. 21
0
        internal static object Build(IFieldSet fields, object destinationModel, IKeyword source, IPage page = null)
        {
            var type       = destinationModel.GetType();
            var properties = type.GetProperties();

            foreach (var property in properties)
            {
                var attributes = property.GetCustomAttributes(true);
                foreach (var attr in attributes)
                {
                    var tridionAttribute = attr as ITridionViewModelPropertyAttribute;
                    if (tridionAttribute == null)
                    {
                        continue;
                    }

                    TrySetAllValues(fields, destinationModel, tridionAttribute, property, page);
                }
            }

            return(destinationModel);
        }
Esempio n. 22
0
        private void keywordsListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            resultsListView.Items.Clear();
            _results.Clear();

            if (indexListView.SelectedIndices.Count <= 0)
            {
                return;
            }
            int index = indexListView.SelectedIndices[0];

            _helpKeywords.MoveTo(index);
            IKeyword keyword = (IKeyword)_helpKeywords.Current;

            if (keyword.Topics.Count > 0)
            {
                ITopicCollection topics = keyword.Topics;
                topics.MoveTo(0);

                for (int i = 0; i < topics.Count; i++)
                {
                    _results.Add((Topic)topics.Current);
                    topics.MoveNext();
                }

                //Load ListView with results
                for (int i = 0; i < topics.Count; i++)
                {
                    ListViewItem li = new ListViewItem((i + 1).ToString());
                    li.ToolTipText = MakeTopicToolTip(_results[i]); // just for dev info -- Hover over the first column to see this tip
                    li.SubItems.AddRange(new String[] { _results[i].Title, _results[i].DisplayVersion });
                    resultsListView.Items.Add(li);
                }

                //Select linkNode #1 -- and trigger display of topic in webBrowser1
                resultsListView.Items[0].Selected = true;
            }
        }
Esempio n. 23
0
        private void keywordsListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = SelectedKeyword;

            if (index < 0 || index >= _helpKeywords.Count)
            {
                return;
            }

            _helpKeywords.MoveTo(index);
            IKeyword keyword = (IKeyword)_helpKeywords.Current;

            keywordsTextBox.Clear();
            RichTextBoxFuncs rtf = new RichTextBoxFuncs(keywordsTextBox);

            rtf.WriteLine("IKeyword Members:");
            rtf.WriteLine("DisplayValue", keyword.DisplayValue);
            rtf.WriteLine("IsSubkey", keyword.IsSubkey.ToString());
            rtf.WriteLine("Value", keyword.Value);
            rtf.WriteLine("Topics", keyword.Topics.Count.ToString());

            //Fill Results Panel
            resultsPanel.SetVirtualList(keyword.Topics);
        }
Esempio n. 24
0
 public StepEventArgs(IKeyword keyword)
 {
     Keyword = keyword;
 }
Esempio n. 25
0
 private static string GetKeywordDisplayText(IKeyword k)
 {
     return !String.IsNullOrEmpty(k.Description) ? k.Description : k.Title;
 }
Esempio n. 26
0
 private static string GetKeywordKey(IKeyword k)
 {
     return !String.IsNullOrEmpty(k.Key) ? k.Key : k.Id;
 }
Esempio n. 27
0
 /// <summary>
 /// Defines a <see cref="KeywordReference"/>
 /// </summary>
 /// <param name="keyword">The keyword for which a reference will be created</param>
 /// <returns></returns>
 public static TokenRule token(IKeyword keyword)
 => Token.Define(keyword.KeywordName);
Esempio n. 28
0
        public bool TryGetKeyword(string categoryUriToLookIn, string keywordName, out IKeyword keyword)
        {
            using (TaxonomyFactory taxFactory = new TaxonomyFactory())
            {
                var taxonomyUri = categoryUriToLookIn;

                //Create filter to retrieve all keywords in a taxonomy
                CompositeFilter compFilter = new CompositeFilter();
                compFilter.DepthFiltering(DepthFilter.UnlimitedDepth, DepthFilter.FilterUp);
                compFilter.DepthFiltering(DepthFilter.UnlimitedDepth, DepthFilter.FilterDown);

                //Get keywords in taxonomy (hierarchically)
                IEnumerable <Keyword> taxonomy = null;
                try
                {
                    //Ugly way to see if a taxonomy exists. Alternative is to loop through all taxonomys in Tridion and check if the categoryUriToLookIn exists...
                    taxonomy = taxFactory.GetTaxonomyKeywords(categoryUriToLookIn, compFilter, new TaxonomyHierarchyFormatter()).KeywordChildren.Cast <Keyword>();
                }
                catch (Exception)
                {
                    //TODO: Trace
                    keyword = null;
                    return(false);
                }

                //Search in taxonomy
                Keyword foundKeyword = null;
                foreach (var currentKeyword in taxonomy)
                {
                    string currentKeywordName = currentKeyword.KeywordName;
                    if (currentKeywordName != keywordName)
                    {
                        foundKeyword = recursive(currentKeyword.KeywordChildren.Cast <Keyword>().ToList(), keywordName);
                    }
                    else
                    {
                        foundKeyword = currentKeyword;
                    }
                    if (foundKeyword != null)
                    {
                        Tridion.Extensions.DynamicDelivery.ContentModel.Keyword returnKeyword = new ContentModel.Keyword();

                        Keyword par = foundKeyword.ParentKeyword;
                        do
                        {
                            Tridion.Extensions.DynamicDelivery.ContentModel.Keyword newParentKeyword = new ContentModel.Keyword();
                            newParentKeyword.Id         = par.KeywordUri;
                            newParentKeyword.TaxonomyId = par.TaxonomyUri;
                            newParentKeyword.Title      = par.KeywordName;
                            returnKeyword.ParentKeywords.Add(newParentKeyword); //Add the parentkeyword to the list
                            par = par.ParentKeyword;
                        } while (par != null);

                        //Add remaining properties to the returnKeyword
                        returnKeyword.Id         = foundKeyword.KeywordUri;
                        returnKeyword.TaxonomyId = foundKeyword.TaxonomyUri;
                        returnKeyword.Title      = foundKeyword.KeywordName;


                        keyword = returnKeyword;
                        return(true);
                    }
                }

                keyword = null;
                return(false); //Keyword not found
            }
        }
        protected virtual object MapKeyword(IKeyword keyword, Type modelType)
        {
            // TODO TSI-811: Keyword mapping should also be generic rather than hard-coded like below
            string displayText = String.IsNullOrEmpty(keyword.Description) ? keyword.Title : keyword.Description;
            if (modelType == typeof(Tag))
            {
                return new Tag
                {
                    DisplayText = displayText,
                    Key = String.IsNullOrEmpty(keyword.Key) ? keyword.Id : keyword.Key,
                    TagCategory = keyword.TaxonomyId
                };
            }

            if (modelType == typeof(bool))
            {
                //For booleans we assume the keyword key or value can be converted to bool
                return Boolean.Parse(String.IsNullOrEmpty(keyword.Key) ? keyword.Title : keyword.Key);
            }

            if (modelType == typeof(string))
            {
                return displayText;
            }

            throw new DxaException(String.Format("Cannot map Keyword to type '{0}'. The type must be Tag, bool or string.", modelType));
        }
Esempio n. 30
0
 internal KeywordValue(Guid id, IKeyword keyword, T value)
 {
     Id      = id;
     Keyword = keyword;
     Value   = value;
 }
Esempio n. 31
0
 public bool TryGetKeyword(string categoryUriToLookIn, string keywordName, out IKeyword keyword)
 {
     throw new NotImplementedException();
 }
Esempio n. 32
0
        private readonly ISchemaData metadataSchema = null; //not implemented by DD4T at this time

        #endregion Fields

        #region Constructors

        public Keyword(IKeyword keyword, string categoryName = null)
        {
            this.keyword = keyword;
            if (keyword != null)
            {
                this.metadata = new FieldSet(keyword.MetadataFields);
                //DD4T provides no way to retrieve an ICategory object
                this.category = new CategoryData(keyword.TaxonomyId, categoryName);
            }
        }
Esempio n. 33
0
 /// <summary>
 /// When overriden in a derived class, this gets the value of the Property for a given Page
 /// </summary>
 /// <param name="page">Page for the View Model</param>
 /// <param name="propertyType">Actual return type for the Property</param>
 /// <param name="factory">View Model factory</param>
 /// <returns>The Property value</returns>
 public abstract IEnumerable GetPropertyValues(IKeyword keyword, Type propertyType, IViewModelFactory factory);
Esempio n. 34
0
        public void TestWriteKeyword()
        {
            Assert.AreEqual(ScalarVerbose("\"~:foo\""), WriteJsonVerbose(TransitFactory.Keyword("foo")));
            Assert.AreEqual(Scalar("\"~:foo\""), WriteJson(TransitFactory.Keyword("foo")));

            IList l = new IKeyword[] 
            {
                TransitFactory.Keyword("foo"),
                TransitFactory.Keyword("foo"),
                TransitFactory.Keyword("foo")
            };
            Assert.AreEqual("[\"~:foo\",\"~:foo\",\"~:foo\"]", WriteJsonVerbose(l));
            Assert.AreEqual("[\"~:foo\",\"^0\",\"^0\"]", WriteJson(l));
        }
Esempio n. 35
0
        public KeywordTypeEnum KeywordPeek()
        {
            IKeyword key = KeywordMatchService.GetCompletelyMatched();

            return(key.KeywordType);
        }
Esempio n. 36
0
 public Show(IKeyword keyword)
 {
     this._keyword = keyword;
 }
Esempio n. 37
0
 public override IEnumerable GetPropertyValues(IModel modelData, IModelProperty property, IViewModelFactory factory)
 {
     IEnumerable result = null;
     if (modelData != null && modelData is IKeyword)
     {
         result = new IKeyword[] { modelData as IKeyword };
     }
     return result;
 }
Esempio n. 38
0
 public KeywordMatch(IKeyword keyword)
 {
     this.keyword = keyword;
 }
        public bool TryGetKeyword(string categoryUriToLookIn, string keywordName, out IKeyword keyword)
        {
            using (TaxonomyFactory taxFactory = new TaxonomyFactory())
            {

                var taxonomyUri = categoryUriToLookIn;

                //Create filter to retrieve all keywords in a taxonomy
                CompositeFilter compFilter = new CompositeFilter();
                compFilter.DepthFiltering(DepthFilter.UnlimitedDepth, DepthFilter.FilterUp);
                compFilter.DepthFiltering(DepthFilter.UnlimitedDepth, DepthFilter.FilterDown);

                //Get keywords in taxonomy (hierarchically)
                IEnumerable<Keyword> taxonomy = null;
                try
                {
                    //Ugly way to see if a taxonomy exists. Alternative is to loop through all taxonomys in Tridion and check if the categoryUriToLookIn exists...
                    taxonomy = taxFactory.GetTaxonomyKeywords(categoryUriToLookIn, compFilter, new TaxonomyHierarchyFormatter()).KeywordChildren.Cast<Keyword>();
                }
                catch (Exception)
                {
                    //TODO: Trace
                    keyword = null;
                    return false;
                }

                //Search in taxonomy
                Keyword foundKeyword = null;
                foreach (var currentKeyword in taxonomy)
                {
                    string currentKeywordName = currentKeyword.KeywordName;
                    if (currentKeywordName != keywordName)
                    {
                        foundKeyword = recursive(currentKeyword.KeywordChildren.Cast<Keyword>().ToList(), keywordName);
                    }
                    else
                    {
                        foundKeyword = currentKeyword;
                    }
                    if (foundKeyword != null)
                    {
                        Tridion.Extensions.DynamicDelivery.ContentModel.Keyword returnKeyword = new ContentModel.Keyword();

                        Keyword par = foundKeyword.ParentKeyword;
                        do
                        {
                            Tridion.Extensions.DynamicDelivery.ContentModel.Keyword newParentKeyword = new ContentModel.Keyword();
                            newParentKeyword.Id = par.KeywordUri;
                            newParentKeyword.TaxonomyId = par.TaxonomyUri;
                            newParentKeyword.Title = par.KeywordName;
                            returnKeyword.ParentKeywords.Add(newParentKeyword); //Add the parentkeyword to the list
                            par = par.ParentKeyword;

                        } while (par != null);

                        //Add remaining properties to the returnKeyword
                        returnKeyword.Id = foundKeyword.KeywordUri;
                        returnKeyword.TaxonomyId = foundKeyword.TaxonomyUri;
                        returnKeyword.Title = foundKeyword.KeywordName;

                        keyword = returnKeyword;
                        return true;
                    }
                }

                keyword = null;
                return false; //Keyword not found
            }
        }