Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;


import static org.eea.utils.LiteralConstants.*;

Expand Down Expand Up @@ -234,6 +231,24 @@ private String calculateS3TableAsFolderPath(S3PathResolver s3PathResolver, Strin
String dataCollectionFolder = formatFolderName(s3PathResolver.getDatasetId(), S3_DATA_COLLECTION_PATTERN);
String euDatasetFolder = formatFolderName(s3PathResolver.getDatasetId(), S3_EU_DATASET_PATTERN);

String preparationSetCode = s3PathResolver.getPreparationSetCode();

// handling preparation dataset case
if (StringUtils.isNotBlank(preparationSetCode)) {

switch (path) {
case S3_TABLE_AS_FOLDER_QUERY_PATH:
return S3_DEFAULT_BUCKET + String.format(S3_TABLE_NAME_PREPARATION_DATASET_FOLDER_PATH, dataflowFolder, dataProviderFolder, datasetFolder, preparationSetCode, s3PathResolver.getTableName());
case S3_TABLE_NAME_FOLDER_PATH:
case S3_TABLE_NAME_PATH:
return String.format(S3_TABLE_NAME_PREPARATION_DATASET_FOLDER_PATH, dataflowFolder, dataProviderFolder, datasetFolder, preparationSetCode, s3PathResolver.getTableName());
case S3_TABLE_NAME_QUERY_PATH:
return String.format(S3_TABLE_NAME_PREPARATION_DATASET_QUERY_PATH, dataflowFolder, dataProviderFolder, datasetFolder, preparationSetCode, s3PathResolver.getTableName());
default:
break;
}
}

switch (path) {
case S3_EXPORT_PREFILLED_TABLE_FILE_PATH:
case S3_IMPORT_FILE_PATH:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ public class S3PathResolver {
/** The isIcebergTable. */
private Boolean isIcebergTable;

/** Name of the preparation dataset, if applicable */
private String preparationSetCode;

public S3PathResolver(long dataflowId, long dataProviderId, long datasetId,
String tableName, String filename, String path, String preparationSetName) {
this(dataflowId, dataProviderId, datasetId, tableName, filename, path);
this.preparationSetCode = preparationSetName;
}

public S3PathResolver(long dataflowId, long dataProviderId, long datasetId) {
this.dataflowId = dataflowId;
this.dataProviderId = dataProviderId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ public final class LiteralConstants {
/** The Constant NO_IMPORT_IN_PROGRESS. */
public static final String NO_IMPORT_IN_PROGRESS = "There is no import process in progress";

/** The Constant S3_PREPARATION_DATASET_PATH: {@value}. */
public static final String S3_PREPARATION_DATASET_PATH = "%s/%s/%s/current/preparation/%s/%s";

/** The Constant S3_TABLE_NAME_PREPARATION_DATASET_FOLDER_PATH: {@value}. */
public static final String S3_TABLE_NAME_PREPARATION_DATASET_FOLDER_PATH = "%s/%s/%s/current/preparation/%s/%s/%s";

/** The Constant S3_TABLE_NAME_PREPARATION_DATASET_QUERY_PATH: {@value}. */
public static final String S3_TABLE_NAME_PREPARATION_DATASET_QUERY_PATH = ".\"%s\".\"%s\".\"%s\".\"current\".\"preparation\".\"%s\".\"%s\".\"%s\"";

/** The Constant S3_NAME_PATTERN_LENGTH: {@value}. */
public static final int S3_NAME_PATTERN_LENGTH = 7;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.apache.commons.lang3.StringUtils;
import org.eea.dataset.service.CreateEmptyTables;
import org.eea.dataset.service.PreparationDatasetService;
import org.eea.exception.EEAException;
import org.eea.interfaces.controller.dataset.PreparationDatasetController;
import org.eea.interfaces.vo.dataset.DataSetMetabaseVO;
import org.eea.interfaces.vo.dataset.PreparationDatasetVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -39,6 +41,9 @@ public class PreparationDatasetControllerImpl
@Autowired
private PreparationDatasetService preparationDatasetService;

@Autowired
private CreateEmptyTables createEmptyTables;

/**
* List preparation datasets by dataflow id and provider id.
*/
Expand Down Expand Up @@ -168,4 +173,12 @@ public void deletePreparationDatasetById(
"Unexpected error while deleting preparation dataset");
}
}

@PostMapping("/run-creation-for-preparation-dataset")
@ApiOperation("Create preparation datasets inside Dremio")
public void runCreationForPreparationDataset(
@RequestBody DataSetMetabaseVO parentDataset,
@RequestParam("preparationSetName") String preparationSetName) throws EEAException {
createEmptyTables.runCreationForPreparationDataset(parentDataset, preparationSetName);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.eea.dataset.service;

import org.eea.datalake.service.DremioHelperService;
import org.eea.datalake.service.model.S3PathResolver;
import org.eea.exception.EEAException;
import org.eea.interfaces.vo.dataset.DataSetMetabaseVO;
Expand Down Expand Up @@ -32,4 +31,9 @@ public interface CreateEmptyTables {
* @throws Exception exception
*/
void deleteTableIfEmpty(String tableSchemaName, S3PathResolver tablePathResolver) throws Exception;

void runCreationForPreparationDataset(DataSetMetabaseVO parentDataset, String preparationSetName) throws EEAException;

void runCreationForPreparationDatasetTable(DataSetMetabaseVO parentDataset, String tableSchemaId, String preparationSetName) throws EEAException;

}
Loading