Ejemplo n.º 1
0
  @Override
  public File exportIndicatorTemplate(
      DefinitionsProvider provider, Generator generator, String levelStr) throws Exception {
    LOGGER.info("Querying Locations By Level: " + levelStr);
    int level = LocationAdmLevelEnum.valueOf(levelStr.toUpperCase()).getLevel();

    List<Location> locationList = locationRepository.findLocationsByLevelUacsNotNull(level);

    LOGGER.info("Writing header");
    generator.writeHeaders(provider.getColumnsDefinitions());

    locationList.forEach(
        location -> {
          Map<String, Object> properties =
              this.toKeyValuePairs(
                  location, Location.class, provider.getMethodsToInvoke().get(LOCATION_CLASSNAME));
          properties.putAll(
              this.toKeyValuePairs(
                  location,
                  AbstractPersistable.class,
                  LOCATION_CLASSNAME,
                  provider.getMethodsToInvoke().get(ABSTRACT_PERSISTABLE_CLASSNAME)));
          LOGGER.info("Writing row");
          generator.writeRow(getRow(provider.getColumnsDefinitions(), properties));
        });

    LOGGER.info("Writing file");
    String name = generator.getFileName();

    File file = fileService.createFile(name, true);
    return generator.toFile(file);
  }
Ejemplo n.º 2
0
  @Override
  public File exportIndicator(DefinitionsProvider provider, Generator generator, Long id)
      throws Exception {
    LOGGER.info("Querying Indicators");
    List<IndicatorDetail> indicatorDetails = indicatorDetailRepository.findByIndicatorId(id);

    LOGGER.info("Writing header");
    generator.writeHeaders(provider.getColumnsDefinitions());

    indicatorDetails.forEach(
        indicatorDetail -> {
          Location loc = locationRepository.findById(indicatorDetail.getLocationId());
          Map<String, Object> properties =
              this.toKeyValuePairs(
                  indicatorDetail,
                  IndicatorDetail.class,
                  provider.getMethodsToInvoke().get(INDICATOR_DETAIL_CLASSNAME));
          properties.putAll(
              this.toKeyValuePairs(
                  loc, Location.class, provider.getMethodsToInvoke().get(LOCATION_CLASSNAME)));
          LOGGER.info("Writing row");
          generator.writeRow(getRow(provider.getColumnsDefinitions(), properties));
        });

    LOGGER.info("Writing file");
    String name = generator.getFileName();

    File file = fileService.createFile(name, true);
    return generator.toFile(file);
  }
Ejemplo n.º 3
0
  public File exportLocationProject(
      DefinitionsProvider provider, Generator generator, Parameters parameters) throws Exception {

    LOGGER.info("Querying Locations");
    List<ProjectLocationDao> projectLocationList =
        locationRepository.findProjectLocationsByParams(parameters);

    LOGGER.info("Writing header");
    generator.writeHeaders(provider.getColumnsDefinitions());

    /*Collect data into a raw format*/
    projectLocationList.forEach(
        projectLocation -> {
          Map<String, Object> properties =
              this.toKeyValuePairs(
                  projectLocation.getLocation(),
                  Location.class,
                  provider.getMethodsToInvoke().get(LOCATION_CLASSNAME));
          properties.putAll(
              this.toKeyValuePairs(
                  projectLocation.getLocation(),
                  AbstractPersistable.class,
                  LOCATION_CLASSNAME,
                  provider.getMethodsToInvoke().get(ABSTRACT_PERSISTABLE_CLASSNAME)));
          properties.putAll(
              this.toKeyValuePairs(
                  projectLocation.getProject(),
                  Project.class,
                  provider.getMethodsToInvoke().get(PROJECT_CLASSNAME)));
          LOGGER.info("Writing row");
          generator.writeRow(getRow(provider.getColumnsDefinitions(), properties));
        });

    LOGGER.info("Writing file");
    String name = generator.getFileName();

    File file = fileService.createFile(name, true);

    return generator.toFile(file);
  }