Commit 3eff5fc0 authored by Matija Obreza's avatar Matija Obreza

DOI Export revision: DOI as first column in Excel export, included in meta.xml

parent 7cd80dac
Pipeline #1904 passed with stages
in 5 minutes and 52 seconds
......@@ -29,6 +29,7 @@ import java.util.HashMap;
import java.util.List;
import com.opencsv.CSVWriter;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.common.usermodel.Hyperlink;
import org.apache.poi.ss.usermodel.Cell;
......@@ -73,11 +74,54 @@ public class DownloadServiceImpl implements DownloadService {
public static final Logger LOG = LoggerFactory.getLogger(DownloadServiceImpl.class);
private static final int COL_DOI = 0;
private static final int COL_INSTCODE = 1;
private static final int COL_ACCENUMB = 2;
private static final int COL_COLLNUMB = 3;
private static final int COL_COLLCODE = 4;
private static final int COL_COLLNAME = 5;
private static final int COL_COLLINSTADDR = 6;
private static final int COL_COLLMISSID = 7;
private static final int COL_GENUS = 8;
private static final int COL_SPECIES = 9;
private static final int COL_SPAUTHOR = 10;
private static final int COL_SUBTAXA = 11;
private static final int COL_SUBTAUTHOR = 12;
private static final int COL_CROPNAME = 13;
private static final int COL_ACCENAME = 14;
private static final int COL_ACQDATE = 15;
private static final int COL_ORIGCTY = 16;
private static final int COL_COLLSITE = 17;
private static final int COL_DECLATITUDE = 18;
private static final int COL_DECLONGITUDE = 19;
private static final int COL_COORDUNCERT = 20;
private static final int COL_COORDDATUM = 21;
private static final int COL_GEOREFMETH = 22;
private static final int COL_ELEVATION = 23;
private static final int COL_COLLDATE = 24;
private static final int COL_BREDCODE = 25;
private static final int COL_SAMPSTAT = 27;
private static final int COL_ANCEST = 28;
private static final int COL_COLLSRC = 29;
private static final int COL_DONORCODE = 30;
private static final int COL_DONORNAME = 31;
private static final int COL_DONORNUMB = 32;
private static final int COL_OTHERNUMB = 33;
private static final int COL_DUPLSITE = 34;
private static final int COL_STORAGE = 36;
private static final int COL_MLSSTAT = 37;
private static final int COL_UUID = 38;
private static final int COL_HISTORIC = 39;
private static final int COL_ACCEURL = 40;
private static final int COL_REMARKS = 41;
@Autowired
private GenesysService genesysService;
@Autowired
@Qualifier("genesysLowlevelRepositoryCustomImpl")
@Qualifier("genesysLowlevelRepositoryCustomImpl")
private GenesysLowlevelRepository genesysLowlevelRepository;
@Value("${base.url}")
......@@ -189,59 +233,59 @@ public class DownloadServiceImpl implements DownloadService {
}
}
private void writeMCPDRow(Sheet sheet, Row row, AccessionData accession, AccessionGeo geo, AccessionCollect collect, AccessionBreeding bred,
List<AccessionAlias> names, AccessionExchange exch, List<AccessionRemark> remarks) {
private void writeMCPDRow(Sheet sheet, Row row, AccessionData accession, AccessionGeo geo, AccessionCollect collect, AccessionBreeding bred, List<AccessionAlias> names, AccessionExchange exch,
List<AccessionRemark> remarks) {
// Process and write result
row.createCell(0).setCellValue(accession.getInstitute().getCode());
row.createCell(1).setCellValue(accession.getAccessionName());
row.createCell(COL_INSTCODE).setCellValue(accession.getInstitute().getCode());
row.createCell(COL_ACCENUMB).setCellValue(accession.getAccessionName());
if (collect != null) {
createCell(row, 2, collect.getCollNumb());
createCell(row, 3, collect.getCollCode());
createCell(row, 4, collect.getCollName());
createCell(row, 5, collect.getCollInstAddress());
createCell(row, 6, collect.getCollMissId());
createCell(row, 16, collect.getCollSite());
createCell(row, 23, collect.getCollDate());
createCell(row, COL_COLLNUMB, collect.getCollNumb());
createCell(row, COL_COLLCODE, collect.getCollCode());
createCell(row, COL_COLLNAME, collect.getCollName());
createCell(row, COL_COLLINSTADDR, collect.getCollInstAddress());
createCell(row, COL_COLLMISSID, collect.getCollMissId());
createCell(row, COL_COLLSITE, collect.getCollSite());
createCell(row, COL_COLLDATE, collect.getCollDate());
}
if (bred != null) {
createCell(row, 24, bred.getBreederCode());
createCell(row, 27, bred.getPedigree());
createCell(row, COL_BREDCODE, bred.getBreederCode());
createCell(row, COL_ANCEST, bred.getPedigree());
}
Taxonomy2 taxonomy = accession.getTaxonomy();
if (taxonomy != null) {
createCell(row, 7, taxonomy.getGenus());
createCell(row, 8, taxonomy.getSpecies());
createCell(row, 9, taxonomy.getSpAuthor());
createCell(row, 10, taxonomy.getSubtaxa());
createCell(row, 11, taxonomy.getSubtAuthor());
createCell(row, COL_GENUS, taxonomy.getGenus());
createCell(row, COL_SPECIES, taxonomy.getSpecies());
createCell(row, COL_SPAUTHOR, taxonomy.getSpAuthor());
createCell(row, COL_SUBTAXA, taxonomy.getSubtaxa());
createCell(row, COL_SUBTAUTHOR, taxonomy.getSubtAuthor());
}
createCell(row, 12, accession.getCropName());
createCell(row, 14, accession.getAcquisitionDate());
createCell(row, COL_CROPNAME, accession.getCropName());
createCell(row, COL_ACQDATE, accession.getAcquisitionDate());
Country origin = accession.getCountryOfOrigin();
if (origin != null) {
createCell(row, 15, origin.getCode3());
createCell(row, COL_ORIGCTY, origin.getCode3());
}
if (geo != null) {
createCell(row, 17, geo.getLatitude());
createCell(row, 18, geo.getLongitude());
createCell(row, 19, geo.getUncertainty());
createCell(row, 20, geo.getDatum());
createCell(row, 21, geo.getMethod());
createCell(row, 22, geo.getElevation());
createCell(row, COL_DECLATITUDE, geo.getLatitude());
createCell(row, COL_DECLONGITUDE, geo.getLongitude());
createCell(row, COL_COORDUNCERT, geo.getUncertainty());
createCell(row, COL_COORDDATUM, geo.getDatum());
createCell(row, COL_GEOREFMETH, geo.getMethod());
createCell(row, COL_ELEVATION, geo.getElevation());
}
createCell(row, 26, accession.getSampleStatus());
createCell(row, COL_SAMPSTAT, accession.getSampleStatus());
if (StringUtils.isNotBlank(accession.getAcquisitionSource())) {
Cell c = row.createCell(28);
Cell c = row.createCell(COL_COLLSRC);
try {
c.setCellValue(Integer.parseInt(accession.getAcquisitionSource()));
} catch (NumberFormatException e) {
......@@ -249,9 +293,9 @@ public class DownloadServiceImpl implements DownloadService {
}
}
createCell(row, 33, accession.getDuplSite());
createCell(row, 35, accession.getStorage());
createCell(row, 36, accession.getMlsStatus());
createCell(row, COL_DUPLSITE, accession.getDuplSite());
createCell(row, COL_STORAGE, accession.getStorage());
createCell(row, COL_MLSSTAT, accession.getMlsStatus());
if (names != null && names.size() > 0) {
String acceName = null;
......@@ -273,32 +317,32 @@ public class DownloadServiceImpl implements DownloadService {
}
}
createCell(row, 13, acceName);
createCell(row, 31, donorNumb);
createCell(row, 32, otherNumb);
createCell(row, COL_ACCENAME, acceName);
createCell(row, COL_DONORNUMB, donorNumb);
createCell(row, COL_OTHERNUMB, otherNumb);
}
if (exch != null) {
createCell(row, 29, exch.getDonorInstitute());
createCell(row, 30, exch.getDonorName());
// row.createCell(32).setCellValue(exch.getAccNumbDonor());
createCell(row, COL_DONORCODE, exch.getDonorInstitute());
createCell(row, COL_DONORNAME, exch.getDonorName());
// row.createCell(COL_DONORNUMB).setCellValue(exch.getAccNumbDonor());
}
if (accession.getUuid() != null) {
XSSFHyperlink hypr = (XSSFHyperlink) sheet.getWorkbook().getCreationHelper().createHyperlink(Hyperlink.LINK_URL);
hypr.setAddress("http://purl.org/germplasm/id/" + accession.getUuid());
Cell cell = createCell(row, 37, accession.getUuid().toString());
Cell cell = createCell(row, COL_UUID, accession.getUuid().toString());
cell.setHyperlink(hypr);
}
if (accession.getHistoric()) {
createCell(row, 38, accession.getHistoric());
createCell(row, COL_HISTORIC, accession.getHistoric());
}
if (StringUtils.isNotBlank(accession.getAcceUrl())) {
XSSFHyperlink hypr = (XSSFHyperlink) sheet.getWorkbook().getCreationHelper().createHyperlink(Hyperlink.LINK_URL);
hypr.setAddress(accession.getAcceUrl());
Cell cell = createCell(row, 39, accession.getAcceUrl());
if (cell!=null && hypr!=null) {
Cell cell = createCell(row, COL_ACCEURL, accession.getAcceUrl());
if (cell != null && hypr != null) {
cell.setHyperlink(hypr);
} else {
LOG.warn("Cell or hyper null for ACCEURL id={} acceUrl={}", accession.getId(), accession.getAcceUrl());
......@@ -317,12 +361,12 @@ public class DownloadServiceImpl implements DownloadService {
}
}
createCell(row, 40, r);
createCell(row, COL_REMARKS, r);
}
if (StringUtils.isNotBlank(accession.getDoi())) {
final String doi = accession.getDoi();
createCell(row, 41, doi);
createCell(row, COL_DOI, doi);
}
}
......@@ -410,10 +454,7 @@ public class DownloadServiceImpl implements DownloadService {
String year = (row[0] != null) ? String.valueOf(row[0]) : "";
StringBuilder builder = new StringBuilder();
builder.append(day).append("-").append(month).append("-").append(year)
.append("#").append(institute.getCode())
.append("#").append(institute.getFullName())
.append("#").append(row[4]);
builder.append(day).append("-").append(month).append("-").append(year).append("#").append(institute.getCode()).append("#").append(institute.getFullName()).append("#").append(row[4]);
writer.writeNext(builder.toString().split("#"));
}
......
......@@ -1181,6 +1181,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
osw.write("\t<field index=\"15\" term=\"createdDate\"/>\n");
osw.write("\t<field index=\"16\" term=\"lastModifiedBy\"/>\n");
osw.write("\t<field index=\"17\" term=\"lastModifiedDate\"/>\n");
osw.write("\t<field index=\"18\" term=\"doi\"/>\n");
osw.write("</core>\n");
osw.write("<extension encoding=\"UTF-8\" fieldsTerminatedBy=\",\" linesTerminatedBy=\"\\n\" fieldsEnclosedBy=\"&quot;\" ignoreHeaderLines=\"0\">\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment