Skip to content
Snippets Groups Projects
Commit 3179ecef authored by esikkala's avatar esikkala
Browse files

Sketching parameters for Sparql2GraphServer

parent f3ae80c3
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,12 @@ class Network extends React.Component { ...@@ -23,6 +23,12 @@ class Network extends React.Component {
} }
componentDidMount = () => { componentDidMount = () => {
this.props.fetchResults({
resultClass: this.props.resultClass,
facetClass: this.props.facetClass,
});
this.cy = cytoscape({ this.cy = cytoscape({
container: this.cyRef.current container: this.cyRef.current
}); });
...@@ -45,7 +51,11 @@ class Network extends React.Component { ...@@ -45,7 +51,11 @@ class Network extends React.Component {
} }
Network.propTypes = { Network.propTypes = {
classes: PropTypes.object.isRequired classes: PropTypes.object.isRequired,
results: PropTypes.object,
fetchResults: PropTypes.func.isRequired,
resultClass: PropTypes.string.isRequired,
facetClass: PropTypes.string.isRequired,
}; };
export default withStyles(styles)(Network); export default withStyles(styles)(Network);
...@@ -81,7 +81,10 @@ let Manuscripts = props => { ...@@ -81,7 +81,10 @@ let Manuscripts = props => {
path={'/manuscripts/faceted-search/network'} path={'/manuscripts/faceted-search/network'}
render={() => render={() =>
<Network <Network
results={props.manuscripts.results}
fetchResults={props.fetchResults}
resultClass='manuscriptsNetwork'
facetClass='manuscripts'
/>} />}
/> />
<Route <Route
......
...@@ -30,7 +30,7 @@ import { ...@@ -30,7 +30,7 @@ import {
} from '../helpers'; } from '../helpers';
export const INITIAL_STATE = { export const INITIAL_STATE = {
results: [], results: null,
resultsSparqlQuery: null, resultsSparqlQuery: null,
paginatedResults: [], paginatedResults: [],
paginatedResultsSparqlQuery: null, paginatedResultsSparqlQuery: null,
......
import { runSelectQuery } from './SparqlApi'; import { runSelectQuery } from './SparqlApi';
import { runNetworkQuery } from './NetworkApi';
import { prefixes } from './SparqlQueriesPrefixes'; import { prefixes } from './SparqlQueriesPrefixes';
import { import {
endpoint, endpoint,
...@@ -14,8 +15,8 @@ import { ...@@ -14,8 +15,8 @@ import {
productionPlacesQuery, productionPlacesQuery,
lastKnownLocationsQuery, lastKnownLocationsQuery,
migrationsQuery, migrationsQuery,
networkQuery, networkLinksQuery,
allManuscriptsQuery networkNodesQuery
} from './SparqlQueriesManuscripts'; } from './SparqlQueriesManuscripts';
import { workProperties } from './SparqlQueriesWorks'; import { workProperties } from './SparqlQueriesWorks';
import { eventProperties, eventPlacesQuery } from './SparqlQueriesEvents'; import { eventProperties, eventPlacesQuery } from './SparqlQueriesEvents';
...@@ -110,13 +111,9 @@ export const getAllResults = ({ ...@@ -110,13 +111,9 @@ export const getAllResults = ({
q = generateEventsByPeriodQuery({ startYear: 1600, endYear: 1620, periodLength: 10 }); q = generateEventsByPeriodQuery({ startYear: 1600, endYear: 1620, periodLength: 10 });
filterTarget = 'event'; filterTarget = 'event';
break; break;
case 'network': case 'manuscriptsNetwork':
q = networkQuery; q = networkLinksQuery;
filterTarget = 'manuscript__id'; filterTarget = 'source';
break;
case 'allManuscripts':
q = allManuscriptsQuery;
filterTarget = 'id';
break; break;
} }
if (constraints == null) { if (constraints == null) {
...@@ -130,6 +127,15 @@ export const getAllResults = ({ ...@@ -130,6 +127,15 @@ export const getAllResults = ({
facetID: null facetID: null
})); }));
} }
if (resultClass === 'manuscriptsNetwork') {
// console.log(prefixes + q)
return runNetworkQuery({
endpoint,
prefixes,
links: q,
nodes: networkNodesQuery,
});
}
// console.log(prefixes + q) // console.log(prefixes + q)
return runSelectQuery({ return runSelectQuery({
query: prefixes + q, query: prefixes + q,
......
import axios from 'axios';
export const runNetworkQuery = async({
endpoint,
prefixes,
links,
nodes
}) => {
const headers = {
'Content-Type': 'application/x-www-form-urlencoded',
};
const params = JSON.stringify({
endpoint,
prefixes,
nodes,
links
});
try {
const response = await axios({
method: 'post',
headers: headers,
url: 'http://127.0.0.1:5000/query',
data: params,
});
return response.data;
} catch(error) {
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
console.log(error.response.data);
//console.log(error.response.status);
//console.log(error.response.headers);
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error', error.message);
}
console.log(error.config);
}
};
;
import axios from 'axios'; import axios from 'axios';
import querystring from 'querystring'; import querystring from 'querystring';
// const defaultConstructHeaders = {
// 'Content-Type': 'application/x-www-form-urlencoded',
// 'Accept': 'text/turtle'
// };
export const runSelectQuery = async ({ export const runSelectQuery = async ({
query, query,
......
...@@ -424,11 +424,21 @@ export const collectionProperties = ...@@ -424,11 +424,21 @@ export const collectionProperties =
`; `;
export const allManuscriptsQuery = ` export const networkLinksQuery = `
SELECT ?id ?prefLabel SELECT DISTINCT ?source ?target
WHERE { WHERE {
<FILTER> <FILTER>
?id a frbroo:F4_Manifestation_Singleton ; ?source mmm-schema:manuscript_author ?target .
}
LIMIT 100
`;
export const networkNodesQuery = `
SELECT DISTINCT ?id ?prefLabel ?class
WHERE {
VALUES ?class { frbroo:F4_Manifestation_Singleton crm:E21_Person }
VALUES ?id { <ID_SET> }
?id a ?class ;
skos:prefLabel ?prefLabel . skos:prefLabel ?prefLabel .
} }
`; `;
...@@ -479,10 +489,3 @@ export const migrationsQuery = ` ...@@ -479,10 +489,3 @@ export const migrationsQuery = `
BIND(IRI(CONCAT(STR(?from__id), "-", REPLACE(STR(?to__id), "http://ldf.fi/mmm/place/", ""))) as ?id) BIND(IRI(CONCAT(STR(?from__id), "-", REPLACE(STR(?to__id), "http://ldf.fi/mmm/place/", ""))) as ?id)
} }
`; `;
export const networkQuery = `
SELECT DISTINCT ?id
WHERE {
}
`;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment