Ejemplo n.º 1
0
  private void processAnnotationScanningResults(
      List<EntityProcessorOutput> entityProcessorOutput,
      Map<String, List<LookupDto>> lookupProcessingResult) {
    Map<String, Long> entityIdMappings = new HashMap<>();

    for (EntityProcessorOutput result : entityProcessorOutput) {
      EntityDto processedEntity = result.getEntityProcessingResult();

      EntityDto entity = entityService.getEntityByClassName(processedEntity.getClassName());

      if (entity == null) {
        entity = entityService.createEntity(processedEntity);
      }
      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());
      entityService.updateMaxFetchDepth(entity.getId(), processedEntity.getMaxFetchDepth());
      entityService.addNonEditableFields(entity, result.getNonEditableProcessingResult());
    }

    for (Map.Entry<String, List<LookupDto>> entry : lookupProcessingResult.entrySet()) {
      entityService.addLookups(entityIdMappings.get(entry.getKey()), entry.getValue());
    }
  }