use of com.developmentontheedge.be5.metadata.serialization.LoadContext in project be5 by DevelopmentOnTheEdge.
the class ModuleLoader2 method loadModules.
public static List<Project> loadModules(Project application, ProcessController logger, LoadContext loadContext) throws ProjectLoadException {
List<Project> result = new ArrayList<>();
for (Module module : application.getModules()) {
if (containsModule(module.getName())) {
Project moduleProject = modulesMap.get(module.getName());
result.add(moduleProject);
} else {
throw new RuntimeException("Module project not found " + module.getName());
}
}
// todo ????? topological sort?
result.sort((o1, o2) -> {
if (o1.getModules().contains(o2.getName()))
return 1;
if (o2.getModules().contains(o1.getName()))
return -1;
return 0;
});
return result;
}
use of com.developmentontheedge.be5.metadata.serialization.LoadContext 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.serialization.LoadContext 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.serialization.LoadContext 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.serialization.LoadContext 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;
}
Aggregations