Search in sources :

Example 56 with Project

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

the class FreemarkerUtils method getConfiguration.

public static Configuration getConfiguration(Project project) {
    Configuration config = (Configuration) configTemplate.clone();
    config.setCacheStorage(new SoftCacheStorage());
    try {
        config.setSharedVariable("project", project);
    } catch (TemplateModelException e) {
        throw new RuntimeException("Unexpected error: " + e, e);
    }
    FreemarkerScript macroCollection = project.getMacroCollection().optScript(FreemarkerCatalog.MAIN_MACRO_LIBRARY);
    if (macroCollection != null) {
        config.addAutoInclude(macroCollection.getCompletePath().toString());
    }
    for (Module module : project.getModules()) {
        FreemarkerCatalog collection = module.getMacroCollection();
        if (collection != null) {
            FreemarkerScript script = collection.optScript(FreemarkerCatalog.MAIN_MACRO_LIBRARY);
            if (script != null) {
                config.addAutoInclude(script.getCompletePath().toString());
            }
        }
    }
    config.setTemplateLoader(new ProjectTemplateLoader(project));
    return config;
}
Also used : TemplateModelException(freemarker.template.TemplateModelException) Configuration(freemarker.template.Configuration) SoftCacheStorage(freemarker.cache.SoftCacheStorage) FreemarkerCatalog(com.developmentontheedge.be5.metadata.model.FreemarkerCatalog) FreemarkerScript(com.developmentontheedge.be5.metadata.model.FreemarkerScript) Module(com.developmentontheedge.be5.metadata.model.Module)

Example 57 with Project

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

the class ProjectProviderImpl method getProject.

@Override
public synchronized Project getProject() {
    if (dirty || project == null) {
        Project oldProject = project;
        project = loadProject();
        if (oldProject != null) {
            be5Caches.clearAll();
            // todo refactoring and add to be5Caches
            userAwareMetaProvider.get().compileLocalizations();
            // todo refactoring and add to be5Caches
            groovyOperationLoaderProvider.get().initOperationMap();
            groovyRegister.initClassLoader();
            updateDatabaseSystem();
        }
    }
    return project;
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project)

Example 58 with Project

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

the class ModuleLoader2 method getFileSystem.

/**
 * Returns BeanExplorerProjectFileSystem for given module if possible
 */
public static ProjectFileSystem getFileSystem(Project app, String moduleName) {
    if (app.getProjectOrigin().equals(moduleName)) {
        return new ProjectFileSystem(app);
    }
    Path modulePath = ModuleLoader2.getModulePath(moduleName);
    if (modulePath != null) {
        Project project = new Project(moduleName);
        project.setLocation(modulePath);
        project.setProjectFileStructure(new ProjectFileStructure(project));
        return new ProjectFileSystem(project);
    }
    return null;
}
Also used : Path(java.nio.file.Path) Project(com.developmentontheedge.be5.metadata.model.Project) ProjectFileStructure(com.developmentontheedge.be5.metadata.model.ProjectFileStructure)

Example 59 with Project

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

the class ModuleLoader2 method loadAllProjects.

public static void loadAllProjects(List<URL> urls) {
    modulesMap = new HashMap<>();
    try {
        replaceAndAddURLtoSource(urls);
        for (URL url : urls) {
            LoadContext loadContext = new LoadContext();
            Project module;
            String ext = url.toExternalForm();
            if (// usual file in directory
            ext.indexOf('!') < 0) {
                Path path = Paths.get(url.toURI()).getParent();
                module = Serialization.load(path, loadContext);
                log.fine("Load module from dir: " + path);
            } else // war or jar file
            {
                String jar = ext.substring(0, ext.indexOf('!'));
                // = FileSystems.getFileSystem(URI.create(jar));
                FileSystem fs;
                try {
                    fs = FileSystems.newFileSystem(URI.create(jar), Collections.emptyMap());
                } catch (FileSystemAlreadyExistsException e) {
                    fs = FileSystems.getFileSystem(URI.create(jar));
                    log.info("Get exists FileSystem after exception");
                }
                Path path = fs.getPath("./");
                module = Serialization.load(path, loadContext);
                log.fine("Load module from " + url.toExternalForm() + ", path=" + path);
            }
            loadContext.check();
            modulesMap.put(module.getAppName(), module);
        }
    } catch (ProjectLoadException | IOException | URISyntaxException e) {
        e.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) Project(com.developmentontheedge.be5.metadata.model.Project) ProjectLoadException(com.developmentontheedge.be5.metadata.exception.ProjectLoadException) FileSystem(java.nio.file.FileSystem) FileSystemAlreadyExistsException(java.nio.file.FileSystemAlreadyExistsException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) URL(java.net.URL)

Example 60 with Project

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

the class ModuleLoader2 method logLoadedProject.

public static String logLoadedProject(Project project, long startTime) {
    StringBuilder sb = new StringBuilder();
    if (project.isModuleProject()) {
        sb.append(JULLogger.infoBlock("Loaded module:"));
    } else {
        sb.append(JULLogger.infoBlock("Loaded project:"));
    }
    sb.append("\nName: ").append(project.getName());
    if (project.getModules().getSize() > 0) {
        sb.append("\nModules: ");
        for (Module module : project.getModules()) {
            sb.append("\n - ");
            sb.append(module.getName());
        }
    }
    sb.append("\nLoading time: ").append(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime)).append(" ms");
    sb.append("\n");
    return sb.toString();
}
Also used : 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