Package easyJ.database.session

Examples of easyJ.database.session.Session


        Class clazz = object.getClass();
        SelectCommand scmdScenarioVersion = DAOFactory.getSelectCommand(clazz);
        Filter filter = DAOFactory.getFilter("scenarioVersionId",
                SQLOperator.EQUAL, ScenarioVersionId.toString());
        scmdScenarioVersion.setFilter(filter);
        Session session = SessionFactory.openSession();
        ArrayList scenarioVersions = session.query(scmdScenarioVersion);
        if (scenarioVersions.size() == 1) {
            scenarioversion = (ScenarioVersion) scenarioVersions.get(0);
        }
        // 查询上一版本的scenarioversion
        if (oldScenarioVersionId.intValue() > -1) {
            SelectCommand scmdOldScenarioVersion = DAOFactory
                    .getSelectCommand(clazz);
            Filter oldfilter = DAOFactory.getFilter("scenarioVersionId",
                    SQLOperator.EQUAL, oldScenarioVersionId.toString());
            scmdOldScenarioVersion.setFilter(oldfilter);
            ArrayList oldscenarioVersions = session
                    .query(scmdOldScenarioVersion);
            if (oldscenarioVersions.size() == 1) {
                oldscenarioversion = (ScenarioVersion) oldscenarioVersions
                        .get(0);
            }
        }
        // 提取当前版本的变化的内容
        String modifyMark = scenarioversion.getModifyMark();
        String[] modifyDomain = modifyMark.split("\\,");
        Object o;
        for (int k = 0; k < modifyDomain.length; k++) {
            String content = " ";
            // 得到datas最新和上一版本的内容
            if ("datas".equals(modifyDomain[k])) {
                String newDatas = "";
                String oldDatas = "无";
                // 取最新的datas
                o = BeanUtil
                        .getEmptyObject("cn.edu.pku.dr.requirement.elicitation.data.Data");
                clazz = o.getClass();
                SelectCommand scmd = DAOFactory.getSelectCommand(clazz);
                String[] datas = new String[10];
                datas = (String[]) scenarioversion.getDatas().split("\\,");
                Filter filternew = DAOFactory.getFilter("dataId",
                        SQLOperator.IN, datas);
                scmd.setFilter(filternew);
                ArrayList dataList = session.query(scmd);
                for (int j = 0; j < dataList.size(); j++) {
                    data = (Data) dataList.get(j);
                    newDatas = newDatas + data.getDataName();
                }
                // 取以前的datas
                if (oldscenarioversion != null) {
                    datas = (String[]) oldscenarioversion.getDatas().split(
                            "\\,");
                    Filter filterold = DAOFactory.getFilter("dataId",
                            SQLOperator.IN, datas);
                    scmd.setFilter(filterold);
                    dataList = session.query(scmd);
                    for (int j = 0; j < dataList.size(); j++) {
                        data = (Data) dataList.get(j);
                        oldDatas = oldDatas + data.getDataName();
                    }
                }
                // 得到content
                /*
                 * content = content + "<table class=\"changeborder\">" + "<tr class=\"change\" ><td>observers</td></tr>" + "<tr class=\"version\"><td>上一版本:</td></tr>" + "<tr class=\"content\"><td>" +
                 * oldDatas + "</td></tr>" + "<tr class=\"version\"><td>目前版本:</td></tr>" + "<tr class=\"content\"><td>" +
                 * newDatas + "</td></tr></table>";
                 */
                content = content + "<table class=\"changeborder\">"
                        + "<tr class=\"change\" ><td>datas</td></tr>"
                        + "<tr class=\"version\"><td>目前版本:</td></tr>"
                        + "<tr class=\"content\"><td>" + newDatas
                        + "</td></tr></table>";

            }
            // 得到participants最新和上一版本的内容
            else if ("participants".equals(modifyDomain[k])) {
                String newParticipants = "";
                String oldParticipants = "无";
                // 取最新的participants
                o = BeanUtil
                        .getEmptyObject("cn.edu.pku.dr.requirement.elicitation.data.Role");
                clazz = o.getClass();
                SelectCommand scmd = DAOFactory.getSelectCommand(clazz);
                String[] participants = new String[10];
                participants = (String[]) scenarioversion.getParticipants()
                        .split("\\,");
                Filter filternew = DAOFactory.getFilter("roleId",
                        SQLOperator.IN, participants);
                scmd.setFilter(filternew);
                ArrayList participantList = session.query(scmd);
                for (int j = 0; j < participantList.size(); j++) {
                    participant = (Role) participantList.get(j);
                    newParticipants = newParticipants
                            + participant.getRoleName();
                }
                // 取以前的participants
                if (oldscenarioversion != null) {
                    participants = (String[]) oldscenarioversion
                            .getParticipants().split("\\,");
                    Filter filterold = DAOFactory.getFilter("roleId",
                            SQLOperator.IN, participants);
                    scmd.setFilter(filterold);
                    participantList = session.query(scmd);
                    session.close();
                    for (int j = 0; j < participantList.size(); j++) {
                        participant = (Role) participantList.get(j);
                        oldParticipants = oldParticipants
                                + participant.getRoleName();
                    }
                }
                // 得到content
                /*
                 * content = content + "<table class=\"changeborder\">" + "<tr class=\"change\" ><td>observers</td></tr>" + "<tr class=\"version\"><td>上一版本:</td></tr>" + "<tr class=\"content\"><td>" +
                 * oldParticipants + "</td></tr>" + "<tr class=\"version\"><td>目前版本:</td></tr>" + "<tr class=\"content\"><td>" +
                 * newParticipants + "</td></tr></table>";
                 */
                content = content + "<table class=\"changeborder\">"
                        + "<tr class=\"change\" ><td>participants</td></tr>"
                        + "<tr class=\"version\"><td>目前版本:</td></tr>"
                        + "<tr class=\"content\"><td>" + newParticipants
                        + "</td></tr></table>";

            } else if ("communicators".equals(modifyDomain[k])) {
                String newCommunicators = "";
                String oldCommunicators = "无";
                // 取最新的communicators
                o = BeanUtil
                        .getEmptyObject("cn.edu.pku.dr.requirement.elicitation.data.Role");
                clazz = o.getClass();
                SelectCommand scmd = DAOFactory.getSelectCommand(clazz);
                String[] communicators = new String[10];
                communicators = (String[]) scenarioversion.getParticipants()
                        .split("\\,");
                Filter filternew = DAOFactory.getFilter("roleId",
                        SQLOperator.IN, communicators);
                scmd.setFilter(filternew);
                ArrayList communicatorList = session.query(scmd);
                for (int j = 0; j < communicatorList.size(); j++) {
                    communicator = (Role) communicatorList.get(j);
                    newCommunicators = newCommunicators
                            + communicator.getRoleName();
                }
                // 取以前的communicators
                if (oldscenarioversion != null) {
                    communicators = (String[]) oldscenarioversion
                            .getParticipants().split("\\,");
                    Filter filterold = DAOFactory.getFilter("roleId",
                            SQLOperator.IN, communicators);
                    scmd.setFilter(filterold);
                    communicatorList = session.query(scmd);
                    session.close();
                    for (int j = 0; j < communicatorList.size(); j++) {
                        communicator = (Role) communicatorList.get(j);
                        oldCommunicators = oldCommunicators
                                + participant.getRoleName();
                    }
                }
                // 得到content
                /*
                 * content = content + "<table class=\"changeborder\">" + "<tr class=\"change\" ><td>observers</td></tr>" + "<tr class=\"version\"><td>上一版本:</td></tr>" + "<tr class=\"content\"><td>" +
                 * oldCommunicators + "</td></tr>" + "<tr class=\"version\"><td>目前版本:</td></tr>" + "<tr class=\"content\"><td>" +
                 * newCommunicators + "</td></tr></table>";
                 */
                content = content + "<table class=\"changeborder\">"
                        + "<tr class=\"change\" ><td>Communicators</td></tr>"
                        + "<tr class=\"version\"><td>目前版本:</td></tr>"
                        + "<tr class=\"content\"><td>" + newCommunicators
                        + "</td></tr></table>";

            } else if ("observers".equals(modifyDomain[k])) {
                String newObservers = "";
                String oldObservers = "";
                // 取最新的observers
                o = BeanUtil
                        .getEmptyObject("cn.edu.pku.dr.requirement.elicitation.data.Role");
                clazz = o.getClass();
                SelectCommand scmd = DAOFactory.getSelectCommand(clazz);
                String[] observers = new String[10];
                observers = (String[]) scenarioversion.getParticipants().split(
                        "\\,");
                Filter filternew = DAOFactory.getFilter("roleId",
                        SQLOperator.IN, observers);
                scmd.setFilter(filternew);
                ArrayList communicatorList = session.query(scmd);
                for (int j = 0; j < communicatorList.size(); j++) {
                    observer = (Role) communicatorList.get(j);
                    newObservers = newObservers + observer.getRoleName();
                }
                // 取以前的observers
                if (oldscenarioversion != null) {
                    observers = (String[]) oldscenarioversion.getParticipants()
                            .split("\\,");
                    Filter filterold = DAOFactory.getFilter("roleId",
                            SQLOperator.IN, observers);
                    scmd.setFilter(filterold);
                    communicatorList = session.query(scmd);
                    session.close();
                    for (int j = 0; j < communicatorList.size(); j++) {
                        observer = (Role) communicatorList.get(j);
                        oldObservers = oldObservers + observer.getRoleName();
                    }
                }
                // 得到content
                /*
                 * content = content + "<table class=\"changeborder\">" + "<tr class=\"change\" ><td>observers</td></tr>" + "<tr class=\"version\"><td>上一版本:</td></tr>" + "<tr class=\"content\"><td>" +
                 * oldObservers + "</td></tr>" + "<tr class=\"version\"><td>目前版本:</td></tr>" + "<tr class=\"content\"><td>" +
                 * newObservers + "</td></tr></table>";
                 */
                content = content + "<table class=\"changeborder\">"
                        + "<tr class=\"version\"><td>目前版本:</td></tr>"
                        + "<tr class=\"content\"><td>" + newObservers
                        + "</td></tr></table>";

            }
            // 取description最新的版本和原来的版本
            else if ("description".equals(modifyDomain[k])) {
                String newDescription = "";
                String oldDescription = "";
                // 取最新的description
                o = BeanUtil
                        .getEmptyObject("cn.edu.pku.dr.requirement.elicitation.data.DescriptionVersion");
                clazz = o.getClass();
                SelectCommand scmd = DAOFactory.getSelectCommand(clazz);
                String descriptions = (String) scenarioversion
                        .getScenarioVersionId().toString();
                Filter filternew = DAOFactory.getFilter("scenarioVersionId",
                        SQLOperator.EQUAL, descriptions);
                scmd.setFilter(filternew);
                ArrayList descriptionList = session.query(scmd);
                for (int j = 0; j < descriptionList.size(); j++) {
                    description = (DescriptionVersion) descriptionList.get(j);
                    newDescription = newDescription
                            + description.getDescriptionVersionContent();
                }
                // 取以前的description
                Filter filter1 = DAOFactory.getFilter();
                Filter filter2 = DAOFactory.getFilter("scenarioVersionId",
                        SQLOperator.LESS, ScenarioVersionId.toString());
                Filter filter3 = DAOFactory.getFilter("creatorId",
                        SQLOperator.EQUAL, scenarioversion.getCreatorId()
                                .toString());
                filter1.addFilter(filter2);
                filter1.addFilter(filter3, LogicOperator.AND);
                scmd.setFilter(filter1);
                scmd.addOrderRule(new OrderRule("scenarioVersionId",
                        OrderDirection.DESC));
                descriptionList = session.query(scmd);
                if (descriptionList.size() > 0) {

                    oldescription = (DescriptionVersion) descriptionList.get(0);
                    oldDescription = oldDescription
                            + oldescription.getDescriptionVersionContent();
View Full Code Here


        SelectCommand scmd = DAOFactory.getSelectCommand(clazz);
        Filter filter = DAOFactory.getFilter("scenarioVersionId",
                SQLOperator.EQUAL, scenarioversionId);
       
        scmd.setFilter(filter);
        Session session = SessionFactory.openSession();
        ArrayList scenarioVersions = session.query(scmd);
        if (scenarioVersions.size() > 0) {
            scenarioversion = (ScenarioVersion) scenarioVersions.get(0);
        }
        // 将参与者取出
        object = BeanUtil
                .getEmptyObject("cn.edu.pku.dr.requirement.elicitation.data.Role");
        clazz = object.getClass();
        scmd = DAOFactory.getSelectCommand(clazz);
        String[] participants = new String[10];
        participants = scenarioversion.getParticipants().split("\\,");
        Filter filter_participants = DAOFactory.getFilter("roleId",
                SQLOperator.IN, participants);
        scmd.setFilter(filter_participants);
        ArrayList participantList = session.query(scmd);
        String participantcontent = "";
        for (int j = 0; j < participantList.size(); j++) {
            participant = (Role) participantList.get(j);
            participantcontent = participantcontent + participant.getRoleName();
        }
        // scenarioversion.setParticipants(participantcontent);
        // 将外部交互者取出
        object = BeanUtil
                .getEmptyObject("cn.edu.pku.dr.requirement.elicitation.data.Role");
        clazz = object.getClass();
        scmd = DAOFactory.getSelectCommand(clazz);
        String[] communicators = new String[10];
        communicators = scenarioversion.getCommunicators().split("\\,");
        Filter filter_communicators = DAOFactory.getFilter("roleId",
                SQLOperator.IN, communicators);
        scmd.setFilter(filter_communicators);
        ArrayList communicatorList = session.query(scmd);
        String communicatorcontent = "";
        for (int j = 0; j < communicatorList.size(); j++) {
            communicator = (Role) communicatorList.get(j);
            communicatorcontent = communicatorcontent
                    + communicator.getRoleName();
        }
        scenarioversion.setCommunicators(communicatorcontent);
        // 将观察者取出
        object = BeanUtil
                .getEmptyObject("cn.edu.pku.dr.requirement.elicitation.data.Role");
        clazz = object.getClass();
        scmd = DAOFactory.getSelectCommand(clazz);
        String[] observers = new String[10];
        observers = scenarioversion.getObservers().split("\\,");
        Filter filter_observers = DAOFactory.getFilter("roleId",
                SQLOperator.IN, observers);
        scmd.setFilter(filter_observers);
        ArrayList observerList = session.query(scmd);
        String observercontent = "";
        for (int j = 0; j < observerList.size(); j++) {
            observer = (Role) observerList.get(j);
            observercontent = observercontent + observer.getRoleName();
        }
        scenarioversion.setObservers(observercontent);
        // 将数据取出
        object = BeanUtil
                .getEmptyObject("cn.edu.pku.dr.requirement.elicitation.data.Data");
        clazz = object.getClass();
        scmd = DAOFactory.getSelectCommand(clazz);
        String[] datas = new String[10];
        datas = scenarioversion.getDatas().split("\\,");
        Filter filter_datas = DAOFactory.getFilter("dataId", SQLOperator.IN,
                datas);
        scmd.setFilter(filter_datas);
        ArrayList dataList = session.query(scmd);
        String datacontent = "";
        for (int j = 0; j < dataList.size(); j++) {
            data = (Data) dataList.get(j);
            datacontent = datacontent + data.getDataName();
        }
        scenarioversion.setDatas(datacontent);
        // 将描述前面的部分放入content
        content = content
                + "<table><tbody id=\"reality\"><tr  align=\"center\">"
                + "场景名:&nbsp;" + scenarioversion.getScenarioName()
                + "&nbsp;&nbsp;&nbsp; &nbsp;版本号:"
                + scenarioversion.getScenarioVersionId() + "</tr>";
        // 加入场景名称
        content = content
                + "<tr class=\"trContent\" ><th class=\"trContent\">场景名称</th><td class=\"trContent\" id=\"sn\">"
                + scenarioversion.getScenarioName() + "</td>";
        // 加入参与者
        content = content
                + "<th class=\"trContent\" width=\"80px\">参与者</th><td  class=\"trContent\" id=\"participant\"><span id=\"participant_list\">"
                + participantcontent + "</span></td></tr>";
        // 加入外部交互者
        content = content
                + "<tr class=\"trContent\" ><th class=\"trContent\">外部交互者</th><td  class=\"trContent\" id=\"communicator\"><span id=\"communicator_list\">"
                + communicatorcontent + "</span></td>";
        // 加入观察者
        content = content
                + "<th class=\"trContent\" width=\"80px\">观察者</th><td  class=\"trContent\" id=\"observer\"><span id=\"observer_list\">"
                + observercontent + "</span></td></tr>";
        // 加入数据
        content = content
                + "<tr class=\"trContent\" width=\"80px\" ><th class=\"trContent\">数据</th><td  class=\"trContent\" id=\"data\" colspan=\"3\"><span id=\"data_list\">"
                + datacontent + "</span></td></tr>";
        // 添加描述以及remark
        int length = scenarioversion.getParticipants().split("\\,").length;
        String[] parti = new String[length];
        parti = scenarioversion.getParticipants().split("\\,");

        for (int i = 0; i < parti.length; i++) {
            object = BeanUtil
                    .getEmptyObject("cn.edu.pku.dr.requirement.elicitation.data.Role");
            clazz = object.getClass();
            scmd = DAOFactory.getSelectCommand(clazz);
            Filter filter_participant = DAOFactory.getFilter("roleId",
                    SQLOperator.EQUAL, parti[i]);
            scmd.setFilter(filter_participant);
            ArrayList participantsList = session.query(scmd);
            if (participantsList.size() > 0) {
                participant = (Role) participantsList.get(0);
            }
            content = content
                    + "<tr  class=\"trContent\" ><th class=\"trContent\" width=\"80px\">"
                    + participant.getRoleName() + "</th>";
            // 取描述
            object = BeanUtil
                    .getEmptyObject("cn.edu.pku.dr.requirement.elicitation.data.DescriptionVersion");
            clazz = object.getClass();
            scmd = DAOFactory.getSelectCommand(clazz);
            Filter filterdescription2 = DAOFactory.getFilter(
                    "scenarioVersionId", SQLOperator.EQUAL, scenarioversion
                            .getScenarioVersionId());
            Filter filterdescription3 = DAOFactory.getFilter("creatorId",
                    SQLOperator.EQUAL, parti[i]);
            Filter filterdescription1 = DAOFactory.getFilter();
            filterdescription1.addFilter(filterdescription3);
            filterdescription1.addFilter(filterdescription2, LogicOperator.AND);
            scmd.setFilter(filterdescription1);
            ArrayList descriptionsList = session.query(scmd);
            if (descriptionsList.size() > 0) {
                description = (DescriptionVersion) descriptionsList.get(0);

                content = content
                        + "<td colspan=\"3\" class=\"tr\"><div class=\"trContent\">"
                        + description.getDescriptionVersionContent() + "</div>";
            } else {
                content = content
                        + "<td colspan=\"3\" class=\"tr\"><div class=\"trContent\">"
                        + descriptiontable + "</div>";
            }
            // 得到评论数据
            object = BeanUtil
                    .getEmptyObject("cn.edu.pku.dr.requirement.elicitation.data.Remark");
            clazz = object.getClass();
            scmd = DAOFactory.getSelectCommand(clazz);
            Filter filterremark = DAOFactory.getFilter("roleId",
                    SQLOperator.EQUAL, parti[i]);
            scmd.setFilter(filterremark);
            ArrayList remarkList = session.query(scmd);
            content = content + "<div class=\"trtitle\">评论</div>";
            if (remarkList.size() > 0) {
                for (int j = 0; j < remarkList.size(); j++) {
                    remark = (Remark) remarkList.get(j);
                    content = content + "<div class=\"trContent\">"
View Full Code Here

        }
        request.setAttribute(Globals.PAGE, page);
        Long creatorId = new Long(request.getParameter("CreatorId"));
        Class clazz = BeanUtil
                .getClass("cn.edu.pku.dr.requirement.elicitation.data.DescriptionVersion");
        Session session = SessionFactory.openSession();
        String content = "";
        // 取用户名
        clazz = BeanUtil
                .getClass("cn.edu.pku.dr.requirement.elicitation.data.Role");
        SelectCommand scmd = DAOFactory.getSelectCommand(clazz);
        Filter filter1 = DAOFactory.getFilter("roleId", SQLOperator.EQUAL,
                creatorId);
        scmd.setFilter(filter1);
        ArrayList creators = session.query(scmd);
        String creatorName = "";
        if (creators.size() > 0) {
            Role creator = (Role) creators.get(0);
            creatorName = creator.getRoleName();
        }
View Full Code Here

        Filter filter = DAOFactory.getFilter("creatorId", SQLOperator.EQUAL,
                creatorId);
        scmdDescriptionVersion.setFilter(filter);
        scmdDescriptionVersion.addOrderRule(new OrderRule(
                "descriptionVersionId", OrderDirection.DESC));
        Session session = SessionFactory.openSession();
        ArrayList tempdescriptionVersions = session
                .query(scmdDescriptionVersion);
        ArrayList descriptionVersions = new ArrayList();
        if (tempdescriptionVersions.size() > 8) {
            for (int size = 0; size < 8; size++) {
                descriptionVersions
                        .add(size, tempdescriptionVersions.get(size));
            }
        } else {
            descriptionVersions = tempdescriptionVersions;
        }
        String content = "";
        // 取用户名
        object = BeanUtil
                .getEmptyObject("cn.edu.pku.dr.requirement.elicitation.data.Role");
        clazz = object.getClass();
        SelectCommand scmd = DAOFactory.getSelectCommand(clazz);
        Filter filter1 = DAOFactory.getFilter("roleId", SQLOperator.EQUAL,
                creatorId);
        scmd.setFilter(filter1);
        ArrayList creators = session.query(scmd);
        String creatorName = "";
        if (creators.size() > 0) {
            Role creator = (Role) creators.get(0);
            creatorName = creator.getRoleName();
        }
View Full Code Here

                    .getSelectCommand(UserPropertyRight.class);
            filter.addFilter(filter1);
            filter.addFilter(filter2, LogicOperator.AND);
            scmd.setFilter(filter);
            // 得到拥有权限的所有的ColumnsList
            Session session = null;
            try {
                session = SessionFactory.openSession();
                ArrayList allColumnsList = session.query(scmd);
                return allColumnsList;
            } finally {
                if (session != null)
                    session.close();
            }
        } catch (EasyJException e) {
            e.printStackTrace();
            throw e;
        }
View Full Code Here

            or.setOrderColumn("editSequence");
            or.setOrderDirection(OrderDirection.ASC);
            OrderRule[] orderRules = {
                or
            };
            Session session = null;
            try {
                session = SessionFactory.openSession();
                ArrayList allPropertiesList = session.query(scmd, orderRules);
                return allPropertiesList;
            } finally {
                if (session != null)
                    session.close();
            }

        } catch (EasyJException e) {
            e.printStackTrace();
            throw e;
View Full Code Here

            or.setOrderColumn("displaySequence");
            or.setOrderDirection(OrderDirection.ASC);
            OrderRule[] orderRules = {
                or
            };
            Session session = null;
            try {
                session = SessionFactory.openSession();
                ArrayList allPropertiesList = session.query(scmd, orderRules);
                return allPropertiesList;
            } finally {
                if (session != null)
                    session.close();
            }

        } catch (EasyJException e) {
            e.printStackTrace();
            throw e;
View Full Code Here

            or.setOrderColumn("querySequence");
            or.setOrderDirection(OrderDirection.ASC);
            OrderRule[] orderRules = {
                or
            };
            Session session = null;
            try {
                session = SessionFactory.openSession();
                ArrayList allPropertiesList = session.query(scmd, orderRules);
                return allPropertiesList;
            } finally {
                if (session != null)
                    session.close();
            }

        } catch (EasyJException e) {
            e.printStackTrace();
            throw e;
View Full Code Here

TOP

Related Classes of easyJ.database.session.Session

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.