Examples of AssociatedResourcesSchemaPlugin


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

                    keepXlinkAttributes);
        }

        String schemaIdentifier = dm.getMetadataSchema(id);
        SchemaPlugin instance = SchemaManager.getSchemaPlugin(context, schemaIdentifier);
        AssociatedResourcesSchemaPlugin schemaPlugin = null;
        if (instance instanceof AssociatedResourcesSchemaPlugin) {
            schemaPlugin = (AssociatedResourcesSchemaPlugin) instance;
        }

        // Search for children of this record
        if (type.equals("") || type.contains("children")) {
            relatedRecords.addContent(search(uuid, "children", context, from, to, fast));
        }

        // Get parent record from this record
        if (schemaPlugin != null && (type.equals("") || type.contains("parent"))) {
            Set<String> listOfUUIDs = schemaPlugin.getAssociatedParentUUIDs(md);
            if (listOfUUIDs.size() > 0) {
                String joinedUUIDs = Joiner.on(" or ").join(listOfUUIDs);
                relatedRecords.addContent(search(joinedUUIDs, "parent", context, from, to, fast));
            }
        }

        // Get aggregates from this record
        if (schemaPlugin != null && (type.equals("") || type.contains("siblings"))) {
            Element response = new Element("response");

            Set<AssociatedResource> listOfAssociatedResources = schemaPlugin.getAssociatedResourcesUUIDs(md);

            if (listOfAssociatedResources != null) {
                for (AssociatedResource resource : listOfAssociatedResources) {
                    Element sibContent = getRecord(resource.getUuid(), context, dm);
                    if (sibContent != null) {
                        Element sibling = new Element("sibling");
                        sibling.setAttribute("initiative", resource.getInitiativeType());
                        response.addContent(sibling.addContent(sibContent));
                    }
                }
            }
            relatedRecords.addContent(new Element("siblings").addContent(response));
        }

        // Search for records where an aggregate point to this record
        if (type.equals("") || type.contains("associated")) {
            relatedRecords.addContent(search(uuid, "associated", context, from, to, fast));
        }

        // Search for services
        if (type.equals("") || type.contains("service")) {
            relatedRecords.addContent(search(uuid, "services", context, from, to, fast));
        }

        // Related record from uuiref attributes in metadata record
        if (schemaPlugin != null && (
                type.equals("") || type.contains("dataset") || type.contains("fcat") || type.contains("source")
        )) {
            // Get datasets related to service search
            if (type.equals("") || type.contains("dataset")) {
                Set<String> listOfUUIDs = schemaPlugin.getAssociatedDatasetUUIDs(md);
                if (listOfUUIDs != null && listOfUUIDs.size() > 0) {
                    String joinedUUIDs = Joiner.on(" or ").join(listOfUUIDs);
                    relatedRecords.addContent(search(joinedUUIDs, "datasets", context, from, to, fast));
                }
            }
            // if source, return source datasets defined in the current record
            if (type.equals("") || type.contains("source")) {
                Set<String> listOfUUIDs = schemaPlugin.getAssociatedSourceUUIDs(md);
                if (listOfUUIDs != null && listOfUUIDs.size() > 0) {
                    String joinedUUIDs = Joiner.on(" or ").join(listOfUUIDs);
                    relatedRecords.addContent(search(joinedUUIDs, "sources", context, from, to, fast));
                }
            }
            // if fcat
            if (type.equals("") || type.contains("fcat")) {
                Set<String> listOfUUIDs = schemaPlugin.getAssociatedFeatureCatalogueUUIDs(md);
                if (listOfUUIDs != null && listOfUUIDs.size() > 0) {
                    String joinedUUIDs = Joiner.on(" or ").join(listOfUUIDs);
                    relatedRecords.addContent(search(joinedUUIDs, "fcats", context, from, to, fast));
                }
            }
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.