Package com.philip.journal.home.dao

Examples of com.philip.journal.home.dao.EntryDAO


        final ServiceFacade mockedFacade = Mockito.mock(ServiceFacade.class);
        getSession().put(BusinessServiceProxy.SERVICE_FACADE, mockedFacade);

        final BranchDAO mockBranchDAO = mock(BranchDAO.class);
        final EntryDAO mockEntryDAO = mock(EntryDAO.class);
        final UserDAO mockUserDAO = mock(UserDAO.class);
        final ConfigItemDAO mockConfigDAO = mock(ConfigItemDAO.class);

        when(daoFacade.getConfigItemDAO()).thenReturn(mockConfigDAO);
        when(mockConfigDAO.readAll()).thenReturn(new ArrayList<ConfigItem>());
View Full Code Here


     */
    void extractEntryFromDocument(final Element branchElement, final Branch targetBranch)
            throws XPathExpressionException
    {
        final XPath xpath = XPathFactory.newInstance().newXPath();
        final EntryDAO entryDao = getDaoFacade().getEntryDAO();
        final BranchDAO branchDao = getDaoFacade().getBranchDAO();
        final Branch subListParent = branchDao.read(targetBranch.getBranchId());
        final Element entriesElement = (Element) xpath.evaluate(TAG_ENTRIES, branchElement, XPathConstants.NODE);

        if (entriesElement != null) {
            final NodeList entryList = (NodeList) xpath.evaluate(TAG_ENTRY, entriesElement, XPathConstants.NODESET);
            final String[] entryProperties = BeanUtils.getProperties(new Entry(), EXCLUDED_PROPS);
            final Entry entry = new Entry();
            for (int i = 0; entryList != null && i < entryList.getLength(); i++) {
                for (final String property : entryProperties) {
                    final Object val = getElementPropValue((Element) entryList.item(i),
                            BeanUtils.getPropertyType(entry, property), property);
                    if (val != null) {
                        try {
                            org.apache.commons.beanutils.BeanUtils.setProperty(entry, property, val);
                        } catch (final Exception e) {
                            throw new JournalException(e.getMessage(), e);
                        }
                    }
                }
                if (null == entryDao.readByTitle(entry.getTitle(), subListParent.getBranchId())) {
                    entry.setBranch(subListParent);
                    entry.setNodeId(0);
                    entryDao.save(entry);
                }
            }
        }

    }
View Full Code Here

     * @return {Entity, size}
     * @exception JournalException when the nodeId passed cannot be found.
     */
    Object[] getEntryNodeProperty(final StringBuilder strBuilder, final long nodeId)
    {
        final EntryDAO entryDao = getDaoFacade().getEntryDAO();
        final Entry entry = entryDao.read(nodeId);
        if (entry == null) {
            throw JournalException.wrapperException(new IllegalArgumentException(Messages.Error.IAE_NULL));
        }

        long size = entry.getTitle().length();
View Full Code Here

     * Case 1.4: Inserted entry has branch set.
     */
    @Test
    public final void testSaveEntry1()
    {
        final EntryDAO mockedEntryDAO = getDaoFacade().getEntryDAO();
        final BranchDAO mockedBranchDAO = getDaoFacade().getBranchDAO();

        final long branchId = 1L;
        final Branch testParentBranch = new Branch("Test Parent", null);
        when(mockedBranchDAO.read(branchId)).thenReturn(testParentBranch);
View Full Code Here

     * Case 2.4: Updated entry has branch set.
     */
    @Test
    public final void testSaveEntry2()
    {
        final EntryDAO mockedEntryDAO = getDaoFacade().getEntryDAO();
        final BranchDAO mockedBranchDAO = getDaoFacade().getBranchDAO();

        final long entryId = 1L;
        final Entry testEntry = new Entry();
        testEntry.setTitle("Test Title");
        testEntry.setDescription("Test Description");
        when(mockedEntryDAO.read(entryId)).thenReturn(testEntry);

        final long newBranchId = 666L;
        final String newTitle = "New Title";
        final String newDescription = "New Description";
        final Branch newParentBranch = new Branch("Test Parent", null);
View Full Code Here

    {
        super.setUp();
        spyInstance = getSpyInstance();

        final BranchDAO branchDAO = getDaoFacade().getBranchDAO();
        final EntryDAO entryDAO = getDaoFacade().getEntryDAO();

        testBranch1 = new Branch("RootBranch1", getTestRootBranch());
        testBranch1.setBranchId(TEST_ID_RTBRANCH1);

        testSubBranch1 = new Branch("SubBranch1", testBranch1);
        testSubBranch1.setBranchId(TEST_ID_SUBBRANCH1);

        final Entry entry1 = new Entry("Entry Title 1", "Entry Desc 1", testBranch1);
        final Entry entry2 = new Entry("Entry Title 2", "Entry Desc 2", testBranch1);
        final Entry entry3 = new Entry("Entry Title 3", "Entry Desc 3", testSubBranch1);

        when(branchDAO.readAllByParent(Constant.ROOT_ID)).thenReturn(Arrays.asList(new Branch[] { testBranch1 }));
        when(branchDAO.readAllByParent(TEST_ID_RTBRANCH1)).thenReturn(Arrays.asList(new Branch[] { testSubBranch1 }));
        when(entryDAO.readAllByBranch(TEST_ID_RTBRANCH1)).thenReturn(Arrays.asList(new Entry[] {
                entry1,
                entry2 }));
        when(entryDAO.readAllByBranch(TEST_ID_SUBBRANCH1)).thenReturn(Arrays.asList(new Entry[] { entry3 }));

        mockDocument = mock(Document.class);
        when(mockDocument.createElement(Mockito.anyString())).thenReturn(mock(Element.class));

        final XPathFactory mockXPathFac = mock(XPathFactory.class);
View Full Code Here

    }

    @Override
    public void moveEntry(final Map<String, Object> session, final long newParentId, final long entryId)
    {
        final EntryDAO entryDao = getDaoFacade().getEntryDAO();
        final BranchDAO branchDao = getDaoFacade().getBranchDAO();

        final Entry entry = entryDao.read(entryId);
        final Branch parent = branchDao.read(newParentId);
        if (entry == null || parent == null) {
            throw new IllegalArgumentException(Error.IAE_GENERIC);
        } else {
            entry.setBranch(parent);
            entryDao.save(entry);
        }
    }
View Full Code Here

    public void renameEntry(final Map<String, Object> session, final long entryId, final String newTitle)
    {
        if (newTitle == null || "".equals(newTitle)) {
            throw new IllegalArgumentException(Error.IAE_NULLOREMPTY);
        } else {
            final EntryDAO entryDao = getDaoFacade().getEntryDAO();
            final Entry entry = entryDao.read(entryId);
            if (entry == null) {
                throw new IllegalArgumentException("Entry ID: " + entryId + " was not found.");
            } else {
                entry.setTitle(newTitle);
                entryDao.save(entry);
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.philip.journal.home.dao.EntryDAO

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.