package easydo.technology.core;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import zmo.technology.lite.core.ZeroCoreStructs;

public class EasydoCore {

    public static class EasydoMenu extends ZeroCoreStructs {

        private int sort;
        private List<EasydoMenu> subMenus;

        public EasydoMenu() {
            super();
        }

        public EasydoMenu(ResultSet set) throws SQLException {
            super(set);

            if (inResultSet(set, "SORT"))
                sort = set.getInt("SORT");
        }

        public int getSort() {
            return sort;
        }

        public void setSort(int sort) {
            this.sort = sort;
        }

        public List<EasydoMenu> getSubMenus() {
            return subMenus;
        }

        public void setSubMenus(List<EasydoMenu> subMenus) {
            this.subMenus = subMenus;
        }

    }

    public static class EasydoEnterprise extends ZeroCoreStructs {

        private String enterpriseName;
        private String enterpriseCode;
        private String enterpriseType;

        private EasydoEnterprise parent;
        private List<EasydoEnterprise> childs;
        private List<EasydoProject> projects;
        private List<EasydoMenu> menus;

        public EasydoEnterprise() {
            super();
        }

        public EasydoEnterprise(ResultSet set) throws SQLException {
            super(set);
            if (inResultSet(set, "ENTERPRISE_NAME"))
                enterpriseName = set.getString("ENTERPRISE_NAME");
            if (inResultSet(set, "ENTERPRISE_CODE"))
                enterpriseCode = set.getString("ENTERPRISE_CODE");
            if (inResultSet(set, "ENTERPRISE_TYPE"))
                enterpriseType = set.getString("ENTERPRISE_TYPE");
        }

        public String getEnterpriseName() {
            return enterpriseName;
        }

        public void setEnterpriseName(String enterpriseName) {
            this.enterpriseName = enterpriseName;
        }

        public String getEnterpriseCode() {
            return enterpriseCode;
        }

        public void setEnterpriseCode(String enterpriseCode) {
            this.enterpriseCode = enterpriseCode;
        }

        public String getEnterpriseType() {
            return enterpriseType;
        }

        public void setEnterpriseType(String enterpriseType) {
            this.enterpriseType = enterpriseType;
        }

        public EasydoEnterprise getParent() {
            return parent;
        }

        public void setParent(EasydoEnterprise parent) {
            this.parent = parent;
        }

        public List<EasydoEnterprise> getChilds() {
            return childs;
        }

        public void setChilds(List<EasydoEnterprise> childs) {
            this.childs = childs;
        }

        public List<EasydoProject> getProjects() {
            return projects;
        }

        public void setProjects(List<EasydoProject> projects) {
            this.projects = projects;
        }

        public List<EasydoMenu> getMenus() {
            return menus;
        }

        public void setMenus(List<EasydoMenu> menus) {
            this.menus = menus;
        }

    }

    public static class EasydoProject extends ZeroCoreStructs {

        private String projectCode;
        private String projectName;
        private String projectType;
        private String projectStatus;
        private String projectScale;
        private EasydoEnterprise enterprise;

        public EasydoProject() {
            super();
        }

        public EasydoProject(ResultSet set) throws SQLException {
            super(set);
            if (inResultSet(set, "PROJECT_CODE"))
                projectCode = set.getString("PROJECT_CODE");

            if (inResultSet(set, "PROJECT_NAME"))
                projectName = set.getString("PROJECT_NAME");

            if (inResultSet(set, "PROJECT_TYPE"))
                projectType = set.getString("PROJECT_TYPE");

            if (inResultSet(set, "PROJECT_STATUS"))
                projectStatus = set.getString("PROJECT_STATUS");

            if (inResultSet(set, "PROJECT_SCALE"))
                projectScale = set.getString("PROJECT_SCALE");

            if (inResultSet(set, "ENTERPRISE_ID")) {
                enterprise = new EasydoEnterprise();
                enterprise.setId(UUID.fromString(set.getString("ENTERPRISE_ID")));
            }
        }

        public String getProjectCode() {
            return projectCode;
        }

        public void setProjectCode(String projectCode) {
            this.projectCode = projectCode;
        }

        public String getProjectName() {
            return projectName;
        }

        public void setProjectName(String projectName) {
            this.projectName = projectName;
        }

        public String getProjectType() {
            return projectType;
        }

        public void setProjectType(String projectType) {
            this.projectType = projectType;
        }

        public String getProjectStatus() {
            return projectStatus;
        }

        public void setProjectStatus(String projectStatus) {
            this.projectStatus = projectStatus;
        }

        public String getProjectScale() {
            return projectScale;
        }

        public void setProjectScale(String projectScale) {
            this.projectScale = projectScale;
        }

        public EasydoEnterprise getEnterprise() {
            return enterprise;
        }

        public void setEnterprise(EasydoEnterprise enterprise) {
            this.enterprise = enterprise;
        }

    }

    public static class EasydoRole extends ZeroCoreStructs {

        private String roleName;
        private List<EasydoMenu> menus;

        public EasydoRole() {
            super();
        }

        public EasydoRole(ResultSet set) throws SQLException {
            super(set);

            if (inResultSet(set, "ROLE_NAME"))
                roleName = set.getString("ROLE_NAME");
        }

        public String getRoleName() {
            return roleName;
        }

        public void setRoleName(String roleName) {
            this.roleName = roleName;
        }

        public List<EasydoMenu> getMenus() {
            return menus;
        }

        public void setMenus(List<EasydoMenu> menus) {
            this.menus = menus;
        }

    }

    public static class EasydoUser extends ZeroCoreStructs {

        private String username;
        private String password;
        private EasydoUserInfo userInfo;

        private List<EasydoRole> roles;

        public EasydoUser() {
            super();
        }

        public EasydoUser(ResultSet set) throws SQLException {
            super(set);

            if (inResultSet(set, "USERNAME"))
                username = set.getString("USERNAME");

            if (inResultSet(set, "PASSWORD"))
                password = set.getString("PASSWORD");
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public EasydoUserInfo getUserInfo() {
            return userInfo;
        }

        public void setUserInfo(EasydoUserInfo userInfo) {
            this.userInfo = userInfo;
        }

        public List<EasydoRole> getRoles() {
            return roles;
        }

        public void setRoles(List<EasydoRole> roles) {
            this.roles = roles;
        }

    }

    public static class EasydoUserInfo extends ZeroCoreStructs {

        private EasydoUser user;
        private String nickName;
        private Date birthday;

        public EasydoUserInfo() {
            super();
        }

        public EasydoUserInfo(ResultSet set) throws SQLException {
            super(set);

            if (inResultSet(set, "NICK_NAME"))
                nickName = set.getString("NICK_NAME");

            if (inResultSet(set, "BIRTHDAY"))
                birthday = new Date(set.getTimestamp("BIRTHDAY").getTime());
        }

        public EasydoUser getUser() {
            return user;
        }

        public void setUser(EasydoUser user) {
            this.user = user;
        }

        public String getNickName() {
            return nickName;
        }

        public void setNickName(String nickName) {
            this.nickName = nickName;
        }

        public Date getBirthday() {
            return birthday;
        }

        public void setBirthday(Date birthday) {
            this.birthday = birthday;
        }

    }
}
