Package org.fao.geonet.domain

Examples of org.fao.geonet.domain.Metadata


            //
            boolean validate = false;
            boolean ufo = false;
            boolean index = false;
            String language = context.getLanguage();
            final Metadata metadata = dataMan.updateMetadata(context, id, md, validate, ufo, index, language, ri.changeDate.toString(),
                    true);

            //--- the administrator could change privileges and categories using the
      //--- web interface so we have to re-set both

            OperationAllowedRepository repository = context.getBean(OperationAllowedRepository.class);
            repository.deleteAllByIdAttribute(OperationAllowedId_.metadataId, Integer.parseInt(id));
            addPrivileges(id, params.getPrivileges(), localGroups, dataMan, context, log);

            metadata.getCategories().clear();
            addCategories(metadata, params.getCategories(), localCateg, context, log, null);

            dataMan.flush();
            dataMan.indexMetadata(id, false);
      result.updatedMetadata++;
View Full Code Here


                //
                boolean validate = false;
                boolean ufo = false;
                boolean index = false;
                String language = context.getLanguage();
                final Metadata metadata = dataMan.updateMetadata(context, id, md, validate, ufo, index, language, ri.changeDate, true);

                OperationAllowedRepository repository = context.getBean(OperationAllowedRepository.class);
        repository.deleteAllByIdAttribute(OperationAllowedId_.metadataId, Integer.parseInt(id));

                addPrivileges(id, params.getPrivileges(), localGroups, dataMan, context, log);

                metadata.getCategories().clear();
                addCategories(metadata, params.getCategories(), localCateg, context, log, null);

                dataMan.flush();

                dataMan.indexMetadata(id, false);
View Full Code Here

     * @param isIndexingTask If true, then withheld elements are not removed.
     * @return
     * @throws Exception
     */
  protected Element internalSelect(String id, boolean isIndexingTask) throws Exception {
        Metadata metadata = _metadataRepository.findOne(id);

    if (metadata == null)
      return null;

    String xmlData = metadata.getData();
    Element metadataXml = Xml.loadString(xmlData, false);

    if (!isIndexingTask) {
            ServiceContext context = ServiceContext.get();
            MetadataSchema mds = _dataManager.getSchema(metadata.getDataInfo().getSchemaId());

            // Check if a filter is defined for this schema
            // for the editing operation ie. user who can not edit
            // will not see those elements.
            Pair<String, Element> editXpathFilter = mds.getOperationFilter(ReservedOperation.editing);
View Full Code Here

     */
  protected Metadata insertDb(final Metadata newMetadata, final Element dataXml,ServiceContext context) throws SQLException {
    if (resolveXLinks()) Processor.removeXLink(dataXml);

        newMetadata.setData(Xml.getString(dataXml));
        Metadata savedMetadata = _metadataRepository.save(newMetadata);
    return savedMetadata;
  }
View Full Code Here

                            final String uuid) throws SQLException {

    if (resolveXLinks()) Processor.removeXLink(xml);

        int metadataId = Integer.valueOf(id);
        Metadata md = _metadataRepository.findOne(metadataId);

        md.setDataAndFixCR(xml);

        if (updateDateStamp)  {
            if (changeDate == null)  {
                md.getDataInfo().setChangeDate( new ISODate());
            } else {
                md.getDataInfo().setChangeDate( new ISODate(changeDate));
            }
        }

        if (uuid != null) {
            md.setUuid(uuid);
        }

        _metadataRepository.save(md);
  }
View Full Code Here

   *
   * @param uuid Uuid of register (ISO19135) metadata record describing thesaurus
   * @param os OutputStream to write rdf to from XSLT conversion
   */
  private void getRegisterMetadataAsRdf(String uuid, OutputStream os, ServiceContext context) throws Exception {
        Metadata mdInfo = context.getBean(MetadataRepository.class).findOneByUuid(uuid);
        Integer id = mdInfo.getId();
        final DataManager dataManager = context.getBean(DataManager.class);
        Element md = dataManager.getMetadata("" + id);
        Processor.detachXLink(md, context);
        final String siteURL = context.getBean(SettingManager.class).getSiteURL(context);
        Element env = Lib.prepareTransformEnv(mdInfo.getUuid(), mdInfo.getDataInfo().getChangeDate().getDateAndTime(),
                "", siteURL, "");

        //--- transform the metadata with the created env and specified stylesheet
        Element root = new Element("root");
        root.addContent(md);
View Full Code Here

    public void testExec() throws Exception {
        long beforeCount = _categoryRepository.count();
        final MetadataCategory category = _categoryRepository.findAll().get(0);
        assertEquals(beforeCount, _categoryRepository.count());

        Metadata entity = MetadataRepositoryTest.newMetadata(inc);
        entity.getCategories().add(category);
        entity = _MetadataRepository.save(entity);

        ServiceContext context = createServiceContext();
        loginAsAdmin(context);
        remove.exec(category.getId());

        assertEquals(beforeCount - 1, _categoryRepository.count());
        assertEquals(1, _MetadataRepository.count());
        entity = _MetadataRepository.findOne(entity.getId());
        assertTrue(entity.getCategories().isEmpty());
    }
View Full Code Here

    @Autowired
    MetadataCategoryRepository _categoryRepo;

    @Test
    public void testHasMetadataId() throws Exception {
        Metadata md1 = _repository.save(newMetadata(_inc));
        assertFindsCorrectMd(md1, hasMetadataId(md1.getId()), true);
    }
View Full Code Here

        assertFindsCorrectMd(md1, hasMetadataId(md1.getId()), true);
    }

    @Test
    public void testHasMetadataType() throws Exception {
        final Metadata metadata = newMetadata(_inc);
        metadata.getDataInfo().setType(MetadataType.METADATA);
        Metadata md1 = _repository.save(metadata);

        final Metadata metadata2 = newMetadata(_inc);
        metadata2.getDataInfo().setType(MetadataType.SUB_TEMPLATE);
        Metadata md2 = _repository.save(metadata2);

        final Metadata metadata3 = newMetadata(_inc);
        metadata3.getDataInfo().setType(MetadataType.TEMPLATE);
        Metadata md3 = _repository.save(metadata3);

        assertEquals(1, _repository.findAll(hasType(MetadataType.METADATA)).size());
        assertEquals(1, _repository.findAll(hasType(MetadataType.SUB_TEMPLATE)).size());
        assertEquals(1, _repository.findAll(hasType(MetadataType.TEMPLATE)).size());

        assertEquals(md1.getId(), _repository.findOne(hasType(MetadataType.METADATA)).getId());
        assertEquals(md2.getId(), _repository.findOne(hasType(MetadataType.SUB_TEMPLATE)).getId());
        assertEquals(md3.getId(), _repository.findOne(hasType(MetadataType.TEMPLATE)).getId());
    }
View Full Code Here

        final MetadataCategory cat1 = _categoryRepo.save(MetadataCategoryRepositoryTest.newMetadataCategory(_inc));
        final MetadataCategory cat2 = _categoryRepo.save(MetadataCategoryRepositoryTest.newMetadataCategory(_inc));
        final MetadataCategory cat3 = _categoryRepo.save(MetadataCategoryRepositoryTest.newMetadataCategory(_inc));
        final MetadataCategory cat4 = _categoryRepo.save(MetadataCategoryRepositoryTest.newMetadataCategory(_inc));

        final Metadata metadata = newMetadata(_inc);
        metadata.getCategories().add(cat1);
        metadata.getCategories().add(cat2);
        Metadata md1 = _repository.save(metadata);

        final Metadata metadata2 = newMetadata(_inc);
        metadata2.getCategories().add(cat1);
        metadata2.getCategories().add(cat3);
        Metadata md2 = _repository.save(metadata2);

        final Metadata metadata3 = newMetadata(_inc);
        metadata3.getCategories().add(cat2);
        Metadata md3 = _repository.save(metadata3);

        List<Metadata> found = _repository.findAll(hasCategory(cat1), SortUtils.createSort(Metadata_.id));

        assertEquals(2, found.size());
        assertEquals(md1.getId(), found.get(0).getId());
        assertEquals(md2.getId(), found.get(1).getId());

        found = _repository.findAll(hasCategory(cat2), SortUtils.createSort(Metadata_.id));
        assertEquals(2, found.size());
        assertEquals(md1.getId(), found.get(0).getId());
        assertEquals(md3.getId(), found.get(1).getId());

        found = _repository.findAll(hasCategory(cat3), SortUtils.createSort(Metadata_.id));
        assertEquals(1, found.size());
        assertEquals(md2.getId(), found.get(0).getId());
View Full Code Here

TOP

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

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.