Search in sources :

Example 21 with Project

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

the class Be5Mojo method init.

// /////////////////////////////////////////////////////////////////
public void init() throws MojoFailureException {
    long startTime = System.nanoTime();
    initLogging();
    if (be5Project == null) {
        if (projectPath == null)
            throw new MojoFailureException("Please specify projectPath attribute");
        getLog().info("Reading be5 project from '" + projectPath + "'...");
        be5Project = loadProject(projectPath.toPath());
        if (debug) {
            be5Project.setDebugStream(System.err);
        }
        try {
            ModuleLoader2.mergeModules(be5Project, logger);
        } catch (ProjectLoadException e) {
            e.printStackTrace();
            throw new MojoFailureException(e.getMessage());
        }
    }
    if (connectionProfileName != null) {
        be5Project.setConnectionProfileName(connectionProfileName);
    }
    BeConnectionProfile profile = be5Project.getConnectionProfile();
    if (profile != null) {
        this.be5Project.setDatabaseSystem(Rdbms.getRdbms(profile.getConnectionUrl()));
        this.connector = new SimpleConnector(Rdbms.getRdbms(profile.getConnectionUrl()).getType(), profile.getConnectionUrl(), profile.getUsername(), connectionPassword != null ? connectionPassword : profile.getPassword());
        getLog().info("Using connection " + DatabaseUtils.formatUrl(profile.getConnectionUrl(), profile.getUsername(), "xxxxx"));
    } else {
        throw new MojoFailureException("Please specify connection profile: create " + be5Project.getProjectFileStructure().getSelectedProfileFile() + " file with profile name or use -DBE5_PROFILE=...");
    }
    getLog().info(ModuleLoader2.logLoadedProject(be5Project, startTime));
}
Also used : ProjectLoadException(com.developmentontheedge.be5.metadata.exception.ProjectLoadException) BeConnectionProfile(com.developmentontheedge.be5.metadata.model.BeConnectionProfile) SimpleConnector(com.developmentontheedge.dbms.SimpleConnector) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 22 with Project

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

the class Be5Mojo method loadProject.

protected Project loadProject(final Path root) throws MojoFailureException {
    final LoadContext loadContext = new LoadContext();
    Project prj;
    try {
        prj = Serialization.load(root, loadContext);
    } catch (final ProjectLoadException e) {
        throw new MojoFailureException("Can not load project", e);
    }
    checkErrors(loadContext, "Project has %d error(s)");
    return prj;
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project) ProjectLoadException(com.developmentontheedge.be5.metadata.exception.ProjectLoadException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) LoadContext(com.developmentontheedge.be5.metadata.serialization.LoadContext)

Example 23 with Project

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

the class TestUtils method setUp.

@Before
public void setUp() throws Exception {
    tpmProjectPath = tmp.newFolder().toPath();
    project = ProjectTestUtils.getProject("test");
    Entity entity = ProjectTestUtils.createEntity(project, "entity", "ID");
    ProjectTestUtils.createScheme(entity);
    ProjectTestUtils.createScript(project, "delete from entity;\nINSERT INTO entity (name) VALUES ('foo')");
    ProjectTestUtils.createH2Profile(project, "profileTestMavenPlugin");
    Query query = ProjectTestUtils.createQuery(entity, "All records", Arrays.asList('@' + SpecialRoleGroup.ALL_ROLES_EXCEPT_GUEST_GROUP, "-User"));
    query.getOperationNames().setValues(Collections.singleton("op"));
    ProjectTestUtils.createOperation(entity);
    Path modulePath = tmp.newFolder().toPath();
    Project moduleProject = createModule(project, "testModule", modulePath);
    Serialization.save(project, tpmProjectPath);
    ArrayList<URL> urls = new ArrayList<>();
    urls.add(modulePath.resolve("project.yaml").toUri().toURL());
    urls.add(tpmProjectPath.resolve("project.yaml").toUri().toURL());
    ModuleLoader2.loadAllProjects(urls);
    LoadContext ctx = new LoadContext();
    ModuleLoader2.mergeAllModules(project, Collections.singletonList(moduleProject), ctx);
}
Also used : Path(java.nio.file.Path) ArrayList(java.util.ArrayList) LoadContext(com.developmentontheedge.be5.metadata.serialization.LoadContext) URL(java.net.URL) Before(org.junit.Before)

Example 24 with Project

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

the class MetaImpl method getLocalization.

private String getLocalization(Project project, String language, String entity, Predicate<LocalizationElement> accept) {
    for (Module module : project.getModulesAndApplication()) {
        Localizations localizations = module.getLocalizations();
        LanguageLocalizations languageLocalizations = localizations.get(language);
        if (languageLocalizations == null)
            continue;
        EntityLocalizations entityLocalizations = languageLocalizations.get(entity);
        if (entityLocalizations == null)
            continue;
        for (LocalizationElement element : entityLocalizations.elements()) if (accept.test(element))
            return element.getValue();
    }
    return "";
}
Also used : EntityLocalizations(com.developmentontheedge.be5.metadata.model.EntityLocalizations) LanguageLocalizations(com.developmentontheedge.be5.metadata.model.LanguageLocalizations) EntityLocalizations(com.developmentontheedge.be5.metadata.model.EntityLocalizations) LanguageLocalizations(com.developmentontheedge.be5.metadata.model.LanguageLocalizations) Localizations(com.developmentontheedge.be5.metadata.model.Localizations) Module(com.developmentontheedge.be5.metadata.model.Module) LocalizationElement(com.developmentontheedge.be5.metadata.model.LocalizationElement)

Example 25 with Project

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

the class ModuleUtilsTest method getModule.

private Project getModule() throws ProjectSaveException {
    Project module = new Project("module", true);
    Entity entity = new Entity("mentity", module.getApplication(), EntityType.TABLE);
    DataElementUtils.save(entity);
    Query q1 = new Query("q1", entity);
    q1.setQuery("QUERY1");
    q1.setTitleName("Query1 title");
    DataElementUtils.save(q1);
    Query q2 = new Query("q2", entity);
    q2.setQuery("QUERY2");
    q2.setTitleName("Query2 title");
    DataElementUtils.save(q2);
    return module;
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project) Entity(com.developmentontheedge.be5.metadata.model.Entity) Query(com.developmentontheedge.be5.metadata.model.Query)

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