use of org.eclipse.winery.model.ids.definitions.RelationshipTypeImplementationId in project winery by eclipse.
the class YamlRepository method putContentToFile.
/**
* Converts incoming xml input stream to yaml service template and writes it to file
*
* @param ref repository file reference
* @param inputStream input stream to write to file
* @param mediaType Media Type
*/
@Override
public void putContentToFile(RepositoryFileReference ref, InputStream inputStream, MediaType mediaType) throws IOException {
if (mediaType.equals(MediaTypes.MEDIATYPE_TOSCA_DEFINITIONS)) {
// use throwable as way to track the callgraph
LOGGER.error("Use of InputStream overload to write definitions with callpath", new Throwable());
}
Path targetPath = this.ref2AbsolutePath(ref);
inputStream = convertToServiceTemplate(ref, inputStream, mediaType);
writeInputStreamToPath(targetPath, inputStream);
if (ref.getParent() instanceof NodeTypeImplementationId || ref.getParent() instanceof RelationshipTypeImplementationId) {
clearCache();
}
}
use of org.eclipse.winery.model.ids.definitions.RelationshipTypeImplementationId in project winery by eclipse.
the class YamlRepository method convertGenericId.
/**
* Converts Generic id of non existing XML Definitions in compatible YAML Definition
*
* @param id GenericId
* @return converted Generic Id
*/
private GenericId convertGenericId(GenericId id) {
if (id instanceof NodeTypeImplementationId) {
return new NodeTypeId(((NodeTypeImplementationId) id).getQName());
} else if (id instanceof RelationshipTypeImplementationId) {
return new RelationshipTypeId(((RelationshipTypeImplementationId) id).getQName());
} else if (id instanceof ArtifactTemplateId) {
QName qName = ((ArtifactTemplateId) id).getQName();
Matcher nameMatcher = namePattern.matcher(qName.getLocalPart());
if (nameMatcher.matches()) {
String typeName = nameMatcher.group(2);
if (nameMatcher.group(3).equalsIgnoreCase("nodetypes")) {
return new NodeTypeId(new QName(qName.getNamespaceURI(), typeName));
} else {
return new RelationshipTypeId(new QName(qName.getNamespaceURI(), typeName));
}
} else {
return new NodeTypeId(new QName(qName.getNamespaceURI(), "Cache"));
}
}
return null;
}
Aggregations