use of org.eclipse.winery.repository.converter.writer.YamlWriter in project winery by eclipse.
the class YamlWriterTests method testPropertyAssignmentSerialization.
@ParameterizedTest
@ArgumentsSource(PropertyAssignmentArgumentsProvider.class)
public void testPropertyAssignmentSerialization(YTPropertyAssignment prop, String expected) {
YamlWriter writer = new YamlWriter();
YamlPrinter p = writer.visit(prop, new YamlWriter.Parameter(0).addContext("root"));
assertEquals(expected, p.toString());
}
use of org.eclipse.winery.repository.converter.writer.YamlWriter in project winery by eclipse.
the class YamlWriterTests method testConstraintClauses.
@ParameterizedTest
@ArgumentsSource(ConstraintClausesArgumentsProvider.class)
public void testConstraintClauses(YTConstraintClause constraint, String expected) {
YamlWriter writer = new YamlWriter();
YamlPrinter p = writer.visit(constraint, new YamlWriter.Parameter(0).addContext("root"));
assertEquals(expected, p.toString());
}
use of org.eclipse.winery.repository.converter.writer.YamlWriter in project winery by eclipse.
the class YamlWriterTests method testTopologyTemplateContent.
@ParameterizedTest
@ArgumentsSource(ServiceTmpltTopologyTmpltProvider.class)
public void testTopologyTemplateContent(YTServiceTemplate serv, String expected) {
YamlWriter writer = new YamlWriter();
YamlPrinter p = writer.visit(serv, new YamlWriter.Parameter(0).addContext("root"));
assertEquals(expected, p.toString());
}
use of org.eclipse.winery.repository.converter.writer.YamlWriter in project winery by eclipse.
the class YamlRepository method deleteArtifact.
/**
* Deletes artifacts from there referenced type
*
* @param id Artifact Template id
*/
private void deleteArtifact(ArtifactTemplateId id) {
if (getNameOfTypeFromArtifactName(id.getQName().getLocalPart()).equalsIgnoreCase("Cache")) {
super.forceDelete(id);
} else {
Path targetPath = id2AbsolutePath(id);
GenericId convertedId = convertGenericId(id);
if (convertedId != null) {
if (convertedId instanceof DefinitionsChildId) {
String convertedFilename = BackendUtils.getFileNameOfDefinitions((DefinitionsChildId) convertedId);
targetPath = targetPath.resolve(convertedFilename);
}
}
if (Files.exists(targetPath)) {
try {
YTServiceTemplate nodeType = readServiceTemplate(targetPath);
String targetArtifactName = getNameOfArtifactFromArtifactName(id.getQName().getLocalPart());
if (getTypeFromArtifactName(id.getQName().getLocalPart()).equalsIgnoreCase("nodetypes")) {
Map<String, YTArtifactDefinition> artifacts = nodeType.getNodeTypes().entrySet().iterator().next().getValue().getArtifacts();
nodeType.getNodeTypes().entrySet().iterator().next().setValue(removeImplementation(nodeType.getNodeTypes().entrySet().iterator().next().getValue(), targetArtifactName));
artifacts.remove(targetArtifactName);
nodeType.getNodeTypes().entrySet().iterator().next().getValue().setArtifacts(artifacts);
} else {
nodeType.getRelationshipTypes().entrySet().iterator().next().setValue(removeRelationshipArtifact(nodeType.getRelationshipTypes().entrySet().iterator().next().getValue(), targetArtifactName));
}
YamlWriter writer = new YamlWriter();
InputStream output = writer.writeToInputStream(nodeType);
writeInputStreamToPath(targetPath, output);
} catch (Exception e) {
LOGGER.error("Error deleting file: {}", e.getMessage(), e);
}
}
}
}
use of org.eclipse.winery.repository.converter.writer.YamlWriter in project winery by eclipse.
the class YAMLDefinitionsBasedCsarEntry method getInputStream.
@Override
public InputStream getInputStream() throws IOException {
YamlWriter writer = new YamlWriter();
InputStream is = writer.writeToInputStream(definitions);
if (Objects.nonNull(is)) {
return is;
}
throw new IOException("Failed to convert XML to YAML");
}
Aggregations