Examples of Branch


Examples of com.philip.journal.home.bean.Branch

    /** Case 4: Expected insert. */
    @Test
    public void testSaveCase4()
    {
        final Branch branch = new Branch();
        final int origCount = super.getRecordCount(super.getBranchTableName());
        final String branchName = TEST_TITLE;
        branch.setName(branchName);
        try {
            testBaseSpringHibernateDAOBranchImpl.save(branch);
        } catch (final JournalException e) {
            fail("Insert test failed.");
        }
        assertEquals("Record count increase failed.", origCount + 1, super.getRecordCount(super.getBranchTableName()));
        final Map<String, Object> saved = super.readBranch(branch.getBranchId());
        assertEquals("Read saved object failed.", branchName, saved.get(ATTR_ENTRY_NAME));

    }
View Full Code Here

Examples of com.philip.journal.home.bean.Branch

    /** Case 5: Expected update. */
    @Test
    public final void testSaveCase5()
    {
        final int origCount = super.getRecordCount(super.getBranchTableName());
        final Branch branch = new Branch();

        System.out.println(1);

        branch.setName(TEST_TITLE);
        final long branchId = 40003L;
        branch.setBranchId(branchId);
        try {
            testBaseSpringHibernateDAOBranchImpl.save(branch);
        } catch (final JournalException e) {
            fail("Save failed with exception.");
        }
View Full Code Here

Examples of com.philip.journal.home.bean.Branch

     * @return Branch path.
     */
    String getBranchPath(final Map<String, Object> session, final Branch branch)
    {
        final StringBuilder strBuilder = new StringBuilder();
        Branch parent = branch;
        strBuilder.insert(0, Constant.BRANCHID_PREFIX + parent.getBranchId());
        if (!Constant.ROOT_NAME.equals(parent.getName())) {
            do {
                parent = parent.getParent();
                strBuilder.insert(0, Constant.BRANCHID_PREFIX + parent.getBranchId());
            } while (!Constant.ROOT_NAME.equals(parent.getName()));
        }

        return strBuilder.toString();
    }
View Full Code Here

Examples of com.philip.journal.home.bean.Branch

    }

    @Override
    public long addBranch(final Map<String, Object> session, final long parentId, final String branchName)
    {
        final Branch parentBranch = getDaoFacade().getBranchDAO().read(parentId);
        if (parentBranch == null) {
            throw new JournalException(Messages.Error.JE_INV_BRANCHID);
        } else if (StringUtils.getInstance().isNullOrEmpty(branchName)) {
            throw new JournalException(Messages.Error.JE_INV_BRANCHNAME);
        }

        final Branch branch = new Branch(branchName, parentBranch);
        branch.setCreator((User) session.get(Constant.CURRENT_USER));
        getDaoFacade().getBranchDAO().save(branch);
        return branch.getBranchId();
    }
View Full Code Here

Examples of com.philip.journal.home.bean.Branch

    public void deleteBranch(final Map<String, Object> session, final long branchId)
    {
        if (branchId == Constant.ROOT_ID) {
            throw new JournalException(Messages.Error.JE_INV_BRANCHID);
        }
        final Branch branch = getDaoFacade().getBranchDAO().read(branchId);
        if (branch == null) {
            throw new JournalException(Messages.Error.JE_INV_BRANCHID);
        }

        final List<Branch> withSubBranches = new ArrayList<Branch>();
View Full Code Here

Examples of com.philip.journal.home.bean.Branch

    }

    @Override
    public void renameBranch(final Map<String, Object> session, final long branchId, final String newName)
    {
        final Branch branch = getDaoFacade().getBranchDAO().read(branchId);
        if (branch == null) {
            throw new JournalException(Messages.Error.JE_INV_BRANCHID);
        }

        branch.setName(newName);
        getDaoFacade().getBranchDAO().save(branch);
    }
View Full Code Here

Examples of com.philip.journal.home.bean.Branch

    @Override
    public void moveBranch(final Map<String, Object> session, final long newParentId, final long branchId)
    {
        final BranchDAO branchDao = getDaoFacade().getBranchDAO();
        final Branch branch = branchDao.read(branchId);
        final Branch parent = branchDao.read(newParentId);

        if (branch == null || parent == null) {
            throw new JournalException(Messages.Error.JE_INV_BRANCHID);
        }
        final String newIds = Constant.BRANCHID_PREFIX + newParentId;
View Full Code Here

Examples of com.philip.journal.home.bean.Branch

        final Date[] actionDates = getActionDates((AbstractAuditableBean) beanData[IDX_BEAN]);

        String parentName;
        Object[] parentBeanData = new Object[beanData.length];
        System.arraycopy(beanData, 0, parentBeanData, 0, beanData.length);
        Branch parent = null;
        do {
            parent = (Branch) BeanUtils.getProperty(parentBeanData[IDX_BEAN],
                    parentBeanData[IDX_BEAN] instanceof Entry ? Entry.PARENT : Branch.ATTR_PARENT);

            parentName = BeanUtils.getProperty(parent, Branch.ATTR_NAME).toString();
            path.insert(0, "/" + parentName);

            parentBeanData = getBranchNodeProperty(null, parent.getBranchId());
        } while (!parentName.equals(Constant.ROOT_NAME));

        synchronized (lock) {
            retval.put(Constant.NodeProperty.CREATED, COMP_DISP_FMT.format(actionDates[IDX_CREATED]));
            retval.put(Constant.NodeProperty.MODIFIED, COMP_DISP_FMT.format(actionDates[IDX_MODIFIED]));
View Full Code Here

Examples of com.philip.journal.home.bean.Branch

     * @exception JournalException branchId is not found.
     */
    Object[] getBranchNodeProperty(final StringBuilder strBuilder, final long branchId)
    {
        final BranchDAO branchDao = getDaoFacade().getBranchDAO();
        final Branch branch = branchDao.read(branchId);
        if (branch == null) {
            throw JournalException.wrapperException(new IllegalArgumentException(Messages.Error.IAE_NULL));
        }
        final long size = branch.getName() == null ? 0 : branch.getName().length();
        if (strBuilder != null) {
            strBuilder.append("/" + branch.getName());
        }
        return new Object[] {
                branch,
                size };
    }
View Full Code Here

Examples of com.philip.journal.home.bean.Branch

     * Case 2: Not null constraint.
     */
    @Test(expected = JournalException.class)
    public void testSaveBranch2()
    {
        branchDAO.save(new Branch());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.