Search in sources :

Example 6 with Definitions

use of org.eclipse.winery.model.tosca.Definitions in project winery by eclipse.

the class AbstractRepository method getDefinitions.

@Override
public Definitions getDefinitions(DefinitionsChildId id) {
    RepositoryFileReference ref = BackendUtils.getRefOfDefinitions(id);
    if (!exists(ref)) {
        return BackendUtils.createWrapperDefinitionsAndInitialEmptyElement(this, id);
    }
    try {
        InputStream is = RepositoryFactory.getRepository().newInputStream(ref);
        Unmarshaller u = JAXBSupport.createUnmarshaller();
        return (Definitions) u.unmarshal(is);
    } catch (Exception e) {
        LOGGER.error("Could not read content from file " + ref, e);
        throw new IllegalStateException(e);
    }
}
Also used : RepositoryFileReference(org.eclipse.winery.common.RepositoryFileReference) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) Definitions(org.eclipse.winery.model.tosca.Definitions) Unmarshaller(javax.xml.bind.Unmarshaller) IOException(java.io.IOException)

Example 7 with Definitions

use of org.eclipse.winery.model.tosca.Definitions in project winery by eclipse.

the class WriterUtils method loadDefinitions.

public static Definitions loadDefinitions(Path path, String namespace, String name) {
    Path filePath = getDefinitionsPath(path, namespace, name);
    Reader reader = new Reader();
    try {
        return reader.parse(new FileInputStream(filePath.toFile()));
    } catch (JAXBException | FileNotFoundException e) {
        e.printStackTrace();
    }
    return new Definitions();
}
Also used : Path(java.nio.file.Path) JAXBException(javax.xml.bind.JAXBException) Definitions(org.eclipse.winery.model.tosca.Definitions) TDefinitions(org.eclipse.winery.model.tosca.TDefinitions) Reader(org.eclipse.winery.yaml.common.reader.xml.Reader)

Example 8 with Definitions

use of org.eclipse.winery.model.tosca.Definitions in project winery by eclipse.

the class Datatypes method testDataTypes.

@Test
public void testDataTypes() throws Exception {
    String name = "data_types";
    String namespace = "http://www.example.com/DataTypesTest";
    TServiceTemplate serviceTemplate = readServiceTemplate(name, namespace);
    Definitions definitions = convert(serviceTemplate, name, namespace);
    writeXml(definitions, name, namespace);
    Assert.assertNotNull(definitions);
}
Also used : Definitions(org.eclipse.winery.model.tosca.Definitions) TServiceTemplate(org.eclipse.winery.model.tosca.yaml.TServiceTemplate) Test(org.junit.Test)

Example 9 with Definitions

use of org.eclipse.winery.model.tosca.Definitions in project winery by eclipse.

the class Datatypes method testDataTypesRecursive.

@Test
public void testDataTypesRecursive() throws Exception {
    String name = "data_types-recursive";
    String namespace = "http://www.example.com/DataTypesRecursive";
    TServiceTemplate serviceTemplate = readServiceTemplate(name, namespace);
    Definitions definitions = convert(serviceTemplate, name, namespace);
    writeXml(definitions, name, namespace);
    Assert.assertNotNull(definitions);
}
Also used : Definitions(org.eclipse.winery.model.tosca.Definitions) TServiceTemplate(org.eclipse.winery.model.tosca.yaml.TServiceTemplate) Test(org.junit.Test)

Example 10 with Definitions

use of org.eclipse.winery.model.tosca.Definitions in project winery by eclipse.

the class Datatypes method testDataTypesWithImport.

@Test
public void testDataTypesWithImport() throws Exception {
    String name = "data_types-with_import";
    String namespace = "http://www.example.com/DataTypesWithImportTest";
    TServiceTemplate serviceTemplate = readServiceTemplate(name, namespace);
    Definitions definitions = convert(serviceTemplate, name, namespace);
    writeXml(definitions, name, namespace);
    Assert.assertNotNull(definitions);
}
Also used : Definitions(org.eclipse.winery.model.tosca.Definitions) TServiceTemplate(org.eclipse.winery.model.tosca.yaml.TServiceTemplate) Test(org.junit.Test)

Aggregations

Definitions (org.eclipse.winery.model.tosca.Definitions)21 RepositoryFileReference (org.eclipse.winery.common.RepositoryFileReference)7 TDefinitions (org.eclipse.winery.model.tosca.TDefinitions)7 IOException (java.io.IOException)6 JAXBException (javax.xml.bind.JAXBException)5 QName (javax.xml.namespace.QName)5 Test (org.junit.Test)5 Unmarshaller (javax.xml.bind.Unmarshaller)4 TServiceTemplate (org.eclipse.winery.model.tosca.yaml.TServiceTemplate)4 BufferedInputStream (java.io.BufferedInputStream)3 InputStream (java.io.InputStream)3 DefinitionsChildId (org.eclipse.winery.common.ids.definitions.DefinitionsChildId)3 PolicyTemplateId (org.eclipse.winery.common.ids.definitions.PolicyTemplateId)3 TArtifactTemplate (org.eclipse.winery.model.tosca.TArtifactTemplate)3 TEntityType (org.eclipse.winery.model.tosca.TEntityType)3 TExtensibleElements (org.eclipse.winery.model.tosca.TExtensibleElements)3 TImport (org.eclipse.winery.model.tosca.TImport)3 TPolicyTemplate (org.eclipse.winery.model.tosca.TPolicyTemplate)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 URI (java.net.URI)2