use of com.developmentontheedge.be5.metadata.model.Module in project be5 by DevelopmentOnTheEdge.
the class Serialization method reloadPages.
public static StaticPages reloadPages(final Path file, final Module target) throws ReadException {
checkProject(target.getProject());
turnOffAutomaticSerialization();
try {
return new YamlDeserializer(new LoadContext()).reloadPages(file, target);
} finally {
turnOnAutomaticSerialization();
}
}
use of com.developmentontheedge.be5.metadata.model.Module in project be5 by DevelopmentOnTheEdge.
the class YamlDeserializer method readEntity.
public static Entity readEntity(final LoadContext loadContext, final String entityName, final Map<String, Object> content, final Module module) {
YamlDeserializer yamlDeserializer = new YamlDeserializer(loadContext);
yamlDeserializer.setProject(module.getProject());
EntityDeserializer entityDeserializer = yamlDeserializer.new EntityDeserializer();
try {
return entityDeserializer.readEntity(entityName, content, module);
} catch (ReadException e) {
Entity entity = new Entity(entityName, module, EntityType.TABLE);
loadContext.addWarning(e.attachElement(entity));
return entity;
}
}
use of com.developmentontheedge.be5.metadata.model.Module in project be5 by DevelopmentOnTheEdge.
the class YamlDeserializer method readCustomizations.
/**
* Used with customizations (module), entity, query, operation and static page.
*/
@SuppressWarnings("unchecked")
private void readCustomizations(final Map<String, Object> serialized, final BeVectorCollection<?> target, boolean replace) {
if (project == null)
throw new IllegalStateException();
final Map<String, Object> serializedCustomizations = (Map<String, Object>) serialized.get("customizations");
if (serializedCustomizations == null || serializedCustomizations.isEmpty())
return;
final BeVectorCollection<PageCustomization> customizations = replace ? new PageCustomizations(target) : target.getOrCreateCollection(PageCustomization.CUSTOMIZATIONS_COLLECTION, PageCustomization.class);
try {
for (final String name : serializedCustomizations.keySet()) {
final Map<String, Object> content = (Map<String, Object>) serializedCustomizations.get(name);
final List<String> splitted = StreamEx.split(name, "\\.").toList();
final String type;
final String domain;
if (splitted.size() == 1) {
type = "";
domain = splitted.get(0);
} else {
type = splitted.get(splitted.size() - 1);
splitted.remove(splitted.size() - 1);
domain = String.join(".", splitted);
}
final PageCustomization customization = new PageCustomization(type, domain, customizations);
customization.setCode((String) content.get(TAG_CODE));
customization.setOriginModuleName(project.getProjectOrigin());
DataElementUtils.saveQuiet(customization);
}
} catch (Exception e) {
loadContext.addWarning(new ReadException(e, target, project.getLocation()));
}
if (replace)
DataElementUtils.save(customizations);
}
use of com.developmentontheedge.be5.metadata.model.Module in project be5 by DevelopmentOnTheEdge.
the class YamlDeserializer method reloadForms.
public JavaScriptForms reloadForms(final Path path, final Module target) throws ReadException {
final JavaScriptForms forms = new JavaScriptForms(target);
final FormsDeserializer deserializer = new FormsDeserializer(path, forms);
deserializer.deserialize();
DataElementUtils.saveQuiet(forms);
return forms;
}
use of com.developmentontheedge.be5.metadata.model.Module 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;
}
Aggregations