use of com.developmentontheedge.be5.metadata.model.Entity in project be5 by DevelopmentOnTheEdge.
the class YamlSerializer method serializeApplication.
private Object serializeApplication(final Module application, boolean serializeReferencedFiles) throws WriteException {
final List<Object> serializedEntities = list();
final Iterable<Entity> entities = application.getEntities();
for (final Entity entity : entities) {
if (serializeReferencedFiles)
new EntitySerializer().serialize(entity);
serializedEntities.add(entity.getName());
}
return serializedEntities;
}
use of com.developmentontheedge.be5.metadata.model.Entity in project be5 by DevelopmentOnTheEdge.
the class YamlSerializer method serializeModules.
private Object serializeModules(final BeModelCollection<Module> modules, boolean serializeReferencedFiles) throws WriteException {
final List<Object> serializedModules = list();
for (final Module module : modules) {
final Map<String, Object> serializedModule = map();
final Map<String, Object> serializedModuleContent = map();
final List<Object> serializedEntities = list();
final Iterable<Entity> entities = module.getEntities();
for (final Entity entity : entities) if (entity.isCustomized()) {
if (serializeReferencedFiles)
new EntitySerializer().serialize(entity);
serializedEntities.add(entity.getName());
}
serializedModuleContent.put(TAG_ENTITIES, serializedEntities);
final List<Object> serializedExtras = list();
for (String extra : module.getExtras()) {
serializedExtras.add(extra);
}
if (!serializedExtras.isEmpty()) {
serializedModuleContent.put(TAG_EXTRAS, serializedExtras);
}
serializedModule.put(module.getName(), serializedModuleContent);
serializedModules.add(serializedModule);
}
return serializedModules;
}
use of com.developmentontheedge.be5.metadata.model.Entity 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;
}
use of com.developmentontheedge.be5.metadata.model.Entity in project be5 by DevelopmentOnTheEdge.
the class ModuleLoader2MergeModulesTest method createModuleWithQueryRoles.
private Project createModuleWithQueryRoles(Project project, Project entityOwner, String moduleName, String queryName, String roleName, Path path) throws Exception {
Project moduleProject = new Project(moduleName, true);
Entity entity;
if (entityOwner == null) {
entity = ProjectTestUtils.createEntity(moduleProject, "moduleEntity", "ID");
} else {
Module appModule = new Module(entityOwner.getName(), moduleProject.getModules());
DataElementUtils.save(appModule);
entity = new Entity("moduleEntity", appModule, EntityType.TABLE);
DataElementUtils.save(entity);
}
ProjectTestUtils.createScheme(entity);
ProjectTestUtils.createQuery(entity, queryName, Collections.singletonList('@' + roleName));
moduleProject.setRoles(Collections.singletonList(roleName));
setRoleGroups(moduleProject, roleName);
Module appModule = new Module(moduleName, project.getModules());
DataElementUtils.save(appModule);
Serialization.save(moduleProject, path);
return moduleProject;
}
use of com.developmentontheedge.be5.metadata.model.Entity in project be5 by DevelopmentOnTheEdge.
the class SerializationTest method testSerializationBasics.
@Test
public void testSerializationBasics() throws IOException, ProjectSaveException, ProjectLoadException {
Path path = tmp.newFolder().toPath();
Project project = ProjectTestUtils.getProject("test");
Entity entity = ProjectTestUtils.createEntity(project, "entity", "ID");
TableDef scheme = ProjectTestUtils.createScheme(entity);
// only for test SqlColumnType getType( Collection<ColumnDef> stack )
ColumnDef column3 = new ColumnDef("column3", scheme.getColumns());
column3.setTableTo(entity.getName());
column3.setColumnsTo("ID");
DataElementUtils.save(column3);
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);
Serialization.save(project, path);
assertEquals(path, project.getLocation());
LoadContext lc = new LoadContext();
Project project2 = Serialization.load(path, lc);
project2.setDatabaseSystem(Rdbms.POSTGRESQL);
lc.check();
Entity entity2 = project2.getEntity("entity");
assertEquals(entity, entity2);
assertTrue(entity2.isBesql());
assertEquals("VARCHAR(20)", entity2.findTableDefinition().getColumns().get("name").getTypeString());
assertEquals(StreamEx.of("Administrator", "Operator").toSet(), entity2.getQueries().get("All records").getRoles().getFinalValues());
assertEquals("op", entity2.getQueries().get("All records").getOperationNames().getFinalValuesString());
}
Aggregations