MustacheNodesToYAML.jrag 5.56 KB
Newer Older
René Schöne's avatar
René Schöne committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
aspect MustacheNodesToYAML {
  syn Document MRagConnect.toYAML() {
    Document doc = new Document();
    MappingElement root = new MappingElement();
    root.addKeyValuePair("rootNodeName", StringElement.of(rootNodeName()));
    root.addKeyValuePair("usesMqtt", ValueElement.of(usesMqtt));
    root.addKeyValuePair("usesRest", ValueElement.of(usesRest));
    // mqtt
    root.addKeyValuePair("mqttHandlerField", StringElement.of(mqttHandlerField()));
    root.addKeyValuePair("mqttHandlerAttribute", StringElement.of(mqttHandlerAttribute()));
    root.addKeyValuePair("mqttSetupWaitUntilReadyMethod", StringElement.of(mqttSetupWaitUntilReadyMethod()));

    // rootTypeComponents
    ListElement rootTypeComponents = new ListElement();
    for (MTypeComponent comp : getRootTypeComponentList()) {
      MappingElement inner = new MappingElement();
      inner.addKeyValuePair("first", ValueElement.of(comp.isFirst()));
      inner.addKeyValuePair("name", StringElement.of(comp.name()));
      rootTypeComponents.addElement(inner);
    }
    root.addKeyValuePair("rootTypeComponents", rootTypeComponents);

    // rest
    root.addKeyValuePair("restHandlerField", StringElement.of(restHandlerField()));
    root.addKeyValuePair("restHandlerAttribute", StringElement.of(restHandlerAttribute()));

    // ReceiveDefinitions
    ListElement receiveDefinitions = new ListElement();
    for (MReceiveDefinition def : getReceiveDefinitionList()) {
      receiveDefinitions.addElement(def.toYAML());
    }
    root.addKeyValuePair("ReceiveDefinitions", receiveDefinitions);

    // SendDefinitions
    ListElement sendDefinitions = new ListElement();
    for (MSendDefinition def : getSendDefinitionList()) {
      sendDefinitions.addElement(def.toYAML());
    }
    root.addKeyValuePair("SendDefinitions", sendDefinitions);

    // MappingDefinitions
    ListElement mappingDefinitions = new ListElement();
    for (MMappingDefinition def : getMappingDefinitionList()) {
      mappingDefinitions.addElement(def.toYAML());
    }
    root.addKeyValuePair("MappingDefinitions", mappingDefinitions);

    // DependencyDefinitions
    ListElement dependencyDefinitions = new ListElement();
    for (MDependencyDefinition def : getDependencyDefinitionList()) {
      dependencyDefinitions.addElement(def.toYAML());
    }
    root.addKeyValuePair("DependencyDefinitions", dependencyDefinitions);

    // TokenComponents
    ListElement tokenComponents = new ListElement();
    for (MTokenComponent comp : getTokenComponentList()) {
      tokenComponents.addElement(comp.toYAML());
    }
    root.addKeyValuePair("TokenComponents", tokenComponents);

    doc.addComplexElement(root);
    return doc;
  }

  syn Element MReceiveDefinition.toYAML() {
    MappingElement inner = new MappingElement();
    inner.addKeyValuePair("parentTypeName", StringElement.of(parentTypeName()));
    inner.addKeyValuePair("connectMethod", StringElement.of(connectMethod()));
    inner.addKeyValuePair("connectParameterName", StringElement.of(connectParameterName()));
    inner.addKeyValuePair("lastDefinitionToType", StringElement.of(lastDefinitionToType()));
    inner.addKeyValuePair("resultVarPrefix", StringElement.of(resultVarPrefix()));
    inner.addKeyValuePair("lastDefinitionName", StringElement.of(lastDefinitionName()));
    inner.addKeyValuePair("preemptiveReturn", StringElement.of(preemptiveReturn()));
    inner.addKeyValuePair("alwaysApply", ValueElement.of(alwaysApply()));
    inner.addKeyValuePair("condition", StringElement.of(condition()));
    inner.addKeyValuePair("loggingEnabledForReads", ValueElement.of(loggingEnabledForReads));
    inner.addKeyValuePair("tokenName", StringElement.of(tokenName()));
    inner.addKeyValuePair("lastResult", StringElement.of(lastResult()));
//    inner.addKeyValuePair("first", ValueElement.of(isFirst()));
//      parentTypeName
//      connectMethod
//      connectParameterName
//      lastDefinitionToType
//      resultVarPrefix
//      lastDefinitionName
//      #InnerMappingDefinitions -> MInnerMappingDefinition
//        last
//        toType
//        methodName
//        inputVarName
//      preemptiveReturn
//      alwaysApply
//      condition - special chars
//      loggingEnabledForReads
//      tokenName
//      lastResult
    return inner;
  }

  syn Element MSendDefinition.toYAML() {
    MappingElement inner = new MappingElement();
//    #SendDefinitions  -> MSendDefinition
//      parentTypeName
//      sender
//      lastValue
//      connectMethod
//      connectParameterName
//      loggingEnabledForWrites
//      updateMethod
//      writeMethod
//      tokenResetMethod
//      lastResult
    return inner;
  }

  syn Element MMappingDefinition.toYAML() {
    MappingElement inner = new MappingElement();
//    #MappingDefinitions -> MMappingDefinition
//      toType
//      methodName
//      fromType
//      fromVariableName
//      content - special chars
    return inner;
  }

  syn Element MDependencyDefinition.toYAML() {
    MappingElement inner = new MappingElement();
//    #DependencyDefinitions -> MDependencyDefinition
//      targetParentTypeName
//      dependencyMethod
//      sourceParentTypeName
//      internalRelationPrefix
    return inner;
  }

  syn Element MTokenComponent.toYAML() {
    MappingElement inner = new MappingElement();
//    #TokenComponents -> MTokenComponent
//      parentTypeName
//      name
//      javaType
//      internalName
//      #DependencyDefinitions -> MDependencyDefinition
//        targetParentTypeName
//        internalRelationPrefix
//        #targetEndpointDefinition -> MSendDefinition
//          updateMethod
//          writeMethod
    return inner;
  }

}