Package org.fao.geonet.kernel.schema

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


     */
  public Element createElement(String schema, Element child, Element parent) throws Exception {

    String childQName = child.getQualifiedName();

    MetadataSchema mds = scm.getSchema(schema);
    MetadataType mdt = getType(mds, parent);
   
    int min = -1, max = -1;

    for (int i=0; i<mdt.getElementCount(); i++) {
View Full Code Here


    protected Element applyChangesEmbedded(String id,
                                        Map<String, String> changes, String currVersion) throws Exception {
        Lib.resource.checkEditPrivilege(context, id);

        String schema = dataManager.getMetadataSchema(id);
        MetadataSchema metadataSchema = dataManager.getSchema(schema);
        EditLib editLib = dataManager.getEditLib();

        // --- check if the metadata has been modified from last time
        if (currVersion != null && !editLib.getVersion(id).equals(currVersion)) {
            Log.error(Geonet.EDITOR, "Version mismatch: had " + currVersion +
View Full Code Here

    Element refEl = (Element)(el.getChild(Edit.RootChild.ELEMENT, Edit.NAMESPACE)).clone();
    Element info = (Element)(md.getChild(Edit.RootChild.INFO,Edit.NAMESPACE)).clone();
    md.removeChild(Edit.RootChild.INFO,Edit.NAMESPACE);

    Element child = null;
    MetadataSchema mds = dataManager.getSchema(schema);
    if (childName != null) {
      if (childName.equals("geonet:attribute")) {
        String defaultValue = "";
        @SuppressWarnings("unchecked")
                List<Element> attributeDefs = el.getChildren(Edit.RootChild.ATTRIBUTE, Edit.NAMESPACE);
View Full Code Here

     */
    private Element getSchemaTronXmlReport(String schema, Element md, String lang, Map<String, Integer[]> valTypeAndStatus) throws Exception {
        // NOTE: this method assumes that you've run enumerateTree on the
        // metadata

        MetadataSchema metadataSchema = getSchema(schema);
        String[] rules = metadataSchema.getSchematronRules();

        // Schematron report is composed of one or more report(s)
        // for each set of rules.
        Element schemaTronXmlOut = new Element("schematronerrors",
                Edit.NAMESPACE);
        if (rules != null) {
            for (String rule : rules) {
                // -- create a report for current rules.
                // Identified by a rule attribute set to shematron file name
                if(Log.isDebugEnabled(Geonet.DATA_MANAGER))
                    Log.debug(Geonet.DATA_MANAGER, " - rule:" + rule);
                String ruleId = rule.substring(0, rule.indexOf(".xsl"));
                Element report = new Element("report", Edit.NAMESPACE);
                report.setAttribute("rule", ruleId,
                        Edit.NAMESPACE);

                String schemaTronXmlXslt = metadataSchema.getSchemaDir() + File.separator
                        + "schematron" + File.separator + rule;
                try {
                    Map<String,Object> params = new HashMap<String,Object>();
                    params.put("lang", lang);
                    params.put("rule", rule);
View Full Code Here

            xsdErrors = JeevesException.toElement(e);
            return xsdErrors;
        }

        if (xsdErrors != null) {
            MetadataSchema mds = getSchema(schema);
            List<Namespace> schemaNamespaces = mds.getSchemaNS();

            //-- now get each xpath and evaluate it
            //-- xsderrors/xsderror/{message,xpath}
            @SuppressWarnings("unchecked")
            List<Element> list = xsdErrors.getChildren();
View Full Code Here

     * @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

        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

        //--- 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

    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

        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

TOP

Related Classes of org.fao.geonet.kernel.schema.MetadataSchema

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.