Plausi Prüfung. Genauer unterteilte ttl Dateien. Eine spezielle Plausi als sparql Datei definiert.
This commit is contained in:
@@ -22,6 +22,7 @@ public class EndpointsZentralesBOA {
|
||||
|
||||
@PostMapping("/CalculateRequest")
|
||||
public String calc(@RequestBody String calculateRequest) throws IOException, DatatypeConfigurationException {
|
||||
System.out.println(calculateRequest);
|
||||
CalculateService cs = new CalculateService();
|
||||
return cs.buildResponse(calculateRequest);
|
||||
};
|
||||
|
||||
@@ -2,8 +2,11 @@ package com.kapdion.omds.productdefinitions.apriori;
|
||||
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.ProductsRequest;
|
||||
|
||||
import org.eclipse.rdf4j.model.IRI;
|
||||
import org.eclipse.rdf4j.model.Model;
|
||||
import org.eclipse.rdf4j.model.impl.LinkedHashModel;
|
||||
import org.eclipse.rdf4j.model.util.Values;
|
||||
import org.eclipse.rdf4j.model.vocabulary.RDF;
|
||||
import org.eclipse.rdf4j.model.vocabulary.XSD;
|
||||
import org.eclipse.rdf4j.query.GraphQuery;
|
||||
import org.eclipse.rdf4j.query.GraphQueryResult;
|
||||
@@ -18,6 +21,10 @@ import javax.xml.datatype.DatatypeConstants;
|
||||
import javax.xml.datatype.DatatypeFactory;
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.eclipse.rdf4j.model.util.Values.iri;
|
||||
|
||||
public class AprioriService {
|
||||
|
||||
@@ -29,7 +36,7 @@ public class AprioriService {
|
||||
conn.add(new File("src/main/resources/data/prodelements.ttl"), RDFFormat.TURTLE);
|
||||
|
||||
String queryString = """
|
||||
PREFIX vvo: <http://vvo.pisanoapi.at/>
|
||||
PREFIX vvo: <http://vvo.pisanoapi.at/>
|
||||
|
||||
CONSTRUCT {
|
||||
?prodelement vvo:ins_id ?ins_id ;
|
||||
@@ -40,20 +47,22 @@ public class AprioriService {
|
||||
vvo:minOccurrence ?minOccurrence ;
|
||||
vvo:maxOccurrence ?maxOccurrence ;
|
||||
vvo:type ?type ;
|
||||
vvo:parent ?parent ;
|
||||
vvo:risikoobjektType ?risikoobjektType .
|
||||
}
|
||||
WHERE {
|
||||
?prodelement a vvo:ProdElement .
|
||||
OPTIONAL { ?prodelement vvo:ins_id ?ins_id . }
|
||||
OPTIONAL { ?prodelement vvo:bez ?bez . }
|
||||
OPTIONAL { ?prodelement vvo:bez ?bez . }
|
||||
OPTIONAL { ?prodelement vvo:created ?created . }
|
||||
OPTIONAL { ?prodelement vvo:salesFrom ?salesfrom . }
|
||||
OPTIONAL { ?prodelement vvo:salesTo ?salesto . }
|
||||
OPTIONAL { ?prodelement vvo:minOccurrence ?minOccurrence . }
|
||||
OPTIONAL { ?prodelement vvo:maxOccurrence ?maxOccurrence . }
|
||||
OPTIONAL { ?prodelement vvo:type ?type . }
|
||||
OPTIONAL { ?prodelement vvo:parent ?parent . }
|
||||
OPTIONAL { ?prodelement vvo:risikoobjektType ?risikoobjektType . }
|
||||
FILTER ( ?salesfrom < ?stichtag && (!BOUND(?salesto) || ?salesto > ?stichtag) )
|
||||
FILTER ( ?salesfrom < ?stichtag && (!BOUND(?salesto) || ?salesto > ?stichtag) )
|
||||
}
|
||||
|
||||
""";
|
||||
@@ -68,6 +77,9 @@ public class AprioriService {
|
||||
result.forEach(model::add);
|
||||
}
|
||||
|
||||
addPlausisToRequest(model);
|
||||
addAttributeToRequest(model);
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
Rio.write(model, baos, RDFFormat.JSONLD);
|
||||
return baos.toString();
|
||||
@@ -76,4 +88,196 @@ public class AprioriService {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void addAttributeToRequest(Model model) {
|
||||
addBoolAttribut(model);
|
||||
addStringAttribut(model);
|
||||
addIntAttribut(model);
|
||||
addDecimalAttribut(model);
|
||||
}
|
||||
|
||||
private void addDecimalAttribut(Model model) {
|
||||
Repository repo = new SailRepository(new MemoryStore());
|
||||
repo.init();
|
||||
|
||||
try (RepositoryConnection conn = repo.getConnection()) {
|
||||
conn.add(new File("src/main/resources/data/Attribute.ttl"), RDFFormat.TURTLE);
|
||||
|
||||
String queryString = """
|
||||
PREFIX vvo: <http://vvo.pisanoapi.at/>
|
||||
|
||||
CONSTRUCT {
|
||||
?attribut a vvo:ElemDecimal ;
|
||||
vvo:bez ?bez ;
|
||||
vvo:ProdElement ?ProdElement ;
|
||||
vvo:required ?required ;
|
||||
vvo:max ?max ;
|
||||
vvo:min ?min ;
|
||||
vvo:default ?default ;
|
||||
}
|
||||
WHERE {
|
||||
?attribut a vvo:ElemDecimal .
|
||||
OPTIONAL { ?attribut vvo:bez ?bez . }
|
||||
OPTIONAL { ?attribut vvo:ProdElement ?ProdElement . }
|
||||
OPTIONAL { ?attribut vvo:required ?required . }
|
||||
OPTIONAL { ?attribut vvo:max ?max . }
|
||||
OPTIONAL { ?attribut vvo:min ?min . }
|
||||
OPTIONAL { ?attribut vvo:default ?default . }
|
||||
}
|
||||
|
||||
""";
|
||||
|
||||
GraphQuery graphQuery = conn.prepareGraphQuery(queryString);
|
||||
// graphQuery.setBinding("stichtag", conn.getValueFactory().createLiteral(stichtagFormated.toXMLFormat(), XSD.DATE));
|
||||
|
||||
try (GraphQueryResult result = graphQuery.evaluate()) {
|
||||
result.forEach(model::add);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void addIntAttribut(Model model) {
|
||||
Repository repo = new SailRepository(new MemoryStore());
|
||||
repo.init();
|
||||
|
||||
try (RepositoryConnection conn = repo.getConnection()) {
|
||||
conn.add(new File("src/main/resources/data/Attribute.ttl"), RDFFormat.TURTLE);
|
||||
|
||||
String queryString = """
|
||||
PREFIX vvo: <http://vvo.pisanoapi.at/>
|
||||
|
||||
CONSTRUCT {
|
||||
?attribut a vvo:ElemInt ;
|
||||
vvo:bez ?bez ;
|
||||
vvo:ProdElement ?ProdElement ;
|
||||
vvo:required ?required ;
|
||||
vvo:max ?max ;
|
||||
vvo:min ?min ;
|
||||
vvo:default ?default ;
|
||||
}
|
||||
WHERE {
|
||||
?attribut a vvo:ElemInt .
|
||||
OPTIONAL { ?attribut vvo:bez ?bez . }
|
||||
OPTIONAL { ?attribut vvo:ProdElement ?ProdElement . }
|
||||
OPTIONAL { ?attribut vvo:required ?required . }
|
||||
OPTIONAL { ?attribut vvo:max ?max . }
|
||||
OPTIONAL { ?attribut vvo:min ?min . }
|
||||
OPTIONAL { ?attribut vvo:default ?default . }
|
||||
}
|
||||
|
||||
""";
|
||||
|
||||
GraphQuery graphQuery = conn.prepareGraphQuery(queryString);
|
||||
// graphQuery.setBinding("stichtag", conn.getValueFactory().createLiteral(stichtagFormated.toXMLFormat(), XSD.DATE));
|
||||
|
||||
try (GraphQueryResult result = graphQuery.evaluate()) {
|
||||
result.forEach(model::add);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void addStringAttribut(Model model) {
|
||||
Repository repo = new SailRepository(new MemoryStore());
|
||||
repo.init();
|
||||
|
||||
try (RepositoryConnection conn = repo.getConnection()) {
|
||||
conn.add(new File("src/main/resources/data/Attribute.ttl"), RDFFormat.TURTLE);
|
||||
|
||||
String queryString = """
|
||||
PREFIX vvo: <http://vvo.pisanoapi.at/>
|
||||
|
||||
CONSTRUCT {
|
||||
?attribut a vvo:ElemString ;
|
||||
vvo:bez ?bez ;
|
||||
vvo:ProdElement ?ProdElement ;
|
||||
vvo:required ?required ;
|
||||
vvo:default ?default ;
|
||||
}
|
||||
WHERE {
|
||||
?attribut a vvo:ElemString .
|
||||
OPTIONAL { ?attribut vvo:bez ?bez . }
|
||||
OPTIONAL { ?attribut vvo:ProdElement ?ProdElement . }
|
||||
OPTIONAL { ?attribut vvo:required ?required . }
|
||||
OPTIONAL { ?attribut vvo:default ?default . }
|
||||
}
|
||||
|
||||
""";
|
||||
|
||||
GraphQuery graphQuery = conn.prepareGraphQuery(queryString);
|
||||
// graphQuery.setBinding("stichtag", conn.getValueFactory().createLiteral(stichtagFormated.toXMLFormat(), XSD.DATE));
|
||||
|
||||
try (GraphQueryResult result = graphQuery.evaluate()) {
|
||||
result.forEach(model::add);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void addBoolAttribut(Model model) {
|
||||
Repository repo = new SailRepository(new MemoryStore());
|
||||
repo.init();
|
||||
|
||||
try (RepositoryConnection conn = repo.getConnection()) {
|
||||
conn.add(new File("src/main/resources/data/Attribute.ttl"), RDFFormat.TURTLE);
|
||||
|
||||
String queryString = """
|
||||
PREFIX vvo: <http://vvo.pisanoapi.at/>
|
||||
|
||||
CONSTRUCT {
|
||||
?attribut a vvo:ElemBoolean ;
|
||||
vvo:bez ?bez ;
|
||||
vvo:ProdElement ?ProdElement ;
|
||||
vvo:required ?required ;
|
||||
vvo:default ?default ;
|
||||
}
|
||||
WHERE {
|
||||
?attribut a vvo:ElemBoolean .
|
||||
OPTIONAL { ?attribut vvo:bez ?bez . }
|
||||
OPTIONAL { ?attribut vvo:ProdElement ?ProdElement . }
|
||||
OPTIONAL { ?attribut vvo:required ?required . }
|
||||
OPTIONAL { ?attribut vvo:default ?default . }
|
||||
}
|
||||
|
||||
""";
|
||||
|
||||
GraphQuery graphQuery = conn.prepareGraphQuery(queryString);
|
||||
// graphQuery.setBinding("stichtag", conn.getValueFactory().createLiteral(stichtagFormated.toXMLFormat(), XSD.DATE));
|
||||
|
||||
try (GraphQueryResult result = graphQuery.evaluate()) {
|
||||
result.forEach(model::add);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlausisToRequest(Model model) throws IOException {
|
||||
IRI plausiIri = iri("http://vvo.pisanoapi.at/plausi");
|
||||
IRI queryIri = iri("http://vvo.pisanoapi.at/query");
|
||||
IRI beschreibungIri = iri("http://vvo.pisanoapi.at/beschreibung");
|
||||
|
||||
File file = new File("src/main/resources/data/plausis");
|
||||
|
||||
int i = 1;
|
||||
for (File plausi : file.listFiles()) {
|
||||
var lines = Files.lines(plausi.toPath()).map(String::trim).toList();
|
||||
|
||||
String beschreibung = lines.stream().filter(line -> line.startsWith("#")).findFirst().get().substring(1);
|
||||
String query = lines.stream().filter(line -> !line.startsWith("#") && !line.isEmpty()).collect(Collectors.joining("\n"));
|
||||
|
||||
IRI spezPlausiIri = iri(plausiIri.stringValue() + i);
|
||||
|
||||
model.add(spezPlausiIri, RDF.TYPE, plausiIri);
|
||||
model.add(spezPlausiIri, queryIri, Values.literal(query));
|
||||
model.add(spezPlausiIri, beschreibungIri, Values.literal(beschreibung));
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,21 +6,28 @@ import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
|
||||
import org.eclipse.rdf4j.model.impl.TreeModel;
|
||||
import org.eclipse.rdf4j.model.util.Models;
|
||||
import org.eclipse.rdf4j.model.util.Values;
|
||||
import org.eclipse.rdf4j.model.vocabulary.RDF;
|
||||
import org.eclipse.rdf4j.query.GraphQuery;
|
||||
import org.eclipse.rdf4j.query.QueryResults;
|
||||
import org.eclipse.rdf4j.repository.Repository;
|
||||
import org.eclipse.rdf4j.repository.RepositoryConnection;
|
||||
import org.eclipse.rdf4j.repository.sail.SailRepository;
|
||||
import org.eclipse.rdf4j.rio.RDFFormat;
|
||||
import org.eclipse.rdf4j.rio.Rio;
|
||||
import org.eclipse.rdf4j.sail.memory.MemoryStore;
|
||||
|
||||
import javax.xml.datatype.DatatypeConfigurationException;
|
||||
import javax.xml.datatype.DatatypeFactory;
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
|
||||
import static org.eclipse.rdf4j.model.util.Values.iri;
|
||||
|
||||
public class CalculateService {
|
||||
public String buildResponse(String calculateRequest) throws IOException, DatatypeConfigurationException {
|
||||
VerkaufsproduktType vp = calculateRequestToVerkaufsprodukt(calculateRequest);
|
||||
VerkaufsproduktType vp = (VerkaufsproduktType) calculateRequestToVerkaufsprodukt(calculateRequest);
|
||||
|
||||
System.out.println("vp: " + vp.getBezeichnung());
|
||||
for (ProduktbausteinType unterbaustein : vp.getBausteine()){
|
||||
@@ -37,14 +44,14 @@ public class CalculateService {
|
||||
return baos.toString();
|
||||
}
|
||||
|
||||
private VerkaufsproduktType calculateRequestToVerkaufsprodukt(String calculateRequest) throws IOException, DatatypeConfigurationException {
|
||||
private ProduktbausteinType calculateRequestToVerkaufsprodukt(String calculateRequest) throws IOException, DatatypeConfigurationException {
|
||||
Model model = Rio.parse(new StringReader(calculateRequest), "", RDFFormat.JSONLD);
|
||||
|
||||
|
||||
|
||||
VerkaufsproduktType verkaufsproduktType = new VerkaufsproduktAllgemeinType();
|
||||
Map<String, ProduktbausteinType> bausteine = new HashMap<>();
|
||||
Map<String, String> parents = new HashMap<>();
|
||||
|
||||
for (Resource iri : Models.subjectIRIs(model)) {
|
||||
String id = iri.stringValue();
|
||||
|
||||
System.out.println(iri.stringValue());
|
||||
ValueFactory vf = SimpleValueFactory.getInstance();
|
||||
@@ -65,16 +72,22 @@ public class CalculateService {
|
||||
XMLGregorianCalendar verkaufsoffenVon = Models.objectLiteral(model.filter(iri, vf.createIRI(
|
||||
"http://vvo.pisanoapi.at/salesFrom"), null)).map(Literal::getLabel).isPresent() ? DatatypeFactory.newInstance().newXMLGregorianCalendar(
|
||||
Models.objectLiteral(model.filter(iri, vf.createIRI(
|
||||
"http://vvo.pisanoapi.at/salesFrom"), null)).map(Literal::getLabel).orElse(null)) : null ;
|
||||
"http://vvo.pisanoapi.at/salesFrom"), null)).map(Literal::getLabel).orElse(null)) : null ;
|
||||
XMLGregorianCalendar verkaufsoffenBis = Models.objectLiteral(model.filter(iri, vf.createIRI(
|
||||
"http://vvo.pisanoapi.at/salesTo"), null)).map(Literal::getLabel).isPresent() ? DatatypeFactory.newInstance().newXMLGregorianCalendar(
|
||||
Models.objectLiteral(model.filter(iri, vf.createIRI(
|
||||
"http://vvo.pisanoapi.at/salesTo"), null)).map(Literal::getLabel).orElse(null)) : null;
|
||||
|
||||
Optional<String> parentId = Models.objectResource(model.filter(iri, vf.createIRI(
|
||||
"http://vvo.pisanoapi.at/parent"), null)).map(Resource::stringValue);
|
||||
|
||||
for (Resource unterbaustein : Models.objectResources(model.filter(iri, vf.createIRI("http://vvo.pisanoapi.at/baustein"), null))){
|
||||
ProduktbausteinType baustein = calculateRequestToUnterbaustein(model, unterbaustein);
|
||||
verkaufsproduktType.getBausteine().add(baustein);
|
||||
|
||||
ProduktbausteinType verkaufsproduktType;
|
||||
if (parentId.isPresent()) {
|
||||
verkaufsproduktType = new ProduktAllgemeinType();
|
||||
}else {
|
||||
System.out.println(parentId);
|
||||
verkaufsproduktType = new VerkaufsproduktAllgemeinType();
|
||||
}
|
||||
|
||||
verkaufsproduktType.setId(iri.stringValue().substring(iri.stringValue().length() - 1));
|
||||
@@ -86,62 +99,27 @@ public class CalculateService {
|
||||
verkaufsproduktType.setMinVorkommen(minOccurrence);
|
||||
verkaufsproduktType.setRisikoobjektErforderlich(risikoobjektType != null);
|
||||
|
||||
break;
|
||||
parentId.ifPresent(p -> parents.put(id, p));
|
||||
bausteine.put(id, verkaufsproduktType);
|
||||
|
||||
}
|
||||
|
||||
return verkaufsproduktType;
|
||||
}
|
||||
List<VerkaufsproduktType> verkaufsprodukteList = new ArrayList<>();
|
||||
|
||||
private ProduktbausteinType calculateRequestToUnterbaustein(Model model, Resource iriUnterbaustein) throws IOException, DatatypeConfigurationException {
|
||||
ProduktbausteinType produktbausteinType = new ProduktAllgemeinType();
|
||||
for (Map.Entry<String, ProduktbausteinType> entry : bausteine.entrySet()){
|
||||
String id = entry.getKey();
|
||||
ProduktbausteinType baustein = entry.getValue();
|
||||
String parentId = parents.get(id);
|
||||
|
||||
for (Resource iri : Models.subjectIRIs(model)) {
|
||||
if (iri.equals(iriUnterbaustein)) {
|
||||
|
||||
|
||||
System.out.println(iri.stringValue());
|
||||
ValueFactory vf = SimpleValueFactory.getInstance();
|
||||
|
||||
|
||||
int insId = Integer.parseInt(Models.objectLiteral(model.filter(iri, vf.createIRI(
|
||||
"http://vvo.pisanoapi.at/ins_id"), null)).map(Literal::getLabel).orElse("-1"));
|
||||
int maxOccurrence = Integer.parseInt(Models.objectLiteral(model.filter(iri, vf.createIRI(
|
||||
"http://vvo.pisanoapi.at/maxOccurrence"), null)).map(Literal::getLabel).orElse("-1"));
|
||||
int minOccurrence = Integer.parseInt(Models.objectLiteral(model.filter(iri, vf.createIRI(
|
||||
"http://vvo.pisanoapi.at/minOccurrence"), null)).map(Literal::getLabel).orElse("-1"));
|
||||
String bez = Models.objectLiteral(model.filter(iri, vf.createIRI(
|
||||
"http://vvo.pisanoapi.at/bez"), null)).map(Literal::getLabel).orElse(null);
|
||||
String type = Models.objectLiteral(model.filter(iri, vf.createIRI(
|
||||
"http://vvo.pisanoapi.at/type"), null)).map(Literal::getLabel).orElse(null);
|
||||
String risikoobjektType = Models.objectLiteral(model.filter(iri, vf.createIRI(
|
||||
"http://vvo.pisanoapi.at/risikoobjektType"), null)).map(Literal::getLabel).orElse(null);
|
||||
XMLGregorianCalendar verkaufsoffenVon = Models.objectLiteral(model.filter(iri, vf.createIRI(
|
||||
"http://vvo.pisanoapi.at/salesFrom"), null)).map(Literal::getLabel).isPresent() ? DatatypeFactory.newInstance().newXMLGregorianCalendar(
|
||||
Models.objectLiteral(model.filter(iri, vf.createIRI(
|
||||
"http://vvo.pisanoapi.at/salesFrom"), null)).map(Literal::getLabel).orElse(null)) : null;
|
||||
XMLGregorianCalendar verkaufsoffenBis = Models.objectLiteral(model.filter(iri, vf.createIRI(
|
||||
"http://vvo.pisanoapi.at/salesTo"), null)).map(Literal::getLabel).isPresent() ? DatatypeFactory.newInstance().newXMLGregorianCalendar(
|
||||
Models.objectLiteral(model.filter(iri, vf.createIRI(
|
||||
"http://vvo.pisanoapi.at/salesTo"), null)).map(Literal::getLabel).orElse(null)) : null;
|
||||
|
||||
|
||||
for (Value unterbaustein : Models.objectResources(model.filter(iri, vf.createIRI("http://vvo.pisanoapi.at/baustein"), null))) {
|
||||
ProduktbausteinType baustein = calculateRequestToVerkaufsprodukt(unterbaustein.stringValue());
|
||||
produktbausteinType.getBausteine().add(baustein);
|
||||
}
|
||||
|
||||
produktbausteinType.setId(iri.stringValue().substring(iri.stringValue().length() - 1));
|
||||
produktbausteinType.setBezeichnung(bez);
|
||||
produktbausteinType.setTyp(type);
|
||||
produktbausteinType.setVerkaufsoffenVon(verkaufsoffenVon);
|
||||
produktbausteinType.setVerkaufsoffenBis(verkaufsoffenBis);
|
||||
produktbausteinType.setMaxVorkommen(maxOccurrence);
|
||||
produktbausteinType.setMinVorkommen(minOccurrence);
|
||||
produktbausteinType.setRisikoobjektErforderlich(risikoobjektType != null);
|
||||
if (parentId != null && bausteine.containsKey(parentId)){
|
||||
bausteine.get(parentId).getBausteine().add(baustein);
|
||||
}else {
|
||||
System.out.println("verkaufsprodukt aus calculate: " + baustein.getBezeichnung());
|
||||
verkaufsprodukteList.add((VerkaufsproduktType) baustein);
|
||||
}
|
||||
}
|
||||
|
||||
return produktbausteinType;
|
||||
return verkaufsprodukteList.getFirst();
|
||||
}
|
||||
|
||||
//Prüfen, ob sie zu den Werten im Verkaufsprodukt passen.
|
||||
@@ -152,12 +130,41 @@ public class CalculateService {
|
||||
//Ergänzen fehlender Bausteine
|
||||
private void validateRequest(VerkaufsproduktType vp) throws IOException {
|
||||
// pruefeVUNr(calculateRequest.getVUNr());
|
||||
pruefePlausis(vp);
|
||||
pruefeVerkaufsoffen(vp);
|
||||
pruefeWerte(vp);
|
||||
pruefeRisikoobjekt(vp);
|
||||
pruefeErgaentzungen(vp);
|
||||
}
|
||||
|
||||
private void pruefePlausis(VerkaufsproduktType vp) throws IOException {
|
||||
|
||||
File file = new File("src/main/resources/data/plausis");
|
||||
|
||||
Repository repo = new SailRepository(new MemoryStore());
|
||||
repo.init();
|
||||
|
||||
try (RepositoryConnection conn = repo.getConnection()) {
|
||||
Model model = createRdfModel(vp);
|
||||
conn.add(model);
|
||||
|
||||
for (File plausi : file.listFiles()) {
|
||||
System.out.println(plausi.getName());
|
||||
System.out.println("query wird gemacht");
|
||||
String sparql = Files.readString(plausi.toPath());
|
||||
|
||||
GraphQuery q = conn.prepareGraphQuery(sparql);
|
||||
Model validatedModel = QueryResults.asModel(q.evaluate());
|
||||
|
||||
model.addAll(validatedModel);
|
||||
}
|
||||
System.out.println("out nach query");
|
||||
} catch(Exception ignored) {
|
||||
System.out.println(ignored.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void pruefeWerte(VerkaufsproduktType verkaufsprodukt) {
|
||||
}
|
||||
|
||||
@@ -177,12 +184,12 @@ public class CalculateService {
|
||||
Model erg = new TreeModel();
|
||||
String baseIri = "http://vvo.pisanoapi.at/";
|
||||
|
||||
addProduktToModel(vp, erg, baseIri);
|
||||
addProduktToModel(vp, erg, baseIri, null);
|
||||
|
||||
return erg;
|
||||
}
|
||||
|
||||
public void addProduktToModel(ProduktbausteinType produkt, Model model, String baseIri) {
|
||||
public void addProduktToModel(ProduktbausteinType produkt, Model model, String baseIri, String parentId) {
|
||||
IRI prodelemIri = iri(baseIri + "ProdElement");
|
||||
IRI insIdIri = iri(baseIri + "ins_id");
|
||||
IRI bezIri = iri(baseIri + "bez");
|
||||
@@ -194,18 +201,23 @@ public class CalculateService {
|
||||
IRI typeIri = iri(baseIri + "type");
|
||||
IRI risikoobjektTypeIri = iri(baseIri + "risikoobjektType");
|
||||
IRI bausteinIri = iri(baseIri + "baustein");
|
||||
IRI parentIri = iri(baseIri + "parent");
|
||||
|
||||
IRI vpIri = iri(baseIri + "ProdElement" + produkt.getId());
|
||||
|
||||
model.add(vpIri, RDF.TYPE, prodelemIri);
|
||||
// erg.add(vpIri, insIdIri, vp.getinsid())
|
||||
model.add(vpIri, bezIri, Values.literal(produkt.getBezeichnung()));
|
||||
// erg.add(vpIri, createdIri, Values.literal(vp.get()));
|
||||
model.add(vpIri, salesFromIri, Values.literal(produkt.getVerkaufsoffenVon()));
|
||||
model.add(vpIri, salesToIri, Values.literal(produkt.getVerkaufsoffenBis()));
|
||||
if (produkt.getVerkaufsoffenBis() != null) model.add(vpIri, salesToIri, Values.literal(produkt.getVerkaufsoffenBis()));
|
||||
model.add(vpIri, minOccurrenceIri, Values.literal(produkt.getMinVorkommen()));
|
||||
model.add(vpIri, maxOccurrenceIri, Values.literal(produkt.getMaxVorkommen()));
|
||||
model.add(vpIri, typeIri, Values.literal(produkt.getTyp()));
|
||||
|
||||
if (parentId != null) model.add(vpIri, parentIri, Values.iri(parentId));
|
||||
|
||||
|
||||
// for (int i = 0; i < vp.getVersicherteObjekte().size(); i++) {
|
||||
// erg.add(vpIri, risikoobjektTypeIri, Values.literal(vp.getVersicherteObjekte().get(i)));
|
||||
// }
|
||||
@@ -213,7 +225,9 @@ public class CalculateService {
|
||||
IRI unterbausteinIri = iri(baseIri + "ProdElement" + produkt.getBausteine().get(i).getId());
|
||||
model.add(vpIri, bausteinIri, unterbausteinIri);
|
||||
|
||||
addProduktToModel(produkt.getBausteine().get(i), model, baseIri);
|
||||
parentId = vpIri.stringValue();
|
||||
|
||||
addProduktToModel(produkt.getBausteine().get(i), model, baseIri, parentId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,6 +235,10 @@ public class CalculateService {
|
||||
|
||||
}
|
||||
|
||||
public void addAttributToModel(AttributType attribut, Model model, String baseIri) {
|
||||
|
||||
}
|
||||
|
||||
private void calculate() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ vvo:ProdElementShape a sh:NodeShape ;
|
||||
sh:path vvo:salesTo ;
|
||||
sh:datatype xs:date ;
|
||||
sh:maxCount 1 ;
|
||||
sh:minCount 1 ;
|
||||
sh:minCount 0 ;
|
||||
] ;
|
||||
sh:property [
|
||||
sh:path vvo:minOccurrence ;
|
||||
|
||||
69
src/main/resources/data/Attribute.ttl
Normal file
69
src/main/resources/data/Attribute.ttl
Normal file
@@ -0,0 +1,69 @@
|
||||
@prefix vvo: <http://vvo.pisanoapi.at/> .
|
||||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
||||
|
||||
vvo:ElemBoolean1 a vvo:ElemBoolean ;
|
||||
vvo:bez "TestBooleanElement1" ;
|
||||
vvo:ProdElement vvo:ProdElement11 ;
|
||||
vvo:required "true"^^xsd:boolean ;
|
||||
vvo:default "true"^^xsd:boolean .
|
||||
|
||||
vvo:ElemBoolean2 a vvo:ElemBoolean ;
|
||||
vvo:bez "TestBooleanElement2" ;
|
||||
vvo:ProdElement vvo:ProdElement12 ;
|
||||
vvo:required "true"^^xsd:boolean ;
|
||||
vvo:default "false"^^xsd:boolean .
|
||||
|
||||
vvo:ElemBoolean3 a vvo:ElemBoolean ;
|
||||
vvo:bez "TestBooleanElement3" ;
|
||||
vvo:ProdElement vvo:ProdElement12 ;
|
||||
vvo:required "false"^^xsd:boolean ;
|
||||
vvo:default "false"^^xsd:boolean .
|
||||
|
||||
vvo:ElemInt1 a vvo:ElemInt ;
|
||||
vvo:bez "AnzSitzplaetze" ;
|
||||
vvo:ProdElement vvo:ProdElement11 ;
|
||||
vvo:required "true"^^xsd:boolean ;
|
||||
vvo:max 11 ;
|
||||
vvo:min 2 ;
|
||||
vvo:default 5 .
|
||||
|
||||
vvo:ElemDecimal1 a vvo:ElemDecimal ;
|
||||
vvo:bez "Versicherungssumme" ;
|
||||
vvo:ProdElement vvo:ProdElement11 ;
|
||||
vvo:required "true"^^xsd:boolean ;
|
||||
vvo:max "10000"^^xsd:decimal ;
|
||||
vvo:min "10"^^xsd:decimal .
|
||||
|
||||
vvo:ElemDecimal2 a vvo:ElemDecimal ;
|
||||
vvo:bez "Selbstbehalt" ;
|
||||
vvo:ProdElement vvo:ProdElement11 ;
|
||||
vvo:required "true"^^xsd:boolean ;
|
||||
vvo:max "10000.0"^^xsd:decimal ;
|
||||
vvo:min "10"^^xsd:decimal;
|
||||
vvo:default "100"^^xsd:decimal .
|
||||
|
||||
vvo:ElemDecimal3 a vvo:ElemDecimal ;
|
||||
vvo:bez "Wert" ;
|
||||
vvo:ProdElement vvo:ProdElement12 ;
|
||||
vvo:required "true"^^xsd:boolean ;
|
||||
vvo:max "50000"^^xsd:decimal ;
|
||||
vvo:min "1000"^^xsd:decimal .
|
||||
|
||||
vvo:ElemString1 a vvo:ElemString ;
|
||||
vvo:bez "TestStringElement1" ;
|
||||
vvo:ProdElement vvo:ProdElement11 ;
|
||||
vvo:required "true"^^xsd:boolean ;
|
||||
vvo:default "TestStringDefaultValue1" .
|
||||
|
||||
vvo:ElemString2 a vvo:ElemString ;
|
||||
vvo:bez "TestStringElement2" ;
|
||||
vvo:ProdElement vvo:ProdElement12 ;
|
||||
vvo:required "false"^^xsd:boolean ;
|
||||
vvo:default "TestStringDefaultValue2" .
|
||||
|
||||
vvo:ElemString3 a vvo:ElemString ;
|
||||
vvo:bez "TestStringElement3" ;
|
||||
vvo:ProdElement vvo:ProdElement11 ;
|
||||
vvo:required "false"^^xsd:boolean ;
|
||||
vvo:default "TestStringDefaultValue3" .
|
||||
|
||||
4
src/main/resources/data/KFZProdukt.ttl
Normal file
4
src/main/resources/data/KFZProdukt.ttl
Normal file
@@ -0,0 +1,4 @@
|
||||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
||||
@prefix xs: <http://www.w3.org/2001/XMLSchema#> .
|
||||
|
||||
16
src/main/resources/data/plausis/kasko.sparql
Normal file
16
src/main/resources/data/plausis/kasko.sparql
Normal file
@@ -0,0 +1,16 @@
|
||||
# Plausi: Ein Baustein darf nur entweder ein Teilkasko oder ein Vollkasko Element haben
|
||||
PREFIX vvo: <http://vvo.pisanoapi.at/>
|
||||
|
||||
CONSTRUCT {
|
||||
?prodelement vvo:meldung "Es kann nur entweder Vollkasko oder Teilkasko eingeschlossen werden" .
|
||||
}
|
||||
WHERE {
|
||||
?prodelement a vvo:ProdElement .
|
||||
|
||||
?prodelement vvo:baustein ?uup1 .
|
||||
?uup1 vvo:type "at.vvo.omds.types.omds3.r2025_05.on2antrag.kfz.TeilkaskoKfzType" .
|
||||
|
||||
?prodelement vvo:baustein ?uup2 .
|
||||
?uup2 vvo:type "at.vvo.omds.types.omds3.r2025_05.on2antrag.kfz.VollkaskoKfzType" .
|
||||
|
||||
}
|
||||
@@ -148,7 +148,7 @@ vvo:ProdElement13 a vvo:ProdElement ;
|
||||
vvo:parent vvo:ProdElement10 ;
|
||||
vvo:previous vvo:ProdElement9 ;
|
||||
vvo:minOccurrence 1 ;
|
||||
vvo:maxOccurrence 1 ;
|
||||
vvo:maxOccurrence 2 ;
|
||||
vvo:type "at.vvo.omds.types.omds3.r2025_05.on2antrag.kfz.AssistanceKfzType" .
|
||||
|
||||
vvo:ProdElement14 a vvo:ProdElement ;
|
||||
@@ -158,7 +158,7 @@ vvo:ProdElement14 a vvo:ProdElement ;
|
||||
vvo:salesFrom "2022-01-01"^^xsd:date ;
|
||||
vvo:parent vvo:ProdElement12 ;
|
||||
vvo:minOccurrence 1 ;
|
||||
vvo:maxOccurrence 1 ;
|
||||
vvo:maxOccurrence 2 ;
|
||||
vvo:type "at.vvo.omds.types.omds3.r2025_05.on2antrag.kfz.VollkaskoKfzType" ;
|
||||
vvo:risikoobjektType "FahrzeugType" .
|
||||
|
||||
@@ -169,7 +169,7 @@ vvo:ProdElement15 a vvo:ProdElement ;
|
||||
vvo:salesFrom "2022-01-01"^^xsd:date ;
|
||||
vvo:parent vvo:ProdElement14 ;
|
||||
vvo:minOccurrence 1 ;
|
||||
vvo:maxOccurrence 1 ;
|
||||
vvo:maxOccurrence 4 ;
|
||||
vvo:type "at.vvo.omds.types.omds3.r2025_05.on2antrag.kfz.VollkaskoKfzType" .
|
||||
|
||||
vvo:ProdElement16 a vvo:ProdElement ;
|
||||
@@ -193,68 +193,3 @@ vvo:ProdElement17 a vvo:ProdElement ;
|
||||
vvo:type "at.vvo.omds.types.omds3.r2025_05.on2antrag.kfz.VerkaufsproduktKfzType" ;
|
||||
vvo:risikoobjektType "FahrzeugType" .
|
||||
|
||||
vvo:ElemBoolean1 a vvo:ElemBoolean ;
|
||||
vvo:bez "TestBooleanElement1" ;
|
||||
vvo:ProdElement vvo:ProdElement11 ;
|
||||
vvo:required "true"^^xsd:boolean ;
|
||||
vvo:default "true"^^xsd:boolean .
|
||||
|
||||
vvo:ElemBoolean2 a vvo:ElemBoolean ;
|
||||
vvo:bez "TestBooleanElement2" ;
|
||||
vvo:ProdElement vvo:ProdElement12 ;
|
||||
vvo:required "true"^^xsd:boolean ;
|
||||
vvo:default "false"^^xsd:boolean .
|
||||
|
||||
vvo:ElemBoolean3 a vvo:ElemBoolean ;
|
||||
vvo:bez "TestBooleanElement3" ;
|
||||
vvo:ProdElement vvo:ProdElement12 ;
|
||||
vvo:required "false"^^xsd:boolean ;
|
||||
vvo:default "false"^^xsd:boolean .
|
||||
|
||||
vvo:ElemInt1 a vvo:ElemInt ;
|
||||
vvo:bez "AnzSitzplaetze" ;
|
||||
vvo:ProdElement vvo:ProdElement11 ;
|
||||
vvo:required "true"^^xsd:boolean ;
|
||||
vvo:max 11 ;
|
||||
vvo:min 2 ;
|
||||
vvo:default 5 .
|
||||
|
||||
vvo:ElemDecimal1 a vvo:ElemDecimal ;
|
||||
vvo:bez "Versicherungssumme" ;
|
||||
vvo:ProdElement vvo:ProdElement11 ;
|
||||
vvo:required "true"^^xsd:boolean ;
|
||||
vvo:max "10000"^^xsd:decimal ;
|
||||
vvo:min "10"^^xsd:decimal .
|
||||
|
||||
vvo:ElemDecimal2 a vvo:ElemDecimal ;
|
||||
vvo:bez "Selbstbehalt" ;
|
||||
vvo:ProdElement vvo:ProdElement11 ;
|
||||
vvo:required "true"^^xsd:boolean ;
|
||||
vvo:max "10000.0"^^xsd:decimal ;
|
||||
vvo:min "10"^^xsd:decimal;
|
||||
vvo:default "100"^^xsd:decimal .
|
||||
|
||||
vvo:ElemDecimal3 a vvo:ElemDecimal ;
|
||||
vvo:bez "Wert" ;
|
||||
vvo:ProdElement vvo:ProdElement12 ;
|
||||
vvo:required "true"^^xsd:boolean ;
|
||||
vvo:max "50000"^^xsd:decimal ;
|
||||
vvo:min "1000"^^xsd:decimal .
|
||||
|
||||
vvo:ElemString1 a vvo:ElemString ;
|
||||
vvo:bez "TestStringElement1" ;
|
||||
vvo:ProdElement vvo:ProdElement11 ;
|
||||
vvo:required "true"^^xsd:boolean ;
|
||||
vvo:default "TestStringDefaultValue1" .
|
||||
|
||||
vvo:ElemString2 a vvo:ElemString ;
|
||||
vvo:bez "TestStringElement2" ;
|
||||
vvo:ProdElement vvo:ProdElement12 ;
|
||||
vvo:required "false"^^xsd:boolean ;
|
||||
vvo:default "TestStringDefaultValue2" .
|
||||
|
||||
vvo:ElemString3 a vvo:ElemString ;
|
||||
vvo:bez "TestStringElement3" ;
|
||||
vvo:ProdElement vvo:ProdElement11 ;
|
||||
vvo:required "false"^^xsd:boolean ;
|
||||
vvo:default "TestStringDefaultValue3" .
|
||||
|
||||
Reference in New Issue
Block a user