use of com.developmentontheedge.be5.metadata.model.Entity in project be5 by DevelopmentOnTheEdge.
the class SelectorTest method testMatch.
@Test
public void testMatch() throws ParseException {
Project project = new Project("test");
Module app = project.getApplication();
Module mod = new Module("mod", project.getModules());
DataElementUtils.save(mod);
Entity appTable = new Entity("appTable", app, EntityType.TABLE);
DataElementUtils.save(appTable);
DataElementUtils.save(new Query("All records", appTable));
Entity appDict = new Entity("appDict", app, EntityType.DICTIONARY);
DataElementUtils.save(appDict);
Query dictRecords = new Query("All records", appDict);
dictRecords.setInvisible(true);
DataElementUtils.save(dictRecords);
Entity modTable = new Entity("modTable", mod, EntityType.DICTIONARY);
DataElementUtils.save(modTable);
DataElementUtils.save(new Query("All records", modTable));
SelectorRule rule1 = UnionSelectorRule.create("Query[invisible=true]");
assertEquals("Query[invisible=true]", rule1.toString());
checkRule(rule1, "test/application/Entities/appDict/Queries/All records", project);
SelectorRule rule2 = UnionSelectorRule.create(".table Query[name=\"All records\"]");
assertEquals(".table Query[name=\"All records\"]", rule2.toString());
checkRule(rule2, "test/application/Entities/appTable/Queries/All records", project);
SelectorRule rule3 = UnionSelectorRule.create("Module#mod Query[name=\"All records\"]");
assertEquals("Module#mod Query[name=\"All records\"]", rule3.toString());
checkRule(rule3, "test/Modules/mod/Entities/modTable/Queries/All records", project);
SelectorRule rule4 = UnionSelectorRule.create("Entity:not(.dictionary)");
assertEquals("Entity:not(.dictionary)", rule4.toString());
checkRule(rule4, "test/application/Entities/appTable", project);
}
use of com.developmentontheedge.be5.metadata.model.Entity in project be5 by DevelopmentOnTheEdge.
the class AppDb method execute.
private void execute(final Module module) throws ProjectElementException {
boolean started = false;
for (Entity entity : module.getOrCreateEntityCollection().getAvailableElements()) {
DdlElement scheme = entity.getScheme();
if (scheme instanceof TableDef) {
if (scheme.withoutDbScheme()) {
if (!started) {
logger.setOperationName("[A] " + module.getCompletePath());
started = true;
}
processDdl(scheme);
createdTables++;
} else {
logger.setOperationName("Skip table with schema: " + scheme.getEntityName());
}
}
}
// Define views after tables as there might be dependencies
for (Entity entity : module.getOrCreateEntityCollection().getAvailableElements()) {
DdlElement scheme = entity.getScheme();
if (scheme instanceof ViewDef) {
if (scheme.withoutDbScheme()) {
if (!started) {
logger.setOperationName("[A] " + module.getCompletePath());
started = true;
}
processDdl(scheme);
createdViews++;
} else {
logger.setOperationName("Skip table with schema: " + scheme.getEntityName());
}
}
}
}
use of com.developmentontheedge.be5.metadata.model.Entity in project be5 by DevelopmentOnTheEdge.
the class AppValidate method checkDdl.
private void checkDdl() throws MojoFailureException {
if (ddlPath != null) {
Entity entity = be5Project.getEntity(ddlPath);
if (entity == null) {
throw new MojoFailureException("Invalid entity: " + ddlPath);
}
DdlElement scheme = entity.getScheme();
if (scheme == null) {
throw new MojoFailureException("Entity has no scheme: " + ddlPath);
}
getLog().info("DDL: " + scheme.getDdl().replaceAll("\n", System.lineSeparator()));
}
}
use of com.developmentontheedge.be5.metadata.model.Entity in project be5 by DevelopmentOnTheEdge.
the class AppValidate method saveProject.
// private List<ProjectElementException> validateDeps( List<Project> moduleProjects )
// {
// List<ProjectElementException> moduleErrors = new ArrayList<>();
// Map<String, String> entityToModule = new HashMap<>();
// for(Project prj : moduleProjects)
// {
// for(Entity entity : prj.getApplication().getEntities())
// entityToModule.put( entity.getName(), prj.getName() );
// }
// for(Project prj : moduleProjects)
// {
// for(Entity entity : prj.getApplication().getEntities())
// {
// for(TableReference ref : entity.getAllReferences())
// {
// String moduleTo = entityToModule.get( ref.getTableTo() );
// if(moduleTo != null && prj.getModule( moduleTo ) == null)
// {
// moduleErrors.add( new ProjectElementException( ref, "Reference to entity '" + ref.getTableTo()
// + "' which is defined in module '" + moduleTo + "' which is not specified in dependencies of module '"
// + prj.getName() + "'" ) );
// }
// }
// }
// }
// return moduleErrors;
// }
private void saveProject() throws MojoFailureException {
if (saveProject) {
try {
getLog().info("Saving...");
Serialization.save(be5Project, be5Project.getLocation());
} catch (ProjectSaveException e) {
throw new MojoFailureException("Can not save project.", e);
}
}
}
use of com.developmentontheedge.be5.metadata.model.Entity 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);
}
Aggregations