Commit 5e11bf65 authored by Jérémy Destin's avatar Jérémy Destin
Browse files

fix: Add collection and panel names in export. Fix bug with focus button. GNP-4309

parent c78a0b80
......@@ -4,6 +4,7 @@ import com.opencsv.CSVWriter;
import fr.inra.urgi.faidare.api.faidare.v1.GnpISGermplasmController;
import fr.inra.urgi.faidare.domain.criteria.FaidareGermplasmPOSTShearchCriteria;
import fr.inra.urgi.faidare.domain.criteria.GermplasmSearchCriteria;
import fr.inra.urgi.faidare.domain.data.germplasm.CollPopVO;
import fr.inra.urgi.faidare.domain.data.germplasm.GermplasmVO;
import fr.inra.urgi.faidare.domain.data.germplasm.PedigreeVO;
import fr.inra.urgi.faidare.domain.data.germplasm.ProgenyVO;
......@@ -19,7 +20,9 @@ import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* @author cpommier, gcornut
......@@ -66,14 +69,32 @@ public class GermplasmServiceImpl implements GermplasmService {
"LotName", "LotSynonym", "CollectionName", "CollectionType", "PanelName", "PanelSize"};
csvWriter.writeNext(header);
while (germplasms.hasNext()) {
List<String> collectionNames = new ArrayList<>();
List<String> panelNames = new ArrayList<>();
GermplasmVO germplasmVO = germplasms.next();
if (germplasmVO.getCollection() != null) {
for (CollPopVO collection : germplasmVO.getCollection()) {
collectionNames.add(collection.getName());
}
}
if (germplasmVO.getPanel() != null) {
for (CollPopVO panel : germplasmVO.getPanel()) {
panelNames.add(panel.getName());
}
}
String[] line = new String[header.length];
line[0] = germplasmVO.getGermplasmPUI();
line[1] = germplasmVO.getAccessionNumber();
line[2] = germplasmVO.getGermplasmName();
line[3] = germplasmVO.getCommonCropName();
line[4] = germplasmVO.getInstituteName();
line[7] = (collectionNames != null) ? String.join(", ", collectionNames) : "";
line[9] = (panelNames != null) ? String.join(", ", panelNames) : "";
csvWriter.writeNext(line);
}
csvWriter.close();
......
......@@ -46,6 +46,10 @@ export class SmallFacetsComponent implements OnInit {
this.checkBoxes.addControl('selectSwitchButton', switchControl);
}
this.displayGermplasmResult$.subscribe(value => {
this.displayGermplasmCurrentState = value;
});
if (this.criteria$) {
this.criteria$.pipe(filter(c => c !== this.localCriteria))
.subscribe(criteria => {
......@@ -62,7 +66,9 @@ export class SmallFacetsComponent implements OnInit {
this.germplasmSearchCriteria$.pipe(filter(c => c !== this.germplasmLocalCriteria))
.subscribe(germplasmCriteria => {
this.germplasmLocalCriteria = germplasmCriteria;
this.getSelectedTerms(germplasmCriteria);
if (this.displayGermplasmCurrentState) {
this.getSelectedTerms(germplasmCriteria);
}
});
}
......@@ -84,10 +90,6 @@ export class SmallFacetsComponent implements OnInit {
}
this.germplasmSearchCriteria$.next(this.germplasmLocalCriteria);
});
this.displayGermplasmResult$.subscribe(value => {
this.displayGermplasmCurrentState = value;
});
}
getSelectedTerms(criteria) {
......
......@@ -65,7 +65,7 @@ export class DataDiscoveryCriteriaUtils {
biologicalStatus: null,
geneticNature: null,
sources: null,
types: null,
types: 'Germplasm',
facetFields: ['holdingInstitute',
'biologicalStatus', 'geneticNature', 'country'],
......
Supports Markdown
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