export reference type name and add ui error

This commit is contained in:
CITE\amentis 2024-07-25 17:55:37 +03:00
parent 36885d5225
commit 129dd61a2c
7 changed files with 42 additions and 7 deletions

View File

@ -17,6 +17,9 @@ public class ReferenceTypeDataImportExport extends BaseFieldDataImportExport {
@XmlElement(name = "referenceTypeId") @XmlElement(name = "referenceTypeId")
private UUID referenceTypeId; private UUID referenceTypeId;
@XmlElement(name = "referenceTypeName")
private String referenceTypeName;
@XmlElement(name = "referenceTypeCode") @XmlElement(name = "referenceTypeCode")
private String referenceTypeCode; private String referenceTypeCode;
@ -43,4 +46,12 @@ public class ReferenceTypeDataImportExport extends BaseFieldDataImportExport {
public void setReferenceTypeCode(String referenceTypeCode) { public void setReferenceTypeCode(String referenceTypeCode) {
this.referenceTypeCode = referenceTypeCode; this.referenceTypeCode = referenceTypeCode;
} }
public String getReferenceTypeName() {
return referenceTypeName;
}
public void setReferenceTypeName(String referenceTypeName) {
this.referenceTypeName = referenceTypeName;
}
} }

View File

@ -428,4 +428,14 @@ public class ErrorThesaurusProperties {
public void setDescriptionTemplateTypeImportNotFound(ErrorDescription descriptionTemplateTypeImportNotFound) { public void setDescriptionTemplateTypeImportNotFound(ErrorDescription descriptionTemplateTypeImportNotFound) {
this.descriptionTemplateTypeImportNotFound = descriptionTemplateTypeImportNotFound; this.descriptionTemplateTypeImportNotFound = descriptionTemplateTypeImportNotFound;
} }
private ErrorDescription referenceTypeImportNotFound;
public ErrorDescription getReferenceTypeImportNotFound() {
return referenceTypeImportNotFound;
}
public void setReferenceTypeImportNotFound(ErrorDescription referenceTypeImportNotFound) {
this.referenceTypeImportNotFound = referenceTypeImportNotFound;
}
} }

View File

@ -3,6 +3,7 @@ package org.opencdmp.service.fielddatahelper;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.exception.MyValidationException;
import gr.cite.tools.fieldset.BaseFieldSet; import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.validation.Validator; import gr.cite.tools.validation.Validator;
@ -13,6 +14,7 @@ import org.opencdmp.commons.types.descriptiontemplate.fielddata.ReferenceTypeDat
import org.opencdmp.commons.types.descriptiontemplate.importexport.fielddata.ReferenceTypeDataImportExport; import org.opencdmp.commons.types.descriptiontemplate.importexport.fielddata.ReferenceTypeDataImportExport;
import org.opencdmp.convention.ConventionService; import org.opencdmp.convention.ConventionService;
import org.opencdmp.data.ReferenceTypeEntity; import org.opencdmp.data.ReferenceTypeEntity;
import org.opencdmp.errorcode.ErrorThesaurusProperties;
import org.opencdmp.model.builder.commonmodels.descriptiontemplate.fielddata.ReferenceTypeDataCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.descriptiontemplate.fielddata.ReferenceTypeDataCommonModelBuilder;
import org.opencdmp.model.builder.descriptiontemplate.fielddata.ReferenceTypeDataBuilder; import org.opencdmp.model.builder.descriptiontemplate.fielddata.ReferenceTypeDataBuilder;
import org.opencdmp.model.descriptiontemplate.fielddata.ReferenceTypeData; import org.opencdmp.model.descriptiontemplate.fielddata.ReferenceTypeData;
@ -33,13 +35,15 @@ public class ReferenceTypeFieldDataHelperService extends BaseFieldDataHelperServ
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final ConventionService conventionService; private final ConventionService conventionService;
private final MessageSource messageSource; private final MessageSource messageSource;
private final ErrorThesaurusProperties errors;
private final ValidatorFactory validatorFactory; private final ValidatorFactory validatorFactory;
public ReferenceTypeFieldDataHelperService(BuilderFactory builderFactory, QueryFactory queryFactory, ConventionService conventionService, MessageSource messageSource, ValidatorFactory validatorFactory) { public ReferenceTypeFieldDataHelperService(BuilderFactory builderFactory, QueryFactory queryFactory, ConventionService conventionService, MessageSource messageSource, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory) {
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.conventionService = conventionService; this.conventionService = conventionService;
this.messageSource = messageSource; this.messageSource = messageSource;
this.errors = errors;
this.validatorFactory = validatorFactory; this.validatorFactory = validatorFactory;
} }
@ -118,7 +122,7 @@ public class ReferenceTypeFieldDataHelperService extends BaseFieldDataHelperServ
ReferenceTypeEntity referenceTypeEntity = data.getReferenceTypeId() != null ? this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(data.getReferenceTypeId()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._id)) : null; ReferenceTypeEntity referenceTypeEntity = data.getReferenceTypeId() != null ? this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(data.getReferenceTypeId()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._id)) : null;
if (referenceTypeEntity == null){ if (referenceTypeEntity == null){
if (!this.conventionService.isNullOrEmpty(data.getReferenceTypeCode())) referenceTypeEntity = this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().codes(data.getReferenceTypeCode()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._id)); if (!this.conventionService.isNullOrEmpty(data.getReferenceTypeCode())) referenceTypeEntity = this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().codes(data.getReferenceTypeCode()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._id));
if (referenceTypeEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getReferenceTypeId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (referenceTypeEntity == null) throw new MyValidationException(this.errors.getReferenceTypeImportNotFound().getCode(), !this.conventionService.isNullOrEmpty(data.getReferenceTypeCode()) ? data.getReferenceTypeCode() : data.getReferenceTypeName());
} }
persist.setMultipleSelect(data.getMultipleSelect()); persist.setMultipleSelect(data.getMultipleSelect());
persist.setReferenceTypeId(referenceTypeEntity.getId()); persist.setReferenceTypeId(referenceTypeEntity.getId());
@ -130,7 +134,7 @@ public class ReferenceTypeFieldDataHelperService extends BaseFieldDataHelperServ
ReferenceTypeEntity referenceTypeEntity = data.getReferenceType() != null && data.getReferenceType().getId() != null ? this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(data.getReferenceType().getId()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._id)) : null; ReferenceTypeEntity referenceTypeEntity = data.getReferenceType() != null && data.getReferenceType().getId() != null ? this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(data.getReferenceType().getId()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._id)) : null;
if (referenceTypeEntity == null){ if (referenceTypeEntity == null){
if (!this.conventionService.isNullOrEmpty(data.getReferenceType().getCode())) referenceTypeEntity = this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().codes(data.getReferenceType().getCode()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._id)); if (!this.conventionService.isNullOrEmpty(data.getReferenceType().getCode())) referenceTypeEntity = this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().codes(data.getReferenceType().getCode()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._id));
if (referenceTypeEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getReferenceType().getId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (referenceTypeEntity == null) throw new MyValidationException(this.errors.getReferenceTypeImportNotFound().getCode(), data.getReferenceType() != null ? data.getReferenceType().getCode() : this.errors.getReferenceTypeImportNotFound().getMessage());
} }
persist.setMultipleSelect(data.getMultipleSelect()); persist.setMultipleSelect(data.getMultipleSelect());
persist.setReferenceTypeId(referenceTypeEntity.getId()); persist.setReferenceTypeId(referenceTypeEntity.getId());
@ -139,11 +143,12 @@ public class ReferenceTypeFieldDataHelperService extends BaseFieldDataHelperServ
@Override @Override
protected ReferenceTypeDataImportExport dataToImportExportXmlInternal(ReferenceTypeDataEntity data, ReferenceTypeDataImportExport xml) { protected ReferenceTypeDataImportExport dataToImportExportXmlInternal(ReferenceTypeDataEntity data, ReferenceTypeDataImportExport xml) {
ReferenceTypeEntity referenceTypeEntity = this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(data.getReferenceTypeId()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._code)); ReferenceTypeEntity referenceTypeEntity = this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().ids(data.getReferenceTypeId()).disableTracking().firstAs(new BaseFieldSet().ensure(ReferenceType._code).ensure(ReferenceType._name));
if (referenceTypeEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getReferenceTypeId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (referenceTypeEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{data.getReferenceTypeId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
xml.setMultipleSelect(data.getMultipleSelect()); xml.setMultipleSelect(data.getMultipleSelect());
xml.setReferenceTypeCode(referenceTypeEntity.getCode()); xml.setReferenceTypeCode(referenceTypeEntity.getCode());
xml.setReferenceTypeName(referenceTypeEntity.getName());
xml.setReferenceTypeId(data.getReferenceTypeId()); xml.setReferenceTypeId(data.getReferenceTypeId());
return xml; return xml;
} }

View File

@ -134,3 +134,6 @@ error-thesaurus:
descriptionTemplateTypeImportNotFound: descriptionTemplateTypeImportNotFound:
code: 148 code: 148
message: Description template type not found message: Description template type not found
referenceTypeImportNotFound:
code: 149
message: Reference type not found

View File

@ -44,6 +44,7 @@ export enum ResponseErrorCode {
UsageLimitMetricAlreadyExists = 146, UsageLimitMetricAlreadyExists = 146,
DescriptionTemplateTypeCodeExists = 147, DescriptionTemplateTypeCodeExists = 147,
descriptionTemplateTypeImportNotFound = 148, descriptionTemplateTypeImportNotFound = 148,
referenceTypeImportNotFound = 149,
// Notification & Annotation Errors // Notification & Annotation Errors
InvalidApiKey = 200, InvalidApiKey = 200,
@ -166,6 +167,8 @@ export class ResponseErrorCodeHelper {
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: case ResponseErrorCode.descriptionTemplateTypeImportNotFound:
return language.instant("GENERAL.BACKEND-ERRORS.DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND"); return language.instant("GENERAL.BACKEND-ERRORS.DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND");
case ResponseErrorCode.referenceTypeImportNotFound:
return language.instant("GENERAL.BACKEND-ERRORS.REFERENCE-TYPE-IMPORT-NOT-FOUND");
default: default:
return language.instant("GENERAL.SNACK-BAR.NOT-FOUND"); return language.instant("GENERAL.SNACK-BAR.NOT-FOUND");
} }

View File

@ -83,7 +83,8 @@
"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." "DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND": "Description template type {{descriptionTemplateTypeLabel}} not found.",
"REFERENCE-TYPE-IMPORT-NOT-FOUND": "Reference type {{referenceTypeCode}} not found."
}, },
"FORM-VALIDATION-DISPLAY-DIALOG": { "FORM-VALIDATION-DISPLAY-DIALOG": {
"WARNING": "Warning!", "WARNING": "Warning!",

View File

@ -21,6 +21,8 @@ export class HttpErrorHandlingService {
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){ } 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); this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.BACKEND-ERRORS.DESCRIPTION-TEMPLATE-TYPE-IMPORT-NOT-FOUND', { 'descriptionTemplateTypeLabel': errorResponse.error.error }), SnackBarNotificationLevel.Error);
} if (errorResponse.error.code === ResponseErrorCode.referenceTypeImportNotFound){
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.BACKEND-ERRORS.REFERENCE-TYPE-IMPORT-NOT-FOUND', { 'referenceTypeCode': 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);
} }