Package org.fao.geonet.domain

Examples of org.fao.geonet.domain.Schematron


    }

    private void addSchematron(String schemaName) {
        final SchemaManager schemaManager = _applicationContext.getBean(SchemaManager.class);
        final SchematronRepository repo = _applicationContext.getBean(SchematronRepository.class);
        Schematron schematron = new Schematron();
        schematron.setSchemaName(schemaName);
        schematron.setFile(schemaManager.getSchemaDir(schemaName) + File.separator + "schematron" + File.separator
                           + "schematron-rules-geonetwork.sch");
        repo.save(schematron);
    }
View Full Code Here


    private AtomicInteger _inc = new AtomicInteger();


    @Test
    public void testFindOne() throws Exception {
        final Schematron schematron = _repo.save(newSchematron(_inc));

        final Schematron found = _repo.findOne(schematron.getId());

        assertSameContents(schematron, found);
    }
View Full Code Here

        assertSameContents(schematron, found);
    }

    @Test
    public void testFindAllByIsoschema() throws Exception {
        final Schematron schematron1 = _repo.save(newSchematron(_inc));
        final Schematron schematron2 = _repo.save(newSchematron(_inc));
        final Schematron entity = newSchematron(_inc);
        entity.setSchemaName(schematron1.getSchemaName());
        final Schematron schematron3 = _repo.save(entity);

        final List<Schematron> allByIsoschema = _repo.findAllBySchemaName(schematron1.getSchemaName());

        assertEquals(2, allByIsoschema.size());

        for (Schematron schematron : allByIsoschema) {
            if (schematron.getId() == schematron2.getId()) {
                fail("schematron 2 should not have been found.  Schematron found are: "+allByIsoschema);
            } else if (schematron.getId() != schematron1.getId() && schematron.getId() != schematron3.getId()) {
                fail("schematron id was neither from schematron 1 or 2: "+allByIsoschema);
            }
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testFindAllByFileAndSchemaName() throws Exception {
        final Schematron schematron1 = _repo.save(newSchematron(_inc));
        _repo.save(newSchematron(_inc));
        final Schematron entity = newSchematron(_inc);
        entity.setFile(schematron1.getFile());
        _repo.save(entity);

        final Schematron oneBySchemaAndFile = _repo.findOneByFileAndSchemaName(schematron1.getFile(), schematron1.getSchemaName());

        assertNotNull(oneBySchemaAndFile);
    }
View Full Code Here

        assertNotNull(oneBySchemaAndFile);
    }

    @Test (expected = DataIntegrityViolationException.class)
    public void testUniqueContraintSchemaNameAndFile() throws Exception {
        final Schematron schematron = _repo.saveAndFlush(newSchematron(_inc));
        Schematron illegalSchematron = new Schematron();
        illegalSchematron.setFile(schematron.getFile());
        illegalSchematron.setSchemaName(schematron.getSchemaName());
        _repo.saveAndFlush(illegalSchematron);
    }
View Full Code Here

    }

    public static Schematron newSchematron(AtomicInteger inc) {
        int id = inc.incrementAndGet();

        final Schematron schematron = new Schematron();
        schematron.setFile("file"+id);
        schematron.setSchemaName("schema" + id);

        return schematron;
    }
View Full Code Here

        Element result;
        if (id == null) {
            result = repository.findAllAsXml();
        } else {
            final Schematron one = repository.findOne(Integer.parseInt(id));
            if (one == null) {
                throw new BadParameterEx(Params.ID, id);
            }
            result = new Element("schematron").addContent(one.asXml());
        }

        result.setName("schematron");
        return result;
    }
View Full Code Here

        assertEquals(_group1_Name1_SchematronId1.getCriteria().size(), result.getChild(GeonetEntity.RECORD_EL_NAME).getChild("criteria").getChildren().size());
    }

    @Test
    public void testExecEditSchematronId() throws Exception {
        Schematron newSchematron = _schematronRepository.save(SchematronRepositoryTest.newSchematron(_inc));
        ServiceContext context = createServiceContext();
        loginAsAdmin(context);


        Element editParams = createParams(
                read(SchematronCriteriaGroupService.PARAM_GROUP_NAME, _group1_Name1_SchematronId1.getId().getName()),
                read(SchematronCriteriaGroupService.PARAM_SCHEMATRON_ID, _group1_Name1_SchematronId1.getId().getSchematronId()),
                read(SchematronCriteriaGroupService.PARAM_NEW_SCHEMATRON_ID, newSchematron.getId())

        );

        Element result = createService(EDIT).exec(editParams, context);
        assertEquals("ok", result.getName());

        Element listParamsOldName = createParams(
                read(SchematronCriteriaGroupService.PARAM_GROUP_NAME, _group1_Name1_SchematronId1.getId().getName()),
                read(SchematronCriteriaGroupService.PARAM_SCHEMATRON_ID, _group1_Name1_SchematronId1.getId().getSchematronId())
        );

        result = createService(EXISTS).exec(listParamsOldName, context);
        assertEquals(""+false, result.getText());

        Element listParamsNewName = createParams(
                read(SchematronCriteriaGroupService.PARAM_GROUP_NAME, _group1_Name1_SchematronId1.getId().getName()),
                read(SchematronCriteriaGroupService.PARAM_SCHEMATRON_ID, newSchematron.getId())
        );

        result = createService(LIST).exec(listParamsNewName, context);
        assertEquals(1, result.getChildren().size());
View Full Code Here

TOP

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

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.