Explorar el Código

move duplicate getModellingRule() to basenode

Martin Kunz hace 10 meses
padre
commit
f393927cf3
Se han modificado 4 ficheros con 11 adiciones y 22 borrados
  1. 2 2
      src/components/TheDynamics.vue
  2. 9 0
      src/ua/UABaseNode.ts
  3. 0 10
      src/ua/UAObject.ts
  4. 0 10
      src/ua/UAVariable.ts

+ 2 - 2
src/components/TheDynamics.vue

@@ -78,10 +78,10 @@ function getInstanceDecl(nid="ns=0;i=58"){
       let mr = "";
       if(item.toNode.nodeClass == "Object"){
         let i = item.toNode as UAObject;
-        mr = i.getModellingRule();
+        mr = i.getModellingRule()||"";
       }else if(item.toNode.nodeClass == "Variable"){
         let i = item.toNode as UAVariable;
-        mr = i.getModellingRule();
+        mr = i.getModellingRule()||"";
       }
       if(mr == "Mandatory"){
         const newItem = { ref: item, checked: true, modellingRule:mr };

+ 9 - 0
src/ua/UABaseNode.ts

@@ -122,6 +122,15 @@ export class UABaseNode implements IToXML{
         }
     }
 
+    getModellingRule(): string|undefined{
+        this.references.forEach((ref)=>{
+            if(ref.referenceType == "HasModellingRule"){
+                return ref.toNode.displayName;
+            }
+        });
+        return undefined;
+    }
+
     static fromXML(xmlObject: any): UABaseNode{
         const xmlReferences=xmlObject['References']||[];
         const references:UAReference[]=[];

+ 0 - 10
src/ua/UAObject.ts

@@ -29,16 +29,6 @@ export class UAObject extends UABaseNode {
         }
         return elem;
     }
-
-    getModellingRule(){
-        let res:any = "";
-        this.references.forEach((ref)=>{
-            if(ref.referenceType == "HasModellingRule"){
-                res = ref.toNode.displayName;
-            }
-        })
-        return res;
-    }
 }
 
 export interface UAObjectNodeOptions extends UABaseNodeOptions{

+ 0 - 10
src/ua/UAVariable.ts

@@ -29,16 +29,6 @@ export class UAVariable extends UABaseNode {
         }
         return elem;
     }
-
-    getModellingRule(){
-        let res:any = "";
-        this.references.forEach((ref)=>{
-            if(ref.referenceType == "HasModellingRule"){
-                res = ref.toNode.displayName;
-            }
-        })
-        return res;
-    }
 }
 
 export interface UAVariableNodeOptions extends UABaseNodeOptions{