Package org.fao.geonet.domain

Examples of org.fao.geonet.domain.HarvesterSetting


    }

    @Test
    public void testFindByPathUsingId() throws Exception {

        HarvesterSetting parent = _repo.save(newSetting());
        HarvesterSetting child2 = _repo.save(newSetting().setParent(parent));
        _repo.save(newSetting().setParent(parent));

        List<HarvesterSetting> found = _repo.findAllByPath("id:" + child2.getId());
        assertEquals(1, found.size());
        assertSameContents(child2, found.get(0), _skipProps);

        found = _repo.findAllByPath("id:" + parent.getId());
        assertEquals(1, found.size());
View Full Code Here


    }

    @Test
    public void testFindByRootByPath() throws Exception {

        HarvesterSetting parent = _repo.save(newSetting());
        final HarvesterSetting parent2 = _repo.save(newSetting());
        _repo.save(newSetting().setParent(parent));

        List<HarvesterSetting> found = _repo.findAllByPath(parent.getName());
        assertEquals(1, found.size());
        assertSameContents(parent, found.get(0), _skipProps);

        found = _repo.findAllByPath(parent2.getName());
        assertEquals(1, found.size());
        assertSameContents(parent2, found.get(0), _skipProps);
    }
View Full Code Here

        String sValue = makeString(value);

        // --- first, we look into the tasks list because the 'id' could have been
        // --- added just now

        HarvesterSetting parent = _settingsRepo.findOneByPath(path);

        if (parent == null)
            return null;

        HarvesterSetting child = new HarvesterSetting().setParent(parent).setName(sName).setValue(sValue);

        _settingsRepo.save(child);
        return Integer.toString(child.getId());
    }
View Full Code Here

        assertSameContents(parent2, found.get(0), _skipProps);
    }

    @Test
    public void testFindByPathUsingTwoId() throws Exception {
        HarvesterSetting parent = _repo.save(newSetting());
        HarvesterSetting child2 = _repo.save(newSetting().setParent(parent));
        _repo.save(newSetting().setParent(parent));

        List<HarvesterSetting> found = _repo.findAllByPath("id:" + Integer.MAX_VALUE + "/id:" + child2.getId());
        assertEquals(1, found.size());
        assertSameContents(child2, found.get(0), _skipProps);
    }
View Full Code Here

     * @param path
     * @return
     * @throws SQLException
     */
    public boolean remove(String path) throws SQLException {
        HarvesterSetting s = _settingsRepo.findOneByPath(path);
        if (s == null)
            return false;

        _settingsRepo.delete(s);
        return true;
View Full Code Here

        assertSameContents(child2, found.get(0), _skipProps);
    }

    @Test
    public void testFindByPathUsingChildNamePath() throws Exception {
        HarvesterSetting parent = _repo.save(newSetting());
        HarvesterSetting child2 = _repo.save(newSetting().setParent(parent).setName("2"));
        HarvesterSetting child3 = _repo.save(newSetting().setParent(parent).setName("3"));
        HarvesterSetting child4 = _repo.save(newSetting().setParent(child3).setName("4"));

        String path = SEPARATOR + child3.getName() + SEPARATOR + child4.getName();
        List<HarvesterSetting> found = _repo.findAllByPath(path);
        assertEquals(1, found.size());
        assertSameContents(child4, found.get(0), _skipProps);

        String path2 = SEPARATOR + child2.getName() + SEPARATOR + child4.getName();
        List<HarvesterSetting> found2 = _repo.findAllByPath(path2);
        assertEquals(0, found2.size());
    }
View Full Code Here

     * @param path
     * @return
     * @throws SQLException
     */
    public boolean removeChildren(String path) throws SQLException {
        HarvesterSetting parent = _settingsRepo.findOneByPath(path);

        if (parent == null)
            return false;

        List<HarvesterSetting> children = _settingsRepo.findAllChildren(parent.getId());
        for (HarvesterSetting child : children) {
            remove(child);
        }

        return true;
View Full Code Here

    // --- Auxiliary methods
    // ---------------------------------------------------------------------------


    public boolean getValueAsBool(String path, boolean defValue) {
        HarvesterSetting setting = _settingsRepo.findOneByPath(path);
        if (setting == null) {
            return defValue;
        }
        return setting.getValueAsBool();
    }
View Full Code Here

        assertEquals(0, found2.size());
    }

    @Test
    public void testFindByPathFindingMany() throws Exception {
        HarvesterSetting parent = _repo.save(newSetting().setName("1"));
        _repo.save(newSetting().setParent(parent).setName("2"));
        HarvesterSetting child3 = _repo.save(newSetting().setParent(parent).setName("2"));

        String path = child3.getName();
        List<HarvesterSetting> found = _repo.findAllByPath(path);
        assertEquals(2, found.size());
    }
View Full Code Here

        assertEquals(2, found.size());
    }

    @Test
    public void testFindByPathUsingIdAndChildNamePath() throws Exception {
        HarvesterSetting parent = _repo.save(newSetting().setName("2"));
        HarvesterSetting child2 = _repo.save(newSetting().setParent(parent).setName("2"));
        HarvesterSetting child3 = _repo.save(newSetting().setParent(parent).setName("3"));
        HarvesterSetting child4 = _repo.save(newSetting().setParent(child3).setName("4"));

        String path = ID_PREFIX + child3.getId() + SEPARATOR + child4.getName();
        List<HarvesterSetting> found = _repo.findAllByPath(path);
        assertEquals(1, found.size());
        assertSameContents(child4, found.get(0), _skipProps);

        String path2 = SEPARATOR + child2.getName() + SEPARATOR + child4.getName();
        List<HarvesterSetting> found2 = _repo.findAllByPath(path2);
        assertEquals(0, found2.size());
    }
View Full Code Here

TOP

Related Classes of org.fao.geonet.domain.HarvesterSetting

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.