├── .gitignore
├── Dockerfile
├── LICENSE
├── README.md
├── Releases.md
├── bin
├── debug_example.sh
└── uploadReleaseToNexus.sh
├── build.gradle
├── docker
├── README.md
├── bin
│ ├── build.sh
│ ├── image_conf.sh
│ ├── remove.sh
│ ├── run_jsonCodeGen.sh
│ └── start_shell.sh
└── image
│ ├── Dockerfile
│ └── release
│ ├── conf
│ └── logback.xml
│ ├── jsonCodeGen.groovy
│ ├── jsonCodeGen.sh
│ └── lib
│ ├── commons-lang3-3.3.jar
│ ├── groovy-all-2.3.11.jar
│ ├── jcommander-1.69.jar
│ ├── jsonCodeGen-0.11.3.jar
│ ├── logback-classic-1.2.3.jar
│ ├── logback-core-1.2.3.jar
│ ├── slf4j-api-1.7.25.jar
│ ├── stax-api-1.0.1.jar
│ └── xmlbeans-3.0.0.jar
├── docs
└── main_structure.puml
├── junctionModel.puml
├── junctionModel2.puml
├── settings.gradle
└── src
├── main
├── groovy
│ └── de
│ │ └── lisaplus
│ │ └── atlas
│ │ ├── DoCodeGen.groovy
│ │ ├── JavaFileLoader.groovy
│ │ ├── builder
│ │ ├── JsonSchemaBuilder.groovy
│ │ ├── XSDBuilder.groovy
│ │ └── helper
│ │ │ └── BuildHelper.groovy
│ │ ├── codegen
│ │ ├── GeneratorBase.groovy
│ │ ├── MultiFileGenarator.groovy
│ │ ├── SingleFileGenarator.groovy
│ │ ├── TemplateType.groovy
│ │ ├── TypeStringManipulation.groovy
│ │ ├── external
│ │ │ ├── ExtMultiFileGenarator.groovy
│ │ │ └── ExtSingleFileGenarator.groovy
│ │ ├── helper
│ │ │ └── java
│ │ │ │ ├── DotnetTypeConvert.groovy
│ │ │ │ ├── JavaTypeConvert.groovy
│ │ │ │ ├── JsonTypeConvert.groovy
│ │ │ │ ├── SwaggerTypeConvert.groovy
│ │ │ │ └── TypeToColor.groovy
│ │ ├── java
│ │ │ ├── JavaBeanGenerator.groovy
│ │ │ ├── JavaGeneratorBase.groovy
│ │ │ ├── JavaGenericDerivedBeanGenerator.groovy
│ │ │ ├── JavaInterfaceGenerator.groovy
│ │ │ ├── JavaInterfacedBeanGenerator.groovy
│ │ │ ├── JavaInterfacedGenericDerivedBeanGenerator.groovy
│ │ │ └── MongoBeanGenerator.groovy
│ │ └── meta
│ │ │ ├── HistModelGenerator.groovy
│ │ │ ├── JsonSchemaGenerator.groovy
│ │ │ ├── PlantUmlGenerator.groovy
│ │ │ ├── PlantUmlJavaGenerator.groovy
│ │ │ ├── SwaggerGenerator.groovy
│ │ │ ├── SwaggerGeneratorExt.groovy
│ │ │ └── XsdGenerator.groovy
│ │ ├── interf
│ │ ├── ICodeGen.groovy
│ │ ├── IExternalCodeGen.groovy
│ │ └── IModelBuilder.groovy
│ │ └── model
│ │ ├── AggregationType.groovy
│ │ ├── ArrayType.groovy
│ │ ├── BaseType.groovy
│ │ ├── ComplexType.groovy
│ │ ├── DateTimeType.groovy
│ │ ├── DateType.groovy
│ │ ├── InnerType.groovy
│ │ ├── MinMaxType.groovy
│ │ ├── Model.groovy
│ │ ├── Property.groovy
│ │ ├── RefType.groovy
│ │ └── Type.groovy
└── resources
│ ├── bin
│ ├── jsonCodeGen.groovy
│ ├── jsonCodeGen.sh
│ └── jsonCodeGenDebug.sh
│ ├── conf
│ └── logback.xml
│ ├── docs
│ ├── extensions.md
│ └── usage.md
│ └── templates
│ ├── java
│ ├── bean.txt
│ ├── generic_derived_bean.txt
│ ├── interface.txt
│ ├── interfaced_bean.txt
│ ├── interfaced_generic_derived_bean.txt
│ ├── mongo_bean.txt
│ └── sub
│ │ ├── mongo_bean_joined_crud.txt
│ │ └── mongo_bean_normal_crud.txt
│ └── meta
│ ├── hist_model_schema.txt
│ ├── hist_model_schema_orig.txt
│ ├── json_schema.txt
│ ├── plantuml.txt
│ ├── plantuml_java.txt
│ ├── sub
│ ├── json_schema_attribs.txt
│ └── json_schema_attribs_orig.txt
│ ├── swagger_ext.txt
│ ├── swagger_file.txt
│ └── xsd.txt
└── test
├── groovy
└── de
│ └── lisaplus
│ └── atlas
│ ├── Model.groovy
│ ├── ModelTestHelper.groovy
│ ├── builder
│ └── test
│ │ └── jsonschema
│ │ ├── ArrayTests.groovy
│ │ ├── JsonSchemaBuilder.groovy
│ │ ├── MultiTypeSchema.groovy
│ │ └── SingleTypeSchema.groovy
│ ├── codegen
│ └── test
│ │ ├── DoCodeGen.groovy
│ │ ├── HistModel.groovy
│ │ ├── JavaBeans.groovy
│ │ ├── JavaInterfacedBeans.groovy
│ │ ├── JavaInterfaces.groovy
│ │ ├── JsonSchema.groovy
│ │ ├── MongoBeans.groovy
│ │ ├── MultiFileTemplates.groovy
│ │ ├── PlantUml.groovy
│ │ ├── Swagger.groovy
│ │ ├── SwaggerExt.groovy
│ │ ├── Xsd.groovy
│ │ └── base
│ │ ├── FileHelper.groovy
│ │ ├── GeneratorBase.groovy
│ │ └── JavaCompileHelper.groovy
│ └── de
│ └── lisaplus
│ └── atlas
│ └── builder
│ └── test
│ └── xsd
│ └── SimpleXsdBuilder.groovy
└── resources
├── extra
├── 2340.json
└── 2430.xml
├── schemas
├── CnResponseType.json
├── Container.json
├── CycCollectionType.json
├── DetCollectionType.json
├── GeoCollectionType.json
├── LocCollectionType.json
├── ProcessDataEvent.json
├── StdCollectionType.json
├── TimCollectionType.json
├── chrome-manifest.json
├── notify.json
├── ramwa.schema.json
├── test_3.json
├── test_4.json
└── vera.json
├── templates
├── HelloWorld_GString.tmpl
├── HelloWorld_Markup.tmpl
├── handling.txt
└── handling_helper.groovy
├── test_schemas
├── ds
│ ├── Device.json
│ ├── KnotenDaten.json
│ ├── array_test.json
│ ├── array_test_simple.json
│ ├── base_types
│ │ ├── gis_object.json
│ │ ├── map_object.json
│ │ ├── map_object_multi_type.json
│ │ ├── simple_gis_object.json
│ │ └── simple_map_object.json
│ ├── extra_types.json
│ ├── implicit_ref.json
│ ├── incident.json
│ ├── ines_network.json
│ ├── junction.json
│ ├── junction2.json
│ ├── junction_base.json
│ ├── license.json
│ ├── lisa-ines-network.json
│ ├── lisa-ines-network_new_references.json
│ ├── model.puml
│ ├── object_base.json
│ ├── referenced_multi_types.json
│ ├── shared
│ │ ├── app_module.json
│ │ ├── application.json
│ │ ├── comment.json
│ │ ├── domain.json
│ │ ├── field_entry.json
│ │ ├── geo_area.json
│ │ ├── geo_multiline.json
│ │ ├── geo_point.json
│ │ ├── icon.json
│ │ ├── junction_short.json
│ │ ├── list_entry.json
│ │ ├── options_response.json
│ │ ├── options_response2.json
│ │ ├── region.json
│ │ ├── selection_entry.json
│ │ ├── tag.json
│ │ ├── tenant.json
│ │ └── text_resource.json
│ ├── user.json
│ └── user_different_enum_values.json
├── multiType.json
└── singleType.json
└── xsd
├── LSA_Versorgung_OMTC.xsd
├── ZEN_Versorgung_OMTC.xsd
├── arrayTest.json
├── arrayTest.xsd
├── complex
├── AddGrpC.xsd
├── DSRC.xsd
├── ElectronicRegistrationIdentificationVehicleDataModule.xsd
├── ITS-Container.xsd
├── REGION.xsd
└── asn1.xsd
├── lisa_ines_network.xsd
├── simpleTest.xsd
└── ui-tlc.xsd
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | *.log
3 | .gradle
4 | build
5 | tmp
6 | classes
7 | out
8 | *.swp
9 | pushLatest.bat
10 | src/main/groovy/de/lisaplus/atlas/DummyGenerator.groovy
11 | src/main/groovy/de/lisaplus/atlas/TestStarter.groovy
12 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM mcr.microsoft.com/java/jdk:11u3-zulu-alpine as build
2 |
3 | RUN ["jlink", \
4 | "--compress=2", \
5 | "--strip-debug", \
6 | "--no-header-files", \
7 | "--no-man-pages", \
8 | "--module-path", "/usr/lib/jvm/zulu-11-azure-jdk_11.31.11-11.0.3-linux_musl_x64/jmods", \
9 | "--add-modules", "java.base,java.logging,java.desktop,java.naming,java.prefs,java.xml,java.scripting,java.sql", \
10 | "--output", "/custom_jre"]
11 |
12 | FROM alpine:latest
13 | COPY --from=build /custom_jre /opt/jre/
14 |
15 | RUN ln -s /opt/jre/bin/java /usr/bin/
16 |
17 | ADD build/release /opt/jsonCodeGen/
18 |
19 | ENTRYPOINT ["/opt/jsonCodeGen/jsonCodeGen.sh"]
20 |
21 | CMD ["--help"]
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Schlothauer & Wauer GmbH
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Releases.md:
--------------------------------------------------------------------------------
1 | ## 0.13.1
2 | - handle the right notation of external references: e.g. ./object_base.json#/definitions/ObjectBase
3 |
4 | (Attention, the wrong reference style before that version, is still working)
5 | ## 0.8.4
6 | - add additional generator parameters to improve plantuml view (ignoreAttribs,ignoreRefs,ignoreImplicitRefs, ignoreCompositions)
7 |
8 | ## 0.8.3
9 | - ignoreTag, neededTag are handled now as lists for multi-file-generators
10 | - rename 'pmta' command line switch to specify a required attribute for main types to 'mta'
11 | - add 'tmt' command line switch to add automatically a 'mainType' tag to all main types
12 |
13 | ## 0.8.2
14 | - needed fix in 'pmta' command line switch
15 |
16 | ## 0.8.1
17 | - add to types schemaPath and schemaFileName attributes (to finally detect what are the interesting main types of a model)
18 | - add a isMainType function to model type
19 | - add command line switches pro print only main types
20 |
21 | ## 0.8.0
22 | - command line switches for type black- and white-lists
23 | - command line switch to add tags to types
24 | - command line switch to remove a tag from types
25 | - command line switch to remove a tag from all types
26 | - enforce camel-case type names in models
27 | - add guidTypeColor generator parameter for plantuml
28 | - remove printTags generator parameter for plantuml
29 | - add printTypeTags generator parameter for plantuml
30 | - add printPropTags generator parameter for plantuml
31 |
32 | ## 0.7.5
33 | - deep copy functions for types
34 | - introduce pure array type to handle definitions where arrays contain only arrays, f.e. geoJson Polygons
35 |
36 | ```json
37 | ...
38 | "FeatureAreaGeometry": {
39 | "type": "object",
40 | "properties": {
41 | "type": {
42 | "type": "string"
43 | },
44 | "coordinates": {
45 | "type": "array",
46 | "items": {
47 | "type": "array",
48 | "items": {
49 | "type": "array",
50 | "items": {
51 | "type": "number"
52 | }
53 | }
54 | }
55 | },
56 | "projection": {
57 | "type": "string"
58 | }
59 | },
60 | "__tags": ["additional"]
61 | },
62 | ...
63 | ```
64 |
65 | ## 0.7.4
66 | - add attributes `selfReference` and `selfContainment` to model property type
--------------------------------------------------------------------------------
/bin/debug_example.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Example script to illustrate the template debugging option of jsonCodeGen
3 |
4 | scriptPos=${0%/*}
5 |
6 | debugStarterScript=$scriptPos/../build/release/jsonCodeGenDebug.sh
7 | if ! [ -f "$debugStarterScript" ]; then
8 | echo "debug starter script not found: $debugStarterScript"
9 | echo "Maybe release is not created. Try to create a release at first and re-run the script"
10 | echo "gradle clean buildRelease"
11 | exit 1
12 | fi
13 |
14 | $debugStarterScript -g "multifiles=$scriptPos/../src/test/resources/templates/handling.txt" \
15 | -gs "$scriptPos/../src/test/resources/templates/handling_helper.groovy" \
16 | -m "$scriptPos/../src/test/resources/test_schemas/ds/incident.json" \
17 | -o "$scriptPos/../tmp/handling" \
18 | -gp "packageName=de.debug"
19 |
20 |
21 |
--------------------------------------------------------------------------------
/bin/uploadReleaseToNexus.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | scriptPos=${0%/*}
4 |
5 | # retrieve the version from project file
6 | version=`cat "$scriptPos/../build.gradle" | grep project.version | grep = | sed -e "s-.* '--" -e "s-'--"`
7 | echo "version: $version"
8 |
9 | pushd "$scriptPos/.." > /dev/null
10 | if ! gradle publish; then
11 | echo "error while publish jars to nexus"
12 | popd > /dev/null
13 | fi
14 | popd > /dev/null
15 |
16 | if [ -z "$NEXUS_USER" ]; then
17 | echo "NEXUS_USER not defined"
18 | exit 1
19 | fi
20 |
21 | if [ -z "$NEXUS_RAW_ARCHIVE" ]; then
22 | echo "NEXUS_RAW_ARCHIVE not defined"
23 | exit 1
24 | fi
25 |
26 | pushd "$scriptPos/.." > /dev/null
27 | if ! gradle clean build; then
28 | echo 'error while build'
29 | exit 1
30 | fi
31 |
32 | if ! gradle buildRelease; then
33 | echo 'error while build release'
34 | exit 1
35 | fi
36 |
37 | cd build/release
38 |
39 |
40 | releaseFile="jsonCodeGen_$version.tgz"
41 |
42 | if [ -f "$releaseFile" ]; then
43 | rm -f "$releaseFile"
44 | fi
45 |
46 | tar -czf "$releaseFile" *
47 |
48 | if ! curl -v --user "$NEXUS_USER" --upload-file "$releaseFile" \
49 | "$NEXUS_RAW_ARCHIVE/$releaseFile"
50 | then
51 | echo "error while upload release to nexus raw repo"
52 | fi
53 |
54 | git tag "$version"
55 |
56 | popd > /dev/null
57 |
58 |
--------------------------------------------------------------------------------
/docker/README.md:
--------------------------------------------------------------------------------
1 | Here are the place for docker related stuff ... Image description and starter scripts
2 |
3 | The idea behind that approach is to run the code generation inside a docker container
4 | and free the user from the dependency of an installed Java
5 |
6 | ```
7 | # example call for a simple plantuml generation
8 | docker run -v ABSOLUTE_PATH_TO_SRC_FOLDER:/opt/input \
9 | -v ABSOLUTE_PATH_TO_DEST_FOLDER:/opt/output LIST_OF_JSONCODEGEN_PARAMETER
10 |
11 | # for example ...
12 | docker run -v /home/eiko/prog/gitlab/lisa-server_models/model:/opt/input \
13 | -v /tmp/output:/opt/output \
14 | schlothauer/jsoncodegen:0.4.1 \
15 | -g plantuml \
16 | -m /opt/input/junction.json \
17 | -o /opt/output \
18 | -gp destFileName=test.puml
19 |
20 | bin/run_jsonCodeGen.sh -m ../src/test/resources/schemas/vera.json \
21 | -o /tmp -g plantuml -p destFileName=test.puml
22 | ```
23 |
24 | ## How to create a docker image
25 | Requirements:
26 | - installed Java v8
27 | - installed Gradle
28 | ```bash
29 | # show all available Gradle tasks (only for information)
30 | gradle tasks --all
31 |
32 | # preparation - create a release and copy the needed libraries to the docker image source
33 | gradle buildDockerImage
34 |
35 | # creates a docker image ...
36 | schlothauer/jsoncodegen:TAG
37 | ```
38 |
39 |
--------------------------------------------------------------------------------
/docker/bin/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | scriptPos=${0%/*}
4 |
5 | source "$scriptPos/image_conf.sh"
6 |
7 | pushd "$scriptPos/.." > /dev/null
8 | if docker build -t $imageName image
9 | then
10 | echo -en "\033[1;34m image created: $imageName \033[0m\n"
11 | else
12 | echo -en "\033[1;31m error while create image: $imageName \033[0m\n"
13 | fi
14 | popd > /dev/null
15 |
16 |
--------------------------------------------------------------------------------
/docker/bin/image_conf.sh:
--------------------------------------------------------------------------------
1 | imageBase=schlothauer/jsoncodegen
2 | imageTag=0.11.3
3 |
4 | if [ -f build.gradle ]; then
5 | imageTag=`cat build.gradle | grep project.version | awk '{ print $3 }' | sed -e "s-'--g"`
6 | fi
7 |
8 | imageName="$imageBase:$imageTag"
9 |
10 | echo "$imageName"
11 |
--------------------------------------------------------------------------------
/docker/bin/remove.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | scriptPos=${0%/*}
4 |
5 | source "$scriptPos/image_conf.sh"
6 |
7 |
8 | if docker rmi -f "$imageName"
9 | then
10 | echo -en "\033[1;34m image deleted: $imageName \033[0m\n"
11 | else
12 | echo -en "\033[1;31m error while delete image: $imageName \033[0m\n"
13 | fi
14 |
--------------------------------------------------------------------------------
/docker/bin/run_jsonCodeGen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | scriptPos=${0%/*}
3 |
4 | source "$scriptPos/image_conf.sh"
5 |
6 | function show_help() {
7 | echo '''
8 | JsonCodeGen is a tool to generate stuff like plantuml diagramms or source code from
9 | JSON schemas.
10 |
11 | usage:
12 | ./run_jsonCodeGen.sh -m MODEL_FILE -o DEST_DIR -g GENERATOR [-p GENERATOR_PARAMETER]
13 |
14 | example:
15 | ./run_jsonCodeGen.sh -m /home/test/my_model.json -d ./out -g plantuml \
16 | -p destFileName=my_diagram.puml -p removeEmptyLines=true
17 | '''
18 | }
19 |
20 | function checkInputAndExitIfEmpty() {
21 | variableToCheck=$1
22 | msgTxt=$2
23 | if [ -z "$variableToCheck" ]; then
24 | echo "$msgTxt"
25 | echo
26 | show_help
27 | exit 1
28 | fi
29 | }
30 |
31 | # @Parameter(names = [ '-m', '--model' ], description = "Path to JSON schema to parse", required = true)
32 | # @Parameter(names = [ '-o', '--outputBase' ], description = "Base directory for the output", required = true)
33 | # @Parameter(names = ['-g', '--generator'], description = "generator that are used with the model. This parameter can be used multiple times")
34 | # @Parameter(names = ['-gp', '--generator-parameter'], description = "special parameter that are passed to template via maps")
35 | # @Parameter(names = ['-h','--help'], help = true)
36 |
37 | generatorParameters="-gp removeEmptyLines=true"
38 |
39 | while getopts "h?m:o:g:p:" opt; do
40 | case "$opt" in
41 | h|\?)
42 | show_help
43 | exit 0
44 | ;;
45 | m) model=$OPTARG
46 | ;;
47 | o) outputBase=$OPTARG
48 | ;;
49 | g) generator=$OPTARG
50 | ;;
51 | p) generatorParameters+=" -gp $OPTARG"
52 | echo $OPTARG
53 | ;;
54 | esac
55 | done
56 |
57 | shift $((OPTIND -1))
58 |
59 | checkInputAndExitIfEmpty "$model" "model file is needed"
60 | checkInputAndExitIfEmpty "$outputBase" "the directory to write the output is needed"
61 | checkInputAndExitIfEmpty "$generator" "the generator to use is needed"
62 |
63 | if ! [ -f "$model" ]; then
64 | echo
65 | echo "given model file not found in file system: $model"
66 | exit 1
67 | fi
68 |
69 | if ! [ -d "$outputBase" ]; then
70 | echo
71 | echo "disired output directory doesn't exist: $outputBase"
72 | exit 1
73 | fi
74 |
75 | modelDir=${model%/*}
76 | absolutModelDir=`pushd "$modelDir" > /dev/null;pwd;popd > /dev/null`
77 | modelFile=${model##*/}
78 |
79 | outputDir=`pushd "$outputBase" > /dev/null;pwd;popd > /dev/null`
80 |
81 | aktImgName=`docker images | grep -G "$imageBase *$imageTag *" | awk '{print $1}'`
82 | aktImgVers=`docker images | grep -G "$imageBase *$imageTag *" | awk '{print $2}'`
83 |
84 |
85 | if [ "$aktImgName" == "$imageBase" ] && [ "$aktImgVers" == "$imageTag" ]
86 | then
87 | echo "run container from image: $aktImgName:$aktImgVers"
88 | else
89 | if docker build -t $imageName $scriptPos/../image
90 | then
91 | echo -en "\033[1;34m image created: $1 \033[0m\n"
92 | else
93 | echo -en "\033[1;31m error while create image: $imageName \033[0m\n"
94 | exit 1
95 | fi
96 | fi
97 |
98 | docker run --rm -it -v "$absolutModelDir":/opt/model -v "$outputDir":/opt/output "$imageName" /opt/jsonCodeGen/jsonCodeGen.sh -o "/opt/output" -m "/opt/model/$modelFile" -g "$generator" $generatorParameters
99 |
100 |
101 |
--------------------------------------------------------------------------------
/docker/bin/start_shell.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | scriptPos=${0%/*}
4 |
5 | source "$scriptPos/image_conf.sh"
6 |
7 |
8 | aktImgName=`docker images | grep -G "$imageBase *$imageTag *" | awk '{print $1}'`
9 | aktImgVers=`docker images | grep -G "$imageBase *$imageTag *" | awk '{print $2}'`
10 |
11 |
12 | if [ "$aktImgName" == "$imageBase" ] && [ "$aktImgVers" == "$imageTag" ]
13 | then
14 | echo "run container from image: $aktImgName:$aktImgVers"
15 | else
16 | if docker build -t $imageName $scriptPos/../image
17 | then
18 | echo -en "\033[1;34m image created: $1 \033[0m\n"
19 | else
20 | echo -en "\033[1;31m error while create image: $imageName \033[0m\n"
21 | exit 1
22 | fi
23 | fi
24 |
25 | docker run -it --rm "$imageName" /bin/sh
26 |
27 |
28 |
--------------------------------------------------------------------------------
/docker/image/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM openjdk:8-jre-alpine
2 |
3 | ADD release /opt/jsonCodeGen
4 |
5 | RUN ln -s /opt/jsonCodeGen/jsonCodeGen.sh /usr/bin/jsonCodeGen
6 | ENV JSONCODEGEN_HOME=/opt/jsonCodeGen
7 | ENTRYPOINT ["jsonCodeGen"]
8 | CMD []
--------------------------------------------------------------------------------
/docker/image/release/conf/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 | w4aImp.log
11 |
12 |
13 | logFile.%d{yyyy-MM-dd}.log
14 |
15 | 30
16 |
17 |
18 | %d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/docker/image/release/jsonCodeGen.groovy:
--------------------------------------------------------------------------------
1 | /**
2 | * This is a platform independent start script for jsonCodeGen
3 | * Requirements:
4 | * Java 8
5 | * Groovy > 2.4.7
6 | * Created by eiko on 13.07.17.
7 | */
8 |
9 |
10 | scriptPos = new File(getClass().protectionDomain.codeSource.location.path).parent
11 |
12 | command = ['java','-cp',"$scriptPos/lib/*","-Dlogback.configurationFile=$scriptPos/conf/logback.xml",'de.lisaplus.atlas.DoCodeGen']
13 |
14 | args.each {
15 | command.add(it)
16 | }
17 |
18 | def sout = new StringBuilder(), serr = new StringBuilder()
19 | def proc = command.execute()
20 | proc.consumeProcessOutput(sout, serr)
21 | proc.waitForOrKill(10000)
22 | println "out> $sout err> $serr"
23 |
--------------------------------------------------------------------------------
/docker/image/release/jsonCodeGen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | scriptPos=${0%/*}
4 |
5 | if [ -z "$JAVACMD" ] ; then
6 | if [ -n "$JAVA_HOME" ] ; then
7 | # IBM's JDK on AIX uses strange locations for the executables
8 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
9 | JAVACMD="$JAVA_HOME/jre/sh/java"
10 | elif [ -x "$JAVA_HOME/jre/bin/java" ] ; then
11 | JAVACMD="$JAVA_HOME/jre/bin/java"
12 | else
13 | JAVACMD="$JAVA_HOME/bin/java"
14 | fi
15 | else
16 | JAVACMD=`which java 2> /dev/null `
17 | if [ -z "$JAVACMD" ] ; then
18 | JAVACMD=java
19 | fi
20 | fi
21 | fi
22 |
23 | if [ ! -x "$JAVACMD" ] ; then
24 | echo "Error: JAVA_HOME is not defined correctly."
25 | echo " We cannot execute $JAVACMD"
26 | exit 1
27 | fi
28 |
29 | case $OSTYPE in
30 | "cygwin"|"msys"|"win32")
31 | pathSep=";"
32 | ;;
33 | *)
34 | pathSep=":"
35 | ;;
36 | esac
37 |
38 | args=
39 | for arg in "$@";
40 | do
41 | args="$args \"$arg\""
42 | done
43 |
44 | if [ -d $scriptPos/lib ]; then
45 | JSONCODEGEN_LIB_DIR=$scriptPos/lib
46 | LOGDIR=$scriptPos/conf
47 | else
48 | JSONCODEGEN_LIB_DIR="$JSONCODEGEN_HOME/lib"
49 | LOGDIR="$JSONCODEGEN_HOME/conf"
50 | fi
51 |
52 | # preset for defining Java classes for DateType and DateTimeType, see JavaTypeConvert.groovy
53 | # Possible values are legacy,310.local,310.offset and 310.zoned
54 | preset=310.local
55 |
56 | if [ -z "$ADDITIONAL_TEMPLATE_DIR" ]; then
57 | "$JAVACMD" -cp "$JSONCODEGEN_LIB_DIR/*" "-Dlogback.configurationFile=$scriptPos/conf/logback.xml" "-Ddate.type.preset=$preset" de.lisaplus.atlas.DoCodeGen $args
58 | else
59 | # an additional direcotry with custom templates is give - needed for sub templates
60 | "$JAVACMD" -cp "$JSONCODEGEN_LIB_DIR/*$pathSep$ADDITIONAL_TEMPLATE_DIR" "-Dlogback.configurationFile=$scriptPos/conf/logback.xml" "-Ddate.type.preset=$preset" de.lisaplus.atlas.DoCodeGen $args
61 | fi
62 |
--------------------------------------------------------------------------------
/docker/image/release/lib/commons-lang3-3.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schlothauer-wauer/jsoncodegen/b5c69b0385ea73dba5a9f0bde9a69908e078c425/docker/image/release/lib/commons-lang3-3.3.jar
--------------------------------------------------------------------------------
/docker/image/release/lib/groovy-all-2.3.11.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schlothauer-wauer/jsoncodegen/b5c69b0385ea73dba5a9f0bde9a69908e078c425/docker/image/release/lib/groovy-all-2.3.11.jar
--------------------------------------------------------------------------------
/docker/image/release/lib/jcommander-1.69.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schlothauer-wauer/jsoncodegen/b5c69b0385ea73dba5a9f0bde9a69908e078c425/docker/image/release/lib/jcommander-1.69.jar
--------------------------------------------------------------------------------
/docker/image/release/lib/jsonCodeGen-0.11.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schlothauer-wauer/jsoncodegen/b5c69b0385ea73dba5a9f0bde9a69908e078c425/docker/image/release/lib/jsonCodeGen-0.11.3.jar
--------------------------------------------------------------------------------
/docker/image/release/lib/logback-classic-1.2.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schlothauer-wauer/jsoncodegen/b5c69b0385ea73dba5a9f0bde9a69908e078c425/docker/image/release/lib/logback-classic-1.2.3.jar
--------------------------------------------------------------------------------
/docker/image/release/lib/logback-core-1.2.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schlothauer-wauer/jsoncodegen/b5c69b0385ea73dba5a9f0bde9a69908e078c425/docker/image/release/lib/logback-core-1.2.3.jar
--------------------------------------------------------------------------------
/docker/image/release/lib/slf4j-api-1.7.25.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schlothauer-wauer/jsoncodegen/b5c69b0385ea73dba5a9f0bde9a69908e078c425/docker/image/release/lib/slf4j-api-1.7.25.jar
--------------------------------------------------------------------------------
/docker/image/release/lib/stax-api-1.0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schlothauer-wauer/jsoncodegen/b5c69b0385ea73dba5a9f0bde9a69908e078c425/docker/image/release/lib/stax-api-1.0.1.jar
--------------------------------------------------------------------------------
/docker/image/release/lib/xmlbeans-3.0.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/schlothauer-wauer/jsoncodegen/b5c69b0385ea73dba5a9f0bde9a69908e078c425/docker/image/release/lib/xmlbeans-3.0.0.jar
--------------------------------------------------------------------------------
/docs/main_structure.puml:
--------------------------------------------------------------------------------
1 | @startuml
2 | hide empty members
3 |
4 | interface IModelBuilder {
5 | Model buildModel(File modelFile)
6 | }
7 |
8 | note bottom of IModelBuilder
9 | Implementation creates
10 | meta model
11 |
12 | If you want implement
13 | your own builder, then
14 | implement this
15 | end note
16 |
17 | interface ICodeGen {
18 | void doCodeGen(Model model, Map extraParams)
19 | }
20 |
21 | note top of ICodeGen
22 | Implementation process
23 | meta model and generate
24 | desired stuff
25 |
26 | If you want implementIModelBuilder
27 | your own code generator, then
28 | implement this
29 | end note
30 |
31 |
32 | class DoCodeGen {
33 | void run()
34 | static void main(String ... args)
35 | }
36 |
37 | class JsonSchemaBuilder
38 | class SingleFileGenerator
39 | class MultiFileGenerator
40 | class JavaBeanGenerator
41 |
42 | note left of DoCodeGen
43 | start class that
44 | handles the code gen
45 | process
46 | end note
47 |
48 | note bottom of JsonSchemaBuilder
49 | builds
50 | from JSON schemas
51 | end note
52 |
53 | note bottom of JavaBeanGenerator
54 | builds simple
55 | Java beans from
56 | meta model
57 | end note
58 |
59 | DoCodeGen o-- IModelBuilder
60 | DoCodeGen o-- ICodeGen
61 |
62 | IModelBuilder <|-- JsonSchemaBuilder
63 | ICodeGen <|-- MultiFileGenerator
64 | ICodeGen <|-- SingleFileGenerator
65 |
66 | MultiFileGenerator <|-- JavaBeanGenerator
67 | SingleFileGenerator <|-- SwaggerGenerator
68 | class Model {
69 | List types
70 | }
71 |
72 | class Type {
73 | List properties
74 | }
75 |
76 | class Property {
77 | BaseType type
78 | }
79 |
80 | BaseType <|-- BooleanType
81 | BaseType <|-- ByteType
82 | BaseType <|-- MinMaxType
83 | BaseType <|-- ComplexType
84 | MinMaxType <|-- DateType
85 | MinMaxType <|-- DateTimeType
86 | MinMaxType <|-- IntType
87 | MinMaxType <|-- LongType
88 | MinMaxType <|-- NumberType
89 | BaseType <|-- RefType
90 | BaseType <|-- StringType
91 | BaseType <|-- ArrayType
92 | BaseType <|-- UnsupportedType
93 |
94 | Property o-- BaseType
95 | Type o-- Property
96 | Model o-- Type
97 |
98 | RefType o-- Type
99 | ICodeGen -- Model
100 |
101 | @enduml
102 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'jsonCodeGen'
2 |
3 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/JavaFileLoader.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas
2 |
3 | import com.beust.jcommander.JCommander
4 | import com.beust.jcommander.Parameter
5 | import com.beust.jcommander.ParameterException
6 | import de.lisaplus.atlas.builder.JsonSchemaBuilder
7 | import de.lisaplus.atlas.codegen.TemplateType
8 | import de.lisaplus.atlas.codegen.external.ExtMultiFileGenarator
9 | import de.lisaplus.atlas.codegen.external.ExtSingleFileGenarator
10 | import de.lisaplus.atlas.codegen.java.*
11 | import de.lisaplus.atlas.codegen.meta.*
12 | import de.lisaplus.atlas.interf.IExternalCodeGen
13 | import de.lisaplus.atlas.interf.IModelBuilder
14 | import de.lisaplus.atlas.model.Model
15 | import org.slf4j.Logger
16 | import org.slf4j.LoggerFactory
17 |
18 | import java.lang.reflect.Method
19 |
20 | /**
21 | * Main class to start the code generation
22 | * Created by eiko on 30.05.17.
23 | */
24 | class JavaFileLoader {
25 | @Parameter(names = [ '-t', '--template' ], description = "comma separated list of classes to load", required = true)
26 | String template
27 |
28 | @Parameter(names = ['-p', '--path'], description = "path to load the Java files")
29 | List paths = []
30 |
31 | @Parameter(names = ['-tp', '--template-parameter'], description = "special parameter that are passed to template via maps")
32 | List template_parameters = []
33 |
34 | @Parameter(names = ['-c', '--class'], description = "class to load")
35 | List classes = []
36 |
37 | @Parameter(names = ['-h','--help'], help = true)
38 | boolean help = false
39 |
40 | static void main(String ... args) {
41 | JavaFileLoader doCodeGen = new JavaFileLoader()
42 | try {
43 | JCommander jCommander = JCommander.newBuilder()
44 | .addObject(doCodeGen)
45 | .build()
46 | jCommander.setProgramName(doCodeGen.getClass().typeName)
47 | jCommander.parse(args)
48 | if (doCodeGen.help) {
49 | doCodeGen.printHelp()
50 | jCommander.usage()
51 | return
52 | }
53 | doCodeGen.run()
54 | }
55 | catch(ParameterException e) {
56 | e.usage()
57 | }
58 | }
59 |
60 | void run() {
61 | final GroovyClassLoader classLoader = new GroovyClassLoader()
62 | classLoader.addClasspath('/home/eiko/prog/gitg_swarco/lisa-junction-server/tmp/server/target/junction-server-1.0.0.jar')
63 | /*
64 | paths.forEach { path ->
65 | classLoader.addClasspath(path)
66 | }
67 | */
68 | /*
69 | classes.forEach { className ->
70 | Class c = classLoader.loadClass(className)
71 | Method[] methods = c.getMethods()
72 | }
73 | */
74 | Class c = classLoader.loadClass('BOOT-INF.classes.io.swagger.Swagger2SpringBoot$ExitException')
75 | Method[] methods = c.getMethods()
76 | }
77 |
78 |
79 | /**
80 | * splits extra generator parameter to Map values
81 | * expected entries looks like this: packageBase=de.sw.atlas
82 | * @param generator_parameters
83 | * @return
84 | */
85 | static Map getMapFromGeneratorParams(List generator_parameters) {
86 | Map map = [:]
87 | if (generator_parameters==null) {
88 | return map
89 | }
90 | generator_parameters.each { param ->
91 | String[] splittedParam = param.split('=')
92 | if (splittedParam.length!=2) {
93 | log.warn("extra generator parameter has wrong format and will be ignored: ${param}")
94 | }
95 | else {
96 | map.put(splittedParam[0].trim(),splittedParam[1].trim())
97 | }
98 | }
99 | return map
100 | }
101 |
102 | void printHelp() {
103 | InputStream usageFile = this.class.getClassLoader().getResourceAsStream('docs/usage.md')
104 | print (usageFile.getText())
105 | }
106 |
107 |
108 | private static final Logger log=LoggerFactory.getLogger(JavaFileLoader.class)
109 | }
110 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/builder/helper/BuildHelper.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.builder.helper
2 |
3 | /**
4 | * Created by eiko on 01.06.17.
5 | */
6 | class BuildHelper {
7 | static String strFromMap(def map,String key,String defValue=null) {
8 | def v = map[key]
9 | if (!v) v = defValue
10 | return v
11 | }
12 |
13 | static String string2Name(String s,boolean firstUpper=true) {
14 | def ret = s.replaceAll('[^a-zA-Z0-9]','_')
15 | if (firstUpper) {
16 | return ret.substring(0,1).toUpperCase()+makeCamelCase(ret.substring(1))
17 | }
18 | else {
19 | return ret.substring(0,1).toLowerCase()+makeCamelCase(ret.substring(1))
20 | }
21 | }
22 |
23 | static String makeCamelCase(String s) {
24 | if (!s) return s
25 | int i = s.indexOf('_')
26 | int txtLen = s.length()
27 | while (i!=-1) {
28 | if (i extraParams) {
21 | if (!template) {
22 | def errorMsg = "template not initialized"
23 | getLogger().error(errorMsg)
24 | throw new Exception(errorMsg)
25 | }
26 | def data = createTemplateDataMap(model)
27 | this.extraParams = extraParams
28 | if (extraParams) {
29 | data.extraParam = extraParams
30 | }
31 | else {
32 | data.extraParam = [:]
33 | }
34 |
35 | initGeneratorScriptForTemplate(data)
36 |
37 | def blackListed=data.extraParam['blackListed']
38 | def whiteListed=data.extraParam['whiteListed']
39 |
40 | def shouldRemoveEmptyLines = extraParams['removeEmptyLines']
41 |
42 | def neededAttrib = extraParams['containsAttrib']
43 | def missingAttrib = extraParams['missingAttrib']
44 | def neededTag = extraParams['neededTag']
45 | def neededTagList = splitValueToArray(neededTag)
46 |
47 | def ignoredTag = extraParams['ignoreTag']
48 | def ignoredTagList = splitValueToArray(ignoredTag)
49 | model.types*.each { type ->
50 | boolean handleNeeded = neededAttrib ? type.properties.find { prop ->
51 | return prop.name==neededAttrib
52 | } != null : true
53 | boolean handleMissing = missingAttrib ? type.properties.find { prop ->
54 | return prop.name==missingAttrib
55 | } == null : true
56 |
57 | boolean handleType=true;
58 | if (whiteListed && (!whiteListed.contains(type.name))) {
59 | handleType = false
60 | println "ingnored by white-list: ${type.name}"
61 | }
62 | else if (blackListed && blackListed.contains(type.name)) {
63 | handleType = false
64 | println "ingnored by black-list: ${type.name}"
65 | }
66 |
67 | boolean handleTag = ignoredTagList ? type.tags.find { tag ->
68 | return ignoredTagList.contains(tag)
69 | } == null : true
70 |
71 | if (handleTag && neededTagList) {
72 | boolean allTagsFound=true;
73 | neededTagList.each { needed ->
74 | if (!type.tags.contains(needed)) {
75 | allTagsFound = false
76 | }
77 | }
78 | handleTag = allTagsFound
79 | }
80 |
81 | if (handleType && handleNeeded && handleMissing && handleTag) {
82 | data.put('currentType', type)
83 | def ergebnis = template.make(data)
84 | def destFileName = getDestFileName(model, extraParams, type)
85 | def destDir = getDestDir(model, outputBasePath, extraParams, type)
86 | def pathToFile = "${destDir}/${destFileName}"
87 | File file = new File(pathToFile)
88 | def resultString = shouldRemoveEmptyLines ? removeEmptyLines(ergebnis.toString()) :
89 | ergebnis.toString()
90 | file.write(resultString)
91 | println ("written: $pathToFile")
92 | }
93 | }
94 | }
95 |
96 | private List splitValueToArray(String value) {
97 | if (!value) return []
98 | return value.indexOf(',')!=-1 ? value.split(',') : value.split(':')
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/TemplateType.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen
2 |
3 | /**
4 | * it ignores the XML template engine because there is no XML input
5 | */
6 | enum TemplateType {
7 | GString,
8 | Markup
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/external/ExtMultiFileGenarator.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.external
2 |
3 | import de.lisaplus.atlas.codegen.GeneratorBase
4 | import de.lisaplus.atlas.codegen.MultiFileGenarator
5 | import de.lisaplus.atlas.codegen.TemplateType
6 | import de.lisaplus.atlas.interf.ICodeGen
7 | import de.lisaplus.atlas.interf.IExternalCodeGen
8 | import de.lisaplus.atlas.model.Model
9 | import de.lisaplus.atlas.model.Type
10 | import org.slf4j.Logger
11 | import org.slf4j.LoggerFactory
12 |
13 | /**
14 | * Base class for generators that creates more than one file ... for instance JavaBeanGenerator
15 | * Created by eiko on 05.06.17.
16 | */
17 | class ExtMultiFileGenarator extends MultiFileGenarator implements IExternalCodeGen {
18 | @Override
19 | void initTemplateFromFile(String templateFile, TemplateType templateType) {
20 | template = createTemplateFromFile(templateFile,templateType)
21 | }
22 |
23 | @Override
24 | void initTemplateFromResource(String templateResource, TemplateType templateType) {
25 | template = createTemplateFromResource(templateFile,templateType)
26 | }
27 |
28 | @Override
29 | String getDestFileName(Model dataModel, Map extraParameters,Type currentType=null) {
30 | def destFileNameExt = extraParameters['destFileNameExt']
31 | def destFileNamePre = extraParameters['destFileNamePre'] ?: ''
32 | def destFileNamePost = extraParameters['destFileNamePost'] ?: ''
33 | def destFileCamelCaseName = extraParameters['destFileCamelCaseName']
34 | def destName = destFileNamePre + ( destFileCamelCaseName ? firstUpperCamelCase(currentType.name) : firstUpperCase(currentType.name) ) + destFileNamePost
35 | if (destFileNameExt) {
36 | destName = destName + "." + destFileNameExt
37 | }
38 | return destName
39 | }
40 |
41 | @Override
42 | String getDestDir(Model dataModel, String outputBasePath, Map extraParameters, Type currentType=null) {
43 | return outputBasePath
44 | }
45 |
46 | Logger getLogger() {
47 | return l
48 | }
49 | private static final Logger l=LoggerFactory.getLogger(ExtMultiFileGenarator.class)
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/external/ExtSingleFileGenarator.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.external
2 |
3 | import de.lisaplus.atlas.codegen.GeneratorBase
4 | import de.lisaplus.atlas.codegen.SingleFileGenarator
5 | import de.lisaplus.atlas.codegen.TemplateType
6 | import de.lisaplus.atlas.interf.ICodeGen
7 | import de.lisaplus.atlas.interf.IExternalCodeGen
8 | import de.lisaplus.atlas.model.Model
9 | import de.lisaplus.atlas.model.Type
10 | import org.slf4j.Logger
11 | import org.slf4j.LoggerFactory
12 |
13 | import static de.lisaplus.atlas.builder.helper.BuildHelper.string2Name
14 |
15 | /**
16 | * This is the published version of SingleFileGenerator. With external template it can be used for own generation
17 | * tasks
18 | * Created by eiko on 05.06.17.
19 | */
20 | class ExtSingleFileGenarator extends SingleFileGenarator implements IExternalCodeGen {
21 | @Override
22 | void initTemplateFromFile(String templateFile, TemplateType templateType) {
23 | template = createTemplateFromFile(templateFile,templateType)
24 | }
25 |
26 | @Override
27 | void initTemplateFromResource(String templateResource, TemplateType templateType) {
28 | template = createTemplateFromResource(templateFile,templateType)
29 | }
30 |
31 | @Override
32 | String getDestFileName(Model dataModel, Map extraParameters, Type currentType=null) {
33 | if (extraParameters.destFileName) {
34 | return extraParameters.destFileName
35 | }
36 | else {
37 | return string2Name("${dataModel.title}.swagger",false)
38 | }
39 | }
40 |
41 | @Override
42 | String getDestDir(Model dataModel, String outputBasePath, Map extraParameters,Type currentType=null) {
43 | if (extraParameters.outputDirExt) {
44 | return outputBasePath + "/" + extraParameters.outputDirExt
45 | }
46 | else {
47 | return outputBasePath
48 | }
49 | }
50 |
51 |
52 | Logger getLogger() {
53 | return l
54 | }
55 | private static final Logger l=LoggerFactory.getLogger(ExtSingleFileGenarator.class)
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/helper/java/DotnetTypeConvert.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.helper.java
2 |
3 | import de.lisaplus.atlas.model.*
4 |
5 | /**
6 | * Converts meta model types to Swagger used types
7 | * Created by eiko on 11.06.17.
8 | */
9 | class DotnetTypeConvert {
10 | static def convert = { type ->
11 | if (! type instanceof BaseType) {
12 | return BaseType.WRONG_TYPE+type
13 | }
14 | switch(type.name()) {
15 | case IntType.NAME:
16 | return type.isArray? 'List' : 'int'
17 | case LongType.NAME:
18 | return type.isArray? 'List' : 'long'
19 | case NumberType.NAME:
20 | return type.isArray? 'List' : 'double'
21 | case StringType.NAME:
22 | return type.isArray? 'List' : 'string'
23 | case UUIDType.NAME:
24 | return type.isArray? 'List' : 'Guid'
25 | case BooleanType.NAME:
26 | return type.isArray? 'List' : 'bool'
27 | case ByteType.NAME:
28 | return type.isArray? 'List' : 'byte'
29 | case DateType.NAME:
30 | return type.isArray? 'List' : 'DateTime'
31 | case DateTimeType.NAME:
32 | return type.isArray? 'List' : 'DateTime'
33 | case RefType.NAME:
34 | return type.type.name
35 | case ArrayType.NAME:
36 | return List
37 | case ComplexType.NAME: // ?
38 | return type.type.name
39 | case UnsupportedType.NAME:
40 | return "unsupported"
41 | default:
42 | return "???"
43 | }
44 | }
45 |
46 | static def meta = { type ->
47 | if (! type instanceof BaseType) {
48 | return BaseType.WRONG_TYPE+type
49 | }
50 | switch(type.name()) {
51 | case IntType.NAME:
52 | return 'integer'
53 | case LongType.NAME:
54 | return 'long'
55 | case NumberType.NAME:
56 | return 'number'
57 | case StringType.NAME:
58 | return 'string'
59 | case UUIDType.NAME:
60 | return 'string/uuid'
61 | case BooleanType.NAME:
62 | return 'boolean'
63 | case ByteType.NAME:
64 | return 'byte'
65 | case DateType.NAME:
66 | return 'string/date'
67 | case DateTimeType.NAME:
68 | return 'string/date-time'
69 | case RefType.NAME:
70 | return type.type.name
71 | case ComplexType.NAME: // ?
72 | return type.type.name
73 | case UnsupportedType.NAME:
74 | return "unsupported"
75 | default:
76 | return "???"
77 | }
78 | }
79 |
80 | static def format = { type ->
81 | switch(type.name()) {
82 | case IntType.NAME:
83 | return 'int64'
84 | case LongType.NAME:
85 | return 'int64'
86 | case NumberType.NAME:
87 | return 'double'
88 | case DateType.NAME:
89 | return 'date'
90 | case DateTimeType.NAME:
91 | return 'date-time'
92 | case UUIDType.NAME:
93 | return 'uuid'
94 | case UnsupportedType.NAME:
95 | return BaseType.UNSUPPORTED_TYPE+type
96 | default:
97 | return ''
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/helper/java/JsonTypeConvert.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.helper.java
2 |
3 | import de.lisaplus.atlas.model.*
4 |
5 | /**
6 | * Converts meta model types to Swagger used types
7 | * Created by eiko on 11.06.17.
8 | */
9 | class JsonTypeConvert {
10 | static def convert = { type ->
11 | if (! type instanceof BaseType) {
12 | return BaseType.WRONG_TYPE+type
13 | }
14 | switch(type.name()) {
15 | case IntType.NAME:
16 | return 'integer'
17 | case LongType.NAME:
18 | return 'integer'
19 | case NumberType.NAME:
20 | return 'number'
21 | case StringType.NAME:
22 | return 'string'
23 | case UUIDType.NAME:
24 | return 'string'
25 | case BooleanType.NAME:
26 | return 'boolean'
27 | case ByteType.NAME:
28 | return 'integer'
29 | case DateType.NAME:
30 | return 'string'
31 | case DateTimeType.NAME:
32 | return 'string'
33 | case RefType.NAME:
34 | return type.type.name
35 | case ComplexType.NAME: // ?
36 | return type.type.name
37 | case UnsupportedType.NAME:
38 | return "unsupported"
39 | default:
40 | return "???"
41 | }
42 | }
43 |
44 | static def meta = { type ->
45 | if (! type instanceof BaseType) {
46 | return BaseType.WRONG_TYPE+type
47 | }
48 | switch(type.name()) {
49 | case IntType.NAME:
50 | return 'integer'
51 | case LongType.NAME:
52 | return 'integer/int64'
53 | case NumberType.NAME:
54 | return 'number'
55 | case StringType.NAME:
56 | return 'string'
57 | case UUIDType.NAME:
58 | return 'string/uuid'
59 | case BooleanType.NAME:
60 | return 'boolean'
61 | case ByteType.NAME:
62 | return 'integer/byte'
63 | case DateType.NAME:
64 | return 'string/date'
65 | case DateTimeType.NAME:
66 | return 'string/date-time'
67 | case RefType.NAME:
68 | return type.type.name
69 | case ComplexType.NAME: // ?
70 | return type.type.name
71 | case UnsupportedType.NAME:
72 | return "unsupported"
73 | default:
74 | return "???"
75 | }
76 | }
77 |
78 | static def format = { type ->
79 | switch(type.name()) {
80 | case IntType.NAME:
81 | return 'int32'
82 | case LongType.NAME:
83 | return 'int64'
84 | case ByteType.NAME:
85 | return 'byte'
86 | case NumberType.NAME:
87 | return 'double'
88 | case DateType.NAME:
89 | return 'date'
90 | case DateTimeType.NAME:
91 | return 'date-time'
92 | case UUIDType.NAME:
93 | return 'uuid'
94 | case UnsupportedType.NAME:
95 | return BaseType.UNSUPPORTED_TYPE+type
96 | default:
97 | return ''
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/helper/java/SwaggerTypeConvert.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.helper.java
2 |
3 | import de.lisaplus.atlas.model.*
4 |
5 | /**
6 | * Converts meta model types to Swagger used types
7 | * Created by eiko on 11.06.17.
8 | */
9 | class SwaggerTypeConvert {
10 | static def convert = { type ->
11 | if (! type instanceof BaseType) {
12 | return BaseType.WRONG_TYPE+type
13 | }
14 | switch(type.name()) {
15 | case IntType.NAME:
16 | return 'integer'
17 | case LongType.NAME:
18 | return 'integer'
19 | case NumberType.NAME:
20 | return 'number'
21 | case StringType.NAME:
22 | return 'string'
23 | case UUIDType.NAME:
24 | return 'string'
25 | case BooleanType.NAME:
26 | return 'boolean'
27 | case ByteType.NAME:
28 | return 'integer'
29 | case DateType.NAME:
30 | return 'string'
31 | case DateTimeType.NAME:
32 | return 'string'
33 | case RefType.NAME:
34 | return type.type.name
35 | case ComplexType.NAME:
36 | return type.type.name
37 | case UnsupportedType.NAME:
38 | return BaseType.UNSUPPORTED_TYPE+type
39 | default:
40 | return BaseType.UNKNOWN_TYPE+type
41 | }
42 | }
43 |
44 | static def format = { type ->
45 | switch(type.name()) {
46 | case IntType.NAME:
47 | return 'int32'
48 | case LongType.NAME:
49 | return 'int64'
50 | case NumberType.NAME:
51 | return 'double'
52 | case DateType.NAME:
53 | return 'date'
54 | case DateTimeType.NAME:
55 | return 'date-time'
56 | case UnsupportedType.NAME:
57 | return BaseType.UNSUPPORTED_TYPE+type
58 | default:
59 | return ''
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/helper/java/TypeToColor.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.helper.java
2 |
3 | import de.lisaplus.atlas.model.Type
4 |
5 | /**
6 | * Created by eiko on 20.06.17.
7 | */
8 | class TypeToColor {
9 | /*
10 | static def colors = ['#3a5d0c', '#5d0c58', '#5d320c','#0c535d','#0c295d',
11 | '#5d0c5c','#d81309','#b97c1c','#b3b91c','#228a22',
12 | '#228a86','#22508a','#6b228a','#dc3a45','#dca53a',
13 | '#1a796a','#2b1acb','#89038b','#9f9f9e','#28692c'
14 | ]
15 | */
16 | static def colors = ['#ff0000', // red
17 | '#ff00ff', // pink
18 | '#0000ff', // blue
19 | '#007f00', // green
20 | '#7f007f', // purple
21 | '#ff6100', // orange
22 | '#00007f', // darker blue
23 | '#007f00', // darker green
24 | '#9b0000', // darker red
25 | '#5f005f' // dark purple
26 | ]
27 |
28 | static int akt = 0;
29 |
30 | static void setColor (Type type) {
31 | if (type.color=='#000000') {
32 | type.color = colors[akt % colors.size()]
33 | akt ++
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/java/JavaBeanGenerator.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.java
2 |
3 | import de.lisaplus.atlas.codegen.MultiFileGenarator
4 | import de.lisaplus.atlas.codegen.TemplateType
5 | import de.lisaplus.atlas.model.Model
6 | import de.lisaplus.atlas.model.Type
7 | import org.slf4j.Logger
8 | import org.slf4j.LoggerFactory
9 |
10 | /**
11 | * Created by eiko on 05.06.17.
12 | */
13 | class JavaBeanGenerator extends JavaGeneratorBase {
14 | private static final Logger log=LoggerFactory.getLogger(JavaBeanGenerator.class)
15 |
16 | void initTemplate() {
17 | template = createTemplateFromResource('templates/java/bean.txt',TemplateType.GString)
18 | }
19 |
20 | Logger getLogger() {
21 | return log
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/java/JavaGeneratorBase.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.java
2 |
3 | import de.lisaplus.atlas.codegen.MultiFileGenarator
4 | import de.lisaplus.atlas.codegen.TemplateType
5 | import de.lisaplus.atlas.model.Model
6 | import de.lisaplus.atlas.model.Type
7 | import org.slf4j.Logger
8 | import org.slf4j.LoggerFactory
9 |
10 | /**
11 | * Created by eiko on 05.06.17.
12 | */
13 | abstract class JavaGeneratorBase extends MultiFileGenarator {
14 | @Override
15 | String getDestFileName(Model dataModel, Map extraParameters, Type currentType=null) {
16 | String fileNameBase = firstUpperCamelCase(currentType.name)
17 | return "${fileNameBase}.java"
18 | }
19 |
20 | @Override
21 | String getDestDir(Model dataModel, String outputBasePath, Map extraParameters, Type currentType=null) {
22 | String destDirBase = extraParameters.outputDirExt ? outputBasePath + File.separator + extraParameters.outputDirExt : outputBasePath
23 | // Force linux/unix file separator, JVM can handle that on all plattforms!
24 | String packageStr = extraParameters.packageName ? extraParameters.packageName.replaceAll('\\.','/') : ''
25 | String destDirStr = "${destDirBase}${File.separator}${packageStr}"
26 | File destDir = new File(destDirStr)
27 | if (!destDir.exists()) destDir.mkdirs()
28 | return destDirStr
29 | }
30 |
31 | abstract void initTemplate()
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/java/JavaGenericDerivedBeanGenerator.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.java
2 |
3 | import de.lisaplus.atlas.codegen.TemplateType
4 | import org.slf4j.Logger
5 | import org.slf4j.LoggerFactory
6 |
7 | /**
8 | * Created by eiko on 05.06.17.
9 | */
10 | class JavaGenericDerivedBeanGenerator extends JavaGeneratorBase {
11 | private static final Logger log=LoggerFactory.getLogger(JavaGenericDerivedBeanGenerator.class)
12 |
13 | void initTemplate() {
14 | template = createTemplateFromResource('templates/java/generic_derived_bean.txt',TemplateType.GString)
15 | }
16 |
17 | Logger getLogger() {
18 | return log
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/java/JavaInterfaceGenerator.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.java
2 |
3 | import de.lisaplus.atlas.codegen.TemplateType
4 | import de.lisaplus.atlas.model.Model
5 | import de.lisaplus.atlas.model.Type
6 | import org.slf4j.Logger
7 | import org.slf4j.LoggerFactory
8 |
9 | /**
10 | * Created by eiko on 05.06.17.
11 | */
12 | class JavaInterfaceGenerator extends JavaGeneratorBase {
13 | private static final Logger log=LoggerFactory.getLogger(JavaInterfaceGenerator.class)
14 |
15 | @Override
16 | String getDestFileName(Model dataModel, Map extraParameters, Type currentType=null) {
17 | String fileNameBase = firstUpperCase(currentType.name)
18 | return "I${fileNameBase}.java"
19 | }
20 |
21 | void initTemplate() {
22 | template = createTemplateFromResource('templates/java/interface.txt',TemplateType.GString)
23 | }
24 |
25 | Logger getLogger() {
26 | return log
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/java/JavaInterfacedBeanGenerator.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.java
2 |
3 | import de.lisaplus.atlas.codegen.TemplateType
4 | import org.slf4j.Logger
5 | import org.slf4j.LoggerFactory
6 |
7 | /**
8 | * Created by eiko on 05.06.17.
9 | */
10 | class JavaInterfacedBeanGenerator extends JavaGeneratorBase {
11 | private static final Logger log=LoggerFactory.getLogger(JavaInterfacedBeanGenerator.class)
12 |
13 | void initTemplate() {
14 | template = createTemplateFromResource('templates/java/interfaced_bean.txt',TemplateType.GString)
15 | }
16 |
17 | Logger getLogger() {
18 | return log
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/java/JavaInterfacedGenericDerivedBeanGenerator.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.java
2 |
3 | import de.lisaplus.atlas.codegen.TemplateType
4 | import org.slf4j.Logger
5 | import org.slf4j.LoggerFactory
6 |
7 | /**
8 | * Created by eiko on 05.06.17.
9 | */
10 | class JavaInterfacedGenericDerivedBeanGenerator extends JavaGeneratorBase {
11 | private static final Logger log=LoggerFactory.getLogger(JavaInterfacedGenericDerivedBeanGenerator.class)
12 |
13 | void initTemplate() {
14 | template = createTemplateFromResource('templates/java/interfaced_generic_derived_bean.txt',TemplateType.GString)
15 | }
16 |
17 | Logger getLogger() {
18 | return log
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/java/MongoBeanGenerator.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.java
2 |
3 | import de.lisaplus.atlas.codegen.TemplateType
4 | import org.slf4j.Logger
5 | import org.slf4j.LoggerFactory
6 |
7 | /**
8 | * Created by eiko on 05.06.17.
9 | */
10 | class MongoBeanGenerator extends JavaGeneratorBase {
11 | private static final Logger log=LoggerFactory.getLogger(MongoBeanGenerator.class)
12 |
13 | void initTemplate() {
14 | template = createTemplateFromResource('templates/java/mongo_bean.txt',TemplateType.GString)
15 | }
16 |
17 | Logger getLogger() {
18 | return log
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/meta/HistModelGenerator.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.meta
2 |
3 | import de.lisaplus.atlas.codegen.SingleFileGenarator
4 | import de.lisaplus.atlas.codegen.TemplateType
5 | import de.lisaplus.atlas.model.Model
6 | import de.lisaplus.atlas.model.Type
7 | import org.slf4j.Logger
8 | import org.slf4j.LoggerFactory
9 |
10 | import static de.lisaplus.atlas.builder.helper.BuildHelper.string2Name
11 |
12 | /**
13 | * Created by eiko on 05.06.17.
14 | */
15 | class HistModelGenerator extends SingleFileGenarator {
16 | private static final Logger log=LoggerFactory.getLogger(HistModelGenerator.class)
17 |
18 | void initTemplate() {
19 | template = createTemplateFromResource('templates/meta/hist_model_schema.txt',TemplateType.GString)
20 | }
21 |
22 | @Override
23 | String getDestFileName(Model dataModel, Map extraParameters, Type currentType=null) {
24 | if (extraParameters.destFileName) {
25 | return extraParameters.destFileName
26 | }
27 | else {
28 | return "${string2Name(dataModel.title,false)}_hist.json"
29 | }
30 | }
31 |
32 | @Override
33 | String getDestDir(Model dataModel, String outputBasePath, Map extraParameters,Type currentType=null) {
34 | if (extraParameters.outputDirExt) {
35 | return outputBasePath + "/" + extraParameters.outputDirExt
36 | }
37 | else {
38 | return outputBasePath
39 | }
40 | }
41 |
42 | Logger getLogger() {
43 | return log
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/meta/JsonSchemaGenerator.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.meta
2 |
3 | import de.lisaplus.atlas.codegen.SingleFileGenarator
4 | import de.lisaplus.atlas.codegen.TemplateType
5 | import de.lisaplus.atlas.model.Model
6 | import de.lisaplus.atlas.model.Type
7 | import org.slf4j.Logger
8 | import org.slf4j.LoggerFactory
9 |
10 | import static de.lisaplus.atlas.builder.helper.BuildHelper.string2Name
11 |
12 | /**
13 | * Created by eiko on 05.06.17.
14 | */
15 | class JsonSchemaGenerator extends SingleFileGenarator {
16 | private static final Logger log=LoggerFactory.getLogger(JsonSchemaGenerator.class)
17 |
18 | void initTemplate() {
19 | template = createTemplateFromResource('templates/meta/json_schema.txt',TemplateType.GString)
20 | }
21 |
22 | @Override
23 | String getDestFileName(Model dataModel, Map extraParameters, Type currentType=null) {
24 | if (extraParameters.destFileName) {
25 | return extraParameters.destFileName
26 | }
27 | else {
28 | return "${string2Name(dataModel.title,false)}_schema.json"
29 | }
30 | }
31 |
32 | @Override
33 | String getDestDir(Model dataModel, String outputBasePath, Map extraParameters,Type currentType=null) {
34 | if (extraParameters.outputDirExt) {
35 | return outputBasePath + "/" + extraParameters.outputDirExt
36 | }
37 | else {
38 | return outputBasePath
39 | }
40 | }
41 |
42 | Logger getLogger() {
43 | return log
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/meta/PlantUmlGenerator.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.meta
2 |
3 | import de.lisaplus.atlas.codegen.SingleFileGenarator
4 | import de.lisaplus.atlas.codegen.TemplateType
5 | import de.lisaplus.atlas.model.Model
6 | import de.lisaplus.atlas.model.Type
7 | import org.slf4j.Logger
8 | import org.slf4j.LoggerFactory
9 |
10 | import static de.lisaplus.atlas.builder.helper.BuildHelper.string2Name
11 |
12 | /**
13 | * Created by eiko on 05.06.17.
14 | */
15 | class PlantUmlGenerator extends SingleFileGenarator {
16 | private static final Logger log=LoggerFactory.getLogger(PlantUmlGenerator.class)
17 |
18 | void initTemplate() {
19 | template = createTemplateFromResource('templates/meta/plantuml.txt',TemplateType.GString)
20 | }
21 |
22 | @Override
23 | String getDestFileName(Model dataModel, Map extraParameters, Type currentType=null) {
24 | if (extraParameters.destFileName) {
25 | return extraParameters.destFileName
26 | }
27 | else {
28 | if (dataModel.title) {
29 | return "${string2Name(dataModel.title,false)}.puml"
30 | }
31 | else {
32 | return "datamodel_${new Date().time}.puml"
33 | }
34 | }
35 | }
36 |
37 | @Override
38 | String getDestDir(Model dataModel, String outputBasePath, Map extraParameters,Type currentType=null) {
39 | if (extraParameters.outputDirExt) {
40 | return outputBasePath + "/" + extraParameters.outputDirExt
41 | }
42 | else {
43 | return outputBasePath
44 | }
45 | }
46 |
47 | Logger getLogger() {
48 | return log
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/meta/PlantUmlJavaGenerator.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.meta
2 |
3 | import de.lisaplus.atlas.codegen.SingleFileGenarator
4 | import de.lisaplus.atlas.codegen.TemplateType
5 | import de.lisaplus.atlas.model.Model
6 | import de.lisaplus.atlas.model.Type
7 | import org.slf4j.Logger
8 | import org.slf4j.LoggerFactory
9 |
10 | import static de.lisaplus.atlas.builder.helper.BuildHelper.string2Name
11 |
12 | /**
13 | * Created by eiko on 05.06.17.
14 | */
15 | class PlantUmlJavaGenerator extends SingleFileGenarator {
16 | private static final Logger log=LoggerFactory.getLogger(PlantUmlJavaGenerator.class)
17 |
18 | void initTemplate() {
19 | template = createTemplateFromResource('templates/meta/plantuml_java.txt',TemplateType.GString)
20 | }
21 |
22 | @Override
23 | String getDestFileName(Model dataModel, Map extraParameters, Type currentType=null) {
24 | if (extraParameters.destFileName) {
25 | return extraParameters.destFileName
26 | }
27 | else {
28 | if (dataModel.title) {
29 | return "${string2Name(dataModel.title,false)}.puml"
30 | }
31 | else {
32 | return "datamodel_${new Date().time}.puml"
33 | }
34 | }
35 | }
36 |
37 | @Override
38 | String getDestDir(Model dataModel, String outputBasePath, Map extraParameters,Type currentType=null) {
39 | if (extraParameters.outputDirExt) {
40 | return outputBasePath + "/" + extraParameters.outputDirExt
41 | }
42 | else {
43 | return outputBasePath
44 | }
45 | }
46 |
47 | Logger getLogger() {
48 | return log
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/meta/SwaggerGenerator.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.meta
2 |
3 | import de.lisaplus.atlas.codegen.SingleFileGenarator
4 | import de.lisaplus.atlas.codegen.TemplateType
5 | import de.lisaplus.atlas.model.Model
6 | import de.lisaplus.atlas.model.Type
7 | import org.slf4j.Logger
8 | import org.slf4j.LoggerFactory
9 |
10 | import static de.lisaplus.atlas.builder.helper.BuildHelper.string2Name
11 |
12 | /**
13 | * Created by eiko on 05.06.17.
14 | */
15 | class SwaggerGenerator extends SingleFileGenarator {
16 | private static final Logger log=LoggerFactory.getLogger(SwaggerGenerator.class)
17 |
18 | void initTemplate() {
19 | template = createTemplateFromResource('templates/meta/swagger_file.txt',TemplateType.GString)
20 | }
21 |
22 | @Override
23 | String getDestFileName(Model dataModel, Map extraParameters, Type currentType=null) {
24 | if (extraParameters.destFileName) {
25 | return extraParameters.destFileName
26 | }
27 | else {
28 | return "${string2Name(dataModel.title,false)}.swagger"
29 | }
30 | }
31 |
32 | @Override
33 | String getDestDir(Model dataModel, String outputBasePath, Map extraParameters,Type currentType=null) {
34 | if (extraParameters.outputDirExt) {
35 | return outputBasePath + "/" + extraParameters.outputDirExt
36 | }
37 | else {
38 | return outputBasePath
39 | }
40 | }
41 |
42 | Logger getLogger() {
43 | return log
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/meta/SwaggerGeneratorExt.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.meta
2 |
3 | import de.lisaplus.atlas.codegen.SingleFileGenarator
4 | import de.lisaplus.atlas.codegen.TemplateType
5 | import de.lisaplus.atlas.model.Model
6 | import de.lisaplus.atlas.model.Type
7 | import org.slf4j.Logger
8 | import org.slf4j.LoggerFactory
9 |
10 | import static de.lisaplus.atlas.builder.helper.BuildHelper.string2Name
11 |
12 | /**
13 | * Created by eiko on 05.06.17.
14 | */
15 | class SwaggerGeneratorExt extends SwaggerGenerator {
16 | private static final Logger log=LoggerFactory.getLogger(SwaggerGeneratorExt.class)
17 |
18 | @Override
19 | void initTemplate() {
20 | template = createTemplateFromResource('templates/meta/swagger_ext.txt',TemplateType.GString)
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/codegen/meta/XsdGenerator.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.meta
2 |
3 | import de.lisaplus.atlas.codegen.SingleFileGenarator
4 | import de.lisaplus.atlas.codegen.TemplateType
5 | import de.lisaplus.atlas.model.Model
6 | import de.lisaplus.atlas.model.Type
7 | import org.slf4j.Logger
8 | import org.slf4j.LoggerFactory
9 |
10 | import static de.lisaplus.atlas.builder.helper.BuildHelper.string2Name
11 |
12 | /**
13 | * Created by eiko on 05.06.17.
14 | */
15 | class XsdGenerator extends SingleFileGenarator {
16 | private static final Logger log=LoggerFactory.getLogger(XsdGenerator.class)
17 |
18 | void initTemplate() {
19 | template = createTemplateFromResource('templates/meta/xsd.txt',TemplateType.GString)
20 | }
21 |
22 | @Override
23 | String getDestFileName(Model dataModel, Map extraParameters, Type currentType=null) {
24 | if (extraParameters.destFileName) {
25 | return extraParameters.destFileName
26 | }
27 | else {
28 | return "${string2Name(dataModel.title,false)}.xsd"
29 | }
30 | }
31 |
32 | @Override
33 | String getDestDir(Model dataModel, String outputBasePath, Map extraParameters,Type currentType=null) {
34 | if (extraParameters.outputDirExt) {
35 | return outputBasePath + "/" + extraParameters.outputDirExt
36 | }
37 | else {
38 | return outputBasePath
39 | }
40 | }
41 |
42 | Logger getLogger() {
43 | return log
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/interf/ICodeGen.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.interf
2 |
3 | import de.lisaplus.atlas.model.Model
4 |
5 | /**
6 | * Created by eiko on 02.06.17.
7 | */
8 | interface ICodeGen {
9 | /**
10 | * This funkction is called to start the code generation process
11 | * @param model model that is the base for the code generation
12 | * @param outputBasePath under this path the output is generated. A generator can add a needed sub path if needed (for instance for packeges)
13 | * @param extraParams additional parameters to initialize the generator
14 | */
15 | void doCodeGen(Model model, String outputBasePath, Map extraParams)
16 | }
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/interf/IExternalCodeGen.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.interf
2 |
3 | import de.lisaplus.atlas.codegen.TemplateType
4 | import de.lisaplus.atlas.model.Model
5 |
6 | /**
7 | * Created by eiko on 02.06.17.
8 | */
9 | interface IExternalCodeGen extends ICodeGen {
10 | /**
11 | * initialize additional scripts that should be passed to the used templates
12 | * @param generatorScripts
13 | */
14 | void setGeneratorScript (String generatorScript)
15 |
16 | /**
17 | * initialize the template file for the generator
18 | * @param templateFile
19 | * @param templateType
20 | */
21 | void initTemplateFromFile(String templateFile, TemplateType templateType)
22 |
23 | /**
24 | * initialize the template resource for the generator
25 | * @param templateResource
26 | * @param templateType
27 | */
28 | void initTemplateFromResource(String templateResource, TemplateType templateType)
29 | }
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/interf/IModelBuilder.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.interf
2 |
3 | import de.lisaplus.atlas.model.Model
4 |
5 | /**
6 | * Created by eiko on 02.06.17.
7 | */
8 | interface IModelBuilder {
9 | Model buildModel(File modelFile)
10 | }
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/model/AggregationType.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.model
2 | /**
3 | * Type used in meta model
4 | * Created by eiko on 01.06.17.
5 | */
6 | enum AggregationType {
7 | aggregation, composition
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/model/ArrayType.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.model
2 | /**
3 | * Type used in meta model
4 | * Created by eiko on 01.06.17.
5 | */
6 | class ArrayType extends BaseType {
7 | BaseType baseType
8 | String name () {
9 | return NAME
10 | }
11 | final static NAME='ARRAY'
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/model/ComplexType.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.model
2 | /**
3 | * Type used in meta model
4 | * Created by eiko on 01.06.17.
5 | */
6 | class ComplexType extends BaseType {
7 | Type type
8 | String name () {
9 | return NAME
10 | }
11 | final static NAME='COMPLEX'
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/model/DateTimeType.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.model
2 | /**
3 | * Type used in meta model
4 | * Created by eiko on 01.06.17.
5 | */
6 | class DateTimeType extends MinMaxType {
7 | String name () {
8 | return NAME
9 | }
10 | final static NAME='DATETIME'
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/model/DateType.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.model
2 | /**
3 | * Type used in meta model
4 | * Created by eiko on 01.06.17.
5 | */
6 | class DateType extends MinMaxType {
7 | String name () {
8 | return NAME
9 | }
10 | final static NAME='DATE'
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/model/InnerType.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.model
2 |
3 | /**
4 | * this type is for inner declarations of complex types
5 | */
6 | class InnerType extends Type {
7 |
8 | InnerType() {
9 | super()
10 | }
11 |
12 | InnerType(InnerType type) {
13 | super()
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/model/MinMaxType.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.model;
2 | /**
3 | * Type used in meta model
4 | * Created by eiko on 01.06.17.
5 | */
6 | abstract class MinMaxType extends BaseType {
7 | def max
8 | def exclusiveMax
9 | def min
10 | def exclusiveMin
11 | }
12 |
13 | class IntType extends MinMaxType {
14 | String name () {
15 | return NAME
16 | }
17 | final static NAME='INT'
18 | }
19 |
20 | class LongType extends MinMaxType {
21 | String name () {
22 | return NAME
23 | }
24 | final static NAME='LONG'
25 | }
26 |
27 | class NumberType extends MinMaxType {
28 | String name () {
29 | return NAME
30 | }
31 | final static NAME='NUMBER'
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/groovy/de/lisaplus/atlas/model/RefType.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.model
2 | /**
3 | * Type used in meta model
4 | * Created by eiko on 01.06.17.
5 | */
6 | class RefType extends BaseType {
7 | def typeName
8 | Type type
9 |
10 | String name () {
11 | return NAME
12 | }
13 | final static NAME='REF'
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/src/main/resources/bin/jsonCodeGen.groovy:
--------------------------------------------------------------------------------
1 | /**
2 | * This is a platform independent start script for jsonCodeGen
3 | * Requirements:
4 | * Java 8
5 | * Groovy > 2.4.7
6 | * Created by eiko on 13.07.17.
7 | */
8 |
9 |
10 | scriptPos = new File(getClass().protectionDomain.codeSource.location.path).parent
11 |
12 | command = ['java','-cp',"$scriptPos/lib/*","-Dlogback.configurationFile=$scriptPos/conf/logback.xml",'de.lisaplus.atlas.DoCodeGen']
13 |
14 | args.each {
15 | command.add(it)
16 | }
17 |
18 | def sout = new StringBuilder(), serr = new StringBuilder()
19 | def proc = command.execute()
20 | proc.consumeProcessOutput(sout, serr)
21 | proc.waitForOrKill(10000)
22 | println "out> $sout err> $serr"
23 |
--------------------------------------------------------------------------------
/src/main/resources/bin/jsonCodeGen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | scriptPos=${0%/*}
4 |
5 | if [ -z "$JAVACMD" ] ; then
6 | if [ -n "$JAVA_HOME" ] ; then
7 | # IBM's JDK on AIX uses strange locations for the executables
8 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
9 | JAVACMD="$JAVA_HOME/jre/sh/java"
10 | elif [ -x "$JAVA_HOME/jre/bin/java" ] ; then
11 | JAVACMD="$JAVA_HOME/jre/bin/java"
12 | else
13 | JAVACMD="$JAVA_HOME/bin/java"
14 | fi
15 | else
16 | JAVACMD=`which java 2> /dev/null `
17 | if [ -z "$JAVACMD" ] ; then
18 | JAVACMD=java
19 | fi
20 | fi
21 | fi
22 |
23 | if [ ! -x "$JAVACMD" ] ; then
24 | echo "Error: JAVA_HOME is not defined correctly."
25 | echo " We cannot execute $JAVACMD"
26 | exit 1
27 | fi
28 |
29 | case $OSTYPE in
30 | "cygwin"|"msys"|"win32")
31 | pathSep=";"
32 | ;;
33 | *)
34 | pathSep=":"
35 | ;;
36 | esac
37 |
38 | args=
39 | for arg in "$@";
40 | do
41 | args="$args \"$arg\""
42 | done
43 |
44 | if [ -d $scriptPos/lib ]; then
45 | JSONCODEGEN_LIB_DIR=$scriptPos/lib
46 | LOGDIR=$scriptPos/conf
47 | else
48 | JSONCODEGEN_LIB_DIR="$JSONCODEGEN_HOME/lib"
49 | LOGDIR="$JSONCODEGEN_HOME/conf"
50 | fi
51 |
52 | # preset for defining Java classes for DateType and DateTimeType, see JavaTypeConvert.groovy
53 | # Possible values are legacy,310.local,310.offset and 310.zoned
54 | preset=310.local
55 |
56 | if [ -z "$ADDITIONAL_TEMPLATE_DIR" ]; then
57 | "$JAVACMD" -cp "$JSONCODEGEN_LIB_DIR/*" "-Dlogback.configurationFile=$scriptPos/conf/logback.xml" "-Ddate.type.preset=$preset" de.lisaplus.atlas.DoCodeGen $args
58 | else
59 | # an additional direcotry with custom templates is give - needed for sub templates
60 | "$JAVACMD" -cp "$JSONCODEGEN_LIB_DIR/*$pathSep$ADDITIONAL_TEMPLATE_DIR" "-Dlogback.configurationFile=$scriptPos/conf/logback.xml" "-Ddate.type.preset=$preset" de.lisaplus.atlas.DoCodeGen $args
61 | fi
62 |
--------------------------------------------------------------------------------
/src/main/resources/bin/jsonCodeGenDebug.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | scriptPos=${0%/*}
4 |
5 | if [ -z "$JAVACMD" ] ; then
6 | if [ -n "$JAVA_HOME" ] ; then
7 | # IBM's JDK on AIX uses strange locations for the executables
8 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
9 | JAVACMD="$JAVA_HOME/jre/sh/java"
10 | elif [ -x "$JAVA_HOME/jre/bin/java" ] ; then
11 | JAVACMD="$JAVA_HOME/jre/bin/java"
12 | else
13 | JAVACMD="$JAVA_HOME/bin/java"
14 | fi
15 | else
16 | JAVACMD=`which java 2> /dev/null `
17 | if [ -z "$JAVACMD" ] ; then
18 | JAVACMD=java
19 | fi
20 | fi
21 | fi
22 |
23 | if [ ! -x "$JAVACMD" ] ; then
24 | echo "Error: JAVA_HOME is not defined correctly."
25 | echo " We cannot execute $JAVACMD"
26 | exit 1
27 | fi
28 |
29 | case $OSTYPE in
30 | "cygwin"|"msys"|"win32")
31 | pathSep=";"
32 | ;;
33 | *)
34 | pathSep=":"
35 | ;;
36 | esac
37 |
38 | args=
39 | for arg in "$@";
40 | do
41 | args="$args \"$arg\""
42 | done
43 |
44 | if [ -d $scriptPos/lib ]; then
45 | JSONCODEGEN_LIB_DIR=$scriptPos/lib
46 | LOGDIR=$scriptPos/conf
47 | else
48 | JSONCODEGEN_LIB_DIR="$JSONCODEGEN_HOME/lib"
49 | LOGDIR="$JSONCODEGEN_HOME/conf"
50 | fi
51 |
52 | # preset for defining Java classes for DateType and DateTimeType, see JavaTypeConvert.groovy
53 | # Possible values are legacy,310.local,310.offset and 310.zoned
54 | preset=310.local
55 |
56 | if [ -z "$ADDITIONAL_TEMPLATE_DIR" ]; then
57 | "$JAVACMD" -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8100 -cp "$JSONCODEGEN_LIB_DIR/*" "-Dlogback.configurationFile=$scriptPos/conf/logback.xml" "-Ddate.type.preset=$preset" de.lisaplus.atlas.DoCodeGen $args
58 | else
59 | # an additional direcotry with custom templates is give - needed for sub templates
60 | "$JAVACMD" -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8100 -cp "$JSONCODEGEN_LIB_DIR/*$pathSep$ADDITIONAL_TEMPLATE_DIR" "-Dlogback.configurationFile=$scriptPos/conf/logback.xml" "-Ddate.type.preset=$preset" de.lisaplus.atlas.DoCodeGen $args
61 | fi
62 |
--------------------------------------------------------------------------------
/src/main/resources/conf/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 | w4aImp.log
11 |
12 |
13 | logFile.%d{yyyy-MM-dd}.log
14 |
15 | 30
16 |
17 |
18 | %d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/main/resources/docs/extensions.md:
--------------------------------------------------------------------------------
1 | # What are the extensions to the standard JSON schema
2 | ## Replace of standard version definition in a multi type schema
3 | Original Version property
4 | ```
5 | ...
6 | "type": "object",
7 | "properties": {
8 | "model_version": {
9 | "description": "version of the current model",
10 | "type": "number",
11 | "enum": [
12 | 1
13 | ],
14 | "maximum": 1,
15 | "minimum": 1
16 | },
17 | ...
18 | }
19 |
20 | ```
21 |
22 | Additional short version property
23 | ```
24 | "type": "object",
25 | "version" 1,
26 | ...
27 | ```
28 | The 'type' attribute has always an integer type
29 |
30 | ##Additional attributes for types
31 | * __tags - string array with additional tags/keywords that can be used select/deselect desired types for code generation
32 |
33 | ##Additional attributes for properties
34 | * __since - since what version the attribute is uses
35 | * __visKey - this attribute works as an visual communication key - for instance name
36 | * __unique - This attribute contains unique values
37 | * __ref - implicit reference of an ID type to another type
38 | * __tags - string array with additional tags/keywords that can be used select/deselect desired types for code generation
39 |
--------------------------------------------------------------------------------
/src/main/resources/templates/java/bean.txt:
--------------------------------------------------------------------------------
1 | <%
2 | boolean versionConst = extraParam.versionConst
3 |
4 | def memberVisibility = extraParam.memberVisibility && extraParam.memberVisibility.toLowerCase()=='protected' ? 'protected' : 'private'
5 | def hasUuid = !currentType.properties.findAll { it.type.name() == 'UUID'}.isEmpty()
6 | def importStr = hasUuid ? '\nimport java.util.UUID;\n' : ''
7 |
8 | %>package ${extraParam.packageName};
9 | ${importStr}
10 | // This class is generated by the jsonCodeGen bean template (bean.txt), changes have to implement there
11 |
12 | <% if ( currentType.description ) { %>
13 | /**
14 | * ${currentType.description}
15 | */
16 | <% }
17 | if (currentType instanceof de.lisaplus.atlas.model.EnumType) {
18 | %>public enum ${ upperCamelCase.call(currentType.name) } {
19 | <% boolean first=true; currentType.allowedValues.each { value ->
20 | if (first) {%>
21 | ${value}
22 | <% first=false} else { %>
23 | ,${value}
24 | <% } } %>
25 | }
26 | <% } else {
27 | %>public class ${ upperCamelCase.call(currentType.name) } {
28 | <% if (versionConst) {
29 | %>
30 | /**
31 | * Resulting from the model description
32 | */
33 | public final static int TYPE_VERSION=${currentType.version};
34 |
35 | /**
36 | * Version information for a concrete object. It can differ from model type version f.e. in
37 | * case of deserialization from message broker content
38 | */
39 | private Integer _objectVersion=${currentType.version};
40 |
41 | public void set_objectVersion(Integer version) {
42 | this._objectVersion = version;
43 | }
44 |
45 | public Integer get_objectVersion() {
46 | return this._objectVersion;
47 | }
48 |
49 | <% } %>
50 | <% currentType.properties.each { prop -> %>
51 | <% if (prop.description) {
52 | %>/**
53 | * ${prop.description}
54 | */
55 | <% }
56 | if (!prop.type.isArray) {
57 | %>${memberVisibility} ${ typeToJava.call(prop.type) } ${prop.name};
58 | <% } else {
59 | %>${memberVisibility} ${ typeToJava.call(prop.type) } ${prop.name} = new java.util.ArrayList<>();
60 | <% }
61 | %>
62 | public ${ typeToJava.call(prop.type) } get${ firstUpperCase.call(prop.name) } () { return this.${prop.name}; }
63 |
64 | public void set${ firstUpperCase.call(prop.name) } (${ typeToJava.call(prop.type) } ${prop.name}) {
65 | <% if (!prop.type.isArray) {
66 | %>this.${prop.name} = ${prop.name};
67 | <% } else {
68 | %>this.${prop.name} = ${prop.name}!=null ? ${prop.name} : new java.util.ArrayList<>();
69 | <% }
70 | %>
71 | }
72 |
73 | <% } %>
74 |
75 | @Override
76 | public boolean equals(Object obj) {
77 | if (obj==null) return false;
78 | if ( ! (obj instanceof ${ upperCamelCase.call(currentType.name) })) return false;
79 |
80 | ${ upperCamelCase.call(currentType.name) } _typeInst = (${ upperCamelCase.call(currentType.name) }) obj;
81 | // handling of non-array-types
82 | <% currentType.properties.findAll{ prop -> ! prop.type.isArray }.each { prop -> %>
83 | ${ typeToJava.call(prop.type) } _${prop.name} = _typeInst.get${ firstUpperCase.call(prop.name) } ();
84 | if (this.${prop.name} == null && _${prop.name} != null) return false;
85 | if (this.${prop.name} != null) {
86 | if (!this.${prop.name}.equals(_${prop.name})) return false;
87 | }
88 | <% } %>
89 | // handling of array-types
90 | <% currentType.properties.findAll{ prop -> prop.type.isArray }.each { prop -> %>
91 | ${ typeToJava.call(prop.type) } _${prop.name} = _typeInst.get${ firstUpperCase.call(prop.name) } ();
92 | if (this.${prop.name} == null && (_${prop.name} != null && _${prop.name}.size()>0)) return false;
93 | if (this.${prop.name} != null && this.${prop.name}.size()>0) {
94 | if (!this.${prop.name}.equals(_${prop.name})) return false;
95 | }
96 | <% } %>
97 | return true;
98 | }
99 |
100 | }
101 | <% } %>
--------------------------------------------------------------------------------
/src/main/resources/templates/java/generic_derived_bean.txt:
--------------------------------------------------------------------------------
1 | package ${extraParam.packageName};
2 |
3 | // This class is generated by the jsonCodeGen bean template (generic_derived_bean.txt), changes have to implement there
4 |
5 | <% if ( currentType.description ) { %>
6 | /**
7 | * ${currentType.description}
8 | */
9 | <% } %>
10 | public class ${ upperCamelCase.call(currentType.name) } extends ${extraParam.genericClass} <${ upperCamelCase.call(currentType.name) }> {
11 | <% currentType.properties.each { prop -> %>
12 | <% if (prop.description) {
13 | %>/**
14 | * ${prop.description}
15 | */
16 | <% }
17 | if (!prop.type.isArray) {
18 | %>${memberVisibility} ${ typeToJava.call(prop.type) } ${prop.name};
19 | <% } else {
20 | %>${memberVisibility} ${ typeToJava.call(prop.type) } ${prop.name} = new java.util.ArrayList<>();
21 | <% }
22 | %>
23 | public ${ typeToJava.call(prop.type) } get${ firstUpperCase.call(prop.name) } () { return this.${prop.name}; }
24 |
25 | public void set${ firstUpperCase.call(prop.name) } (${ typeToJava.call(prop.type) } ${prop.name}) {
26 | <% if (!prop.type.isArray) {
27 | %>this.${prop.name} = ${prop.name};
28 | <% } else {
29 | %>this.${prop.name} = ${prop.name}!=null ? ${prop.name} : new java.util.ArrayList<>();
30 | <% }
31 | %>
32 | }
33 |
34 | <% } %>
35 |
36 | @Override
37 | public boolean equals(Object obj) {
38 | if (obj==null) return false;
39 | if ( ! (obj instanceof ${ upperCamelCase.call(currentType.name) })) return false;
40 |
41 | ${ upperCamelCase.call(currentType.name) } _typeInst = (${ upperCamelCase.call(currentType.name) }) obj;
42 | // handling of non-array-types
43 | <% currentType.properties.findAll{ prop -> ! prop.type.isArray }.each { prop -> %>
44 | ${ typeToJava.call(prop.type) } _${prop.name} = _typeInst.get${ firstUpperCase.call(prop.name) } ();
45 | if (this.${prop.name} == null && _${prop.name} != null) return false;
46 | if (this.${prop.name} != null) {
47 | if (!this.${prop.name}.equals(_${prop.name})) return false;
48 | }
49 | <% } %>
50 | // handling of array-types
51 | <% currentType.properties.findAll{ prop -> prop.type.isArray }.each { prop -> %>
52 | ${ typeToJava.call(prop.type) } _${prop.name} = _typeInst.get${ firstUpperCase.call(prop.name) } ();
53 | if (this.${prop.name} == null && (_${prop.name} != null && _${prop.name}.size()>0)) return false;
54 | if (this.${prop.name} != null && this.${prop.name}.size()>0) {
55 | if (!this.${prop.name}.equals(_${prop.name})) return false;
56 | }
57 | <% } %>
58 | return true;
59 | }
60 | }
--------------------------------------------------------------------------------
/src/main/resources/templates/java/interface.txt:
--------------------------------------------------------------------------------
1 | package ${extraParam.packageName};
2 |
3 | <% if ( currentType.description ) { %>
4 | /**
5 | * ${currentType.description}
6 | */
7 | <% } %>
8 | public interface I${ firstUpperCase.call(currentType.name) } {
9 | <% currentType.properties.each { prop -> %>
10 | <% if (prop.description) { %>
11 | /**
12 | * ${prop.description}
13 | */
14 | <% } %>
15 | public ${ typeToJava.call(prop.type,'I') } get${ firstUpperCase.call(prop.name) } ();
16 | public void set${ firstUpperCase.call(prop.name) } (${ typeToJava.call(prop.type,'I') } ${prop.name});
17 | <% } %>
18 | }
--------------------------------------------------------------------------------
/src/main/resources/templates/java/interfaced_bean.txt:
--------------------------------------------------------------------------------
1 | package ${extraParam.packageName};
2 |
3 | <% if ( extraParam.interfacePackageName) { %>
4 | import ${extraParam.interfacePackageName}.*;
5 | <% } %>
6 |
7 |
8 | <% if ( currentType.description ) { %>
9 | /**
10 | * ${currentType.description}
11 | */
12 | <% } %>
13 | public class ${ upperCamelCase.call(currentType.name) } implements I${ firstUpperCase.call(currentType.name) } {
14 | <% currentType.properties.each { prop -> %>
15 | <% if (prop.description) { %>
16 | /**
17 | * ${prop.description}
18 | */
19 | <% } %>
20 | private ${ typeToJava.call(prop.type,'I') } ${prop.name};
21 |
22 | public ${ typeToJava.call(prop.type,'I') } get${ firstUpperCase.call(prop.name) } () { return this.${prop.name}; }
23 |
24 | public void set${ firstUpperCase.call(prop.name) } (${ typeToJava.call(prop.type,'I') } ${prop.name}) {
25 | this.${prop.name} = ${prop.name};
26 | }
27 |
28 | <% } %>
29 | }
--------------------------------------------------------------------------------
/src/main/resources/templates/java/interfaced_generic_derived_bean.txt:
--------------------------------------------------------------------------------
1 | package ${extraParam.packageName};
2 |
3 | <% if ( extraParam.interfacePackageName) { %>
4 | import ${extraParam.interfacePackageName}.*;
5 | <% } %>
6 |
7 |
8 | <% if ( currentType.description ) { %>
9 | /**
10 | * ${currentType.description}
11 | */
12 | <% } %>
13 | public class ${ upperCamelCase.call(currentType.name) } extends ${extraParam.genericClass} <${ upperCamelCase.call(currentType.name) }>
14 | implements I${ firstUpperCase.call(currentType.name) } {
15 | <% currentType.properties.each { prop -> %>
16 | <% if (prop.description) { %>
17 | /**
18 | * ${prop.description}
19 | */
20 | <% } %>
21 | private ${ typeToJava.call(prop.type,'I') } ${prop.name};
22 |
23 | public ${ typeToJava.call(prop.type,'I') } get${ firstUpperCase.call(prop.name) } () { return this.${prop.name}; }
24 |
25 | public void set${ firstUpperCase.call(prop.name) } (${ typeToJava.call(prop.type,'I') } ${prop.name}) {
26 | this.${prop.name} = ${prop.name};
27 | }
28 |
29 | <% } %>
30 | @Override
31 | public boolean equals(Object obj) {
32 | if (obj==null) return false;
33 | if ( ! (obj instanceof ${ upperCamelCase.call(currentType.name) })) return false;
34 |
35 | ${ upperCamelCase.call(currentType.name) } _typeInst = (${ upperCamelCase.call(currentType.name) }) obj;
36 | <% currentType.properties.each { prop -> %>
37 | ${ typeToJava.call(prop.type) } _${prop.name} = _typeInst.get${ firstUpperCase.call(prop.name) } ();
38 | if (this.${prop.name} == null && _${prop.name} != null) return false;
39 | if (this.${prop.name} != null) {
40 | if (!this.${prop.name}.equals(_${prop.name})) return false;
41 | }
42 | <% } %>
43 | return true;
44 | }
45 | }
--------------------------------------------------------------------------------
/src/main/resources/templates/meta/hist_model_schema.txt:
--------------------------------------------------------------------------------
1 | {
2 | "${DOLLAR}schema": "http://json-schema.org/draft-04/schema#",
3 | "title": "${model.title}",
4 | <% if ( model.description ) { %>
5 | "description": "${model.description}",
6 | <% } %>
7 | "definitions": {
8 | //// type for the meta data that contains the owner of the entry
9 | "meta_entry_data": {
10 | "type": "object",
11 | "properties": {
12 | "user": {
13 | "type": "string"
14 | },
15 | "entry_date": {
16 | "type": "string",
17 | "format": "date-time"
18 | },
19 | "active": {
20 | "type": "boolean"
21 | }
22 | }
23 | }
24 | //// Start of standard type handline
25 | <% model.types.each { type -> %>
26 | <% if (! type.isInnerType()) { %> //// Only not inner types need to be handled
27 | ,
28 | "${type.name}": {
29 | <% if (type.description) { %>
30 | "description": "${type.description}",
31 | <% } %>
32 | "type": "object",
33 | "properties": {
34 | <% boolean firstProp=true; type.properties.each { prop -> %>
35 | <% if (firstProp) { firstProp=false; } else { %>
36 | ,
37 | <% } %>
38 | //// call of an inner template to make the code more readable
39 | //// this also allow complext nested inner type consturcts
40 | ${renderInnerTemplate.call('templates/meta/sub/json_schema_attribs.txt',prop,10)}
41 | <% } %>
42 | <% if (!isInnerType.call(type)) { %>
43 | ,
44 | "meta_history": {
45 | "type": "array",
46 | "description": "array with the historical values of that entry",
47 | "items": {
48 | "${DOLLAR}ref": "#/definitions/${type.name}"
49 | }
50 | },
51 | "meta_entry": {
52 | "description": "data about entry creation",
53 | "${DOLLAR}ref": "#/definitions/meta_entry_data"
54 | }
55 | <% } %>
56 | }
57 | }
58 | <% } %>
59 | <% } %>
60 | },
61 | "type": "object"
62 | <% if ( model.version ) { %>
63 | ,"version": "${model.version}"
64 | <% } %>
65 | }
--------------------------------------------------------------------------------
/src/main/resources/templates/meta/hist_model_schema_orig.txt:
--------------------------------------------------------------------------------
1 | {
2 | "${DOLLAR}schema": "http://json-schema.org/draft-04/schema#",
3 | "title": "${model.title}",
4 | <% if ( model.description ) { %>
5 | "description": "${model.description}",
6 | <% } %>
7 | "definitions": {
8 | "meta_entry_data": {
9 | "type": "object",
10 | "properties": {
11 | "user": {
12 | "type": "string"
13 | },
14 | "entry_date": {
15 | "type": "string",
16 | "format": "date-time"
17 | },
18 | "active": {
19 | "type": "boolean"
20 | }
21 | }
22 | }
23 | <% model.types.each { type -> %>
24 | <% if (! type.isInnerType()) { %>
25 | ,
26 | "${toLowerCase.call(type.name)}": {
27 | <% if (type.description) { %>
28 | "description": "${type.description}",
29 | <% } %>
30 | "type": "object",
31 | "properties": {
32 | <% boolean firstProp=true; type.properties.each { prop -> %>
33 | <% if (firstProp) { firstProp=false; } else { %>
34 | ,
35 | <% } %>
36 | ${renderInnerTemplate.call('templates/meta/sub/json_schema_attribs.txt',prop,10)}
37 | <% } %>
38 | <% if (!isInnerType.call(type)) { %>
39 | ,
40 | "meta_history": {
41 | "type": "array",
42 | "items": {
43 | "${DOLLAR}ref": "#/definitions/${toLowerCase.call(type.name)}"
44 | }
45 | },
46 | "meta_entry": {
47 | "${DOLLAR}ref": "#/definitions/meta_entry_data"
48 | }
49 | <% } %>
50 | }
51 | }
52 | <% } %>
53 | <% } %>
54 | },
55 | "type": "object",
56 | <% if ( model.version ) { %>
57 | "version": "${model.version}"
58 | <% } %>
59 | }
--------------------------------------------------------------------------------
/src/main/resources/templates/meta/json_schema.txt:
--------------------------------------------------------------------------------
1 | {
2 | "${DOLLAR}schema": "http://json-schema.org/draft-04/schema#",
3 | "title": "${model.title}",
4 | <% if ( model.description ) { %>
5 | "description": "${model.description}",
6 | <% } %>
7 | "definitions": {
8 | <% boolean firstType=true; model.types.each { type -> %>
9 | <% if (firstType) { firstType=false; } else { %>
10 | ,
11 | <% } %>
12 | "${type.name}": {
13 | <% if (type.description) { %>
14 | "description": "${type.description}",
15 | <% } %>
16 | "type": "object",
17 | "properties": {
18 | <% boolean firstProp=true; type.properties.each { prop -> %>
19 | <% if (firstProp) { firstProp=false; } else { %>
20 | ,
21 | <% } %>
22 | ${renderInnerTemplate.call('templates/meta/sub/json_schema_attribs.txt',prop,10)}
23 | <% } %>
24 | }
25 | }
26 | <% } %>
27 | },
28 | "type": "object"
29 | <% if ( model.version ) { %>
30 | ,"version": "${model.version}"
31 | <% } %>
32 | }
--------------------------------------------------------------------------------
/src/main/resources/templates/meta/sub/json_schema_attribs.txt:
--------------------------------------------------------------------------------
1 | //define INDENT=${printIndent.call(indent)}
2 | //// write one property entry to the resulting json schema
3 | "${actObj.name}": {
4 | <% if (actObj.description) { %>
5 | ${printIndent.call(indent)} "description": "${actObj.description}",
6 | <% } %>
7 | <% if (actObj.type.isArray) { %>
8 | //// the property is an arraytype
9 | INDENT "type": "array",
10 | INDENT "items": {
11 | <% if (actObj.isRefType()) { %>
12 | INDENT "${DOLLAR}ref": "#/definitions/${actObj.type.type.name}"
13 | <% } else if (actObj.isComplexType() ) { %>
14 |
15 | INDENT "type": "object",
16 | INDENT "properties": {
17 | <% boolean firstProp=true; actObj.type.type.properties.each { prop -> %>
18 | <% if (firstProp) { firstProp=false; } else { %>
19 | INDENT ,
20 | <% } %>
21 | INDENT ${renderInnerTemplate.call('templates/meta/sub/json_schema_attribs.txt',prop,indent+6)}
22 | <% } %>
23 | INDENT }
24 |
25 | <% } else { %>
26 | <% if (typeFormatToJson.call(actObj.type)) { %>
27 | INDENT "type": "${typeToJson.call(actObj.type)}",
28 | INDENT "format": "${typeFormatToJson.call(actObj.type)}"
29 | <% } else { %>
30 | INDENT "type": "${typeToJson.call(actObj.type)}"
31 | <% } %>
32 | <% if (actObj.implicitRef) { %>
33 | <% if (actObj.implicitRefIsRefType()) { %>
34 | INDENT ,"ref": "#/definitions/${actObj.implicitRef.type.name}"
35 | <% } else if (actObj.implicitRefIsComplexType() ) { %>
36 | INDENT ,"ref": "#/definitions/${actObj.implicitRef.name}"
37 | <% }%>
38 | <% } %>
39 | <% } %>
40 | INDENT }
41 | <% } else { %>
42 | //// the property is no arraytype
43 | <% if (actObj.isRefType()) { %>
44 | INDENT "${DOLLAR}ref": "#/definitions/${actObj.type.type.name}"
45 | <% } else if (actObj.isComplexType() ) { %>
46 | INDENT "type": "object",
47 | INDENT "properties": {
48 | <% boolean firstProp=true; actObj.type.type.properties.each { prop -> %>
49 | <% if (firstProp) { firstProp=false; } else { %>
50 | INDENT ,
51 | <% } %>
52 | INDENT ${renderInnerTemplate.call('templates/meta/sub/json_schema_attribs.txt',prop,indent+2)}
53 | <% } %>
54 | INDENT }
55 | <% } else { %>
56 | <% if (typeFormatToJson.call(actObj.type)) { %>
57 | INDENT "type": "${typeToJson.call(actObj.type)}",
58 | INDENT "format": "${typeFormatToJson.call(actObj.type)}"
59 | <% } else { %>
60 | INDENT "type": "${typeToJson.call(actObj.type)}"
61 | <% } %>
62 | //// handle the case that the property is for instance a string type with a guid and points
63 | //// implizit to another type
64 | <% if (actObj.implicitRef) { %>
65 | <% if (actObj.implicitRefIsRefType()) { %>
66 | INDENT ,"ref": "#/definitions/${actObj.implicitRef.type.name}"
67 | <% } else if (actObj.implicitRefIsComplexType() ) { %>
68 | INDENT ,"ref": "#/definitions/${actObj.implicitRef.name}"
69 | <% }%>
70 | <% } %>
71 | <% } %>
72 | <% } %>
73 | INDENT}
74 |
--------------------------------------------------------------------------------
/src/main/resources/templates/meta/sub/json_schema_attribs_orig.txt:
--------------------------------------------------------------------------------
1 | "${toLowerCase.call(actObj.name)}": {
2 | <% if (actObj.description) { %>
3 | ${printIndent.call(indent)} "description": "${actObj.description}",
4 | <% } %>
5 | <% if (actObj.type.isArray) { %>
6 | ${printIndent.call(indent)} "type": "array",
7 | ${printIndent.call(indent)} "items": {
8 | <% if (actObj.isRefType()) { %>
9 | ${printIndent.call(indent)} "${DOLLAR}ref": "#/definitions/${toLowerCase.call(actObj.type.type.name)}"
10 | <% } else if (actObj.isComplexType() ) { %>
11 |
12 | ${printIndent.call(indent)} "type": "object",
13 | ${printIndent.call(indent)} "properties": {
14 | <% boolean firstProp=true; actObj.type.type.properties.each { prop -> %>
15 | <% if (firstProp) { firstProp=false; } else { %>
16 | ${printIndent.call(indent)} ,
17 | <% } %>
18 | ${printIndent.call(indent)} ${renderInnerTemplate.call('templates/meta/sub/json_schema_attribs.txt',prop,indent+6)}
19 | <% } %>
20 | ${printIndent.call(indent)} }
21 |
22 | <% } else { %>
23 | <% if (typeFormatToJson.call(actObj.type)) { %>
24 | ${printIndent.call(indent)} "type": "${typeToJson.call(actObj.type)}",
25 | ${printIndent.call(indent)} "format": "${typeFormatToJson.call(actObj.type)}"
26 | <% } else { %>
27 | ${printIndent.call(indent)} "type": "${typeToJson.call(actObj.type)}"
28 | <% } %>
29 | <% if (actObj.implicitRef) { %>
30 | <% if (actObj.implicitRefIsRefType()) { %>
31 | ${printIndent.call(indent)} ,"ref": "#/definitions/${toLowerCase.call(actObj.implicitRef.type.name)}"
32 | <% } else if (actObj.implicitRefIsComplexType() ) { %>
33 | ${printIndent.call(indent)} ,"ref": "#/definitions/${toLowerCase.call(actObj.implicitRef.name)}"
34 | <% }%>
35 | <% } %>
36 | <% } %>
37 | ${printIndent.call(indent)} }
38 | <% } else { %>
39 | <% if (actObj.isRefType()) { %>
40 | ${printIndent.call(indent)} "${DOLLAR}ref": "#/definitions/${toLowerCase.call(actObj.type.type.name)}"
41 | <% } else if (actObj.isComplexType() ) { %>
42 |
43 |
44 | ${printIndent.call(indent)} "type": "object",
45 | ${printIndent.call(indent)} "properties": {
46 | <% boolean firstProp=true; actObj.type.type.properties.each { prop -> %>
47 | <% if (firstProp) { firstProp=false; } else { %>
48 | ${printIndent.call(indent)} ,
49 | <% } %>
50 | ${printIndent.call(indent)} ${renderInnerTemplate.call('templates/meta/sub/json_schema_attribs.txt',prop,indent+2)}
51 | <% } %>
52 | ${printIndent.call(indent)} }
53 |
54 |
55 | <% } else { %>
56 | <% if (typeFormatToJson.call(actObj.type)) { %>
57 | ${printIndent.call(indent)} "type": "${typeToJson.call(actObj.type)}",
58 | ${printIndent.call(indent)} "format": "${typeFormatToJson.call(actObj.type)}"
59 | <% } else { %>
60 | ${printIndent.call(indent)} "type": "${typeToJson.call(actObj.type)}"
61 | <% } %>
62 | <% if (actObj.implicitRef) { %>
63 | <% if (actObj.implicitRefIsRefType()) { %>
64 | ${printIndent.call(indent)} ,"ref": "#/definitions/${toLowerCase.call(actObj.implicitRef.type.name)}"
65 | <% } else if (actObj.implicitRefIsComplexType() ) { %>
66 | ${printIndent.call(indent)} ,"ref": "#/definitions/${toLowerCase.call(actObj.implicitRef.name)}"
67 | <% }%>
68 | <% } %>
69 | <% } %>
70 | <% } %>
71 | ${printIndent.call(indent)}}
72 |
--------------------------------------------------------------------------------
/src/main/resources/templates/meta/xsd.txt:
--------------------------------------------------------------------------------
1 | <%
2 | def targetNameSpace = extraParam.targetNamespace ? extraParam.targetNamespace : 'http://please.change.org/use/targetNamespace/generator/param/1.0'
3 |
4 | def printOccurs = { propType ->
5 | if (propType.isArray) {
6 | return ' minOccurs="0" maxOccurs="unbounded"'
7 | }
8 | else {
9 | return ''
10 | }
11 | }
12 |
13 | def typeConvert = { type ->
14 | if (! type instanceof de.lisaplus.atlas.model.BaseType) {
15 | return BaseType.WRONG_TYPE+type
16 | }
17 | switch(type.name()) {
18 | case de.lisaplus.atlas.model.IntType.NAME:
19 | return 'xsd:integer'
20 | case de.lisaplus.atlas.model.LongType.NAME:
21 | return 'xsd:long'
22 | case de.lisaplus.atlas.model.NumberType.NAME:
23 | return 'xsd:double'
24 | case de.lisaplus.atlas.model.StringType.NAME:
25 | return 'xsd:string'
26 | case de.lisaplus.atlas.model.UUIDType.NAME:
27 | return 'Guid'
28 | case de.lisaplus.atlas.model.BooleanType.NAME:
29 | return 'xsd:boolean'
30 | case de.lisaplus.atlas.model.ByteType.NAME:
31 | return 'xsd:byte'
32 | case de.lisaplus.atlas.model.DateType.NAME:
33 | return 'xsd:date'
34 | case de.lisaplus.atlas.model.DateTimeType.NAME:
35 | return 'xsd:dateTime'
36 | case de.lisaplus.atlas.model.RefType.NAME:
37 | return type.type.name
38 | case de.lisaplus.atlas.model.ComplexType.NAME: // ?
39 | return type.type.name
40 | case de.lisaplus.atlas.model.UnsupportedType.NAME:
41 | return "Unsupported"
42 | default:
43 | return "???"
44 | }
45 | }
46 |
47 | def hasUnsupportedType = model.types.find { type ->
48 | type.properties.find { prop ->
49 | prop.type instanceof de.lisaplus.atlas.model.UnsupportedType
50 | } != null
51 | }
52 |
53 | def hasGuidType = model.types.find { type ->
54 | type.properties.find { prop ->
55 | prop.type instanceof de.lisaplus.atlas.model.UUIDType
56 | } != null
57 | }
58 |
59 | %>
64 |
65 | <% if (hasUnsupportedType) {
66 | %>
67 |
68 |
69 | <% } %>
70 | <% if (hasGuidType) {
71 | %>
72 |
73 |
74 |
75 |
76 | <% } %>
77 |
78 | <% model.types.each { type ->
79 | %>
80 | <% if (type.description) {
81 | %>
82 | ${type.description}
83 |
84 | <% } %>
85 |
86 | <% type.properties.each { prop ->
87 | %>
88 | <% if (prop.description) {
89 | %>
90 | ${prop.description}
91 |
92 | <% } %>
93 |
94 | <% } %>
95 |
96 |
97 |
98 | <% } %>
99 |
--------------------------------------------------------------------------------
/src/test/groovy/de/lisaplus/atlas/Model.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas
2 |
3 | import org.junit.Test
4 |
5 | import static org.junit.Assert.assertEquals
6 | import static org.junit.Assert.assertTrue
7 |
8 | /**
9 | * Meta model tests
10 | * Created by eiko on 23.06.17.
11 | */
12 | class Model {
13 | @Test
14 | void testInitRefOwner() {
15 | def modelFile = new File('src/test/resources/test_schemas/ds/user.json')
16 | assertTrue(modelFile.isFile())
17 | def builder = new de.lisaplus.atlas.builder.JsonSchemaBuilder()
18 | def model = builder.buildModel(modelFile)
19 | def typeName='Domain'
20 | boolean found=false
21 | model.types.find { it.name==typeName }.each { type ->
22 | found=true
23 | assertEquals(0,type.refOwner.size())
24 | }
25 | assertTrue(found)
26 | typeName='Application'
27 | found=false
28 | model.types.find { it.name==typeName }.each { type ->
29 | found=true
30 | assertEquals(0,type.refOwner.size())
31 | }
32 | assertTrue(found)
33 | typeName='AppModule'
34 | found=false
35 | model.types.find { it.name==typeName }.each { type ->
36 | found=true
37 | // because inner type are ignored
38 | assertEquals(0,type.refOwner.size())
39 | }
40 | assertTrue(found)
41 | typeName='Role'
42 | found=false
43 | model.types.find { it.name==typeName }.each { type ->
44 | found=true
45 | assertEquals(1,type.refOwner.size())
46 | }
47 | assertTrue(found)
48 | typeName='User'
49 | found=false
50 | model.types.find { it.name==typeName }.each { type ->
51 | found=true
52 | assertEquals(0,type.refOwner.size())
53 | }
54 | assertTrue(found)
55 | typeName='UserLog'
56 | found=false
57 | model.types.find { it.name==typeName }.each { type ->
58 | found=true
59 | assertEquals(0,type.refOwner.size())
60 | }
61 | assertTrue(found)
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/test/groovy/de/lisaplus/atlas/ModelTestHelper.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas
2 |
3 | import de.lisaplus.atlas.model.RefType
4 |
5 | import static org.junit.Assert.*
6 |
7 | /**
8 | * Created by eiko on 02.06.17.
9 | */
10 | class ModelTestHelper {
11 | static void checkPropertySize (def model, def typeName,def expectedSize) {
12 | def found = false
13 | model.types.find { it.name==typeName }.each {
14 | found = true
15 | assertEquals(expectedSize,it.properties.size())
16 | }
17 | assertTrue(found)
18 | }
19 |
20 | static void compareProperty (def expectedProperty,def model,def typeName) {
21 | def propName = expectedProperty.name
22 | def found = false
23 | model.types.find { it.name==typeName }.properties.find { it.name==propName }.each {
24 | found = true
25 | assertEquals(expectedProperty.name,it.name)
26 | assertEquals(expectedProperty.description,it.description)
27 | assertEquals(expectedProperty.type.class,it.type.class)
28 | assertEquals(expectedProperty.type.isArray,it.type.isArray)
29 | if (expectedProperty.type instanceof RefType ) {
30 | assertEquals(expectedProperty.type.typeName,it.type.typeName)
31 | }
32 | }
33 | assertTrue(found)
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/groovy/de/lisaplus/atlas/builder/test/jsonschema/ArrayTests.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.builder.test.jsonschema
2 |
3 | import de.lisaplus.atlas.ModelTestHelper
4 | import de.lisaplus.atlas.builder.JsonSchemaBuilder
5 | import de.lisaplus.atlas.codegen.test.base.FileHelper
6 | import de.lisaplus.atlas.model.Property
7 | import de.lisaplus.atlas.model.StringType
8 | import org.junit.Test
9 |
10 | import static org.junit.Assert.*
11 |
12 | /**
13 | * Created by eiko on 02.06.17.
14 | */
15 | class ArrayTests {
16 | @Test
17 | void test_initModel() {
18 | def modelFile = new File('src/test/resources/test_schemas/ds/array_test_simple.json')
19 | assertTrue(modelFile.isFile())
20 | def builder = new JsonSchemaBuilder()
21 | def model = builder.buildModel(modelFile)
22 | assertEquals(model.description,'Test user model')
23 | assertEquals('User model',model.title)
24 | assertEquals(4,model.types.size())
25 | }
26 |
27 | @Test
28 | void test_initModelWithEnums() {
29 | def modelFile = new File('src/test/resources/test_schemas/ds/array_test_simple.json')
30 | assertTrue(modelFile.isFile())
31 | def builder = new JsonSchemaBuilder()
32 | builder.createEnumTypes = true
33 | def model = builder.buildModel(modelFile)
34 | assertEquals(model.description,'Test user model')
35 | assertEquals('User model',model.title)
36 | assertEquals(6,model.types.size())
37 | }
38 |
39 | @Test
40 | void testContainsAttrib() {
41 | def destDir = 'tmp/array_tests'
42 | FileHelper.removeDirectoryIfExists(destDir)
43 | def modelFile = new File('src/test/resources/test_schemas/ds/array_test_simple.json')
44 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
45 | doCodeGen.models = [modelFile]
46 | doCodeGen.generators.add('java_beans')
47 | doCodeGen.outputBaseDir = destDir
48 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
49 | doCodeGen.generator_parameters.add('packageName=de.test2.jsoncodegen.impl')
50 | doCodeGen.run()
51 | /*
52 | assertTrue(new File('tmp/java_beans/de/test2/jsoncodegen/impl/Role.java').exists())
53 | assertTrue(new File('tmp/java_beans/de/test2/jsoncodegen/impl/User.java').exists())
54 | assertTrue(new File('tmp/java_beans/de/test2/jsoncodegen/impl/UserLog.java').exists())
55 | new File('tmp/java_beans/de/test2/jsoncodegen/impl').listFiles(new FileFilter() {
56 | @Override
57 | boolean accept(File file) {
58 | return file.isFile()
59 | }
60 | }).size()==3
61 | */
62 | }
63 |
64 |
65 | void test_initModel2() {
66 | def modelFile = new File('src/test/resources/test_schemas/ds/array_test.json')
67 | assertTrue(modelFile.isFile())
68 | def builder = new JsonSchemaBuilder()
69 | def model = builder.buildModel(modelFile)
70 | assertEquals(model.description,'Test user model')
71 | assertEquals('User model',model.title)
72 | assertEquals(7,model.types.size())
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/test/groovy/de/lisaplus/atlas/builder/test/jsonschema/MultiTypeSchema.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.builder.test.jsonschema
2 |
3 | import de.lisaplus.atlas.ModelTestHelper
4 | import de.lisaplus.atlas.builder.JsonSchemaBuilder
5 | import de.lisaplus.atlas.model.ComplexType
6 | import de.lisaplus.atlas.model.Property
7 | import de.lisaplus.atlas.model.RefType
8 | import de.lisaplus.atlas.model.StringType
9 | import de.lisaplus.atlas.model.UnsupportedType
10 | import org.junit.Test
11 | import static org.junit.Assert.*
12 |
13 | /**
14 | * Created by eiko on 02.06.17.
15 | */
16 | class MultiTypeSchema {
17 | @Test
18 | void test_initModel() {
19 | def modelFile = new File('src/test/resources/test_schemas/multiType.json')
20 | assertTrue(modelFile.isFile())
21 | def builder = new JsonSchemaBuilder()
22 | def model = builder.buildModel(modelFile)
23 | assertEquals(model.description,'This is a multi type test schema :)')
24 | assertEquals(model.title,'JSON schema for multi type testing')
25 | assertEquals(1,model.version)
26 | assertEquals(5,model.types.size())
27 | def typeName = 'Action'
28 | ModelTestHelper.checkPropertySize(model,typeName,3)
29 | ModelTestHelper.compareProperty (new Property(
30 | name: 'defaultTitle',
31 | description: 'Tooltip for the main toolbar icon.',
32 | type: new StringType()
33 | ),model,typeName)
34 | ModelTestHelper.compareProperty (new Property(
35 | name: 'defaultPopup',
36 | description: 'The popup appears when the user clicks the icon.',
37 | type: new RefType(typeName: 'Icon')
38 | ),model,typeName)
39 | ModelTestHelper.compareProperty (new Property(
40 | name: 'defaultIcon',
41 | description: 'Icon for the main toolbar.',
42 | type: new ComplexType()
43 | ),model,typeName)
44 |
45 | typeName = 'Command'
46 | ModelTestHelper.checkPropertySize(model,typeName,2)
47 | ModelTestHelper.compareProperty (new Property(
48 | name: 'description',
49 | description: null,
50 | type: new StringType()
51 | ),model,typeName)
52 | ModelTestHelper.compareProperty (new Property(
53 | name: 'suggestedKey',
54 | description: null,
55 | type: new UnsupportedType()
56 | ),model,typeName)
57 | }
58 |
59 | /**
60 | * Additional tests for lisa server data models ... runs only if the related project is available
61 | */
62 | @Test
63 | void testComplexIncludes() {
64 | File f1 = new File('.')
65 | def s = f1.getAbsolutePath()
66 |
67 | File f = new File('../../gitlab/lisa-server_models/model/junction.json')
68 | if (f.exists()) {
69 | def builder = new JsonSchemaBuilder()
70 | def model = builder.buildModel(f)
71 | assertNotNull(model)
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/test/groovy/de/lisaplus/atlas/builder/test/jsonschema/SingleTypeSchema.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.builder.test.jsonschema
2 |
3 | import de.lisaplus.atlas.ModelTestHelper
4 | import de.lisaplus.atlas.builder.JsonSchemaBuilder
5 | import de.lisaplus.atlas.model.Property
6 | import de.lisaplus.atlas.model.StringType
7 | import org.junit.Test
8 | import static org.junit.Assert.*
9 |
10 | /**
11 | * Created by eiko on 02.06.17.
12 | */
13 | class SingleTypeSchema {
14 | @Test
15 | void test_initModel() {
16 | def modelFile = new File('src/test/resources/test_schemas/singleType.json')
17 | assertTrue(modelFile.isFile())
18 | def builder = new JsonSchemaBuilder()
19 | def model = builder.buildModel(modelFile)
20 | assertEquals(model.description,'JSON Schema for process data of a traffic controller.')
21 | assertNull(model.title)
22 | assertEquals(6,model.types.size())
23 |
24 | // check property count
25 | def typeName = 'SingleType'
26 | ModelTestHelper.checkPropertySize(model,typeName,10)
27 | ModelTestHelper.compareProperty (new Property(
28 | name: 'domainUUID',
29 | description: 'RFC 4122 compliant universally unique identifier (UUID) for identifying the domain of the traffic controller.',
30 | type: new StringType()
31 | ),model,typeName)
32 | ModelTestHelper.compareProperty (new Property(
33 | name: 'permissions',
34 | type: new StringType(isArray: true),
35 | ),model,typeName)
36 |
37 | // test that the type has no tags
38 | def singleType = null
39 | model.types.find { type -> return type.name==typeName}.each { type ->
40 | singleType = type;
41 | }
42 |
43 | assertEquals(0, singleType.tags.size())
44 | }
45 |
46 | @Test
47 | void test_tags() {
48 | def modelFile = new File('src/test/resources/test_schemas/ds/shared/icon.json')
49 | assertTrue(modelFile.isFile())
50 | def builder = new JsonSchemaBuilder()
51 | def model = builder.buildModel(modelFile)
52 | def typeName = 'Icon'
53 | // test that the type has no tags
54 | def singleType = null
55 | model.types.find { type -> return type.name==typeName}.each { type ->
56 | singleType = type;
57 | }
58 |
59 | assertEquals(3, singleType.tags.size())
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/test/groovy/de/lisaplus/atlas/codegen/test/DoCodeGen.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.test
2 |
3 | import org.junit.Test
4 |
5 | import static junit.framework.Assert.assertFalse
6 | import static junit.framework.Assert.assertNull
7 | import static org.junit.Assert.assertEquals
8 | import static org.junit.Assert.assertFalse
9 | import static org.junit.Assert.assertTrue
10 |
11 | /**
12 | * Created by eiko on 07.06.17.
13 | */
14 | class DoCodeGen {
15 | @Test
16 | void test_getMapFromGeneratorParams_1() {
17 | def input = ['test=test','a=test with spaces','b=täst','c=täst with spaces']
18 | Map output = de.lisaplus.atlas.DoCodeGen.getMapFromGeneratorParams(input)
19 | assertEquals(4,output.size())
20 | assertEquals('test',output['test'])
21 | assertEquals('test with spaces',output['a'])
22 | assertEquals('täst',output['b'])
23 | assertEquals('täst with spaces',output['c'])
24 | }
25 |
26 | @Test
27 | void test_getMapFromGeneratorParams_2() {
28 | def input = ['test=test', 'a=test with spaces', 'btäst', 'c=täst with spaces']
29 | Map output = de.lisaplus.atlas.DoCodeGen.getMapFromGeneratorParams(input)
30 | assertEquals(3,output.size())
31 | assertEquals('test',output['test'])
32 | assertEquals('test with spaces',output['a'])
33 | assertNull(output['b'])
34 | assertEquals('täst with spaces',output['c'])
35 | }
36 |
37 | @Test
38 | void test_prepareOutputBaseDir() {
39 | def testDir='build/tmp/test_prepareOutputBaseDir/test/test2'
40 | def f1 = new File ('build/tmp/test_prepareOutputBaseDir')
41 | if (f1.isDirectory()) f1.deleteDir()
42 | assertFalse(f1.exists())
43 | def f2 = new File (testDir)
44 | try {
45 | assertFalse(f2.exists())
46 | de.lisaplus.atlas.DoCodeGen.prepareOutputBaseDir(testDir)
47 | assertTrue(f2.exists())
48 | }
49 | finally {
50 | f1.deleteDir()
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/test/groovy/de/lisaplus/atlas/codegen/test/HistModel.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.test
2 |
3 | import org.junit.Test
4 |
5 | import static junit.framework.Assert.assertTrue
6 |
7 | /**
8 | * Tests the plantuml generator and template
9 | * Created by eiko on 19.06.17.
10 | */
11 | class HistModel {
12 | private static void generateHistModel(String model, String destFile) {
13 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
14 | doCodeGen.models = [model]
15 | doCodeGen.generators.add('hist_model')
16 | doCodeGen.outputBaseDir='tmp'
17 | doCodeGen.generator_parameters.add("destFileName=${destFile}")
18 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
19 | doCodeGen.run()
20 | assertTrue(new File("tmp/${destFile}").exists())
21 | }
22 |
23 | private static void generatePlantUML(String model, String destFile) {
24 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
25 | doCodeGen.models=[model]
26 | doCodeGen.generators.add('plantuml')
27 | doCodeGen.outputBaseDir='tmp'
28 | doCodeGen.generator_parameters.add("destFileName=${destFile}")
29 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
30 | doCodeGen.run()
31 | assertTrue(new File("tmp/${destFile}").exists())
32 | }
33 |
34 | @Test
35 | void createUserModel() {
36 | def model='src/test/resources/test_schemas/ds/user.json'
37 | def histModel='user_hist.json'
38 | def plantUml='user_hist.puml'
39 | generateHistModel(model,histModel)
40 | generatePlantUML("tmp/${histModel}",plantUml)
41 | }
42 |
43 | @Test
44 | void createMapObjectModel() {
45 | def model='src/test/resources/test_schemas/ds/base_types/map_object.json'
46 | def histModel='map_hist.json'
47 | def plantUml='map_hist.puml'
48 | generateHistModel(model,histModel)
49 | generatePlantUML("tmp/${histModel}",plantUml)
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/test/groovy/de/lisaplus/atlas/codegen/test/JavaInterfacedBeans.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.test
2 |
3 | import de.lisaplus.atlas.codegen.test.base.FileHelper
4 | import org.junit.Test
5 |
6 | import static org.junit.Assert.assertTrue
7 |
8 | /**
9 | * Tests the generator for java interfaced beans and template
10 | * Created by eiko on 19.06.17.
11 | */
12 | class JavaInterfacedBeans {
13 | @Test
14 | void createFromUserModel() {
15 | def destDir = 'tmp/java_interfaced_beans'
16 | FileHelper.removeDirectoryIfExists(destDir)
17 | def modelFile = new File('src/test/resources/test_schemas/ds/user.json')
18 |
19 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
20 | doCodeGen.models=[modelFile]
21 | doCodeGen.generators.add('java_interfaces')
22 | doCodeGen.outputBaseDir = destDir
23 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
24 | doCodeGen.generator_parameters.add('packageName=de.test.jsoncodegen.interf')
25 | doCodeGen.run()
26 |
27 | de.lisaplus.atlas.DoCodeGen doCodeGen2 = new de.lisaplus.atlas.DoCodeGen()
28 | doCodeGen2.models = [modelFile]
29 | doCodeGen2.generators.add('java_interfaced_beans')
30 | doCodeGen2.outputBaseDir = destDir
31 | doCodeGen2.generator_parameters.add('removeEmptyLines=true')
32 | doCodeGen2.generator_parameters.add('interfacePackageName=de.test.jsoncodegen.interf')
33 | doCodeGen2.generator_parameters.add('packageName=de.test.jsoncodegen.impl')
34 | doCodeGen2.run()
35 | }
36 |
37 | @Test
38 | void testMapObjMulti() {
39 | def modelFile = new File('src/test/resources/test_schemas/ds/base_types/map_object_multi_type.json')
40 | def destDir = 'tmp/java_interfaced_beans'
41 | FileHelper.removeDirectoryIfExists(destDir)
42 |
43 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
44 | doCodeGen.models=[modelFile]
45 | doCodeGen.generators.add('java_interfaces')
46 | doCodeGen.outputBaseDir = destDir
47 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
48 | doCodeGen.generator_parameters.add('packageName=de.test2.jsoncodegen.interf')
49 | doCodeGen.run()
50 |
51 | de.lisaplus.atlas.DoCodeGen doCodeGen2 = new de.lisaplus.atlas.DoCodeGen()
52 | doCodeGen2.models = [modelFile]
53 | doCodeGen2.generators.add('java_interfaced_beans')
54 | doCodeGen2.outputBaseDir = destDir
55 | doCodeGen2.generator_parameters.add('removeEmptyLines=true')
56 | doCodeGen2.generator_parameters.add('interfacePackageName=de.test.jsoncodegen.interf')
57 | doCodeGen2.generator_parameters.add('packageName=de.test2.jsoncodegen.impl')
58 | doCodeGen2.run()
59 | }
60 |
61 | @Test
62 | void testSimpleMapObj() {
63 | def modelFile = new File('src/test/resources/test_schemas/ds/base_types/simple_map_object.json')
64 | def destDir = 'tmp/java_interfaced_beans'
65 | FileHelper.removeDirectoryIfExists(destDir)
66 |
67 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
68 | doCodeGen.models=[modelFile]
69 | doCodeGen.generators.add('java_interfaces')
70 | doCodeGen.outputBaseDir = destDir
71 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
72 | doCodeGen.generator_parameters.add('packageName=de.test3.jsoncodegen.interf')
73 | doCodeGen.run()
74 |
75 | de.lisaplus.atlas.DoCodeGen doCodeGen2 = new de.lisaplus.atlas.DoCodeGen()
76 | doCodeGen2.models = [modelFile]
77 | doCodeGen2.generators.add('java_interfaced_beans')
78 | doCodeGen2.outputBaseDir = destDir
79 | doCodeGen2.generator_parameters.add('removeEmptyLines=true')
80 | doCodeGen2.generator_parameters.add('interfacePackageName=de.test.jsoncodegen.interf')
81 | doCodeGen2.generator_parameters.add('packageName=de.test3.jsoncodegen.impl')
82 | doCodeGen2.run()
83 |
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/src/test/groovy/de/lisaplus/atlas/codegen/test/JavaInterfaces.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.test
2 |
3 | import de.lisaplus.atlas.codegen.test.base.FileHelper
4 | import org.junit.Test
5 |
6 | import static org.junit.Assert.assertTrue
7 |
8 | /**
9 | * Tests the java interface generator and template
10 | * Created by eiko on 19.06.17.
11 | */
12 | class JavaInterfaces {
13 | @Test
14 | void createFromUserModel() {
15 | def destDir = 'tmp/java_interfaces'
16 | FileHelper.removeDirectoryIfExists(destDir)
17 | def modelFile = new File('src/test/resources/test_schemas/ds/user.json')
18 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
19 | doCodeGen.models = [modelFile]
20 | doCodeGen.generators.add('java_interfaces')
21 | doCodeGen.outputBaseDir = destDir
22 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
23 | doCodeGen.generator_parameters.add('packageName=de.test.jsoncodegen.impl')
24 | doCodeGen.run()
25 | }
26 |
27 | @Test
28 | void testMapObjMulti() {
29 | def destDir = 'tmp/java_interfaces'
30 | FileHelper.removeDirectoryIfExists(destDir)
31 | def modelFile = new File('src/test/resources/test_schemas/ds/base_types/map_object_multi_type.json')
32 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
33 | doCodeGen.models = [modelFile]
34 | doCodeGen.generators.add('java_interfaces')
35 | doCodeGen.outputBaseDir = destDir
36 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
37 | doCodeGen.generator_parameters.add('packageName=de.test2.jsoncodegen.impl')
38 | doCodeGen.run()
39 | }
40 |
41 | @Test
42 | void testSimpleMapObj() {
43 | def destDir = 'tmp/java_interfaces'
44 | FileHelper.removeDirectoryIfExists(destDir)
45 | def modelFile = new File('src/test/resources/test_schemas/ds/base_types/simple_map_object.json')
46 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
47 | doCodeGen.models = [modelFile]
48 | doCodeGen.generators.add('java_interfaces')
49 | doCodeGen.outputBaseDir = destDir
50 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
51 | doCodeGen.generator_parameters.add('packageName=de.test3.jsoncodegen.impl')
52 | doCodeGen.run()
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/test/groovy/de/lisaplus/atlas/codegen/test/JsonSchema.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.test
2 |
3 | import org.junit.Test
4 |
5 | import static junit.framework.Assert.assertTrue
6 | import static org.junit.Assert.assertTrue
7 |
8 | /**
9 | * Tests the plantuml generator and template
10 | * Created by eiko on 19.06.17.
11 | */
12 | class JsonSchema {
13 | private static void generateHistModel(String model, String destFile) {
14 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
15 | doCodeGen.models=[model]
16 | doCodeGen.generators.add('json_schema')
17 | doCodeGen.outputBaseDir='tmp'
18 | doCodeGen.generator_parameters.add("destFileName=${destFile}")
19 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
20 | doCodeGen.run()
21 | assertTrue(new File("tmp/${destFile}").exists())
22 | }
23 |
24 | private static void generatePlantUML(String model, String destFile) {
25 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
26 | doCodeGen.models=[model]
27 | doCodeGen.generators.add('plantuml')
28 | doCodeGen.outputBaseDir='tmp'
29 | doCodeGen.generator_parameters.add("destFileName=${destFile}")
30 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
31 | doCodeGen.run()
32 | assertTrue(new File("tmp/${destFile}").exists())
33 | }
34 |
35 | @Test
36 | void createUserModel() {
37 | def model='src/test/resources/test_schemas/ds/user.json'
38 | def histModel='user_schema.json'
39 | def plantUml='user_schema.puml'
40 | generateHistModel(model,histModel)
41 | generatePlantUML("tmp/${histModel}",plantUml)
42 | }
43 |
44 | @Test
45 | void createMapObjectModel() {
46 | def model='src/test/resources/test_schemas/ds/base_types/map_object.json'
47 | def histModel='map_schema.json'
48 | def plantUml='map_schema.puml'
49 | generateHistModel(model,histModel)
50 | generatePlantUML("tmp/${histModel}",plantUml)
51 | }
52 |
53 | @Test
54 | void createMapObjectModel2() {
55 | def model='src/test/resources/test_schemas/ds/base_types/map_object_multi_type.json'
56 | def histModel='map_schema2.json'
57 | def plantUml='map_schema2.puml'
58 | generateHistModel(model,histModel)
59 | generatePlantUML("tmp/${histModel}",plantUml)
60 | }
61 |
62 | @Test
63 | void createRecursiveModel() {
64 | def model='src/test/resources/test_schemas/ds/shared/options_response.json'
65 | def histModel='options_response.json'
66 | def plantUml='options_response.puml'
67 | generateHistModel(model,histModel)
68 | generatePlantUML("tmp/${histModel}",plantUml)
69 | }
70 |
71 | @Test
72 | void testXsdInput() {
73 | generateHistModel('src/test/resources/xsd/ui-tlc.xsd','ui-tlc.json')
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/src/test/groovy/de/lisaplus/atlas/codegen/test/MongoBeans.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.test
2 |
3 | import de.lisaplus.atlas.codegen.test.base.FileHelper
4 | import org.junit.Test
5 |
6 | import static org.junit.Assert.assertTrue
7 |
8 | /**
9 | * Tests the java bean generator and template
10 | * Created by eiko on 19.06.17.
11 | */
12 | class MongoBeans {
13 | @Test
14 | void createFromUserModel() {
15 | def destDir = 'tmp/mongo_beans'
16 | FileHelper.removeDirectoryIfExists(destDir)
17 | def modelFile = new File('src/test/resources/test_schemas/ds/junction2.json')
18 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
19 | doCodeGen.models=[modelFile]
20 | doCodeGen.generators.add('mongo_beans')
21 | doCodeGen.outputBaseDir = destDir
22 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
23 | doCodeGen.generator_parameters.add('packageName=de.schlothauer.test.mongo')
24 | doCodeGen.run()
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/groovy/de/lisaplus/atlas/codegen/test/MultiFileTemplates.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.test
2 |
3 | import de.lisaplus.atlas.codegen.test.base.FileHelper
4 | import org.junit.Test
5 |
6 | import static org.junit.Assert.assertFalse
7 | import static org.junit.Assert.assertTrue
8 |
9 | class MultiFileTemplates {
10 | @Test
11 | void testHandlingTemplate() {
12 | def destDir = 'tmp/handling'
13 | FileHelper.removeDirectoryIfExists(destDir)
14 | def modelFile = new File('src/test/resources/test_schemas/ds/incident.json')
15 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
16 | doCodeGen.models=[modelFile]
17 | doCodeGen.generators.add('multifiles=src/test/resources/templates/handling.txt')
18 | doCodeGen.generatorScript = 'src/test/resources/templates/handling_helper.groovy'
19 | doCodeGen.outputBaseDir = destDir
20 | doCodeGen.generator_parameters.add('packageName=de.handling')
21 | doCodeGen.run()
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/groovy/de/lisaplus/atlas/codegen/test/Swagger.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.test
2 |
3 | import junit.framework.Assert
4 | import org.junit.Test
5 |
6 | import static junit.framework.Assert.assertTrue
7 | import static junit.framework.Assert.assertEquals
8 |
9 | /**
10 | * Tests the swagger generator and the swagger template
11 | * Created by eiko on 21.06.17.
12 | */
13 | class Swagger {
14 | @Test
15 | void createUserModel_SingleFile() {
16 | def destFile='tmp/user.swagger'
17 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
18 | doCodeGen.models=['src/test/resources/test_schemas/ds/user.json']
19 | doCodeGen.generators.add('singlefile=src/main/resources/templates/meta/swagger_file.txt')
20 | doCodeGen.outputBaseDir='tmp'
21 | doCodeGen.generator_parameters.add('destFileName=user.swagger')
22 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
23 | doCodeGen.generator_parameters.add('host=api.lisaplus.de')
24 | doCodeGen.run()
25 | assertTrue(new File(destFile).exists())
26 | }
27 |
28 | @Test
29 | void createUserModel_BuiltIn() {
30 | def destFile='tmp/userModel.swagger'
31 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
32 | doCodeGen.models=['src/test/resources/test_schemas/ds/user.json']
33 | doCodeGen.generators.add('swagger')
34 | doCodeGen.outputBaseDir='tmp'
35 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
36 | doCodeGen.generator_parameters.add('host=api.lisaplus.de')
37 | doCodeGen.run()
38 | assertTrue(new File(destFile).exists())
39 | }
40 |
41 | @Test
42 | void createLicenseModel_BuiltIn() {
43 | def destFile='tmp/licenseModel.swagger'
44 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
45 | doCodeGen.models=['src/test/resources/test_schemas/ds/license.json']
46 | doCodeGen.generators.add('swagger')
47 | doCodeGen.outputBaseDir='tmp'
48 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
49 | doCodeGen.generator_parameters.add('host=api.lisaplus.de')
50 | doCodeGen.run()
51 | assertTrue(new File(destFile).exists())
52 | }
53 |
54 | @Test
55 | void createNotifyModel_BuiltIn() {
56 | def destFile='tmp/notify_swagger.yaml'
57 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
58 | doCodeGen.models=['src/test/resources/schemas/notify.json']
59 | doCodeGen.generators.add('swagger')
60 | doCodeGen.outputBaseDir='tmp'
61 | doCodeGen.generator_parameters.add('destFileName=notify_swagger.yaml')
62 | doCodeGen.generator_parameters.add('containsAttrib=message')
63 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
64 | doCodeGen.generator_parameters.add('host=notify.swarco.com')
65 | doCodeGen.run()
66 | assertTrue(destFile, new File(destFile).exists())
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/test/groovy/de/lisaplus/atlas/codegen/test/SwaggerExt.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.test
2 |
3 | import org.junit.Test
4 |
5 | import static junit.framework.Assert.assertTrue
6 |
7 | /**
8 | * Tests the swagger generator and the swagger template
9 | * Created by eiko on 21.06.17.
10 | */
11 | class SwaggerExt {
12 | @Test
13 | void createUserModel_SingleFile() {
14 | def destFile='tmp/user.swagger'
15 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
16 | doCodeGen.models=['src/test/resources/test_schemas/ds/user.json']
17 | doCodeGen.generators.add('singlefile=src/main/resources/templates/meta/swagger_ext.txt')
18 | doCodeGen.outputBaseDir='tmp'
19 | doCodeGen.generator_parameters.add('destFileName=user.swagger')
20 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
21 | doCodeGen.generator_parameters.add('host=api.lisaplus.de')
22 | doCodeGen.run()
23 | assertTrue(new File(destFile).exists())
24 | }
25 |
26 | @Test
27 | void createUserModel_BuiltIn() {
28 | def destFile='tmp/userModel.swagger'
29 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
30 | doCodeGen.models=['src/test/resources/test_schemas/ds/user.json']
31 | doCodeGen.generators.add('swagger_ext')
32 | doCodeGen.outputBaseDir='tmp'
33 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
34 | doCodeGen.generator_parameters.add('host=api.lisaplus.de')
35 | doCodeGen.run()
36 | assertTrue(new File(destFile).exists())
37 | }
38 |
39 | @Test
40 | void createLicenseModel_BuiltIn() {
41 | def destFile='tmp/licenseModel.swagger'
42 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
43 | doCodeGen.models=['src/test/resources/test_schemas/ds/license.json']
44 | doCodeGen.generators.add('swagger_ext')
45 | doCodeGen.outputBaseDir='tmp'
46 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
47 | doCodeGen.generator_parameters.add('host=api.lisaplus.de')
48 | doCodeGen.run()
49 | assertTrue(new File(destFile).exists())
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/test/groovy/de/lisaplus/atlas/codegen/test/Xsd.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.test
2 |
3 | import org.junit.Test
4 |
5 | import static junit.framework.Assert.assertTrue
6 |
7 | /**
8 | * Tests the plantuml generator and template
9 | * Created by eiko on 19.06.17.
10 | */
11 | class Xsd {
12 | private static void generateXsd(String model, String destFile) {
13 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
14 | doCodeGen.models=[model]
15 | doCodeGen.generators.add('xsd')
16 | doCodeGen.outputBaseDir='tmp'
17 | doCodeGen.generator_parameters.add("destFileName=${destFile}")
18 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
19 | doCodeGen.run()
20 | assertTrue(new File("tmp/${destFile}").exists())
21 | }
22 |
23 | private static void generatePlantUML(String model, String destFile) {
24 | de.lisaplus.atlas.DoCodeGen doCodeGen = new de.lisaplus.atlas.DoCodeGen()
25 | doCodeGen.models=[model]
26 | doCodeGen.generators.add('plantuml')
27 | doCodeGen.outputBaseDir='tmp'
28 | doCodeGen.generator_parameters.add("destFileName=${destFile}")
29 | doCodeGen.generator_parameters.add('removeEmptyLines=true')
30 | doCodeGen.run()
31 | assertTrue(new File("tmp/${destFile}").exists())
32 | }
33 |
34 | @Test
35 | void createUserModel() {
36 | def model='src/test/resources/test_schemas/ds/user.json'
37 | def xsdModel='user.xsd'
38 | def plantUmlJson='user_xsd.puml'
39 | def plantUmlXsd='user_xsd.puml'
40 | generatePlantUML(model,plantUmlJson)
41 | generateXsd(model,xsdModel)
42 | generatePlantUML("tmp/${xsdModel}",plantUmlXsd)
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/groovy/de/lisaplus/atlas/codegen/test/base/FileHelper.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.test.base
2 |
3 | import static org.junit.Assert.assertTrue
4 |
5 | class FileHelper {
6 | static void removeDirectoryIfExists(String pathToDir) {
7 | File f = new File(pathToDir)
8 | if (f.exists()) {
9 | f.deleteDir()
10 | }
11 | assertTrue(!f.exists())
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/test/groovy/de/lisaplus/atlas/codegen/test/base/JavaCompileHelper.groovy:
--------------------------------------------------------------------------------
1 | package de.lisaplus.atlas.codegen.test.base
2 |
3 | import static org.junit.Assert.assertTrue
4 |
5 | class JavaCompileHelper {
6 | // TODO
7 | }
8 |
--------------------------------------------------------------------------------
/src/test/resources/schemas/CnResponseType.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "type": "object",
4 | "additionalProperties": false,
5 | "properties": {
6 | "version": {
7 | "type": "string"
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/src/test/resources/schemas/CycCollectionType.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "type": "object",
4 | "additionalProperties": false,
5 | "properties": {
6 | "cycles": {
7 | "$ref": "#/definitions/CyclesType"
8 | },
9 | "version": {
10 | "type": "string"
11 | }
12 | },
13 | "definitions": {
14 | "CyclesType": {
15 | "type": "object",
16 | "additionalProperties": false,
17 | "properties": {
18 | "cycle": {
19 | "type": "array",
20 | "items": {
21 | "$ref": "#/definitions/CycleType"
22 | }
23 | },
24 | "period": {
25 | "type": "integer"
26 | },
27 | "numsys": {
28 | "type": "integer"
29 | }
30 | }
31 | },
32 | "CycleType": {
33 | "type": "object",
34 | "additionalProperties": false,
35 | "properties": {
36 | "greens": {
37 | "$ref": "#/definitions/Greens"
38 | },
39 | "id": {
40 | "type": "string"
41 | },
42 | "num": {
43 | "type": "integer"
44 | },
45 | "cyc": {
46 | "type": "integer"
47 | },
48 | "valid": {
49 | "type": "integer"
50 | },
51 | "err": {
52 | "type": "integer"
53 | },
54 | "trans": {
55 | "type": "integer"
56 | },
57 | "offcor": {
58 | "type": "integer"
59 | },
60 | "now": {
61 | "type": "integer"
62 | },
63 | "std": {
64 | "type": "integer"
65 | },
66 | "geo": {
67 | "type": "integer"
68 | },
69 | "node": {
70 | "type": "integer"
71 | },
72 | "send": {
73 | "type": "string",
74 | "enum": [
75 | "OK",
76 | "FAIL"
77 | ]
78 | },
79 | "errno": {
80 | "type": "integer"
81 | },
82 | "sys": {
83 | "type": "string"
84 | }
85 | }
86 | },
87 | "Greens": {
88 | "type": "object",
89 | "additionalProperties": false,
90 | "properties": {
91 | "green": {
92 | "type": "array",
93 | "items": {
94 | "$ref": "#/definitions/GreenType"
95 | }
96 | }
97 | }
98 | },
99 | "GreenType": {
100 | "type": "object",
101 | "additionalProperties": false,
102 | "properties": {
103 | "id": {
104 | "type": "string"
105 | },
106 | "grn": {
107 | "type": "integer"
108 | },
109 | "ped": {
110 | "type": "integer"
111 | },
112 | "tim": {
113 | "type": "integer"
114 | },
115 | "gap": {
116 | "type": "integer"
117 | },
118 | "max": {
119 | "type": "integer"
120 | },
121 | "fo": {
122 | "type": "integer"
123 | }
124 | }
125 | }
126 | }
127 | }
--------------------------------------------------------------------------------
/src/test/resources/schemas/DetCollectionType.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "type": "object",
4 | "additionalProperties": false,
5 | "properties": {
6 | "sums": {
7 | "$ref": "#/definitions/Sums"
8 | },
9 | "version": {
10 | "type": "string"
11 | }
12 | },
13 | "definitions": {
14 | "Sums": {
15 | "type": "object",
16 | "additionalProperties": false,
17 | "properties": {
18 | "detection": {
19 | "type": "array",
20 | "items": {
21 | "$ref": "#/definitions/DetectionType"
22 | }
23 | },
24 | "period": {
25 | "type": "integer"
26 | },
27 | "numsys": {
28 | "type": "integer"
29 | }
30 | }
31 | },
32 | "DetectionType": {
33 | "type": "object",
34 | "additionalProperties": false,
35 | "properties": {
36 | "dets": {
37 | "$ref": "#/definitions/Dets"
38 | },
39 | "id": {
40 | "type": "string"
41 | },
42 | "now": {
43 | "type": "integer"
44 | },
45 | "comm": {
46 | "type": "string",
47 | "enum": [
48 | "OK",
49 | "FAIL"
50 | ]
51 | },
52 | "num": {
53 | "type": "integer"
54 | }
55 | }
56 | },
57 | "Dets": {
58 | "type": "object",
59 | "additionalProperties": false,
60 | "properties": {
61 | "det": {
62 | "type": "array",
63 | "items": {
64 | "$ref": "#/definitions/DetType"
65 | }
66 | }
67 | }
68 | },
69 | "DetType": {
70 | "type": "object",
71 | "additionalProperties": false,
72 | "properties": {
73 | "id": {
74 | "type": "string"
75 | },
76 | "pos": {
77 | "type": "integer"
78 | },
79 | "vol": {
80 | "type": "integer"
81 | },
82 | "occ": {
83 | "type": "integer"
84 | },
85 | "grn": {
86 | "type": "integer"
87 | }
88 | }
89 | }
90 | }
91 | }
--------------------------------------------------------------------------------
/src/test/resources/schemas/GeoCollectionType.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "type": "object",
4 | "additionalProperties": false,
5 | "properties": {
6 | "geometries": {
7 | "$ref": "#/definitions/GeometriesType"
8 | },
9 | "version": {
10 | "type": "string"
11 | }
12 | },
13 | "definitions": {
14 | "GeometriesType": {
15 | "type": "object",
16 | "additionalProperties": false,
17 | "properties": {
18 | "geometry": {
19 | "type": "array",
20 | "items": {
21 | "$ref": "#/definitions/GeometryType"
22 | }
23 | },
24 | "path": {
25 | "type": "string"
26 | }
27 | }
28 | },
29 | "GeometryType": {
30 | "type": "object",
31 | "additionalProperties": false,
32 | "properties": {
33 | "directions": {
34 | "$ref": "#/definitions/Directions"
35 | },
36 | "id": {
37 | "type": "string"
38 | },
39 | "file": {
40 | "type": "string",
41 | "enum": [
42 | "OK",
43 | "NONE"
44 | ]
45 | },
46 | "path": {
47 | "type": "string"
48 | }
49 | }
50 | },
51 | "Directions": {
52 | "type": "object",
53 | "additionalProperties": false,
54 | "properties": {
55 | "direction": {
56 | "type": "array",
57 | "items": {
58 | "$ref": "#/definitions/DirectionType"
59 | }
60 | }
61 | }
62 | },
63 | "DirectionType": {
64 | "type": "object",
65 | "additionalProperties": false,
66 | "properties": {
67 | "movements": {
68 | "$ref": "#/definitions/Movements"
69 | },
70 | "id": {
71 | "type": "string"
72 | },
73 | "bound": {
74 | "type": "string",
75 | "enum": [
76 | "NORTH",
77 | "SOUTH",
78 | "EAST",
79 | "WEST"
80 | ]
81 | },
82 | "exitlanes": {
83 | "type": "integer"
84 | },
85 | "speed": {
86 | "type": "integer"
87 | },
88 | "next": {
89 | "type": "string"
90 | },
91 | "distance": {
92 | "type": "integer"
93 | },
94 | "name": {
95 | "type": "string"
96 | }
97 | }
98 | },
99 | "Movements": {
100 | "type": "object",
101 | "additionalProperties": false,
102 | "properties": {
103 | "movement": {
104 | "type": "array",
105 | "items": {
106 | "$ref": "#/definitions/MovementType"
107 | }
108 | }
109 | }
110 | },
111 | "MovementType": {
112 | "type": "object",
113 | "additionalProperties": false,
114 | "properties": {
115 | "value": {
116 | "type": "string"
117 | },
118 | "dir": {
119 | "type": "string",
120 | "enum": [
121 | "LT",
122 | "ST",
123 | "RT"
124 | ]
125 | },
126 | "lanes": {
127 | "type": "integer"
128 | },
129 | "faze": {
130 | "type": "integer"
131 | },
132 | "overlap": {
133 | "type": "string",
134 | "enum": [
135 | "E",
136 | "F",
137 | "A",
138 | "G",
139 | "B",
140 | "C",
141 | "H",
142 | "D"
143 | ]
144 | },
145 | "perm": {
146 | "type": "integer"
147 | },
148 | "display": {
149 | "type": "string",
150 | "enum": [
151 | "BALL",
152 | "ARROW",
153 | "STDLEFT"
154 | ]
155 | }
156 | }
157 | }
158 | }
159 | }
--------------------------------------------------------------------------------
/src/test/resources/schemas/LocCollectionType.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "type": "object",
4 | "additionalProperties": false,
5 | "properties": {
6 | "locations": {
7 | "$ref": "#/definitions/LocationsType"
8 | },
9 | "version": {
10 | "type": "string"
11 | }
12 | },
13 | "definitions": {
14 | "LocationsType": {
15 | "type": "object",
16 | "additionalProperties": false,
17 | "properties": {
18 | "location": {
19 | "type": "array",
20 | "items": {
21 | "$ref": "#/definitions/LocationType"
22 | }
23 | },
24 | "numsys": {
25 | "type": "integer"
26 | }
27 | }
28 | },
29 | "LocationType": {
30 | "type": "object",
31 | "additionalProperties": false,
32 | "properties": {
33 | "detectors": {
34 | "$ref": "#/definitions/Detectors"
35 | },
36 | "id": {
37 | "type": "string"
38 | },
39 | "file": {
40 | "type": "string",
41 | "enum": [
42 | "OK",
43 | "NONE"
44 | ]
45 | },
46 | "path": {
47 | "type": "string"
48 | }
49 | }
50 | },
51 | "Detectors": {
52 | "type": "object",
53 | "additionalProperties": false,
54 | "properties": {
55 | "detector": {
56 | "type": "array",
57 | "items": {
58 | "$ref": "#/definitions/DetectorType"
59 | }
60 | }
61 | }
62 | },
63 | "DetectorType": {
64 | "type": "object",
65 | "additionalProperties": false,
66 | "properties": {
67 | "id": {
68 | "type": "string"
69 | },
70 | "code": {
71 | "type": "integer"
72 | },
73 | "faze": {
74 | "type": "integer"
75 | },
76 | "lane": {
77 | "type": "integer"
78 | },
79 | "mode": {
80 | "type": "string"
81 | }
82 | }
83 | }
84 | }
85 | }
--------------------------------------------------------------------------------
/src/test/resources/schemas/StdCollectionType.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "type": "object",
4 | "additionalProperties": false,
5 | "properties": {
6 | "signalTimingData": {
7 | "$ref": "#/definitions/SignalTimingDataType"
8 | },
9 | "version": {
10 | "type": "string"
11 | }
12 | },
13 | "definitions": {
14 | "SignalTimingDataType": {
15 | "type": "object",
16 | "additionalProperties": false,
17 | "properties": {
18 | "std": {
19 | "type": "array",
20 | "items": {
21 | "$ref": "#/definitions/Std"
22 | }
23 | },
24 | "numsys": {
25 | "type": "integer"
26 | }
27 | }
28 | },
29 | "Std": {
30 | "type": "object",
31 | "additionalProperties": false,
32 | "properties": {
33 | "timingPlans": {
34 | "$ref": "#/definitions/TimingPlans"
35 | },
36 | "id": {
37 | "type": "string"
38 | },
39 | "file": {
40 | "type": "string",
41 | "enum": [
42 | "OK",
43 | "NONE"
44 | ]
45 | },
46 | "path": {
47 | "type": "string"
48 | },
49 | "name": {
50 | "type": "string"
51 | }
52 | }
53 | },
54 | "TimingPlans": {
55 | "type": "object",
56 | "additionalProperties": false,
57 | "properties": {
58 | "timingPlan": {
59 | "type": "array",
60 | "items": {
61 | "$ref": "#/definitions/TimingPlan"
62 | }
63 | }
64 | }
65 | },
66 | "TimingPlan": {
67 | "type": "object",
68 | "additionalProperties": false,
69 | "properties": {
70 | "phases": {
71 | "$ref": "#/definitions/Phases"
72 | },
73 | "id": {
74 | "type": "string"
75 | },
76 | "cycle": {
77 | "type": "integer"
78 | },
79 | "min": {
80 | "type": "integer"
81 | },
82 | "offset": {
83 | "type": "integer"
84 | },
85 | "sigplan": {
86 | "type": "integer"
87 | }
88 | }
89 | },
90 | "Phases": {
91 | "type": "object",
92 | "additionalProperties": false,
93 | "properties": {
94 | "phase": {
95 | "type": "array",
96 | "items": {
97 | "$ref": "#/definitions/PhaseType"
98 | }
99 | }
100 | }
101 | },
102 | "PhaseType": {
103 | "type": "object",
104 | "additionalProperties": false,
105 | "properties": {
106 | "value": {
107 | "type": "string"
108 | },
109 | "id": {
110 | "type": "string"
111 | },
112 | "serves": {
113 | "type": "integer"
114 | },
115 | "rof": {
116 | "type": "integer"
117 | },
118 | "split": {
119 | "type": "integer"
120 | },
121 | "disp": {
122 | "type": "string",
123 | "enum": [
124 | "EW_L",
125 | "SB_L",
126 | "NB_W",
127 | "SB_W",
128 | "WB_G",
129 | "NB_L",
130 | "EW_W",
131 | "NS_W",
132 | "EB_W",
133 | "NS_E",
134 | "NS_L",
135 | "WB_L",
136 | "SB_G",
137 | "EB_L",
138 | "WB_B",
139 | "EW_G"
140 | ]
141 | },
142 | "minvar": {
143 | "type": "integer"
144 | },
145 | "variable": {
146 | "type": "integer"
147 | },
148 | "clear": {
149 | "type": "integer"
150 | },
151 | "fixed": {
152 | "type": "integer"
153 | }
154 | }
155 | }
156 | }
157 | }
--------------------------------------------------------------------------------
/src/test/resources/schemas/TimCollectionType.json:
--------------------------------------------------------------------------------
1 | {"$schema":"http://json-schema.org/draft-04/schema#","type":"object","additionalProperties":false,"properties":{"timings":{"$ref":"#/definitions/TimingsType"},"version":{"type":"string"}},"definitions":{"TimingsType":{"type":"object","additionalProperties":false,"properties":{"timing":{"type":"array","items":{"$ref":"#/definitions/TimingType"}},"numsys":{"type":"integer"}}},"TimingType":{"type":"object","additionalProperties":false,"properties":{"curPlan":{"$ref":"#/definitions/TimingPlanType"},"id":{"type":"integer"},"adaptive":{"type":"string","enum":["PLAN","PATTERN","STANDBY"]},"adaPlan":{"type":"integer"},"adaMode":{"type":"string","enum":["FREE","FLASH"]},"adaPattern":{"type":"integer"},"tod":{"type":"string","enum":["PLAN","PATTERN","STANDBY"]},"todPlan":{"type":"integer"},"todMode":{"type":"string","enum":["FREE","FLASH"]},"todPattern":{"type":"integer"},"todnum":{"type":"integer"},"override":{"type":"string","enum":["PLAN","PATTERN","STANDBY"]},"ovrPlan":{"type":"integer"},"ovrMode":{"type":"string","enum":["FREE","FLASH"]},"ovrPattern":{"type":"integer"},"now":{"type":"string","enum":["PATTERN","FLASH","TBC","STANDBY","FAIL","PLAN","UNKNOWN"]},"op":{"type":"string","enum":["PICKUP","OFFSET","NCS","TRANSITION"]},"to":{"type":"integer"},"fail":{"type":"string","enum":["CONFLICT","CDI","PRE_EMPT","UNKNOWN","RESET"]}}},"TimingPlanType":{"type":"object","additionalProperties":false,"properties":{"phases":{"$ref":"#/definitions/Phases"},"id":{"type":"string"},"cycle":{"type":"integer"},"min":{"type":"integer"},"offset":{"type":"integer"},"sigplan":{"type":"integer"}}},"Phases":{"type":"object","additionalProperties":false,"properties":{"phase":{"type":"array","items":{"$ref":"#/definitions/PhaseType"}}}},"PhaseType":{"type":"object","additionalProperties":false,"properties":{"value":{"type":"string"},"id":{"type":"string"},"serves":{"type":"integer"},"rof":{"type":"integer"},"split":{"type":"integer"},"disp":{"type":"string","enum":["EW_L","SB_L","NB_W","SB_W","WB_G","NB_L","EW_W","NS_W","EB_W","NS_E","NS_L","WB_L","SB_G","EB_L","WB_B","EW_G"]},"minvar":{"type":"integer"},"variable":{"type":"integer"},"clear":{"type":"integer"},"fixed":{"type":"integer"}}}}}
--------------------------------------------------------------------------------
/src/test/resources/schemas/notify.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-06/schema#",
3 | "title": "Notification",
4 | "description": "Notification data model",
5 | "definitions": {
6 | "Message": {
7 | "description": "a message that should be delivered",
8 | "type": "object",
9 | "properties": {
10 | "guid": {
11 | "description": "global identifier",
12 | "type": "string",
13 | "format": "uuid"
14 | },
15 | "title": {
16 | "description": "title of the message",
17 | "type": "string"
18 | },
19 | "text": {
20 | "description": "message text",
21 | "type": "string"
22 | },
23 | "priority": {
24 | "description": "priority of the message",
25 | "type": "string",
26 | "enum": [
27 | "normal",
28 | "high",
29 | "hot"
30 | ]
31 | },
32 | "sender": {
33 | "$ref": "#/definitions/Sender"
34 | }
35 | },
36 | "required": [
37 | "guid",
38 | "title",
39 | "text",
40 | "sender"
41 | ]
42 | },
43 | "NotifyJob": {
44 | "description": "a job to deliver message",
45 | "type": "object",
46 | "properties": {
47 | "guid": {
48 | "description": "global identifier",
49 | "type": "string",
50 | "format": "uuid"
51 | },
52 | "message": {
53 | "$ref": "#/definitions/Message",
54 | "example": "bar-chart"
55 | },
56 | "type": {
57 | "description": "how should the message be delivered",
58 | "type": "string",
59 | "enum": [
60 | "email",
61 | "sms",
62 | "webhook"
63 | ]
64 | },
65 | "receiver": {
66 | "description": "who should receive the message",
67 | "type": "array",
68 | "items": {
69 | "type": "string"
70 | }
71 | },
72 | "times": {
73 | "type": "object",
74 | "properties": {
75 | "to_send": {
76 | "description": "what time it should be sent",
77 | "type": "string",
78 | "format": "date-time"
79 | },
80 | "sended": {
81 | "description": "When was it sent",
82 | "type": "string",
83 | "format": "date-time"
84 | },
85 | "last_trial": {
86 | "description": "In case of error when was the last delivery trial",
87 | "type": "string",
88 | "format": "date-time"
89 | }
90 | }
91 | },
92 | "topics": {
93 | "type": "object",
94 | "properties": {
95 | "success": {
96 | "description": "a topic name to notify the sender about success",
97 | "type": "string"
98 | },
99 | "error": {
100 | "description": "a topic name to notify the sender about delivery errors",
101 | "type": "string"
102 | }
103 | }
104 | }
105 | },
106 | "required": [
107 | "message",
108 | "type",
109 | "receiver"
110 | ]
111 | },
112 | "Sender": {
113 | "description": "which service is the source of the message/job",
114 | "type": "object",
115 | "properties": {
116 | "guid": {
117 | "description": "global identifier",
118 | "type": "string",
119 | "format": "uuid"
120 | },
121 | "name": {
122 | "description": "text to display",
123 | "type": "string"
124 | },
125 | "event_id": {
126 | "description": "global id that allows the sender to link a message/job with an interal event",
127 | "type": "string",
128 | "format": "uuid"
129 | }
130 | }
131 | }
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/src/test/resources/schemas/vera.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "title": "Short VERA inspired JSON schema",
4 | "definitions": {
5 | "object": {
6 | "type": "object",
7 | "description": "container for a top level object",
8 | "properties": {
9 | }
10 | },
11 | "address": {
12 | "type": "object",
13 | "description": "address data of contract partner, department and stuff like that",
14 | "properties": {
15 | }
16 | },
17 | "timeentry": {
18 | "type": "object",
19 | "description": "dates for something",
20 | "properties": {
21 | }
22 | },
23 | "maintenance": {
24 | "type": "object",
25 | "description": "maintenance data for objects",
26 | "properties": {
27 | }
28 | },
29 | "disturbance": {
30 | "type": "object",
31 | "description": "data of disturbance events",
32 | "properties": {
33 | }
34 | },
35 | "object_disturbance": {
36 | "type": "object",
37 | "description": "data of disturbance events",
38 | "properties": {
39 | }
40 | }
41 |
42 | }
43 | }
--------------------------------------------------------------------------------
/src/test/resources/templates/HelloWorld_GString.tmpl:
--------------------------------------------------------------------------------
1 | Hello World ${Name}
2 | äöüß
--------------------------------------------------------------------------------
/src/test/resources/templates/HelloWorld_Markup.tmpl:
--------------------------------------------------------------------------------
1 | xmlDeclaration()
2 | hello {
3 | hello.each {
4 | world {
5 | it.name
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/src/test/resources/templates/handling_helper.groovy:
--------------------------------------------------------------------------------
1 | def printHello(def someString) {
2 | return "Hello: $someString"
3 | }
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/Device.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "type": "object",
4 | "title": "device",
5 | "additionalProperties": false,
6 | "properties": {
7 | "locations": {
8 | "type": "array",
9 | "items": {
10 | "$ref": "#/definitions/Location"
11 | }
12 | },
13 | "configuration": {
14 | "$ref": "#/definitions/DeviceConfigurationArchive"
15 | },
16 | "status": {
17 | "type": "array",
18 | "items": {
19 | "$ref": "#/definitions/DeviceStatus"
20 | }
21 | },
22 | "deviceInfo": {
23 | "$ref": "#/definitions/DeviceInfo"
24 | },
25 | "guid": {
26 | "type": "string"
27 | },
28 | "uri": {
29 | "type": "string"
30 | }
31 | },
32 | "definitions": {
33 | "Location": {
34 | "type": "object",
35 | "additionalProperties": false,
36 | "properties": {
37 | "id": {
38 | "type": "string"
39 | }
40 | }
41 | },
42 | "DeviceConfigurationArchive": {
43 | "type": "object",
44 | "additionalProperties": false,
45 | "properties": {
46 | "configurations": {
47 | "type": "string"
48 | }
49 | }
50 | },
51 | "DeviceStatus": {
52 | "type": "object",
53 | "additionalProperties": false,
54 | "properties": {}
55 | },
56 | "DeviceInfo": {
57 | "type": "object",
58 | "additionalProperties": false,
59 | "properties": {
60 | "deviceType": {
61 | "type": "string",
62 | "enum": [
63 | "OTHER",
64 | "STREETLIGHT_AREA",
65 | "VARIABLE_MESSAGE_SIGN",
66 | "PARKING_HOUSE",
67 | "DETECTOR",
68 | "TRAFFIC_LIGHT_CONTROLLER"
69 | ]
70 | },
71 | "manufacturer": {
72 | "type": "string"
73 | },
74 | "designation": {
75 | "type": "string"
76 | },
77 | "version": {
78 | "type": "string"
79 | }
80 | }
81 | }
82 | }
83 | }
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/array_test.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "title": "User model",
4 | "description": "Test user model",
5 | "definitions": {
6 | "role": {
7 | "type": "object",
8 | "properties": {
9 | "domain_id": {
10 | "description": "what is the related domain",
11 | "type": "string",
12 | "format": "uuid",
13 | "__ref": "./shared/domain.json"
14 | },
15 | "name": {
16 | "description": "Name of the role",
17 | "type": "string",
18 | "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
19 | },
20 | "comment": {
21 | "description": "the common field contain all unmodeled stuff",
22 | "type": "string"
23 | },
24 | "module_grants": {
25 | "type": "array",
26 | "items": {
27 | "type": "object",
28 | "description": "what is granted to do with specific modules",
29 | "properties": {
30 | "module": {
31 | "$ref": "./shared/app_module.json"
32 | },
33 | "grant": {
34 | "type": "string",
35 | "enum": [
36 | "read",
37 | "write",
38 | "commit"
39 | ]
40 | }
41 | },
42 | "__tags": [
43 | "five",
44 | "six",
45 | "seven"
46 | ]
47 | },
48 | "__tags": [
49 | "one",
50 | "two"
51 | ]
52 | },
53 | "data_grants": {
54 | "type": "array",
55 | "items": {
56 | "type": "object",
57 | "description": "what is granted to do with specific modules",
58 | "properties": {
59 | "data_path": {
60 | "description" : "dummy string to define some data",
61 | "type": "string"
62 | },
63 | "grant": {
64 | "type": "string",
65 | "enum": [
66 | "read",
67 | "write",
68 | "commit"
69 | ]
70 | }
71 | }
72 | }
73 | },
74 | "innerArray": {
75 | "type": "array",
76 | "items": {
77 | "type": "array",
78 | "items": {
79 | "type": "object",
80 | "description": "what is granted to do with specific modules",
81 | "properties": {
82 | "data_path": {
83 | "description": "dummy string to define some data",
84 | "type": "string"
85 | },
86 | "grant": {
87 | "type": "string",
88 | "enum": [
89 | "read",
90 | "write",
91 | "commit"
92 | ],
93 | "__tags": [
94 | "one",
95 | "two"
96 | ]
97 | }
98 | }
99 | }
100 | }
101 | },
102 | "active": {
103 | "description": "is this entry still active",
104 | "type": "boolean"
105 | }
106 | }
107 | }
108 | },
109 | "type": "object",
110 | "version": 1
111 | }
112 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/array_test_simple.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "title": "User model",
4 | "description": "Test user model",
5 | "definitions": {
6 | "FeatureAreaGeometry": {
7 | "type": "object",
8 | "properties": {
9 | "type": {
10 | "type": "string"
11 | },
12 | "coordinates": {
13 | "type": "array",
14 | "items": {
15 | "type": "array",
16 | "items": {
17 | "type": "number"
18 | }
19 | }
20 | },
21 | "projection": {
22 | "type": "string"
23 | }
24 | },
25 | "__tags": ["additional"]
26 | },
27 | "role": {
28 | "type": "object",
29 | "properties": {
30 | "name": {
31 | "description": "Name of the role",
32 | "type": "string",
33 | "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
34 | },
35 | "comment": {
36 | "description": "the common field contain all unmodeled stuff",
37 | "type": "string"
38 | },
39 | "innerArray": {
40 | "type": "array",
41 | "items": {
42 | "type": "array",
43 | "items": {
44 | "type": "object",
45 | "description": "what is granted to do with specific modules",
46 | "properties": {
47 | "data_path": {
48 | "description": "dummy string to define some data",
49 | "type": "string"
50 | },
51 | "grant": {
52 | "type": "string",
53 | "enum": [
54 | "read",
55 | "write",
56 | "commit"
57 | ],
58 | "__tags": [
59 | "one",
60 | "two"
61 | ]
62 | }
63 | }
64 | }
65 | }
66 | },
67 | "realDeep": {
68 | "type": "array",
69 | "items": {
70 | "type": "array",
71 | "items": {
72 | "type": "array",
73 | "items": {
74 | "type": "array",
75 | "items": {
76 | "type": "array",
77 | "items": {
78 | "type": "object",
79 | "description": "what is granted to do with specific modules",
80 | "properties": {
81 | "data_path": {
82 | "description": "dummy string to define some data",
83 | "type": "string"
84 | },
85 | "grant": {
86 | "type": "string",
87 | "enum": [
88 | "read",
89 | "write",
90 | "commit"
91 | ],
92 | "__tags": [
93 | "one",
94 | "two"
95 | ]
96 | }
97 | }
98 | }
99 | }
100 | }
101 | }
102 | }
103 | },
104 | "active": {
105 | "description": "is this entry still active",
106 | "type": "boolean"
107 | }
108 | }
109 | }
110 | },
111 | "type": "object",
112 | "version": 1
113 | }
114 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/base_types/gis_object.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/gis_object.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "title": "GIS_object",
5 | "description": "A GIS object is an application defined type that owns GIS coordinates",
6 | "type": "object",
7 | "properties": {
8 | "gis": {
9 | "description": "Definition of an object that owns GIS coordinates. At minimum an object of this type owns one of the props",
10 | "type": "object",
11 | "properties": {
12 | "center": {
13 | "$ref": "../shared/geo_point.json"
14 | },
15 | "area": {
16 | "$ref": "../shared/geo_area.json"
17 | },
18 | "route": {
19 | "$ref": "../shared/geo_multiline.json"
20 | }
21 | }
22 | }
23 | },
24 | "required": [
25 | "gis"
26 | ],
27 | "version": 1
28 | }
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/base_types/map_object.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/map_object.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "title": "Map_object",
5 | "description": "A map object is a basic type for objects displayed on maps",
6 | "type": "object",
7 | "allOf": [
8 | {
9 | "$ref": "./gis_object.json"
10 | },
11 | {
12 | "properties": {
13 | "display": {
14 | "description": "Default properties to display the object on the map",
15 | "type": "object",
16 | "properties": {
17 | "radius": {
18 | "type": "integer"
19 | },
20 | "fill_color": {
21 | "type": "string"
22 | },
23 | "stroke_color": {
24 | "type": "string"
25 | },
26 | "icon": {
27 | "type": "object",
28 | "$ref": "../shared/icon.json"
29 | },
30 | "caption": {
31 | "description": "How to handle locale",
32 | "type": "object",
33 | "$ref": "../shared/text_resource.json"
34 | }
35 | }
36 | }
37 | }
38 | }
39 | ],
40 | "version": 1
41 | }
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/base_types/map_object_multi_type.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/map_object_multi_type.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "title": "Map_object_multi",
5 | "description": "A map object is a basic type for objects displayed on maps",
6 | "type": "object",
7 | "definitions" : {
8 | "map_object": {
9 | "allOf": [
10 | {
11 | "$ref": "./gis_object.json"
12 | },
13 | {
14 | "properties": {
15 | "display": {
16 | "description": "Default properties to display the object on the map",
17 | "type": "object",
18 | "properties": {
19 | "radius": {
20 | "type": "integer"
21 | },
22 | "fill_color": {
23 | "type": "string"
24 | },
25 | "stroke_color": {
26 | "type": "string"
27 | },
28 | "icon": {
29 | "type": "object",
30 | "$ref": "../shared/icon.json"
31 | },
32 | "caption": {
33 | "description": "How to handle locale",
34 | "type": "object",
35 | "$ref": "../shared/text_resource.json"
36 | }
37 | }
38 | }
39 | }
40 | }
41 | ]
42 | }
43 | },
44 | "version": 1
45 | }
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/base_types/simple_gis_object.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/simple_gis_object.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "title": "GIS_object",
5 | "description": "A GIS object is an application defined type that owns GIS coordinates",
6 | "type": "object",
7 | "properties": {
8 | "gis": {
9 | "description": "Definition of an object that owns GIS coordinates. At minimum an object of this type owns one of the props",
10 | "type": "object",
11 | "properties": {
12 | "center": {
13 | "type": "string"
14 | },
15 | "area": {
16 | "type": "string"
17 | },
18 | "route": {
19 | "type": "string"
20 | }
21 | }
22 | }
23 | },
24 | "required": [
25 | "gis"
26 | ],
27 | "version": 1
28 | }
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/base_types/simple_map_object.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/simple_map_object.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "title": "Map_object",
5 | "description": "A map object is a basic type for objects displayed on maps",
6 | "type": "object",
7 | "allOf": [
8 | {
9 | "$ref": "./simple_gis_object.json"
10 | },
11 | {
12 | "properties": {
13 | "display": {
14 | "description": "Default properties to display the object on the map",
15 | "type": "object",
16 | "properties": {
17 | "radius": {
18 | "type": "integer"
19 | },
20 | "fill_color": {
21 | "type": "string"
22 | },
23 | "stroke_color": {
24 | "type": "string"
25 | },
26 | "icon": {
27 | "type": "object",
28 | "$ref": "../shared/icon.json"
29 | },
30 | "caption": {
31 | "description": "How to handle locale",
32 | "type": "object",
33 | "$ref": "../shared/text_resource.json"
34 | }
35 | }
36 | }
37 | }
38 | }
39 | ],
40 | "version": 1
41 | }
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/extra_types.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "title": "Type-Test",
4 | "description": "Test for more exotic types",
5 | "definitions": {
6 | "ExtraType": {
7 | "type": "object",
8 | "properties": {
9 | "intAttrib": {
10 | "type": "integer",
11 | },
12 | "intAttrib2": {
13 | "type": "integer",
14 | "format": "int32"
15 | },
16 | "noIntAttrib": {
17 | "type": "integer",
18 | "format": "int64"
19 | },
20 | "byteAttrib": {
21 | "type": "integer",
22 | "format": "byte"
23 | }
24 | }
25 | }
26 | },
27 | "type": "object",
28 | "__version": 3
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/implicit_ref.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://oth.de/schemas/documents.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "title": "documents",
5 | "description": "a simple data model that save data for different documents",
6 | "definitions": {
7 | "document_type": {
8 | "type": "object",
9 | "properties": {
10 | "gid": {
11 | "type": "string",
12 | "format": "uuid"
13 | },
14 | "text": {
15 | "description": "Short text that describes the tag",
16 | "type": "string"
17 | },
18 | "comment": {
19 | "description": "Comment to that tab",
20 | "type": "string"
21 | },
22 | "active": {
23 | "description": "is the entry currently active",
24 | "type": "boolean"
25 | }
26 | }
27 | },
28 | "comment": {
29 | "type": "object",
30 | "properties": {
31 | "text": {
32 | "description": "comment text",
33 | "type": "string"
34 | },
35 | "date": {
36 | "description": "date of entry",
37 | "type": "string",
38 | "format": "date-time"
39 | },
40 | "user": {
41 | "description": "who did this comment",
42 | "type": "string"
43 | }
44 | }
45 | },
46 | "tag": {
47 | "type": "object",
48 | "properties": {
49 | "gid": {
50 | "type": "string",
51 | "format": "uuid"
52 | },
53 | "text": {
54 | "description": "Short text that describes the tag",
55 | "type": "string"
56 | },
57 | "comment": {
58 | "description": "Comment to that tab",
59 | "type": "string"
60 | },
61 | "color": {
62 | "description": "color that marks this tag",
63 | "type": "string"
64 | }
65 | }
66 | },
67 | "document": {
68 | "type": "object",
69 | "properties": {
70 | "gid": {
71 | "type": "string",
72 | "format": "uuid"
73 | },
74 | "path": {
75 | "description": "where is the document located",
76 | "type": "string"
77 | },
78 | "preview": {
79 | "description": "where is the document preview located",
80 | "type": "string"
81 | },
82 | "icon": {
83 | "description": "icon preview for the document",
84 | "type": "string"
85 | },
86 | "comments": {
87 | "type": "array",
88 | "items": {
89 | "$ref": "#/definitions/comment"
90 | }
91 | },
92 | "date": {
93 | "type": "string",
94 | "format": "date"
95 | },
96 | "type": {
97 | "$ref": "#/definitions/document_type"
98 | },
99 | "tags": {
100 | "type": "array",
101 | "items": {
102 | "type": "string",
103 | "format": "uuid",
104 | "__ref": "#/definitions/tag"
105 | }
106 | }
107 | }
108 | }
109 | },
110 | "type": "object",
111 | "version": 1
112 | }
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/junction_base.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "title": "Junction base model",
4 | "description": "Junction is a anchor point of interest of application level",
5 | "definitions": {
6 | "JunctionBase": {
7 | "type": "object",
8 | "description": "Junction is a anchor point of interest of application level, that's the minimal information about that",
9 | "properties": {
10 | "guid": {
11 | "type": "string",
12 | "format": "uuid",
13 | "__tags": ["internal"]
14 | },
15 | "domainId": {
16 | "description": "what is the related domain",
17 | "type": "string",
18 | "format": "uuid",
19 | "__ref": "./shared/domain.json",
20 | "__tags": ["internal"]
21 | },
22 | "tags": {
23 | "type": "array",
24 | "items": {
25 | "type": "string",
26 | "format": "uuid",
27 | "__ref": "./shared/tag.json"
28 | }
29 | },
30 | "name": {
31 | "description": "main name of the junction",
32 | "type": "string"
33 | },
34 | "number": {
35 | "description": "main number of the junction",
36 | "type": "string"
37 | },
38 | "gis": {
39 | "description": "location of that junciton",
40 | "type": "object",
41 | "properties": {
42 | "area": {
43 | "description": "geografic area of this object",
44 | "$ref": "./shared/geo_area.json"
45 | },
46 | "center": {
47 | "description": "geografic area of this object",
48 | "$ref": "./shared/geo_point.json"
49 | }
50 | }
51 | }
52 | },
53 | "__tags": ["rest","mongodb"]
54 | }
55 | },
56 | "type": "object",
57 | "version": 1
58 | }
59 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/license.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "title": "License model",
4 | "description": "Test license model",
5 | "definitions": {
6 | "license": {
7 | "type": "object",
8 | "properties": {
9 | "gid": {
10 | "type": "string",
11 | "format": "uuid"
12 | },
13 | "domain_id": {
14 | "description": "what is the related domain",
15 | "type": "string",
16 | "format": "uuid",
17 | "__ref": "./shared/domain.json"
18 | },
19 | "app_modues" : {
20 | "type": "array",
21 | "items": {
22 | "$ref": "./shared/app_module.json"
23 | }
24 | },
25 | "count": {
26 | "description": "how many licenses are given",
27 | "type": "integer"
28 | },
29 | "start_date": {
30 | "description": "when goes this licence active",
31 | "type": "string",
32 | "format": "date"
33 | },
34 | "end_date": {
35 | "description": "when runs this licence out of active state",
36 | "type": "string",
37 | "format": "date"
38 | },
39 | "active": {
40 | "description": "this is a current license entry",
41 | "type": "boolean"
42 | }
43 |
44 | }
45 | }
46 | },
47 | "type": "object",
48 | "version": 1
49 | }
50 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/model.puml:
--------------------------------------------------------------------------------
1 | @startuml
2 |
3 | package "license service" {
4 | class domain {
5 |
6 | }
7 |
8 | class application {
9 | }
10 |
11 | class app_module {
12 | }
13 |
14 | domain "m" -- "n" application: relation isn't designed yet
15 | application "1" -- "n" app_module
16 |
17 | class license {
18 | }
19 | }
20 |
21 | license "m" -- "n" app_module
22 | domain "1" -- "n" license
23 |
24 |
25 | package "user service" {
26 | class user {
27 | domain:string
28 | }
29 |
30 | class user_log {
31 | domain:string
32 | }
33 |
34 | class "role" as role {
35 | domain:string
36 | name:string
37 | }
38 |
39 | class module_grant {
40 | app_module_id:string
41 | read:boolean
42 | write:boolean
43 | lock:boolean
44 | }
45 |
46 | class data_grant
47 | }
48 | role -- module_grant
49 | role -- data_grant
50 |
51 | role "m"--"n" user
52 |
53 | app_module -- module_grant
54 |
55 |
56 | user_log "n"--"1" user
57 |
58 | note top of role
59 | provided with the token
60 | of Keycloak
61 | end note
62 |
63 | note "server need to resolv\nthe role name\nto specific actions" as app_grants
64 |
65 | module_grant .. app_grants
66 | data_grant .. app_grants
67 | @enduml
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/referenced_multi_types.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "title": "referenced multi types",
4 | "description": "Test model with top-level referenced model files",
5 | "definitions": {
6 | "incident": {
7 | "$ref": "./incident.json#/incident"
8 | },
9 | "user": {
10 | "$ref": "./user.json#/user"
11 | }
12 | },
13 | "type": "object",
14 | "version": 1
15 | }
16 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/app_module.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/shared/app_module.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "application specific module",
5 | "type": "object",
6 | "properties": {
7 | "name": {
8 | "description": "Name of the module",
9 | "type": "string",
10 | "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
11 | "__unique": true,
12 | "__visKey": true
13 | },
14 | "description": {
15 | "description": "some more words to explain",
16 | "type": "string"
17 | },
18 | "guid": {
19 | "description": "global identifier",
20 | "type": "string",
21 | "format": "uuid"
22 | },
23 | "app_id": {
24 | "description": "Which application owns that module",
25 | "type": "string",
26 | "format": "uuid",
27 | "__ref": "./application.json"
28 | },
29 | "active": {
30 | "description": "is this entry still active",
31 | "type": "boolean"
32 | }
33 | },
34 | "required": [
35 | "name",
36 | "gid"
37 | ],
38 | "version": 1
39 | }
40 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/application.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/shared/application.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "application data",
5 | "type": "object",
6 | "properties": {
7 | "name": {
8 | "description": "Name of the application",
9 | "type": "string",
10 | "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
11 | "unique": true,
12 | "__visKey": true
13 | },
14 | "description": {
15 | "description": "some more words to explain",
16 | "type": "string"
17 | },
18 | "gid": {
19 | "description": "global identifier",
20 | "type": "string",
21 | "format": "uuid"
22 | },
23 | "active": {
24 | "description": "is this entry still active",
25 | "type": "boolean"
26 | }
27 | },
28 | "required": [
29 | "name",
30 | "gid"
31 | ],
32 | "version": 1
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/comment.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/shared/domain.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "A comment for an data entry",
5 | "type": "object",
6 | "properties": {
7 | "text": {
8 | "description": "comment text",
9 | "type": "string"
10 | },
11 | "date": {
12 | "description": "date of entry",
13 | "type": "string",
14 | "format": "date-time"
15 | },
16 | "user": {
17 | "description": "who did this comment",
18 | "type": "string"
19 | },
20 | "gid": {
21 | "description": "global identifier",
22 | "type": "string",
23 | "format": "uuid"
24 | }
25 | },
26 | "tags": [
27 | "no_unbound_get",
28 | "no_unbound_add"
29 | ],
30 | "required": [
31 | "text",
32 | "date",
33 | "user"
34 | ],
35 | "version": 1
36 | }
37 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/domain.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/shared/domain.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "Domain of a running application.",
5 | "type": "object",
6 | "properties": {
7 | "name": {
8 | "description": "Domain name",
9 | "type": "string",
10 | "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
11 | "__unique": true,
12 | "__visKey": true
13 | },
14 | "description": {
15 | "description": "some words to explain",
16 | "type": "string"
17 | },
18 | "gid": {
19 | "description": "global identifier",
20 | "type": "string",
21 | "format": "uuid"
22 | },
23 | "active": {
24 | "description": "is this entry still active",
25 | "type": "boolean"
26 | }
27 | },
28 | "required": [
29 | "name",
30 | "domain_id"
31 | ],
32 | "__version": 4
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/field_entry.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/shared/text_resource.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "Definition of a text resource",
5 | "type": "object",
6 | "properties": {
7 | "meta": {
8 | "description": "enable more entries",
9 | "type": "object",
10 | "properties": {
11 | "name": {
12 | "description": "Name of that entry",
13 | "type": "string"
14 | }
15 | }
16 | },
17 | "type": {
18 | "description": "type of that entry",
19 | "type": "string"
20 | },
21 | "childs": {
22 | "type": "array",
23 | "items": {
24 | "$ref": "./field_entry.json"
25 | }
26 | },
27 | "display": {
28 | "type": "object",
29 | "properties": {
30 | "visible": {
31 | "description": "type of that entry",
32 | "type": "boolean"
33 | },
34 | "caption": {
35 | "description": "What is the caption of that field",
36 | "$ref": "./text_resource.json"
37 | },
38 | "icon": {
39 | "description": "What is the caption of that field",
40 | "$ref": "./icon.json"
41 | }
42 | }
43 | },
44 | "modify": {
45 | "type": "object",
46 | "properties": {
47 | "changeble": {
48 | "description": "type of that entry",
49 | "type": "boolean"
50 | },
51 | "needed": {
52 | "description": "is this field needed",
53 | "type": "boolean"
54 | },
55 | "possible_values": {
56 | "type": "object",
57 | "properties": {
58 | "values": {
59 | "type": "array",
60 | "items": {
61 | "type": "string"
62 | }
63 | },
64 | "query_link": {
65 | "type": "string"
66 | }
67 | }
68 | }
69 | }
70 | }
71 | },
72 | "version": 1
73 | }
74 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/geo_area.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/shared/geo_area.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "Area geo-type",
5 | "type": "object",
6 | "properties": {
7 | "projection": {
8 | "description": "geographic projection used for this object",
9 | "type": "string"
10 | },
11 | "points": {
12 | "description": "polygon points",
13 | "type": "array",
14 | "items": {
15 | "$ref": "./geo_point.json"
16 | }
17 | }
18 | },
19 | "required": [
20 | "points"
21 | ],
22 | "version": 1
23 | }
24 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/geo_multiline.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/shared/geo_multiline.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "Multiline geo-type",
5 | "type": "object",
6 | "properties": {
7 | "projection": {
8 | "description": "geographic projection used for this object",
9 | "type": "string"
10 | },
11 | "points": {
12 | "description": "points of the multiline in the right order",
13 | "type": "array",
14 | "items": {
15 | "$ref": "./geo_point.json"
16 | }
17 | }
18 | },
19 | "required": [
20 | "points"
21 | ],
22 | "version": 1
23 | }
24 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/geo_point.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/shared/geo_point.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "Single point geo-type",
5 | "type": "object",
6 | "properties": {
7 | "projection": {
8 | "description": "geographic projection used for this point",
9 | "type": "string"
10 | },
11 | "lon": {
12 | "description": "longitude of the point",
13 | "type": "number"
14 | },
15 | "lat": {
16 | "description": "latitude of the point",
17 | "type": "number"
18 | }
19 | },
20 | "required": [
21 | "lon",
22 | "lat"
23 | ],
24 | "version": 1
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/icon.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/shared/icon.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "Icon definition",
5 | "type": "object",
6 | "properties": {
7 | "url": {
8 | "description": "download url for that icon",
9 | "type": "string"
10 | },
11 | "res_id": {
12 | "description": "resource id of that icon",
13 | "type": "string"
14 | }
15 | },
16 | "__tags": ["eins","zwei","drei"],
17 | "version": 1
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/junction_short.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/shared/app_module.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "short version of junction data. Used to save redundant in related data sets",
5 | "type": "object",
6 | "properties": {
7 | "name": {
8 | "description": "main name of this junction",
9 | "type": "string"
10 | },
11 | "number": {
12 | "description": "all the number (technical names) of this object",
13 | "type": "string"
14 | },
15 | "gid": {
16 | "description": "global identifier",
17 | "type": "string",
18 | "format": "uuid"
19 | }
20 | },
21 | "required": [
22 | "name",
23 | "gid"
24 | ],
25 | "version": 1
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/list_entry.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/shared/tenant.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "type for entries that have references to look-up tables - as an more dynamic alternative to enums",
5 | "type": "object",
6 | "properties": {
7 | "text": {
8 | "description": "a default text to display",
9 | "type": "string",
10 | "__tags": ["formatString"]
11 | },
12 | "refId": {
13 | "description": "guid in the lookup-table to enable later editing of texts",
14 | "type": "string",
15 | "format": "uuid",
16 | "__tags": ["notDisplayed"]
17 | }
18 | },
19 | "__tags": ["noHandling"],
20 | "required": [
21 | "text"
22 | ],
23 | "__version": 1
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/options_response.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/shared/app_module.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "application specific module",
5 | "type": "object",
6 | "properties": {
7 | "caption": {
8 | "$ref": "./text_resource.json"
9 | },
10 | "fields": {
11 | "type": "array",
12 | "items": {
13 | "$ref": "./field_entry.json"
14 | }
15 | },
16 | "commands": {
17 | "type": "string"
18 | }
19 | },
20 | "required": [
21 | "fields"
22 | ],
23 | "version": 1
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/options_response2.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "title": "License model",
4 | "description": "Test license model",
5 | "definitions": {
6 | "license": {
7 | "type": "object",
8 | "properties": {
9 | "gid": {
10 | "type": "string",
11 | "format": "uuid"
12 | },
13 | "app_modues" : {
14 | "type": "array",
15 | "items": {
16 | "$ref": "./app_module.json"
17 | }
18 | },
19 | "count": {
20 | "description": "how many licenses are given",
21 | "type": "integer"
22 | },
23 | "start_date": {
24 | "description": "when goes this licence active",
25 | "type": "string",
26 | "format": "date"
27 | },
28 | "end_date": {
29 | "description": "when runs this licence out of active state",
30 | "type": "string",
31 | "format": "date"
32 | },
33 | "active": {
34 | "description": "this is a current license entry",
35 | "type": "boolean"
36 | },
37 | "license": {
38 | "description": "test for internal recursion",
39 | "$ref": "#/definitions/license"
40 | }
41 |
42 | }
43 | }
44 | },
45 | "type": "object",
46 | "version": 1
47 | }
48 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/region.json:
--------------------------------------------------------------------------------
1 |
2 |
3 | {
4 | "id": "http://schlothauer.de/schemas/shared/tenant.json",
5 | "$schema": "http://json-schema.org/draft-04/schema#",
6 | "description": "A region is some kind of a logical group that could be set for some entries. It allows 'vertical' restrictions of object visibility",
7 | "type": "object",
8 | "properties": {
9 | "guid": {
10 | "type": "string",
11 | "format": "uuid",
12 | "__tags": ["notDisplayed", "notNull"]
13 | },
14 | "name": {
15 | "description": "Name of the tag",
16 | "type": "string",
17 | "__tags": ["notNull","unique"]
18 | },
19 | "group": {
20 | "description": "Short text that describes the tag",
21 | "type": "string"
22 | },
23 | "comment": {
24 | "description": "Comment to that tab",
25 | "type": "string"
26 | },
27 | "created": {
28 | "type": "string",
29 | "format": "datetime"
30 | },
31 | "active": {
32 | "type": "boolean",
33 | "__tags": ["notNull","defaultTrue"]
34 | },
35 | "locked": {
36 | "description": "entry is needed and should not be deleted",
37 | "type": "boolean",
38 | "__tags": ["notNull","defaultFalse"]
39 | },
40 | "tenantId": {
41 | "description": "what is the related domain",
42 | "type": "string",
43 | "format": "uuid",
44 | "__ref": "./tenant.json",
45 | "__tags": ["notDisplayed"]
46 | }
47 | },
48 | "required": [
49 | "guid",
50 | "text"
51 | ],
52 | "__tags": ["rest","mongodb","selList"],
53 | "__version": 1
54 | }
55 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/selection_entry.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/shared/app_module.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "generic type that descripes the entry of a selection list",
5 | "type": "object",
6 | "properties": {
7 | "name": {
8 | "description": "a describing name",
9 | "type": "string",
10 | "unique": true,
11 | "visKey": true
12 | },
13 | "description": {
14 | "description": "some more words to explain",
15 | "type": "string"
16 | },
17 | "gid": {
18 | "description": "global identifier",
19 | "type": "string",
20 | "format": "uuid"
21 | },
22 | "active": {
23 | "description": "is this entry still active",
24 | "type": "boolean"
25 | }
26 | },
27 | "required": [
28 | "name",
29 | "gid"
30 | ],
31 | "version": 1
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/tag.json:
--------------------------------------------------------------------------------
1 |
2 |
3 | {
4 | "id": "http://schlothauer.de/schemas/shared/domain.json",
5 | "$schema": "http://json-schema.org/draft-04/schema#",
6 | "description": "A tag is some kind of a global keyword that could be set for some entries",
7 | "type": "object",
8 | "properties": {
9 | "guid": {
10 | "type": "string",
11 | "format": "uuid"
12 | },
13 | "text": {
14 | "description": "Short text that describes the tag",
15 | "type": "string"
16 | },
17 | "group": {
18 | "description": "Short text that describes the tag",
19 | "type": "string"
20 | },
21 | "comment": {
22 | "description": "Comment to that tab",
23 | "type": "string"
24 | },
25 | "color": {
26 | "description": "color that marks this tag",
27 | "type": "string"
28 | },
29 | "created": {
30 | "type": "string",
31 | "format": "datetime"
32 | },
33 | "active": {
34 | "type": "boolean"
35 | },
36 | "internal": {
37 | "type": "boolean"
38 | }
39 | },
40 | "required": [
41 | "guid",
42 | "text"
43 | ],
44 | "version": 1
45 | }
46 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/tenant.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/shared/tenant.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "Tenant of a running application.",
5 | "type": "object",
6 | "properties": {
7 | "name": {
8 | "description": "Tenant name",
9 | "type": "string",
10 | "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
11 | "__tags": ["notNull","unique"]
12 | },
13 | "description": {
14 | "description": "some words to explain",
15 | "type": "string"
16 | },
17 | "guid": {
18 | "description": "global identifier",
19 | "type": "string",
20 | "format": "uuid",
21 | "__tags": ["notDisplayed", "notNull"]
22 | },
23 | "active": {
24 | "description": "is this entry still active",
25 | "type": "boolean",
26 | "__tags": ["notNull","defaultTrue"]
27 | }
28 | },
29 | "required": [
30 | "name",
31 | "guid"
32 | ],
33 | "__version": 1
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/ds/shared/text_resource.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "http://schlothauer.de/schemas/shared/text_resource.json",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "Definition of a text resource",
5 | "type": "object",
6 | "properties": {
7 | "text": {
8 | "description": "Text to display",
9 | "type": "string"
10 | },
11 | "res_id": {
12 | "description": "resource id of that text",
13 | "type": "string"
14 | }
15 | },
16 | "version": 1
17 | }
18 |
--------------------------------------------------------------------------------
/src/test/resources/test_schemas/multiType.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "title": "JSON schema for multi type testing",
4 | "description": "This is a multi type test schema :)",
5 | "definitions": {
6 | "action": {
7 | "type": "object",
8 | "properties": {
9 | "default_title": {
10 | "description": "Tooltip for the main toolbar icon.",
11 | "type": "string"
12 | },
13 | "default_popup": {
14 | "description": "The popup appears when the user clicks the icon.",
15 | "$ref": "#/definitions/icon"
16 | },
17 | "default_icon": {
18 | "description": "Icon for the main toolbar.",
19 | "type": "object",
20 | "properties": {
21 | "19": {
22 | "$ref": "#/definitions/icon"
23 | },
24 | "38": {
25 | "$ref": "#/definitions/icon"
26 | }
27 | }
28 | }
29 | }
30 | },
31 | "icon": {
32 | "type": "object",
33 | "properties": {
34 | "description": {
35 | "type": "string"
36 | },
37 | "suggested_key": {
38 | "type": "object",
39 | "patternProperties": {
40 | "^(default|mac|windows|linux|chromeos)$": {
41 | "type": "string",
42 | "pattern": "^(Ctrl|Command|MacCtrl|Alt|Option)\\+(Shift\\+)?[A-Z]"
43 | }
44 | },
45 | "additionalProperties": false
46 | }
47 | }
48 | },
49 | "command": {
50 | "type": "object",
51 | "properties": {
52 | "description": {
53 | "type": "string"
54 | },
55 | "suggested_key": {
56 | "type": "object",
57 | "patternProperties": {
58 | "^(default|mac|windows|linux|chromeos)$": {
59 | "type": "string",
60 | "pattern": "^(Ctrl|Command|MacCtrl|Alt|Option)\\+(Shift\\+)?[A-Z]"
61 | }
62 | },
63 | "additionalProperties": false
64 | }
65 | }
66 | }
67 | },
68 | "type": "object",
69 | "properties": {
70 | "model_version": {
71 | "description": "version of the current model",
72 | "type": "number",
73 | "enum": [
74 | 1
75 | ],
76 | "maximum": 1,
77 | "minimum": 1
78 | },
79 | "default_locale": {
80 | "description": "Specifies the subdirectory of _locales that contains the default strings for this extension.",
81 | "type": "string",
82 | "default": "en"
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/test/resources/xsd/complex/ElectronicRegistrationIdentificationVehicleDataModule.xsd:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/src/test/resources/xsd/complex/REGION.xsd:
--------------------------------------------------------------------------------
1 |
2 |
4 |
10 |
12 |
14 |
15 |
--------------------------------------------------------------------------------
/src/test/resources/xsd/simpleTest.xsd:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 | This is a simple test
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | This is a simple test2
23 | over more than one line
24 |
25 |
26 |
27 |
28 |
29 | That's a name
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | This is a simple test2
48 | over more than one line
49 |
50 |
51 |
52 |
53 |
54 | That's a name
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------