use of com.icthh.xm.ms.entity.config.XmEntityTenantConfigService.XmEntityTenantConfig in project xm-ms-entity by xm-online.
the class XmEntitySpecService method extendDataForm.
@SneakyThrows
private void extendDataForm(TypeSpec type, TypeSpec parentType, String tenant) {
XmEntityTenantConfig entityTenantConfig = this.tenantConfigService.getXmEntityTenantConfig(tenant);
Boolean isInheritanceEnabled = entityTenantConfig.getEntitySpec().getEnableDataFromInheritance();
if (isFeatureEnabled(isInheritanceEnabled, type.getDataFormInheritance()) && hasDataForm(type, parentType)) {
ObjectMapper objectMapper = new ObjectMapper();
var defaults = objectMapper.readValue(parentType.getDataForm(), Map.class);
ObjectReader updater = objectMapper.readerForUpdating(defaults);
Map<String, Object> merged = updater.readValue(type.getDataForm());
String mergedJson = objectMapper.writeValueAsString(merged);
type.setDataForm(mergedJson);
} else {
type.setDataForm(type.getDataForm() != null ? type.getDataForm() : parentType.getDataForm());
}
}
use of com.icthh.xm.ms.entity.config.XmEntityTenantConfigService.XmEntityTenantConfig in project xm-ms-entity by xm-online.
the class XmEntitySpecServiceUnitTest method setExtendsFormAndSpec.
private void setExtendsFormAndSpec(Boolean value) {
XmEntityTenantConfig config = new XmEntityTenantConfig();
config.getEntitySpec().setEnableDataFromInheritance(value);
config.getEntitySpec().setEnableDataSpecInheritance(value);
when(tenantConfig.getXmEntityTenantConfig("RESINTTEST")).thenReturn(config);
}
Aggregations