Skip to content

Commit

Permalink
Merge pull request #13 from OP-TED/feature/TED-1432
Browse files Browse the repository at this point in the history
checking queries correctness
  • Loading branch information
duprijil authored Nov 14, 2023
2 parents 1a8ca5d + bba2314 commit eba6f57
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 54 deletions.
89 changes: 37 additions & 52 deletions docs/antora/modules/ROOT/pages/sample_app/sparql_queries.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ The query retrieves:
The notice publication date, organization country and organization size can be changed to create other queries. To do this, change the following section:

VALUES (?NoticePublicationDate ?CountryCode ?BusinessSize) {
(
"20230905"
("20230905"
<http://publications.europa.eu/resource/authority/country/DEU>
<http://publications.europa.eu/resource/authority/economic-operator-size/sme>
)
<http://publications.europa.eu/resource/authority/economic-operator-size/sme>)

* Existing value for publication date in example above:

Expand All @@ -66,15 +64,14 @@ SELECT
(COUNT(DISTINCT ?Notice) as ?NrOfNotices)
WHERE {
VALUES (?NoticePublicationDate ?CountryCode ?BusinessSize) {
(
"20230905"
("20230905"
<http://publications.europa.eu/resource/authority/country/DEU>
<http://publications.europa.eu/resource/authority/economic-operator-size/sme>
)
<http://publications.europa.eu/resource/authority/economic-operator-size/sme>)
}
?Notice epo:hasPublicationDate ?NoticePublicationDate .
?Notice epo:announcesRole ?Buyer .
?Buyer epo:playedBy ?Organization .
?Buyer a epo:Winner ;
epo:playedBy ?Organization .
?Organization epo:hasBusinessSize ?BusinessSize .
?Organization cccev:registeredAddress / epo:hasCountryCode ?CountryCode .
}
Expand Down Expand Up @@ -126,7 +123,8 @@ WHERE {
}
?Notice epo:hasPublicationDate ?PublicationDate .
?Notice epo:announcesRole ?Buyer .
?Buyer epo:playedBy ?Organization .
?Buyer a epo:Buyer ;
epo:playedBy ?Organization .
?Organization cccev:registeredAddress / epo:hasCountryCode ?countryCode .
?Organization epo:hasLegalName ?LegalName .
}
Expand All @@ -135,31 +133,27 @@ WHERE {
== Query: Who are the winners for a given date ?
{nbsp}

This SPARQL query aims to retrieve information about the winners of procurement lots for a specific date ("20230921" or 21-09-2023). It does so by specifying a value for the publication date, and then querying the RDF data based on that value. The query returns information about the lots, the organizations that won them, and details about the awarded amounts and currencies.
This SPARQL query aims to retrieve information about the winners of procurement lots for a specific date ("20230831" or 31-08-2023). It does so by specifying a value for the publication date, and then querying the RDF data based on that value. The query returns information about the lots, the organizations that won them, and details about the awarded amounts and currencies.

The query retrieves:

* Notice ID
* Procedure ID
* Notice publication date
* Lot Number (optional, may be missing as it not specified in notice)
* The legal name of the winner
* The winners country code as URI

* Lot URI
* Winner Legal Name
* Winner Country Code
* Lot value awarded to winner
* The currency of the awarded value
* Lot URI
* Notice URI

The notice publication date and winner legal name language can be changed to create other queries. To do this, change the following section:

VALUES ?NoticePublicationDate {
"20230831"
"20230905"
}
FILTER(LANG(?WinnerLegalName) = 'en')

* Existing value for publication date in example above:

"20230831"
"20230905"

* Existing value for winner legal name language in example above:

Expand All @@ -172,29 +166,21 @@ PREFIX epo: <http://data.europa.eu/a4g/ontology#>
PREFIX org: <http://www.w3.org/ns/org#>
PREFIX cccev: <http://data.europa.eu/m8g/>
SELECT DISTINCT
?NoticeID
?NoticePublicationDate
?ProcedureNr
?LotNr
?Lot
?WinnerLegalName
?WinnerCountryCode
?LotAwardedValue
?LotAwardedValueCurrency
?LotURI
?NoticeURI
?AwardedValue
?AwardedValueCurrency
WHERE {
VALUES ?NoticePublicationDate {
"20230831"
"20230905"
}
FILTER(LANG(?WinnerLegalName) = 'en')
?NoticeURI a epo:ResultNotice;
epo:hasPublicationDate ?NoticePublicationDate;
epo:hasID / epo:hasIdentifierValue ?NoticeID ;
epo:refersToLot ?LotURI.
?LotURI a epo:Lot.
?LotAwardOutcome epo:describesLot ?LotURI;
a epo:LotAwardOutcome;
epo:hasAwardedValue ?LotAwardedValueURI ;
?Notice a epo:Notice;
epo:hasPublicationDate ?NoticePublicationDate ;
epo:refersToLot ?Lot .
?LotAwardOutcome epo:describesLot ?Lot ;
epo:hasAwardedValue ?MonetaryValue ;
epo:comprisesTenderAwardOutcome ?TenderAwardOutcome.
?TenderAwardOutcome a epo:TenderAwardOutcome;
epo:indicatesAwardOfLotToWinner / epo:playedBy ?Winner.
Expand All @@ -203,15 +189,9 @@ WHERE {
OPTIONAL {
?Winner cccev:registeredAddress / epo:hasCountryCode ?WinnerCountryCode.
}
?LotAwardedValueURI a epo:MonetaryValue;
epo:hasAmountValue ?LotAwardedValue;
epo:hasCurrency ?LotAwardedValueCurrency.
OPTIONAL {
?LotURI epo:hasID / epo:hasIdentifierValue ?LotNr .
}
?ProcedureURI epo:hasProcurementScopeDividedIntoLot ?LotURI;
a epo:Procedure ;
epo:hasID / epo:hasIdentifierValue ?ProcedureNr .
?MonetaryValue a epo:MonetaryValue;
epo:hasAmountValue ?AwardedValue;
epo:hasCurrency ?AwardedValueCurrency .
}


Expand All @@ -230,19 +210,23 @@ The query retrieves:

The notice publication date and winner legal name language can be changed to create other queries. To do this, change the following section:

VALUES ?NoticePublicationDate {
"20230921"
VALUES (?NoticePublicationDate ?LotAwardedValueCurrency) {
("20230905" <http://publications.europa.eu/resource/authority/currency/EUR>)
}
FILTER(LANG(?WinnerLegalName) = 'en')

* Existing value for publication date in example above:

"20230921"
"20230905"

* Existing value for winner legal name language in example above:

'en'

* EXisting value for currency in example above:

<http://publications.europa.eu/resource/authority/currency/EUR>

==== Query text:

[source,sparql]
Expand All @@ -256,8 +240,8 @@ SELECT
?LotAwardedValue
?LotAwardedValueCurrency
WHERE {
VALUES ?NoticePublicationDate {
"20230921"
VALUES (?NoticePublicationDate ?LotAwardedValueCurrency) {
("20230905" <http://publications.europa.eu/resource/authority/currency/EUR>)
}
FILTER(LANG(?WinnerLegalName) = 'en')
?Notice epo:hasPublicationDate ?NoticePublicationDate ;
Expand All @@ -279,6 +263,7 @@ WHERE {
ORDER BY DESC(?LotAwardedValue)
LIMIT 1


////
NOTE: Other examples of SPARQL queries can be found https://github.com/OP-TED/ted-rdf-docs/tree/main/queries[here].
////
Expand Down
4 changes: 2 additions & 2 deletions queries/highest_value_of_contract.rq
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ SELECT
?LotAwardedValue
?LotAwardedValueCurrency
WHERE {
VALUES ?NoticePublicationDate {
"20230921"
VALUES (?NoticePublicationDate ?LotAwardedValueCurrency) {
("20230905" <http://publications.europa.eu/resource/authority/currency/EUR>)
}
FILTER(LANG(?WinnerLegalName) = 'en')
?Notice epo:hasPublicationDate ?NoticePublicationDate ;
Expand Down

0 comments on commit eba6f57

Please sign in to comment.