use of mom.trd.opentheso.bdd.datas.Concept in project opentheso by miledrousset.
the class ImportSkosHelper method addConcepts_progress.
/**
* récupération des concepts
* @param fileBean
* @return
*/
public boolean addConcepts_progress(FileBean_progress fileBean) {
String uri;
Value value;
boolean isTopConcept = true;
Concept concept = new Concept();
ConceptHelper conceptHelper = new ConceptHelper();
TermHelper termHelper = new TermHelper();
NoteHelper noteHelper = new NoteHelper();
Term term = new Term();
AlignmentHelper alignmentHelper = new AlignmentHelper();
// ajout des termes et traductions
NodeTerm nodeTerm = new NodeTerm();
ArrayList<NodeTermTraduction> nodeTermTraductionList = new ArrayList<>();
// Enregister les synonymes et traductions
ArrayList<NodeEM> nodeEMList = new ArrayList<>();
// ajout des notes
ArrayList<NodeNote> nodeNotes = new ArrayList<>();
// ajout des alignements
ArrayList<NodeAlignment> nodeAlignments = new ArrayList<>();
// ajout des relations
ArrayList<HierarchicalRelationship> hierarchicalRelationships = new ArrayList<>();
// ajout des relations Groups
ArrayList<String> idGrps = new ArrayList<>();
if (dataSet.getSKOSConcepts().isEmpty())
return false;
int i = 0;
// i can get all the concepts from this scheme
for (SKOSConcept conceptsInScheme : dataSet.getSKOSConcepts()) {
// URI du Concept récupération automatique de l'identifiant
String id = getIdFromUri(conceptsInScheme.getURI().toString());
if (id == null || id.isEmpty()) {
message = message + "identifiant null pour l'URI : " + conceptsInScheme.getURI().toString();
continue;
} else {
concept.setIdConcept(id);
}
concept.setIdThesaurus(thesaurus.getId_thesaurus());
// concept.setIdGroup(idGroup.get(0));
concept.setNotation("");
concept.setStatus("");
concept.setIdArk(conceptsInScheme.getURI().toString());
for (SKOSAnnotation anno : conceptsInScheme.getSKOSAnnotations(dataSet)) {
// c'est une valeur
if (anno.isAnnotationByConstant()) {
// balises SKOS
if (anno.getURI().getFragment() != null) {
// get altLabels
if (anno.getURI().getFragment().equalsIgnoreCase("prefLabel")) {
value = getValue(anno);
NodeTermTraduction nodeTermTraduction = new NodeTermTraduction();
nodeTermTraduction.setLexicalValue(value.getValue());
nodeTermTraduction.setLang(value.getLang());
nodeTermTraductionList.add(nodeTermTraduction);
}
if (anno.getURI().getFragment().equalsIgnoreCase("altLabel")) {
value = getValue(anno);
NodeEM nodeEM = new NodeEM();
nodeEM.setLexical_value(value.getValue());
nodeEM.setLang(value.getLang());
nodeEM.setSource("" + idUser);
nodeEM.setStatus("USE");
nodeEM.setHiden(false);
nodeEMList.add(nodeEM);
}
if (anno.getURI().getFragment().equalsIgnoreCase("hiddenLabel")) {
value = getValue(anno);
NodeEM nodeEM = new NodeEM();
nodeEM.setLexical_value(value.getValue());
nodeEM.setLang(value.getLang());
nodeEM.setSource("" + idUser);
nodeEM.setStatus("Hidden");
nodeEM.setHiden(true);
nodeEMList.add(nodeEM);
}
// get notes
if (anno.getURI().getFragment().equalsIgnoreCase("definition")) {
value = getValue(anno);
NodeNote nodeNote = new NodeNote();
nodeNote.setLang(value.getLang());
nodeNote.setLexicalvalue(value.getValue());
nodeNote.setNotetypecode("definition");
nodeNotes.add(nodeNote);
}
if (anno.getURI().getFragment().equalsIgnoreCase("note")) {
value = getValue(anno);
NodeNote nodeNote = new NodeNote();
nodeNote.setLang(value.getLang());
nodeNote.setLexicalvalue(value.getValue());
nodeNote.setNotetypecode("note");
nodeNotes.add(nodeNote);
}
if (anno.getURI().getFragment().equalsIgnoreCase("scopeNote")) {
value = getValue(anno);
NodeNote nodeNote = new NodeNote();
nodeNote.setLang(value.getLang());
nodeNote.setLexicalvalue(value.getValue());
nodeNote.setNotetypecode("scopeNote");
nodeNotes.add(nodeNote);
}
if (anno.getURI().getFragment().equalsIgnoreCase("editorialNote")) {
value = getValue(anno);
NodeNote nodeNote = new NodeNote();
nodeNote.setLang(value.getLang());
nodeNote.setLexicalvalue(value.getValue());
nodeNote.setNotetypecode("editorialNote");
nodeNotes.add(nodeNote);
}
if (anno.getURI().getFragment().equalsIgnoreCase("historyNote")) {
value = getValue(anno);
NodeNote nodeNote = new NodeNote();
nodeNote.setLang(value.getLang());
nodeNote.setLexicalvalue(value.getValue());
nodeNote.setNotetypecode("historyNote");
nodeNotes.add(nodeNote);
}
} else // balises DublinCore dc
{
uri = getIdFromUri(anno.getURI().toString());
if (uri.equalsIgnoreCase("created") || uri.equalsIgnoreCase("date")) {
concept = addDates(concept, formatDate, getValue(anno).getValue(), "created");
}
if (uri.equalsIgnoreCase("modified")) {
concept = addDates(concept, formatDate, getValue(anno).getValue(), "modified");
}
// get the identifier from dcterms ceci peut être aussi l'identifiant ark
if (uri.equalsIgnoreCase("identifier")) {
concept.setIdArk(getValue(anno).getValue());
}
}
} else // c'est une relation
{
// balises SKOS
if (anno.getURI().getFragment() != null) {
// get relations hiérarchiques
if (anno.getURI().getFragment().equalsIgnoreCase("narrower")) {
uri = getIdFromUri(anno.getAnnotationValue().getURI().toString());
HierarchicalRelationship hierarchicalRelationship = new HierarchicalRelationship();
hierarchicalRelationship.setIdConcept1(concept.getIdConcept());
hierarchicalRelationship.setIdConcept2(uri);
hierarchicalRelationship.setIdThesaurus(thesaurus.getId_thesaurus());
hierarchicalRelationship.setRole("NT");
hierarchicalRelationships.add(hierarchicalRelationship);
}
if (anno.getURI().getFragment().equalsIgnoreCase("broader")) {
uri = getIdFromUri(anno.getAnnotationValue().getURI().toString());
HierarchicalRelationship hierarchicalRelationship = new HierarchicalRelationship();
hierarchicalRelationship.setIdConcept1(concept.getIdConcept());
hierarchicalRelationship.setIdConcept2(uri);
hierarchicalRelationship.setIdThesaurus(thesaurus.getId_thesaurus());
hierarchicalRelationship.setRole("BT");
hierarchicalRelationships.add(hierarchicalRelationship);
isTopConcept = false;
}
if (anno.getURI().getFragment().equalsIgnoreCase("related")) {
uri = getIdFromUri(anno.getAnnotationValue().getURI().toString());
HierarchicalRelationship hierarchicalRelationship = new HierarchicalRelationship();
hierarchicalRelationship.setIdConcept1(concept.getIdConcept());
hierarchicalRelationship.setIdConcept2(uri);
hierarchicalRelationship.setIdThesaurus(thesaurus.getId_thesaurus());
hierarchicalRelationship.setRole("RT");
hierarchicalRelationships.add(hierarchicalRelationship);
}
// get scheme
if (anno.getURI().getFragment().equalsIgnoreCase("inScheme")) {
// uri = anno.getAnnotationValue().getURI().toString();
}
// get Groups
if (anno.getURI().getFragment().equalsIgnoreCase("memberOf")) {
uri = getIdFromUri(anno.getAnnotationValue().getURI().toString());
idGrps.add(uri);
addIdGroupToVector(uri);
}
// get Alignements
if (anno.getURI().getFragment().equalsIgnoreCase("closeMatch")) {
uri = anno.getAnnotationValue().getURI().toString();
NodeAlignment nodeAlignment = new NodeAlignment();
nodeAlignment.setId_author(idUser);
nodeAlignment.setConcept_target("");
nodeAlignment.setThesaurus_target("");
nodeAlignment.setUri_target(uri);
nodeAlignment.setInternal_id_concept(concept.getIdConcept());
nodeAlignment.setInternal_id_thesaurus(thesaurus.getId_thesaurus());
nodeAlignment.setAlignement_id_type(2);
nodeAlignments.add(nodeAlignment);
}
if (anno.getURI().getFragment().equalsIgnoreCase("exactMatch")) {
uri = anno.getAnnotationValue().getURI().toString();
NodeAlignment nodeAlignment = new NodeAlignment();
nodeAlignment.setId_author(idUser);
nodeAlignment.setConcept_target("");
nodeAlignment.setThesaurus_target("");
nodeAlignment.setUri_target(uri);
nodeAlignment.setInternal_id_concept(concept.getIdConcept());
nodeAlignment.setInternal_id_thesaurus(thesaurus.getId_thesaurus());
nodeAlignment.setAlignement_id_type(1);
nodeAlignments.add(nodeAlignment);
}
if (anno.getURI().getFragment().equalsIgnoreCase("broadMatch")) {
uri = anno.getAnnotationValue().getURI().toString();
NodeAlignment nodeAlignment = new NodeAlignment();
nodeAlignment.setId_author(idUser);
nodeAlignment.setConcept_target("");
nodeAlignment.setThesaurus_target("");
nodeAlignment.setUri_target(uri);
nodeAlignment.setInternal_id_concept(concept.getIdConcept());
nodeAlignment.setInternal_id_thesaurus(thesaurus.getId_thesaurus());
nodeAlignment.setAlignement_id_type(3);
nodeAlignments.add(nodeAlignment);
}
if (anno.getURI().getFragment().equalsIgnoreCase("narrowMatch")) {
uri = anno.getAnnotationValue().getURI().toString();
NodeAlignment nodeAlignment = new NodeAlignment();
nodeAlignment.setId_author(idUser);
nodeAlignment.setConcept_target("");
nodeAlignment.setThesaurus_target("");
nodeAlignment.setUri_target(uri);
nodeAlignment.setInternal_id_concept(concept.getIdConcept());
nodeAlignment.setInternal_id_thesaurus(thesaurus.getId_thesaurus());
nodeAlignment.setAlignement_id_type(5);
nodeAlignments.add(nodeAlignment);
}
if (anno.getURI().getFragment().equalsIgnoreCase("relatedMatch")) {
uri = anno.getAnnotationValue().getURI().toString();
NodeAlignment nodeAlignment = new NodeAlignment();
nodeAlignment.setId_author(idUser);
nodeAlignment.setConcept_target("");
nodeAlignment.setThesaurus_target("");
nodeAlignment.setUri_target(uri);
nodeAlignment.setInternal_id_concept(concept.getIdConcept());
nodeAlignment.setInternal_id_thesaurus(thesaurus.getId_thesaurus());
nodeAlignment.setAlignement_id_type(4);
nodeAlignments.add(nodeAlignment);
}
}
}
}
// ajout des termes et traductions
nodeTerm.setNodeTermTraduction(nodeTermTraductionList);
nodeTerm.setIdTerm(concept.getIdConcept());
nodeTerm.setIdConcept(concept.getIdConcept());
nodeTerm.setIdThesaurus(thesaurus.getId_thesaurus());
nodeTerm.setSource("");
nodeTerm.setStatus("");
nodeTerm.setCreated(concept.getCreated());
nodeTerm.setModified(concept.getModified());
// conctrole si le concept est vide aucun prefLable, on l'ignore
if (!isConceptEmpty(nodeTermTraductionList)) {
if (idGrps.isEmpty()) {
concept.setTopConcept(isTopConcept);
concept.setIdGroup(idGroupDefault);
conceptHelper.insertConceptInTable(ds, concept, idUser);
} else {
for (String idGrp : idGrps) {
concept.setTopConcept(isTopConcept);
concept.setIdGroup(idGrp);
conceptHelper.insertConceptInTable(ds, concept, idUser);
}
}
termHelper.insertTerm(ds, nodeTerm, idUser);
try {
Connection conn = ds.getConnection();
conn.setAutoCommit(false);
for (HierarchicalRelationship hierarchicalRelationship : hierarchicalRelationships) {
conceptHelper.addLinkHierarchicalRelation(conn, hierarchicalRelationship, idUser);
}
conn.commit();
conn.close();
} catch (SQLException ex) {
}
for (NodeNote nodeNoteList1 : nodeNotes) {
if (nodeNoteList1.getNotetypecode().contains("scopeNote")) {
noteHelper.addConceptNote(ds, concept.getIdConcept(), nodeNoteList1.getLang(), thesaurus.getId_thesaurus(), nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().contains("historyNote")) {
noteHelper.addConceptNote(ds, concept.getIdConcept(), nodeNoteList1.getLang(), thesaurus.getId_thesaurus(), nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().contains("definition")) {
noteHelper.addTermNote(ds, nodeTerm.getIdTerm(), nodeNoteList1.getLang(), thesaurus.getId_thesaurus(), nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().contains("editorialNote")) {
noteHelper.addTermNote(ds, nodeTerm.getIdTerm(), nodeNoteList1.getLang(), thesaurus.getId_thesaurus(), nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().contains("note")) {
noteHelper.addConceptNote(ds, nodeTerm.getIdTerm(), nodeNoteList1.getLang(), thesaurus.getId_thesaurus(), nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
}
for (NodeAlignment nodeAlignment : nodeAlignments) {
alignmentHelper.addNewAlignment(ds, nodeAlignment);
}
for (NodeEM nodeEMList1 : nodeEMList) {
term.setId_concept(concept.getIdConcept());
term.setId_term(nodeTerm.getIdTerm());
term.setLexical_value(nodeEMList1.getLexical_value());
term.setLang(nodeEMList1.getLang());
term.setId_thesaurus(thesaurus.getId_thesaurus());
term.setSource(nodeEMList1.getSource());
term.setStatus(nodeEMList1.getStatus());
termHelper.addNonPreferredTerm(ds, term, idUser);
}
}
// initialisation des variables
concept = new Concept();
term = new Term();
nodeTerm = new NodeTerm();
nodeTermTraductionList = new ArrayList<>();
nodeEMList = new ArrayList<>();
nodeNotes = new ArrayList<>();
nodeAlignments = new ArrayList<>();
hierarchicalRelationships = new ArrayList<>();
idGrps = new ArrayList<>();
isTopConcept = true;
if (conceptsCount < 100) {
fileBean.setProgress(i * (100 / conceptsCount));
} else {
fileBean.setProgress(i / (conceptsCount / 100));
}
try {
Thread.sleep(200);
if (fileBean.getProgress() == null) {
fileBean.setProgress(100);
return false;
}
} catch (InterruptedException e) {
}
i++;
}
for (String idTopConcept1 : idTopConcept) {
if (!conceptHelper.setTopConcept(ds, idTopConcept1, thesaurus.getId_thesaurus())) {
// erreur;
}
}
addGroups();
addLangsToThesaurus(ds, thesaurus.getId_thesaurus());
message = message + "\n nombre de Concepts importés : " + conceptsCount;
fileBean.setProgress(100);
// System.out.println("Finished Function");
return true;
}
use of mom.trd.opentheso.bdd.datas.Concept in project opentheso by miledrousset.
the class ImportSkosHelper method addConcepts_progress.
/**
* récupération des concepts
* @param fileBean
* @return
*/
public boolean addConcepts_progress(FileBean fileBean) {
String uri;
Value value;
boolean isTopConcept = true;
Concept concept = new Concept();
ConceptHelper conceptHelper = new ConceptHelper();
TermHelper termHelper = new TermHelper();
NoteHelper noteHelper = new NoteHelper();
Term term = new Term();
AlignmentHelper alignmentHelper = new AlignmentHelper();
// ajout des termes et traductions
NodeTerm nodeTerm = new NodeTerm();
ArrayList<NodeTermTraduction> nodeTermTraductionList = new ArrayList<>();
// Enregister les synonymes et traductions
ArrayList<NodeEM> nodeEMList = new ArrayList<>();
// ajout des notes
ArrayList<NodeNote> nodeNotes = new ArrayList<>();
// ajout des alignements
ArrayList<NodeAlignment> nodeAlignments = new ArrayList<>();
// ajout des relations
ArrayList<HierarchicalRelationship> hierarchicalRelationships = new ArrayList<>();
// ajout des relations Groups
ArrayList<String> idGrps = new ArrayList<>();
if (dataSet.getSKOSConcepts().isEmpty())
return false;
int i = 0;
// i can get all the concepts from this scheme
for (SKOSConcept conceptsInScheme : dataSet.getSKOSConcepts()) {
// URI du Concept récupération automatique de l'identifiant
String id = getIdFromUri(conceptsInScheme.getURI().toString());
if (id == null || id.isEmpty()) {
message = message + "identifiant null pour l'URI : " + conceptsInScheme.getURI().toString();
continue;
} else {
concept.setIdConcept(id);
}
concept.setIdThesaurus(thesaurus.getId_thesaurus());
// concept.setIdGroup(idGroup.get(0));
concept.setNotation("");
concept.setStatus("");
concept.setIdArk(conceptsInScheme.getURI().toString());
for (SKOSAnnotation anno : conceptsInScheme.getSKOSAnnotations(dataSet)) {
// c'est une valeur
if (anno.isAnnotationByConstant()) {
// balises SKOS
if (anno.getURI().getFragment() != null) {
// get altLabels
if (anno.getURI().getFragment().equalsIgnoreCase("prefLabel")) {
value = getValue(anno);
NodeTermTraduction nodeTermTraduction = new NodeTermTraduction();
nodeTermTraduction.setLexicalValue(value.getValue());
nodeTermTraduction.setLang(value.getLang());
nodeTermTraductionList.add(nodeTermTraduction);
}
if (anno.getURI().getFragment().equalsIgnoreCase("altLabel")) {
value = getValue(anno);
NodeEM nodeEM = new NodeEM();
nodeEM.setLexical_value(value.getValue());
nodeEM.setLang(value.getLang());
nodeEM.setSource("" + idUser);
nodeEM.setStatus("USE");
nodeEM.setHiden(false);
nodeEMList.add(nodeEM);
}
if (anno.getURI().getFragment().equalsIgnoreCase("hiddenLabel")) {
value = getValue(anno);
NodeEM nodeEM = new NodeEM();
nodeEM.setLexical_value(value.getValue());
nodeEM.setLang(value.getLang());
nodeEM.setSource("" + idUser);
nodeEM.setStatus("Hidden");
nodeEM.setHiden(true);
nodeEMList.add(nodeEM);
}
// get notes
if (anno.getURI().getFragment().equalsIgnoreCase("definition")) {
value = getValue(anno);
NodeNote nodeNote = new NodeNote();
nodeNote.setLang(value.getLang());
nodeNote.setLexicalvalue(value.getValue());
nodeNote.setNotetypecode("definition");
nodeNotes.add(nodeNote);
}
if (anno.getURI().getFragment().equalsIgnoreCase("note")) {
value = getValue(anno);
NodeNote nodeNote = new NodeNote();
nodeNote.setLang(value.getLang());
nodeNote.setLexicalvalue(value.getValue());
nodeNote.setNotetypecode("note");
nodeNotes.add(nodeNote);
}
if (anno.getURI().getFragment().equalsIgnoreCase("scopeNote")) {
value = getValue(anno);
NodeNote nodeNote = new NodeNote();
nodeNote.setLang(value.getLang());
nodeNote.setLexicalvalue(value.getValue());
nodeNote.setNotetypecode("scopeNote");
nodeNotes.add(nodeNote);
}
if (anno.getURI().getFragment().equalsIgnoreCase("editorialNote")) {
value = getValue(anno);
NodeNote nodeNote = new NodeNote();
nodeNote.setLang(value.getLang());
nodeNote.setLexicalvalue(value.getValue());
nodeNote.setNotetypecode("editorialNote");
nodeNotes.add(nodeNote);
}
if (anno.getURI().getFragment().equalsIgnoreCase("historyNote")) {
value = getValue(anno);
NodeNote nodeNote = new NodeNote();
nodeNote.setLang(value.getLang());
nodeNote.setLexicalvalue(value.getValue());
nodeNote.setNotetypecode("historyNote");
nodeNotes.add(nodeNote);
}
} else // balises DublinCore dc
{
uri = getIdFromUri(anno.getURI().toString());
if (uri.equalsIgnoreCase("created") || uri.equalsIgnoreCase("date")) {
concept = addDates(concept, formatDate, getValue(anno).getValue(), "created");
}
if (uri.equalsIgnoreCase("modified")) {
concept = addDates(concept, formatDate, getValue(anno).getValue(), "modified");
}
// get the identifier from dcterms ceci peut être aussi l'identifiant ark
if (uri.equalsIgnoreCase("identifier")) {
concept.setIdArk(getValue(anno).getValue());
}
}
} else // c'est une relation
{
// balises SKOS
if (anno.getURI().getFragment() != null) {
// get relations hiérarchiques
if (anno.getURI().getFragment().equalsIgnoreCase("narrower")) {
uri = getIdFromUri(anno.getAnnotationValue().getURI().toString());
HierarchicalRelationship hierarchicalRelationship = new HierarchicalRelationship();
hierarchicalRelationship.setIdConcept1(concept.getIdConcept());
hierarchicalRelationship.setIdConcept2(uri);
hierarchicalRelationship.setIdThesaurus(thesaurus.getId_thesaurus());
hierarchicalRelationship.setRole("NT");
hierarchicalRelationships.add(hierarchicalRelationship);
}
if (anno.getURI().getFragment().equalsIgnoreCase("broader")) {
uri = getIdFromUri(anno.getAnnotationValue().getURI().toString());
HierarchicalRelationship hierarchicalRelationship = new HierarchicalRelationship();
hierarchicalRelationship.setIdConcept1(concept.getIdConcept());
hierarchicalRelationship.setIdConcept2(uri);
hierarchicalRelationship.setIdThesaurus(thesaurus.getId_thesaurus());
hierarchicalRelationship.setRole("BT");
hierarchicalRelationships.add(hierarchicalRelationship);
isTopConcept = false;
}
if (anno.getURI().getFragment().equalsIgnoreCase("related")) {
uri = getIdFromUri(anno.getAnnotationValue().getURI().toString());
HierarchicalRelationship hierarchicalRelationship = new HierarchicalRelationship();
hierarchicalRelationship.setIdConcept1(concept.getIdConcept());
hierarchicalRelationship.setIdConcept2(uri);
hierarchicalRelationship.setIdThesaurus(thesaurus.getId_thesaurus());
hierarchicalRelationship.setRole("RT");
hierarchicalRelationships.add(hierarchicalRelationship);
}
// get scheme
if (anno.getURI().getFragment().equalsIgnoreCase("inScheme")) {
// uri = anno.getAnnotationValue().getURI().toString();
}
// get Groups
if (anno.getURI().getFragment().equalsIgnoreCase("memberOf")) {
uri = getIdFromUri(anno.getAnnotationValue().getURI().toString());
idGrps.add(uri);
addIdGroupToVector(uri);
}
// get Alignements
if (anno.getURI().getFragment().equalsIgnoreCase("closeMatch")) {
uri = anno.getAnnotationValue().getURI().toString();
NodeAlignment nodeAlignment = new NodeAlignment();
nodeAlignment.setId_author(idUser);
nodeAlignment.setConcept_target("");
nodeAlignment.setThesaurus_target("");
nodeAlignment.setUri_target(uri);
nodeAlignment.setInternal_id_concept(concept.getIdConcept());
nodeAlignment.setInternal_id_thesaurus(thesaurus.getId_thesaurus());
nodeAlignment.setAlignement_id_type(2);
nodeAlignments.add(nodeAlignment);
}
if (anno.getURI().getFragment().equalsIgnoreCase("exactMatch")) {
uri = anno.getAnnotationValue().getURI().toString();
NodeAlignment nodeAlignment = new NodeAlignment();
nodeAlignment.setId_author(idUser);
nodeAlignment.setConcept_target("");
nodeAlignment.setThesaurus_target("");
nodeAlignment.setUri_target(uri);
nodeAlignment.setInternal_id_concept(concept.getIdConcept());
nodeAlignment.setInternal_id_thesaurus(thesaurus.getId_thesaurus());
nodeAlignment.setAlignement_id_type(1);
nodeAlignments.add(nodeAlignment);
}
if (anno.getURI().getFragment().equalsIgnoreCase("broadMatch")) {
uri = anno.getAnnotationValue().getURI().toString();
NodeAlignment nodeAlignment = new NodeAlignment();
nodeAlignment.setId_author(idUser);
nodeAlignment.setConcept_target("");
nodeAlignment.setThesaurus_target("");
nodeAlignment.setUri_target(uri);
nodeAlignment.setInternal_id_concept(concept.getIdConcept());
nodeAlignment.setInternal_id_thesaurus(thesaurus.getId_thesaurus());
nodeAlignment.setAlignement_id_type(3);
nodeAlignments.add(nodeAlignment);
}
if (anno.getURI().getFragment().equalsIgnoreCase("narrowMatch")) {
uri = anno.getAnnotationValue().getURI().toString();
NodeAlignment nodeAlignment = new NodeAlignment();
nodeAlignment.setId_author(idUser);
nodeAlignment.setConcept_target("");
nodeAlignment.setThesaurus_target("");
nodeAlignment.setUri_target(uri);
nodeAlignment.setInternal_id_concept(concept.getIdConcept());
nodeAlignment.setInternal_id_thesaurus(thesaurus.getId_thesaurus());
nodeAlignment.setAlignement_id_type(5);
nodeAlignments.add(nodeAlignment);
}
if (anno.getURI().getFragment().equalsIgnoreCase("relatedMatch")) {
uri = anno.getAnnotationValue().getURI().toString();
NodeAlignment nodeAlignment = new NodeAlignment();
nodeAlignment.setId_author(idUser);
nodeAlignment.setConcept_target("");
nodeAlignment.setThesaurus_target("");
nodeAlignment.setUri_target(uri);
nodeAlignment.setInternal_id_concept(concept.getIdConcept());
nodeAlignment.setInternal_id_thesaurus(thesaurus.getId_thesaurus());
nodeAlignment.setAlignement_id_type(4);
nodeAlignments.add(nodeAlignment);
}
}
}
}
// ajout des termes et traductions
nodeTerm.setNodeTermTraduction(nodeTermTraductionList);
nodeTerm.setIdTerm(concept.getIdConcept());
nodeTerm.setIdConcept(concept.getIdConcept());
nodeTerm.setIdThesaurus(thesaurus.getId_thesaurus());
nodeTerm.setSource("");
nodeTerm.setStatus("");
nodeTerm.setCreated(concept.getCreated());
nodeTerm.setModified(concept.getModified());
// conctrole si le concept est vide aucun prefLable, on l'ignore
if (!isConceptEmpty(nodeTermTraductionList)) {
if (idGrps.isEmpty()) {
concept.setTopConcept(isTopConcept);
concept.setIdGroup(idGroupDefault);
conceptHelper.insertConceptInTable(ds, concept, idUser);
} else {
for (String idGrp : idGrps) {
concept.setTopConcept(isTopConcept);
concept.setIdGroup(idGrp);
conceptHelper.insertConceptInTable(ds, concept, idUser);
}
}
termHelper.insertTerm(ds, nodeTerm, idUser);
try {
Connection conn = ds.getConnection();
conn.setAutoCommit(false);
for (HierarchicalRelationship hierarchicalRelationship : hierarchicalRelationships) {
conceptHelper.addLinkHierarchicalRelation(conn, hierarchicalRelationship, idUser);
}
conn.commit();
conn.close();
} catch (SQLException ex) {
}
for (NodeNote nodeNoteList1 : nodeNotes) {
if (nodeNoteList1.getNotetypecode().contains("scopeNote")) {
noteHelper.addConceptNote(ds, concept.getIdConcept(), nodeNoteList1.getLang(), thesaurus.getId_thesaurus(), nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().contains("historyNote")) {
noteHelper.addConceptNote(ds, concept.getIdConcept(), nodeNoteList1.getLang(), thesaurus.getId_thesaurus(), nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().contains("definition")) {
noteHelper.addTermNote(ds, nodeTerm.getIdTerm(), nodeNoteList1.getLang(), thesaurus.getId_thesaurus(), nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().contains("editorialNote")) {
noteHelper.addTermNote(ds, nodeTerm.getIdTerm(), nodeNoteList1.getLang(), thesaurus.getId_thesaurus(), nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
if (nodeNoteList1.getNotetypecode().contains("note")) {
noteHelper.addConceptNote(ds, nodeTerm.getIdTerm(), nodeNoteList1.getLang(), thesaurus.getId_thesaurus(), nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
}
}
for (NodeAlignment nodeAlignment : nodeAlignments) {
alignmentHelper.addNewAlignment(ds, nodeAlignment);
}
for (NodeEM nodeEMList1 : nodeEMList) {
term.setId_concept(concept.getIdConcept());
term.setId_term(nodeTerm.getIdTerm());
term.setLexical_value(nodeEMList1.getLexical_value());
term.setLang(nodeEMList1.getLang());
term.setId_thesaurus(thesaurus.getId_thesaurus());
term.setSource(nodeEMList1.getSource());
term.setStatus(nodeEMList1.getStatus());
termHelper.addNonPreferredTerm(ds, term, idUser);
}
}
// initialisation des variables
concept = new Concept();
term = new Term();
nodeTerm = new NodeTerm();
nodeTermTraductionList = new ArrayList<>();
nodeEMList = new ArrayList<>();
nodeNotes = new ArrayList<>();
nodeAlignments = new ArrayList<>();
hierarchicalRelationships = new ArrayList<>();
idGrps = new ArrayList<>();
isTopConcept = true;
if (conceptsCount < 100) {
fileBean.setProgress(i * (100 / conceptsCount));
} else {
fileBean.setProgress(i / (conceptsCount / 100));
}
try {
Thread.sleep(200);
if (fileBean.getProgress() == null) {
fileBean.setProgress(100);
return false;
}
} catch (InterruptedException e) {
}
i++;
}
for (String idTopConcept1 : idTopConcept) {
if (!conceptHelper.setTopConcept(ds, idTopConcept1, thesaurus.getId_thesaurus())) {
// erreur;
}
}
addGroups();
addLangsToThesaurus(ds, thesaurus.getId_thesaurus());
message = message + "\n nombre de Concepts importés : " + conceptsCount;
fileBean.setProgress(100);
// System.out.println("Finished Function");
return true;
}
use of mom.trd.opentheso.bdd.datas.Concept in project opentheso by miledrousset.
the class WriteBranchSkosBDD method writeFirstConceptAfterGroup.
private boolean writeFirstConceptAfterGroup(SKOSResource resource, String idGroup, String idThesaurus, String id_langueSource, String dateFormat, String adressSite, boolean useArk, int idUser) {
RelationsHelper relationsHelper = new RelationsHelper();
// ajout du concept dans la base
Concept concept = new Concept();
ConceptHelper conceptHelper = new ConceptHelper();
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(true);
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
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);
}
return true;
}
use of mom.trd.opentheso.bdd.datas.Concept in project opentheso by miledrousset.
the class WriteBranchSkosBDD method writeConcept.
private void writeConcept(SKOSResource resource, String idConcept, 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();
if (idConcept.trim().isEmpty())
return;
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.datas.Concept in project opentheso by miledrousset.
the class ImportTabuleIntoBDD method insertConcept.
private boolean insertConcept(HikariDataSource ds, TabulateDocument tabulateDocument, String idThesaurus, boolean istopConcept, int idUser) {
// ajout du concept dans la base
Concept concept = new Concept();
ConceptHelper conceptHelper = new ConceptHelper();
concept.setIdConcept(tabulateDocument.getId());
concept.setIdThesaurus(idThesaurus);
concept.setNotation("");
concept.setStatus("");
concept.setTopConcept(istopConcept);
concept.setCreated(tabulateDocument.getCreated());
concept.setModified(tabulateDocument.getModified());
// cas de plusieurs Domaines (MT)
if (!tabulateDocument.getInScheme().isEmpty()) {
for (String idGroup : tabulateDocument.getInScheme()) {
concept.setIdGroup(idGroup);
conceptHelper.insertConceptInTable(ds, concept, idUser);
}
} else {
return false;
}
// ajout des termes et traductions
NodeTerm nodeTerm = new NodeTerm();
ArrayList<NodeTermTraduction> nodeTermTraductionList = new ArrayList<>();
for (Label prefLabel : tabulateDocument.getPrefLabels()) {
NodeTermTraduction nodeTermTraduction = new NodeTermTraduction();
nodeTermTraduction.setLexicalValue(prefLabel.getLabel());
nodeTermTraduction.setLang(prefLabel.getLang());
nodeTermTraductionList.add(nodeTermTraduction);
}
nodeTerm.setNodeTermTraduction(nodeTermTraductionList);
nodeTerm.setIdTerm(tabulateDocument.getId());
nodeTerm.setIdConcept(tabulateDocument.getId());
nodeTerm.setIdThesaurus(idThesaurus);
nodeTerm.setSource("");
nodeTerm.setStatus("");
nodeTerm.setCreated(tabulateDocument.getCreated());
nodeTerm.setModified(tabulateDocument.getModified());
TermHelper termHelper = new TermHelper();
termHelper.insertTerm(ds, nodeTerm, idUser);
// Enregister les synonymes et traductions (AltLabel)
ArrayList<NodeEM> nodeEMList = new ArrayList<>();
for (Label altLabel : tabulateDocument.getAltLabels()) {
NodeEM nodeEM = new NodeEM();
nodeEM.setLexical_value(altLabel.getLabel());
nodeEM.setLang(altLabel.getLang());
nodeEM.setSource("");
nodeEM.setStatus("USE");
nodeEM.setHiden(false);
nodeEMList.add(nodeEM);
}
Term term = new Term();
for (NodeEM nodeEMList1 : nodeEMList) {
term.setId_concept(tabulateDocument.getId());
term.setId_term(tabulateDocument.getId());
term.setLexical_value(nodeEMList1.getLexical_value());
term.setLang(nodeEMList1.getLang());
term.setId_thesaurus(idThesaurus);
term.setSource(nodeEMList1.getSource());
term.setStatus(nodeEMList1.getStatus());
termHelper.addNonPreferredTerm(ds, term, idUser);
}
// ajouter les notes
NoteHelper noteHelper = new NoteHelper();
for (Note note : tabulateDocument.getDefinition()) {
noteHelper.addTermNote(ds, tabulateDocument.getId(), note.getLang(), idThesaurus, note.getNote(), "definition", idUser);
}
for (Note note : tabulateDocument.getScopeNote()) {
noteHelper.addTermNote(ds, tabulateDocument.getId(), note.getLang(), idThesaurus, note.getNote(), "scopeNote", idUser);
}
for (Note note : tabulateDocument.getHistoryNote()) {
noteHelper.addTermNote(ds, tabulateDocument.getId(), note.getLang(), idThesaurus, note.getNote(), "historyNote", idUser);
}
for (Note note : tabulateDocument.getEditorialNote()) {
noteHelper.addTermNote(ds, tabulateDocument.getId(), note.getLang(), idThesaurus, note.getNote(), "editorialNote", idUser);
}
// Enregistrer les relations
writeRelationsList(ds, tabulateDocument, idThesaurus, idUser);
// Enregistrer les Mappings (alignements)
AlignmentHelper alignmentHelper = new AlignmentHelper();
for (Alignment alignment : tabulateDocument.getAlignments()) {
if (alignment.getType().equalsIgnoreCase("exactMatch")) {
alignmentHelper.addNewAlignment(ds, // user
1, // concept target
"", // thesaurus target
"", // URI
alignment.getUri(), 1, tabulateDocument.getId(), idThesaurus, 0);
}
if (alignment.getType().equalsIgnoreCase("closeMatch")) {
alignmentHelper.addNewAlignment(ds, // user
1, // concept target
"", // thesaurus target
"", // URI
alignment.getUri(), 2, tabulateDocument.getId(), idThesaurus, 0);
}
}
return true;
}
Aggregations