private void _buildSubTree(XElement rootElement, Tag parent, Scheme scheme)
 {
     IEnumerable<Tuple<string, string>> childs = _getChilds(rootElement, parent.WeeId);
     foreach (Tuple<String, String> tuplo in childs) {
         string path = parent.Path + "\\" + tuplo.Item2; // children path
         Tag children = new Tag(tuplo.Item2, path, tuplo.Item1);
         scheme.arvore.add(children, parent.Path, children.Path);
         scheme.arvoreByWeeboxIds.add(children, parent.WeeId, children.WeeId);
         _buildSubTree(rootElement, children, scheme);
     }
 }
Ejemplo n.º 2
0
 private static void alter(Tag tag)
 {
     tag.Name = tag.Path = tag.WeeId = "ola";
 }
Ejemplo n.º 3
0
 public Scheme(string id, Tag root)
 {
     arvore = new Tree<Tag>(root, root.Path);
     arvoreByWeeboxIds = new Tree<Tag>(root, root.WeeId);
     this.id = id;
 }
        private Scheme getScheme(string rootID)
        {
            //TODO - check every , see getSchemes comments
            HttpResponseMessage resp = null;
            bool bo = true;
            while (bo) {
                try {
                    resp = _client.Get("manager/api?operation=getThesaurus&thesaurus=" + rootID);
                    bo = false;
                }
                catch (HttpStageProcessingException e) {
                    continue;
                }

            }
            _checkAndThrowsExceptions(resp.StatusCode, "getSchemeFromServer");
            Stream s = resp.Content.ReadAsStream();
            // TODO - validate xml answer.
            XDocument classifications = XDocument.Load(s);
            XElement rootElement = classifications.Root;

            //TODO - check to see if this will return always the value we want for the root.
            XElement raiz = rootElement.Element(_getSkoName("ConceptScheme"));

            Tag rootTag = new Tag(raiz.Value, raiz.Value, "Q2W1C42bT6");
            Scheme scheme = new Scheme("Q2W1C42bT6", rootTag);
            //<id,label>
            IEnumerable<Tuple<string, string>> lista = _getFirstLevelChilds(rootElement);

            foreach (Tuple<String, String> tup in lista) {
                string myPath = rootTag.Path + "\\" + tup.Item2;
                Tag t = new Tag(tup.Item2, myPath, tup.Item1);
                scheme.arvore.add(t, rootTag.Path, t.Path);
                scheme.arvoreByWeeboxIds.add(t, rootTag.WeeId, t.WeeId);
                _buildSubTree(rootElement, t, scheme);
            }

            return scheme;
        }
Ejemplo n.º 5
0
 public Tag(Tag t)
 {
     this.Name = t.Name;
     this.WeeId = WeeId;
     this.Path = t.Path;
 }
 private void _createFolderForTag(Tag node, Scheme scheme){
     Directory.CreateDirectory(this.path_schemes + "\\" + node.Path  + "\\"); 
     IEnumerable<Tag>   filhos   = scheme.arvore.findChilds(node.Path); 
     if (filhos != null){
         foreach (Tag t in filhos){
             _createFolderForTag(t, scheme);
         }
     }
 }
 private void SaveTag(Tag t, Scheme scheme, SqlConnection con)
 {
     foreach (Tag tFilho in scheme.arvore.findChilds(t.Path)) {
         SqlCommand query = new SqlCommand(
             "INSERT INTO plano_classificacao (parent_name, parent_weeID, parent_path, child_name, child_weeID, child_path) VALUES ('" +
             t.Name + "', '" + t.WeeId + "', '" + t.Path + "', '" + tFilho.Name + "', '" + tFilho.WeeId + "', '" + tFilho.Path + "')", con);
         query.ExecuteNonQuery();
         SaveTag(tFilho, scheme, con);
     }
 }
 private Scheme GetChildTags(Tag parent, Scheme scheme, SqlConnection con)
 {
     SqlCommand query = new SqlCommand(string.Format(
                "select child_name, child_weeID, child_path from plano_classificacao where parent_weeID = '{0}'", parent.WeeId), con);
     SqlDataReader reader = query.ExecuteReader();
     List<Tag> childs = new List<Tag>();
     while (reader.Read()) {
         Tag tempTag = new Tag(reader.GetString(0), reader.GetString(2), reader.GetString(1));
         childs.Add(tempTag);
         scheme.arvore.add(tempTag, parent.Path, tempTag.Path);
         scheme.arvoreByWeeboxIds.add(tempTag, parent.WeeId, tempTag.WeeId);
     }
     reader.Close();
     foreach (var child in childs) {
         scheme = GetChildTags(child, scheme, con);
     }
     return scheme;
 }
 //private static string connectionString = "Data Source=(local);Integrated Security=True";
 //TODO - tocha - change return on error to ArgumentNullException()
 /**
  * retrieves the classification scheme of this weebox server instance
  */
 public List<Scheme> GetClassificationScheme()
 {
     List<Scheme> lista = new List<Scheme>();
     SqlConnection con = new SqlConnection(connectionString);
     try {
         con.Open();
         //fetch the parents of each scheme
         List<Scheme> parentList = new List<Scheme>();
         SqlCommand query = new SqlCommand(string.Format(
             "select child_name, child_weeID, child_path, parent_path from plano_classificacao where parent_weeID = '{0}'", ROOT_TAG), con);
         SqlDataReader reader = query.ExecuteReader();
         while (reader.Read()) {
             Tag tempTag = new Tag(reader.GetString(0), reader.GetString(2), reader.GetString(1));
             Scheme tempScheme = new Scheme(reader.GetString(3), tempTag);
             parentList.Add(tempScheme);
         }
         reader.Close();
         foreach (Scheme parent in parentList) {
             lista.Add(GetChildTags(parent.arvore.getRoot(), parent, con));
         }
         con.Close();
     }
     catch (Exception e) {
         Console.WriteLine(e.ToString());
     }
     if (lista.Count == 0)
         lista = null;
     return lista;
 }