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) {
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.setDescription(importXml.getDescription());
persist.setLanguage(importXml.getLanguage());
persist.setType(this.xmlDescriptionTemplateTypeToPersist(importXml.getDescriptionTemplateType()));
persist.setType(this.xmlDescriptionTemplateTypeToPersist(importXml.getDescriptionTemplateType(), label));
persist.setDefinition(this.xmlDefinitionToPersist(importXml));
this.validatorFactory.validator(DescriptionTemplatePersist.DescriptionTemplatePersistValidator.class).validateForce(persist);
return this.persist(persist, groupId, fields);
@ -750,7 +750,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
persist.setDescription(importXml.getDescription());
persist.setLanguage(importXml.getLanguage());
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()));
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;
DescriptionTemplateTypeQuery query = null;
if (importXml.getId() != null) {
// search by id
query = this.queryFactory.query(DescriptionTemplateTypeQuery.class).ids(importXml.getId());
if (query != null && query.count() > 0 ) {
return query.firstAs(new BaseFieldSet().ensure(DescriptionTemplate._id)).getId();
DescriptionTemplateTypeEntity entity = this.queryFactory.query(DescriptionTemplateTypeQuery.class).ids(importXml.getId()).firstAs(new BaseFieldSet().ensure(DescriptionTemplate._id));
if (entity != null ) {
return entity.getId();
} else {
if (!this.conventionService.isNullOrEmpty(importXml.getCode())){
// search by code
query = this.queryFactory.query(DescriptionTemplateTypeQuery.class).codes(importXml.getCode());
if (query != null && query.count() > 0) {
return query.firstAs(new BaseFieldSet().ensure(DescriptionTemplate._id)).getId();
entity = this.queryFactory.query(DescriptionTemplateTypeQuery.class).codes(importXml.getCode()).firstAs(new BaseFieldSet().ensure(DescriptionTemplate._id));
if (entity != null) {
return entity.getId();
}
}
}
}
return null;
throw new MyValidationException(this.errors.getDescriptionTemplateTypeImportNotFound().getCode(), !this.conventionService.isNullOrEmpty(importXml.getCode()) ? importXml.getCode() : importXml.getName());
}
@Override

View File

@ -131,3 +131,6 @@ error-thesaurus:
descriptionTemplateTypeCodeExists:
code: 147
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,
UsageLimitMetricAlreadyExists = 146,
DescriptionTemplateTypeCodeExists = 147,
descriptionTemplateTypeImportNotFound = 148,
// Notification & Annotation Errors
InvalidApiKey = 200,
@ -163,6 +164,8 @@ export class ResponseErrorCodeHelper {
return language.instant("GENERAL.BACKEND-ERRORS.USAGE-LIMIT-METRIC-ALLREADY-EXISTS");
case ResponseErrorCode.DescriptionTemplateTypeCodeExists:
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:
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.refresh();
},
error => {
this.uiNotificationService.snackBarNotification(error.error.error, SnackBarNotificationLevel.Error);
});
error => this.httpErrorHandlingService.handleBackedRequestError(error));
}
});
}

View File

@ -82,7 +82,8 @@
"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-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": {
"WARNING": "Warning!",

View File

@ -19,6 +19,8 @@ export class HttpErrorHandlingService {
if(errorResponse.error && ResponseErrorCodeHelper.isBackendError(errorResponse.error?.code)){
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);
} 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 {
this.uiNotificationService.snackBarNotification(ResponseErrorCodeHelper.getErrorMessageByBackendStatusCode(errorResponse.error.code, this.language), SnackBarNotificationLevel.Error);
}