use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.
the class ModuleLoader2 method foldModules.
private static Project foldModules(final Project model, final List<Project> modules, LoadContext context) {
if (modules.isEmpty()) {
return null;
}
Project compositeModule = null;
for (Project module : modules) {
if (compositeModule != null) {
module.getModules().merge(compositeModule.getModules(), true, true);
module.getApplication().merge(compositeModule.getModule(module.getProjectOrigin()), true, true);
}
module.applyMassChanges(context);
compositeModule = module;
if (compositeModule.isModuleProject()) {
DataElementUtils.addQuiet(module.getModules(), module.getApplication());
module.setApplication(new Module(model.getProjectOrigin(), model));
}
}
return compositeModule;
}
use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.
the class SqlMacroTest method testMacro.
@Test
public void testMacro() throws ProjectElementException {
Project project = new Project("test");
project.setDatabaseSystem(Rdbms.POSTGRESQL);
FreemarkerScript script = new FreemarkerScript("script", project.getApplication().getFreemarkerScripts());
DataElementUtils.save(script);
script.setSource("SELECT ${concat('a'?asDate, 'b', 'c'?str)} FROM test");
assertEquals("SELECT ( TO_DATE(a,'YYYY-MM-DD') || b || 'c' ) FROM test", project.mergeTemplate(script).validate());
script.setSource("<#macro _sql>${project.enterSQL()}<#assign nested><#nested></#assign>${project.translateSQL(nested)}</#macro>" + "<@_sql>SELECT TO_DATE(a) || b || 'c' FROM test</@>");
assertEquals("SELECT TO_DATE(a, 'YYYY-MM-DD') || b || 'c' FROM test", project.mergeTemplate(script).validate());
script.setSource("<#macro _sql>${project.enterSQL()}<#assign nested><#nested></#assign>${project.translateSQL(nested)}</#macro>" + "<@_sql>SELECT ${'a'?asDate} || b || 'c' FROM test</@>");
assertEquals("SELECT TO_DATE(a, 'YYYY-MM-DD') || b || 'c' FROM test", project.mergeTemplate(script).validate());
}
use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.
the class MassChangeTest method testMassChange.
@Test
public void testMassChange() {
Project project = new Project("test");
Entity entity = new Entity("entity", project.getApplication(), EntityType.TABLE);
DataElementUtils.save(entity);
Query queryToChange = new Query("queryToChange", entity);
DataElementUtils.save(queryToChange);
Query query = new Query("query", entity);
DataElementUtils.save(query);
MassChange mc = new MassChange("Query[name*=\"Change\"]", project.getApplication().getMassChangeCollection(), Collections.singletonMap("type", QueryType.D2));
assertEquals("type", mc.getPropertiesString());
assertEquals("Query[name*=Change]", mc.getSelectorString());
DataElementUtils.save(mc);
assertEquals(QueryType.D1, queryToChange.getType());
assertEquals(QueryType.D1, query.getType());
LoadContext context = new LoadContext();
project.applyMassChanges(context);
context.check();
assertEquals(QueryType.D2, entity.getQueries().get("queryToChange").getType());
assertEquals(QueryType.D1, entity.getQueries().get("query").getType());
}
use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.
the class ReadModelFromXmlTest method testWriteReadConnectionProfile.
/**
* Unexpected error when serializing 'connectionUrl' of TestProject/Connection profiles/Local/test
* on windows
* @throws Exception
*/
@Test
public void testWriteReadConnectionProfile() throws Exception {
Assume.assumeFalse(System.getProperty("os.name").toLowerCase().startsWith("win"));
final Project project = new Project("TestProject");
BeConnectionProfile profile = new BeConnectionProfile("test", project.getConnectionProfiles().getLocalProfiles());
profile.setConnectionUrl("jdbc:db2://localhost:50000/housing:retrieveMessagesFromServerOnGetMessage=true;");
profile.setUsername("test");
profile.setPassword("password");
LinkedHashMap<String, Object> serializedProfiles = new LinkedHashMap<>();
serializedProfiles.put(profile.getName(), YamlSerializer.serializeProfile(profile));
String serialized = new Yaml().dump(serializedProfiles);
LoadContext loadContext = new LoadContext();
BeConnectionProfile createdProfile = YamlDeserializer.deserializeConnectionProfile(loadContext, serialized, project);
assertNotNull(createdProfile);
if (!loadContext.getWarnings().isEmpty())
throw loadContext.getWarnings().get(0);
assertEquals(profile.getConnectionUrl(), createdProfile.getConnectionUrl());
assertEquals(profile.getUsername(), createdProfile.getUsername());
}
use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.
the class ReadModelFromXmlTest method testWriteReadQueryOperation.
@Test
public void testWriteReadQueryOperation() throws Exception {
final Project project = new Project("TestProject");
final Module module = project.getApplication();
DataElementUtils.saveQuiet(module);
final Entity table = new Entity("table", module, EntityType.TABLE);
DataElementUtils.saveQuiet(table);
final Operation op = Operation.createOperation("op", Operation.OPERATION_TYPE_JAVA, table);
DataElementUtils.saveQuiet(op);
final Query query = new Query("q", table);
DataElementUtils.saveQuiet(query);
query.getOperationNames().add("op");
final Path tempFolder = Files.createTempDirectory("be4-temp");
Serialization.save(project, tempFolder);
final Project readProject = Serialization.load(tempFolder);
final Entity readEntity = readProject.getApplication().getEntity("table");
assertEquals("op", readEntity.getQueries().get("q").getOperationNames().getValuesArray()[0]);
FileUtils.deleteRecursively(tempFolder);
}
Aggregations