Examples of MetadataCategory


Examples of org.fao.geonet.domain.MetadataCategory

    @PersistenceContext
    EntityManager _entityManager;

    @Test
    public void testFindOne() {
        MetadataCategory category1 = newMetadataCategory();
        category1 = _repo.save(category1);

        MetadataCategory category2 = newMetadataCategory();
        category2 = _repo.save(category2);

        assertEquals(category2, _repo.findOne(category2.getId()));
        assertEquals(category1, _repo.findOne(category1.getId()));
    }
View Full Code Here

Examples of org.fao.geonet.domain.MetadataCategory

        assertEquals(category1, _repo.findOne(category1.getId()));
    }

    @Test
    public void testFindOneByNameIgnoreCase() {
        MetadataCategory category1 = newMetadataCategory();
        category1 = _repo.save(category1);

        MetadataCategory category2 = newMetadataCategory();
        _repo.save(category2);

        assertEquals(category1, _repo.findOneByNameIgnoreCase(category1.getName().toLowerCase()));
        assertEquals(category1, _repo.findOneByNameIgnoreCase(category1.getName().toUpperCase()));
    }
View Full Code Here

Examples of org.fao.geonet.domain.MetadataCategory

        assertEquals(category1, _repo.findOneByNameIgnoreCase(category1.getName().toUpperCase()));
    }

    @Test
    public void testFindOneByName() {
        MetadataCategory category1 = newMetadataCategory();
        category1 = _repo.save(category1);

        MetadataCategory category2 = newMetadataCategory();
        category2 = _repo.save(category2);

        MetadataCategory metadataCategory = _repo.findOneByName(category1.getName());
        assertEquals(category1.getName(), metadataCategory.getName());

        metadataCategory = _repo.findOneByName(category2.getName());
        assertEquals(category2.getName(), metadataCategory.getName());
    }
View Full Code Here

Examples of org.fao.geonet.domain.MetadataCategory


    @Test
    public void testDeleteDeletesFromMetadata() throws Exception {

        MetadataCategory cat1 = _repo.save(newMetadataCategory(_inc));
        MetadataCategory cat2 = _repo.save(newMetadataCategory(_inc));

        Metadata metadata1 = MetadataRepositoryTest.newMetadata(_inc);
        metadata1.getCategories().add(cat1);
        metadata1.getCategories().add(cat2);
        metadata1 = _metadataRepo.save(metadata1);

        Metadata metadata2 = MetadataRepositoryTest.newMetadata(_inc);
        metadata2.getCategories().add(cat1);
        metadata2 = _metadataRepo.save(metadata2);

        _repo.deleteCategoryAndMetadataReferences(cat1.getId());

        _entityManager.flush();
        _entityManager.clear();

        // org.fao.geonet.services.category.Remove assumes that this test passes.  If this test can't pass
        // then there needs to be a way to fix Remove as well.
        final Set<MetadataCategory> foundCategories = _metadataRepo.findOne(metadata1.getId()).getCategories();
        assertEquals(1, foundCategories.size());
        assertEquals(cat2.getId(), foundCategories.iterator().next().getId());

        assertEquals(0, _metadataRepo.findOne(metadata2.getId()).getCategories().size());
    }
View Full Code Here

Examples of org.fao.geonet.domain.MetadataCategory

        return newMetadataCategory(_inc);
    }

    public static MetadataCategory newMetadataCategory(AtomicInteger inc) {
        int val = inc.incrementAndGet();
        MetadataCategory metadataCategory = new MetadataCategory();
        metadataCategory.setName("name" + val);
        metadataCategory.getLabelTranslations().put("eng", "engLab" + val);
        metadataCategory.getLabelTranslations().put("fre", "fraLab" + val);
        metadataCategory.getLabelTranslations().put("ger", "gerLab" + val);

        return metadataCategory;
    }
View Full Code Here

Examples of org.fao.geonet.domain.MetadataCategory

                .setSourceId(source);
        if (groupOwner != null) {
            newMetadata.getSourceInfo().setGroupOwner(Integer.valueOf(groupOwner));
        }
        if (category != null) {
            MetadataCategory metadataCategory = _applicationContext.getBean(MetadataCategoryRepository.class).findOneByName(category);
            if (metadataCategory == null) {
                throw new IllegalArgumentException("No category found with name: "+category);
            }
            newMetadata.getCategories().add(metadataCategory);
        }
View Full Code Here

Examples of org.fao.geonet.domain.MetadataCategory

     * @throws Exception
     */
    public void setCategory(ServiceContext context, String mdId, String categId) throws Exception {
        final MetadataCategoryRepository categoryRepository = _applicationContext.getBean(MetadataCategoryRepository.class);

        final MetadataCategory newCategory = categoryRepository.findOne(Integer.valueOf(categId));
        final boolean[] changed = new boolean[1];
        _metadataRepository.update(Integer.valueOf(mdId), new Updater<Metadata>() {
            @Override
            public void apply(@Nonnull Metadata entity) {
                changed[0] = !entity.getCategories().contains(newCategory);
View Full Code Here

Examples of org.fao.geonet.domain.MetadataCategory

                final MetadataCategoryRepository categoryRepository = context.getBean(MetadataCategoryRepository.class);
                for (Element el : list) {
          String name = el.getName();

          if (name.startsWith("_"))  {
                        final MetadataCategory category = categoryRepository.findOne(Integer.valueOf(name.substring(1)));
                        if (category != null) {
                            info.getCategories().add(category);
                        } else {
                            context.warning("Unable to find category with name: "+name.substring(1));
                        }
View Full Code Here

Examples of org.fao.geonet.domain.MetadataCategory

        final User principal = serviceContext.getUserSession().getPrincipal();

        final GroupRepository bean = serviceContext.getBean(GroupRepository.class);
        Group group = bean.findAll().get(0);

        MetadataCategory category = serviceContext.getBean(MetadataCategoryRepository.class).findAll().get(0);

        final SourceRepository sourceRepository = serviceContext.getBean(SourceRepository.class);
        Source source = sourceRepository.save(new Source().setLocal(true).setName("GN").setUuid("sourceuuid"));

        final Element sampleMetadataXml = super.getSampleMetadataXml();
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.