UAModel.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { XMLElem, type IToXML } from "@/util/XmlElem";
  2. import { UARequiredModel } from "./UARequiredModel";
  3. export class UAModel implements IToXML{
  4. constructor(public modelUri: string,
  5. public xmlSchemaUri: string,
  6. public version: string,
  7. public publicationDate: string,
  8. public modelVersion: string,
  9. public accessRestrictions: string,
  10. public requiredModels: UARequiredModel[])
  11. {
  12. }
  13. toXML(): XMLElem {
  14. const model= new XMLElem('Model')
  15. .attr('ModelUri', this.modelUri)
  16. .attr('XmlSchemaUri', this.xmlSchemaUri)
  17. .attr('Version', this.version)
  18. .attr('PublicationDate', this.publicationDate)
  19. .attr('ModelVersion', this.modelVersion)
  20. .attr('AccessRestrictions', this.accessRestrictions);
  21. for(const rm of this.requiredModels) {
  22. model.add(rm.toXML());
  23. }
  24. return model;
  25. }
  26. static fromXML(xmlObject: any): UAModel{
  27. const reqModels:UARequiredModel[]=[];
  28. for(const model of xmlObject['RequiredModel']||[]) {
  29. reqModels.push(UARequiredModel.fromXML(model));
  30. }
  31. return new UAModel(xmlObject['@_ModelUri'], xmlObject['@_XmlSchemaUri'],xmlObject['@_Version'], xmlObject['@_PublicationDate'], xmlObject['@_ModelVersion'], xmlObject['@_AccessRestrictions'], reqModels);
  32. }
  33. }