Examples of MetadataSchema


Examples of org.fao.geonet.kernel.schema.MetadataSchema

     * @param lang
     * @param valTypeAndStatus    @return errors
     */
    public Element applyCustomSchematronRules(String schema, int metadataId, Element md,
                                              String lang, Map<String, Integer[]> valTypeAndStatus) {
        MetadataSchema metadataSchema = getSchema(schema);
        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) {
                    List<SchematronCriteria> criterias = criteriaGroup.getCriteria();
                    boolean apply = false;
                    for(SchematronCriteria criteria : criterias) {
                        boolean tmpApply = criteria.accepts(_applicationContext, metadataId, md, metadataSchema.getSchemaNS());

                        if(!tmpApply) {
                            apply = false;
                            break;
                        } else {
View Full Code Here

Examples of org.fao.geonet.kernel.schema.MetadataSchema

        final SchematronRepository schematronRepository = context.getBean(SchematronRepository.class);
        // --- add translations for schematrons
        final List<Schematron> schematrons = schematronRepository.findAllBySchemaName(schemaName);

        MetadataSchema metadataSchema = dataMan.getSchema(schemaName);
        String schemaDir = metadataSchema.getSchemaDir();
        SAXBuilder builder = new SAXBuilder();

        for (Schematron schematron : schematrons) {
            // it contains absolute path to the xsl file
            String rule = schematron.getRuleName();
View Full Code Here

Examples of org.fao.geonet.kernel.schema.MetadataSchema

        //--- then we must skip this phase
        Namespace ns = md.getNamespace();
        if (ns == Namespace.NO_NAMESPACE)
            return;

        MetadataSchema mds = schemaMan.getSchema(schema);

        //--- get the namespaces and add prefixes to any that are
        //--- default (ie. prefix is '') if namespace match one of the schema
        ArrayList<Namespace> nsList = new ArrayList<Namespace>();
        nsList.add(ns);
        @SuppressWarnings("unchecked")
        List<Namespace> additionalNamespaces = md.getAdditionalNamespaces();
        nsList.addAll(additionalNamespaces);
        for (Object aNsList : nsList) {
            Namespace aNs = (Namespace) aNsList;
            if (aNs.getPrefix().equals("")) { // found default namespace
                String prefix = mds.getPrefix(aNs.getURI());
                if (prefix == null) {
                    Log.warning(Geonet.DATA_MANAGER, "Metadata record contains a default namespace " + aNs.getURI() + " (with no prefix) which does not match any " + schema + " schema's namespaces.");
                }
                ns = Namespace.getNamespace(prefix, aNs.getURI());
                setNamespacePrefix(md, ns);
View Full Code Here

Examples of org.fao.geonet.kernel.schema.MetadataSchema

    public void notifyMetadataChange (Element md, String metadataId) throws Exception {

        final Metadata metadata = _metadataRepository.findOne(metadataId);
        if (metadata != null && metadata.getDataInfo().getType() == MetadataType.METADATA) {
            MetadataSchema mds = servContext.getBean(DataManager.class).getSchema(metadata.getDataInfo().getSchemaId());
            Pair<String, Element> editXpathFilter = mds.getOperationFilter(ReservedOperation.editing);
            XmlSerializer.removeFilteredElement(md, editXpathFilter, mds.getNamespaces());

            String uuid = getMetadataUuid( metadataId);
            servContext.getBean(MetadataNotifierManager.class).updateMetadata(md, metadataId, uuid, servContext);
        }
    }
View Full Code Here

Examples of org.fao.geonet.kernel.schema.MetadataSchema

        boolean forEditing = false, withValidationErrors = false, keepXlinkAttributes = false;
        Element md = gc.getBean(DataManager.class).getMetadata(context, id, forEditing, withValidationErrors, keepXlinkAttributes);

        // List or analyze all suggestions process registered for this schema
        if ("list".equals(action) || "analyze".equals(action)) {
            MetadataSchema metadataSchema = dm.getSchema(mdInfo.getDataInfo().getSchemaId());
            String filePath = metadataSchema.getSchemaDir() + "/"
                    + XSL_SUGGEST;
            File xslProcessing = new File(filePath);
            if (xslProcessing.exists()) {
                // -- here we send parameters set by user from
                // URL if needed.
View Full Code Here

Examples of org.fao.geonet.kernel.schema.MetadataSchema

  }

    private int _mdId;

    public void setSchemaFilters(boolean withHeld, boolean keepMarkedElement) {
        MetadataSchema mds = _dataManager.getSchema(metadata.getDataInfo().getSchemaId());
        Map<String, Pair<String, Element>> filters = new HashMap<String, Pair<String, Element>>();
        if (withHeld) {
            if (keepMarkedElement) {
                Element mark = new Element("keepMarkedElement");
                mark.setAttribute("nilReason", "withheld", Geonet.Namespaces.GCO);
                filters.put("editing",
                        Pair.read(XPATH_WITHHELD, mark));
            } else {
                filters.put("editing",
                        Pair.<String, Element>read(XPATH_WITHHELD, null));
            }
        }

        filters.put("download",
                Pair.<String, Element>read(XPATH_DOWNLOAD, null));
        filters.put("dynamic",
                Pair.<String, Element>read(XPATH_DYNAMIC, null));

        mds.setOperationFilters(filters);
    }
View Full Code Here

Examples of org.fao.geonet.kernel.schema.MetadataSchema

    private SchemaManager _schemaManager;

    @Test
    public void testAddElementFromXpath_NoAttributes() throws Exception {

        MetadataSchema schema = _schemaManager.getSchema("iso19139");

        final Element metadataElement = new Element("MD_Metadata", GMD);
        String newValue = "newValue";
        final String xpathProperty = "gmd:fileIdentifier/gco:CharacterString";
        boolean updated = new EditLib(_schemaManager).addElementOrFragmentFromXpath(metadataElement, schema, xpathProperty,
View Full Code Here

Examples of org.fao.geonet.kernel.schema.MetadataSchema


    @Test
    public void testAddElementFromXpath_HasPositionalIdentifier() throws Exception {

        MetadataSchema schema = _schemaManager.getSchema("iso19139");

        final Element metadataElement = new Element("MD_Metadata", GMD).addContent(
                new Element("fileIdentifier", GMD).addContent(
                        new Element("CharacterString", GCO).setText("OldValue")
                )
View Full Code Here

Examples of org.fao.geonet.kernel.schema.MetadataSchema

    }

    @Test
    public void testEditElementFromXpath_NoAttributes() throws Exception {

        MetadataSchema schema = _schemaManager.getSchema("iso19139");

        final Element metadataElement = new Element("MD_Metadata", GMD).addContent(
                new Element("fileIdentifier", GMD).addContent(
                        new Element("CharacterString", GCO).setText("OldValue")
                )
View Full Code Here

Examples of org.fao.geonet.kernel.schema.MetadataSchema

    }

    @Test
    public void testEditExistingAttribute() throws Exception {

        MetadataSchema schema = _schemaManager.getSchema("iso19139");

        final Element metadataElement = new Element("MD_Metadata", GMD).addContent(
                new Element("fileIdentifier", GMD).setAttribute("nilReason", "missing", GCO).addContent(
                        new Element("CharacterString", GCO).setText("OldValue")
                )
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.