Skip to content

Commit

Permalink
feat: refactor a query inside a FLTH file and add a sort statement to…
Browse files Browse the repository at this point in the history
… another one (#676)
  • Loading branch information
EmmanuelDemey authored Jul 5, 2024
1 parent 974d178 commit f706515
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,10 @@ public static String conceptsQuery() throws RmesException {
return buildConceptRequest("getConcepts.ftlh", params);
}

public static String conceptsSearchQuery() {
return "SELECT DISTINCT ?id ?label ?created ?modified ?disseminationStatus "
+ "?validationStatus ?definition ?creator ?isTopConceptOf ?valid \n"
+ "(group_concat(?altLabelLg1;separator=' || ') as ?altLabel) \n"
+ "WHERE { GRAPH <"+config.getConceptsGraph()+"> { \n"
+ "?concept skos:notation ?notation . \n"
+ "BIND (STR(?notation) AS ?id) \n"
+ "?concept skos:prefLabel ?label . \n"
+ "OPTIONAL{?concept skos:altLabel ?altLabelLg1 . \n"
+ "FILTER (lang(?altLabelLg1) = '" + config.getLg1() + "')} \n"
+ "?concept dcterms:created ?created . \n"
// Not topConceptOf if has broader
+ "BIND (exists{?concept skos:broader ?broa} AS ?broader) . \n"
+ "BIND (IF(?broader, 'false', 'true') AS ?isTopConceptOf) . \n"
+ "OPTIONAL{?concept dcterms:modified ?modified} . \n"
+ "OPTIONAL {?concept dcterms:valid ?valid} . \n"
+ "?concept insee:disseminationStatus ?disseminationStatus . \n"
+ "?concept insee:isValidated ?validationStatus . \n"
+ "FILTER (lang(?label) = '" + config.getLg1() + "') . \n"
+ "?concept dc:creator ?creator . \n"
+ "OPTIONAL{?concept skos:definition ?noteUri . \n"
+ "?noteUri pav:version ?version . \n"
+ "?noteUri evoc:noteLiteral ?definition . \n"
+ "?noteUri dcterms:language '" + config.getLg1() + "'^^xsd:language . \n"
+ "OPTIONAL {?concept skos:definition ?latest . \n"
+ "?latest pav:version ?latestVersion . \n"
+ "?latest dcterms:language '" + config.getLg1() + "'^^xsd:language . \n"
+ "FILTER (?version < ?latestVersion)} . \n"
+ "FILTER (!bound (?latest))}"
+ "}} \n"
+ "GROUP BY ?id ?label ?created ?modified ?disseminationStatus \n"
+ "?validationStatus ?definition ?creator ?isTopConceptOf ?valid \n"
+ "ORDER BY ?label";
public static String conceptsSearchQuery() throws RmesException {
if (params==null) {initParams();}
params.put(CONCEPTS_GRAPH, config.getConceptsGraph());
return buildConceptRequest("getConceptsForAdvancedSearch.ftlh", params);
}

public static String conceptsToValidateQuery() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
SELECT DISTINCT ?id ?label ?created ?modified ?disseminationStatus ?validationStatus ?definition ?creator ?isTopConceptOf ?valid (group_concat(?altLabelLg1;separator=' || ') as ?altLabel)
WHERE
{
GRAPH <${CONCEPTS_GRAPH}> {
?concept skos:notation ?notation .
BIND (STR(?notation) AS ?id)
?concept skos:prefLabel ?label .
FILTER (lang(?label) = '${LG1}') .

OPTIONAL {
?concept skos:altLabel ?altLabelLg1 .
FILTER (lang(?altLabelLg1) = '${LG1}')
}
?concept dcterms:created ?created .
BIND (exists{?concept skos:broader ?broa} AS ?broader) .
BIND (IF(?broader, 'false', 'true') AS ?isTopConceptOf) .

OPTIONAL{?concept dcterms:modified ?modified} .
OPTIONAL {?concept dcterms:valid ?valid} .

?concept insee:disseminationStatus ?disseminationStatus .
?concept insee:isValidated ?validationStatus .

?concept dc:creator ?creator .
OPTIONAL{
?concept skos:definition ?noteUri .
?noteUri pav:version ?version .
?noteUri evoc:noteLiteral ?definition .
?noteUri dcterms:language '${LG1}'^^xsd:language .
OPTIONAL {
?concept skos:definition ?latest .
?latest pav:version ?latestVersion .
?latest dcterms:language '${LG1}'^^xsd:language .
FILTER (?version < ?latestVersion)
} .
FILTER (!bound (?latest))
}
}
}
GROUP BY ?id ?label ?created ?modified ?disseminationStatus ?validationStatus ?definition ?creator ?isTopConceptOf ?valid
ORDER BY ?label
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ WHERE {
BIND(EXISTS{?series dc:creator ?creator} AS ?hasCreator)
BIND(EXISTS{?series dcterms:contributor ?contrib} AS ?hasContributor)
BIND(EXISTS{?series insee:dataCollector ?datacoll} AS ?hasDataCollector)
BIND(EXISTS{?series dcterms:publisher ?publisher} AS ?hasPublisher)
}
BIND(EXISTS{?series dcterms:publisher ?publisher} AS ?hasPublisher)
}
ORDER BY ?prefLabelLg1

0 comments on commit f706515

Please sign in to comment.