use of org.motechproject.mds.annotations.internal.EntityProcessorOutput in project motech by motech.
the class EditableLookupsLoaderTest method prepareOutput.
private void prepareOutput() {
EntityProcessorOutput entityProcessorOutput = new EntityProcessorOutput();
entityProcessorOutput.setEntityProcessingResult(prepareEntityDto());
List<EntityProcessorOutput> entityProcessorOutputs = new ArrayList<>();
entityProcessorOutputs.add(entityProcessorOutput);
output = new MDSProcessorOutput(entityProcessorOutputs, new HashMap<>(), bundle);
}
use of org.motechproject.mds.annotations.internal.EntityProcessorOutput in project motech by motech.
the class MdsBundleWatcher method processAnnotationScanningResults.
private void processAnnotationScanningResults(MDSProcessorOutput output) {
Map<String, Long> entityIdMappings = new HashMap<>();
Set<String> newEntities = new HashSet<>();
Bundle bundle = output.getBundle();
try {
migrationService.processBundle(bundle);
} catch (IOException e) {
LOGGER.error("An error occurred while copying the migrations from bundle: {}", bundle.getSymbolicName(), e);
}
try {
editableLookupsLoader.addEditableLookups(output, bundle);
} catch (MdsException e) {
LOGGER.error("Unable to read JSON defined lookups from bundle: {}", bundle, e);
}
for (EntityProcessorOutput result : output.getEntityProcessorOutputs()) {
EntityDto processedEntity = result.getEntityProcessingResult();
EntityDto entity = entityService.getEntityByClassName(processedEntity.getClassName());
if (entity == null) {
entity = entityService.createEntity(processedEntity);
newEntities.add(entity.getClassName());
}
entityIdMappings.put(entity.getClassName(), entity.getId());
entityService.updateRestOptions(entity.getId(), result.getRestProcessingResult());
entityService.updateTracking(entity.getId(), result.getTrackingProcessingResult());
entityService.addFields(entity, result.getFieldProcessingResult());
entityService.addFilterableFields(entity, result.getUiFilterableProcessingResult());
entityService.addDisplayedFields(entity, result.getUiDisplayableProcessingResult());
entityService.updateSecurityOptions(entity.getId(), processedEntity.getSecurityMode(), processedEntity.getSecurityMembers(), processedEntity.getReadOnlySecurityMode(), processedEntity.getReadOnlySecurityMembers());
entityService.updateMaxFetchDepth(entity.getId(), processedEntity.getMaxFetchDepth());
entityService.addNonEditableFields(entity, result.getNonEditableProcessingResult());
}
for (Map.Entry<String, List<LookupDto>> entry : output.getLookupProcessorOutputs().entrySet()) {
String entityClassName = entry.getKey();
Long entityId = entityIdMappings.get(entityClassName);
if (schemaComparator.lookupsDiffer(entityId, entry.getValue())) {
entityService.addLookups(entityId, entry.getValue());
if (!newEntities.contains(entityClassName)) {
entityService.incrementVersion(entityId);
}
}
}
}
Aggregations