renderYaml function
Implementation
void renderYaml(String yamlString, String outputTemplate) {
if (yamlString.length == 0) {
return;
}
final yaml = loadYaml(yamlString) as Map;
final concepts = yaml['concepts'] as Iterable;
for (final concept in concepts) {
final conceptName = concept['name'] as String;
print(outputTemplate
.replaceAll('{conceptName}', conceptName)
.replaceAll('{attributeName}', '')
.replaceAll('{relationName}', ''));
final attributes = concept['attributes'] as Iterable<Map>;
for (final attribute in attributes) {
final attributeName = attribute['name'] as String;
print(outputTemplate
.replaceAll('{conceptName}', conceptName)
.replaceAll('{attributeName}', attributeName)
.replaceAll('{relationName}', ''));
}
final relations = yaml['relations'] as Iterable;
for (final relation in relations) {
final from = relation['from'] as String;
final to = relation['to'] as String;
final fromToName = relation['fromToName'] as String;
final toFromName = relation['toFromName'] as String;
if (from == conceptName) {
final relationName = '$fromToName $to';
print(outputTemplate
.replaceAll('{conceptName}', conceptName)
.replaceAll('{attributeName}', '')
.replaceAll('{relationName}', relationName));
}
if (to == conceptName) {
final relationName = '$toFromName $from';
print(outputTemplate
.replaceAll('{conceptName}', conceptName)
.replaceAll('{attributeName}', '')
.replaceAll('{relationName}', relationName));
}
}
}
}