Search in sources :

Example 6 with LoadContext

use of com.developmentontheedge.be5.metadata.serialization.LoadContext in project be5 by DevelopmentOnTheEdge.

the class Serialization method reloadLocalization.

public static LanguageLocalizations reloadLocalization(final Path file, final Localizations localizations) throws ReadException {
    checkProject(localizations.getProject());
    turnOffAutomaticSerialization();
    try {
        return new YamlDeserializer(new LoadContext()).reloadLocalization(file, localizations);
    } finally {
        turnOnAutomaticSerialization();
    }
}
Also used : YamlDeserializer(com.developmentontheedge.be5.metadata.serialization.yaml.YamlDeserializer)

Example 7 with LoadContext

use of com.developmentontheedge.be5.metadata.serialization.LoadContext in project be5 by DevelopmentOnTheEdge.

the class Serialization method reloadPages.

public static StaticPages reloadPages(final Path file, final Module target) throws ReadException {
    checkProject(target.getProject());
    turnOffAutomaticSerialization();
    try {
        return new YamlDeserializer(new LoadContext()).reloadPages(file, target);
    } finally {
        turnOnAutomaticSerialization();
    }
}
Also used : YamlDeserializer(com.developmentontheedge.be5.metadata.serialization.yaml.YamlDeserializer)

Example 8 with LoadContext

use of com.developmentontheedge.be5.metadata.serialization.LoadContext in project be5 by DevelopmentOnTheEdge.

the class YamlDeserializer method readQuery.

public static Query readQuery(final LoadContext loadContext, final String queryName, final Map<String, Object> content, final Entity entity) {
    YamlDeserializer yamlDeserializer = new YamlDeserializer(loadContext);
    yamlDeserializer.setProject(entity.getProject());
    EntityDeserializer entityDeserializer = yamlDeserializer.new EntityDeserializer();
    try {
        return entityDeserializer.readQuery(queryName, content, entity);
    } catch (ReadException e) {
        Query query = new Query(queryName, entity);
        loadContext.addWarning(e.attachElement(query));
        return query;
    }
}
Also used : ReadException(com.developmentontheedge.be5.metadata.exception.ReadException) Query(com.developmentontheedge.be5.metadata.model.Query)

Example 9 with LoadContext

use of com.developmentontheedge.be5.metadata.serialization.LoadContext in project be5 by DevelopmentOnTheEdge.

the class YamlDeserializer method readConnectionProfile.

/**
 * Parses a connection profile. Doesn't save it to connection profiles collection.
 *
 * @param serializedProfileBody just a map of properties
 * @throws ReadException
 */
private static BeConnectionProfile readConnectionProfile(final LoadContext loadContext, final String profileName, final Map<String, Object> serializedProfileBody, final Project project) throws ReadException {
    final YamlDeserializer yamlDeserializer = new YamlDeserializer(loadContext);
    final ConnectionProfilesDeserializer connectionProfilesDeserializer = yamlDeserializer.new ConnectionProfilesDeserializer(project.getConnectionProfiles().getLocalProfiles());
    final BeConnectionProfile connectionProfile = connectionProfilesDeserializer.deserializeConnectionProfile(profileName, serializedProfileBody);
    return connectionProfile;
}
Also used : BeConnectionProfile(com.developmentontheedge.be5.metadata.model.BeConnectionProfile)

Example 10 with LoadContext

use of com.developmentontheedge.be5.metadata.serialization.LoadContext in project be5 by DevelopmentOnTheEdge.

the class YamlDeserializer method readEntity.

public static Entity readEntity(final LoadContext loadContext, final String entityName, final Map<String, Object> content, final Module module) {
    YamlDeserializer yamlDeserializer = new YamlDeserializer(loadContext);
    yamlDeserializer.setProject(module.getProject());
    EntityDeserializer entityDeserializer = yamlDeserializer.new EntityDeserializer();
    try {
        return entityDeserializer.readEntity(entityName, content, module);
    } catch (ReadException e) {
        Entity entity = new Entity(entityName, module, EntityType.TABLE);
        loadContext.addWarning(e.attachElement(entity));
        return entity;
    }
}
Also used : ReadException(com.developmentontheedge.be5.metadata.exception.ReadException) Entity(com.developmentontheedge.be5.metadata.model.Entity)

Aggregations

YamlDeserializer (com.developmentontheedge.be5.metadata.serialization.yaml.YamlDeserializer)10 Project (com.developmentontheedge.be5.metadata.model.Project)9 LoadContext (com.developmentontheedge.be5.metadata.serialization.LoadContext)7 ProjectLoadException (com.developmentontheedge.be5.metadata.exception.ProjectLoadException)5 ReadException (com.developmentontheedge.be5.metadata.exception.ReadException)5 URL (java.net.URL)4 Path (java.nio.file.Path)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 BeConnectionProfile (com.developmentontheedge.be5.metadata.model.BeConnectionProfile)3 Query (com.developmentontheedge.be5.metadata.model.Query)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 Yaml (org.yaml.snakeyaml.Yaml)3 Entity (com.developmentontheedge.be5.metadata.model.Entity)2 Module (com.developmentontheedge.be5.metadata.model.Module)2 IOException (java.io.IOException)2 URISyntaxException (java.net.URISyntaxException)2 MojoFailureException (org.apache.maven.plugin.MojoFailureException)2 Before (org.junit.Before)2