Examples of MetadataSchema


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

            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);

        // -- add cached xml files (schema codelists and label files)
        // -- as Jeeves XmlFile objects (they need not exist)

        String base = fromAppPath + name + FS + "loc";
        Map<String, XmlFile> xfMap = new HashMap<String, XmlFile>();

        for (String fname : fnames) {
            String filePath = path + FS + "loc" + FS + defaultLang + FS + fname;
            if (Log.isDebugEnabled(Geonet.SCHEMA_MANAGER))
                Log.debug(Geonet.SCHEMA_MANAGER, "Searching for " + filePath);
            if (new File(filePath).exists()) {
                Element config = new Element("xml");
                config.setAttribute("name", name);
                config.setAttribute("base", base);
                config.setAttribute("file", fname);
                if (Log.isDebugEnabled(Geonet.SCHEMA_MANAGER))
                    Log.debug(Geonet.SCHEMA_MANAGER, "Adding XmlFile " + Xml.getString(config));
                XmlFile xf = new XmlFile(config, defaultLang, true);
                xfMap.put(fname, xf);
            } else {
                Log.warning(Geonet.SCHEMA_MANAGER, "Unable to load loc file: " + filePath);
            }
        }


        Pair<String, String> idInfo = extractIdInfo(xmlIdFile, name);

        mds.setReadwriteUUID(extractReadWriteUuid(xmlIdFile));
        mds.setOperationFilters(extractOperationFilters(xmlIdFile));
        Log.debug(Geonet.SCHEMA_MANAGER, "  UUID is read/write mode: " + mds.isReadwriteUUID());

        putSchemaInfo(
                name,
                idInfo.one(), // uuid of schema
                idInfo.two(), // version of schema
View Full Code Here

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

        String schema = metadata.getDataInfo().getSchemaId();
        if (schema.contains("iso19139") && !schema.equals("iso19139")) {
            // ie. this is an ISO profil.
            GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
            DataManager dm = gc.getBean(DataManager.class);
            MetadataSchema metadataSchema = dm.getSchema(schema);
            String path = metadataSchema.getSchemaDir() + "/convert/to19139.xsl";

            String data19139 = formatData(metadata, true, path);
            return Collections.singleton(Pair.read(FILE_METADATA_19139, data19139));
        }
View Full Code Here

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

     * @throws Exception
     * @throws IllegalStateException Fail to parse the fragment.
     */
    public void addFragment(String schema, Element el, String qname, String fragment, boolean removeExisting) throws Exception {
       
        MetadataSchema mdSchema = scm.getSchema(schema);
        String parentName = getParentNameFromChild(el);
        Element fragElt;

        if(Log.isDebugEnabled(Geonet.EDITORADDELEMENT))
            Log.debug(Geonet.EDITORADDELEMENT, "Add XML fragment for element name:" + qname + ", parent: " + parentName);
       
        try {
            fragElt = Xml.loadString(fragment, false);
        }
        catch (JDOMException e) {
            Log.error(Geonet.EDITORADDELEMENT, "EditLib : Error parsing XML fragment " + fragment);
            throw new IllegalStateException("EditLib : Error when loading XML fragment, " + e.getMessage());
        }
       
        String typeName = mdSchema.getElementType(el.getQualifiedName(), parentName);
        MetadataType type = mdSchema.getTypeInfo(typeName);
       
        // --- collect all children, adding the new one at the end of the others
        Vector<Element> children = new Vector<Element>();
       
        for (int i = 0; i < type.getElementCount(); i++) {
View Full Code Here

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

    //

        boolean hasContent = false;
    Vector<Element> holder = new Vector<Element>();

    MetadataSchema mdSchema = scm.getSchema(schema);
    String chUQname = getUnqualifiedName(chName);
    String chPrefix = getPrefix(chName);
    String chNS     = getNamespace(chName, md, mdSchema);
    Element container = new Element(chUQname, chPrefix, chNS);
    MetadataType containerType = mdSchema.getTypeInfo(chName);
    for (int k=0;k<containerType.getElementCount();k++) { 
      String elemName = containerType.getElementAt(k);
            if(Log.isDebugEnabled(Geonet.EDITOR))
                Log.debug(Geonet.EDITOR,"    -- Searching for child "+elemName);
      List<Element> elems;
View Full Code Here

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

            expandElements(schema, child);
        }
 
    String name = md.getQualifiedName();
    String parentName = getParentNameFromChild(md);
    MetadataSchema mdSchema = scm.getSchema(schema);
    String typeName = mdSchema.getElementType(name,parentName);
    MetadataType thisType = mdSchema.getTypeInfo(typeName);

    if (thisType.hasContainers) {
      Vector<Content> holder = new Vector<Content>();
     
      for (int i=0;i<thisType.getElementCount();i++) {
View Full Code Here

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

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

    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

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

    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

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

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

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

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