Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata Explorer first implementation #585

Merged
merged 20 commits into from
May 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0c27157
first metadata explorer implementation
offtherailz May 6, 2016
75e2335
Fixes #552 Handle properly the new props (#563)
May 13, 2016
567e364
Fixes #550 Mouse position plugin improvements (#561)
May 13, 2016
c762f42
fix #565. Fixed react-color dependency to the working one (#566)
offtherailz May 13, 2016
4745e02
Fixes #567: added copy to clipboard to mouseposition example (#568)
mbarto May 13, 2016
bbd33fa
Fixes #545 Disable locate button if permission denied (#569)
May 16, 2016
041f7a6
Fixes #570: cesium wms single tile layer not working when multiple ur…
mbarto May 16, 2016
dae781c
fix #572. Toolbar uses cfg from localconfig (#573)
offtherailz May 16, 2016
2f377df
fix #574 (#575)
offtherailz May 16, 2016
900ef2f
finalized csw
offtherailz May 18, 2016
6388fde
Merge branch 'master' of https://github.com/geosolutions-it/MapStore2…
offtherailz May 18, 2016
c250215
Merge branch 'master' of https://github.com/geosolutions-it/MapStore2…
offtherailz May 18, 2016
11eeb59
add configuration
offtherailz May 18, 2016
66f30d4
merged to master
offtherailz May 19, 2016
8ef4b79
generalization of catalog components
offtherailz May 19, 2016
5cbfbe4
restored dependencies for ogc-schemas
offtherailz May 19, 2016
c3d7829
fixed test and copyright info
offtherailz May 19, 2016
045ad61
improved performance for catalog selector
offtherailz May 20, 2016
bb0659e
clean up, dependency improvements and configurable items
offtherailz May 20, 2016
821e41c
fixed typo
offtherailz May 20, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"html2canvas": "0.5.0-beta4",
"intl": "1.2.2",
"json-loader": "0.5.4",
"jsonix": "2.4.1",
"keymirror": "0.1.1",
"leaflet": "0.7.7",
"leaflet-draw": "0.2.4",
Expand All @@ -86,6 +87,8 @@
"moment": "2.13.0",
"node-uuid": "1.4.3",
"object-assign": "3.0.0",
"ogc-schemas": "2.6.1",
"w3c-schemas": "1.3.1",
"openlayers": "3.15.1",
"pdfviewer": "0.3.2",
"proj4": "2.3.14",
Expand Down
47 changes: 47 additions & 0 deletions web/client/actions/__tests__/catalog-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright 2016, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

const expect = require('expect');
const {getRecords} = require('../catalog');
describe('Test correctness of the catalog actions', () => {

it('getRecords ISO Metadata Profile', (done) => {
getRecords('base/web/client/test-resources/csw/getRecordsResponseISO.xml', 1, 1)((actionResult) => {
try {
let result = actionResult && actionResult.result;
expect(result).toExist();
expect(result.records).toExist();
expect(result.records.length).toBe(1);
done();
} catch(ex) {
done(ex);
}
});
});
it('getRecords Dublin Core', (done) => {
getRecords('base/web/client/test-resources/csw/getRecordsResponseDC.xml', 1, 2)((actionResult) => {
try {
let result = actionResult && actionResult.result;
expect(result).toExist();
expect(result.records).toExist();
expect(result.records.length).toBe(2);
let rec0 = result.records[0];
expect(rec0.dc).toExist();
expect(rec0.dc.URI).toExist();
expect(rec0.dc.URI[0]);
let uri = rec0.dc.URI[0];
expect(uri.name).toExist();
expect(uri.value).toExist();
expect(uri.description).toExist();
done();
} catch(ex) {
done(ex);
}
});
});
});
59 changes: 59 additions & 0 deletions web/client/actions/catalog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Copyright 2016, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

var API = require('../api/CSW');

const RECORD_LIST_LOADED = 'RECORD_LIST_LOADED';
const RECORD_LIST_LOAD_ERROR = 'RECORD_LIST_LOAD_ERROR';

function recordsLoaded(options, result) {
return {
type: RECORD_LIST_LOADED,
searchOptions: options,
result: result
};
}

function recordsLoadError(e) {
return {
type: RECORD_LIST_LOAD_ERROR,
error: e
};
}
function getRecords(url, startPosition = 1, maxRecords, filter, options) {
return (dispatch /* , getState */) => {
// TODO auth (like) let opts = GeoStoreApi.getAuthOptionsFromState(getState(), {params: {start: 0, limit: 20}, baseURL: geoStoreUrl });
API.getRecords(url, startPosition, maxRecords, filter, options).then((result) => {
dispatch(recordsLoaded({
url,
startPosition,
maxRecords,
filter
}, result));
}).catch((e) => {
dispatch(recordsLoadError(e));
});
};
}
function textSearch(url, startPosition, maxRecords, text, options) {
return (dispatch /* , getState */) => {
// TODO auth (like) let opts = GeoStoreApi.getAuthOptionsFromState(getState(), {params: {start: 0, limit: 20}, baseURL: geoStoreUrl });
API.textSearch(url, startPosition, maxRecords, text, options).then((result) => {
dispatch(recordsLoaded({
url,
startPosition,
maxRecords,
text
}, result));
}).catch((e) => {
dispatch(recordsLoadError(e));
});
};
}

module.exports = {RECORD_LIST_LOADED, RECORD_LIST_LOAD_ERROR, getRecords, textSearch};
138 changes: 138 additions & 0 deletions web/client/api/CSW.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/**
* Copyright 2016, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
const axios = require('../libs/ajax');

const {CSW, marshaller, unmarshaller} = require('../utils/ogc/CSW');
const {Filter} = require('../utils/ogc/Filter');

const _ = require('lodash');


/**
* API for local config
*/
var Api = {
getRecords: function(url, startPosition, maxRecords, filter) {
let body = marshaller.marshalString({
name: "csw:GetRecords",
value: CSW.getRecords(startPosition, maxRecords, filter)
});
return axios.post(url, body, { headers: {
'Content-Type': 'application/xml'
}}).then(
(response) => {
if (response ) {
let json = unmarshaller.unmarshalString(response.data);
if (json && json.name && json.name.localPart === "GetRecordsResponse" && json.value && json.value.searchResults) {
let rawResult = json.value;
let rawRecords = rawResult.searchResults.abstractRecord || rawResult.searchResults.any;
let result = {
numberOfRecordsMatched: rawResult.searchResults.numberOfRecordsMatched,
numberOfRecordsReturned: rawResult.searchResults.numberOfRecordsReturned,
nextRecord: rawResult.searchResults.nextRecord
// searchStatus: rawResult.searchStatus
};
let records = [];

if (rawRecords) {
for (let i = 0; i < rawRecords.length; i++) {
let rawRec = rawRecords[i].value;
let obj = {
dateStamp: rawRec.dateStamp && rawRec.dateStamp.date,
fileIdentifier: rawRec.fileIdentifier && rawRec.fileIdentifier.characterString && rawRec.fileIdentifier.characterString.value,
identificationInfo: rawRec.abstractMDIdentification && rawRec.abstractMDIdentification.value
};
if (rawRec.boundingBox) {
let bbox;
let crs;
let el;
if (Array.isArray(rawRec.boundingBox)) {
el = _.head(rawRec.boundingBox);
} else {
el = rawRec.boundingBox;
}
if (el && el.value) {
let lc = el.value.lowerCorner;
let uc = el.value.upperCorner;
bbox = [lc[1], lc[0], uc[1], uc[0]];
// TODO parse the extent's crs
let crsCode = el.value.crs.split(":::")[1];
if (crsCode === "WGS 1984") {
crs = "EPSG:4326";
} else if (crsCode) {
// TODO check is valid EPSG code
crs = "EPSG:" + crsCode;
} else {
crs = "EPSG:4326";
}
}
obj.boundingBox = {
extent: bbox,
crs: crs
};

}
let dcElement = rawRec.dcElement;
if (dcElement) {
let dc = {
};
for (let j = 0; j < dcElement.length; j++) {
let dcel = dcElement[j];
let elName = dcel.name.localPart;
let finalEl = {};
/* Some services (e.g. GeoServer ) support http://schemas.opengis.net/csw/2.0.2/record.xsd only
* Usually they publish the WMS URL at dct:"references" with scheme=OGC:WMS
* So we place references as they are.
*/
if (elName === "references" && dcel.value) {
let urlString = dcel.value.content && dcel.value.content[0] || dcel.value.content || dcel.value;

finalEl = {
value: urlString,
scheme: dcel.value.scheme
};
} else {
finalEl = dcel.value.content && dcel.value.content[0] || dcel.value.content || dcel.value;
}

if (dc[elName] && Array.isArray(dc[elName])) {
dc[elName].push(finalEl);
} else if (dc[elName]) {
dc[elName] = [dc[elName], finalEl];
} else {
dc[elName] = finalEl;
}
}
obj.dc = dc;

}
records.push(obj);

}
}
result.records = records;
return result;
}
}
return null;

});
},
textSearch: function(url, startPosition, maxRecords, text) {
// creates a request like this:
// <ogc:PropertyName>apiso:AnyText</ogc:PropertyName><ogc:Literal>%a%</ogc:Literal></ogc:PropertyIsLike>
let filter = null;
if (text) {
let ops = Filter.propertyIsLike("csw:AnyText", "%" + text + "%");
filter = Filter.filter(ops);
}
return Api.getRecords(url, startPosition, maxRecords, filter);
}
};

module.exports = Api;
59 changes: 59 additions & 0 deletions web/client/components/catalog/RecordGrid.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Copyright 2016, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
const React = require('react');

const {Grid, Row, Col} = require('react-bootstrap');

const RecordItem = require('./RecordItem');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this pluggable, overridable with a prop

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can make it, but we need to include RecordGrid as a part of the recordgrid to make it really configurable from config.js files.



const RecordGrid = React.createClass({
propTypes: {
recordItem: React.PropTypes.element,
catalogURL: React.PropTypes.string,
onZoomToExtent: React.PropTypes.func,
onLayerAdd: React.PropTypes.func,
records: React.PropTypes.array,
style: React.PropTypes.object
},
getDefaultProps() {
return {
records: [],
onLayerAdd: () => {}
};
},
renderRecordItem(record) {
let Item = this.props.recordItem || RecordItem;
return (
<Col xs={12} sm={6} md={6} lg={6} key={record.identifier}>
<Item
onLayerAdd={this.props.onLayerAdd}
onZoomToExtent={this.props.onZoomToExtent}
catalogURL={this.props.catalogURL}
record={record}
style={{height: "215px", maxHeight: "215px"}}/>
</Col>
);
},
render() {
if (this.props.records) {
let mapsList = this.props.records instanceof Array ? this.props.records : [this.props.records];
return (
<Grid className="record-grid" style={this.props.style}>
<Row>
{mapsList.map(this.renderRecordItem)}
</Row>
</Grid>
);
}

return null;
}
});

module.exports = RecordGrid;
Loading