GostBlockungsdaten.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. import { JavaObject, cast_java_lang_Object } from '../../../java/lang/JavaObject';
  2. import { GostBlockungSchiene, cast_de_nrw_schule_svws_core_data_gost_GostBlockungSchiene } from '../../../core/data/gost/GostBlockungSchiene';
  3. import { JavaString, cast_java_lang_String } from '../../../java/lang/JavaString';
  4. import { GostBlockungRegel, cast_de_nrw_schule_svws_core_data_gost_GostBlockungRegel } from '../../../core/data/gost/GostBlockungRegel';
  5. import { Vector, cast_java_util_Vector } from '../../../java/util/Vector';
  6. import { GostBlockungKurs, cast_de_nrw_schule_svws_core_data_gost_GostBlockungKurs } from '../../../core/data/gost/GostBlockungKurs';
  7. export class GostBlockungsdaten extends JavaObject {
  8. public id : number = -1;
  9. public name : String = "Neue Blockung";
  10. public gostHalbjahr : number = 0;
  11. public schienen : Vector<GostBlockungSchiene> = new Vector();
  12. public regeln : Vector<GostBlockungRegel> = new Vector();
  13. public kurse : Vector<GostBlockungKurs> = new Vector();
  14. public constructor() {
  15. super();
  16. }
  17. isTranspiledInstanceOf(name : string): boolean {
  18. return ['de.nrw.schule.svws.core.data.gost.GostBlockungsdaten'].includes(name);
  19. }
  20. public static transpilerFromJSON(json : string): GostBlockungsdaten {
  21. const obj = JSON.parse(json);
  22. const result = new GostBlockungsdaten();
  23. if (typeof obj.id === "undefined")
  24. throw new Error('invalid json format, missing attribute id');
  25. result.id = obj.id;
  26. if (typeof obj.name === "undefined")
  27. throw new Error('invalid json format, missing attribute name');
  28. result.name = obj.name;
  29. if (typeof obj.gostHalbjahr === "undefined")
  30. throw new Error('invalid json format, missing attribute gostHalbjahr');
  31. result.gostHalbjahr = obj.gostHalbjahr;
  32. if (!!obj.schienen) {
  33. for (let elem of obj.schienen) {
  34. result.schienen?.add(GostBlockungSchiene.transpilerFromJSON(JSON.stringify(elem)));
  35. }
  36. }
  37. if (!!obj.regeln) {
  38. for (let elem of obj.regeln) {
  39. result.regeln?.add(GostBlockungRegel.transpilerFromJSON(JSON.stringify(elem)));
  40. }
  41. }
  42. if (!!obj.kurse) {
  43. for (let elem of obj.kurse) {
  44. result.kurse?.add(GostBlockungKurs.transpilerFromJSON(JSON.stringify(elem)));
  45. }
  46. }
  47. return result;
  48. }
  49. public static transpilerToJSON(obj : GostBlockungsdaten) : string {
  50. let result = '{';
  51. result += '"id" : ' + obj.id + ',';
  52. result += '"name" : ' + '"' + obj.name.valueOf() + '"' + ',';
  53. result += '"gostHalbjahr" : ' + obj.gostHalbjahr + ',';
  54. if (!obj.schienen) {
  55. result += '[]';
  56. } else {
  57. result += '[ ';
  58. for (let i : number = 0; i < obj.schienen.size(); i++) {
  59. let elem = obj.schienen.get(i);
  60. result += GostBlockungSchiene.transpilerToJSON(elem);
  61. if (i < obj.schienen.size() - 1)
  62. result += ',';
  63. }
  64. result += ' ]' + ',';
  65. }
  66. if (!obj.regeln) {
  67. result += '[]';
  68. } else {
  69. result += '[ ';
  70. for (let i : number = 0; i < obj.regeln.size(); i++) {
  71. let elem = obj.regeln.get(i);
  72. result += GostBlockungRegel.transpilerToJSON(elem);
  73. if (i < obj.regeln.size() - 1)
  74. result += ',';
  75. }
  76. result += ' ]' + ',';
  77. }
  78. if (!obj.kurse) {
  79. result += '[]';
  80. } else {
  81. result += '[ ';
  82. for (let i : number = 0; i < obj.kurse.size(); i++) {
  83. let elem = obj.kurse.get(i);
  84. result += GostBlockungKurs.transpilerToJSON(elem);
  85. if (i < obj.kurse.size() - 1)
  86. result += ',';
  87. }
  88. result += ' ]' + ',';
  89. }
  90. result = result.slice(0, -1);
  91. result += '}';
  92. return result;
  93. }
  94. public static transpilerToJSONPatch(obj : Partial<GostBlockungsdaten>) : string {
  95. let result = '{';
  96. if (typeof obj.id !== "undefined") {
  97. result += '"id" : ' + obj.id + ',';
  98. }
  99. if (typeof obj.name !== "undefined") {
  100. result += '"name" : ' + '"' + obj.name.valueOf() + '"' + ',';
  101. }
  102. if (typeof obj.gostHalbjahr !== "undefined") {
  103. result += '"gostHalbjahr" : ' + obj.gostHalbjahr + ',';
  104. }
  105. if (typeof obj.schienen !== "undefined") {
  106. if (!obj.schienen) {
  107. result += '[]';
  108. } else {
  109. result += '[ ';
  110. for (let i : number = 0; i < obj.schienen.size(); i++) {
  111. let elem = obj.schienen.get(i);
  112. result += GostBlockungSchiene.transpilerToJSON(elem);
  113. if (i < obj.schienen.size() - 1)
  114. result += ',';
  115. }
  116. result += ' ]' + ',';
  117. }
  118. }
  119. if (typeof obj.regeln !== "undefined") {
  120. if (!obj.regeln) {
  121. result += '[]';
  122. } else {
  123. result += '[ ';
  124. for (let i : number = 0; i < obj.regeln.size(); i++) {
  125. let elem = obj.regeln.get(i);
  126. result += GostBlockungRegel.transpilerToJSON(elem);
  127. if (i < obj.regeln.size() - 1)
  128. result += ',';
  129. }
  130. result += ' ]' + ',';
  131. }
  132. }
  133. if (typeof obj.kurse !== "undefined") {
  134. if (!obj.kurse) {
  135. result += '[]';
  136. } else {
  137. result += '[ ';
  138. for (let i : number = 0; i < obj.kurse.size(); i++) {
  139. let elem = obj.kurse.get(i);
  140. result += GostBlockungKurs.transpilerToJSON(elem);
  141. if (i < obj.kurse.size() - 1)
  142. result += ',';
  143. }
  144. result += ' ]' + ',';
  145. }
  146. }
  147. result = result.slice(0, -1);
  148. result += '}';
  149. return result;
  150. }
  151. }
  152. export function cast_de_nrw_schule_svws_core_data_gost_GostBlockungsdaten(obj : unknown) : GostBlockungsdaten {
  153. return obj as GostBlockungsdaten;
  154. }