Procházet zdrojové kódy

parse requiredmodels

Martin Kunz před 9 měsíci
rodič
revize
f0286b67f7
2 změnil soubory, kde provedl 24 přidání a 9 odebrání
  1. 23 9
      src/ua/UAModel.ts
  2. 1 0
      src/ua/UANodeSet.ts

+ 23 - 9
src/ua/UAModel.ts

@@ -1,23 +1,37 @@
 import { XMLElem, type IToXML } from "@/util/XmlElem";
+import { UARequiredModel } from "./UARequiredModel";
 
 export class UAModel implements IToXML{
     constructor(public modelUri: string,
-                public publicationDate: string,
-                public version: string,
-                public xmlSchemaUri: string)
+        public xmlSchemaUri: string,
+        public version: string,
+        public publicationDate: string,
+        public modelVersion: string,
+        public accessRestrictions: string,
+        public requiredModels: UARequiredModel[])
     {
 
     }
 
     toXML(): XMLElem {
-        return new XMLElem('Model')
-                .attr('ModelUri', this.modelUri)
-                .attr('XmlSchemaUri', this.xmlSchemaUri)
-                .attr('Version', this.version)
-                .attr('PublicationDate', this.publicationDate)
+        const model= new XMLElem('Model')
+        .attr('ModelUri', this.modelUri)
+        .attr('XmlSchemaUri', this.xmlSchemaUri)
+        .attr('Version', this.version)
+        .attr('PublicationDate', this.publicationDate)
+        .attr('ModelVersion', this.modelVersion)
+        .attr('AccessRestrictions', this.accessRestrictions);
+        for(const rm of this.requiredModels) {
+            model.add(rm.toXML());
+        }
+        return model;
     }
 
     static fromXML(xmlObject: any): UAModel{
-        return new UAModel(xmlObject['@_ModelUri'], xmlObject['@_PublicationDate'], xmlObject['@_Version'], xmlObject['@_XmlSchemaUri']);
+        const reqModels:UARequiredModel[]=[];
+        for(const model of xmlObject['RequiredModel']||[]) {
+            reqModels.push(UARequiredModel.fromXML(model));
+        }
+        return new UAModel(xmlObject['@_ModelUri'], xmlObject['@_XmlSchemaUri'],xmlObject['@_Version'], xmlObject['@_PublicationDate'],  xmlObject['@_ModelVersion'], xmlObject['@_AccessRestrictions'], reqModels);
     }
 }

+ 1 - 0
src/ua/UANodeSet.ts

@@ -84,6 +84,7 @@ export class UANodeSet implements IToXML{
                 switch(jpath) {
                     case 'UANodeSet.NamespaceUris.Uri':
                     case 'UANodeSet.Models.Model':
+                    case 'UANodeSet.Models.Model.RequiredModel':
                     case 'UANodeSet.UAObject':
                     case 'UANodeSet.UAObject.References.Reference':
                     case 'UANodeSet.UAObject.DisplayName':