Class CreateLayerExtractService

java.lang.Object
org.tailormap.api.service.CreateLayerExtractService

@Service public class CreateLayerExtractService extends Object
  • Constructor Details

    • CreateLayerExtractService

      public CreateLayerExtractService(@Qualifier("viewerSseEventBus") ch.rasc.sse.eventbus.SseEventBus eventBus, tools.jackson.databind.json.JsonMapper jsonMapper, FeatureSourceFactoryHelper featureSourceFactoryHelper)
  • Method Details

    • getExportFilesLocation

      public String getExportFilesLocation()
    • emitProgress

      public void emitProgress(@NonNull String clientId, @Nullable String fileId, int progress, boolean completed, @Nullable String message)
    • validateClientId

      public void validateClientId(@NonNull String clientId) throws IllegalArgumentException
      Check that the sse client id is valid and exists.
      Parameters:
      clientId - the SSE client id
      Throws:
      IllegalArgumentException - when the SSE client id is invalid or not found on the event bus
    • createExtractFilename

      public String createExtractFilename(@NonNull String clientId, @NonNull TMFeatureType sourceFT, @NonNull LayerExtractController.ExtractOutputFormat outputFormat) throws IllegalArgumentException
      Create a validated filename for an extract. The naming follows the pattern "%s_%s_%s%s".formatted(sourceFT.getName(), clientId, UUIDv7.randomV7(), outputFormat.getExtension()) where the first part is the source feature type name (this is cleaned from some characters), the second part is the SSE client id, the third part is a random UUIDv7 and the fourth part is the file extension based on the requested output format.
      Parameters:
      clientId - the SSE client id
      sourceFT - the source featuretype for the extract
      outputFormat - the required format of the extract
      Returns:
      the filename used to create an extract
      Throws:
      IllegalArgumentException - when the SSE clientId is invalid or not found on the event bus
    • createLayerExtract

      @Async("extractTaskExecutor") @Transactional public void createLayerExtract(@NonNull String clientId, @NonNull TMFeatureType inputTmFeatureType, @NonNull Set<String> attributes, @Nullable org.geotools.api.filter.Filter filter, String sortBy, org.geotools.api.filter.sort.SortOrder sortOrder, @NonNull LayerExtractController.ExtractOutputFormat extractOutputFormat, @NonNull String outputFileName)
    • cleanupExpiredExtracts

      @Scheduled(fixedDelay=5L, timeUnit=MINUTES, initialDelay=15L) public void cleanupExpiredExtracts()
      Cleanup expired extract files. Filenames are created in createExtractFilename(String, TMFeatureType, LayerExtractController.ExtractOutputFormat) and follow the pattern "%s_%s_%s.%s".formatted(sourceFT.getName(), clientId, UUIDv7.randomV7(), outputFormat.getExtension())