Search in sources :

Example 6 with Project

use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.

the class Serialization method reloadSecurity.

public static SecurityCollection reloadSecurity(final Path file, final Project project) throws ReadException {
    checkProject(project);
    turnOffAutomaticSerialization();
    try {
        return new YamlDeserializer(new LoadContext()).reloadSecurityCollection(file, project);
    } finally {
        turnOnAutomaticSerialization();
    }
}
Also used : YamlDeserializer(com.developmentontheedge.be5.metadata.serialization.yaml.YamlDeserializer)

Example 7 with Project

use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.

the class Serialization method save.

/**
 * @param project
 * @param root
 * @param format
 * @throws ProjectSaveException
 */
public static void save(final Project project, final Path root) throws ProjectSaveException {
    Objects.requireNonNull(project);
    Objects.requireNonNull(root);
    try {
        new YamlSerializer().serializeProjectTo(project, root);
    } catch (final WriteException e) {
        throw new ProjectSaveException(root, e);
    }
}
Also used : WriteException(com.developmentontheedge.be5.metadata.exception.WriteException) YamlSerializer(com.developmentontheedge.be5.metadata.serialization.yaml.YamlSerializer) ProjectSaveException(com.developmentontheedge.be5.metadata.exception.ProjectSaveException)

Example 8 with Project

use of com.developmentontheedge.be5.metadata.model.Project 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 9 with Project

use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.

the class YamlDeserializer method readCustomizations.

/**
 * Used with customizations (module), entity, query, operation and static page.
 */
@SuppressWarnings("unchecked")
private void readCustomizations(final Map<String, Object> serialized, final BeVectorCollection<?> target, boolean replace) {
    if (project == null)
        throw new IllegalStateException();
    final Map<String, Object> serializedCustomizations = (Map<String, Object>) serialized.get("customizations");
    if (serializedCustomizations == null || serializedCustomizations.isEmpty())
        return;
    final BeVectorCollection<PageCustomization> customizations = replace ? new PageCustomizations(target) : target.getOrCreateCollection(PageCustomization.CUSTOMIZATIONS_COLLECTION, PageCustomization.class);
    try {
        for (final String name : serializedCustomizations.keySet()) {
            final Map<String, Object> content = (Map<String, Object>) serializedCustomizations.get(name);
            final List<String> splitted = StreamEx.split(name, "\\.").toList();
            final String type;
            final String domain;
            if (splitted.size() == 1) {
                type = "";
                domain = splitted.get(0);
            } else {
                type = splitted.get(splitted.size() - 1);
                splitted.remove(splitted.size() - 1);
                domain = String.join(".", splitted);
            }
            final PageCustomization customization = new PageCustomization(type, domain, customizations);
            customization.setCode((String) content.get(TAG_CODE));
            customization.setOriginModuleName(project.getProjectOrigin());
            DataElementUtils.saveQuiet(customization);
        }
    } catch (Exception e) {
        loadContext.addWarning(new ReadException(e, target, project.getLocation()));
    }
    if (replace)
        DataElementUtils.save(customizations);
}
Also used : ReadException(com.developmentontheedge.be5.metadata.exception.ReadException) PageCustomizations(com.developmentontheedge.be5.metadata.model.PageCustomizations) PageCustomization(com.developmentontheedge.be5.metadata.model.PageCustomization) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) ReadException(com.developmentontheedge.be5.metadata.exception.ReadException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MarkedYAMLException(org.yaml.snakeyaml.error.MarkedYAMLException) YAMLException(org.yaml.snakeyaml.error.YAMLException)

Example 10 with Project

use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.

the class ModuleLoader2 method loadModules.

public static List<Project> loadModules(Project application, ProcessController logger, LoadContext loadContext) throws ProjectLoadException {
    List<Project> result = new ArrayList<>();
    for (Module module : application.getModules()) {
        if (containsModule(module.getName())) {
            Project moduleProject = modulesMap.get(module.getName());
            result.add(moduleProject);
        } else {
            throw new RuntimeException("Module project not found " + module.getName());
        }
    }
    // todo ????? topological sort?
    result.sort((o1, o2) -> {
        if (o1.getModules().contains(o2.getName()))
            return 1;
        if (o2.getModules().contains(o1.getName()))
            return -1;
        return 0;
    });
    return result;
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project) ArrayList(java.util.ArrayList) Module(com.developmentontheedge.be5.metadata.model.Module)

Aggregations

Project (com.developmentontheedge.be5.metadata.model.Project)40 Module (com.developmentontheedge.be5.metadata.model.Module)19 Test (org.junit.Test)19 Entity (com.developmentontheedge.be5.metadata.model.Entity)14 Path (java.nio.file.Path)13 Query (com.developmentontheedge.be5.metadata.model.Query)12 LoadContext (com.developmentontheedge.be5.metadata.serialization.LoadContext)7 ArrayList (java.util.ArrayList)7 ProjectLoadException (com.developmentontheedge.be5.metadata.exception.ProjectLoadException)6 FreemarkerScript (com.developmentontheedge.be5.metadata.model.FreemarkerScript)5 URL (java.net.URL)5 Map (java.util.Map)5 ReadException (com.developmentontheedge.be5.metadata.exception.ReadException)4 BeConnectionProfile (com.developmentontheedge.be5.metadata.model.BeConnectionProfile)4 Operation (com.developmentontheedge.be5.metadata.model.Operation)4 IOException (java.io.IOException)4 MojoFailureException (org.apache.maven.plugin.MojoFailureException)4 WriteException (com.developmentontheedge.be5.metadata.exception.WriteException)3 FreemarkerCatalog (com.developmentontheedge.be5.metadata.model.FreemarkerCatalog)3 Localizations (com.developmentontheedge.be5.metadata.model.Localizations)3