Search in sources :

Example 41 with Project

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

the class YamlSerializer method serializeSources.

private void serializeSources(final Project project) throws WriteException {
    for (SourceFileCollection collection : project.getApplication().getSourceFiles()) {
        for (final SourceFile file : collection) {
            if (!file.isLoaded())
                continue;
            try {
                fileSystem.writeSourceFile(collection.getName(), file.getName(), file.getSource());
                file.setLinkedFile(fileSystem.getNameSpaceFile(collection.getName(), file.getName()));
            } catch (final IOException e) {
                throw new WriteException(file, e);
            }
        }
    }
}
Also used : WriteException(com.developmentontheedge.be5.metadata.exception.WriteException) SourceFile(com.developmentontheedge.be5.metadata.model.SourceFile) IOException(java.io.IOException) SourceFileCollection(com.developmentontheedge.be5.metadata.model.SourceFileCollection)

Example 42 with Project

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

the class YamlSerializer method serializeToObject.

private Object serializeToObject(final Project project, final boolean serializeReferencedFiles) throws WriteException {
    final Map<String, Object> root = map();
    final Map<String, Object> content = map();
    this.fileSystem = new ProjectFileSystem(project);
    if (project.isModuleProject())
        content.put(ATTR_MODULE_PROJECT, Boolean.valueOf(true));
    serializeDocumentation(project, content);
    content.put(ATTR_FEATURES, list(project.getFeatures()));
    content.put(ATTR_LOCALIZATIONS, list(project.getApplication().getLocalizations().getNameList()));
    serializeBugtrackers(project, content);
    content.put(TAG_PROJECT_FILE_STRUCTURE, serialize(project.getProjectFileStructure()));
    content.put(TAG_MODULES, serializeModules(project.getModules(), serializeReferencedFiles));
    content.put(TAG_APPLICATION, serializeApplication(project.getApplication(), serializeReferencedFiles));
    final List<Object> scriptNames = serializeScripts(project.getApplication().getFreemarkerScripts(), serializeReferencedFiles);
    if (!scriptNames.isEmpty())
        content.put(TAG_SCRIPTS, scriptNames);
    final List<Object> macroFilesNames = serializeMacroFiles(project.getApplication().getMacroCollection(), serializeReferencedFiles);
    if (!macroFilesNames.isEmpty())
        content.put(TAG_MACRO_FILES, macroFilesNames);
    serializeProperties(project, content);
    if (serializeReferencedFiles) {
        serializeDaemons(project.getApplication().getDaemonCollection());
        serializeStaticPages(project.getApplication().getStaticPageCollection());
        serializeSources(project);
        serializeForms(project.getApplication());
        serializeLocalizations(project);
        serializeSecurity(project.getSecurityCollection());
        serializeCustomization(project.getApplication());
        serializeMassChanges(project.getApplication().getMassChangeCollection());
        if (!project.isModuleProject()) {
            serializeConnectionProfiles(project.getConnectionProfiles());
            if (project.getConnectionProfileName() != null) {
                try {
                    fileSystem.writeSelectedProfileFile(project.getConnectionProfileName());
                } catch (IOException e) {
                    throw new WriteException(project, e);
                }
            }
        }
    }
    root.put(project.getName(), content);
    return root;
}
Also used : ProjectFileSystem(com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem) WriteException(com.developmentontheedge.be5.metadata.exception.WriteException) IOException(java.io.IOException)

Example 43 with Project

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

the class ModuleUtilsTest method testMergeAllModulesWithLoadRead.

@Test
public void testMergeAllModulesWithLoadRead() throws Exception {
    Path tpmProjectPath = tmp.newFolder().toPath();
    Path tpmModulePath = tmp.newFolder().toPath();
    Project module = getModule();
    Serialization.save(module, tpmModulePath);
    Project app = getProject();
    Serialization.save(app, tpmProjectPath);
    ArrayList<URL> urls = new ArrayList<>();
    urls.add(tpmModulePath.resolve("project.yaml").toUri().toURL());
    urls.add(tpmProjectPath.resolve("project.yaml").toUri().toURL());
    ModuleLoader2.loadAllProjects(urls);
    assertNotNull(ModuleLoader2.getModulePath("app").resolve("project.yaml"));
    app = ModuleLoader2.getModulesMap().get("app");
    ModuleLoader2.mergeModules(app, new NullLogger());
    assertEquals(Collections.singleton("mentity"), app.getEntityNames());
    assertEquals(EntityType.DICTIONARY, app.getEntity("mentity").getType());
    BeModelCollection<Query> queries = app.getEntity("mentity").getQueries();
    assertEquals("QUERY1 customized", queries.get("q1").getQuery());
    assertEquals("Query1 title", queries.get("q1").getTitleName());
    assertEquals("QUERY2", queries.get("q2").getQuery());
    assertEquals("Query2 title", queries.get("q2").getTitleName());
    assertEquals("QUERY3", queries.get("q3").getQuery());
    assertEquals("Query3 title", queries.get("q3").getTitleName());
}
Also used : Path(java.nio.file.Path) Project(com.developmentontheedge.be5.metadata.model.Project) Query(com.developmentontheedge.be5.metadata.model.Query) ArrayList(java.util.ArrayList) URL(java.net.URL) Test(org.junit.Test)

Example 44 with Project

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

the class ModuleUtilsTest method getProject.

private Project getProject() throws ProjectSaveException {
    Project app = new Project("app");
    Module appModule = new Module("module", app.getModules());
    DataElementUtils.save(appModule);
    Entity appEntity = new Entity("mentity", appModule, EntityType.DICTIONARY);
    DataElementUtils.save(appEntity);
    Query appQ1 = new Query("q1", appEntity);
    appQ1.setQuery("QUERY1 customized");
    DataElementUtils.save(appQ1);
    Query appQ3 = new Query("q3", appEntity);
    appQ3.setQuery("QUERY3");
    appQ3.setTitleName("Query3 title");
    DataElementUtils.save(appQ3);
    return app;
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project) Entity(com.developmentontheedge.be5.metadata.model.Entity) Query(com.developmentontheedge.be5.metadata.model.Query) Module(com.developmentontheedge.be5.metadata.model.Module)

Example 45 with Project

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

the class ModuleLoader2MergeModulesTest method setRoleGroups.

private void setRoleGroups(Project project, String name) {
    BeModelCollection<RoleGroup> groups = project.getRoleGroups();
    RoleGroup management = new RoleGroup(name, groups);
    management.getRoleSet().addInclusionAll(Collections.singletonList(name));
    DataElementUtils.save(management);
    project.fireCodeChanged();
}
Also used : RoleGroup(com.developmentontheedge.be5.metadata.model.RoleGroup)

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