use of mom.trd.opentheso.bdd.helper.RelationsHelper in project opentheso by miledrousset.
the class AutoCompletBean method newRelationNT.
/**
* Permet d'ajouter une relation terme spécifique NT pour un concept
* #MR
*/
public void newRelationNT() {
createValid = false;
if ((terme.getSelectedTermComp() == null) || (terme.getSelectedTermComp().getIdConcept() == null) || (terme.getSelectedTermComp().getIdConcept().isEmpty())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("tree.error1")));
return;
}
// vérification si la relation est cohérente (NT et RT à la fois ?)
if (!isAddRelationNTValid(terme.getIdC(), terme.getSelectedTermComp().getIdConcept())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("relation.errorNTRT")));
return;
}
RelationsHelper relationsHelper = new RelationsHelper();
if (!relationsHelper.addRelationNT(connect.getPoolConnexion(), terme.getIdC(), terme.getIdTheso(), terme.getSelectedTermComp().getIdConcept(), terme.getUser().getUser().getId())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
return;
}
tree.reInit();
tree.reExpand();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", terme.getSelectedTermComp().getIdConcept() + " " + langueBean.getMsg("tree.info1")));
terme.setSelectedTermComp(new NodeAutoCompletion());
createValid = true;
}
use of mom.trd.opentheso.bdd.helper.RelationsHelper in project opentheso by miledrousset.
the class ExportRdf4jHelper method addMember.
private void addMember(String id, String idThesaurus, SKOSResource resource) {
RelationsHelper relationsHelper = new RelationsHelper();
ArrayList<NodeHieraRelation> listChildren = relationsHelper.getListNT(ds, id, idThesaurus);
for (NodeHieraRelation idChildren : listChildren) {
// System.out.println(idChildren.getUri().getIdConcept());
resource.addRelation(getUriFromNodeUri(idChildren.getUri(), idThesaurus), SKOSProperty.member);
addMember(idChildren.getUri().getIdConcept(), idThesaurus, resource);
}
}
use of mom.trd.opentheso.bdd.helper.RelationsHelper in project opentheso by miledrousset.
the class WriteBranchSkosBDD method writeFirstConcept.
public boolean writeFirstConcept(SKOSResource resource, String idConcept, String idGroup, String idThesaurus, String id_langueSource, String dateFormat, String adressSite, boolean useArk, int idUser) {
RelationsHelper relationsHelper = new RelationsHelper();
try {
relationsHelper.addRelationBT(ds.getConnection(), getId(getId(resource.getUri())), idThesaurus, idConcept, idUser);
} catch (SQLException ex) {
Logger.getLogger(WriteBranchSkosBDD.class.getName()).log(Level.SEVERE, null, ex);
return false;
}
// ajout du concept dans la base
Concept concept = new Concept();
ConceptHelper conceptHelper = new ConceptHelper();
if (idConcept.trim().isEmpty())
return false;
if (idGroup.trim().isEmpty())
return false;
String idC = getId(resource.getUri());
concept.setIdConcept(idC);
// concept.setCreated(null);
concept.setIdThesaurus(idThesaurus);
concept.setNotation("");
concept.setStatus("");
concept.setTopConcept(false);
concept.setIdGroup(idGroup);
concept = addDates(resource.getDateList(), concept, dateFormat);
conceptHelper.insertConceptInTable(ds, concept, idUser);
// ajout des termes et traductions
NodeTerm nodeTerm = new NodeTerm();
nodeTerm.setNodeTermTraduction(getTraductionConcept(resource.getLabelsList()));
nodeTerm.setIdTerm(idC);
nodeTerm.setIdConcept(idC);
nodeTerm.setIdThesaurus(idThesaurus);
nodeTerm.setSource("");
nodeTerm.setStatus("");
nodeTerm = addDatesTerm(resource.getDateList(), nodeTerm, dateFormat);
TermHelper termHelper = new TermHelper();
termHelper.insertTerm(ds, nodeTerm, idUser);
// ajouter les notes
ArrayList<NodeNote> nodeNoteList = addNotes(resource.getDocumentationsList());
NoteHelper noteHelper = new NoteHelper();
for (NodeNote nodeNoteList1 : nodeNoteList) {
if (nodeNoteList1.getNotetypecode().contains("scopeNote")) {
noteHelper.addConceptNote(ds, concept.getIdConcept(), nodeNoteList1.getLang(), idThesaurus, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().contains("historyNote")) {
noteHelper.addConceptNote(ds, concept.getIdConcept(), nodeNoteList1.getLang(), idThesaurus, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().contains("definition")) {
noteHelper.addTermNote(ds, nodeTerm.getIdTerm(), nodeNoteList1.getLang(), idThesaurus, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().contains("editorialNote")) {
noteHelper.addTermNote(ds, nodeTerm.getIdTerm(), nodeNoteList1.getLang(), idThesaurus, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
}
// Enregistrer les relations sans les BT
writeFirstRelationsList(resource.getRelationsList(), concept.getIdConcept(), idThesaurus, idUser);
ArrayList<SKOSMapping> sKOSMappings = resource.getMappings();
// Enregistrer les Mappings (alignements)
AlignmentHelper alignmentHelper = new AlignmentHelper();
for (SKOSMapping sKOSMapping : sKOSMappings) {
if (sKOSMapping.getProperty() == SKOSProperty.exactMatch) {
alignmentHelper.addNewAlignment(ds, // user
1, // concept target
"", // thesaurus target
"", // URI
sKOSMapping.getTargetUri(), 1, concept.getIdConcept(), idThesaurus, 0);
}
if (sKOSMapping.getProperty() == SKOSProperty.closeMatch) {
alignmentHelper.addNewAlignment(ds, // user
1, // concept target
"", // thesaurus target
"", // URI
sKOSMapping.getTargetUri(), 2, concept.getIdConcept(), idThesaurus, 0);
}
}
// Ajouter l'id du concept importé pour l'aligner avec le thésaurus source
alignmentHelper.addNewAlignment(ds, // user
1, // concept target
"", // thesaurus target
"", // URI de la source
resource.getUri(), // sKOSMapping.getTargetUri(), // URI
1, concept.getIdConcept(), idThesaurus, 0);
// Enregister les synonymes et traductions
ArrayList<NodeEM> nodeEMs = writeLabelsList(ds, resource.getLabelsList());
Term term = new Term();
for (int i = 0; i < nodeEMs.size(); i++) {
term.setId_concept(concept.getIdConcept());
term.setId_term(nodeTerm.getIdTerm());
term.setLexical_value(nodeEMs.get(i).getLexical_value());
term.setLang(nodeEMs.get(i).getLang());
term.setId_thesaurus(idThesaurus);
term.setSource(nodeEMs.get(i).getSource());
term.setStatus(nodeEMs.get(i).getStatus());
termHelper.addNonPreferredTerm(ds, term, idUser);
}
return true;
}
use of mom.trd.opentheso.bdd.helper.RelationsHelper in project opentheso by miledrousset.
the class ImportRdf4jHelper method finalizeAddConceptStruct.
private void finalizeAddConceptStruct(AddConceptsStruct acs) throws SQLException {
acs.termHelper.insertTerm(ds, acs.nodeTerm, idUser);
RelationsHelper relationsHelper = new RelationsHelper();
for (HierarchicalRelationship hierarchicalRelationship : acs.hierarchicalRelationships) {
if (!relationsHelper.insertHierarchicalRelation(ds, hierarchicalRelationship.getIdConcept1(), hierarchicalRelationship.getIdThesaurus(), hierarchicalRelationship.getRole(), hierarchicalRelationship.getIdConcept2())) {
// System.out.println("Erreur sur la relation = " + acs.concept.getIdConcept() + " ## " + hierarchicalRelationship.getRole());
message.append(System.getProperty("line.separator"));
message.append("Erreur sur la relation = ");
message.append(acs.concept.getIdConcept());
message.append(" ## ");
message.append(hierarchicalRelationship.getRole());
}
}
// For Term : definition; editorialNote; historyNote;
for (NodeNote nodeNoteList1 : acs.nodeNotes) {
if (nodeNoteList1.getNotetypecode().equals("customnote") || nodeNoteList1.getNotetypecode().equals("scopeNote") || nodeNoteList1.getNotetypecode().equals("historyNote") || nodeNoteList1.getNotetypecode().equals("note")) {
acs.noteHelper.addConceptNote(ds, acs.concept.getIdConcept(), nodeNoteList1.getLang(), idTheso, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().equals("definition") || nodeNoteList1.getNotetypecode().equals("editorialNote")) {
acs.noteHelper.addTermNote(ds, acs.nodeTerm.getIdTerm(), nodeNoteList1.getLang(), idTheso, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
}
for (NodeAlignment nodeAlignment : acs.nodeAlignments) {
acs.alignmentHelper.addNewAlignment(ds, nodeAlignment);
}
for (NodeEM nodeEMList1 : acs.nodeEMList) {
acs.term.setId_concept(acs.concept.getIdConcept());
acs.term.setId_term(acs.nodeTerm.getIdTerm());
acs.term.setLexical_value(nodeEMList1.getLexical_value());
acs.term.setLang(nodeEMList1.getLang());
acs.term.setId_thesaurus(thesaurus.getId_thesaurus());
acs.term.setSource(nodeEMList1.getSource());
acs.term.setStatus(nodeEMList1.getStatus());
acs.termHelper.addNonPreferredTerm(ds, acs.term, idUser);
}
if (acs.nodeGps.getLatitude() != null && acs.nodeGps.getLongitude() != null) {
// insertion des données GPS
acs.gpsHelper.insertCoordonees(ds, acs.concept.getIdConcept(), thesaurus.getId_thesaurus(), acs.nodeGps.getLatitude(), acs.nodeGps.getLongitude());
}
for (String idTopConcept1 : idTopConcept) {
if (!acs.conceptHelper.setTopConcept(ds, idTopConcept1, thesaurus.getId_thesaurus())) {
// erreur;
}
}
// initialisation des variables
acs.concept = new Concept();
acs.nodeTerm = new NodeTerm();
acs.nodeTermTraductionList = new ArrayList<>();
acs.nodeEMList = new ArrayList<>();
acs.nodeNotes = new ArrayList<>();
acs.nodeAlignments = new ArrayList<>();
acs.hierarchicalRelationships = new ArrayList<>();
acs.idGrps = new ArrayList<>();
acs.isTopConcept = false;
acs.nodeGps = new NodeGps();
}
use of mom.trd.opentheso.bdd.helper.RelationsHelper in project opentheso by miledrousset.
the class SelectedTerme method delAsso.
/**
* Supprime la relation d'association qui lie le terme courant au terme dont
* l'id est passé en paramètre.
*
* @param id
*/
public void delAsso(String id) {
if (!new RelationsHelper().deleteRelationRT(connect.getPoolConnexion(), idC, idTheso, id, user.getUser().getId())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.info7")));
return;
}
majTAsso();
vue.setAddTAsso(0);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sTerme.info7")));
}
Aggregations