Search in sources :

Example 1 with Inspire

use of io.arlas.server.core.model.Inspire in project ARLAS-server by gisaia.

the class RecordBuilder method getFullResult.

public static RecordType getFullResult(CollectionReference collectionReference, String[] elements, String baseUri, boolean inspireIsEnabled) {
    RecordType record = new RecordType();
    DublinCoreElementName dublinCoreElementName = collectionReference.params.dublinCoreElementName;
    Inspire inspire = collectionReference.params.inspire;
    addIdentifier(record, dublinCoreElementName.identifier);
    if (elements.length == 0 || elements == null) {
        // ADD ALL field
        addTitle(record, dublinCoreElementName.title);
        if (inspire != null && inspire.keywords != null) {
            inspire.keywords.forEach(keyword -> {
                if (keyword.value != null) {
                    addSubject(record, keyword.value);
                }
            });
        }
        if (!StringUtil.isNullOrEmpty(dublinCoreElementName.subject)) {
            addSubject(record, dublinCoreElementName.subject);
        }
        if (inspireIsEnabled) {
            addType(record, RESOURCE_TYPE);
        } else {
            addType(record, dublinCoreElementName.type);
        }
        addBbox(record, dublinCoreElementName.bbox);
        addModified(record, dublinCoreElementName.getDate());
        addFormat(record, dublinCoreElementName.format);
        addAbstract(record, dublinCoreElementName.description);
        addUrlToWFS(record, baseUri + "ogc/wfs/" + collectionReference.collectionName + "/?" + OGCConstant.WFS_GET_CAPABILITIES_PARAMETERS);
    } else {
        for (String element : Arrays.asList(elements)) {
            switch(element.toLowerCase()) {
                case CSWConstant.DC_FIELD_TITLE:
                    addTitle(record, dublinCoreElementName.title);
                    break;
                case CSWConstant.DC_FIELD_TYPE:
                    if (inspireIsEnabled) {
                        addType(record, RESOURCE_TYPE);
                    } else {
                        addType(record, dublinCoreElementName.type);
                    }
                    break;
                case CSWConstant.DC_FIELD_BBOX:
                    addBbox(record, dublinCoreElementName.bbox);
                    break;
                case CSWConstant.DC_FIELD_SUBJECT:
                    if (inspire.keywords != null) {
                        inspire.keywords.forEach(keyword -> addSubject(record, keyword.value));
                    }
                    if (!StringUtil.isNullOrEmpty(dublinCoreElementName.subject)) {
                        addSubject(record, dublinCoreElementName.subject);
                    }
                    break;
                case CSWConstant.DC_FIELD_MODIFIED:
                    addModified(record, dublinCoreElementName.getDate());
                    break;
                case CSWConstant.DC_FIELD_FORMAT:
                    addFormat(record, dublinCoreElementName.format);
                    break;
                case CSWConstant.DC_FIELD_ABSTRACT:
                    addAbstract(record, dublinCoreElementName.description);
                    break;
            }
        }
    }
    return record;
}
Also used : BriefRecordType(net.opengis.cat.csw._3.BriefRecordType) RecordType(net.opengis.cat.csw._3.RecordType) SummaryRecordType(net.opengis.cat.csw._3.SummaryRecordType) AbstractRecordType(net.opengis.cat.csw._3.AbstractRecordType) DublinCoreElementName(io.arlas.server.core.model.DublinCoreElementName) Inspire(io.arlas.server.core.model.Inspire)

Example 2 with Inspire

use of io.arlas.server.core.model.Inspire in project ARLAS-server by gisaia.

the class RecordBuilder method getSummaryResult.

public static SummaryRecordType getSummaryResult(CollectionReference collectionReference, String[] elements, String baseUri, boolean inspireIsEnabled) {
    SummaryRecordType summaryRecord = new SummaryRecordType();
    DublinCoreElementName dublinCoreElementName = collectionReference.params.dublinCoreElementName;
    Inspire inspire = collectionReference.params.inspire;
    addIdentifier(summaryRecord, dublinCoreElementName.identifier);
    if (elements.length == 0) {
        // ADD ALL field
        addTitle(summaryRecord, dublinCoreElementName.title);
        if (inspire != null && inspire.keywords != null) {
            inspire.keywords.forEach(keyword -> {
                addSubject(summaryRecord, keyword.value);
            });
        }
        if (!StringUtil.isNullOrEmpty(dublinCoreElementName.subject)) {
            addSubject(summaryRecord, dublinCoreElementName.subject);
        }
        if (inspireIsEnabled) {
            addType(summaryRecord, RESOURCE_TYPE);
        } else {
            addType(summaryRecord, dublinCoreElementName.type);
        }
        addBbox(summaryRecord, dublinCoreElementName.bbox);
        addModified(summaryRecord, dublinCoreElementName.getDate());
        addFormat(summaryRecord, dublinCoreElementName.format);
        addAbstract(summaryRecord, dublinCoreElementName.description);
        addUrlToWFS(summaryRecord, baseUri + "ogc/wfs/" + collectionReference.collectionName + "/?" + OGCConstant.WFS_GET_CAPABILITIES_PARAMETERS);
    } else {
        for (String element : Arrays.asList(elements)) {
            switch(element.toLowerCase()) {
                case CSWConstant.DC_FIELD_TITLE:
                    addTitle(summaryRecord, dublinCoreElementName.title);
                    break;
                case CSWConstant.DC_FIELD_TYPE:
                    if (inspireIsEnabled) {
                        addType(summaryRecord, RESOURCE_TYPE);
                    } else {
                        addType(summaryRecord, dublinCoreElementName.type);
                    }
                    break;
                case CSWConstant.DC_FIELD_BBOX:
                    addBbox(summaryRecord, dublinCoreElementName.bbox);
                    break;
                case CSWConstant.DC_FIELD_SUBJECT:
                    if (inspire.keywords != null) {
                        inspire.keywords.forEach(keyword -> addSubject(summaryRecord, keyword.value));
                    }
                    if (!StringUtil.isNullOrEmpty(dublinCoreElementName.subject)) {
                        addSubject(summaryRecord, dublinCoreElementName.subject);
                    }
                    break;
                case CSWConstant.DC_FIELD_MODIFIED:
                    addModified(summaryRecord, dublinCoreElementName.getDate());
                    break;
                case CSWConstant.DC_FIELD_FORMAT:
                    addFormat(summaryRecord, dublinCoreElementName.format);
                    break;
                case CSWConstant.DC_FIELD_ABSTRACT:
                    addAbstract(summaryRecord, dublinCoreElementName.description);
                    break;
            }
        }
    }
    return summaryRecord;
}
Also used : SummaryRecordType(net.opengis.cat.csw._3.SummaryRecordType) DublinCoreElementName(io.arlas.server.core.model.DublinCoreElementName) Inspire(io.arlas.server.core.model.Inspire)

Example 3 with Inspire

use of io.arlas.server.core.model.Inspire in project ARLAS-server by gisaia.

the class CollectionTool method load.

public void load(long sleepAfter) throws ArlasException {
    try {
        DataSetTool.loadDataSet();
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }
    CollectionReferenceParameters params = new CollectionReferenceParameters();
    params.indexName = DataSetTool.DATASET_INDEX_NAME;
    params.idPath = DataSetTool.DATASET_ID_PATH;
    params.geometryPath = DataSetTool.WKT_GEOMETRIES ? DataSetTool.DATASET_WKT_GEOMETRY_PATH : DataSetTool.DATASET_GEOMETRY_PATH;
    params.centroidPath = DataSetTool.DATASET_CENTROID_PATH;
    params.h3Path = DataSetTool.DATASET_H3_PATH;
    params.timestampPath = DataSetTool.DATASET_TIMESTAMP_PATH;
    params.excludeFields = DataSetTool.DATASET_EXCLUDE_FIELDS;
    params.excludeWfsFields = DataSetTool.DATASET_EXCLUDE_WFS_FIELDS;
    params.rasterTileURL = DataSetTool.DATASET_TILE_URL;
    params.rasterTileWidth = 256;
    params.rasterTileHeight = 256;
    params.inspire = new Inspire();
    params.inspire.lineage = DataSetTool.DATASET_INSPIRE_LINEAGE;
    params.inspire.topicCategories = Arrays.asList(DataSetTool.DATASET_INSPIRE_TOPIC_CATEGORY);
    params.dublinCoreElementName = new DublinCoreElementName();
    params.dublinCoreElementName.title = DataSetTool.DATASET_DUBLIN_CORE_TITLE;
    params.dublinCoreElementName.description = DataSetTool.DATASET_DUBLIN_CORE_DESCRIPTION;
    params.dublinCoreElementName.language = DataSetTool.DATASET_DUBLIN_CORE_LANGUAGE;
    // PUT new collection
    given().contentType("application/json").body(params).when().put(getUrlPath()).then().statusCode(200);
    Filter filter = new Filter();
    filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.job", OperatorEnum.eq, DataSetTool.jobs[0])));
    params.filter = filter;
    given().contentType("application/json").body(params).when().put(arlasPath + "collections/" + COLLECTION_NAME_ACTOR).then().statusCode(200);
    try {
        Thread.sleep(sleepAfter);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) Filter(io.arlas.server.core.model.request.Filter) MultiValueFilter(io.arlas.server.core.model.request.MultiValueFilter) Expression(io.arlas.server.core.model.request.Expression) DublinCoreElementName(io.arlas.server.core.model.DublinCoreElementName) MultiValueFilter(io.arlas.server.core.model.request.MultiValueFilter) IOException(java.io.IOException) CollectionReferenceParameters(io.arlas.server.core.model.CollectionReferenceParameters) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ArlasException(io.arlas.server.core.exceptions.ArlasException) Inspire(io.arlas.server.core.model.Inspire)

Example 4 with Inspire

use of io.arlas.server.core.model.Inspire in project ARLAS-server by gisaia.

the class CollectionTool method loadCsw.

public void loadCsw(long sleepAfter) throws IOException {
    try {
        DataSetTool.loadDataSet();
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (ArlasException e) {
        e.printStackTrace();
    }
    InputStreamReader dcelementForCollection = new InputStreamReader(CollectionTool.class.getClassLoader().getResourceAsStream("csw.collection.dcelements.json"));
    ObjectMapper objectMapper = new ObjectMapper();
    DublinCoreElementName[] dcelements = objectMapper.readValue(dcelementForCollection, DublinCoreElementName[].class);
    Arrays.asList(dcelements).forEach(dublinCoreElementName -> {
        CollectionReferenceParameters params = new CollectionReferenceParameters();
        params.indexName = DataSetTool.DATASET_INDEX_NAME;
        params.idPath = DataSetTool.DATASET_ID_PATH;
        params.geometryPath = DataSetTool.DATASET_GEOMETRY_PATH;
        params.centroidPath = DataSetTool.DATASET_CENTROID_PATH;
        params.timestampPath = DataSetTool.DATASET_TIMESTAMP_PATH;
        params.excludeFields = DataSetTool.DATASET_EXCLUDE_FIELDS;
        params.excludeWfsFields = DataSetTool.DATASET_EXCLUDE_WFS_FIELDS;
        params.rasterTileURL = DataSetTool.DATASET_TILE_URL;
        params.dublinCoreElementName = dublinCoreElementName;
        params.inspire = new Inspire();
        params.inspire.lineage = DataSetTool.DATASET_INSPIRE_LINEAGE;
        params.inspire.topicCategories = Arrays.asList(DataSetTool.DATASET_INSPIRE_TOPIC_CATEGORY);
        String url = arlasPath + "collections/" + dublinCoreElementName.title.split(" ")[0].toLowerCase();
        // PUT new collection
        given().contentType("application/json").body(params).when().put(url).then().statusCode(200);
    });
    try {
        Thread.sleep(sleepAfter);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
Also used : ArlasException(io.arlas.server.core.exceptions.ArlasException) UnknownHostException(java.net.UnknownHostException) InputStreamReader(java.io.InputStreamReader) DublinCoreElementName(io.arlas.server.core.model.DublinCoreElementName) IOException(java.io.IOException) CollectionReferenceParameters(io.arlas.server.core.model.CollectionReferenceParameters) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Inspire(io.arlas.server.core.model.Inspire)

Example 5 with Inspire

use of io.arlas.server.core.model.Inspire in project ARLAS-server by gisaia.

the class CollectionInjector method loadCsw.

public void loadCsw(long sleepAfter) throws IOException {
    try {
        getDataInjector(POSTGIS_SINK).loadDataSet();
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (ArlasException e) {
        e.printStackTrace();
    }
    InputStreamReader dcelementForCollection = new InputStreamReader(CollectionInjector.class.getClassLoader().getResourceAsStream("csw.collection.dcelements.json"));
    ObjectMapper objectMapper = new ObjectMapper();
    DublinCoreElementName[] dcelements = objectMapper.readValue(dcelementForCollection, DublinCoreElementName[].class);
    Arrays.asList(dcelements).forEach(dublinCoreElementName -> {
        CollectionReferenceParameters params = new CollectionReferenceParameters();
        params.indexName = AbstractDataInjector.DATA_SINK_NAME;
        params.idPath = AbstractDataInjector.DATASET_ID_PATH;
        params.geometryPath = AbstractDataInjector.DATASET_GEOMETRY_PATH;
        params.centroidPath = AbstractDataInjector.DATASET_CENTROID_PATH;
        params.h3Path = AbstractDataInjector.DATASET_H3_PATH;
        params.timestampPath = AbstractDataInjector.DATASET_TIMESTAMP_PATH;
        params.excludeFields = AbstractDataInjector.DATASET_EXCLUDE_FIELDS;
        params.excludeWfsFields = AbstractDataInjector.DATASET_EXCLUDE_WFS_FIELDS;
        params.rasterTileURL = AbstractDataInjector.DATASET_TILE_URL;
        params.dublinCoreElementName = dublinCoreElementName;
        params.inspire = new Inspire();
        params.inspire.lineage = AbstractDataInjector.DATASET_INSPIRE_LINEAGE;
        params.inspire.topicCategories = Arrays.asList(AbstractDataInjector.DATASET_INSPIRE_TOPIC_CATEGORY);
        String url = arlasPath + "collections/" + dublinCoreElementName.title.split(" ")[0].toLowerCase();
        // PUT new collection
        given().contentType("application/json").body(params).when().put(url).then().statusCode(200);
    });
    try {
        Thread.sleep(sleepAfter);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
Also used : ArlasException(io.arlas.server.core.exceptions.ArlasException) UnknownHostException(java.net.UnknownHostException) InputStreamReader(java.io.InputStreamReader) DublinCoreElementName(io.arlas.server.core.model.DublinCoreElementName) IOException(java.io.IOException) CollectionReferenceParameters(io.arlas.server.core.model.CollectionReferenceParameters) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Inspire(io.arlas.server.core.model.Inspire)

Aggregations

DublinCoreElementName (io.arlas.server.core.model.DublinCoreElementName)6 Inspire (io.arlas.server.core.model.Inspire)6 ArlasException (io.arlas.server.core.exceptions.ArlasException)4 CollectionReferenceParameters (io.arlas.server.core.model.CollectionReferenceParameters)4 IOException (java.io.IOException)4 UnknownHostException (java.net.UnknownHostException)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Expression (io.arlas.server.core.model.request.Expression)2 Filter (io.arlas.server.core.model.request.Filter)2 MultiValueFilter (io.arlas.server.core.model.request.MultiValueFilter)2 InputStreamReader (java.io.InputStreamReader)2 SummaryRecordType (net.opengis.cat.csw._3.SummaryRecordType)2 AbstractRecordType (net.opengis.cat.csw._3.AbstractRecordType)1 BriefRecordType (net.opengis.cat.csw._3.BriefRecordType)1 RecordType (net.opengis.cat.csw._3.RecordType)1