Commit 2285a023 authored by René Schöne's avatar René Schöne
Browse files

Update YAML generation.

parent 9287757d
......@@ -2,63 +2,71 @@ aspect MustacheNodesToYAML {
syn Document MRagConnect.toYAML() {
Document doc = new Document();
MappingElement root = new MappingElement();
root.addKeyValuePair("rootNodeName", StringElement.of(rootNodeName()));
root.addKeyValuePair("closeMethod", StringElement.of(closeMethod()));
root.addKeyValuePair("usesMqtt", ValueElement.of(usesMqtt));
root.addKeyValuePair("usesRest", ValueElement.of(usesRest));
root.put("rootNodeName", rootNodeName());
root.put("closeMethod", closeMethod());
root.put("usesMqtt", usesMqtt);
root.put("usesRest", usesRest);
// mqtt
root.addKeyValuePair("mqttHandlerField", StringElement.of(mqttHandlerField()));
root.addKeyValuePair("mqttHandlerAttribute", StringElement.of(mqttHandlerAttribute()));
root.addKeyValuePair("mqttSetupWaitUntilReadyMethod", StringElement.of(mqttSetupWaitUntilReadyMethod()));
root.put("mqttHandlerField", mqttHandlerField());
root.put("mqttHandlerAttribute", mqttHandlerAttribute());
root.put("mqttSetupWaitUntilReadyMethod", 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()));
inner.put("first", comp.isFirst());
inner.put("name", comp.name());
rootTypeComponents.addElement(inner);
}
root.addKeyValuePair("RootTypeComponents", rootTypeComponents);
root.put("RootTypeComponents", rootTypeComponents);
// rest
root.addKeyValuePair("restHandlerField", StringElement.of(restHandlerField()));
root.addKeyValuePair("restHandlerAttribute", StringElement.of(restHandlerAttribute()));
root.put("restHandlerField", restHandlerField());
root.put("restHandlerAttribute", restHandlerAttribute());
// ReceiveDefinitions
ListElement receiveDefinitions = new ListElement();
for (MReceiveDefinition def : getReceiveDefinitionList()) {
receiveDefinitions.addElement(def.toYAML());
}
root.addKeyValuePair("ReceiveDefinitions", receiveDefinitions);
root.put("ReceiveDefinitions", receiveDefinitions);
// SendDefinitions
ListElement sendDefinitions = new ListElement();
for (MSendDefinition def : getSendDefinitionList()) {
sendDefinitions.addElement(def.toYAML());
}
root.addKeyValuePair("SendDefinitions", sendDefinitions);
root.put("SendDefinitions", sendDefinitions);
// MappingDefinitions
ListElement mappingDefinitions = new ListElement();
for (MMappingDefinition def : getMappingDefinitionList()) {
mappingDefinitions.addElement(def.toYAML());
}
root.addKeyValuePair("MappingDefinitions", mappingDefinitions);
root.put("MappingDefinitions", mappingDefinitions);
// DependencyDefinitions
ListElement dependencyDefinitions = new ListElement();
for (MDependencyDefinition def : getDependencyDefinitionList()) {
dependencyDefinitions.addElement(def.toYAML());
}
root.addKeyValuePair("DependencyDefinitions", dependencyDefinitions);
root.put("DependencyDefinitions", dependencyDefinitions);
// TokenComponents
ListElement tokenComponents = new ListElement();
for (MTokenComponent comp : getTokenComponentList()) {
tokenComponents.addElement(comp.toYAML());
}
root.addKeyValuePair("TokenComponents", tokenComponents);
root.put("TokenComponents", tokenComponents);
// Handlers
ListElement handlers = new ListElement();
for (MHandler handler : getHandlerList()) {
handlers.add(handler.toYAML()
.put("rootTokenComponents", rootTypeComponents.treeCopy()) );
}
root.put("Handlers", handlers);
doc.setRootElement(root);
return doc;
......@@ -66,75 +74,75 @@ aspect MustacheNodesToYAML {
syn MappingElement MEndpointDefinition.toYAML() {
MappingElement result = new MappingElement();
result.addKeyValuePair("parentTypeName", StringElement.of(parentTypeName()));
result.addKeyValuePair("connectMethod", StringElement.of(connectMethod()));
result.addKeyValuePair("connectParameterName", StringElement.of(connectParameterName()));
result.addKeyValuePair("lastDefinitionToType", StringElement.of(lastDefinitionToType()));
result.addKeyValuePair("preemptiveReturn", StringElement.of(preemptiveReturn()));
result.addKeyValuePair("alwaysApply", ValueElement.of(alwaysApply()));
result.addKeyValuePair("condition", StringElement.of(
condition().replace("\"", "\\\"").replace("\n", "\\n")));
result.addKeyValuePair("lastResult", StringElement.of(lastResult()));
result.addKeyValuePair("tokenName", StringElement.of(tokenName()));
result.addKeyValuePair("InnerMappingDefinitions", innerMappingDefinitionsAsListElement());
result.put("parentTypeName", parentTypeName());
result.put("connectMethod", connectMethod());
result.put("connectParameterName", connectParameterName());
result.put("lastDefinitionToType", lastDefinitionToType());
result.put("preemptiveReturn", preemptiveReturn());
result.put("alwaysApply", alwaysApply());
result.put("condition",
condition().replace("\"", "\\\"").replace("\n", "\\n"));
result.put("lastResult", lastResult());
result.put("tokenName", tokenName());
result.put("InnerMappingDefinitions", innerMappingDefinitionsAsListElement());
return result;
}
syn MappingElement MReceiveDefinition.toYAML() {
MappingElement result = super.toYAML();
result.addKeyValuePair("loggingEnabledForReads", ValueElement.of(loggingEnabledForReads));
result.put("loggingEnabledForReads", loggingEnabledForReads);
return result;
}
syn MappingElement MSendDefinition.toYAML() {
MappingElement result = super.toYAML();
result.addKeyValuePair("sender", StringElement.of(sender()));
result.addKeyValuePair("lastValue", StringElement.of(lastValue()));
result.addKeyValuePair("loggingEnabledForWrites", ValueElement.of(loggingEnabledForWrites));
result.addKeyValuePair("updateMethod", StringElement.of(updateMethod()));
result.addKeyValuePair("writeMethod", StringElement.of(writeMethod()));
result.addKeyValuePair("tokenResetMethod", StringElement.of(tokenResetMethod()));
result.put("sender", sender());
result.put("lastValue", lastValue());
result.put("loggingEnabledForWrites", loggingEnabledForWrites);
result.put("updateMethod", updateMethod());
result.put("writeMethod", writeMethod());
result.put("tokenResetMethod", tokenResetMethod());
return result;
}
syn Element MMappingDefinition.toYAML() {
MappingElement result = new MappingElement();
result.addKeyValuePair("toType", StringElement.of(toType()));
result.addKeyValuePair("methodName", StringElement.of(methodName()));
result.addKeyValuePair("fromType", StringElement.of(fromType()));
result.addKeyValuePair("fromVariableName", StringElement.of(fromVariableName()));
result.addKeyValuePair("content", StringElement.of(
content().replace("\"", "\\\"").replace("\n", "\\n")));
result.put("toType", toType());
result.put("methodName", methodName());
result.put("fromType", fromType());
result.put("fromVariableName", fromVariableName());
result.put("content",
content().replace("\"", "\\\"").replace("\n", "\\n"));
return result;
}
syn Element MDependencyDefinition.toYAML() {
MappingElement result = new MappingElement();
result.addKeyValuePair("targetParentTypeName", StringElement.of(targetParentTypeName()));
result.addKeyValuePair("dependencyMethod", StringElement.of(dependencyMethod()));
result.addKeyValuePair("sourceParentTypeName", StringElement.of(sourceParentTypeName()));
result.addKeyValuePair("internalRelationPrefix", StringElement.of(internalRelationPrefix()));
result.put("targetParentTypeName", targetParentTypeName());
result.put("dependencyMethod", dependencyMethod());
result.put("sourceParentTypeName", sourceParentTypeName());
result.put("internalRelationPrefix", internalRelationPrefix());
return result;
}
syn Element MTokenComponent.toYAML() {
MappingElement result = new MappingElement();
result.addKeyValuePair("parentTypeName", StringElement.of(parentTypeName()));
result.addKeyValuePair("name", StringElement.of(name()));
result.addKeyValuePair("javaType", StringElement.of(javaType()));
result.addKeyValuePair("internalName", StringElement.of(internalName()));
result.put("parentTypeName", parentTypeName());
result.put("name", name());
result.put("javaType", javaType());
result.put("internalName", internalName());
ListElement dependencyDefinitions = new ListElement();
for (MDependencyDefinition def : getDependencyDefinitionList()) {
MappingElement inner = new MappingElement();
inner.addKeyValuePair("targetParentTypeName", StringElement.of(def.targetParentTypeName()));
inner.addKeyValuePair("internalRelationPrefix", StringElement.of(def.internalRelationPrefix()));
inner.put("targetParentTypeName", def.targetParentTypeName());
inner.put("internalRelationPrefix", def.internalRelationPrefix());
MappingElement targetEndpointDefinition = new MappingElement();
targetEndpointDefinition.addKeyValuePair("updateMethod", StringElement.of(def.targetEndpointDefinition().updateMethod()));
targetEndpointDefinition.addKeyValuePair("writeMethod", StringElement.of(def.targetEndpointDefinition().writeMethod()));
inner.addKeyValuePair("targetEndpointDefinition", targetEndpointDefinition);
targetEndpointDefinition.put("updateMethod", def.targetEndpointDefinition().updateMethod());
targetEndpointDefinition.put("writeMethod", def.targetEndpointDefinition().writeMethod());
inner.put("targetEndpointDefinition", targetEndpointDefinition);
dependencyDefinitions.addElement(inner);
}
result.addKeyValuePair("DependencyDefinitions", dependencyDefinitions);
result.put("DependencyDefinitions", dependencyDefinitions);
return result;
}
......@@ -142,15 +150,25 @@ aspect MustacheNodesToYAML {
ListElement innerMappingDefinitions = new ListElement();
for (MInnerMappingDefinition def : getInnerMappingDefinitionList()) {
MappingElement inner = new MappingElement();
inner.addKeyValuePair("toType", StringElement.of(def.toType()));
inner.addKeyValuePair("methodName", StringElement.of(def.methodName()));
inner.addKeyValuePair("inputVarName", StringElement.of(def.inputVarName()));
inner.addKeyValuePair("outputVarName", StringElement.of(def.outputVarName()));
inner.addKeyValuePair("last", ValueElement.of(def.isLast()));
inner.put("toType", def.toType());
inner.put("methodName", def.methodName());
inner.put("inputVarName", def.inputVarName());
inner.put("outputVarName", def.outputVarName());
inner.put("last", def.isLast());
innerMappingDefinitions.addElement(inner);
}
return innerMappingDefinitions;
}
syn MappingElement MHandler.toYAML() {
MappingElement result = new MappingElement();
result.put("ClassName", getClassName());
result.put("Construction", getConstruction());
result.put("AttributeName", getAttributeName());
result.put("FieldName", getFieldName());
result.put("InUse", getInUse());
return result;
}
}
aspect Navigation {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment