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));
}
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;
}
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);
}
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 "";
}
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;
}
Aggregations