Skip to content

Commit

Permalink
✨ Versao completa (por enquanto) do RDF dos servicos
Browse files Browse the repository at this point in the history
  • Loading branch information
rausth committed Jul 20, 2023
1 parent 35fe241 commit c29c170
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.apache.jena.rdf.model.*;
import org.apache.jena.sparql.vocabulary.FOAF;
import org.apache.jena.vocabulary.RDF;
import org.apache.jena.vocabulary.RDFS;
import org.springframework.http.MediaType;
Expand Down Expand Up @@ -33,11 +34,24 @@ public void getAllAsRDF(HttpServletResponse response) {

String myNS = "http://localhost:8080/services/asRDF/";
String grNS = "http://purl.org/goodrelations/v1#";
String sNS = "http://schema.org/#";

model.setNsPrefix("gr", grNS);
model.setNsPrefix("s", sNS);

Resource grOffering = ResourceFactory.createResource(grNS + "Offering");

Property grBusinessEntity = ResourceFactory.createProperty(grNS + "BusinessEntity");
Property grName = ResourceFactory.createProperty(grNS + "name");
Property sTelephone = ResourceFactory.createProperty(sNS + "telephone");
Property sEmail = ResourceFactory.createProperty(sNS + "email");

Property sPostalAddress = ResourceFactory.createProperty(sNS + "PostalAddress");
Property sAddressCountry = ResourceFactory.createProperty(sNS + "addressCountry");
Property sAddressRegion = ResourceFactory.createProperty(sNS + "addressRegion");
Property sAdressLocality = ResourceFactory.createProperty(sNS + "addressLocality");
Property sStreetAddress = ResourceFactory.createProperty(sNS + "streetAddress");

Resource grPriceSpecification = ResourceFactory.createResource(grNS + "PriceSpecification");
Property grHasPriceSpecification = ResourceFactory.createProperty(grNS + "hasPriceSpecification");
Property grHasCurrencyValue = ResourceFactory.createProperty(grNS + "hasCurrencyValue");
Expand All @@ -47,6 +61,17 @@ public void getAllAsRDF(HttpServletResponse response) {
.addProperty(RDF.type, grOffering)
.addProperty(RDFS.label, service.getTitle())
.addProperty(RDFS.comment, service.getDescription())
.addProperty(grBusinessEntity, model.createResource()
.addLiteral(grName, service.getProvider().getName())
.addProperty(sTelephone, service.getProvider().getTelephone())
.addProperty(sEmail, service.getProvider().getEmail())
)
.addProperty(sPostalAddress, model.createResource()
.addProperty(sAddressCountry, "Brasil")
.addProperty(sAddressRegion, service.getAddress().getState())
.addProperty(sAdressLocality, service.getAddress().getCity() + ", " + service.getAddress().getDistrict())
.addProperty(sStreetAddress, service.getAddress().getPublicPlace() + ", " + service.getAddress().getNumber())
)
.addProperty(grHasPriceSpecification, model.createResource()
.addProperty(RDF.type, grPriceSpecification)
.addLiteral(grHasCurrencyValue, service.getPrice())
Expand Down

0 comments on commit c29c170

Please sign in to comment.