Package org.fao.geonet.repository

Examples of org.fao.geonet.repository.SchematronCriteriaGroupRepository


            System.setProperty(Constants.XML_CATALOG_FILES, catalogProp);
            Xml.resetResolver();
        }

        SchematronRepository schemaRepo = applicationContext.getBean(SchematronRepository.class);
        SchematronCriteriaGroupRepository criteriaGroupRepository = applicationContext.getBean(SchematronCriteriaGroupRepository.class);
        MetadataSchema mds = new SchemaLoader().load(xmlSchemaFile, xmlSubstitutionsFile, schemaRepo, criteriaGroupRepository);

        mds.setName(name);
        mds.setSchemaDir(path);
        mds.loadSchematronRules(basePath);
View Full Code Here


    @Override
    protected Element delete(Element params, ServiceContext context) throws Exception {
        String groupName = Util.getParam(params, PARAM_GROUP_NAME);
        int schematronId = Integer.parseInt(Util.getParam(params, PARAM_SCHEMATRON_ID));

        final SchematronCriteriaGroupRepository repository = context.getBean(SchematronCriteriaGroupRepository.class);
        try {
            repository.delete(new SchematronCriteriaGroupId(groupName, schematronId));
        } catch (EmptyResultDataAccessException e) {
            if (!context.getBean(SchematronRepository.class).exists(schematronId)) {
                throw new BadParameterEx(PARAM_SCHEMATRON_ID, ""+schematronId);
            } else {
                throw new BadParameterEx(PARAM_GROUP_NAME, groupName);
View Full Code Here

        boolean includeCriteriaParamPresent = params.getChild(PARAM_INCLUDE_CRITERIA) != null;
        boolean includeCriteria = Util.getParam(params, PARAM_INCLUDE_CRITERIA, includeCriteriaParamPresent);
        boolean includeSchematronParamPresent = params.getChild(PARAM_INCLUDE_SCHEMATRON) != null;
        boolean includeSchematron = Util.getParam(params, PARAM_INCLUDE_SCHEMATRON, includeSchematronParamPresent);

        final SchematronCriteriaGroupRepository repository = context.getBean(SchematronCriteriaGroupRepository.class);
        Specifications<SchematronCriteriaGroup> spec = null;

        if (schematronId != null) {
            spec = Specifications.where(SchematronCriteriaGroupSpecs.hasSchematronId(Integer.parseInt(schematronId)));
        }

        if (groupName != null) {
            if (spec == null) {
                spec = Specifications.where(SchematronCriteriaGroupSpecs.hasGroupName(groupName));
            } else {
                spec = spec.and(SchematronCriteriaGroupSpecs.hasGroupName(groupName));
            }
        }

        Element groups = repository.findAllAsXml(spec);

        @SuppressWarnings("unchecked")
        final List<Element> records = groups.getChildren(GeonetEntity.RECORD_EL_NAME);
        if (!includeCriteria || !includeSchematron) {
            for (Element child : records) {
View Full Code Here

        }

    }

    private Element updateRequirement(Element params, ServiceContext context) {
        final SchematronCriteriaGroupRepository repository = context.getBean(SchematronCriteriaGroupRepository.class);

        String groupName = Util.getParam(params, PARAM_GROUP_NAME);
        int schematronId = Integer.parseInt(Util.getParam(params, PARAM_SCHEMATRON_ID));
        final String requirement = Util.getParam(params, PARAM_REQUIREMENT, null);

        if (requirement != null) {
            repository.update(new SchematronCriteriaGroupId(groupName, schematronId), new Updater<SchematronCriteriaGroup>() {
                @Override
                public void apply(@Nonnull SchematronCriteriaGroup entity) {
                    entity.setRequirement(SchematronRequirement.valueOf(requirement.toUpperCase()));
                }
            });
View Full Code Here

        return new Element("NoUpdate");
    }

    private Element renameGroup(Element params, ServiceContext context) {
        final SchematronCriteriaGroupRepository repository = context.getBean(SchematronCriteriaGroupRepository.class);
        String groupName = Util.getParam(params, PARAM_GROUP_NAME);
        int schematronId = Integer.parseInt(Util.getParam(params, PARAM_SCHEMATRON_ID));
        String newRequirement = Util.getParam(params, PARAM_REQUIREMENT, null);
        final SchematronCriteriaGroup group = repository.findOne(new SchematronCriteriaGroupId(groupName, schematronId));

        SchematronRequirement finalRequirement = group.getRequirement();
        if (newRequirement != null) {
            finalRequirement = SchematronRequirement.valueOf(newRequirement.toUpperCase());
        }

        String newGroupName = Util.getParam(params, PARAM_NEW_GROUP_NAME, groupName);
        int newSchematronId = Util.getParam(params, PARAM_NEW_SCHEMATRON_ID, schematronId);

        SchematronCriteriaGroup newGroup = new SchematronCriteriaGroup().
                setId(new SchematronCriteriaGroupId(newGroupName, newSchematronId)).
                setRequirement(finalRequirement);
        for (SchematronCriteria schematronCriteria : group.getCriteria()) {
            newGroup.addCriteria(schematronCriteria.copy());
        }

        if (group.getId().equals(newGroup.getId())) {
            throw new BadInputEx(PARAM_NEW_GROUP_NAME + " and " + PARAM_NEW_SCHEMATRON_ID +
                                 " have the same value as the old values", newGroupName+":"+newSchematronId){};
        }

        repository.delete(group.getId());
        repository.saveAndFlush(newGroup);
        return new Element("ok");
    }
View Full Code Here

    @Override
    protected Element add(Element params, ServiceContext context) throws Exception {
        String groupName = Util.getParam(params, SchematronCriteriaGroupService.PARAM_GROUP_NAME);
        int schematronId = Integer.parseInt(Util.getParam(params, SchematronCriteriaGroupService.PARAM_SCHEMATRON_ID));

        final SchematronCriteriaGroupRepository criteriaGroupRepository = context.getBean(SchematronCriteriaGroupRepository.class);

        final SchematronCriteriaType type = SchematronCriteriaType
                .valueOf(Util.getParam(params, PARAM_TYPE));
        final String value = Util.getParam(params, PARAM_VALUE, "");
        final String uitype = Util.getParam(params, PARAM_UI_TYPE);
        final String uivalue = Util.getParam(params, PARAM_UI_VALUE, "");

        final SchematronCriteriaGroupId id = new SchematronCriteriaGroupId(groupName, schematronId);
        SchematronCriteriaGroup group = criteriaGroupRepository.findOne(id);
        if (group == null) {
            group = new SchematronCriteriaGroup();
            group.setId(id);
            group.setRequirement(SchematronRequirement.REQUIRED);
        }

        SchematronCriteria criteria = new SchematronCriteria();
        criteria.setType(type);
        criteria.setValue(value);
        criteria.setUiType(uitype);
        criteria.setUiValue(uivalue);
        group.addCriteria(criteria);

        group = criteriaGroupRepository.saveAndFlush(group);
        SchematronCriteria savedCriteria = group.getCriteria().get(group.getCriteria().size() - 1);

        Element result = new Element(Jeeves.Elem.RESPONSE);
        result.addContent(new Element("status").setText("success"));
        result.addContent(new Element("id").setText("" + savedCriteria.getId()));
View Full Code Here

    }

    @Override
    public Element exec(Element params, ServiceContext context) throws Exception {
        SchemaManager schemaManager = context.getApplicationContext().getBean(SchemaManager.class);
        SchematronCriteriaGroupRepository criteriaGroupRepo = context.getApplicationContext().getBean(SchematronCriteriaGroupRepository.class);
        final XmlCacheManager cacheManager = context.getBean(XmlCacheManager.class);

        Element schematrons = schematronService.exec(params, context);
        Element results = new Element(Jeeves.Elem.RESPONSE);
        Element schemas = new Element("schemas");
View Full Code Here

        final String schemaDir = this.schemaMan.getSchemaDir(schema);

        Element schemaTronXmlOut = new Element("schematronerrors", Edit.NAMESPACE);
        try {
            final SchematronRepository schematronRepository = _applicationContext.getBean(SchematronRepository.class);
            final SchematronCriteriaGroupRepository criteriaGroupRepository = _applicationContext.getBean(SchematronCriteriaGroupRepository.class);

            final List<Schematron> schematronList = schematronRepository.findAllBySchemaName(metadataSchema.getName());

            //Loop through all xsl files
            for (Schematron schematron : schematronList) {

                int id = schematron.getId();
                //it contains absolute path to the xsl file
                String rule = schematron.getRuleName();
                String dbident = ""+id;

                List<SchematronCriteriaGroup> criteriaGroups = criteriaGroupRepository.findAllById_SchematronId(schematron.getId());

                //Loop through all criteria to see if apply schematron
                //if any criteria does not apply, do not apply at all (AND)
                SchematronRequirement requirement = SchematronRequirement.DISABLED;
                for (SchematronCriteriaGroup criteriaGroup : criteriaGroups) {
View Full Code Here

TOP

Related Classes of org.fao.geonet.repository.SchematronCriteriaGroupRepository

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.