Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove study from Order API #3282

Merged
merged 2 commits into from
Dec 11, 2023
Merged
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 @@ -159,11 +159,6 @@
version: item.selectedVersion,
dataFormats: extractDataFormats(item,
item.selectedAccessWay),
study: {
id: item.id,
surveyDataTypes: item.surveyDataTypes,
title: item.title
},
dataPackage: {
id: item.id,
surveyDataTypes: item.surveyDataTypes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,6 @@
version: $ctrl.selectedVersion,
dataFormats: extractDataFormats($ctrl.dataPackage,
$ctrl.selectedAccessWay),
study: {
id: $ctrl.dataPackage.id,
surveyDataTypes: $ctrl.dataPackage.surveyDataTypes,
title: $ctrl.dataPackage.title
},
dataPackage: {
id: $ctrl.dataPackage.id,
surveyDataTypes: $ctrl.dataPackage.surveyDataTypes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ angular.module('metadatamanagementApp').service('ShoppingCartService', ['OrderRe
.stripVersionSuffix(normalizedProduct.dataAcquisitionProjectId);

if (product.hasOwnProperty('dataPackage')) {
normalizedProduct.study.id = ProjectReleaseService
.stripVersionSuffix(normalizedProduct.study.id);
normalizedProduct.dataPackage.id = ProjectReleaseService
.stripVersionSuffix(normalizedProduct.dataPackage.id);
} else {
Expand Down Expand Up @@ -171,7 +169,7 @@ angular.module('metadatamanagementApp').service('ShoppingCartService', ['OrderRe
var removed = _.remove(order.products, function(productInOrder) {
if (product.hasOwnProperty('dataPackage') &&
productInOrder.hasOwnProperty('dataPackage')) {
return productInOrder.study.id === product.study.id &&
return productInOrder.dataPackage.id === product.dataPackage.id &&
productInOrder.version === product.version &&
productInOrder.accessWay === product.accessWay;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ angular.module('metadatamanagementApp').controller('ShoppingCartController', [
var suffixedProduct = _.cloneDeep(product);
suffixedProduct.dataAcquisitionProjectId =
product.dataAcquisitionProjectId + '-' + product.version;

suffixedProduct.study.id = product.study.id + '-' +
product.version;
suffixedProduct.dataPackage.id = product.dataPackage.id + '-' +
product.version;
return suffixedProduct;
Expand Down Expand Up @@ -319,20 +316,14 @@ angular.module('metadatamanagementApp').controller('ShoppingCartController', [
var createDataPackageForOrder = function(product, order) {
var completeProduct = {
dataAcquisitionProjectId: product.dataAcquisitionProjectId,
study: ctrl.dataPackages[product.study.id + '-' +
product.version],
dataPackage: ctrl.dataPackages[product.dataPackage.id + '-' +
product.version],
accessWay: product.accessWay,
version: product.version,
dataFormats: product.dataFormats
};
_.set(completeProduct, 'study.surveyDataTypes',
product.study.surveyDataTypes);
_.set(completeProduct, 'dataPackage.surveyDataTypes',
product.dataPackage.surveyDataTypes);
completeProduct.study.id = ProjectReleaseService
.stripVersionSuffix(completeProduct.study.id);
completeProduct.dataPackage.id = ProjectReleaseService
.stripVersionSuffix(completeProduct.dataPackage.id);
order.products.push(completeProduct);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ public class Product implements Serializable {
@NotEmpty
private String dataAcquisitionProjectId;

/**
* The (partial) {@link OrderedDataPackage} of this product.
*
* Either this or analysisPackage must be present.
*
* @deprecated will be renamed to dataPackage in alignment with DLP
*/
@Valid
private OrderedDataPackage study;

/**
* The (partial) {@link OrderedDataPackage} of this product.
*
Expand All @@ -73,7 +63,7 @@ public class Product implements Serializable {

/**
* The access way to the {@link OrderedDataPackage} which the customer wants to have.
*
*
* It must not be empty if dataPackage is present.
*/
private String accessWay;
Expand All @@ -86,8 +76,8 @@ public class Product implements Serializable {
private String version;

/**
* The available data formats of the {@link OrderedDataPackage}.
*
* The available data formats of the {@link OrderedDataPackage}.
*
* It must not be empty if dataPackage is present.
*/
private Set<DataFormat> dataFormats;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class EitherAnalysisPackageOrDataPackageOrderedValidator

@Override
public boolean isValid(Product product, ConstraintValidatorContext constraintValidatorContext) {
return (product.getDataPackage() != null && product.getStudy() != null)
return (product.getDataPackage() != null)
^ product.getAnalysisPackage() != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ public ResponseEntity<Order> findOrder(@PathVariable String id) {
if (product != null && product.getDataPackage() != null) {
product.getDataPackage().setRemarksUserService(null);
}
if (product != null && product.getStudy() != null) {
product.getStudy().setRemarksUserService(null);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,10 @@ private Order removeMarkdown(Order order) {
if (product.getDataPackage().getAnnotations().getDe() != null) {
product.getDataPackage().getAnnotations().setDe(
markdownHelper.getPlainText(product.getDataPackage().getAnnotations().getDe()));
product.getStudy().getAnnotations().setDe(
markdownHelper.getPlainText(product.getDataPackage().getAnnotations().getDe()));
}
if (product.getDataPackage().getAnnotations().getEn() != null) {
product.getDataPackage().getAnnotations().setEn(
markdownHelper.getPlainText(product.getDataPackage().getAnnotations().getEn()));
product.getStudy().getAnnotations().setEn(
markdownHelper.getPlainText(product.getDataPackage().getAnnotations().getEn()));
}
}
if (product.getAnalysisPackage() != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void updateOrder() throws Exception {

mockMvc.perform(get(UPDATE_ORDER_URL + order.getId())).andExpect(status().isOk())
.andExpect(jsonPath("$.products.length()", is(1)))
.andExpect(jsonPath("$.products[0].study.title.de",
.andExpect(jsonPath("$.products[0].dataPackage.title.de",
is(order.getProducts().get(0).getDataPackage().getTitle().getDe())));

// now update as DLP
Expand Down Expand Up @@ -146,7 +146,7 @@ public void shouldFailToCreateOrderWithoutDataPackageAndWithoutAnalysisPackage()
"eu.dzhw.fdz.metadatamanagement.domain.validationorder-management.error."
+ "either-analysis-package-or-data-package")));
}

@Test
public void shouldFailToCreateOrderWithDataPackageAndWithAnalysisPackage()
throws Exception {
Expand All @@ -164,7 +164,7 @@ public void shouldFailToCreateOrderWithDataPackageAndWithAnalysisPackage()
"eu.dzhw.fdz.metadatamanagement.domain.validationorder-management.error."
+ "either-analysis-package-or-data-package")));
}

@Test
public void shouldCreateOrderWithWithAnalysisPackage()
throws Exception {
Expand Down Expand Up @@ -198,7 +198,7 @@ private Product createProduct(String dataAcquisitionProjectId) {
dataPackage.setId("stu-" + dataAcquisitionProjectId + "$");
I18nString title = new I18nString("test", "test");
dataPackage.setTitle(title);
return new Product(dataAcquisitionProjectId, dataPackage, dataPackage, null,
return new Product(dataAcquisitionProjectId, dataPackage, null,
"remote-desktop-suf", "1.0.0", Set.of(DataFormat.R));
}
}