use of org.talend.dataprep.qa.dto.Folder in project data-prep by Talend.
the class PreparationStep method givenICreateAPreparation.
@Given("^I create a preparation with name \"(.*)\", based on \"(.*)\" dataset$")
public void givenICreateAPreparation(String prepFullName, String datasetName) throws IOException {
String suffixedPrepName = getSuffixedPrepName(prepFullName);
String prepPath = util.extractPathFromFullName(prepFullName);
Folder prepFolder = folderUtil.searchFolder(prepPath);
String suffixedDatasetName = (context.getDatasetId(datasetName) == null) ? suffixName(datasetName) : datasetName;
final String datasetId = context.getDatasetId(suffixedDatasetName);
if (StringUtils.isBlank(datasetId)) {
fail("could not find dataset id from name '" + suffixedDatasetName + "' in the context");
}
LOGGER.info("I create a preparation with name {}", suffixedPrepName);
String preparationId = api.createPreparation(datasetId, suffixedPrepName, folderUtil.getAPIFolderRepresentation(prepFolder)).then().statusCode(//
OK.value()).extract().body().asString();
context.storePreparationRef(preparationId, suffixedPrepName, prepFolder.getPath());
}
use of org.talend.dataprep.qa.dto.Folder in project data-prep by Talend.
the class OSIntegrationTestUtil method splitFolder.
/**
* Split a folder in a {@link Set} folder and subfolders.
*
* @param folder the folder to split.
* @param folders existing folders.
* @return a {@link Set} of folders and subfolders.
*/
public Set<Folder> splitFolder(Folder folder, List<Folder> folders) {
Set<Folder> ret = new HashSet<>();
if (folder == null || folder.getPath().equals("/"))
return ret;
final Map<String, Folder> folderByPath = new HashMap<>(folders.size());
folders.forEach(f -> folderByPath.put(f.getPath().substring(1), f));
String[] folderPaths = folder.getPath().split("/");
StringBuilder folderBuilder = new StringBuilder();
Arrays.stream(//
folderPaths).filter(//
f -> !f.isEmpty() && !f.equals("/")).forEach(f -> {
//
if (folderBuilder.length() > 0) {
folderBuilder.append("/");
}
folderBuilder.append(f);
Folder tmpF = folderByPath.get(folderBuilder.toString());
if (tmpF != null) {
ret.add(tmpF);
}
});
return ret;
}
use of org.talend.dataprep.qa.dto.Folder in project data-prep by Talend.
the class PreparationStep method movePreparation.
@Then("^I move the preparation \"(.*)\" to \"(.*)\"$")
public void movePreparation(String prepOriginFullName, String prepDestFullName) throws IOException {
String suffixedPrepOriginName = getSuffixedPrepName(prepOriginFullName);
String suffixedPrepOriginPath = util.extractPathFromFullName(prepOriginFullName);
String suffixedPrepOriginId = context.getPreparationId(suffixedPrepOriginName, suffixedPrepOriginPath);
String suffixedPrepDestName = getSuffixedPrepName(prepDestFullName);
String prepDestPath = util.extractPathFromFullName(prepDestFullName);
Folder originFolder = folderUtil.searchFolder(suffixedPrepOriginPath);
Folder destFolder = folderUtil.searchFolder(prepDestPath);
Response response = //
api.movePreparation(suffixedPrepOriginId, originFolder.id, destFolder.id, suffixedPrepDestName);
response.then().statusCode(OK.value());
context.storePreparationMove(suffixedPrepOriginId, suffixedPrepOriginName, originFolder.path, suffixedPrepDestName, destFolder.path);
}
use of org.talend.dataprep.qa.dto.Folder in project data-prep by Talend.
the class PreparationStep method copyPreparation.
@Then("^I copy the preparation \"(.*)\" to \"(.*)\"$")
public void copyPreparation(String prepOriginFullName, String prepDestFullName) throws IOException {
String suffixedPrepOriginName = getSuffixedPrepName(prepOriginFullName);
String suffixedPrepOriginPath = util.extractPathFromFullName(prepOriginFullName);
String suffixedPrepDestName = getSuffixedPrepName(prepDestFullName);
String suffixedPrepDestPath = util.extractPathFromFullName(prepDestFullName);
Folder destFolder = folderUtil.searchFolder(suffixedPrepDestPath);
String prepId = context.getPreparationId(suffixedPrepOriginName, suffixedPrepOriginPath);
String newPreparationId = api.copyPreparation(prepId, destFolder.id, suffixedPrepDestName).then().statusCode(OK.value()).extract().body().asString();
context.storePreparationRef(newPreparationId, suffixedPrepDestName, destFolder.path);
}
use of org.talend.dataprep.qa.dto.Folder in project data-prep by Talend.
the class OSFolderUtil method splitFolder.
@Override
public Set<Folder> splitFolder(Folder folder, List<Folder> folders) {
Set<Folder> ret = new HashSet<>();
if (folder == null || folder.getPath().equals("/"))
return ret;
final Map<String, Folder> folderByPath = new HashMap<>(folders.size());
folders.forEach(f -> folderByPath.put(f.getPath().substring(1), f));
String[] folderPaths = folder.getPath().split("/");
StringBuilder folderBuilder = new StringBuilder();
Arrays.stream(//
folderPaths).filter(//
f -> !f.isEmpty() && !"/".equals(f)).forEach(f -> {
//
if (folderBuilder.length() > 0) {
folderBuilder.append("/");
}
folderBuilder.append(f);
Folder tmpF = folderByPath.get(folderBuilder.toString());
if (tmpF != null) {
ret.add(tmpF);
}
});
return ret;
}
Aggregations