Esempio n. 1
0
  static {
    // prepare the common namespace support
    NAMESPACES = new NamespaceSupport();
    NAMESPACES.declarePrefix("csw", CSW.NAMESPACE);
    NAMESPACES.declarePrefix("rim", "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0");
    NAMESPACES.declarePrefix("dc", DC.NAMESPACE);
    NAMESPACES.declarePrefix("dct", DCT.NAMESPACE);
    NAMESPACES.declarePrefix("ows", OWS.NAMESPACE);
    NAMESPACES.declarePrefix("ogc", OGC.NAMESPACE);

    // prepare the CSW record related types
    FeatureTypeFactory typeFactory = new FeatureTypeFactoryImpl();
    TypeBuilder builder = new TypeBuilder(typeFactory);

    // create the SimpleLiteral type
    builder.setNamespaceURI(DC.SimpleLiteral.getNamespaceURI());
    builder.name("scheme");
    builder.bind(URI.class);
    AttributeType schemeType = builder.attribute();
    builder.setNamespaceURI(DC.SimpleLiteral.getNamespaceURI());
    builder.name("value");
    builder.bind(Object.class);
    AttributeType valueType = builder.attribute();
    builder.setNillable(true);
    builder.addAttribute("scheme", schemeType);
    builder.addAttribute("value", valueType);
    builder.setName("SimpleLiteral");
    SIMPLE_LITERAL = builder.complex();

    builder.setNamespaceURI(OWS.NAMESPACE);
    builder.setName("BoundingBoxType");
    builder.setBinding(MultiPolygon.class);
    builder.crs(DEFAULT_CRS);
    AttributeType bboxType = builder.geometry();

    EmfComplexFeatureReader reader = EmfComplexFeatureReader.newInstance();

    SchemaIndex index = null;
    try {
      index = reader.parse(new URL("http://schemas.opengis.net/csw/2.0.2/record.xsd"));
    } catch (IOException e) {
      // this is fatal
      throw new RuntimeException("Failed to parse CSW Record Schemas", e);
    }

    FeatureTypeRegistry featureTypeRegistry =
        new FeatureTypeRegistry(
            NAMESPACES, typeFactory, new RecordFeatureTypeRegistryHelper("RecordType"));

    featureTypeRegistry.register(SIMPLE_LITERAL);

    featureTypeRegistry.register(bboxType);

    featureTypeRegistry.addSchemas(index);

    RECORD_TYPE =
        (FeatureType)
            featureTypeRegistry.getAttributeType(new NameImpl(CSW.NAMESPACE, "RecordType"));

    RECORD_DESCRIPTOR =
        featureTypeRegistry.getDescriptor(new NameImpl(CSW.NAMESPACE, "Record"), null);

    RECORD_BBOX_DESCRIPTOR = (AttributeDescriptor) RECORD_TYPE.getDescriptor(RECORD_BBOX_NAME);
    DC_ELEMENT = (AttributeDescriptor) RECORD_TYPE.getDescriptor(DC_ELEMENT_NAME);

    // ---

    // setup the list of names for brief and summary records
    BRIEF_ELEMENTS =
        createNameList(NAMESPACES, "dc:identifier", "dc:title", "dc:type", "ows:BoundingBox");
    SUMMARY_ELEMENTS =
        createNameList(
            NAMESPACES,
            "dc:identifier",
            "dc:title",
            "dc:type",
            "dc:subject",
            "dc:format",
            "dc:relation",
            "dct:modified",
            "dct:abstract",
            "dct:spatial",
            "ows:BoundingBox");

    // create the xpath extender that fill adapt dc:title to dc:title/dc:value
    PATH_EXTENDER = new CRSRecordProjectyPathAdapter(NAMESPACES);
    // qualified the xpath in the filters
    NSS_QUALIFIER = new NamespaceQualifier(NAMESPACES);
    // applies the default CRS to geometry filters coming from the outside
    CRS_DEFAULTER = new DefaultCRSFilterVisitor(FF, DEFAULT_CRS);
    // transforms geometry filters into the internal representation
    CRS_REPROJECTOR = new ReprojectingFilterVisitor(FF, RECORD_TYPE);

    // build queriables list
    QUERIABLES =
        createNameList(
            NAMESPACES,
            "dc:contributor",
            "dc:source",
            "dc:language",
            "dc:title",
            "dc:subject",
            "dc:creator",
            "dc:type",
            "ows:BoundingBox",
            "dct:modified",
            "dct:abstract",
            "dc:relation",
            "dc:date",
            "dc:identifier",
            "dc:publisher",
            "dc:format",
            "csw:AnyText",
            "dc:rights");
  }