use of mom.trd.opentheso.bdd.helper.AlignmentHelper 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.AlignmentHelper in project opentheso by miledrousset.
the class WriteBranchSkosBDD method writeConceptAfterGroup.
private void writeConceptAfterGroup(SKOSResource resource, String idGroup, String idThesaurus, String id_langueSource, String dateFormat, String adressSite, boolean useArk, int idUser) {
// ajout du concept dans la base
Concept concept = new Concept();
ConceptHelper conceptHelper = new ConceptHelper();
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);
if (idGroup.trim().isEmpty())
return;
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
writeRelationsList(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);
}
}
use of mom.trd.opentheso.bdd.helper.AlignmentHelper in project opentheso by miledrousset.
the class WriteSkosBDD method writeConcept.
public void writeConcept(SKOSResource resource, String idThesaurus, String id_langueSource, String dateFormat, String adressSite, boolean useArk, int idUser) {
// ajout du concept dans la base
// boolean isTopConcept = isTopConcept(getId(resource.getUri()));
boolean isTopConcept = isTopConceptByRelation(resource.getRelationsList());
Concept concept = new Concept();
ConceptHelper conceptHelper = new ConceptHelper();
String id = getId(getId(resource.getUri()));
if (id == null) {
System.out.println("identifiant null : " + resource.getUri());
}
concept.setIdConcept(getId(getId(resource.getUri())));
// concept.setCreated(null);
concept.setIdThesaurus(idThesaurus);
concept.setNotation("");
concept.setStatus("");
concept.setTopConcept(isTopConcept);
concept = addDates(resource.getDateList(), concept, dateFormat);
ArrayList<String> idGroup = getGroups(resource.getRelationsList());
if (!idGroup.isEmpty()) {
for (String idGroup1 : idGroup) {
concept.setIdGroup(getId(idGroup1));
conceptHelper.insertConceptInTable(ds, concept, idUser);
}
}
// ajout des termes et traductions
NodeTerm nodeTerm = new NodeTerm();
nodeTerm.setNodeTermTraduction(getTraductionConcept(resource.getLabelsList()));
String id_term = getId(getId(resource.getUri()));
if (id_term == null) {
System.out.println("identifiant null : " + resource.getUri());
}
nodeTerm.setIdTerm(getId(getId(resource.getUri())));
nodeTerm.setIdConcept(getId(resource.getUri()));
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
if (isTopConcept) {
writeRelationsListTopConcept(resource.getRelationsList(), concept.getIdConcept(), idThesaurus, idUser);
} else {
writeRelationsList(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);
}
}
// 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);
}
}
use of mom.trd.opentheso.bdd.helper.AlignmentHelper in project opentheso by miledrousset.
the class SelectedThesaurus method regenIdConcept.
/**
* Cette fonction remplace tout les id des concepts du théso
*/
private void regenIdConcept(Connection conn, String idTheso, ArrayList<String> idGroup) throws Exception {
/*récup les concepts*/
ConceptHelper conceptHelper = new ConceptHelper();
ArrayList<String> idConcepts = conceptHelper.getAllIdConceptOfThesaurus(conn, idTheso);
if (idConcepts == null || idConcepts.isEmpty()) {
throw new Exception("No concept in this thesaurus");
}
/*génération des nouveaux id*/
ArrayList<String> reservedId = idConcepts;
reservedId.addAll(idGroup);
ArrayList<String> newIdConcepts = createNewId(reservedId, idConcepts.size());
/*maj des tables*/
NoteHelper noteHelper = new NoteHelper();
GpsHelper gpsHelper = new GpsHelper();
ImagesHelper imagesHelper = new ImagesHelper();
AlignmentHelper alignmentHelper = new AlignmentHelper();
for (int i = 0; i < idConcepts.size(); i++) {
String id = idConcepts.get(i);
String newId = newIdConcepts.get(i);
// table concept
conceptHelper.setIdConcept(conn, idTheso, id, newId);
// table concept_group_concept
conceptHelper.setIdConceptGroupConcept(conn, idTheso, id, newId);
// table concept_historique
conceptHelper.setIdConceptHistorique(conn, idTheso, id, newId);
// table concept_orphan
conceptHelper.setIdConceptOrphan(conn, idTheso, id, newId);
// table gps
gpsHelper.setIdConceptGPS(conn, idTheso, id, newId);
// table hierarchical_relationship
conceptHelper.setIdConceptHieraRelation(conn, idTheso, id, newId);
// table hierarchical_relationship_historique
conceptHelper.setIdConceptHieraRelationHisto(conn, idTheso, id, newId);
// table note
noteHelper.setIdConceptNote(conn, idTheso, id, newId);
// table note_historique
noteHelper.setIdConceptNoteHisto(conn, idTheso, id, newId);
// table images
imagesHelper.setIdConceptImage(conn, idTheso, id, newId);
// table concept_fusion
conceptHelper.setIdConceptFusion(conn, idTheso, id, newId);
// table preferred_term
conceptHelper.setIdConceptPreferedTerm(conn, idTheso, id, newId);
// table alignement
alignmentHelper.setIdConceptAlignement(conn, idTheso, id, newId);
}
}
use of mom.trd.opentheso.bdd.helper.AlignmentHelper in project opentheso by miledrousset.
the class SelectedTerme method ajouterAlignAutoByLot.
/**
* Permet de creer une alignement, cette funtion s'utilise pour l'alignement
* par lot l'apelation de la funtion c'est de AlignementParLotBean
*
* @param nodeAlignment
* @return
*/
public boolean ajouterAlignAutoByLot(NodeAlignment nodeAlignment, boolean addDefinition, String id_term) {
AlignmentHelper alignmentHelper = new AlignmentHelper();
NoteHelper noteHelper = new NoteHelper();
if (!alignmentHelper.addNewAlignment(connect.getPoolConnexion(), user.getUser().getId(), nodeAlignment.getConcept_target(), nodeAlignment.getThesaurus_target(), nodeAlignment.getUri_target(), nodeAlignment.getAlignement_id_type(), nodeAlignment.getInternal_id_concept(), idTheso, alignementSource.getId())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Notation Error BDD")));
return false;
}
if (addDefinition) {
StringPlus stringPlus = new StringPlus();
String dejaBonString = stringPlus.clearAngles(nodeAlignment.getDef_target());
if (!noteHelper.addTermNote(connect.getPoolConnexion(), id_term, idlangue, idTheso, dejaBonString, "definition", user.getUser().getId())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Notation Error BDD")));
return false;
}
}
messageAlig = alignmentHelper.getMessage();
return true;
}
Aggregations