Zeus-Commons-APIs ist Ihr Schweizer Taschenmesser für Backend-Services. Erstellen Sie mächtige, verschachtelte SQL-Abfragen einfach über REST oder die Konsole. Läuft leichtgewichtig auf Spark Java und gibt Daten im JSON- oder XML-Format bis zu vier Verschachtelungsebenen zurück. Perfekt für alle, die Flexibilität ohne den Overhead wollen.
Wichtiger Hinweis: Für den Produktiveinsatz sind weitere Maßnahmen gegen SQL-Injection notwendig.
- API-Backend-Entwicklung
- Integration diverser Datenquellen
- Modernisierung von Legacy-Systemen wie System-i (AS/400)
Es gibt zwei Hauptendpunkte:
- POST localhost:4567/json gibt Daten im JSON-Format zurück.
- POST localhost:4567/xml gibt Daten im XML-Format zurück.
Sie können die Ausgabe von Metadaten ein- oder ausschalten, indem Sie das Feld includeMetadata im JSON-Body auf true oder false setzen.
Beispieldaten finden Sie unter examples.
Die Anwendung unterstützt Datenverschachtelungen bis zu vier Ebenen. Dies erlaubt die Darstellung komplexer Abfragebeziehungen.
{
"query": {
"name": "agents",
"statement": "select * from agents where agent_code = 'A105'",
"subquery": {
"name": "orders",
"statement": "select * from orders where agent_code = '[$agent_code]'",
"subquery": {
"name": "customers",
"statement": "select * from customers where cust_code = '[$cust_code]'",
"subquery": {
"name": "revenue",
"statement": "select * from agent_revenue where agent_code = '[$agent_code]'"
}
}
}
},
"includeMetadata": false
}Dieses Projekt verwendet Maven für den Build-Prozess und stellt verschiedene Profile zur Verfügung, um spezifische Abhängigkeiten hinzuzufügen oder zu entfernen.
Dieses Profil fügt die JT400-Bibliothek als Abhängigkeit hinzu und ermöglicht die Integration mit IBM i (früher AS/400).
mvn clean install -P include-jt400Dieses Profil fügt die Bouncy Castle Bibliothek als Abhängigkeit hinzu, um SSL-Unterstützung zu ermöglichen.
mvn clean install -P include-sslDieses Profil erstellt ein "Uber-JAR", das alle Abhängigkeiten in einer einzigen JAR-Datei bündelt. Ideal für den einfachen Transport und Deployment.
mvn clean install -P fat-jarDieses Profil erstellt ein Standard-JAR ohne eingebettete Abhängigkeiten. Nützlich, wenn Sie die Abhängigkeiten selbst verwalten wollen.
mvn clean install -P standard-jarEs ist auch möglich, mehrere Profile gleichzeitig zu verwenden, um eine Kombination der jeweiligen Features zu erhalten.
mvn clean install -P include-jt400,include-ssl,fat-jarDer Provider fungiert als Einstiegspunkt, um die Anwendung als REST-Service oder über die Konsole zu betreiben. Er behandelt Befehlszeilenargumente, initialisiert die notwendigen Komponenten und startet den Service. Aufruf des Provider als REST-Service:
java -cp zeus-commons-0.0.1-SNAPSHOT.jar de.zeus.commons.provider.Provider "REST" "<pfad-zur-jdbc-properties-datei>" "<pfad-zur-spark-properties-datei>"Aufruf des Provider über die Konsole:
java -cp zeus-commons-0.0.1-SNAPSHOT.jar de.zeus.commons.provider.Provider "CONSOLE" "<pfad-zur-jdbc-properties-datei>" "<json-query-objekt>" "<modus>"Als 'mode' kann application/xml oder application/xml angegeben werden, um das Ausgabeformat zu steuern.
Der Consumer dient als Einstiegspunkt für den Clientbetrieb des Systems. Er verarbeitet Befehlszeilenargumente und sendet eine JSON-Anfrage an eine spezifizierte Service-URL. Die Konfiguration erfolgt über Properties-Dateien.
Aufruf des Consumer:
java -cp zeus-commons-0.0.1-SNAPSHOT.jar de.zeus.commons.consumer.Consumer "JSON_EAV" "<path-to-jdbc-properties-file>" "<path-to-jsonclient-properties-file>"Zeus-Commons-APIs is your Swiss Army knife for backend services. Easily create powerful, nested SQL queries via REST or console input. Running lean on Spark Java, it returns data in JSON or XML formats with up to four levels of nesting. Perfect for those who want flexibility without the overhead.
Important Note: Further measures against SQL Injection are required for production use.
- API Backend Development
- Integration of Various Data Sources
- Modernization of Legacy Systems like System-i (AS/400)
There are two main endpoints:
- POST localhost:4567/json returns data in JSON format.
- POST localhost:4567/xml returns data in XML format.
You can toggle metadata output on or off by setting the includeMetadata field in the JSON body to true or false.
Sample data can be found under examples.
The application supports data nesting up to four levels, allowing for complex query relationships to be modelled.
{
"query": {
"name": "agents",
"statement": "select * from agents where agent_code = 'A105'",
"subquery": {
"name": "orders",
"statement": "select * from orders where agent_code = '[$agent_code]'",
"subquery": {
"name": "customers",
"statement": "select * from customers where cust_code = '[$cust_code]'",
"subquery": {
"name": "revenue",
"statement": "select * from agent_revenue where agent_code = '[$agent_code]'"
}
}
}
},
"includeMetadata": false
}This project uses Maven for the build process and provides several profiles to add or remove specific dependencies.
This profile adds the JT400 library as a dependency and allows integration with IBM i (formerly AS/400).
mvn clean install -P include-jt400This profile adds the Bouncy Castle library as a dependency to enable SSL support.
mvn clean install -P include-sslThis profile creates an "Uber JAR" that bundles all dependencies into a single JAR file. Ideal for easy transport and deployment.
mvn clean install -P fat-jarThis profile creates a standard JAR without embedded dependencies. Useful if you want to manage the dependencies yourself.
mvn clean install -P standard-jarIt is also possible to use several profiles at the same time to get a combination of their features.
mvn clean install -P include-jt400,include-ssl,fat-jarThe provider acts as an entry point to run the application as a REST service or via the console. It handles command line arguments, initializes the necessary components and starts the service. How to run the Provider as REST Service:
java -cp zeus-commons-0.0.1-SNAPSHOT.jar de.zeus.commons.provider.Provider "REST" "<path-to-jdbc-properties-file>" "<path-to-spark-properties-file>"How to run the Provider from the console:
java -cp zeus-commons-0.0.1-SNAPSHOT.jar de.zeus.commons.provider.Provider "CONSOLE" "<path-to-jdbc-properties-file>" "<json-query-object>" "<mode>"Application/xml or application/xml can be specified as 'mode' to control the output format.
The Consumer serves as the entry point for client operation of the system. It processes command line arguments and sends a JSON request to a specified service URL. Configuration is done via properties files.
How to run the Consumer:
java -cp zeus-commons-0.0.1-SNAPSHOT.jar de.zeus.commons.consumer.Consumer "JSON_EAV" "<path-to-jdbc-properties-file>" "<path-to-jsonclient-properties-file>"