Exemple #1
0
        //--- Methods ---
        public virtual TagBE Copy()
        {
            TagBE tag = new TagBE();

            tag._Type = _Type;
            tag.Id    = Id;
            tag.Name  = Name;
            return(tag);
        }
Exemple #2
0
 //--- Methods ---
 public virtual TagBE Copy() {
     TagBE tag = new TagBE();
     tag._Type = _Type;
     tag.Id = Id;
     tag.Name = Name;
     return tag;
 }
Exemple #3
0
 private TagBE Tags_Populate(IDataReader dr) {
     TagBE tag = new TagBE();
     tag._Type = dr.Read<uint>("tag_type");
     tag.Id = dr.Read<uint>("tag_id");
     tag.Name = dr.Read<string>("tag_name");
     return tag;
 }
Exemple #4
0
        public uint Tags_Insert(TagBE tag) {
            try {
                return Catalog.NewQuery(@" /* Tags_Insert */
INSERT INTO tags (tag_name, tag_type) VALUES (?TAGNAME, ?TAGTYPE);
SELECT LAST_INSERT_ID();")
                    .With("TAGNAME", tag.Name)
                    .With("TAGTYPE", tag.Type)
                    .ReadAsUInt() ?? 0;
            } catch(MySqlException e) {
                if(e.Number == 1062) {
                    _log.DebugFormat("tag '{0}'({1}) already exists, returning 0",tag.Name,tag.Type);
                    return 0;
                }
                throw;
            }
        }
Exemple #5
0
        public bool Tags_ValidateDefineTagMapping(TagBE tag) {
            if(tag == null) {
                throw new ArgumentNullException("tag");
            }
            if(tag.Type != TagType.DEFINE) {
                throw new ArgumentException("Tag has to be of type DEFINE");
            }
            return Catalog.NewQuery(@" /* Tags_ValidateDefineTagMapping */
DELETE FROM tag_map WHERE tagmap_tag_id = ?TAGID AND (SELECT COUNT(*) FROM pages WHERE page_id = tagmap_page_id) = 0;
SELECT COUNT(*) FROM tag_map WHERE tagmap_tag_id = ?TAGID;")
                    .With("TAGID", tag.Id).ReadAsInt() > 0;
        }
 /// <summary>
 /// Convert from MediaWiki categories to MindTouch tags
 /// </summary>
 public void ConvertCategories() {
     Console.Out.Write("Migrating categories... ");
     Dictionary<string, List<string>> pageToCategoryMap = MediaWikiDA.GetCategoryNamesByPage();
     foreach (KeyValuePair<string, List<string>> categoriesByPage in pageToCategoryMap) {
         TagBE[] tags = new TagBE[categoriesByPage.Value.Count];
         for (int i = 0; i < tags.Length; i++) {
             TagBE categoryTag = new TagBE();
             categoryTag.Type = TagType.TEXT;
             categoryTag.Name = categoriesByPage.Value[i];
             tags[i] = categoryTag;
         }
         ulong pageID;
         if (_MWToDWPageIDMap.TryGetValue(categoriesByPage.Key, out pageID)) {
             TagBL.InsertTags(pageID, tags);
         }
     }
     Console.Out.WriteLine("Done!");
 }
Exemple #7
0
        internal Hashtable MakeTagObject(TagBE tag) {
            Hashtable result = new Hashtable(StringComparer.OrdinalIgnoreCase) {
                { "name", tag.PrefixedName }, 
                { "prefix", tag.Prefix }, 
                { "value", tag.Name }, 
                { "type", tag.Type.ToString().ToLowerInvariant() }
            };

            // add related pages
            if(tag.RelatedPages != null) {
                var sortedPages = PageBL.SortPagesByTitle(tag.RelatedPages);
                ArrayList pages = new ArrayList();
                foreach(PageBE related in sortedPages) {
                    pages.Add(PropertyAt("$page", related.ID));
                }
                result.Add("pages", pages);
            } else {
                result.Add("pages", PropertyAt("$tagged", tag.Id));
            }

            // add page
            if(tag.DefinedTo != null) {
                result.Add("definition", PropertyAt("$page", tag.DefinedTo.ID));
            } else {
                result.Add("definition", null);
            }
            return result;
        }
Exemple #8
0
        public void Tags_Update(TagBE tag) {
            Catalog.NewQuery(@" /* Tags_Update */
UPDATE tags SET 
tag_name = ?TAGNAME,
tag_type = ?TAGTYPE
WHERE tag_id = ?TAGID;
")
            .With("TAGNAME", tag.Name)
            .With("TAGTYPE", tag.Type)
            .With("TAGID", tag.Id)
            .Execute();
            _log.DebugFormat("tag '{0}'({1}) updated", tag.Name, tag.Type);
        }
 public void Tags_Update(TagBE tag) {
     Stopwatch sw = Stopwatch.StartNew();
     _next.Tags_Update(tag);
     LogQuery(CATEGORY_TAGS, "Tags_Update", sw, "tag", tag);
 }
 public uint Tags_Insert(TagBE tag) {
     Stopwatch sw = Stopwatch.StartNew();
     var ret = _next.Tags_Insert(tag);
     LogQuery(CATEGORY_TAGS, "Tags_Insert", sw, "tag", tag);
     return ret;
 }
 public bool Tags_ValidateDefineTagMapping(TagBE tag) {
     Stopwatch sw = Stopwatch.StartNew();
     var ret = _next.Tags_ValidateDefineTagMapping(tag);
     LogQuery(CATEGORY_TAGS, "Tags_ValidateDefineTagMapping", sw, "tag", tag);
     return ret;
 }