Skip to content
Permalink
Browse files

Import List CSV

Correction d'un Bug (affichage d'un thésaurus sans traduction)
  • Loading branch information...
miledrousset committed May 15, 2019
1 parent 1f5bb0c commit be3bebb72086d81eec82a1d85cc45940d824855d
Showing with 848 additions and 676 deletions.
  1. +10 −10 faces-config.NavData
  2. +1 −1 pom.xml
  3. +1 −1 src/main/java/mom/trd/opentheso/SelectedBeans/DownloadBean.java
  4. +30 −63 src/main/java/mom/trd/opentheso/SelectedBeans/NewTreeBean.java
  5. +1 −1 src/main/java/mom/trd/opentheso/SelectedBeans/SearchCandidatBean.java
  6. +4 −2 src/main/java/mom/trd/opentheso/SelectedBeans/SelectedTerme.java
  7. +369 −165 src/main/java/mom/trd/opentheso/bdd/helper/ConceptHelper.java
  8. +1 −1 src/main/java/mom/trd/opentheso/bdd/helper/CopyAndPasteHelper.java
  9. +1 −1 src/main/java/mom/trd/opentheso/core/exports/rdf4j/{helper → }/ExportRdf4jHelper.java
  10. +0 −325 src/main/java/mom/trd/opentheso/core/imports/csv/CsvHelper.java
  11. +133 −0 src/main/java/mom/trd/opentheso/core/imports/csv/CsvImportHelper.java
  12. +262 −0 src/main/java/mom/trd/opentheso/core/imports/csv/CsvReadHelper.java
  13. +0 −80 src/main/java/mom/trd/opentheso/core/imports/csv/InsertBDD.java
  14. +1 −1 src/main/java/mom/trd/opentheso/core/imports/helper/ImportSkosHelper.java
  15. +1 −1 src/main/java/mom/trd/opentheso/ws/rest/Rest.java
  16. +1 −1 src/main/java/mom/trd/opentheso/ws/rest/RestRDFHelper.java
  17. +1 −1 src/main/webapp/WEB-INF/web.xml
  18. +2 −2 src/main/webapp/deleteBranchOrphan.xhtml
  19. +6 −6 src/main/webapp/dialogs/conceptFusionValidationDlg.xhtml
  20. +11 −6 src/main/webapp/dialogs/nt/ntListImportDlg.xhtml
  21. +7 −3 src/main/webapp/panelGauche/arbre/arbre.xhtml
  22. +3 −3 src/test/java/csv/ImportCsv.java
  23. +1 −1 src/test/java/json/ExportJsonTest.java
  24. +1 −1 src/test/java/rdf4j/exportConceptTest.java
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scene Scope="Project" version="2">
<Scope Scope="Faces Configuration Only"/>
<Scope Scope="Project">
<Node id="conf.xhtml" x="400" y="150" zoom="true"/>
<Node id="index.xhtml" x="650" y="150" zoom="true"/>
<Node id="gestCandidat.xhtml" x="400" y="300" zoom="true"/>
</Scope>
<Scope Scope="All Faces Configurations"/>
</Scene>
<?xml version="1.0" encoding="UTF-8"?>
<Scene Scope="Project" version="2">
<Scope Scope="Faces Configuration Only"/>
<Scope Scope="Project">
<Node id="index.xhtml" x="650" y="150" zoom="true"/>
<Node id="conf.xhtml" x="400" y="150" zoom="true"/>
<Node id="gestCandidat.xhtml" x="400" y="300" zoom="true"/>
</Scope>
<Scope Scope="All Faces Configurations"/>
</Scene>
@@ -5,7 +5,7 @@
<!-- ici c'est pour la version du WAR, pour la version d'Opentheso, il faut modifier le fichier web.xml-->
<groupId>trd</groupId>
<artifactId>opentheso</artifactId>
<version>4.4.6</version>
<version>4.4.7</version>
<packaging>war</packaging>

<name>opentheso</name>
@@ -28,7 +28,7 @@
import mom.trd.opentheso.core.exports.old.ExportFromBDD_Frantiq;
import mom.trd.opentheso.core.exports.pdf.WritePdf;
import mom.trd.opentheso.core.exports.rdf4j.WriteRdf4j;
import mom.trd.opentheso.core.exports.rdf4j.helper.ExportRdf4jHelper;
import mom.trd.opentheso.core.exports.rdf4j.ExportRdf4jHelper;
import mom.trd.opentheso.core.jsonld.helper.JsonldHelper;
import org.eclipse.rdf4j.rio.RDFFormat;
import org.eclipse.rdf4j.rio.Rio;
@@ -41,10 +41,12 @@
import mom.trd.opentheso.bdd.helper.nodes.NodeRT;
import mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree;
import mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup;
import mom.trd.opentheso.core.imports.csv.CsvHelper;
import mom.trd.opentheso.core.imports.csv.CsvImportHelper;
import mom.trd.opentheso.core.imports.csv.CsvReadHelper;
import mom.trd.opentheso.dragdrop.StructIdBroaderTerm;
import mom.trd.opentheso.dragdrop.TreeChange;
import mom.trd.opentheso.ws.handle.HandleHelper;
import mom.trd.opentheso.ws.rest.theso;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVRecord;
import org.primefaces.PrimeFaces;
@@ -101,7 +103,7 @@
private String iconSort = "ui-icon-sort-16";
private String sortTitle = "tree.sortByNotation";

private ArrayList<CsvHelper.ConceptObject> conceptObjects;
private ArrayList<CsvReadHelper.ConceptObject> conceptObjects;

public NewTreeBean() {
root = (TreeNode) new DefaultTreeNode("Root", null);
@@ -2252,6 +2254,7 @@ public void alignDomainAux(TreeNode mtn, String idGroup) {
}

/*fonction pour importer de multiples NT, une seule colonne sans Id ****/
// deprecated by Miled
public void addMultipleNT() {
InputStream is = null;
ArrayList<String> narrowerTerm = new ArrayList<>();
@@ -2300,68 +2303,27 @@ public void addMultipleNT() {
* #MR en cours de construction
*/
public void addMultipleNT2() {

Term terme = new Term();
TermHelper termHelper = new TermHelper();
ConceptHelper conceptHelper = new ConceptHelper();
String idconcept = null;

if (conceptObjects == null) {
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", "No values"));
return;
}
for (CsvHelper.ConceptObject conceptObject : conceptObjects) {
/* NodeAutoCompletion nac=new NodeAutoCompletion();
nac.setTermLexicalValue(nt);
this.selectedTerme.setSelectedTermComp(nac);*/

for (CsvHelper.Label prefLabel : conceptObject.getPrefLabels()) {
if (prefLabel.getLang().equalsIgnoreCase("fr")) {

selectedTerme.setValueEdit(conceptObject.getPrefLabels().get(0).getLabel());
selectedTerme.creerTermeSpe((MyTreeNode) getSelectedNode(), "NT", null, conceptObject.getId());//conceptObject.getId());

idconcept = selectedTerme.getIdConceptTemp();
/*
new NoteHelper().addTermNote(connect.getPoolConnexion(),
termHelper.getIdTermOfConcept(connect.getPoolConnexion(),
idconcept, ((MyTreeNode)getSelectedNode()).getIdTheso()),
"fr",
((MyTreeNode)getSelectedNode()).getIdTheso(),
"Id_Calenda :" + conceptObject.getOldId()
+ " ## Id_OE :" + conceptObject.getOldId2()
+ " ## Id_old :" + conceptObject.getOldId3(),//"noteHistorique",
"historyNote", 1);
*/

} // ajout des traductions
else {
if (idconcept != null) {
terme.setId_thesaurus(((MyTreeNode) getSelectedNode()).getIdTheso());
terme.setLang(prefLabel.getLang());
terme.setLexical_value(prefLabel.getLabel());
terme.setId_term(
termHelper.getIdTermOfConcept(connect.getPoolConnexion(),
idconcept, ((MyTreeNode) getSelectedNode()).getIdTheso()));
terme.setContributor(1);
terme.setCreator(1);
terme.setSource("");
terme.setStatus("");
/* if (termHelper.isTermExist(connect.getPoolConnexion(),
terme.getLexical_value(),
terme.getId_thesaurus(), terme.getLang())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
return;
}*/
if (!conceptHelper.addConceptTraduction(connect.getPoolConnexion(), terme, 1)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", "Error"));
return;
}
}

}
}

CsvImportHelper csvImportHelper = new CsvImportHelper(roleOnTheso.getNodePreference());

// ajout des concepts
String idPere = selectedTerme.getIdC();
if( ((MyTreeNode) selectedNode).isIsGroup() || ((MyTreeNode) selectedNode).isIsSubGroup()){
idPere = null;
}
for (CsvReadHelper.ConceptObject conceptObject : conceptObjects) {
csvImportHelper.addSingleConcept(connect.getPoolConnexion(),
idThesoSelected, idPere, selectedTerme.getIdDomaine(),
selectedTerme.getUser().getUser().getIdUser(), conceptObject);
}
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,
"infos:", csvImportHelper.getMessage()));
reloadTree();
}

public void handleFileUpload(FileUploadEvent event) {
@@ -2381,9 +2343,14 @@ public void handleFileUpload(FileUploadEvent event) {

private boolean readCsvFile(FileUploadEvent event) {
try {
Reader in = new InputStreamReader(event.getFile().getInputstream());
CsvHelper csvHelper = new CsvHelper();
if (!csvHelper.readFile(in)) {
Reader in1 = new InputStreamReader(event.getFile().getInputstream());
CsvReadHelper csvHelper = new CsvReadHelper();
if(! csvHelper.setLangs(in1)){
return false;
}

Reader in2 = new InputStreamReader(event.getFile().getInputstream());
if (!csvHelper.readFile(in2)) {
return false;
}

@@ -2675,7 +2642,7 @@ public void setSortTitle(String sortTitle) {
this.sortTitle = sortTitle;
}

public ArrayList<CsvHelper.ConceptObject> getConceptObjects() {
public ArrayList<CsvReadHelper.ConceptObject> getConceptObjects() {
return conceptObjects;
}

@@ -92,7 +92,7 @@ public void filter3(){

}
public void init(){

if(st == null) return;
this.candidats=st.listeCandidats();
this.candidatsA=st.listeCdtArchives();
this.candidatsV=st.listeCdtValid();
@@ -837,6 +837,7 @@ public String getIdConceptOf(String idTerm) {
* @param selecedTerm
* @param relationType
* @param idConcept
* @param notation
* @return true or false
*/
public boolean creerTermeSpe(MyTreeNode selecedTerm, String relationType,
@@ -865,7 +866,8 @@ public boolean creerTermeSpe(MyTreeNode selecedTerm, String relationType,
terme.setLexical_value(valueEdit);
terme.setSource("");
terme.setStatus("");
idConceptRetour = instance.addTopConcept(connect.getPoolConnexion(), idTheso, concept, terme, user.getUser().getIdUser());
concept.setTopConcept(true);
idConceptRetour = instance.addConcept(connect.getPoolConnexion(), null, null, concept, terme, user.getUser().getIdUser());
if (idConceptRetour == null) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", instance.getMessage()));
return false;
@@ -1491,7 +1493,7 @@ public void creerTradterme() {
return;
}

if (!ch.addTopConceptTraduction(connect.getPoolConnexion(), terme, user.getUser().getIdUser())) {
if (!ch.addConceptTraduction(connect.getPoolConnexion(), terme, user.getUser().getIdUser())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error")));
return;
}

0 comments on commit be3bebb

Please sign in to comment.
You can’t perform that action at this time.