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

fix(sdk): added improvement patch for detail query of quote and order #56

Merged
merged 11 commits into from
Nov 4, 2024
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 @@ -22,6 +22,7 @@
@Slf4j
public class DBCrudActionRunner extends AbstractActionRunner {
private static final String ENTITY_NOT_FOUND_ERR = "DBCrudFilterFactory: entity not found";
private static final String ENTITY_ID_ERROR = ENTITY_NOT_FOUND_ERR + ", entityId:%s";
private final HttpRequestRepository repository;
private final FilterHeaderService filterHeaderService;

Expand Down Expand Up @@ -138,10 +139,16 @@ private void onUpdate(ServerWebExchange exchange, Config config) {
}

private void onRead(ServerWebExchange exchange, Config config) {
if (StringUtils.isBlank(config.getId()) && StringUtils.isNotBlank(config.getBlankIdErrMsg())) {
throw KrakenException.badRequest(config.getBlankIdErrMsg());
}
Optional<HttpRequestEntity> optionalEntity = readRequestEntity(config.getId());
if (optionalEntity.isEmpty()) {
log.error(ENTITY_NOT_FOUND_ERR);
return;
if (StringUtils.isNotBlank(config.getNotExistedErrMsg())) {
throw KrakenException.notFound(config.getNotExistedErrMsg());
} else {
throw KrakenException.notFound(String.format(ENTITY_ID_ERROR, config.getId()));
}
}
HttpRequestEntity entity = optionalEntity.get();
exchange.getAttributes().put(KrakenFilterConstants.X_ENTITY_ID, entity.getId().toString());
Expand All @@ -156,9 +163,9 @@ private Optional<HttpRequestEntity> readRequestEntity(String entityId) {
try {
entityUUID = UUID.fromString(entityId);
} catch (Exception e) {
String error = ENTITY_NOT_FOUND_ERR + ", entityId:" + entityId;
String error = String.format(ENTITY_ID_ERROR, entityId);
log.error(error, e);
throw KrakenException.notFound(error);
return Optional.empty();
}
return repository.findById(entityUUID);
}
Expand All @@ -171,6 +178,8 @@ public static class Config {
private String id;
private List<String> properties;
private String externalId;
private String blankIdErrMsg;
private String notExistedErrMsg;

public static Config of(ComponentAPIFacets.Action action, Map<String, Object> inputs) {
Map<String, Object> with = action.getWith();
Expand All @@ -181,6 +190,12 @@ public static Config of(ComponentAPIFacets.Action action, Map<String, Object> in
if ("undefined".equalsIgnoreCase(config.getBizType())) {
config.setBizType((String) inputs.get("bizType"));
}
if (config.getBlankIdErrMsg() == null) {
config.setBlankIdErrMsg((String) inputs.getOrDefault("blankIdErrMsg", ""));
}
if (config.getNotExistedErrMsg() == null) {
config.setNotExistedErrMsg((String) inputs.getOrDefault("notExistedErrMsg", ""));
}
return config;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
description: ""
source: "@{{id}}"
sourceLocation: "PATH"
target: "}"
target: ""
targetLocation: ""
requiredMapping: true
response:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ spec:
targetLocation: BODY
requiredMapping: true
replaceStar: false
- name: address.validation.country.mapper
- name: mapper.address.validation.country
title: "The country of the identified alternate Geographic Address"
description: ""
source: ""
Expand All @@ -64,7 +64,7 @@ spec:
targetLocation: BODY
requiredMapping: false
replaceStar: false
- name: address.validation.city.mapper
- name: mapper.address.validation.city
title: "The city of the identified alternate Geographic Address"
description: ""
source: ""
Expand All @@ -74,7 +74,7 @@ spec:
targetLocation: BODY
requiredMapping: false
replaceStar: false
- name: address.validation.address.mapper
- name: mapper.address.validation.address
title: "The street of the identified alternate Geographic Address"
description: ""
source: ""
Expand All @@ -84,7 +84,7 @@ spec:
targetLocation: BODY
requiredMapping: false
replaceStar: false
- name: address.validation.locality.mapper
- name: mapper.address.validation.locality
title: "The metroId of the identified alternate Geographic Address"
description: ""
source: ""
Expand All @@ -94,7 +94,7 @@ spec:
targetLocation: BODY
requiredMapping: false
replaceStar: false
- name: address.validation.bestMatch.id.mapper
- name: mapper.address.validation.bestMatch.id
title: "Unique identifier of the identified best match Address"
requiredMapping: false
description: ""
Expand All @@ -106,7 +106,7 @@ spec:
checkPath: "$.bestMatchGeographicAddress.id"
deletePath: "$.bestMatchGeographicAddress"
replaceStar: false
- name: address.validation.bestMatch.city.mapper
- name: mapper.address.validation.bestMatch.city
title: "The City of the identified best match Address"
requiredMapping: false
description: ""
Expand All @@ -116,7 +116,7 @@ spec:
targetType: string
targetLocation: BODY
replaceStar: false
- name: address.validation.bestMatch.country.mapper
- name: mapper.address.validation.bestMatch.country
title: "The Country of the identified best match Address"
requiredMapping: false
description: ""
Expand All @@ -126,7 +126,7 @@ spec:
targetType: string
targetLocation: BODY
replaceStar: false
- name: address.validation.bestMatch.streetName.mapper
- name: mapper.address.validation.bestMatch.streetName
title: "The streetName of the identified best match Address"
requiredMapping: false
description: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ links:
- targetAssetKey: mef.sonata.api-target-mapper.address.validate
relationship: implementation.target-mapper
group: mef.sonata.api-target.address.validate
- targetAssetKey: mef.sonata.api.matrix.address.validate
- targetAssetKey: mef.sonata.api.matrix.address.validation
relationship: implementation.matrix
group: mef.sonata.api-target.address.validate
- targetAssetKey: mef.sonata.api-target-mapper.address.retrieve
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ spec:
actionType: buildin@db
env:
id: ${query.productOrderId}
blankIdErrMsg: "productOrderId id cannot be blank"
notExistedErrMsg: "productOrderId id does not exist"
with:
action: read
preRequest: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ spec:
actionType: buildin@db
env:
id: ${segment}
blankIdErrMsg: "order id cannot be blank"
notExistedErrMsg: "order id does not exist"
with:
action: read
preRequest: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ spec:
actionType: buildin@db
env:
id: ${segment}
blankIdErrMsg: "quote id cannot be blank"
notExistedErrMsg: "quote id does not exist"
with:
action: read
preRequest: true
Expand Down
Loading