use of com.developmentontheedge.be5.metadata.model.PageCustomizations 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.PageCustomizations in project be5 by DevelopmentOnTheEdge.
the class YamlSerializer method serialize.
public void serialize(final PageCustomizations customizations) throws WriteException {
this.fileSystem = new ProjectFileSystem(customizations.getProject());
new CustomizationSerializer().serialize(customizations.getModule());
}
use of com.developmentontheedge.be5.metadata.model.PageCustomizations in project be5 by DevelopmentOnTheEdge.
the class Serialization method reloadCustomizations.
public static PageCustomizations reloadCustomizations(final Path file, final Module target) throws ReadException {
checkProject(target.getProject());
turnOffAutomaticSerialization();
try {
return new YamlDeserializer(new LoadContext()).reloadCustomizations(file, target);
} finally {
turnOnAutomaticSerialization();
}
}
Aggregations