use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.
the class ModuleUtilsTest method testMergeAllModules.
@Test
public void testMergeAllModules() throws Exception {
Project module = getModule();
Project app = getProject();
LoadContext ctx = new LoadContext();
ModuleLoader2.mergeAllModules(app, Collections.singletonList(module), ctx);
ctx.check();
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());
}
use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.
the class ModuleLoader2MergeModulesTest method setUp.
@Before
public void setUp() throws Exception {
Path 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 moduleProject1 = createModuleWithQueryRoles(project, null, "testModule1", "testQuery1", "testRole1", modulePath);
Path modulePath2 = tmp.newFolder().toPath();
Project moduleProject2 = createModuleWithQueryRoles(project, moduleProject1, "testModule2", "testQuery2", "testRole2", modulePath2);
project.setRoles(Arrays.asList("testRole1", "testRole2"));
Serialization.save(project, tpmProjectPath);
ArrayList<URL> urls = new ArrayList<>();
urls.add(modulePath.resolve("project.yaml").toUri().toURL());
urls.add(modulePath2.resolve("project.yaml").toUri().toURL());
urls.add(tpmProjectPath.resolve("project.yaml").toUri().toURL());
ModuleLoader2.loadAllProjects(urls);
LoadContext ctx = new LoadContext();
ModuleLoader2.mergeAllModules(project, Arrays.asList(moduleProject1, moduleProject2), ctx);
}
use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.
the class BaseTypeManagerTest method createTable.
protected TableDef createTable(Rdbms dbms) {
Project proj = new Project("test");
proj.setDatabaseSystem(dbms);
Entity ent = new Entity("table", proj.getApplication(), EntityType.TABLE);
DataElementUtils.save(ent);
TableDef def = new TableDef(ent);
DataElementUtils.save(def);
return def;
}
use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.
the class Templates method getTemplatesProject.
public static Project getTemplatesProject() throws ReadException {
Project prj = new Project(TEMPLATES_PROJECT_NAME, true);
LoadContext lc = new LoadContext();
for (String template : TEMPLATES) {
URL url = Templates.class.getResource("templates/" + template + ".yaml");
Node content;
try (InputStream is = url.openStream()) {
content = new Yaml().compose(new InputStreamReader(is, StandardCharsets.UTF_8));
} catch (MarkedYAMLException e) {
throw new ReadException(new Exception((e.getProblemMark().getLine() + 1) + ":" + (e.getProblemMark().getColumn() + 1) + ": " + e.getMessage()), getPath(url), ReadException.LEE_INVALID_STRUCTURE);
} catch (YAMLException | IOException e) {
throw new ReadException(new Exception(e.getMessage()), getPath(url), ReadException.LEE_INVALID_STRUCTURE);
}
try {
Object obj = Serialization.derepresent(content);
@SuppressWarnings("unchecked") Map<String, Object> root = (Map<String, Object>) obj;
@SuppressWarnings("unchecked") Map<String, Object> entityContent = (Map<String, Object>) root.get(template);
DataElementUtils.saveQuiet(YamlDeserializer.readEntity(lc, template, entityContent, prj.getApplication()));
} catch (RuntimeException e) {
throw new ReadException(e, getPath(url), ReadException.LEE_INTERNAL_ERROR);
}
lc.check();
}
return prj;
}
use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.
the class BeModelElementSupport method isAvailable.
@PropertyName("Available in current project")
@Override
public boolean isAvailable() {
if (usedInExtras == null || usedInExtras.length == 0)
return true;
Module module = getModule();
String[] extras = module == null ? Strings2.EMPTY : module.getExtras();
Project project = getProject();
for (String usedInExtra : usedInExtras) {
if (!hasExtra(extras, project, usedInExtra))
return false;
}
return true;
}
Aggregations