Search in sources :

Example 11 with MultiException

use of org.eclipse.winery.yaml.common.exception.MultiException in project winery by eclipse.

the class SchemaVisitor method visit.

public Map<QName, Map<String, QName>> visit(TServiceTemplate node, Path path, Path outpath, String namespace) {
    for (TMapImportDefinition map : node.getImports()) {
        for (Map.Entry<String, TImportDefinition> entry : map.entrySet()) {
            Reader reader = Reader.getReader();
            try {
                TServiceTemplate serviceTemplate = reader.parse(entry.getValue(), path, entry.getValue().getNamespaceUri());
                visit(serviceTemplate, new Parameter(outpath, entry.getValue().getNamespaceUri()).setBuildSchema(false));
            } catch (MultiException e) {
                setException(e);
            }
        }
    }
    this.visit(node, new Parameter(outpath, namespace));
    return propertyDefinition;
}
Also used : TMapImportDefinition(org.eclipse.winery.model.tosca.yaml.support.TMapImportDefinition) Reader(org.eclipse.winery.yaml.common.reader.yaml.Reader) Parameter(org.eclipse.winery.yaml.converter.yaml.visitors.support.Parameter) MultiException(org.eclipse.winery.yaml.common.exception.MultiException)

Example 12 with MultiException

use of org.eclipse.winery.yaml.common.exception.MultiException in project winery by eclipse.

the class Showcases method convert.

public MultiException convert(String path, String namespace, Stream<String> files) throws Exception {
    MultiException exception = new MultiException();
    files.map(name -> {
        try {
            return new LinkedHashMap.SimpleEntry<>(name, readServiceTemplate(path + File.separator + name));
        } catch (Exception e) {
            exception.add(e);
        }
        return null;
    }).filter(Objects::nonNull).map(entry -> new LinkedHashMap.SimpleEntry<>(entry.getKey(), convert(entry.getValue(), entry.getKey(), namespace))).forEach(entry -> WriterUtils.saveDefinitions(entry.getValue(), outPath, namespace, entry.getKey()));
    if (exception.hasException()) {
        throw exception.getException();
    }
    return exception;
}
Also used : ServiceTemplateId(org.eclipse.winery.common.ids.definitions.ServiceTemplateId) Test(org.junit.Test) FileInputStream(java.io.FileInputStream) XmlId(org.eclipse.winery.common.ids.XmlId) RepositoryFactory(org.eclipse.winery.repository.backend.RepositoryFactory) File(java.io.File) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) LinkedHashMap(java.util.LinkedHashMap) Objects(java.util.Objects) Stream(java.util.stream.Stream) Ignore(org.junit.Ignore) Paths(java.nio.file.Paths) MultiException(org.eclipse.winery.yaml.common.exception.MultiException) Namespaces(org.eclipse.winery.yaml.common.Namespaces) AbstractTestY2X(org.eclipse.winery.yaml.converter.yaml.support.AbstractTestY2X) Namespace(org.eclipse.winery.common.ids.Namespace) WriterUtils(org.eclipse.winery.yaml.common.writer.WriterUtils) Assert(org.junit.Assert) Converter(org.eclipse.winery.yaml.converter.Converter) InputStream(java.io.InputStream) Objects(java.util.Objects) MultiException(org.eclipse.winery.yaml.common.exception.MultiException) MultiException(org.eclipse.winery.yaml.common.exception.MultiException) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

MultiException (org.eclipse.winery.yaml.common.exception.MultiException)12 Reader (org.eclipse.winery.yaml.common.reader.yaml.Reader)8 TServiceTemplate (org.eclipse.winery.model.tosca.yaml.TServiceTemplate)6 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4 File (java.io.File)3 Path (java.nio.file.Path)3 Objects (java.util.Objects)3 TOSCAMetaFile (org.eclipse.winery.model.csar.toscametafile.TOSCAMetaFile)3 TOSCAMetaFileParser (org.eclipse.winery.model.csar.toscametafile.TOSCAMetaFileParser)3 Definitions (org.eclipse.winery.model.tosca.Definitions)3 RepositoryFactory (org.eclipse.winery.repository.backend.RepositoryFactory)3 WineryRepositoryException (org.eclipse.winery.repository.exceptions.WineryRepositoryException)3 StandardCharsets (java.nio.charset.StandardCharsets)2 java.nio.file (java.nio.file)2 Arrays (java.util.Arrays)2 Map (java.util.Map)2 Optional (java.util.Optional)2 QName (javax.xml.namespace.QName)2 DefinitionsChildId (org.eclipse.winery.common.ids.definitions.DefinitionsChildId)2