A FluidDB user, for example named Sara, can tag as many different objects as she likes with her tags, using whatever values she likes. For example, she might tag an object representing The Eiffel Tower, with a sara/opinion of beautiful and another object representing Quantum Electrodynamics, with the sara/opinion of hard.
Exemple #1
0
        /// <summary>
        /// Returns an object reference to the tag with the specified name in the specified namespace
        /// </summary>
        /// <param name="c"></param>
        /// <param name="f_namespace"></param>
        /// <param name="name"></param>
        /// <param name="returnDescription"></param>
        /// <returns></returns>
        public static FluidTag GetTag(FluidConnector c, FluidNamespace f_namespace, string name, bool returnDescription)
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("returnDescription", returnDescription.ToString());

            // send get request with parameters in URI (.net does not allow you to use the payload
            string path = "/tags/" + (f_namespace != null ? f_namespace.Name + "/" : "") + name;
            HttpWebResponse r = c.Call(METHOD.GET, path, parameters, null);

            if (r.StatusCode == HttpStatusCode.OK)
            {
                Dictionary<string, object> response = c.GetJsonResultDictionary(r);

                FluidTag t = new FluidTag(c, (f_namespace != null ? f_namespace.Name + "/" : "") + name);
                if (returnDescription)
                {
                    t.Description = response["description"].ToString();
                }
                t.ID = new FluidDBGUID(response["id"].ToString());
                t.Indexed = bool.Parse(response["indexed"].ToString());
                return t;
            }
            else
            {
                return null;
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates the tag in the namespace
        /// </summary>
        public static FluidTag CreateTag(FluidConnector c, FluidNamespace f_namespace, string name, string description, bool indexed)
        {
            Dictionary<string, object> parameters = new Dictionary<string,object>();
            parameters.Add("description", description);
            parameters.Add("indexed", indexed);
            parameters.Add("name", name);

            HttpWebResponse r = c.Call(METHOD.POST, "/tags/" + f_namespace.Name, null, parameters);
            if (r.StatusCode == HttpStatusCode.Created)
            {
                Dictionary<string, object> d = c.GetJsonResultDictionary(r);

                FluidTag t = new FluidTag(c, f_namespace + "/" + name);
                t.Description = description;
                t.Indexed = indexed;
                t.ID = new FluidDBGUID(d["id"].ToString());

                return t;
            }
            else
            {
                return null;
            }
        }
Exemple #3
0
        /// <summary>
        /// Gets information for specified namespace 
        /// <param name="c">The FluidConnector instance to make calls to</param>
        /// <param name="fl_namespace">The namespace to query, can be empty or null for top-level namespace</param>
        /// <param name="returnDescription">Whether to return a description of the namespace</param>
        /// <param name="returnNamespaces">Whether to return all namespaces within this namespace</param>
        /// <param name="returnTags">Whether or not to return all tags for this namespace</param>
        /// </summary>
        public static FluidNamespace GetNamespace(FluidConnector connection, string name, bool returnDescription, bool returnNamespaces, bool returnTags)
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>();

            parameters.Add("returnDescription", returnDescription.ToString());
            parameters.Add("returnNamespaces", returnNamespaces.ToString());
            parameters.Add("returnTags", returnTags.ToString());

            HttpWebResponse r = connection.Call(METHOD.GET, "/namespaces/" + name, parameters, null);
            
            if (r.StatusCode == HttpStatusCode.OK)
            {
                FluidNamespace n = new FluidNamespace(connection, name);
                Dictionary<string, object> response = connection.GetJsonResultDictionary(r);

                n.ID = new FluidDBGUID(response["id"] as string);

                if (returnDescription)
                {
                    n.Description = response["description"].ToString();
                }
                if (returnNamespaces)
                {
                    ArrayList namespaces = response["namespaceNames"] as ArrayList;
                    n.Namespaces.Clear();
                    foreach (object o in namespaces)
                    {
                        n.Namespaces.Add(new FluidNamespace(connection, o.ToString()));
                    }
                }
                if (returnTags)
                {
                    ArrayList tags = response["tagNames"] as ArrayList;
                    n.Tags.Clear();
                    foreach (object o in tags)
                    {
                       FluidTag t = new FluidTag(connection,  o.ToString());
                       n.Tags.Add(t);
                    }
                }

                return n;
            }
            else
            {
                return null;
            }
        }