Keong Lim | cae9c8d | 2019-05-17 15:29:58 +1000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # time ./generate-uml-snapshot.sh 2>&1 | tee log-generate-uml-snapshot.txt |
| 4 | |
| 5 | set -x |
| 6 | |
| 7 | # start in aai/schema-service repo |
| 8 | STARTDIR=`pwd` |
| 9 | git status |
| 10 | |
| 11 | # modify templates |
| 12 | if [ -f ${STARTDIR}/aai-schema-gen/src/main/resources/swagger.html.ftl -a -f ${STARTDIR}/aai-schema-gen/src/main/resources/swagger.plantuml.ftl ] ; then |
| 13 | cp ${STARTDIR}/aai-schema-gen/src/main/resources/swagger.plantuml.ftl ${STARTDIR}/aai-schema-gen/src/main/resources/swagger.html.ftl |
| 14 | mvn --offline -DskipTests process-classes |
| 15 | git status |
| 16 | fi |
| 17 | |
| 18 | # $ find aai-schema/src/main -name "aai_swagger_*.html" |
| 19 | # aai-schema/src/main/resources/onap/aai_swagger_html/aai_swagger_v10.html |
| 20 | # aai-schema/src/main/resources/onap/aai_swagger_html/aai_swagger_v11.html |
| 21 | # aai-schema/src/main/resources/onap/aai_swagger_html/aai_swagger_v12.html |
| 22 | # aai-schema/src/main/resources/onap/aai_swagger_html/aai_swagger_v13.html |
| 23 | # aai-schema/src/main/resources/onap/aai_swagger_html/aai_swagger_v14.html |
| 24 | # aai-schema/src/main/resources/onap/aai_swagger_html/aai_swagger_v15.html |
| 25 | # aai-schema/src/main/resources/onap/aai_swagger_html/aai_swagger_v16.html |
| 26 | |
| 27 | |
| 28 | mkdir -p ${STARTDIR}/plantuml/backups |
| 29 | cp ${STARTDIR}/aai-schema/src/main/resources/onap/aai_swagger_html/aai_swagger_*.html ${STARTDIR}/plantuml/ |
| 30 | |
| 31 | cd ${STARTDIR}/plantuml/ |
| 32 | |
| 33 | # OXM transformation - class names |
| 34 | for f in aai_swagger_*.html ; do mv $f `basename $f | sed 's/\.html//'`.plantuml ; done |
| 35 | |
| 36 | # pre-clean |
| 37 | sed -i.bak0 -s 's/\/{[^\/]*}//g' aai_swagger_*.plantuml |
| 38 | sed -i.bak1 -s 's/\/relationship[^\/]*//g' aai_swagger_*.plantuml |
| 39 | |
| 40 | grep -c "^class.*\/" aai_swagger_*.plantuml |
| 41 | RET=$? |
| 42 | COUNT=0 |
| 43 | while [ ${RET} -eq 0 ] ; do |
| 44 | COUNT=$(( COUNT + 1 )) |
| 45 | echo Replacing ${COUNT}... |
| 46 | sed -i.bak2-${COUNT} -s 's/^class \/\([^\/]*\)/class \1\nclass /' aai_swagger_*.plantuml |
| 47 | grep -c "^class.*\/" aai_swagger_*.plantuml |
| 48 | RET=$? |
| 49 | done |
| 50 | |
| 51 | # unique without sorting |
| 52 | for f in aai_swagger_*.plantuml ; do |
| 53 | cp ${f} ${f}.bak3 |
| 54 | awk '!a[$0]++' ${f}.bak3 > ${f} |
| 55 | done |
| 56 | |
| 57 | # OXM transformation - compositions |
| 58 | sed -i.bak4 -s 's/^\//"/g' aai_swagger_*.plantuml |
| 59 | |
| 60 | grep -c "^\".*\/.*\/" aai_swagger_*.plantuml |
| 61 | RET=$? |
| 62 | COUNT=0 |
| 63 | while [ ${RET} -eq 0 ] ; do |
| 64 | COUNT=$(( COUNT + 1 )) |
| 65 | echo Replacing ${COUNT}... |
| 66 | sed -i.bak5-${COUNT} -s 's/^"[^\/]*\/\([^\/]*\)\//"\1\//' aai_swagger_*.plantuml |
| 67 | grep -c "^\".*\/.*\/" aai_swagger_*.plantuml |
| 68 | RET=$? |
| 69 | done |
| 70 | |
| 71 | sed -i.bak6 -s 's/^"\([^\/]*\)\/\([^\/]*\)/"\1" *-- "\2"/' aai_swagger_*.plantuml |
| 72 | |
| 73 | # post-clean |
| 74 | sed -i.bak7 -s '/^class $/d' aai_swagger_*.plantuml |
| 75 | sed -i.bak8 -s '/^Note: Convert/d' aai_swagger_*.plantuml |
| 76 | |
| 77 | # unique without sorting |
| 78 | for f in aai_swagger_*.plantuml ; do |
| 79 | cp ${f} ${f}.bak9 |
| 80 | awk '!a[$0]++' ${f}.bak9 > ${f} |
| 81 | done |
| 82 | |
| 83 | |
| 84 | # $ find aai-schema/src/main -name "DbEdgeRules*.json" |
| 85 | # aai-schema/src/main/resources/onap/dbedgerules/v10/DbEdgeRules_v10.json |
| 86 | # aai-schema/src/main/resources/onap/dbedgerules/v11/DbEdgeRules_esr_v11.json |
| 87 | # aai-schema/src/main/resources/onap/dbedgerules/v11/DbEdgeRules_v11.json |
| 88 | # aai-schema/src/main/resources/onap/dbedgerules/v12/DbEdgeRules_esr_v12.json |
| 89 | # aai-schema/src/main/resources/onap/dbedgerules/v12/DbEdgeRules_hpa_v12.json |
| 90 | # aai-schema/src/main/resources/onap/dbedgerules/v12/DbEdgeRules_v12.json |
| 91 | # aai-schema/src/main/resources/onap/dbedgerules/v13/DbEdgeRules_esr_v13.json |
| 92 | # aai-schema/src/main/resources/onap/dbedgerules/v13/DbEdgeRules_hpa_v13.json |
| 93 | # aai-schema/src/main/resources/onap/dbedgerules/v13/DbEdgeRules_v13.json |
| 94 | # aai-schema/src/main/resources/onap/dbedgerules/v14/DbEdgeRules_ccvpn_v14.json |
| 95 | # aai-schema/src/main/resources/onap/dbedgerules/v14/DbEdgeRules_esr_v14.json |
| 96 | # aai-schema/src/main/resources/onap/dbedgerules/v14/DbEdgeRules_hpa_v14.json |
| 97 | # aai-schema/src/main/resources/onap/dbedgerules/v14/DbEdgeRules_pnp_v14.json |
| 98 | # aai-schema/src/main/resources/onap/dbedgerules/v14/DbEdgeRules_v14.json |
| 99 | # aai-schema/src/main/resources/onap/dbedgerules/v15/DbEdgeRules_ccvpn_v15.json |
| 100 | # aai-schema/src/main/resources/onap/dbedgerules/v15/DbEdgeRules_esr_v15.json |
| 101 | # aai-schema/src/main/resources/onap/dbedgerules/v15/DbEdgeRules_hpa_v15.json |
| 102 | # aai-schema/src/main/resources/onap/dbedgerules/v15/DbEdgeRules_pnp_v15.json |
| 103 | # aai-schema/src/main/resources/onap/dbedgerules/v15/DbEdgeRules_v15.json |
| 104 | # aai-schema/src/main/resources/onap/dbedgerules/v16/DbEdgeRules_bbs_v16.json |
| 105 | # aai-schema/src/main/resources/onap/dbedgerules/v16/DbEdgeRules_ccvpn_v16.json |
| 106 | # aai-schema/src/main/resources/onap/dbedgerules/v16/DbEdgeRules_esr_v16.json |
| 107 | # aai-schema/src/main/resources/onap/dbedgerules/v16/DbEdgeRules_hpa_v16.json |
| 108 | # aai-schema/src/main/resources/onap/dbedgerules/v16/DbEdgeRules_pnp_v16.json |
| 109 | # aai-schema/src/main/resources/onap/dbedgerules/v16/DbEdgeRules_v16.json |
| 110 | # aai-schema/src/main/resources/onap/dbedgerules/v8/DbEdgeRules_v8.json |
| 111 | # aai-schema/src/main/resources/onap/dbedgerules/v9/DbEdgeRules_v9.json |
| 112 | |
| 113 | # EdgeRule transformation |
| 114 | for g in v16 v15 v14 v13 v12 v11 ; do |
| 115 | cat ${STARTDIR}/aai-schema/src/main/resources/onap/dbedgerules/${g}/DbEdgeRules*_${g}.json >> ${STARTDIR}/plantuml/aai_edgerules_${g}.plantuml |
| 116 | done |
| 117 | |
| 118 | for f in v16 v15 v14 v13 v12 v11 ; do |
| 119 | cp aai_edgerules_${f}.plantuml aai_edgerules_${f}.plantuml.bak1 |
| 120 | echo "@startuml" > aai_edgerules_${f}.plantuml |
| 121 | echo "title ${f} Active and Available Inventory EdgeRule Relationships" >> aai_edgerules_${f}.plantuml |
| 122 | awk -F \" '/"from"/ { from = $4 } /"to"/ { to = $4 } /"label"/ { label = $4 ; print "\"" from "\" -- \"" to "\" : " label " >" }' aai_edgerules_${f}.plantuml.bak1 | sort -u >> aai_edgerules_${f}.plantuml |
| 123 | echo "@enduml" >> aai_edgerules_${f}.plantuml |
| 124 | done |
| 125 | |
| 126 | sed -i.bak2 -s '/inventory.BelongsTo/d' aai_edgerules_*.plantuml |
| 127 | sed -i.bak3 -s 's/: \(.*\.\)/: /' aai_edgerules_*.plantuml |
| 128 | |
| 129 | # save backups and restore originals |
| 130 | cd ${STARTDIR} |
| 131 | mv ${STARTDIR}/plantuml/*.bak* ${STARTDIR}/plantuml/backups |
| 132 | ls -alR ${STARTDIR}/plantuml |
| 133 | git status |
| 134 | |
| 135 | if [ -f ${STARTDIR}/aai-schema-gen/src/main/resources/swagger.html.ftl -a -f ${STARTDIR}/aai-schema-gen/src/main/resources/swagger.plantuml.ftl ] ; then |
| 136 | git checkout ${STARTDIR}/aai-schema-gen/src/main/resources/swagger.plantuml.ftl ${STARTDIR}/aai-schema-gen/src/main/resources/swagger.html.ftl |
Keong Lim | c44bcf6 | 2019-07-19 18:43:10 +1000 | [diff] [blame] | 137 | mvn --offline -DskipTests process-classes |
| 138 | |
| 139 | # $ find aai-schema/src/main -name "aai_swagger_*.yaml" |
| 140 | # aai-schema/src/main/resources/onap/aai_swagger_yaml/aai_swagger_v10.nodes.yaml |
| 141 | # aai-schema/src/main/resources/onap/aai_swagger_yaml/aai_swagger_v10.yaml |
| 142 | # aai-schema/src/main/resources/onap/aai_swagger_yaml/aai_swagger_v11.nodes.yaml |
| 143 | # aai-schema/src/main/resources/onap/aai_swagger_yaml/aai_swagger_v11.yaml |
| 144 | # aai-schema/src/main/resources/onap/aai_swagger_yaml/aai_swagger_v12.nodes.yaml |
| 145 | # aai-schema/src/main/resources/onap/aai_swagger_yaml/aai_swagger_v12.yaml |
| 146 | # aai-schema/src/main/resources/onap/aai_swagger_yaml/aai_swagger_v13.nodes.yaml |
| 147 | # aai-schema/src/main/resources/onap/aai_swagger_yaml/aai_swagger_v13.yaml |
| 148 | # aai-schema/src/main/resources/onap/aai_swagger_yaml/aai_swagger_v14.nodes.yaml |
| 149 | # aai-schema/src/main/resources/onap/aai_swagger_yaml/aai_swagger_v14.yaml |
| 150 | # aai-schema/src/main/resources/onap/aai_swagger_yaml/aai_swagger_v15.nodes.yaml |
| 151 | # aai-schema/src/main/resources/onap/aai_swagger_yaml/aai_swagger_v15.yaml |
| 152 | # aai-schema/src/main/resources/onap/aai_swagger_yaml/aai_swagger_v16.nodes.yaml |
| 153 | # aai-schema/src/main/resources/onap/aai_swagger_yaml/aai_swagger_v16.yaml |
| 154 | |
| 155 | # convert yaml to json |
| 156 | for g in v16 v15 v14 v13 v12 v11 ; do |
| 157 | ${STARTDIR}/yaml2json.py < ${STARTDIR}/aai-schema/src/main/resources/onap/aai_swagger_yaml/aai_swagger_${g}.yaml > ${STARTDIR}/plantuml/aai_swagger_${g}.json |
| 158 | ${STARTDIR}/yaml2json.py < ${STARTDIR}/aai-schema/src/main/resources/onap/aai_swagger_yaml/aai_swagger_${g}.nodes.yaml > ${STARTDIR}/plantuml/aai_swagger_${g}.nodes.json |
| 159 | done |
| 160 | |
Keong Lim | cae9c8d | 2019-05-17 15:29:58 +1000 | [diff] [blame] | 161 | git status |
| 162 | fi |
| 163 | |
| 164 | ls -al ${STARTDIR}/plantuml |
| 165 | |