description type not found in import description template case

This commit is contained in:
CITE\amentis 2024-07-25 16:57:18 +03:00
parent 89eb5bc963
commit 5a784f0362
7 changed files with 32 additions and 15 deletions

View File

@ -418,4 +418,14 @@ public class ErrorThesaurusProperties {
public void setDescriptionTemplateTypeCodeExists(ErrorDescription descriptionTemplateTypeCodeExists) { public void setDescriptionTemplateTypeCodeExists(ErrorDescription descriptionTemplateTypeCodeExists) {
this.descriptionTemplateTypeCodeExists = descriptionTemplateTypeCodeExists; this.descriptionTemplateTypeCodeExists = descriptionTemplateTypeCodeExists;
} }
private ErrorDescription descriptionTemplateTypeImportNotFound;
public ErrorDescription getDescriptionTemplateTypeImportNotFound() {
return descriptionTemplateTypeImportNotFound;
}
public void setDescriptionTemplateTypeImportNotFound(ErrorDescription descriptionTemplateTypeImportNotFound) {
this.descriptionTemplateTypeImportNotFound = descriptionTemplateTypeImportNotFound;
}
} }

View File

@ -730,7 +730,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
persist.setStatus(DescriptionTemplateStatus.Draft); persist.setStatus(DescriptionTemplateStatus.Draft);
persist.setDescription(importXml.getDescription()); persist.setDescription(importXml.getDescription());
persist.setLanguage(importXml.getLanguage()); persist.setLanguage(importXml.getLanguage());
persist.setType(this.xmlDescriptionTemplateTypeToPersist(importXml.getDescriptionTemplateType())); persist.setType(this.xmlDescriptionTemplateTypeToPersist(importXml.getDescriptionTemplateType(), label));
persist.setDefinition(this.xmlDefinitionToPersist(importXml)); persist.setDefinition(this.xmlDefinitionToPersist(importXml));
this.validatorFactory.validator(DescriptionTemplatePersist.DescriptionTemplatePersistValidator.class).validateForce(persist); this.validatorFactory.validator(DescriptionTemplatePersist.DescriptionTemplatePersistValidator.class).validateForce(persist);
return this.persist(persist, groupId, fields); return this.persist(persist, groupId, fields);
@ -750,7 +750,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
persist.setDescription(importXml.getDescription()); persist.setDescription(importXml.getDescription());
persist.setLanguage(importXml.getLanguage()); persist.setLanguage(importXml.getLanguage());
persist.setDefinition(this.xmlDefinitionToPersist(importXml)); persist.setDefinition(this.xmlDefinitionToPersist(importXml));
persist.setType(this.xmlDescriptionTemplateTypeToPersist(importXml.getDescriptionTemplateType())); persist.setType(this.xmlDescriptionTemplateTypeToPersist(importXml.getDescriptionTemplateType(), label));
persist.setHash(this.conventionService.hashValue(latestVersionDescriptionTemplate.getUpdatedAt())); persist.setHash(this.conventionService.hashValue(latestVersionDescriptionTemplate.getUpdatedAt()));
this.validatorFactory.validator(NewVersionDescriptionTemplatePersist.NewVersionDescriptionTemplatePersistValidator.class).validateForce(persist); this.validatorFactory.validator(NewVersionDescriptionTemplatePersist.NewVersionDescriptionTemplatePersistValidator.class).validateForce(persist);
@ -759,28 +759,28 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
} }
} }
private UUID xmlDescriptionTemplateTypeToPersist(DescriptionTemplateTypeImportExport importXml) { private UUID xmlDescriptionTemplateTypeToPersist(DescriptionTemplateTypeImportExport importXml, String label) {
if (importXml == null) return null; if (importXml == null) return null;
DescriptionTemplateTypeQuery query = null; DescriptionTemplateTypeQuery query = null;
if (importXml.getId() != null) { if (importXml.getId() != null) {
// search by id // search by id
query = this.queryFactory.query(DescriptionTemplateTypeQuery.class).ids(importXml.getId()); DescriptionTemplateTypeEntity entity = this.queryFactory.query(DescriptionTemplateTypeQuery.class).ids(importXml.getId()).firstAs(new BaseFieldSet().ensure(DescriptionTemplate._id));
if (query != null && query.count() > 0 ) { if (entity != null ) {
return query.firstAs(new BaseFieldSet().ensure(DescriptionTemplate._id)).getId(); return entity.getId();
} else { } else {
if (!this.conventionService.isNullOrEmpty(importXml.getCode())){ if (!this.conventionService.isNullOrEmpty(importXml.getCode())){
// search by code // search by code
query = this.queryFactory.query(DescriptionTemplateTypeQuery.class).codes(importXml.getCode()); entity = this.queryFactory.query(DescriptionTemplateTypeQuery.class).codes(importXml.getCode()).firstAs(new BaseFieldSet().ensure(DescriptionTemplate._id));
if (query != null && query.count() > 0) { if (entity != null) {
return query.firstAs(new BaseFieldSet().ensure(DescriptionTemplate._id)).getId(); return entity.getId();
} }
} }
} }
} }
return null; throw new MyValidationException(this.errors.getDescriptionTemplateTypeImportNotFound().getCode(), !this.conventionService.isNullOrEmpty(importXml.getCode()) ? importXml.getCode() : importXml.getName());
} }
@Override @Override

View File

@ -130,4 +130,7 @@ error-thesaurus:
message: Usage limit metric is already selected as target message: Usage limit metric is already selected as target
descriptionTemplateTypeCodeExists: descriptionTemplateTypeCodeExists:
code: 147 code: 147
message: Description template type code exists message: Description template type code exists
descriptionTemplateTypeImportNotFound:
code: 148
message: Description template type not found

View File

@ -43,6 +43,7 @@ export enum ResponseErrorCode {
UsageLimitException = 145, UsageLimitException = 145,
UsageLimitMetricAlreadyExists = 146, UsageLimitMetricAlreadyExists = 146,
DescriptionTemplateTypeCodeExists = 147, DescriptionTemplateTypeCodeExists = 147,
descriptionTemplateTypeImportNotFound = 148,
// Notification & Annotation Errors // Notification & Annotation Errors
InvalidApiKey = 200, InvalidApiKey = 200,
@ -163,6 +164,8 @@ export class ResponseErrorCodeHelper {
return language.instant("GENERAL.BACKEND-ERRORS.USAGE-LIMIT-METRIC-ALLREADY-EXISTS"); return language.instant("GENERAL.BACKEND-ERRORS.USAGE-LIMIT-METRIC-ALLREADY-EXISTS");
case ResponseErrorCode.DescriptionTemplateTypeCodeExists: case ResponseErrorCode.DescriptionTemplateTypeCodeExists:
return language.instant("GENERAL.BACKEND-ERRORS.DESCRIPTION-TEMPLATE-TYPE-CODE-EXISTS"); return language.instant("GENERAL.BACKEND-ERRORS.DESCRIPTION-TEMPLATE-TYPE-CODE-EXISTS");
case ResponseErrorCode.descriptionTemplateTypeImportNotFound:
return language.instant("GENERAL.BACKEND-ERRORS.DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND");
default: default:
return language.instant("GENERAL.SNACK-BAR.NOT-FOUND"); return language.instant("GENERAL.SNACK-BAR.NOT-FOUND");
} }

View File

@ -302,9 +302,7 @@ export class DescriptionTemplateListingComponent extends BaseListingComponent<De
this.uiNotificationService.snackBarNotification(this.language.instant('DESCRIPTION-TEMPLATE-LISTING.MESSAGES.TEMPLATE-UPLOAD-SUCCESS'), SnackBarNotificationLevel.Success); this.uiNotificationService.snackBarNotification(this.language.instant('DESCRIPTION-TEMPLATE-LISTING.MESSAGES.TEMPLATE-UPLOAD-SUCCESS'), SnackBarNotificationLevel.Success);
this.refresh(); this.refresh();
}, },
error => { error => this.httpErrorHandlingService.handleBackedRequestError(error));
this.uiNotificationService.snackBarNotification(error.error.error, SnackBarNotificationLevel.Error);
});
} }
}); });
} }

View File

@ -82,7 +82,8 @@
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template", "MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator.", "USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator.",
"USAGE-LIMIT-METRIC-ALLREADY-EXISTS": "This usage limit metric is already defined in this tenant. Change metric or select other tenant.", "USAGE-LIMIT-METRIC-ALLREADY-EXISTS": "This usage limit metric is already defined in this tenant. Change metric or select other tenant.",
"DESCRIPTION-TEMPLATE-TYPE-CODE-EXISTS": "The description template type code you provided already exists. Please choose a different code." "DESCRIPTION-TEMPLATE-TYPE-CODE-EXISTS": "The description template type code you provided already exists. Please choose a different code.",
"DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND": "Description template type {{descriptionTemplateTypeLabel}} not found."
}, },
"FORM-VALIDATION-DISPLAY-DIALOG": { "FORM-VALIDATION-DISPLAY-DIALOG": {
"WARNING": "Warning!", "WARNING": "Warning!",

View File

@ -19,6 +19,8 @@ export class HttpErrorHandlingService {
if(errorResponse.error && ResponseErrorCodeHelper.isBackendError(errorResponse.error?.code)){ if(errorResponse.error && ResponseErrorCodeHelper.isBackendError(errorResponse.error?.code)){
if (errorResponse.error.code === ResponseErrorCode.UsageLimitException && errorResponse.error.error){ if (errorResponse.error.code === ResponseErrorCode.UsageLimitException && errorResponse.error.error){
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.BACKEND-ERRORS.USAGE-LIMIT-EXCEPTION', { 'usageLimitLabel': errorResponse.error.error }), SnackBarNotificationLevel.Error); this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.BACKEND-ERRORS.USAGE-LIMIT-EXCEPTION', { 'usageLimitLabel': errorResponse.error.error }), SnackBarNotificationLevel.Error);
} if (errorResponse.error.code === ResponseErrorCode.descriptionTemplateTypeImportNotFound){
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.BACKEND-ERRORS.DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND', { 'descriptionTemplateTypeLabel': errorResponse.error.error }), SnackBarNotificationLevel.Error);
} else { } else {
this.uiNotificationService.snackBarNotification(ResponseErrorCodeHelper.getErrorMessageByBackendStatusCode(errorResponse.error.code, this.language), SnackBarNotificationLevel.Error); this.uiNotificationService.snackBarNotification(ResponseErrorCodeHelper.getErrorMessageByBackendStatusCode(errorResponse.error.code, this.language), SnackBarNotificationLevel.Error);
} }