using System;
using System.Collections.Generic;
using System.Text;

using System.Xml;

namespace DataWarehouse
{
    public class DatabaseInterface
    {

        IUser user;

        IDatabaseInterface data;

        public DatabaseInterface(IUser user, IDatabaseInterface data)
        {
            this.user = user;
            this.data = data;
        }

        public virtual XmlDocument GetTree(string[] ext)
        {
            XmlDocument doc = new XmlDocument();
            string xml = data.GetTreeString(user.Login, user.Password, ext);
            doc.LoadXml(xml);
            return doc;
        }

        public virtual byte[] GetData(string id, ref string ext)
        {
            return data.GetData(user.Login, user.Password, id, ref ext);
        }

        public string AddData(string parentId, string name, string description, byte[] data, string ext)
        {
            return this.data.AddData(user.Login, user.Password, parentId, name, description, data, ext);
        }

        public void UpdateData(string id, byte[] data)
        {
            this.data.UpdateData(user.Login, user.Password, id, data);
        }

        public string AddDirectory(string parentId, string name, string description, string ext)
        {
            return data.AddDirectory(user.Login, user.Password, parentId, name, description, ext);
        }

        public void UpdateData(string id, string name, string description)
        {
            data.UpdateData(user.Login, user.Password, id, name, description);
        }

        public void UpdateDirectory(string id, string name, string description)
        {
            data.UpdateDirectory(user.Login, user.Password, id, name, description);
        }

        public void RemoveData(string id)
        {
            data.RemoveData(user.Login, user.Password, id);
        }

        public void RemoveDirectory(string id)
        {
            data.RemoveDirectory(user.Login, user.Password, id);
        }

    }
}