client-lib, client-app und server-app aus den jeweiligen projekten importiert. api-definition begonnen zu implementieren
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
package at.vvo.omds.client;
|
||||
|
||||
import at.vvo.omds.types.omds2.v2_17.NATUERLICHEPERSONType;
|
||||
import at.vvo.omds.types.omds2.v2_17.PersArtCdType;
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.AdresseType;
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.ObjektIdType;
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.PersonType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.xml.datatype.DatatypeConfigurationException;
|
||||
import javax.xml.datatype.DatatypeFactory;
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
/**
|
||||
* Hilfsmethoden für die Erzeugung von Requests.
|
||||
*/
|
||||
public class BuildRequestHelper {
|
||||
|
||||
static Logger log = LoggerFactory.getLogger(BuildRequestHelper.class);
|
||||
/** Privater default Constructor versteckt den nicht benötigten Default-Constructor. */
|
||||
private BuildRequestHelper() {
|
||||
}
|
||||
|
||||
public static XMLGregorianCalendar omdsDatum(int year, int month, int day) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd");
|
||||
try {
|
||||
GregorianCalendar c = new GregorianCalendar();
|
||||
c.set(year, month, day);
|
||||
return DatatypeFactory.newInstance().newXMLGregorianCalendar(c.toZonedDateTime().format(formatter));
|
||||
} catch (DatatypeConfigurationException e) {
|
||||
log.atError().log("Datum konnte nicht erzeugt werden");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static XMLGregorianCalendar aktuellesDatum() {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss");
|
||||
try {
|
||||
GregorianCalendar c = new GregorianCalendar();
|
||||
return DatatypeFactory.newInstance().newXMLGregorianCalendar(c.toZonedDateTime().format(formatter));
|
||||
} catch (DatatypeConfigurationException e) {
|
||||
log.atError().log("Datum konnte nicht erzeugt werden");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static XMLGregorianCalendar zuXml(LocalDate localDate) {
|
||||
XMLGregorianCalendar xmlGregorianCalendar = null;
|
||||
try {
|
||||
xmlGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(localDate.toString());
|
||||
} catch (DatatypeConfigurationException e) {
|
||||
log.atError().log(String.format("DatatypeConfigurationException %s", e.getMessage()));
|
||||
}
|
||||
return xmlGregorianCalendar;
|
||||
}
|
||||
|
||||
public static XMLGregorianCalendar hauptfalligkeit(int monat) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss");
|
||||
try {
|
||||
GregorianCalendar c = new GregorianCalendar();
|
||||
c.set(Calendar.MONTH, monat);
|
||||
c.set(Calendar.DAY_OF_MONTH, 1);
|
||||
c.set(Calendar.HOUR_OF_DAY, 0);
|
||||
c.set(Calendar.MINUTE, 0);
|
||||
c.set(Calendar.SECOND, 0);
|
||||
c.set(Calendar.MILLISECOND, 0);
|
||||
return DatatypeFactory.newInstance().newXMLGregorianCalendar(c.toZonedDateTime().format(formatter));
|
||||
} catch (DatatypeConfigurationException e) {
|
||||
log.atError().log("Datum konnte nicht erzeugt werden");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static PersonType createNatPerson(String vorname, String nachname, LocalDate gebDat, String strasse, String hausnr, int plz, String ort) {
|
||||
PersonType person = new PersonType();
|
||||
|
||||
person.setPersArtCd(PersArtCdType.N); //neu
|
||||
NATUERLICHEPERSONType natPerson = new NATUERLICHEPERSONType();
|
||||
natPerson.setFamilienname(nachname);
|
||||
natPerson.setVorname(vorname);
|
||||
natPerson.setGebdat(BuildRequestHelper.zuXml(gebDat));
|
||||
natPerson.setGeschlechtCd("1");
|
||||
natPerson.setFamilienstandCd("0"); // neu
|
||||
natPerson.setLandesCd("AUT"); // neu
|
||||
person.setNATUERLICHEPERSON(natPerson);
|
||||
AdresseType adresse = new AdresseType();
|
||||
person.setAdresse(adresse);
|
||||
adresse.setOrt(ort);
|
||||
adresse.setPLZ(Integer.toString(plz));
|
||||
adresse.setStrasse(strasse);
|
||||
adresse.setHausnr(hausnr);
|
||||
adresse.setLandesCd("AUT"); //neu
|
||||
ObjektIdType objektId = new ObjektIdType(); //neu
|
||||
objektId.setId("1"); //neu
|
||||
adresse.setObjektId(objektId); //neu
|
||||
return person;
|
||||
}
|
||||
|
||||
public static PersonType createNatPerson(String vorname, String nachname, int gebJahr, int gebMonat, int gebTag) {
|
||||
PersonType person = new PersonType();
|
||||
|
||||
person.setPersArtCd(PersArtCdType.N); //neu
|
||||
NATUERLICHEPERSONType natPerson = new NATUERLICHEPERSONType();
|
||||
natPerson.setFamilienname(nachname);
|
||||
natPerson.setVorname(vorname);
|
||||
natPerson.setGebdat(BuildRequestHelper.omdsDatum(gebJahr, gebMonat, gebTag));
|
||||
natPerson.setGeschlechtCd("1");
|
||||
natPerson.setFamilienstandCd("0"); // neu
|
||||
natPerson.setLandesCd("AUT"); // neu
|
||||
person.setNATUERLICHEPERSON(natPerson);
|
||||
AdresseType adresse = new AdresseType();
|
||||
person.setAdresse(adresse);
|
||||
adresse.setOrt("Wien");
|
||||
adresse.setPLZ("1020");
|
||||
adresse.setStrasse("Schüttelstraße");
|
||||
adresse.setHausnr("99");
|
||||
adresse.setZusatz("7");
|
||||
adresse.setLandesCd("AUT"); //neu
|
||||
ObjektIdType objektId = new ObjektIdType(); //neu
|
||||
objektId.setId("1"); //neu
|
||||
adresse.setObjektId(objektId); //neu
|
||||
|
||||
return person;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package at.vvo.omds.client;
|
||||
|
||||
import at.vvo.omds.types.omds3.r2025_05.on2antrag.unfall.CalculateUnfallResponseType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class LogCalculateResponse {
|
||||
|
||||
public static void ausgabe(CalculateUnfallResponseType response) {
|
||||
Logger logger = LoggerFactory.getLogger(LogCalculateResponse.class);
|
||||
logger.info("Got Response As below ================================== : ");
|
||||
logger.info("Status : "+response.getStatus().getErgebnis().value());
|
||||
logger.info("KorrelationsId : "+response.getStatus().getKorrelationsId());
|
||||
logger.info("Personen =============================================== : ");
|
||||
logger.info("Anzahl-Personen : "+response.getBerechnungsantwort().getPersonen().size());
|
||||
for (int i=0; i<response.getBerechnungsantwort().getPersonen().size(); i++) {
|
||||
logger.info("Person-" + (i+1));
|
||||
if (response.getBerechnungsantwort().getPersonen().get(i).getPerson().getNATUERLICHEPERSON() != null) {
|
||||
logger.info("Natürliche Person : ");
|
||||
logger.info("Familienname : " + response.getBerechnungsantwort().getPersonen().get(i).getPerson().getNATUERLICHEPERSON().getFamilienname());
|
||||
logger.info("Vorname : " + response.getBerechnungsantwort().getPersonen().get(i).getPerson().getNATUERLICHEPERSON().getVorname());
|
||||
logger.info("Geburtsdatum : " + response.getBerechnungsantwort().getPersonen().get(i).getPerson().getNATUERLICHEPERSON().getGebdat());
|
||||
}else {
|
||||
logger.info("Sonstige Person : ");
|
||||
logger.info("Name : " + response.getBerechnungsantwort().getPersonen().get(i).getPerson().getSONSTIGEPERSON().getName());
|
||||
logger.info("Kurzname : " + response.getBerechnungsantwort().getPersonen().get(i).getPerson().getSONSTIGEPERSON().getKurzname());
|
||||
logger.info("Kurzname : " + response.getBerechnungsantwort().getPersonen().get(i).getPerson().getSONSTIGEPERSON().getSonstPersArtCd());
|
||||
}
|
||||
logger.info("Plz Ort : " + response.getBerechnungsantwort().getPersonen().get(i).getPerson().getAdresse().getPLZ() + " " + response.getBerechnungsantwort().getPersonen().get(i).getPerson().getAdresse().getOrt());
|
||||
logger.info("Anschrift : " + response.getBerechnungsantwort().getPersonen().get(i).getPerson().getAdresse().getStrasse() + " " +
|
||||
response.getBerechnungsantwort().getPersonen().get(i).getPerson().getAdresse().getHausnr() + "/" +
|
||||
response.getBerechnungsantwort().getPersonen().get(i).getPerson().getAdresse().getZusatz());
|
||||
}
|
||||
logger.info("Verkaufsprodukt ======================================== : ");
|
||||
logger.info("Produktvariante : " + response.getBerechnungsantwort().getVerkaufsprodukt().getId());
|
||||
logger.info("Vertragsbeginn : " + response.getBerechnungsantwort().getVerkaufsprodukt().getVtgBeg());
|
||||
logger.info("Vertragsende : " + response.getBerechnungsantwort().getVerkaufsprodukt().getVtgEnde());
|
||||
logger.info("Vermittlernummer : " + response.getBerechnungsantwort().getVerkaufsprodukt().getVermittlernr());
|
||||
logger.info("Hauptfaelligkeit : " + response.getBerechnungsantwort().getVerkaufsprodukt().getHauptfaelligkeit());
|
||||
logger.info("Zahlrhythmus : " + response.getBerechnungsantwort().getVerkaufsprodukt().getZahlrhythmus());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
# Verhalten Server und Client
|
||||
|
||||
### Prämissen
|
||||
* Request kann immer vollkommen "dirty" sein, über Kaskade von Prüfungen muss dies validiert werden.
|
||||
* Immer gültiges XML
|
||||
* Aufbau des Requests entspricht dem a priori Produktwissen. Wenn dagegen verstoßen wird (Baustein oder Attribut), gibt es
|
||||
möglichst sprechende Fehlermeldungen. Es ist aber ein Fehler zur Entwicklungszeit, d.h. es darf aber es muss keinen Produktbaum im
|
||||
Response geben, einfache Fehlermeldung genügt. Es ist kein inhaltlicher Konfigurationsfehler, der über einen "schönen"
|
||||
Response an den Client zur Korrektur gegeben werden muss.
|
||||
* Response darf teilweise "dirty" sein, damit gute Fehlerhinweise möglich sind und der User leicht korrigieren kann.
|
||||
* Client zeigt den Response an und keine Mischung aus seinem Request und dem Response. Damit
|
||||
Client und Server wieder synchron sind.
|
||||
* Das Verhalten könnte Context-gesteuert sein, z.B.:
|
||||
* Im Context "Produktvergleich" werden immer nur Fehlermeldungen geworfen
|
||||
* Im Context "Antrag", "Vertragsänderung" oder "Einzelkonfiguration" werden Empfehlungen abgegeben.
|
||||
* Das Verhalten des Servers könnte sogar Produktabhängig definiert sein: An manchen Bausteinen Variante 1 an
|
||||
anderen Variante 2 des Verhaltens.(?)
|
||||
* Berechnung nur, wenn die Instanz (Antrag, Vertrag) erfolgreich plausibilisiert.
|
||||
* Unterstützung für "Actions"?
|
||||
* Verhaltenssteuerung: Im Request kann ein Profil vorgegeben werden. Im Response wird angegeben, ob es berücksichtigt werden konnte, oder Fallbackverhalten.
|
||||
* Basic - nur Fehlermeldungen, Baum wird nie verändert
|
||||
* Advanced - Fehlermeldungen und Änderungen im Baum (z.B. Anlage von Default-Elementen). Das Verhalten im Baum ist normiert.
|
||||
* Freestyle - Server reagiert innerhalb der vorgegebenen Möglichkeiten, wie er es an der Stelle für richtig hält. Sprich der
|
||||
Produktentwickler legt dies fest und kann das für Bausteine und Attribute festlegen.
|
||||
* Actions - es werden Actions angeboten, um Korrekturen im Baum vorzunehmen.
|
||||
|
||||
## Fälle Bausteine
|
||||
|
||||
Der Client schickt einen Unbekannten Baustein. Der Server gibt eine Fehlermeldung zurück.
|
||||
Der Client schickt einen Baustein mit einem fehlerhaften Attribut. Der Server gibt eine Fehlermeldung zurück.
|
||||
Der Server schickt einen ungültigen Baustein. Der Server gibt eine Fehlermeldung zurück.
|
||||
|
||||
|
||||
Der Client schickt zu viele von einem Baustein. A priori erstmal ausgeschlossen, da der
|
||||
Client über Produktwissen verfügt. Über Plausis in der Instanz kann der Fall trotzdem eintreten.
|
||||
Der Server könnte:
|
||||
1) Fehlermeldung in Oberbaustein senden
|
||||
2) Die überzähligen Bausteine auf Inaktiv setzen und mit Fehler markieren
|
||||
3) Den überzähligen Baustein / die überzähligen Bausteine entfernen
|
||||
|
||||
Der Client schickt zu wenig von einem Baustein. Der Server könnte:
|
||||
1) Einen Default Baustein (mehrere Default-Bausteine) hinzufügen (er kann dabei die Daten des Requests in den
|
||||
Vorschlag einfließen lassen, was der Client nicht kann)
|
||||
2) Eine Meldung über den Parent mitgeben, der Client ist dann zuständig den Baustein anzulegen.
|
||||
|
||||
Der Client schickt Bausteine, die sich wiedersprechen. Der Server könnte:
|
||||
1) Fehlermeldung und beide belassen
|
||||
2) Fehlermeldung und einen priorisieren und den anderen inaktiv setzen.
|
||||
3) Fehlermeldung und beide inaktiv setzen
|
||||
|
||||
Der Client schickt einen Baustein in einem falschen Kontext. Der Server könnte:
|
||||
1) Den Baustein dem richtigen Kontext zuordnen
|
||||
2) Den Baustein inaktiv setzen
|
||||
|
||||
|
||||
## Fälle Attribute
|
||||
|
||||
Attribut unbekannt - sollte gar nicht auftreten, muss nicht inhaltlich behandelt werden
|
||||
|
||||
Wert in Attribut ungültig - Attribut behält den falschen Wert, wird aber mit Fehlermeldung zurückgegeben.
|
||||
|
||||
Kardinalität Attribut überschritten:
|
||||
1) Fehler an Baustein
|
||||
2) Fehler an überzähligen Attributen
|
||||
|
||||
Kardinalität Attribut unterschritten:
|
||||
1) Fehler an Baustein aber keine automatische Ergänzung
|
||||
2) Hinweis an Baustein, Ergänzen der fehlenden Attribute mit Defaultwerten.
|
||||
|
||||
|
||||
@@ -0,0 +1,427 @@
|
||||
package at.vvo.omds.client.gui;
|
||||
|
||||
import at.vvo.omds.helpers.GuiProdukt;
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.*;
|
||||
import javafx.animation.PauseTransition;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.paint.Paint;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.scene.text.FontWeight;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.util.Duration;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.*;
|
||||
|
||||
public class ItemAttribute {
|
||||
Map<TreeItem<GuiProdukt>, Map<AttributType, String>> infoBoxFromItem = new HashMap<>();
|
||||
List<VersichertesInteresseMitAttributMetadatenType> risikoobjekte = new ArrayList<>();
|
||||
|
||||
public List<VersichertesInteresseMitAttributMetadatenType> getRisikoobjekte() {
|
||||
return risikoobjekte;
|
||||
}
|
||||
|
||||
public void setRisikoobjekte(List<VersichertesInteresseMitAttributMetadatenType> risikoobjekte) {
|
||||
this.risikoobjekte = risikoobjekte;
|
||||
}
|
||||
|
||||
public Map<TreeItem<GuiProdukt>, Map<AttributType, String>> getInfoBoxFromItem() {
|
||||
return infoBoxFromItem;
|
||||
}
|
||||
public void setInfoBoxFromItem(Map<TreeItem<GuiProdukt>, Map<AttributType, String>> infoBoxFromItem) {
|
||||
this.infoBoxFromItem = infoBoxFromItem;
|
||||
}
|
||||
|
||||
public VBox addItemInfo(TreeItem<GuiProdukt> newSelection, VBox attributBox) {
|
||||
for(int j = 0; j < ((ProduktbausteinType)newSelection.getValue().getProdukt()).getAttribute().size(); j++) {
|
||||
VBox singleAttributBox = new VBox();
|
||||
singleAttributBox.setPadding(new Insets(10));
|
||||
|
||||
Label label = new Label(
|
||||
((ProduktbausteinType)newSelection.getValue().getProdukt()).getAttribute().get(j).getBezeichnung() + ": ");
|
||||
label.setId("label");
|
||||
TextField textField = new TextField();
|
||||
|
||||
CheckBox checkBox = new CheckBox();
|
||||
|
||||
AttributStringType stringAttribut;
|
||||
AttributBooleanType attributBoolean;
|
||||
AttributDezimalType attributDezimal;
|
||||
AttributIntType attributInt;
|
||||
|
||||
if (((ProduktbausteinType)newSelection.getValue().getProdukt()).getAttribute().get(j).getClass()
|
||||
.equals(AttributBooleanType.class)) {
|
||||
attributDezimal = null;
|
||||
attributInt = null;
|
||||
stringAttribut = null;
|
||||
|
||||
attributBoolean = (AttributBooleanType) (
|
||||
(ProduktbausteinType)newSelection.getValue().getProdukt()).getAttribute().get(j);
|
||||
|
||||
if (infoBoxFromItem.get(newSelection) != null && infoBoxFromItem.get(newSelection).get(attributBoolean)
|
||||
!= null && !infoBoxFromItem.get(newSelection).get(attributBoolean).isEmpty()){
|
||||
if (infoBoxFromItem.get(newSelection).get(attributBoolean).equals("false")){
|
||||
checkBox.setSelected(false);
|
||||
}else if(infoBoxFromItem.get(newSelection).get(attributBoolean).equals("true")){
|
||||
checkBox.setSelected(true);
|
||||
}
|
||||
}
|
||||
} else if (((ProduktbausteinType)newSelection.getValue().getProdukt()).getAttribute().get(j).getClass()
|
||||
.equals(AttributStringType.class)) {
|
||||
attributDezimal = null;
|
||||
attributBoolean = null;
|
||||
attributInt = null;
|
||||
|
||||
stringAttribut = (AttributStringType) ((ProduktbausteinType)newSelection.getValue().getProdukt()).getAttribute().get(j);
|
||||
|
||||
if (stringAttribut.isPflichtfeld()) {
|
||||
label.setText(label.getText().substring(0, label.getText().length()-2) + "*: ");
|
||||
}
|
||||
if (stringAttribut.isAenderbar() != null && !stringAttribut.isAenderbar()) {
|
||||
textField.setEditable(false);
|
||||
}
|
||||
if (infoBoxFromItem.get(newSelection) != null
|
||||
&& infoBoxFromItem.get(newSelection).get(stringAttribut) != null
|
||||
&& !infoBoxFromItem.get(newSelection).get(stringAttribut).isEmpty()){
|
||||
textField.setText(infoBoxFromItem.get(newSelection).get(stringAttribut));
|
||||
} else if (stringAttribut.getValue() != null && !stringAttribut.getValue().equals("null")) {
|
||||
textField.setText(stringAttribut.getValue());
|
||||
} else if (stringAttribut.getDefault() != null) {
|
||||
textField.setText(stringAttribut.getDefault());
|
||||
}
|
||||
textField.setPromptText("Text eingeben");
|
||||
|
||||
} else if (((ProduktbausteinType)newSelection.getValue().getProdukt()).getAttribute().get(j).getClass()
|
||||
.equals(AttributDezimalType.class)) {
|
||||
attributBoolean = null;
|
||||
attributInt = null;
|
||||
stringAttribut = null;
|
||||
|
||||
attributDezimal = (AttributDezimalType) ((ProduktbausteinType)newSelection.getValue().getProdukt()).getAttribute().get(j);
|
||||
|
||||
if (attributDezimal.isPflichtfeld()) {
|
||||
label.setText(label.getText().substring(0, label.getText().length()-2) + "*: ");
|
||||
}
|
||||
if (attributDezimal.isAenderbar() != null && !attributDezimal.isAenderbar()) {
|
||||
textField.setEditable(false);
|
||||
}
|
||||
if (infoBoxFromItem.get(newSelection) != null
|
||||
&& infoBoxFromItem.get(newSelection).get(attributDezimal) != null
|
||||
&& !infoBoxFromItem.get(newSelection).get(attributDezimal).isEmpty()){
|
||||
textField.setText(infoBoxFromItem.get(newSelection).get(attributDezimal));
|
||||
} else if (attributDezimal.getValue() != null && !(attributDezimal.getValue().toString().equals("-1"))) {
|
||||
textField.setText(attributDezimal.getValue().toString());
|
||||
} else if (attributDezimal.getDefault() != null) {
|
||||
textField.setText(attributDezimal.getDefault().toString());
|
||||
}
|
||||
textField.setPromptText("Dezimalzahl eingeben");
|
||||
} else {
|
||||
attributDezimal = null;
|
||||
attributBoolean = null;
|
||||
stringAttribut = null;
|
||||
|
||||
attributInt = (AttributIntType) ((ProduktbausteinType)newSelection.getValue().getProdukt()).getAttribute().get(j);
|
||||
|
||||
if (attributInt.isPflichtfeld()) {
|
||||
label.setText(label.getText().substring(0, label.getText().length()-2) + "*: ");
|
||||
}
|
||||
if (attributInt.isAenderbar() != null && !attributInt.isAenderbar()) {
|
||||
textField.setEditable(false);
|
||||
}
|
||||
if (infoBoxFromItem.get(newSelection) != null
|
||||
&& infoBoxFromItem.get(newSelection).get(attributInt) != null
|
||||
&& !infoBoxFromItem.get(newSelection).get(attributInt).isEmpty()){
|
||||
textField.setText(infoBoxFromItem.get(newSelection).get(attributInt));
|
||||
} else if (attributInt.getValue() != null && !attributInt.getValue().equals(-1)) {
|
||||
textField.setText(attributInt.getValue().toString());
|
||||
} else if (attributInt.getDefault() != null) {
|
||||
textField.setText(attributInt.getDefault().toString());
|
||||
}
|
||||
textField.setPromptText("Ganzzahl eingeben");
|
||||
}
|
||||
|
||||
if (attributBoolean != null && attributBoolean.isValue() != null) {
|
||||
checkBox.setSelected(attributBoolean.isValue());
|
||||
}else if(attributBoolean != null && attributBoolean.isDefault() != null) {
|
||||
checkBox.setSelected(attributBoolean.isDefault());
|
||||
}
|
||||
|
||||
if (attributBoolean != null && attributBoolean.isAenderbar() != null && !attributBoolean.isAenderbar()) {
|
||||
checkBox.setDisable(true);
|
||||
}
|
||||
if (attributBoolean != null && attributBoolean.isPflichtfeld()) {
|
||||
label.setText(label.getText().substring(0, label.getText().length()-2) + "*: ");
|
||||
}
|
||||
|
||||
int finalJ = j;
|
||||
checkBox.selectedProperty().addListener((obsVal, oldVal, newVal) -> {
|
||||
if (attributBoolean != null) {
|
||||
infoBoxFromItem.computeIfAbsent(newSelection,
|
||||
k -> new HashMap<>()).put(attributBoolean, checkBox.isSelected() ? "true" : "false");
|
||||
attributBoolean.setValue(checkBox.isSelected());
|
||||
((ProduktbausteinType)newSelection.getValue().getProdukt()).getAttribute().set(finalJ, attributBoolean);
|
||||
}
|
||||
});
|
||||
textField.focusedProperty().addListener((observableValue, oldVal, newVal) -> {
|
||||
if (!newVal) {
|
||||
PauseTransition pause = new PauseTransition(Duration.seconds(3));
|
||||
pause.setOnFinished(ep -> {
|
||||
textField.setStyle("-fx-border-color: #bfbfbf");
|
||||
});
|
||||
if (attributDezimal != null){
|
||||
infoBoxFromItem.computeIfAbsent(newSelection,
|
||||
k -> new HashMap<>()).put(attributDezimal, textField.getText());
|
||||
|
||||
String eingabe = textField.getText().replace(",",".");
|
||||
if (textField.getText().isEmpty()){
|
||||
if (attributDezimal.isPflichtfeld()){
|
||||
|
||||
Label failedCheck = new Label("Es muss ein Wert mitgegeben werden");
|
||||
failedCheck.setVisible(true);
|
||||
failedCheck.setTextFill(Paint.valueOf("#DD0000"));
|
||||
|
||||
textField.setStyle("-fx-border-color: #dd0000");
|
||||
|
||||
pause.play();
|
||||
|
||||
if (singleAttributBox.getChildren().size() > 2) singleAttributBox.getChildren().removeLast();
|
||||
singleAttributBox.getChildren().addLast(failedCheck);
|
||||
}
|
||||
} else if(!textField.getText().matches("^-?[0-9]+[,.]?[0-9]*")){
|
||||
Label failedCheck = new Label("Der Wert muss einer Dezimal Zahl entsprechen ");
|
||||
failedCheck.setVisible(true);
|
||||
failedCheck.setTextFill(Paint.valueOf("#DD0000"));
|
||||
|
||||
textField.setStyle("-fx-border-color: #dd0000");
|
||||
pause.play();
|
||||
|
||||
if (singleAttributBox.getChildren().size() > 2) singleAttributBox.getChildren().removeLast();
|
||||
singleAttributBox.getChildren().addLast(failedCheck);
|
||||
} else if (new BigDecimal(eingabe).compareTo(attributDezimal.getMin()) < 0 ||
|
||||
new BigDecimal(eingabe).compareTo(attributDezimal.getMax()) > 0) {
|
||||
Label failedCheck = new Label("Der Wert muss zwischen "
|
||||
+ attributDezimal.getMin() + " und " + attributDezimal.getMax() + " liegen");
|
||||
failedCheck.setVisible(true);
|
||||
failedCheck.setTextFill(Paint.valueOf("#DD0000"));
|
||||
|
||||
textField.setStyle("-fx-border-color: #dd0000");
|
||||
pause.play();
|
||||
|
||||
if (singleAttributBox.getChildren().size() > 2) singleAttributBox.getChildren().removeLast();
|
||||
singleAttributBox.getChildren().addLast(failedCheck);
|
||||
}else {
|
||||
if (singleAttributBox.getChildren().size() > 2) singleAttributBox.getChildren().removeLast();
|
||||
attributDezimal.setValue(new BigDecimal(eingabe));
|
||||
((ProduktbausteinType)newSelection.getValue().getProdukt()).getAttribute().set(finalJ, attributDezimal);
|
||||
}
|
||||
} else if (attributInt != null) {
|
||||
infoBoxFromItem.computeIfAbsent(newSelection,
|
||||
k -> new HashMap<>()).put(attributInt, textField.getText());
|
||||
|
||||
if (textField.getText() == null || textField.getText().isEmpty()
|
||||
|| !textField.getText().matches("^-?[0-9]*")) {
|
||||
Label failedCheck = new Label("Es muss ein ganzzahliger Wert eingegeben werden");
|
||||
failedCheck.setVisible(true);
|
||||
failedCheck.setTextFill(Paint.valueOf("#DD0000"));
|
||||
|
||||
textField.setStyle("-fx-border-color: #dd0000");
|
||||
pause.play();
|
||||
|
||||
if (singleAttributBox.getChildren().size() > 2) singleAttributBox.getChildren().removeLast();
|
||||
singleAttributBox.getChildren().addLast(failedCheck);
|
||||
}else if (Integer.parseInt(textField.getText()) < attributInt.getMin()
|
||||
|| Integer.parseInt(textField.getText()) > attributInt.getMax()) {
|
||||
Label failedCheck = new Label("Der Wert muss zwischen " + attributInt.getMin()
|
||||
+ " und " + attributInt.getMax() + " liegen");
|
||||
failedCheck.setVisible(true);
|
||||
failedCheck.setTextFill(Paint.valueOf("#DD0000"));
|
||||
|
||||
textField.setStyle("-fx-border-color: #dd0000");
|
||||
pause.play();
|
||||
|
||||
if (singleAttributBox.getChildren().size() > 2) singleAttributBox.getChildren().removeLast();
|
||||
singleAttributBox.getChildren().addLast(failedCheck);
|
||||
}else {
|
||||
if (singleAttributBox.getChildren().size() > 2) singleAttributBox.getChildren().removeLast();
|
||||
attributInt.setValue(Integer.parseInt(textField.getText()));
|
||||
((ProduktbausteinType)newSelection.getValue().getProdukt()).getAttribute().set(finalJ, attributInt);
|
||||
}
|
||||
} else if (stringAttribut != null) {
|
||||
infoBoxFromItem.computeIfAbsent(newSelection,
|
||||
k -> new HashMap<>()).put(stringAttribut, textField.getText());
|
||||
|
||||
if (textField.getText() == null ||
|
||||
(stringAttribut.getMinLaenge() != null
|
||||
&& textField.getText().length() < stringAttribut.getMinLaenge()) ||
|
||||
(stringAttribut.getMaxLaenge() != null
|
||||
&& textField.getText().length() > stringAttribut.getMaxLaenge()) ||
|
||||
(stringAttribut.getRegex() != null
|
||||
&& !textField.getText().matches(stringAttribut.getRegex()))) {
|
||||
Label failedCheck = new Label("Der Wert muss zwischen " +
|
||||
stringAttribut.getMinLaenge() + " und " + stringAttribut.getMaxLaenge() +
|
||||
(stringAttribut.getRegex() != null ? " Buchstaben haben und der Form " +
|
||||
stringAttribut.getRegex() + " entsprechen" : "Buchstaben haben"));
|
||||
failedCheck.setVisible(true);
|
||||
failedCheck.setTextFill(Paint.valueOf("#DD0000"));
|
||||
|
||||
textField.setStyle("-fx-border-color: #dd0000");
|
||||
pause.play();
|
||||
|
||||
if (singleAttributBox.getChildren().size() > 2) singleAttributBox.getChildren().removeLast();
|
||||
((ProduktbausteinType)newSelection.getValue().getProdukt()).getAttribute().set(finalJ, attributInt);
|
||||
|
||||
}else {
|
||||
if (singleAttributBox.getChildren().size() > 2) singleAttributBox.getChildren().removeLast();
|
||||
stringAttribut.setValue(textField.getText());
|
||||
((ProduktbausteinType)newSelection.getValue().getProdukt()).getAttribute().set(finalJ, stringAttribut);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
if (attributBoolean != null) {
|
||||
singleAttributBox.getChildren().addAll(label, checkBox);
|
||||
}else {
|
||||
textField.setId("textField");
|
||||
singleAttributBox.getChildren().addAll(label, textField);
|
||||
}
|
||||
|
||||
singleAttributBox.setId("singleAttributBox");
|
||||
|
||||
attributBox.getChildren().add(singleAttributBox);
|
||||
}
|
||||
|
||||
if (((ProduktbausteinType) newSelection.getValue().getProdukt()).isRisikoobjektErforderlich()) {
|
||||
|
||||
VBox risikoobjektAuswahlBox = new VBox();
|
||||
Label vpRo = new Label("Mit dem Baustein assoziierte Risikoobjekte: ");
|
||||
|
||||
for (int i = 0; i < risikoobjekte.size(); i++) {
|
||||
CheckBox checkBox = new CheckBox();
|
||||
checkBox.setText(risikoobjekte.get(i).toString());
|
||||
|
||||
if (risikoobjekte.get(i) instanceof FahrzeugType) {
|
||||
checkBox.setText(((FahrzeugType) risikoobjekte.get(i)).getHandelsbez() + " ("
|
||||
+ ((FahrzeugType) risikoobjekte.get(i)).getBaujahr() + ")");
|
||||
|
||||
int finalI = i;
|
||||
|
||||
if (((ProduktbausteinType) newSelection.getValue().getProdukt()).getVersicherteObjekte()
|
||||
.stream().anyMatch(v -> ((FahrzeugType) v).getHandelsbez()
|
||||
.equals(((FahrzeugType) risikoobjekte.get(finalI)).getHandelsbez()))) {
|
||||
checkBox.setSelected(true);
|
||||
}
|
||||
|
||||
checkBox.selectedProperty().addListener((observableValue, oldValue, newValue) -> {
|
||||
if (newValue) {
|
||||
((ProduktbausteinType) newSelection.getValue().getProdukt()).getVersicherteObjekte().add(risikoobjekte.get(finalI));
|
||||
} else {
|
||||
((ProduktbausteinType) newSelection.getValue().getProdukt()).getVersicherteObjekte().remove(finalI);
|
||||
}
|
||||
});
|
||||
}
|
||||
risikoobjektAuswahlBox.getChildren().add(checkBox);
|
||||
}
|
||||
|
||||
risikoobjektAuswahlBox.getChildren().addFirst(vpRo);
|
||||
risikoobjektAuswahlBox.setPadding(new Insets(10));
|
||||
risikoobjektAuswahlBox.setId("risikoobjektAuswahlBox");
|
||||
|
||||
attributBox.getChildren().removeIf(c -> c.getId() != null && c.getId().equals("risikoobjektAuswahlBox"));
|
||||
attributBox.getChildren().add(risikoobjektAuswahlBox);
|
||||
}
|
||||
|
||||
return addFaultsInfo((ProduktbausteinType) newSelection.getValue().getProdukt(), attributBox);
|
||||
}
|
||||
|
||||
public VBox addFaultsInfo(ProduktbausteinType produktbaustein, VBox attributBox) {
|
||||
if (produktbaustein.getMeldungen() != null && !produktbaustein.getMeldungen().isEmpty()) {
|
||||
attributBox.getChildren().removeIf(n -> n.getId() != null && n.getId().equals("faultsbox"));
|
||||
VBox faultsBox = new VBox();
|
||||
faultsBox.setId("faultsbox");
|
||||
|
||||
for (ServiceFault sf : produktbaustein.getMeldungen()) {
|
||||
HBox singleFaultBox = new HBox();
|
||||
|
||||
Text symbole = new Text("\u26A0 ");
|
||||
symbole.setFont(Font.font("System", FontWeight.BOLD, symbole.getFont().getSize() + 2));
|
||||
|
||||
if (sf.getErrorType().equals(BigInteger.ONE)) {
|
||||
symbole.setFill(Paint.valueOf("#aa3333"));
|
||||
} else if (sf.getErrorType().equals(BigInteger.TWO)) {
|
||||
symbole.setFill(Paint.valueOf("#ccbb00"));
|
||||
}
|
||||
Label errorText = new Label(sf.getErrorMsg() + System.lineSeparator());
|
||||
errorText.setId("errorText");
|
||||
|
||||
singleFaultBox.getChildren().addAll(symbole, errorText);
|
||||
singleFaultBox.setId("singleFaultBox");
|
||||
faultsBox.getChildren().add(singleFaultBox);
|
||||
}
|
||||
|
||||
if (!faultsBox.getChildren().isEmpty()) {
|
||||
if (produktbaustein.getAttribute().isEmpty()) {
|
||||
attributBox.getChildren().addAll(faultsBox);
|
||||
}else {
|
||||
List<Node> singleAttributBoxes = attributBox.getChildren().stream().filter(n -> n.getId() != null && n.getId().equals("singleAttributBox")).toList();
|
||||
Optional<Node> textField;
|
||||
Optional<Node> label;
|
||||
for (Node singleAttributBox : singleAttributBoxes) {
|
||||
textField = ((VBox)singleAttributBox).getChildren().stream().filter(n -> n.getId() != null && n.getId().equals("textField")).findFirst();
|
||||
label = ((VBox)singleAttributBox).getChildren().stream().filter(n -> n.getId() != null && n.getId().equals("label")).findFirst();
|
||||
List<Node> singleFaultBoxes = faultsBox.getChildren().stream().filter(n -> n.getId() != null && n.getId().equals("singleFaultBox")).toList();
|
||||
|
||||
if (textField.isPresent() && label.isPresent()) {
|
||||
|
||||
for (Node singleFaultBox : singleFaultBoxes) {
|
||||
Optional<Node> errorText = ((HBox)singleFaultBox).getChildren().stream().filter(c -> c.getId() != null && c.getId().equals("errorText")).findFirst();
|
||||
|
||||
if (errorText.isPresent() && ((Label)errorText.get()).getText().contains(((Label)label.get()).getText().replace(":","").replace("*",""))) {
|
||||
textField.get().setStyle("-fx-border-color: #dd0000");
|
||||
((VBox)singleAttributBox).getChildren().addLast(faultsBox);
|
||||
Optional<Node> finalTextField = textField;
|
||||
textField.get().focusedProperty().addListener(s -> finalTextField.get().setStyle(null));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return attributBox;
|
||||
}
|
||||
|
||||
public VBox addVpInfo(VBox attributBox, boolean meldungVorhanden, VerkaufsproduktType vp) {
|
||||
attributBox.getChildren().removeIf(c -> c.getId() != null && c.getId().equals("vpLabel"));
|
||||
|
||||
Label vpLabel = new Label();
|
||||
if (!meldungVorhanden) {
|
||||
vpLabel.setText("Gültiges Verkaufsprodukt " + System.lineSeparator());
|
||||
}else {
|
||||
vpLabel.setText("Kein Gültiges Verkaufsprodukt " + System.lineSeparator());
|
||||
}
|
||||
vpLabel.setPadding(new Insets(10));
|
||||
attributBox.getChildren().addFirst(vpLabel);
|
||||
|
||||
|
||||
// VBox vpMeldungenTexts = new VBox();
|
||||
// vp.getMeldungen().forEach( m -> {
|
||||
// Label vpMeldungText = new Label(m.getErrorMsg() + System.lineSeparator());
|
||||
// vpMeldungText.setPadding(new Insets(10));
|
||||
//
|
||||
// vpMeldungenTexts.getChildren().add(vpMeldungText);
|
||||
// });
|
||||
|
||||
attributBox.getChildren().removeIf(c -> c.getId() != null && c.getId().equals("vpMeldungenTexts"));
|
||||
// attributBox.getChildren().addAll(vpMeldungenTexts);
|
||||
|
||||
return attributBox;
|
||||
}
|
||||
|
||||
}
|
||||
711
client-app/src/main/java/at/vvo/omds/client/gui/MainView.java
Normal file
711
client-app/src/main/java/at/vvo/omds/client/gui/MainView.java
Normal file
@@ -0,0 +1,711 @@
|
||||
package at.vvo.omds.client.gui;
|
||||
|
||||
import at.vvo.omds.client.gui.api.apriori.AprioriAuskunftService;
|
||||
import at.vvo.omds.client.gui.api.calc.CalculateRequestAuskunftService;
|
||||
import at.vvo.omds.client.gui.api.SOAPConnector;
|
||||
import at.vvo.omds.helpers.*;
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.*;
|
||||
import at.vvo.omds.types.omds3.r2025_05.on2antrag.common.*;
|
||||
import com.sun.xml.messaging.saaj.SOAPExceptionImpl;
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.paint.Paint;
|
||||
import javafx.scene.text.*;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Pair;
|
||||
import org.controlsfx.control.ToggleSwitch;
|
||||
import org.eclipse.rdf4j.model.Model;
|
||||
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.math.BigInteger;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class MainView extends Application {
|
||||
|
||||
Map<String, Integer> timesItemisIncludedById = new HashMap<>();
|
||||
Map<TreeItem<GuiProdukt>, Map<AttributType, String>> infoBoxFromItem = new HashMap<>();
|
||||
List<Plausi> plausiList = new ArrayList<>();
|
||||
|
||||
RisikoobjektView risikoobjektView = new RisikoobjektView();
|
||||
TreeHelper treeHelper = new TreeHelper();
|
||||
RDFHelper rdfHelper = new RDFHelper();
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) {
|
||||
|
||||
stage.setTitle("OMDS Client");
|
||||
stage.getIcons().add(new Image(MainView.class.getResourceAsStream("/logo/VVO_Logo_2024.png")));
|
||||
|
||||
TabPane tabPane = new TabPane();
|
||||
Tab baumView = new Tab("Deckungsbaum");
|
||||
Tab risikoView = new Tab("Risikoobjekte");
|
||||
|
||||
baumView.setClosable(false);
|
||||
risikoView.setClosable(false);
|
||||
|
||||
tabPane.getTabs().addAll(baumView, risikoView);
|
||||
|
||||
BorderPane content = new BorderPane();
|
||||
StackPane view = new StackPane();
|
||||
GridPane risikoobjekt = risikoobjektView.risikoobjekte();
|
||||
VBox deckungsbaum = deckungsbaum();
|
||||
|
||||
content.setTop(tabPane);
|
||||
content.setCenter(view);
|
||||
|
||||
view.getChildren().addAll(risikoobjekt ,deckungsbaum);
|
||||
risikoobjekt.setVisible(false);
|
||||
|
||||
|
||||
tabPane.getSelectionModel().selectedItemProperty().addListener((obs, oldTab, newTab) -> {
|
||||
if (newTab == risikoView) {
|
||||
risikoobjekt.setVisible(true);
|
||||
deckungsbaum.setVisible(false);
|
||||
} else if (newTab == baumView) {
|
||||
risikoobjekt.setVisible(false);
|
||||
deckungsbaum.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
Scene scene = new Scene(content, 900, 600);
|
||||
stage.setScene(scene);
|
||||
|
||||
stage.show();
|
||||
}
|
||||
|
||||
public VBox deckungsbaum(){
|
||||
AprioriAuskunftService s = new AprioriAuskunftService(new SOAPConnector());
|
||||
|
||||
final VBox[] controlBox = {new VBox()};
|
||||
DatePicker dp = new DatePicker();
|
||||
ChoiceBox<String> vpBox = new ChoiceBox<>();
|
||||
|
||||
vpBox.setValue("Verkaufsprodukt auswählen ");
|
||||
vpBox.setVisible(false);
|
||||
vpBox.setPadding(new Insets(0, 10, 0, 0));
|
||||
|
||||
AtomicReference<XMLGregorianCalendar> stichtag = new AtomicReference<>();
|
||||
AtomicReference<ProductsResponse> response = new AtomicReference<>();
|
||||
Button newCalcRequestButton = new Button("Calculate");
|
||||
HBox newCalcRequestControlBox = new HBox();
|
||||
newCalcRequestControlBox.setVisible(false);
|
||||
newCalcRequestControlBox.setPadding(new Insets(10, 10, 10, 10));
|
||||
newCalcRequestControlBox.getChildren().add(newCalcRequestButton);
|
||||
|
||||
HBox servBox = new HBox();
|
||||
ToggleSwitch serverBtn = new ToggleSwitch("Benutze RDF Messaging");
|
||||
serverBtn.setSelected(true);
|
||||
serverBtn.setDisable(true);
|
||||
|
||||
AtomicReference<List<APrioriVerkaufsproduktType>> responseproduct = new AtomicReference<>(new ArrayList<>());
|
||||
|
||||
dp.setOnAction(e -> {
|
||||
try {
|
||||
stichtag.set(stichtagEvent(dp));
|
||||
if (stichtagEvent(dp) != null) {
|
||||
try {
|
||||
Pair<List<APrioriVerkaufsproduktType>, List<Plausi>> aprioriPair = s.aprioriRDFAuskunft(stichtag.get(), "042");
|
||||
responseproduct.set(aprioriPair.getKey());
|
||||
plausiList = aprioriPair.getValue();
|
||||
|
||||
newCalcRequestControlBox.setVisible(true);
|
||||
|
||||
if (responseproduct.get().size() > 1) {
|
||||
if (!vpBox.getItems().isEmpty()) {
|
||||
vpBox.getItems().clear();
|
||||
}
|
||||
for (APrioriVerkaufsproduktType vp : responseproduct.get()) {
|
||||
vpBox.getItems().add(vp.getName());
|
||||
}
|
||||
vpBox.setVisible(true);
|
||||
vpBox.setOnAction(ee -> {
|
||||
for (int i = 0; i < responseproduct.get().size(); i++) {
|
||||
if (vpBox.getSelectionModel().getSelectedItem() != null && vpBox.getSelectionModel()
|
||||
.getSelectedItem().equals(responseproduct.get().get(i).getName())) {
|
||||
try {
|
||||
controlBox[0] = buttonAuskunft(responseproduct.get().get(i),
|
||||
controlBox[0], newCalcRequestButton, stichtag, serverBtn);
|
||||
controlBox[0].getChildren().add(newCalcRequestControlBox);
|
||||
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
controlBox[0] = buttonAuskunft(responseproduct.get().getFirst(),
|
||||
controlBox[0], newCalcRequestButton, stichtag, serverBtn);
|
||||
}
|
||||
} catch (Exception rdfex) {
|
||||
serverBtn.setSelected(false);
|
||||
|
||||
try {
|
||||
response.set(s.aprioriAuskunft(stichtag.get(), "042"));
|
||||
|
||||
newCalcRequestControlBox.setVisible(true);
|
||||
if (response.get() != null && response.get().getVerkaufsprodukt().size() > 1) {
|
||||
|
||||
if (!vpBox.getItems().isEmpty()) {
|
||||
vpBox.getItems().clear();
|
||||
}
|
||||
for (APrioriVerkaufsproduktType vp : response.get().getVerkaufsprodukt()) {
|
||||
vpBox.getItems().add(vp.getName());
|
||||
}
|
||||
vpBox.setVisible(true);
|
||||
vpBox.setOnAction(ee -> {
|
||||
for (int i = 0; i < response.get().getVerkaufsprodukt().size(); i++) {
|
||||
if (vpBox.getSelectionModel().getSelectedItem() != null && vpBox.getSelectionModel()
|
||||
.getSelectedItem().equals(response.get().getVerkaufsprodukt().get(i).getName())) {
|
||||
try {
|
||||
controlBox[0] = buttonAuskunft(response.get().getVerkaufsprodukt().get(i),
|
||||
controlBox[0], newCalcRequestButton, stichtag, serverBtn);
|
||||
controlBox[0].getChildren().add(newCalcRequestControlBox);
|
||||
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
controlBox[0] = buttonAuskunft(response.get().getVerkaufsprodukt().getFirst(),
|
||||
controlBox[0], newCalcRequestButton, stichtag, serverBtn);
|
||||
}
|
||||
} catch (NoSuchElementException ex) {
|
||||
controlBox[0].getChildren().clear();
|
||||
controlBox[0].getChildren().add(dp);
|
||||
vpBox.getItems().clear();
|
||||
|
||||
Label label = new Label("Kein Verkaufsoffenes Produkt an dem Datum: " +
|
||||
stichtag.get().toString().substring(0, stichtag.get().toString().length() - 1) +
|
||||
System.lineSeparator());
|
||||
controlBox[0].getChildren().add(3, label);
|
||||
throw new NoSuchElementException(ex.getMessage());
|
||||
} catch (SOAPExceptionImpl ex) {
|
||||
HBox errorBox = new HBox();
|
||||
errorBox.setAlignment(Pos.CENTER);
|
||||
errorBox.setPadding(new Insets(10, 10, 10, 10));
|
||||
errorBox.getChildren().add(new Text("Keine Verbindung zu einer Rdf oder SOAP Schnittstelle möglich!"));
|
||||
|
||||
controlBox[0].getChildren().add(errorBox);
|
||||
}
|
||||
}
|
||||
|
||||
if (!controlBox[0].getChildren().contains(newCalcRequestControlBox)) {
|
||||
controlBox[0].getChildren().add(newCalcRequestControlBox);
|
||||
}
|
||||
} else {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("Error");
|
||||
alert.setHeaderText("Invalid Date");
|
||||
alert.showAndWait();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
dp.setValue(LocalDate.now());
|
||||
|
||||
Platform.runLater(() -> {
|
||||
dp.getOnAction().handle(new ActionEvent(dp, null));
|
||||
});
|
||||
|
||||
VBox.setVgrow(newCalcRequestControlBox, Priority.ALWAYS);
|
||||
newCalcRequestControlBox.setAlignment(Pos.BOTTOM_RIGHT);
|
||||
newCalcRequestControlBox.setId("newCalcRequestControlBox");
|
||||
|
||||
servBox.getChildren().add(serverBtn);
|
||||
servBox.setAlignment(Pos.TOP_RIGHT);
|
||||
|
||||
HBox aprioriControlBox = new HBox();
|
||||
Region region = new Region();
|
||||
HBox.setHgrow(region, Priority.ALWAYS);
|
||||
aprioriControlBox.setPadding(new Insets(10, 10, 0, 10));
|
||||
aprioriControlBox.getChildren().addAll(dp, vpBox, region, servBox);
|
||||
|
||||
controlBox[0].getChildren().addAll(aprioriControlBox);
|
||||
|
||||
return controlBox[0];
|
||||
}
|
||||
|
||||
public XMLGregorianCalendar stichtagEvent(DatePicker dp) throws DatatypeConfigurationException {
|
||||
if (dp.getValue() == null) {
|
||||
return null;
|
||||
}
|
||||
int day = dp.getValue().getDayOfMonth();
|
||||
int month = dp.getValue().getMonthValue();
|
||||
int year = dp.getValue().getYear();
|
||||
|
||||
return DatatypeFactory.newInstance().newXMLGregorianCalendarDate(year, month, day, 0);
|
||||
}
|
||||
|
||||
public VBox buttonAuskunft(APrioriVerkaufsproduktType verkaufsprodukt, VBox vbox, Button newCalcRequest,
|
||||
AtomicReference<XMLGregorianCalendar> stichtag, ToggleSwitch serverBtn) throws Exception {
|
||||
while (vbox.getChildren().size() > 1) {
|
||||
vbox.getChildren().removeLast();
|
||||
}
|
||||
|
||||
VBox treeBox = new VBox();
|
||||
VBox infoBox = new VBox();
|
||||
|
||||
TreeItem<GuiProdukt> vkp = treeHelper.aprioriItemToCalcItem(new TreeItem<>(new GuiProdukt(verkaufsprodukt)));
|
||||
vkp.setExpanded(true);
|
||||
|
||||
treeHelper.aprioriProduktToTree(verkaufsprodukt, vkp);
|
||||
|
||||
TreeView<GuiProdukt> tv = new TreeView<>(vkp);
|
||||
|
||||
|
||||
tv.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> {
|
||||
if (newSelection != null) {
|
||||
if (!infoBox.getChildren().isEmpty()) {
|
||||
infoBox.getChildren().removeAll(infoBox.getChildren());
|
||||
}
|
||||
|
||||
if (isMeldungVorhanden((ProduktbausteinType) newSelection.getValue().getProdukt(), tv)){
|
||||
((ProduktbausteinType) newSelection.getValue().getProdukt()).getAttribute().removeIf(a -> a.getBezeichnung().equals("Praemie"));
|
||||
}
|
||||
ItemAttribute itemAttribute = new ItemAttribute();
|
||||
itemAttribute.setRisikoobjekte(risikoobjektView.getRisikoobjekte());
|
||||
if (!infoBoxFromItem.isEmpty()) itemAttribute.setInfoBoxFromItem(infoBoxFromItem);
|
||||
|
||||
itemAttribute.addItemInfo(newSelection, infoBox);
|
||||
if (newSelection.getValue().getProdukt() instanceof VerkaufsproduktType){
|
||||
itemAttribute.addVpInfo(infoBox, isMeldungVorhanden((ProduktbausteinType) newSelection.getValue().getProdukt(), tv), (VerkaufsproduktType) newSelection.getValue().getProdukt());
|
||||
}
|
||||
infoBoxFromItem = itemAttribute.getInfoBoxFromItem();
|
||||
}else{
|
||||
infoBox.getChildren().removeAll(infoBox.getChildren());
|
||||
}
|
||||
});
|
||||
|
||||
final TreeItem<GuiProdukt> originalRoot = treeHelper.cloneTreeItem(tv.getRoot());
|
||||
tv.setCellFactory(tc -> new TreeCell<>() {
|
||||
@Override
|
||||
public void updateItem(GuiProdukt item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item == null || empty) {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
setStyle("");
|
||||
} else {
|
||||
HBox cellBox = new HBox();
|
||||
Button include = new Button("+");
|
||||
include.setStyle("-fx-margin: 5;");
|
||||
Label label = new Label(((ProduktbausteinType) item.getProdukt()).getBezeichnung() + " ");
|
||||
Button remove = new Button("-");
|
||||
|
||||
remove.setVisible(true);
|
||||
remove.setFont(Font.font("System", FontWeight.BOLD, include.getFont().getSize() + 2));
|
||||
remove.setPadding(new Insets(0, 5, 0, 5));
|
||||
|
||||
include.setFont(Font.font("System", FontWeight.BOLD, include.getFont().getSize() + 2));
|
||||
include.setPadding(new Insets(0, 5, 0, 5));
|
||||
|
||||
if (!shouldBeIncluded(getTreeItem())) {
|
||||
label.setFont(Font.font("System", FontPosture.ITALIC, label.getFont().getSize()));
|
||||
label.setTextFill(Paint.valueOf("#A0A0A0"));
|
||||
if (!(getTreeItem().getValue().isNotIncluded())) {
|
||||
getTreeItem().getValue().setNotIncluded(true);
|
||||
}
|
||||
remove.setDisable(true);
|
||||
remove.setStyle("-fx-background-color: #CCCCCC");
|
||||
} else {
|
||||
label.setTextFill(Paint.valueOf("#000000"));
|
||||
remove.setVisible(true);
|
||||
|
||||
getTreeItem().getValue().setNotIncluded(false);
|
||||
}
|
||||
|
||||
Region spacer = new Region();
|
||||
HBox.setHgrow(spacer, Priority.ALWAYS);
|
||||
Label spacer2 = new Label(" ");
|
||||
|
||||
label.setMaxWidth(Double.MAX_VALUE);
|
||||
|
||||
if (getTreeItem().getValue().getProdukt() instanceof VerkaufsproduktType ||
|
||||
getTreeItem().getValue().getClass().equals(APrioriVerkaufsproduktType.class)) {
|
||||
cellBox.getChildren().addAll(label);
|
||||
} else if (timesItemisIncludedById.get(
|
||||
((ProduktbausteinType) getTreeItem().getValue().getProdukt()).getId()) != null
|
||||
&& ((ProduktbausteinType) getTreeItem().getValue().getProdukt()).getMaxVorkommen() != null
|
||||
&& ((ProduktbausteinType) getTreeItem().getValue().getProdukt()).getMaxVorkommen() <=
|
||||
timeItemIsIncludedByParent(getTreeItem().getParent(),
|
||||
((ProduktbausteinType) getTreeItem().getValue().getProdukt()).getId())) {
|
||||
include.setDisable(true);
|
||||
include.setStyle("-fx-background-color: #CCCCCC");
|
||||
cellBox.getChildren().addAll(label, spacer, include, spacer2, remove);
|
||||
} else {
|
||||
cellBox.getChildren().addAll(label, spacer, include, spacer2, remove);
|
||||
}
|
||||
|
||||
include.setOnAction(e -> {
|
||||
if (getTreeItem().getValue().isNotIncluded()) {
|
||||
label.setFont(Font.font("System", label.getFont().getSize()));
|
||||
label.setTextFill(Paint.valueOf("#000000"));
|
||||
remove.setVisible(true);
|
||||
|
||||
timesItemisIncludedById.put(((ProduktbausteinType) getTreeItem().getValue().getProdukt()).getId(),
|
||||
(timesItemisIncludedById.get(
|
||||
((ProduktbausteinType) getTreeItem().getValue().getProdukt()).getId()) != null ?
|
||||
timesItemisIncludedById.get(
|
||||
((ProduktbausteinType) getTreeItem().getValue().getProdukt()).getId()) + 1 : 1));
|
||||
|
||||
getTreeItem().getValue().setNotIncluded(false);
|
||||
includeAddedParent(getTreeItem());
|
||||
includeAddedChildren(getTreeItem());
|
||||
tv.setRoot(treeHelper.sortTree(tv.getRoot()));
|
||||
tv.refresh();
|
||||
timesItemisIncludedById.clear();
|
||||
refreshTimesItemisIncludedById(tv.getRoot());
|
||||
} else {
|
||||
TreeItem<GuiProdukt> parent = getTreeItem().getParent();
|
||||
TreeItem<GuiProdukt> clone = null;
|
||||
try {
|
||||
clone = treeHelper.cloneTreeItem(
|
||||
treeHelper.findTreeItem((ProduktbausteinType) item.getProdukt(), tv.getRoot()));
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
parent.getChildren().add(clone);
|
||||
|
||||
timesItemisIncludedById.clear();
|
||||
refreshTimesItemisIncludedById(tv.getRoot());
|
||||
|
||||
tv.setRoot(treeHelper.sortTree(tv.getRoot()));
|
||||
tv.refresh();
|
||||
}
|
||||
|
||||
TreeItem<GuiProdukt> newRoot = checkPlausis(plausiList, tv.getRoot(), verkaufsprodukt);
|
||||
if (newRoot != null) {
|
||||
newRoot.setExpanded(true);
|
||||
tv.setRoot(newRoot);
|
||||
tv.refresh();
|
||||
}
|
||||
});
|
||||
|
||||
remove.setOnAction(e -> {
|
||||
Map<String, Integer> countByParent = new HashMap<>();
|
||||
Map<String, Integer> countByAprioriParent = new HashMap<>();
|
||||
timesItemisIncludedById.clear();
|
||||
refreshTimesItemisIncludedById(tv.getRoot());
|
||||
timesItemisIncludedById.replace(((ProduktbausteinType) item.getProdukt()).getId(),
|
||||
timesItemisIncludedById.get(((ProduktbausteinType) item.getProdukt()).getId()) - 1);
|
||||
|
||||
if (countChildIds(countByParent, getTreeItem().getParent()).get
|
||||
(((ProduktbausteinType) item.getProdukt()).getId()).equals(countChildIds(countByAprioriParent,
|
||||
treeHelper.findTreeItem(((ProduktbausteinType) item.getProdukt()), originalRoot).getParent()).get(
|
||||
((ProduktbausteinType) item.getProdukt()).getId()))) {
|
||||
label.setFont(Font.font("System", label.getFont().getSize()));
|
||||
label.setTextFill(Paint.valueOf("#A0A0A0"));
|
||||
remove.setVisible(false);
|
||||
|
||||
getTreeItem().getValue().setNotIncluded(true);
|
||||
includeAddedChildren(getTreeItem());
|
||||
|
||||
tv.setRoot(treeHelper.sortTree(tv.getRoot()));
|
||||
tv.refresh();
|
||||
} else {
|
||||
getTreeItem().getParent().getChildren().remove((getTreeItem()));
|
||||
}
|
||||
|
||||
TreeItem<GuiProdukt> newRoot = checkPlausis(plausiList, tv.getRoot(), verkaufsprodukt);
|
||||
if (newRoot != null) {
|
||||
newRoot.setExpanded(true);
|
||||
|
||||
tv.setRoot(newRoot);
|
||||
tv.refresh();
|
||||
}
|
||||
|
||||
timesItemisIncludedById.clear();
|
||||
refreshTimesItemisIncludedById(tv.getRoot());
|
||||
});
|
||||
|
||||
if(((ProduktbausteinType) item.getProdukt()).getMeldungen() != null && !((ProduktbausteinType) item.getProdukt()).getMeldungen().isEmpty()) {
|
||||
AtomicBoolean symboleAdded = new AtomicBoolean(false);
|
||||
Text symbole = new Text("\u26A0 ");
|
||||
symbole.setFont(Font.font("System", FontWeight.BOLD, symbole.getFont().getSize() + 2));
|
||||
|
||||
|
||||
((ProduktbausteinType) item.getProdukt()).getMeldungen().forEach(m -> {
|
||||
if(m.getErrorType().equals(BigInteger.ONE)) {
|
||||
symbole.setFill(Paint.valueOf("#aa3333"));
|
||||
symboleAdded.set(true);
|
||||
}
|
||||
if (m.getErrorType().equals(BigInteger.TWO) && !symboleAdded.get()) {
|
||||
symbole.setFill(Paint.valueOf("#ccbb00"));
|
||||
}
|
||||
});
|
||||
cellBox.getChildren().addFirst(symbole);
|
||||
}else {
|
||||
if (cellBox.getChildren().getFirst() instanceof Text && ((Text)cellBox.getChildren().getFirst()).getText().equals("\u26A0")) {
|
||||
cellBox.getChildren().removeFirst();
|
||||
}
|
||||
}
|
||||
setGraphic(cellBox);
|
||||
setText(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
newCalcRequest.setOnAction(e -> {
|
||||
try {
|
||||
TreeItem<GuiProdukt> cleanedRoot = treeHelper.cleanTree(tv.getRoot());
|
||||
|
||||
|
||||
CalculateRequestAuskunftService s = new CalculateRequestAuskunftService(new SOAPConnector());
|
||||
TreeItem<GuiProdukt> newRoot = new TreeItem<>(cleanedRoot.getValue());
|
||||
treeHelper.setTimesItemisIncludedById(timesItemisIncludedById);
|
||||
if (serverBtn.isSelected()) {
|
||||
VerkaufsproduktType calcResponse = s.calculateRDFAuskunft(new TreeView<>(cleanedRoot), stichtag.get());
|
||||
newRoot.getValue().setProdukt(calcResponse);
|
||||
treeHelper.produktToTree(calcResponse, newRoot);
|
||||
}else {
|
||||
CalculateResponse calcResponse = s.calculateAuskunft(new TreeView<>(cleanedRoot), stichtag.get());
|
||||
newRoot.getValue().setProdukt(calcResponse.getBerechnungsantwort().getVerkaufsprodukt());
|
||||
treeHelper.produktToTree(calcResponse.getBerechnungsantwort().getVerkaufsprodukt(), newRoot);
|
||||
}
|
||||
|
||||
timesItemisIncludedById = treeHelper.getTimesItemisIncludedById();
|
||||
newRoot.setExpanded(true);
|
||||
|
||||
TreeItem<GuiProdukt> finalRoot = checkPlausis(plausiList, newRoot, verkaufsprodukt);
|
||||
if (finalRoot != null) {
|
||||
finalRoot.setExpanded(true);
|
||||
tv.setRoot(finalRoot);
|
||||
} else {
|
||||
newRoot = treeHelper.addAprioriToCalc(newRoot, originalRoot);
|
||||
newRoot = treeHelper.sortTree(newRoot);
|
||||
tv.setRoot(newRoot);
|
||||
}
|
||||
|
||||
|
||||
|
||||
timesItemisIncludedById.clear();
|
||||
|
||||
refreshTimesItemisIncludedById(tv.getRoot());
|
||||
|
||||
tv.refresh();
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
});
|
||||
|
||||
if (!treeBox.getChildren().isEmpty()) {
|
||||
treeBox.getChildren().clear();
|
||||
}
|
||||
|
||||
tv.setRoot(treeHelper.sortTree(tv.getRoot()));
|
||||
|
||||
VBox.setVgrow(tv, Priority.ALWAYS);
|
||||
tv.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
|
||||
tv.setStyle("-fx-border-color: white;");
|
||||
|
||||
treeBox.getChildren().add(tv);
|
||||
treeBox.setPadding(new Insets(10));
|
||||
treeBox.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
|
||||
HBox.setHgrow(treeBox, Priority.ALWAYS);
|
||||
treeBox.setStyle("-fx-border-color: black; -fx-background-color: white");
|
||||
|
||||
infoBox.setStyle("-fx-border-color: black; -fx-background-color: white");
|
||||
infoBox.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
|
||||
HBox.setHgrow(infoBox, Priority.ALWAYS);
|
||||
|
||||
HBox splitBox = new HBox(treeBox, infoBox);
|
||||
splitBox.setId("splitBox");
|
||||
splitBox.setSpacing(10);
|
||||
splitBox.setPadding(new Insets(20));
|
||||
splitBox.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
|
||||
|
||||
VBox wrapper = new VBox(splitBox);
|
||||
wrapper.setAlignment(Pos.CENTER);
|
||||
VBox.setVgrow(splitBox, Priority.ALWAYS);
|
||||
|
||||
HBox logWrapper = new HBox();
|
||||
logWrapper.setPadding(new Insets(0, 20, 20, 20)); // Abstand zum Rand unten + Seite
|
||||
logWrapper.setAlignment(Pos.CENTER_LEFT);
|
||||
logWrapper.setMaxWidth(Double.MAX_VALUE);
|
||||
|
||||
vbox.getChildren().addAll(wrapper);
|
||||
VBox.setVgrow(wrapper, Priority.ALWAYS);
|
||||
|
||||
return vbox;
|
||||
}
|
||||
|
||||
private void includeAddedParent(TreeItem<GuiProdukt> treeItem) {
|
||||
if (treeItem.getParent() != null) {
|
||||
treeItem.getParent().getValue().setNotIncluded(false);
|
||||
if (treeItem.getParent().getParent() != null) {
|
||||
includeAddedParent(treeItem.getParent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void includeAddedChildren(TreeItem<GuiProdukt> parent) {
|
||||
for (int i = 0; i < parent.getChildren().size(); i++) {
|
||||
parent.getChildren().get(i).getValue().setNotIncluded(false);
|
||||
if (!shouldBeIncluded(parent.getChildren().get(i)) && !(parent.getChildren().get(i).getValue().isNotIncluded())) {
|
||||
parent.getChildren().get(i).getValue().setNotIncluded(true);
|
||||
} else {
|
||||
parent.getChildren().get(i).getValue().setNotIncluded(false);
|
||||
}
|
||||
|
||||
if (!parent.getChildren().get(i).getChildren().isEmpty() && parent.getChildren().get(i).getChildren() != null) {
|
||||
includeAddedChildren(parent.getChildren().get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean shouldBeIncluded(TreeItem<GuiProdukt> treeItem) {
|
||||
return !(((treeItem.getParent() != null && treeItem.getParent().getValue().isNotIncluded()) || treeItem.getValue().isNotIncluded() ||
|
||||
(((ProduktbausteinType) treeItem.getValue().getProdukt()).getMinVorkommen() != null && ((ProduktbausteinType) treeItem.getValue().getProdukt()).getMinVorkommen() == 0 &&
|
||||
(timesItemisIncludedById.get(((ProduktbausteinType) treeItem.getValue().getProdukt()).getId()) == null ||
|
||||
timesItemisIncludedById.get(((ProduktbausteinType) treeItem.getValue().getProdukt()).getId()) == 0))) &&
|
||||
!(treeItem.getValue().getProdukt() instanceof VerkaufsproduktType));
|
||||
}
|
||||
|
||||
private Map<String, Integer> countChildIds(Map<String, Integer> count, TreeItem<GuiProdukt> root) {
|
||||
if (root != null) {
|
||||
for (int i = 0; i < root.getChildren().size(); i++) {
|
||||
TreeItem<GuiProdukt> item = root.getChildren().get(i);
|
||||
|
||||
if (count.get(((ProduktbausteinType) item.getValue().getProdukt()).getId()) == null) {
|
||||
count.put(((ProduktbausteinType) item.getValue().getProdukt()).getId(), 1);
|
||||
} else {
|
||||
count.replace(((ProduktbausteinType) item.getValue().getProdukt()).getId(),
|
||||
count.get(((ProduktbausteinType) item.getValue().getProdukt()).getId()) + 1);
|
||||
}
|
||||
|
||||
if (!item.getChildren().isEmpty()) {
|
||||
countChildIds(count, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
private void refreshTimesItemisIncludedById(TreeItem<GuiProdukt> root) {
|
||||
for (int i = 0; i < root.getChildren().size(); i++) {
|
||||
TreeItem<GuiProdukt> item = root.getChildren().get(i);
|
||||
if (!item.getValue().isNotIncluded()) {
|
||||
if (timesItemisIncludedById.get(((ProduktbausteinType) item.getValue().getProdukt()).getId()) == null) {
|
||||
timesItemisIncludedById.put(((ProduktbausteinType) item.getValue().getProdukt()).getId(), 1);
|
||||
} else {
|
||||
timesItemisIncludedById.replace(((ProduktbausteinType) item.getValue().getProdukt()).getId(),
|
||||
timesItemisIncludedById.get(((ProduktbausteinType) item.getValue().getProdukt()).getId()) + 1);
|
||||
}
|
||||
}
|
||||
if (!item.getChildren().isEmpty()) {
|
||||
refreshTimesItemisIncludedById(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int timeItemIsIncludedByParent(TreeItem<GuiProdukt> parent, String itemId) {
|
||||
int erg = 0;
|
||||
for (int i = 0; i < parent.getChildren().size(); i++) {
|
||||
TreeItem<GuiProdukt> item = parent.getChildren().get(i);
|
||||
if (((ProduktbausteinType) item.getValue().getProdukt()).getId().equals(itemId)) {
|
||||
if (!item.getValue().isNotIncluded()) {
|
||||
erg++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return erg;
|
||||
}
|
||||
public boolean isMeldungVorhanden(ProduktbausteinType produkt, TreeView<GuiProdukt> tv) {
|
||||
TreeHelper treeHelper = new TreeHelper();
|
||||
TreeItem<GuiProdukt> actual = treeHelper.findTreeItem(produkt, tv.getRoot());
|
||||
|
||||
if (actual != null && ((ProduktbausteinType)actual.getValue().getProdukt()).getMeldungen() != null && !((ProduktbausteinType)actual.getValue().getProdukt()).getMeldungen().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
for (ProduktbausteinType child : produkt.getBausteine()){
|
||||
if(isMeldungVorhanden(child, tv)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public TreeItem<GuiProdukt> checkPlausis(List<Plausi> plausiList, TreeItem<GuiProdukt> vp, APrioriProduktbausteinType verkaufsprodukt){
|
||||
Repository repo = new SailRepository(new MemoryStore());
|
||||
repo.init();
|
||||
|
||||
try (RepositoryConnection conn = repo.getConnection()) {
|
||||
Model model = rdfHelper.createRdfModel(vp);
|
||||
|
||||
conn.add(model);
|
||||
|
||||
plausiList.stream().filter(p -> p.getArt().equals("update")).forEach(p -> {
|
||||
String query = p.getQuery();
|
||||
|
||||
conn.prepareUpdate(query).execute();
|
||||
});
|
||||
|
||||
model.clear();
|
||||
conn.getStatements(null, null, null).forEach(model::add);
|
||||
|
||||
plausiList.stream().filter(p -> p.getArt().equals("graph")).forEach(p -> {
|
||||
String sparql = p.getQuery();
|
||||
|
||||
GraphQuery q = conn.prepareGraphQuery(sparql);
|
||||
Model validatedModel = QueryResults.asModel(q.evaluate());
|
||||
|
||||
model.addAll(validatedModel);
|
||||
});
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
Rio.write(model, baos, RDFFormat.JSONLD);
|
||||
|
||||
VerkaufsproduktType neuRoot = rdfHelper.calculateRequestToVerkaufsprodukt(baos.toString());
|
||||
TreeItem<GuiProdukt> newRoot = new TreeItem<>(new GuiProdukt(neuRoot));
|
||||
newRoot.setExpanded(true);
|
||||
|
||||
try {
|
||||
treeHelper.produktToTree(neuRoot, newRoot);
|
||||
|
||||
TreeItem<GuiProdukt> aprioriTree = new TreeItem<>();
|
||||
treeHelper.aprioriProduktToTree(verkaufsprodukt, aprioriTree);
|
||||
|
||||
return (treeHelper.sortTree(treeHelper.addAprioriToCalc(newRoot, aprioriTree)));
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
} catch(Exception ignored) {
|
||||
ignored.printStackTrace();
|
||||
System.out.println("CheckPlausi: " + ignored.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
package at.vvo.omds.client.gui;
|
||||
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.FahrzeugType;
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.VersichertesInteresseMitAttributMetadatenType;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.paint.Paint;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.scene.text.FontWeight;
|
||||
|
||||
import javax.xml.datatype.DatatypeConfigurationException;
|
||||
import javax.xml.datatype.DatatypeFactory;
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RisikoobjektView {
|
||||
List<VersichertesInteresseMitAttributMetadatenType> risikoobjekte = new ArrayList<>();
|
||||
VBox objekteListe = new VBox();
|
||||
ScrollPane objekteScroll = new ScrollPane();
|
||||
GridPane main = new GridPane();
|
||||
|
||||
public List<VersichertesInteresseMitAttributMetadatenType> getRisikoobjekte() {
|
||||
return risikoobjekte;
|
||||
}
|
||||
|
||||
public GridPane risikoobjekte() {
|
||||
VBox createObjekt = createRisikoobjekt();
|
||||
|
||||
objekteListe = risikoobjekteListe();
|
||||
|
||||
objekteScroll.setContent(objekteListe);
|
||||
objekteScroll.setFitToWidth(true);
|
||||
objekteScroll.setFitToHeight(false);
|
||||
objekteScroll.setStyle("-fx-background-color:transparent;");
|
||||
|
||||
main.add(createObjekt, 0, 0);
|
||||
main.add(objekteScroll, 1, 0);
|
||||
|
||||
GridPane.setHgrow(createObjekt, Priority.ALWAYS);
|
||||
GridPane.setVgrow(createObjekt, Priority.ALWAYS);
|
||||
GridPane.setHgrow(objekteScroll, Priority.ALWAYS);
|
||||
GridPane.setVgrow(objekteScroll, Priority.ALWAYS);
|
||||
|
||||
createObjekt.setPadding(new Insets(10, 10, 10, 5));
|
||||
createObjekt.setStyle("-fx-border-color: black; -fx-border-width: 1px;");
|
||||
|
||||
objekteScroll.setPadding(new Insets(10, 10, 10, 5));
|
||||
objekteScroll.setStyle("-fx-border-color: black; -fx-border-width: 1px;");
|
||||
|
||||
main.setAlignment(Pos.CENTER);
|
||||
main.setPadding(new Insets(10));
|
||||
main.setHgap(10);
|
||||
|
||||
return main;
|
||||
}
|
||||
|
||||
private VBox risikoobjekteListe() {
|
||||
VBox objekteListe = new VBox(10); // spacing
|
||||
objekteListe.setFillWidth(true);
|
||||
|
||||
if (risikoobjekte != null && !risikoobjekte.isEmpty()) {
|
||||
for (VersichertesInteresseMitAttributMetadatenType r : risikoobjekte) {
|
||||
|
||||
|
||||
HBox singleRisikoobjekt = new HBox(10);
|
||||
singleRisikoobjekt.setPadding(new Insets(5));
|
||||
singleRisikoobjekt.setAlignment(Pos.CENTER);
|
||||
|
||||
VBox objektInfo = new VBox(2);
|
||||
|
||||
if (r instanceof FahrzeugType fahrzeug) {
|
||||
Label handelsbezeichnung = new Label(fahrzeug.getHandelsbez());
|
||||
handelsbezeichnung.setFont(Font.font("System", FontWeight.BOLD, 14));
|
||||
|
||||
Label baujahr = new Label(fahrzeug.getBaujahr().toString());
|
||||
baujahr.setStyle("-fx-text-fill: #555555");
|
||||
|
||||
Label erstzulassung = new Label(fahrzeug.getErstzulassdat().toString()
|
||||
.substring(0, fahrzeug.getErstzulassdat().toString().length()-1));
|
||||
erstzulassung.setStyle("-fx-text-fill: #555555");
|
||||
|
||||
objektInfo.getChildren().addAll(handelsbezeichnung, baujahr, erstzulassung);
|
||||
|
||||
Pane separator = new Pane();
|
||||
separator.setPrefWidth(2);
|
||||
separator.setMaxWidth(2);
|
||||
separator.setStyle("-fx-background-color: black;");
|
||||
|
||||
Label symbole = new Label("\u26DF");
|
||||
symbole.setFont(Font.font(18));
|
||||
|
||||
VBox symbolBox = new VBox(symbole);
|
||||
|
||||
singleRisikoobjekt.getChildren().addAll(symbolBox, separator, objektInfo);
|
||||
singleRisikoobjekt.setAlignment(Pos.CENTER_LEFT);
|
||||
}
|
||||
|
||||
objekteListe.getChildren().add(singleRisikoobjekt);
|
||||
}
|
||||
}
|
||||
return objekteListe;
|
||||
}
|
||||
|
||||
private VBox createRisikoobjekt() {
|
||||
VBox createForm = new VBox();
|
||||
ChoiceBox<String> choiceBox = new ChoiceBox<>();
|
||||
|
||||
List<String> risikoobjektArten = new ArrayList<>();
|
||||
risikoobjektArten.add("Versichertes objekt SachPrivat");
|
||||
risikoobjektArten.add("Versicherte Liegenschaft");
|
||||
risikoobjektArten.add("Fahrzeug");
|
||||
risikoobjektArten.add("Risiko Gebaeude");
|
||||
risikoobjektArten.add("Versicherte Person");
|
||||
risikoobjektArten.add("Risiko Haushalt");
|
||||
|
||||
choiceBox.getSelectionModel().selectedItemProperty().addListener((obs, oldVal, newVal) -> {
|
||||
if (newVal != null) {
|
||||
int a = createForm.getChildren().size();
|
||||
for (int i = 1; i < a; i++) {
|
||||
createForm.getChildren().remove(i);
|
||||
}
|
||||
switch (newVal) {
|
||||
case "Versichertes objekt SachPrivat": {
|
||||
System.out.println("formular sach Privat");
|
||||
break;
|
||||
}
|
||||
case "Versicherte Liegenschaft": {
|
||||
System.out.println("create Versicherte Liegenschaft");
|
||||
break;
|
||||
}
|
||||
case "Fahrzeug": {
|
||||
FahrzeugType fahrzeug = new FahrzeugType();
|
||||
|
||||
VBox createFormBox = new VBox();
|
||||
|
||||
VBox baujahrBox = new VBox();
|
||||
Label label1 = new Label("Baujahr");
|
||||
TextField textField1 = new TextField();
|
||||
|
||||
textField1.setPromptText("Baujahr");
|
||||
baujahrBox.setPadding(new Insets(5));
|
||||
baujahrBox.getChildren().addAll(label1, textField1);
|
||||
|
||||
textField1.focusedProperty().addListener((observableValue, oldValue, newValue) -> {
|
||||
if (!newValue) {
|
||||
Label failedCheck = new Label("Es muss eine 4 stellige Jahreszahl mitgegeben werden");
|
||||
failedCheck.setId("failedCheck");
|
||||
failedCheck.setTextFill(Paint.valueOf("#DD0000"));
|
||||
if (textField1.getText().length() != 4) {
|
||||
textField1.setStyle("-fx-border-color: #dd0000");
|
||||
baujahrBox.getChildren().addAll(failedCheck);
|
||||
} else {
|
||||
textField1.setStyle("-fx-border-color: #555555");
|
||||
baujahrBox.getChildren().removeIf(c -> c.getId() != null && c.getId().equals("failedCheck"));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
VBox handelsbezeichnungBox = new VBox();
|
||||
Label label2 = new Label("Handelsbezeichnung");
|
||||
TextField textField2 = new TextField();
|
||||
|
||||
textField2.setPromptText("Handelsbezeichnung");
|
||||
handelsbezeichnungBox.setPadding(new Insets(5));
|
||||
handelsbezeichnungBox.getChildren().addAll(label2, textField2);
|
||||
|
||||
VBox erstzulassungBox = new VBox();
|
||||
Label label3 = new Label("Erstzulassung");
|
||||
DatePicker datePicker = new DatePicker(LocalDate.now());
|
||||
|
||||
erstzulassungBox.setPadding(new Insets(5));
|
||||
erstzulassungBox.getChildren().addAll(label3, datePicker);
|
||||
|
||||
Button createBtn = new Button("Create");
|
||||
|
||||
createBtn.setOnAction(e -> {
|
||||
fahrzeug.setBaujahr(Integer.valueOf(textField1.getText()));
|
||||
fahrzeug.setHandelsbez(textField2.getText());
|
||||
try {
|
||||
int day = datePicker.getValue().getDayOfMonth();
|
||||
int month = datePicker.getValue().getMonthValue();
|
||||
int year = datePicker.getValue().getYear();
|
||||
|
||||
XMLGregorianCalendar erstzulassung = DatatypeFactory.newInstance().newXMLGregorianCalendarDate(year, month, day, 0);
|
||||
|
||||
fahrzeug.setErstzulassdat(erstzulassung);
|
||||
} catch (DatatypeConfigurationException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
risikoobjekte.add(fahrzeug);
|
||||
|
||||
objekteListe.getChildren().setAll(risikoobjekteListe().getChildren());
|
||||
|
||||
createFormBox.getChildren().clear();
|
||||
String select = choiceBox.getSelectionModel().getSelectedItem();
|
||||
choiceBox.getSelectionModel().clearSelection();
|
||||
choiceBox.getSelectionModel().select(select);
|
||||
|
||||
});
|
||||
|
||||
createFormBox.getChildren().addAll(baujahrBox, handelsbezeichnungBox, erstzulassungBox, createBtn);
|
||||
createForm.getChildren().add(createFormBox);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
choiceBox.getItems().addAll(risikoobjektArten);
|
||||
|
||||
createForm.getChildren().addAll(choiceBox);
|
||||
return createForm;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
package at.vvo.omds.client.gui.api;
|
||||
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.ProductsRequest;
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.ProductsResponse;
|
||||
import at.vvo.omds.types.omds3.r2025_05.on2antrag.common.CalculateRequest;
|
||||
import at.vvo.omds.types.omds3.r2025_05.on2antrag.common.CalculateResponse;
|
||||
import jakarta.xml.bind.JAXBContext;
|
||||
import jakarta.xml.bind.JAXBElement;
|
||||
import jakarta.xml.bind.Marshaller;
|
||||
import jakarta.xml.bind.Unmarshaller;
|
||||
import jakarta.xml.soap.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileReader;
|
||||
|
||||
public class SOAPConnector {
|
||||
|
||||
static Logger logger = LoggerFactory.getLogger(SOAPConnector.class);
|
||||
|
||||
public CalculateResponse calculateRequestAuskunft(String url, JAXBElement<CalculateRequest> request, String token) throws Exception {
|
||||
|
||||
logger.info("Url:" + url);
|
||||
logger.info("Request VUNr:" + request.getValue().getVUNr());
|
||||
|
||||
SOAPConnectionFactory connectionFactory = SOAPConnectionFactory.newInstance();
|
||||
SOAPConnection soapConnection = connectionFactory.createConnection();
|
||||
|
||||
SOAPMessage req = createCalcRequest(request, token);
|
||||
|
||||
SOAPMessage response = soapConnection.call(req, url);
|
||||
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(at.vvo.omds.types.omds3.r2025_05.on2antrag.common.ObjectFactory.class);
|
||||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();;
|
||||
|
||||
System.out.println("-----------------------------------------------------------------------------");
|
||||
printMessage(response);
|
||||
System.out.println("-----------------------------------------------------------------------------");
|
||||
printMessage(req);
|
||||
|
||||
CalculateResponse erg =
|
||||
(CalculateResponse) unmarshaller.unmarshal(response.getSOAPBody().extractContentAsDocument());
|
||||
soapConnection.close();
|
||||
|
||||
return erg;
|
||||
}
|
||||
|
||||
public ProductsResponse aprioriAuskunft(String url, JAXBElement<ProductsRequest> request, String token) throws Exception {
|
||||
|
||||
logger.info("Url:" + url);
|
||||
logger.info("Request VUNr:" + request.getValue().getVUNr());
|
||||
|
||||
SOAPConnectionFactory connectionFactory = SOAPConnectionFactory.newInstance();
|
||||
SOAPConnection soapConnection = connectionFactory.createConnection();
|
||||
|
||||
SOAPMessage req = createRequest(request, token);
|
||||
|
||||
SOAPMessage response = soapConnection.call(req, url);
|
||||
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(at.vvo.omds.types.omds3.r2025_05.common.ObjectFactory.class, at.vvo.omds.types.omds2.v2_17.ObjectFactory.class, at.vvo.omds.types.omds3.r2025_05.on2antrag.common.ObjectFactory.class);
|
||||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
||||
|
||||
ProductsResponse erg =
|
||||
(ProductsResponse) unmarshaller.unmarshal(response.getSOAPBody().extractContentAsDocument());
|
||||
soapConnection.close();
|
||||
|
||||
return erg;
|
||||
}
|
||||
|
||||
private SOAPMessage createCalcRequest(JAXBElement<CalculateRequest> request, String token) throws Exception {
|
||||
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
|
||||
SOAPMessage soapMessage = messageFactory.createMessage();
|
||||
|
||||
createCalcEnvelope(soapMessage, request, token);
|
||||
|
||||
MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
|
||||
mimeHeaders.addHeader("Content-Type", "application/soap+xml");
|
||||
|
||||
soapMessage.saveChanges();
|
||||
|
||||
return soapMessage;
|
||||
}
|
||||
|
||||
private SOAPMessage createRequest(JAXBElement<ProductsRequest> request, String token) throws Exception {
|
||||
MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
|
||||
SOAPMessage soapMessage = messageFactory.createMessage();
|
||||
|
||||
createEnvelope(soapMessage, request, token);
|
||||
|
||||
MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
|
||||
mimeHeaders.addHeader("Content-Type", "application/soap+xml");
|
||||
|
||||
soapMessage.saveChanges();
|
||||
|
||||
return soapMessage;
|
||||
}
|
||||
|
||||
private void createEnvelope(SOAPMessage soapMessage, JAXBElement<ProductsRequest> request, String token) throws Exception {
|
||||
SOAPPart soapPart = soapMessage.getSOAPPart();
|
||||
|
||||
SOAPEnvelope envelope = soapPart.getEnvelope();
|
||||
SOAPHeader soapHeader = envelope.getHeader();
|
||||
|
||||
Name headerElementName = envelope.createName(
|
||||
"Security",
|
||||
"wsse",
|
||||
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
|
||||
);
|
||||
SOAPHeaderElement soapHeaderElement = soapHeader.addHeaderElement(headerElementName);
|
||||
|
||||
SOAPElement securityContextTokenSOAPElement = soapHeaderElement.addChildElement("SecurityContextToken", "wsc", "http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512");
|
||||
securityContextTokenSOAPElement.addNamespaceDeclaration("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
|
||||
securityContextTokenSOAPElement.addAttribute(new QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", "Id", "wsu"), "authPolicy");
|
||||
SOAPElement identifierSOAPElement = securityContextTokenSOAPElement.addChildElement("Identifier", "wsc");
|
||||
// identifierSOAPElement.addTextNode(getToken(request.getValue().getVUNr()));
|
||||
identifierSOAPElement.addTextNode("eintollertoken");
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance("at.vvo.omds.types.omds3.r2025_05.common");
|
||||
|
||||
SOAPBody body = envelope.getBody();
|
||||
|
||||
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
|
||||
Marshaller marshaller = jaxbContext.createMarshaller();
|
||||
|
||||
marshaller.marshal(request,document);
|
||||
|
||||
body.addDocument(document);
|
||||
|
||||
soapMessage.saveChanges();
|
||||
|
||||
}
|
||||
|
||||
private void createCalcEnvelope(SOAPMessage soapMessage, JAXBElement<CalculateRequest> request, String token) throws Exception {
|
||||
SOAPPart soapPart = soapMessage.getSOAPPart();
|
||||
|
||||
SOAPEnvelope envelope = soapPart.getEnvelope();
|
||||
SOAPHeader soapHeader = envelope.getHeader();
|
||||
|
||||
Name headerElementName = envelope.createName(
|
||||
"Security",
|
||||
"wsse",
|
||||
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
|
||||
);
|
||||
SOAPHeaderElement soapHeaderElement = soapHeader.addHeaderElement(headerElementName);
|
||||
|
||||
SOAPElement securityContextTokenSOAPElement = soapHeaderElement.addChildElement("SecurityContextToken", "wsc", "http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512");
|
||||
securityContextTokenSOAPElement.addNamespaceDeclaration("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
|
||||
securityContextTokenSOAPElement.addAttribute(new QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", "Id", "wsu"), "authPolicy");
|
||||
SOAPElement identifierSOAPElement = securityContextTokenSOAPElement.addChildElement("Identifier", "wsc");
|
||||
// identifierSOAPElement.addTextNode(getToken(request.getValue().getVUNr()));
|
||||
identifierSOAPElement.addTextNode("eintollertoken");
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(at.vvo.omds.types.omds3.r2025_05.on2antrag.common.ObjectFactory.class);
|
||||
|
||||
SOAPBody body = envelope.getBody();
|
||||
|
||||
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
|
||||
Marshaller marshaller = jaxbContext.createMarshaller();
|
||||
|
||||
marshaller.marshal(request,document);
|
||||
|
||||
body.addDocument(document);
|
||||
|
||||
soapMessage.saveChanges();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void printMessage(SOAPMessage soapMessage) throws Exception {
|
||||
TransformerFactory tff = TransformerFactory.newInstance();
|
||||
Transformer tf = tff.newTransformer();
|
||||
|
||||
tf.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
|
||||
|
||||
Source sc = soapMessage.getSOAPPart().getContent();
|
||||
|
||||
ByteArrayOutputStream streamOut = new ByteArrayOutputStream();
|
||||
StreamResult result = new StreamResult(streamOut);
|
||||
tf.transform(sc, result);
|
||||
|
||||
String strMessage = streamOut.toString();
|
||||
|
||||
logger.atInfo().log("----- SOAPMessage -----");
|
||||
logger.atInfo().log(strMessage);
|
||||
}
|
||||
|
||||
public String getToken(String vunr) throws Exception {
|
||||
BufferedReader br = new BufferedReader(
|
||||
new FileReader(System.getProperty("user.home") + "\\OMDSSchlüssel.txt"));
|
||||
|
||||
String[] tokens = br.lines().toArray(String[]::new);
|
||||
if (tokens.length > 1) {
|
||||
for (String token : tokens) {
|
||||
if (token.contains(vunr)) {
|
||||
if (!(token.replaceAll(".*[=: ]\\s*", "").contains(vunr))){
|
||||
return token.replaceAll(".*[=: ]\\s*","");
|
||||
}
|
||||
throw new Exception("Der Token mit der angegebenen VuNr hat ein ungültiges Format");
|
||||
}
|
||||
}
|
||||
throw new Exception("Kein Token für die angegebene VuNr vorhanden");
|
||||
}else{
|
||||
throw new Exception("Keine Tokens in der Datei");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package at.vvo.omds.client.gui.api.apriori;
|
||||
|
||||
import at.vvo.omds.helpers.Plausi;
|
||||
import at.vvo.omds.helpers.RDFHelper;
|
||||
import at.vvo.omds.client.gui.api.SOAPConnector;
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.APrioriVerkaufsproduktType;
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.ProductsRequest;
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.ProductsResponse;
|
||||
import jakarta.xml.bind.JAXBElement;
|
||||
import javafx.util.Pair;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class AprioriAuskunftService {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(AprioriAuskunftService.class);
|
||||
|
||||
private final SOAPConnector soapConnector;
|
||||
|
||||
public AprioriAuskunftService(SOAPConnector soapConnector) {
|
||||
this.soapConnector = soapConnector;
|
||||
}
|
||||
|
||||
public ProductsResponse aprioriAuskunft(XMLGregorianCalendar stichtag, String vuNr) throws Exception {
|
||||
|
||||
String token = "<KEY>";
|
||||
JAXBElement<ProductsRequest> r = BuildProductsRequest.aprioriRequest(stichtag, vuNr);
|
||||
|
||||
ProductsResponse response =
|
||||
soapConnector.aprioriAuskunft(
|
||||
"http://localhost:9090/ws", r, token
|
||||
);
|
||||
log.info("Got Response As below ========= : ");
|
||||
log.info("Status : {}", response.getVerkaufsprodukt().getFirst().getName());
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public Pair<List<APrioriVerkaufsproduktType>, List<Plausi>> aprioriRDFAuskunft(XMLGregorianCalendar stichtag, String vuNr) throws Exception {
|
||||
JAXBElement<ProductsRequest> r = BuildProductsRequest.aprioriRequest(stichtag, vuNr);
|
||||
|
||||
RDFHelper rdfHelper = new RDFHelper();
|
||||
Pair<List<APrioriVerkaufsproduktType>, List<Plausi>> response = rdfHelper.getAprioriRDF(r);
|
||||
|
||||
log.info("Got Response As below ========= : ");
|
||||
log.info("Status : {}", response.getKey().getFirst().getName());
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package at.vvo.omds.client.gui.api.apriori;
|
||||
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.*;
|
||||
import jakarta.xml.bind.JAXBElement;
|
||||
import jakarta.xml.bind.annotation.XmlElementDecl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
public class BuildProductsRequest {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(BuildProductsRequest.class);
|
||||
|
||||
private static final ObjectFactory OUOF =
|
||||
new ObjectFactory();
|
||||
|
||||
/** Privater default Constructor versteckt den nicht benötigten Default-Constructor. */
|
||||
private BuildProductsRequest() {
|
||||
}
|
||||
|
||||
static public JAXBElement<ProductsRequest> aprioriRequest(XMLGregorianCalendar Stichtag, String vuNr) {
|
||||
LOG.info("VUNr = " + vuNr);
|
||||
|
||||
ProductsRequest request = OUOF.createProductsRequest();
|
||||
request.setKorrelationsId("123456");
|
||||
request.setVUNr(vuNr);
|
||||
request.setStichtag(Stichtag);
|
||||
return createProductsRequest(request);
|
||||
}
|
||||
|
||||
@XmlElementDecl(namespace = "urn:omds3CommonServiceTypes-1-1-0", name = "ProductsRequest")
|
||||
public static JAXBElement<ProductsRequest> createProductsRequest(ProductsRequest value) {
|
||||
return new JAXBElement<>(new QName("urn:omds3CommonServiceTypes-1-1-0","ProductsRequest"),
|
||||
ProductsRequest.class, null, value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package at.vvo.omds.client.gui.api.calc;
|
||||
|
||||
import at.vvo.omds.helpers.GuiProdukt;
|
||||
import at.vvo.omds.helpers.ObjectFactoryFactory;
|
||||
import at.vvo.omds.helpers.RDFHelper;
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.*;
|
||||
import at.vvo.omds.types.omds3.r2025_05.on2antrag.common.*;
|
||||
import jakarta.xml.bind.JAXBElement;
|
||||
import javafx.scene.control.TreeItem;
|
||||
import javafx.scene.control.TreeView;
|
||||
import org.eclipse.rdf4j.model.Model;
|
||||
import org.eclipse.rdf4j.rio.RDFFormat;
|
||||
import org.eclipse.rdf4j.rio.Rio;
|
||||
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
import javax.xml.namespace.QName;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
public class BuildCalculateRequestAuskunft {
|
||||
private static final at.vvo.omds.types.omds3.r2025_05.on2antrag.common.ObjectFactory OUOF =
|
||||
new at.vvo.omds.types.omds3.r2025_05.on2antrag.common.ObjectFactory();
|
||||
|
||||
private BuildCalculateRequestAuskunft(){}
|
||||
|
||||
static public JAXBElement<CalculateRequest> buildRequestFromTreeView(TreeView<GuiProdukt> treeView, XMLGregorianCalendar vtBeg) {
|
||||
CalculateRequest request = OUOF.createCalculateRequest();
|
||||
VerkaufsproduktType verkaufsprodukt = TreeViewToVerkaufsprodukt(treeView, vtBeg);
|
||||
verkaufsprodukt.setVtgBeg(vtBeg);
|
||||
verkaufsprodukt.setTyp(((ProduktbausteinType)treeView.getRoot().getValue().getProdukt()).getTyp());
|
||||
SpezBerechnungGenType berechnungsanfrage = new SpezBerechnungGenType();
|
||||
|
||||
berechnungsanfrage.setVerkaufsprodukt(verkaufsprodukt);
|
||||
request.setBerechnungsanfrage(berechnungsanfrage);
|
||||
request.setKorrelationsId("12444579");
|
||||
request.setVUNr("042");
|
||||
|
||||
return createCalculateRequest(request);
|
||||
}
|
||||
|
||||
static public String buildRDFRequestFromTreeView(TreeView<GuiProdukt> treeView, XMLGregorianCalendar vtBeg) {
|
||||
RDFHelper rdf = new RDFHelper();
|
||||
Model requestModel = rdf.createRdfModel(treeView.getRoot());
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
Rio.write(requestModel, baos, RDFFormat.JSONLD);
|
||||
|
||||
return baos.toString();
|
||||
}
|
||||
|
||||
public static JAXBElement<CalculateRequest> createCalculateRequest(CalculateRequest value) {
|
||||
return new JAXBElement<>(new QName("urn:at.vvo.omds.types.omds3types.v1-3-0.on2antrag.common","CalculateRequest"),
|
||||
CalculateRequest.class, null, value);
|
||||
}
|
||||
|
||||
public static ProduktbausteinType TreeItemToBaustein(TreeItem<GuiProdukt> treeItem) {
|
||||
ProduktbausteinType baustein = new ObjectFactoryFactory().create(
|
||||
((ProduktbausteinType)treeItem.getValue().getProdukt()).getTyp());
|
||||
|
||||
baustein.setBezeichnung(((ProduktbausteinType)treeItem.getValue().getProdukt()).getBezeichnung());
|
||||
baustein.setId(((ProduktbausteinType)treeItem.getValue().getProdukt()).getId());
|
||||
baustein.setVerkaufsoffenVon(((ProduktbausteinType)treeItem.getValue().getProdukt()).getVerkaufsoffenVon());
|
||||
baustein.setVerkaufsoffenBis(((ProduktbausteinType)treeItem.getValue().getProdukt()).getVerkaufsoffenBis());
|
||||
baustein.getAttribute().addAll(((ProduktbausteinType)treeItem.getValue().getProdukt()).getAttribute());
|
||||
baustein.setTyp(((ProduktbausteinType)treeItem.getValue().getProdukt()).getTyp());
|
||||
baustein.setMinVorkommen(((ProduktbausteinType)treeItem.getValue().getProdukt()).getMinVorkommen());
|
||||
baustein.setMaxVorkommen(((ProduktbausteinType)treeItem.getValue().getProdukt()).getMaxVorkommen());
|
||||
baustein.getVersicherteObjekte().addAll(((ProduktbausteinType) treeItem.getValue().getProdukt()).getVersicherteObjekte());
|
||||
baustein.setPraemienfaktor(((ProduktbausteinType)treeItem.getValue().getProdukt()).getPraemienfaktor());
|
||||
|
||||
return baustein;
|
||||
}
|
||||
|
||||
public static VerkaufsproduktType TreeViewToVerkaufsprodukt(TreeView<GuiProdukt> treeView, XMLGregorianCalendar vtBeg) {
|
||||
VerkaufsproduktType verkaufsprodukt = (VerkaufsproduktType) TreeItemToBaustein(treeView.getRoot());
|
||||
verkaufsprodukt.setVtgBeg(vtBeg);
|
||||
|
||||
if (!treeView.getRoot().getChildren().isEmpty()) {
|
||||
for (int i = 0; i < treeView.getRoot().getChildren().size(); i++) {
|
||||
verkaufsprodukt.getBausteine().add((addUpFromTreeItem(treeView.getRoot().getChildren().get(i))));
|
||||
}
|
||||
}
|
||||
|
||||
return verkaufsprodukt;
|
||||
}
|
||||
|
||||
public static ProduktbausteinType addUpFromTreeItem(TreeItem<GuiProdukt> treeItem) {
|
||||
ProduktbausteinType baustein = TreeItemToBaustein(treeItem);
|
||||
|
||||
if (!treeItem.getChildren().isEmpty()) {
|
||||
for (int i = 0; i < treeItem.getChildren().size(); i++) {
|
||||
baustein.getBausteine().add(addUpFromTreeItem(treeItem.getChildren().get(i)));
|
||||
}
|
||||
}
|
||||
return baustein;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package at.vvo.omds.client.gui.api.calc;
|
||||
|
||||
import at.vvo.omds.helpers.GuiProdukt;
|
||||
import at.vvo.omds.helpers.RDFHelper;
|
||||
import at.vvo.omds.client.gui.api.SOAPConnector;
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.VerkaufsproduktType;
|
||||
import at.vvo.omds.types.omds3.r2025_05.on2antrag.common.CalculateRequest;
|
||||
import at.vvo.omds.types.omds3.r2025_05.on2antrag.common.CalculateResponse;
|
||||
import jakarta.xml.bind.JAXBElement;
|
||||
import javafx.scene.control.TreeView;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
|
||||
|
||||
public class CalculateRequestAuskunftService {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(CalculateRequestAuskunftService.class);
|
||||
|
||||
private final SOAPConnector soapConnector;
|
||||
|
||||
public CalculateRequestAuskunftService(SOAPConnector soapConnector) {
|
||||
this.soapConnector = soapConnector;
|
||||
}
|
||||
|
||||
public CalculateResponse calculateAuskunft(TreeView<GuiProdukt> treeView, XMLGregorianCalendar vtBeg) throws Exception {
|
||||
|
||||
String token = "<KEY>";
|
||||
JAXBElement<CalculateRequest> r = BuildCalculateRequestAuskunft.buildRequestFromTreeView(treeView, vtBeg);
|
||||
|
||||
CalculateResponse response =
|
||||
soapConnector.calculateRequestAuskunft(
|
||||
"http://localhost:9090/ws", r, token
|
||||
);
|
||||
log.info("Got Response As below ========= : ");
|
||||
log.info("Status : {}", response.getBerechnungsantwort().getVerkaufsprodukt().getBezeichnung());
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public VerkaufsproduktType calculateRDFAuskunft(TreeView<GuiProdukt> treeView, XMLGregorianCalendar vtBeg) throws Exception {
|
||||
|
||||
String request = BuildCalculateRequestAuskunft.buildRDFRequestFromTreeView(treeView, vtBeg);
|
||||
|
||||
RDFHelper rdfHelper = new RDFHelper();
|
||||
VerkaufsproduktType response = rdfHelper.getCalculateRDF(request);
|
||||
log.info("Got Response As below ========= : ");
|
||||
log.info("Status : {}", response.getBezeichnung());
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.kapdion.pisano;
|
||||
|
||||
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
|
||||
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
|
||||
// to see how IntelliJ IDEA suggests fixing it.
|
||||
System.out.printf("Hello and welcome!");
|
||||
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
//TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
|
||||
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
|
||||
System.out.println("i = " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
15
client-app/src/main/resources/log4j.properties
Normal file
15
client-app/src/main/resources/log4j.properties
Normal file
@@ -0,0 +1,15 @@
|
||||
# Logging Properties fuer Produktion
|
||||
# Root logger
|
||||
log4j.rootLogger=INFO, stdout
|
||||
|
||||
# Define stdout Appender
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target=System.out
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %-12c{1}:%-3L - %m%n
|
||||
|
||||
# Log-Level fuer Projekt
|
||||
log4j.logger.at.vvo=DEBUG
|
||||
|
||||
# Wenn gewünscht, z.B. ändern auf Debug
|
||||
#log4j.logger.at.vvo=DEBUG
|
||||
BIN
client-app/src/main/resources/logo/VVO_Logo_2024.png
Normal file
BIN
client-app/src/main/resources/logo/VVO_Logo_2024.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
1
client-app/src/main/resources/logo/VVO_Logo_2024.svg
Normal file
1
client-app/src/main/resources/logo/VVO_Logo_2024.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="1144" height="388" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-68 -166)"><path d="M326.308 12.6085 220.397 224.936 113.477 12.6085 12.6085 12.6085 172.989 344.465C180.554 360.603 196.693 371.195 213.336 371.195 229.979 371.195 246.118 360.603 253.683 344.465L416.081 12.6085 326.308 12.6085Z" fill="#101820" transform="matrix(1.00014 0 0 1 68 167.09)"/><path d="M778.702 12.6085 672.286 224.936 565.366 12.6085 464.498 12.6085 624.878 344.465C632.443 360.603 648.582 371.195 665.225 371.195 682.373 371.195 698.007 360.603 705.572 344.465L867.97 12.6085 778.702 12.6085 778.702 12.6085Z" fill="#101820" transform="matrix(1.00014 0 0 1 68 167.09)"/><path d="M1062.14 114.99C1018.26 114.99 993.551 149.285 993.551 191.649 993.551 234.014 1018.26 268.309 1062.14 268.309 1106.02 268.309 1131.24 234.014 1131.24 191.649 1131.24 149.285 1106.02 114.99 1062.14 114.99Z" fill="#80BC00" transform="matrix(1.00014 0 0 1 68 167.09)"/></g></svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1,45 @@
|
||||
package omdsclient;
|
||||
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.APrioriUnterbausteinType;
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.APrioriProduktbausteinType;
|
||||
import at.vvo.omds.types.omds3.r2025_05.common.APrioriVerkaufsproduktType;
|
||||
|
||||
|
||||
import javax.xml.datatype.DatatypeFactory;
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
import java.time.LocalDate;
|
||||
import javax.xml.datatype.DatatypeConfigurationException;
|
||||
import java.time.ZoneId;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
public class ProduktauskunftTests {
|
||||
|
||||
|
||||
public void testProduktauskunft() {
|
||||
APrioriProduktbausteinType vk_kraftfahrt_2024 = new APrioriVerkaufsproduktType();
|
||||
vk_kraftfahrt_2024.setId("1");
|
||||
vk_kraftfahrt_2024.setName("Kraftfahrt 2024");
|
||||
vk_kraftfahrt_2024.setFrom(convert(LocalDate.of(2024, 1, 1)));
|
||||
|
||||
APrioriUnterbausteinType p_kfz_haftpflicht_2024 = new APrioriUnterbausteinType();
|
||||
p_kfz_haftpflicht_2024.setId("2");
|
||||
p_kfz_haftpflicht_2024.setName("Haftpflicht 2024");
|
||||
p_kfz_haftpflicht_2024.setFrom(convert(LocalDate.of(2024, 1, 1)));
|
||||
p_kfz_haftpflicht_2024.setTo(convert(LocalDate.of(2024, 1, 1)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static XMLGregorianCalendar convert(LocalDate date) {
|
||||
try {
|
||||
// Konvertiere LocalDate zu GregorianCalendar
|
||||
GregorianCalendar gregorianCalendar = GregorianCalendar.from(date.atStartOfDay(ZoneId.systemDefault()));
|
||||
|
||||
// Erstelle XMLGregorianCalendar mit Hilfe der DatatypeFactory
|
||||
return DatatypeFactory.newInstance().newXMLGregorianCalendar(gregorianCalendar);
|
||||
} catch (DatatypeConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
return null; // Fehlerfall, falls die DatatypeFactory fehlschlägt
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user