Skip to content

Commit

Permalink
- FIX: Fixed the catch-all exception handling which didn't store feed…
Browse files Browse the repository at this point in the history
…back to the database.

- FIX: Fixed a bug where institution import from the MCPD would fail if no institution code was available.
- FIX: Added MCPD fields that are also stored elsewhere to the mcpd table.
-
  • Loading branch information
sebastian-raubach committed Sep 2, 2022
1 parent a046fed commit 9d256c0
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 59 deletions.
77 changes: 36 additions & 41 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ protected void reportError(Exception ex)
addImportResult(ImportStatus.GENERIC_IO_ERROR, -1, ex.getMessage());
List<ImportResult> result = getImportResult();

result.add(new ImportResult(ImportStatus.GENERIC_IO_ERROR, -1, ex.getMessage()));
DataImportJobsRecord job = context.selectFrom(DATA_IMPORT_JOBS).where(DATA_IMPORT_JOBS.ID.eq(this.importJobId)).fetchAny();
job.setFeedback(result.toArray(new ImportResult[0]));
job.setStatus(DataImportJobsStatus.failed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,23 +222,7 @@ protected void checkFile()
if (filenameToImage.containsKey(filename))
addImportResult(ImportStatus.GENERIC_DUPLICATE_VALUE, i, "An image filename has been specified more than once: " + filename);
else
{
filenameToImage.put(filename, null);

// TODO: Create this when actually importing
// ViewTableImages image = new ViewTableImages();
// image.setImageId(intId);
// image.setReferenceName(name);
// image.setImageRefTable(reference);
// image.setImagePath(filename);
// image.setImageDescription(description);
// if (!StringUtils.isEmpty(tags)) {
// String[] parsedTags = Arrays.stream(tags.split(",", -1))
// .map(String::trim)
// .toArray(String[]::new);
// image.setTags(parsedTags);
// }
}
}
}
}
Expand Down Expand Up @@ -351,6 +335,8 @@ protected void importFile()
String reference = getCellValue(current, 2);
String filename = getCellValue(current, 3);
String description = getCellValue(current, 4);
if (StringUtils.isEmpty(description))
description = filename;
String tags = getCellValue(current, 5);

Integer intId = null;
Expand Down
22 changes: 20 additions & 2 deletions src/main/java/jhi/germinate/server/util/importer/McpdImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,6 @@ private InstitutionsRecord getOrCreateInstitution(DSLContext context, Institutio
if (changed) {
// If there are changes, store it back
result.store();
institutionCodes.put(result.getCode(), result);
}
}

Expand All @@ -950,7 +949,8 @@ private InstitutionsRecord getOrCreateInstitution(DSLContext context, Institutio
result.store();
}

institutionCodes.put(result.getCode(), result);
if (!StringUtils.isEmpty(result.getCode()))
institutionCodes.put(result.getCode(), result);

return result;
}
Expand Down Expand Up @@ -1015,6 +1015,7 @@ private Germplasm parseMcpd(Row r)
germplasm.mcpd.setAccenumb(getCellValue(r, columnNameToIndex, McpdField.ACCENUMB.name()));
germplasm.mcpd.setAcqdate(getCellValue(r, columnNameToIndex, McpdField.ACQDATE.name()));
germplasm.pedigree.setDefinition(getCellValue(r, columnNameToIndex, McpdField.ANCEST.name()));
germplasm.mcpd.setAncest(getCellValue(r, columnNameToIndex, McpdField.ANCEST.name()));
germplasm.mcpd.setBredcode(getCellValue(r, columnNameToIndex, McpdField.BREDCODE.name()));
germplasm.mcpd.setBredname(getCellValue(r, columnNameToIndex, McpdField.BREDNAME.name()));
germplasm.mcpd.setCollcode(getCellValue(r, columnNameToIndex, McpdField.COLLCODE.name()));
Expand All @@ -1025,14 +1026,22 @@ private Germplasm parseMcpd(Row r)
germplasm.mcpd.setCollnumb(getCellValue(r, columnNameToIndex, McpdField.COLLNUMB.name()));
germplasm.mcpd.setCollsrc(getCellValueInteger(r, columnNameToIndex, McpdField.COLLSRC.name()));
germplasm.location.setCoordinateDatum(getCellValue(r, columnNameToIndex, McpdField.COORDDATUM.name()));
germplasm.mcpd.setCoorddatum(getCellValue(r, columnNameToIndex, McpdField.COORDDATUM.name()));
germplasm.location.setCoordinateUncertainty(getCellValueInteger(r, columnNameToIndex, McpdField.COORDUNCERT.name()));
germplasm.mcpd.setCoorduncert(getCellValueInteger(r, columnNameToIndex, McpdField.COORDUNCERT.name()));
germplasm.taxonomy.setCropname(getCellValue(r, columnNameToIndex, McpdField.CROPNAME.name()));
germplasm.mcpd.setCropname(getCellValue(r, columnNameToIndex, McpdField.CROPNAME.name()));
germplasm.location.setSiteName(getCellValue(r, columnNameToIndex, McpdField.COLLSITE.name()));
germplasm.mcpd.setCollsite(getCellValue(r, columnNameToIndex, McpdField.COLLSITE.name()));
germplasm.location.setLatitude(getCellValueBigDecimal(r, columnNameToIndex, McpdField.DECLATITUDE.name()));
germplasm.mcpd.setDeclatitude(getCellValueBigDecimal(r, columnNameToIndex, McpdField.DECLATITUDE.name()));
germplasm.mcpd.setLatitude(getCellValue(r, columnNameToIndex, McpdField.LATITUDE.name()));
// If there's no decimal, try and parse the DMS
if (germplasm.location.getLatitude() == null && !StringUtils.isEmpty(getCellValue(r, columnNameToIndex, McpdField.LATITUDE.name())))
germplasm.location.setLatitude(getCellValueDMS(r, columnNameToIndex, McpdField.LATITUDE.name()));
germplasm.location.setLongitude(getCellValueBigDecimal(r, columnNameToIndex, McpdField.DECLONGITUDE.name()));
germplasm.mcpd.setDeclongitude(getCellValueBigDecimal(r, columnNameToIndex, McpdField.DECLONGITUDE.name()));
germplasm.mcpd.setLongitude(getCellValue(r, columnNameToIndex, McpdField.LONGITUDE.name()));
// If there's no decimal, try and parse the DMS
if (germplasm.location.getLongitude() == null && !StringUtils.isEmpty(getCellValue(r, columnNameToIndex, McpdField.LONGITUDE.name())))
germplasm.location.setLongitude(getCellValueDMS(r, columnNameToIndex, McpdField.LONGITUDE.name()));
Expand All @@ -1042,6 +1051,7 @@ private Germplasm parseMcpd(Row r)
germplasm.mcpd.setDuplinstname(getCellValue(r, columnNameToIndex, McpdField.DUPLINSTNAME.name()));
germplasm.mcpd.setDuplsite(getCellValue(r, columnNameToIndex, McpdField.DUPLSITE.name()));
germplasm.location.setElevation(getCellValueBigDecimal(r, columnNameToIndex, McpdField.ELEVATION.name()));
germplasm.mcpd.setElevation(getCellValueBigDecimal(r, columnNameToIndex, McpdField.ELEVATION.name()));
String parentName = getCellValue(r, columnNameToIndex, "Entity parent ACCENUMB");
if (!StringUtils.isEmpty(parentName))
{
Expand All @@ -1055,23 +1065,31 @@ private Germplasm parseMcpd(Row r)
germplasm.germinatebase.setEntitytypeId(entityTypeId);
}
germplasm.taxonomy.setGenus(getCellValue(r, columnNameToIndex, McpdField.GENUS.name()));
germplasm.mcpd.setGenus(getCellValue(r, columnNameToIndex, McpdField.GENUS.name()));
germplasm.location.setGeoreferencingMethod(getCellValue(r, columnNameToIndex, McpdField.GEOREFMETH.name()));
germplasm.mcpd.setGeorefmeth(getCellValue(r, columnNameToIndex, McpdField.GEOREFMETH.name()));
germplasm.mcpd.setInstcode(getCellValue(r, columnNameToIndex, McpdField.INSTCODE.name()));
germplasm.mcpd.setMlsstat(getCellValueInteger(r, columnNameToIndex, McpdField.MLSSTAT.name()));
germplasm.country.setCountryCode3(getCellValue(r, columnNameToIndex, McpdField.ORIGCTY.name()));
germplasm.mcpd.setOrigcty(getCellValue(r, columnNameToIndex, McpdField.ORIGCTY.name()));
germplasm.mcpd.setOthernumb(getCellValue(r, columnNameToIndex, McpdField.OTHERNUMB.name()));
germplasm.mcpd.setPuid(getCellValue(r, columnNameToIndex, McpdField.PUID.name()));
germplasm.mcpd.setSampstat(getCellValueInteger(r, columnNameToIndex, McpdField.SAMPSTAT.name()));
germplasm.taxonomy.setSpeciesAuthor(getCellValue(r, columnNameToIndex, McpdField.SPAUTHOR.name()));
germplasm.mcpd.setSpauthor(getCellValue(r, columnNameToIndex, McpdField.SPAUTHOR.name()));
germplasm.taxonomy.setSpecies(getCellValue(r, columnNameToIndex, McpdField.SPECIES.name()));
germplasm.mcpd.setSpecies(getCellValue(r, columnNameToIndex, McpdField.SPECIES.name()));
germplasm.taxonomy.setSubtaxaAuthor(getCellValue(r, columnNameToIndex, McpdField.SUBTAUTHOR.name()));
germplasm.mcpd.setSubtauthor(getCellValue(r, columnNameToIndex, McpdField.SUBTAUTHOR.name()));
germplasm.taxonomy.setSubtaxa(getCellValue(r, columnNameToIndex, McpdField.SUBTAXA.name()));
germplasm.mcpd.setSubtaxa(getCellValue(r, columnNameToIndex, McpdField.SUBTAXA.name()));

if (germplasm.germinatebase.getEntitytypeId() == null) germplasm.germinatebase.setEntitytypeId(1);

germplasm.location.setLocationtypeId(1);

germplasm.remarks = getCellValue(r, columnNameToIndex, McpdField.REMARKS.name());
germplasm.mcpd.setRemarks(getCellValue(r, columnNameToIndex, McpdField.REMARKS.name()));
germplasm.mcpd.setStorage(getCellValue(r, columnNameToIndex, McpdField.STORAGE.name()));

if (!StringUtils.isEmpty(germplasm.mcpd.getInstcode()))
Expand Down

0 comments on commit 9d256c0

Please sign in to comment.