use of de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class SampleListEntryDtoResultTransformer method transformTuple.
@Override
public Object transformTuple(Object[] objects, String[] strings) {
boolean referred = objects[5] != null;
String labName = (String) objects[11];
String labUuid = (String) objects[12];
FacilityReferenceDto lab = new FacilityReferenceDto(labUuid, FacilityHelper.buildFacilityString(labUuid, labName), null);
AdditionalTestingStatus additionalTestingStatus = Boolean.TRUE.equals(objects[16]) ? AdditionalTestingStatus.PERFORMED : (Boolean.TRUE.equals(objects[15]) ? AdditionalTestingStatus.REQUESTED : AdditionalTestingStatus.NOT_REQUESTED);
return new SampleListEntryDto((String) objects[0], (SampleMaterial) objects[1], (PathogenTestResultType) objects[2], (SpecimenCondition) objects[3], (SamplePurpose) objects[4], referred, (boolean) objects[6], (Date) objects[7], (boolean) objects[8], (Date) objects[9], (Date) objects[10], lab, (SamplingReason) objects[13], (String) objects[14], additionalTestingStatus, (long) objects[17]);
}
use of de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class PreviousHospitalizationsField method updateColumns.
@Override
protected void updateColumns() {
Table table = getTable();
table.addGeneratedColumn(PERIOD, new Table.ColumnGenerator() {
@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
PreviousHospitalizationDto prevHospitalization = (PreviousHospitalizationDto) itemId;
if (prevHospitalization.getAdmissionDate() == null && prevHospitalization.getDischargeDate() == null) {
return I18nProperties.getString(Strings.notSpecified);
} else {
StringBuilder periodBuilder = new StringBuilder();
periodBuilder.append(prevHospitalization.getAdmissionDate() != null ? DateFormatHelper.formatDate(prevHospitalization.getAdmissionDate()) : "?");
periodBuilder.append(" - ");
periodBuilder.append(prevHospitalization.getDischargeDate() != null ? DateFormatHelper.formatDate(prevHospitalization.getDischargeDate()) : "?");
return periodBuilder.toString();
}
}
});
table.addGeneratedColumn(COMMUNITY, (Table.ColumnGenerator) (source, itemId, columnId) -> {
PreviousHospitalizationDto prevHospitalization = (PreviousHospitalizationDto) itemId;
return prevHospitalization.getCommunity();
});
table.addGeneratedColumn(DISTRICT, (Table.ColumnGenerator) (source, itemId, columnId) -> {
PreviousHospitalizationDto prevHospitalization = (PreviousHospitalizationDto) itemId;
DistrictReferenceDto district = prevHospitalization.getDistrict();
return district != null ? district.getCaption() : I18nProperties.getCaption(Captions.unknown);
});
table.addGeneratedColumn(PreviousHospitalizationDto.HEALTH_FACILITY, (Table.ColumnGenerator) (source, itemId, columnId) -> {
PreviousHospitalizationDto prevHospitalization = (PreviousHospitalizationDto) itemId;
FacilityReferenceDto healthFacility = prevHospitalization.getHealthFacility();
return healthFacility != null ? healthFacility.getCaption() : I18nProperties.getCaption(Captions.unknown);
});
table.setVisibleColumns(EDIT_COLUMN_ID, PERIOD, PreviousHospitalizationDto.HEALTH_FACILITY, COMMUNITY, DISTRICT, PreviousHospitalizationDto.DESCRIPTION, PreviousHospitalizationDto.ISOLATED);
table.setColumnExpandRatio(EDIT_COLUMN_ID, 0);
table.setColumnExpandRatio(PERIOD, 0);
table.setColumnExpandRatio(PreviousHospitalizationDto.HEALTH_FACILITY, 0);
table.setColumnExpandRatio(COMMUNITY, 0);
table.setColumnExpandRatio(DISTRICT, 0);
table.setColumnExpandRatio(PreviousHospitalizationDto.DESCRIPTION, 0);
table.setColumnExpandRatio(PreviousHospitalizationDto.ISOLATED, 0);
for (Object columnId : table.getVisibleColumns()) {
if (columnId.equals(EDIT_COLUMN_ID)) {
table.setColumnHeader(columnId, " ");
} else {
table.setColumnHeader(columnId, I18nProperties.getPrefixCaption(PreviousHospitalizationDto.I18N_PREFIX, (String) columnId));
}
}
}
use of de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class EventParticipantImporter method insertColumnEntryIntoData.
/**
* Inserts the entry of a single cell into the eventparticipant or its person.
*/
private void insertColumnEntryIntoData(EventParticipantDto eventParticipant, PersonDto person, String entry, String[] entryHeaderPath) throws InvalidColumnException, ImportErrorException {
Object currentElement = eventParticipant;
for (int i = 0; i < entryHeaderPath.length; i++) {
String headerPathElementName = entryHeaderPath[i];
try {
if (i != entryHeaderPath.length - 1) {
currentElement = new PropertyDescriptor(headerPathElementName, currentElement.getClass()).getReadMethod().invoke(currentElement);
// Set the current element to the created person
if (currentElement instanceof PersonReferenceDto) {
currentElement = person;
}
} else if (EventParticipantExportDto.BIRTH_DATE.equals(headerPathElementName)) {
BirthDateDto birthDateDto = PersonHelper.parseBirthdate(entry, currentUser.getLanguage());
if (birthDateDto != null) {
person.setBirthdateDD(birthDateDto.getDateOfBirthDD());
person.setBirthdateMM(birthDateDto.getDateOfBirthMM());
person.setBirthdateYYYY(birthDateDto.getDateOfBirthYYYY());
}
} else {
PropertyDescriptor pd = new PropertyDescriptor(headerPathElementName, currentElement.getClass());
Class<?> propertyType = pd.getPropertyType();
// according to the types of the eventparticipant or person fields
if (executeDefaultInvoke(pd, currentElement, entry, entryHeaderPath)) {
continue;
} else if (propertyType.isAssignableFrom(DistrictReferenceDto.class)) {
List<DistrictReferenceDto> district = FacadeProvider.getDistrictFacade().getByName(entry, ImporterPersonHelper.getRegionBasedOnDistrict(pd.getName(), null, person, currentElement), false);
if (district.isEmpty()) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importEntryDoesNotExistDbOrRegion, entry, buildEntityProperty(entryHeaderPath)));
} else if (district.size() > 1) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importDistrictNotUnique, entry, buildEntityProperty(entryHeaderPath)));
} else {
pd.getWriteMethod().invoke(currentElement, district.get(0));
}
} else if (propertyType.isAssignableFrom(CommunityReferenceDto.class)) {
List<CommunityReferenceDto> community = FacadeProvider.getCommunityFacade().getByName(entry, ImporterPersonHelper.getPersonDistrict(pd.getName(), person), false);
if (community.isEmpty()) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importEntryDoesNotExistDbOrDistrict, entry, buildEntityProperty(entryHeaderPath)));
} else if (community.size() > 1) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importCommunityNotUnique, entry, buildEntityProperty(entryHeaderPath)));
} else {
pd.getWriteMethod().invoke(currentElement, community.get(0));
}
} else if (propertyType.isAssignableFrom(FacilityReferenceDto.class)) {
DataHelper.Pair<DistrictReferenceDto, CommunityReferenceDto> infrastructureData = ImporterPersonHelper.getPersonDistrictAndCommunity(pd.getName(), person);
List<FacilityReferenceDto> facility = FacadeProvider.getFacilityFacade().getByNameAndType(entry, infrastructureData.getElement0(), infrastructureData.getElement1(), getTypeOfFacility(pd.getName(), currentElement), false);
if (facility.isEmpty()) {
if (infrastructureData.getElement1() != null) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importEntryDoesNotExistDbOrCommunity, entry, buildEntityProperty(entryHeaderPath)));
} else {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importEntryDoesNotExistDbOrDistrict, entry, buildEntityProperty(entryHeaderPath)));
}
} else if (facility.size() > 1 && infrastructureData.getElement1() == null) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importFacilityNotUniqueInDistrict, entry, buildEntityProperty(entryHeaderPath)));
} else if (facility.size() > 1 && infrastructureData.getElement1() != null) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importFacilityNotUniqueInCommunity, entry, buildEntityProperty(entryHeaderPath)));
} else {
pd.getWriteMethod().invoke(currentElement, facility.get(0));
}
} else {
throw new UnsupportedOperationException(I18nProperties.getValidationError(Validations.importPropertyTypeNotAllowed, propertyType.getName()));
}
}
} catch (IntrospectionException e) {
throw new InvalidColumnException(buildEntityProperty(entryHeaderPath));
} catch (InvocationTargetException | IllegalAccessException e) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importErrorInColumn, buildEntityProperty(entryHeaderPath)));
} catch (IllegalArgumentException e) {
throw new ImportErrorException(entry, buildEntityProperty(entryHeaderPath));
} catch (ImportErrorException e) {
throw e;
} catch (Exception e) {
LOGGER.error("Unexpected error when trying to import an eventparticipant: " + e.getMessage(), e);
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importCasesUnexpectedError));
}
}
ImportLineResultDto<EventParticipantDto> constraintErrors = validateConstraints(eventParticipant);
if (constraintErrors.isError()) {
throw new ImportErrorException(constraintErrors.getMessage());
}
}
use of de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class HospitalizationForm method addFields.
@SuppressWarnings("deprecation")
@Override
protected void addFields() {
if (caze == null || viewMode == null) {
return;
}
Label hospitalizationHeadingLabel = new Label(I18nProperties.getString(Strings.headingHospitalization));
hospitalizationHeadingLabel.addStyleName(H3);
getContent().addComponent(hospitalizationHeadingLabel, HOSPITALIZATION_HEADING_LOC);
Label previousHospitalizationsHeadingLabel = new Label(I18nProperties.getString(Strings.headingPreviousHospitalizations));
previousHospitalizationsHeadingLabel.addStyleName(H3);
getContent().addComponent(previousHospitalizationsHeadingLabel, PREVIOUS_HOSPITALIZATIONS_HEADING_LOC);
TextField facilityField = addCustomField(HEALTH_FACILITY, FacilityReferenceDto.class, TextField.class);
FacilityReferenceDto healthFacility = caze.getHealthFacility();
final boolean noneFacility = healthFacility == null || healthFacility.getUuid().equalsIgnoreCase(FacilityDto.NONE_FACILITY_UUID);
facilityField.setValue(noneFacility || !FacilityType.HOSPITAL.equals(caze.getFacilityType()) ? null : healthFacility.toString());
facilityField.setReadOnly(true);
final NullableOptionGroup admittedToHealthFacilityField = addField(HospitalizationDto.ADMITTED_TO_HEALTH_FACILITY, NullableOptionGroup.class);
final DateField admissionDateField = addField(HospitalizationDto.ADMISSION_DATE, DateField.class);
final DateField dischargeDateField = addDateField(HospitalizationDto.DISCHARGE_DATE, DateField.class, 7);
intensiveCareUnit = addField(HospitalizationDto.INTENSIVE_CARE_UNIT, NullableOptionGroup.class);
intensiveCareUnitStart = addField(HospitalizationDto.INTENSIVE_CARE_UNIT_START, DateField.class);
intensiveCareUnitStart.setVisible(false);
intensiveCareUnitEnd = addField(HospitalizationDto.INTENSIVE_CARE_UNIT_END, DateField.class);
intensiveCareUnitEnd.setVisible(false);
FieldHelper.setVisibleWhen(intensiveCareUnit, Arrays.asList(intensiveCareUnitStart, intensiveCareUnitEnd), Arrays.asList(YesNoUnknown.YES), true);
final Field isolationDateField = addField(HospitalizationDto.ISOLATION_DATE);
final TextArea descriptionField = addField(HospitalizationDto.DESCRIPTION, TextArea.class);
descriptionField.setRows(4);
final NullableOptionGroup isolatedField = addField(HospitalizationDto.ISOLATED, NullableOptionGroup.class);
final NullableOptionGroup leftAgainstAdviceField = addField(HospitalizationDto.LEFT_AGAINST_ADVICE, NullableOptionGroup.class);
final ComboBox hospitalizationReason = addField(HospitalizationDto.HOSPITALIZATION_REASON);
final TextField otherHospitalizationReason = addField(HospitalizationDto.OTHER_HOSPITALIZATION_REASON, TextField.class);
NullableOptionGroup hospitalizedPreviouslyField = addField(HospitalizationDto.HOSPITALIZED_PREVIOUSLY, NullableOptionGroup.class);
CssStyles.style(hospitalizedPreviouslyField, CssStyles.ERROR_COLOR_PRIMARY);
PreviousHospitalizationsField previousHospitalizationsField = addField(HospitalizationDto.PREVIOUS_HOSPITALIZATIONS, PreviousHospitalizationsField.class);
FieldHelper.setEnabledWhen(admittedToHealthFacilityField, Arrays.asList(YesNoUnknown.YES, YesNoUnknown.NO, YesNoUnknown.UNKNOWN), Arrays.asList(facilityField, admissionDateField, dischargeDateField, intensiveCareUnit, intensiveCareUnitStart, intensiveCareUnitEnd, isolationDateField, descriptionField, isolatedField, leftAgainstAdviceField, hospitalizationReason, otherHospitalizationReason), false);
initializeVisibilitiesAndAllowedVisibilities();
initializeAccessAndAllowedAccesses();
if (isVisibleAllowed(HospitalizationDto.ISOLATION_DATE)) {
FieldHelper.setVisibleWhen(getFieldGroup(), HospitalizationDto.ISOLATION_DATE, HospitalizationDto.ISOLATED, Arrays.asList(YesNoUnknown.YES), true);
}
if (isVisibleAllowed(HospitalizationDto.PREVIOUS_HOSPITALIZATIONS)) {
FieldHelper.setVisibleWhen(getFieldGroup(), HospitalizationDto.PREVIOUS_HOSPITALIZATIONS, HospitalizationDto.HOSPITALIZED_PREVIOUSLY, Arrays.asList(YesNoUnknown.YES), true);
}
FieldHelper.setVisibleWhen(getFieldGroup(), HospitalizationDto.OTHER_HOSPITALIZATION_REASON, HospitalizationDto.HOSPITALIZATION_REASON, Collections.singletonList(HospitalizationReasonType.OTHER), true);
// Validations
// Add a visual-only validator to check if symptomonsetdate<admissiondate, as saving should be possible either way
admissionDateField.addValueChangeListener(event -> {
if (caze.getSymptoms().getOnsetDate() != null && DateTimeComparator.getDateOnlyInstance().compare(admissionDateField.getValue(), caze.getSymptoms().getOnsetDate()) < 0) {
admissionDateField.setComponentError(new ErrorMessage() {
@Override
public ErrorLevel getErrorLevel() {
return ErrorLevel.INFO;
}
@Override
public String getFormattedHtmlMessage() {
return I18nProperties.getValidationError(Validations.afterDateSoft, admissionDateField.getCaption(), I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, SymptomsDto.ONSET_DATE));
}
});
} else {
// remove all invalidity-indicators and re-evaluate field
admissionDateField.setComponentError(null);
admissionDateField.markAsDirty();
}
// re-evaluate validity of dischargeDate (necessary because discharge has to be after admission)
dischargeDateField.markAsDirty();
});
admissionDateField.addValidator(new DateComparisonValidator(admissionDateField, dischargeDateField, true, false, I18nProperties.getValidationError(Validations.beforeDate, admissionDateField.getCaption(), dischargeDateField.getCaption())));
dischargeDateField.addValidator(new DateComparisonValidator(dischargeDateField, admissionDateField, false, false, I18nProperties.getValidationError(Validations.afterDate, dischargeDateField.getCaption(), admissionDateField.getCaption())));
// re-evaluate admission date for consistent validation of all fields
dischargeDateField.addValueChangeListener(event -> admissionDateField.markAsDirty());
intensiveCareUnitStart.addValidator(new DateComparisonValidator(intensiveCareUnitStart, admissionDateField, false, false, I18nProperties.getValidationError(Validations.afterDate, intensiveCareUnitStart.getCaption(), admissionDateField.getCaption())));
intensiveCareUnitStart.addValidator(new DateComparisonValidator(intensiveCareUnitStart, intensiveCareUnitEnd, true, false, I18nProperties.getValidationError(Validations.beforeDate, intensiveCareUnitStart.getCaption(), intensiveCareUnitEnd.getCaption())));
intensiveCareUnitEnd.addValidator(new DateComparisonValidator(intensiveCareUnitEnd, intensiveCareUnitStart, false, false, I18nProperties.getValidationError(Validations.afterDate, intensiveCareUnitEnd.getCaption(), intensiveCareUnitStart.getCaption())));
intensiveCareUnitEnd.addValidator(new DateComparisonValidator(intensiveCareUnitEnd, dischargeDateField, true, false, I18nProperties.getValidationError(Validations.beforeDate, intensiveCareUnitEnd.getCaption(), dischargeDateField.getCaption())));
intensiveCareUnitStart.addValueChangeListener(event -> intensiveCareUnitEnd.markAsDirty());
intensiveCareUnitEnd.addValueChangeListener(event -> intensiveCareUnitStart.markAsDirty());
hospitalizedPreviouslyField.addValueChangeListener(e -> updatePrevHospHint(hospitalizedPreviouslyField, previousHospitalizationsField));
previousHospitalizationsField.addValueChangeListener(e -> updatePrevHospHint(hospitalizedPreviouslyField, previousHospitalizationsField));
}
use of de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class CaseImportFacadeEjb method insertColumnEntryIntoData.
/**
* Inserts the entry of a single cell into the case or its person.
*/
private void insertColumnEntryIntoData(CaseDataDto caze, PersonDto person, String entry, String[] entryHeaderPath) throws InvalidColumnException, ImportErrorException {
Object currentElement = caze;
for (int i = 0; i < entryHeaderPath.length; i++) {
String headerPathElementName = entryHeaderPath[i];
Language language = I18nProperties.getUserLanguage();
try {
if (i != entryHeaderPath.length - 1) {
currentElement = new PropertyDescriptor(headerPathElementName, currentElement.getClass()).getReadMethod().invoke(currentElement);
// Set the current element to the created person
if (currentElement instanceof PersonReferenceDto) {
currentElement = person;
}
} else if (CaseExportDto.BIRTH_DATE.equals(headerPathElementName)) {
BirthDateDto birthDateDto = PersonHelper.parseBirthdate(entry, language);
if (birthDateDto != null) {
person.setBirthdateDD(birthDateDto.getDateOfBirthDD());
person.setBirthdateMM(birthDateDto.getDateOfBirthMM());
person.setBirthdateYYYY(birthDateDto.getDateOfBirthYYYY());
}
} else {
PropertyDescriptor pd = new PropertyDescriptor(headerPathElementName, currentElement.getClass());
Class<?> propertyType = pd.getPropertyType();
// according to the types of the case or person fields
if (importFacade.executeDefaultInvoke(pd, currentElement, entry, entryHeaderPath, false)) {
continue;
} else if (propertyType.isAssignableFrom(DistrictReferenceDto.class)) {
List<DistrictReferenceDto> district = districtFacade.getByName(entry, ImportHelper.getRegionBasedOnDistrict(pd.getName(), caze, null, null, person, currentElement), false);
if (district.isEmpty()) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importEntryDoesNotExistDbOrRegion, entry, buildEntityProperty(entryHeaderPath)));
} else if (district.size() > 1) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importDistrictNotUnique, entry, buildEntityProperty(entryHeaderPath)));
} else {
pd.getWriteMethod().invoke(currentElement, district.get(0));
}
} else if (propertyType.isAssignableFrom(CommunityReferenceDto.class)) {
List<CommunityReferenceDto> community = communityFacade.getByName(entry, ImportHelper.getDistrictBasedOnCommunity(pd.getName(), caze, person, currentElement), false);
if (community.isEmpty()) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importEntryDoesNotExistDbOrDistrict, entry, buildEntityProperty(entryHeaderPath)));
} else if (community.size() > 1) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importCommunityNotUnique, entry, buildEntityProperty(entryHeaderPath)));
} else {
pd.getWriteMethod().invoke(currentElement, community.get(0));
}
} else if (propertyType.isAssignableFrom(FacilityReferenceDto.class)) {
DataHelper.Pair<DistrictReferenceDto, CommunityReferenceDto> infrastructureData = ImportHelper.getDistrictAndCommunityBasedOnFacility(pd.getName(), caze, person, currentElement);
if (I18nProperties.getPrefixCaption(FacilityDto.I18N_PREFIX, FacilityDto.OTHER_FACILITY).equals(entry)) {
entry = FacilityDto.OTHER_FACILITY;
}
if (I18nProperties.getPrefixCaption(FacilityDto.I18N_PREFIX, FacilityDto.NO_FACILITY).equals(entry)) {
entry = FacilityDto.NO_FACILITY;
}
List<FacilityReferenceDto> facilities = facilityFacade.getByNameAndType(entry, infrastructureData.getElement0(), infrastructureData.getElement1(), getTypeOfFacility(pd.getName(), currentElement), false);
if (facilities.isEmpty()) {
if (infrastructureData.getElement1() != null) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importEntryDoesNotExistDbOrCommunity, entry, buildEntityProperty(entryHeaderPath)));
} else {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importEntryDoesNotExistDbOrDistrict, entry, buildEntityProperty(entryHeaderPath)));
}
} else if (facilities.size() > 1 && infrastructureData.getElement1() == null) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importFacilityNotUniqueInDistrict, entry, buildEntityProperty(entryHeaderPath)));
} else if (facilities.size() > 1 && infrastructureData.getElement1() != null) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importFacilityNotUniqueInCommunity, entry, buildEntityProperty(entryHeaderPath)));
} else {
pd.getWriteMethod().invoke(currentElement, facilities.get(0));
}
} else if (propertyType.isAssignableFrom(PointOfEntryReferenceDto.class)) {
PointOfEntryReferenceDto pointOfEntryReference;
DistrictReferenceDto pointOfEntryDistrict = CaseLogic.getDistrictWithFallback(caze);
List<PointOfEntryReferenceDto> customPointsOfEntry = pointOfEntryFacade.getByName(entry, pointOfEntryDistrict, false);
if (customPointsOfEntry.isEmpty()) {
final String poeName = entry;
List<PointOfEntryDto> defaultPointOfEntries = pointOfEntryFacade.getByUuids(PointOfEntryDto.CONSTANT_POE_UUIDS);
Optional<PointOfEntryDto> defaultPointOfEntry = defaultPointOfEntries.stream().filter(defaultPoe -> InfrastructureHelper.buildPointOfEntryString(defaultPoe.getUuid(), defaultPoe.getName()).equals(poeName)).findFirst();
if (!defaultPointOfEntry.isPresent()) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importEntryDoesNotExistDbOrDistrict, entry, buildEntityProperty(entryHeaderPath)));
}
pointOfEntryReference = defaultPointOfEntry.get().toReference();
} else if (customPointsOfEntry.size() > 1) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importPointOfEntryNotUniqueInDistrict, entry, buildEntityProperty(entryHeaderPath)));
} else {
pointOfEntryReference = customPointsOfEntry.get(0);
}
pd.getWriteMethod().invoke(currentElement, pointOfEntryReference);
} else {
throw new UnsupportedOperationException(I18nProperties.getValidationError(Validations.importCasesPropertyTypeNotAllowed, propertyType.getName()));
}
}
} catch (IntrospectionException e) {
throw new InvalidColumnException(buildEntityProperty(entryHeaderPath));
} catch (InvocationTargetException | IllegalAccessException e) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importErrorInColumn, buildEntityProperty(entryHeaderPath)));
} catch (IllegalArgumentException | EnumService.InvalidEnumCaptionException e) {
throw new ImportErrorException(entry, buildEntityProperty(entryHeaderPath));
} catch (ParseException e) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importInvalidDate, buildEntityProperty(entryHeaderPath), DateHelper.getAllowedDateFormats(language.getDateFormat())));
} catch (ImportErrorException e) {
throw e;
} catch (Exception e) {
LOGGER.error("Unexpected error when trying to import a case: " + e.getMessage(), e);
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importCasesUnexpectedError));
}
}
}
Aggregations