Examples of HarvesterSetting


Examples of org.fao.geonet.domain.HarvesterSetting

        List<HarvesterSetting> currentSettings = null;
        String firstSegment = pathSegments.get(0);
        if (firstSegment.startsWith(ID_PREFIX)) {
            int id = Integer.parseInt(firstSegment.substring(ID_PREFIX.length()));
            HarvesterSetting setting = _entityManager.find(HarvesterSetting.class, id);
            if (setting == null) {
                currentSettings = Collections.emptyList();
                pathSegments = Collections.emptyList();
            } else {
                currentSettings = Collections.singletonList(setting);
                pathSegments = pathSegments.subList(1, pathSegments.size());
            }
        } else {
            currentSettings = findRoots();
            for (HarvesterSetting currentSetting : currentSettings) {
                if (currentSetting.getName().equals(firstSegment)) {
                    pathSegments.remove(0);
                    currentSettings = Arrays.asList(currentSetting);
                    break;
                }
            }
        }

        for (String childName : pathSegments) {
            List<HarvesterSetting> oldSettings = currentSettings;
            currentSettings = new LinkedList<HarvesterSetting>();
            for (HarvesterSetting setting : oldSettings) {
                List<HarvesterSetting> children = findChildrenByName(setting.getId(), childName);
                currentSettings.addAll(children);
            }
        }
        return currentSettings;
    }
View Full Code Here

Examples of org.fao.geonet.domain.HarvesterSetting

     * @param path path to the setting that is root of the subtree
     * @param level depth of tree to create
     * @return
     */
    public Element get(String path, int level) {
        HarvesterSetting s = _settingsRepo.findOneByPath(path);

        return (s == null) ? null : build(s, level);
    }
View Full Code Here

Examples of org.fao.geonet.domain.HarvesterSetting

    private String[] _skipProps = new String[]{"getValueAsInt", "getValueAsBool"};

    @Test
    public void testFindByName() throws Exception {
        HarvesterSetting setting = _repo.save(newSetting());
        List<HarvesterSetting> found = _repo.findByName(setting.getName());
        assertEquals(1, found.size());
        assertSameContents(setting, found.get(0), _skipProps);
        assertEquals(0, _repo.findByName("some wrong name").size());
    }
View Full Code Here

Examples of org.fao.geonet.domain.HarvesterSetting

    }

    // ---------------------------------------------------------------------------

    public String getValue(String path) {
        HarvesterSetting s = _settingsRepo.findOneByPath(path);

        return (s == null) ? null : s.getValue();
    }
View Full Code Here

Examples of org.fao.geonet.domain.HarvesterSetting

        assertEquals(0, _repo.findByName("some wrong name").size());
    }

    @Test
    public void testFindRoot() throws Exception {
        HarvesterSetting actualRoot = _repo.save(newSetting());
        List<HarvesterSetting> roots = _repo.findRoots();
        assertEquals(1, roots.size());

        HarvesterSetting root = roots.get(0);
        assertSameContents(actualRoot, root, _skipProps);
        assertNull(root.getParent());
    }
View Full Code Here

Examples of org.fao.geonet.domain.HarvesterSetting

        assertNull(root.getParent());
    }

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

        assertEquals(2, _repo.count());

        List<HarvesterSetting> children = _repo.findAllChildren(parent.getId());
View Full Code Here

Examples of org.fao.geonet.domain.HarvesterSetting

     */
    public boolean setName(String path, String name) throws SQLException {
        if (path == null)
            throw new IllegalArgumentException("Path cannot be null");

        HarvesterSetting updatedSetting = _settingsRepo.findOneByPath(path);
        if (updatedSetting == null) {
            return false;
        } else {
            updatedSetting.setName(name);
            _settingsRepo.save(updatedSetting);

            return true;
        }
    }
View Full Code Here

Examples of org.fao.geonet.domain.HarvesterSetting

    }

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

        assertEquals(2, _repo.count());

        List<Integer> children = _repo.findAllChildIds(parent.getId());
        assertEquals(1, children.size());
        assertEquals(child.getId(), children.get(0).intValue());

    }
View Full Code Here

Examples of org.fao.geonet.domain.HarvesterSetting

    }

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

        assertEquals(3, _repo.count());

        List<HarvesterSetting> children = _repo.findChildrenByName(parent.getId(), child3.getName());
        assertEquals(1, children.size());
        assertSameContents(child3, children.get(0), _skipProps);

    }
View Full Code Here

Examples of org.fao.geonet.domain.HarvesterSetting

        List<HarvesterSetting> toSave = new ArrayList<HarvesterSetting>(values.size());
        for (Map.Entry<String, Object> entry : values.entrySet()) {
            String path = entry.getKey();
            String value = makeString(entry.getValue());

            HarvesterSetting s = _settingsRepo.findOneByPath(path);

            if (s == null) {
                success = false;
                Log.warning(Geonet.SETTINGS, "Unable to find Settings row for: " + path + ". Check settings table.");
            } else {
                s.setValue(value);
                if (Log.isDebugEnabled(Geonet.SETTINGS)) {
                    Log.debug(Geonet.SETTINGS, "Set path: " + path + ", value: " + value);
                }
                toSave.add(s);
            }
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.