Search in sources :

Example 6 with Module

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

use of com.developmentontheedge.be5.metadata.model.Module 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)

Example 8 with Module

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

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

the class YamlDeserializer method reloadForms.

public JavaScriptForms reloadForms(final Path path, final Module target) throws ReadException {
    final JavaScriptForms forms = new JavaScriptForms(target);
    final FormsDeserializer deserializer = new FormsDeserializer(path, forms);
    deserializer.deserialize();
    DataElementUtils.saveQuiet(forms);
    return forms;
}
Also used : JavaScriptForms(com.developmentontheedge.be5.metadata.model.JavaScriptForms)

Example 10 with Module

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

Module (com.developmentontheedge.be5.metadata.model.Module)26 Project (com.developmentontheedge.be5.metadata.model.Project)21 Entity (com.developmentontheedge.be5.metadata.model.Entity)19 Query (com.developmentontheedge.be5.metadata.model.Query)12 Test (org.junit.Test)9 Path (java.nio.file.Path)8 ArrayList (java.util.ArrayList)6 Operation (com.developmentontheedge.be5.metadata.model.Operation)5 YamlDeserializer (com.developmentontheedge.be5.metadata.serialization.yaml.YamlDeserializer)5 HashMap (java.util.HashMap)5 ProjectElementException (com.developmentontheedge.be5.metadata.exception.ProjectElementException)4 TableDef (com.developmentontheedge.be5.metadata.model.TableDef)4 Map (java.util.Map)4 FreemarkerCatalog (com.developmentontheedge.be5.metadata.model.FreemarkerCatalog)3 FreemarkerScript (com.developmentontheedge.be5.metadata.model.FreemarkerScript)3 BeModelElement (com.developmentontheedge.be5.metadata.model.base.BeModelElement)3 List (java.util.List)3 FreemarkerSqlException (com.developmentontheedge.be5.metadata.exception.FreemarkerSqlException)2 ReadException (com.developmentontheedge.be5.metadata.exception.ReadException)2 ColumnDef (com.developmentontheedge.be5.metadata.model.ColumnDef)2