use of skos.SKOSRelation in project opentheso by miledrousset.
the class WriteBranchSkosBDD method writeRelationsListTopConcept.
public void writeRelationsListTopConcept(ArrayList<SKOSRelation> relationsList, String idConcept, String idThesaurus, int idUser) {
ConceptHelper conceptHelper = new ConceptHelper();
HierarchicalRelationship hierarchicalRelationship = new HierarchicalRelationship();
for (int i = 0; i < relationsList.size(); i++) {
SKOSRelation relation = relationsList.get(i);
switch(relation.getProperty()) {
case SKOSProperty.narrower:
hierarchicalRelationship.setIdConcept1(idConcept);
hierarchicalRelationship.setIdConcept2(getId(relation.getTargetUri()));
hierarchicalRelationship.setIdThesaurus(idThesaurus);
hierarchicalRelationship.setRole("NT");
try {
Connection conn = ds.getConnection();
conn.setAutoCommit(false);
if (!conceptHelper.addLinkHierarchicalRelation(conn, hierarchicalRelationship, idUser)) {
conn.rollback();
conn.close();
}
conn.commit();
conn.close();
} catch (SQLException ex) {
Logger.getLogger(WriteBranchSkosBDD.class.getName()).log(Level.SEVERE, null, ex);
}
// query.addRelation(id_terme, "NT", getId(relation.getTargetUri()), id_thesaurus);
break;
case SKOSProperty.related:
hierarchicalRelationship.setIdConcept1(idConcept);
hierarchicalRelationship.setIdConcept2(getId(relation.getTargetUri()));
hierarchicalRelationship.setIdThesaurus(idThesaurus);
hierarchicalRelationship.setRole("RT");
try {
try (Connection conn = ds.getConnection()) {
conn.setAutoCommit(false);
if (!conceptHelper.addLinkHierarchicalRelation(conn, hierarchicalRelationship, idUser)) {
conn.rollback();
conn.close();
}
conn.commit();
conn.close();
}
} catch (SQLException ex) {
Logger.getLogger(WriteBranchSkosBDD.class.getName()).log(Level.SEVERE, null, ex);
}
// query.addRelation(id_terme, "RT", getId(relation.getTargetUri()), id_thesaurus);
break;
default:
break;
}
}
}
use of skos.SKOSRelation in project opentheso by miledrousset.
the class WriteSkosBDD method writeDomaine.
public void writeDomaine(SKOSResource resource, String id_thesaurus, String id_langueSource, String adressSite, boolean useArk, int idUser) {
GroupHelper conceptGroupHelper = new GroupHelper();
String idConceptGroup = getId(resource.getUri());
conceptGroupHelper.insertGroup(ds, idConceptGroup, id_thesaurus, "D", "", adressSite, useArk, idUser);
// ajouter les traductions des Groupes
ConceptGroupLabel conceptGroupLabel = new ConceptGroupLabel();
for (int i = 0; i < resource.getLabelsList().size(); i++) {
conceptGroupLabel.setIdgroup(idConceptGroup);
conceptGroupLabel.setIdthesaurus(id_thesaurus);
conceptGroupLabel.setLang(resource.getLabelsList().get(i).getLanguage());
conceptGroupLabel.setLexicalvalue(resource.getLabelsList().get(i).getLabel());
conceptGroupHelper.addGroupTraduction(ds, conceptGroupLabel, idUser);
}
ArrayList<SKOSRelation> relationsList = resource.getRelationsList();
for (SKOSRelation relation : relationsList) {
switch(relation.getProperty()) {
// ici on a les identifiants des TopConcepts
case SKOSProperty.narrower:
idsTopConcept.add(getId(relation.getTargetUri()));
break;
default:
break;
}
}
}
use of skos.SKOSRelation in project opentheso by miledrousset.
the class SkosToJsonldSchemaOrg method addElementRelation.
private void addElementRelation(ArrayList<SKOSRelation> skosRelation, String nameSpace) {
String element;
if (skosRelation.size() > 1) {
endElement();
element = " \"" + nameSpaceSkosCore + nameSpace + "\": [\n";
boolean first = true;
for (SKOSRelation skosRelation1 : skosRelation) {
if (!first)
element += " },\n";
element += " {\n";
element += " \"@id\": \"" + skosRelation1.getTargetUri() + "\"\n";
first = false;
}
element += " }\n";
element += " ]";
} else {
endElement();
element = " \"" + nameSpaceSkosCore + nameSpace + "\": {\n";
for (SKOSRelation skosRelation1 : skosRelation) {
element += " \"@id\": \"" + skosRelation1.getTargetUri() + "\"\n";
element += " }";
}
}
jsonLd.append(element);
}
use of skos.SKOSRelation in project opentheso by miledrousset.
the class WriteBranchSkosBDD method writeFirstRelationsList.
public void writeFirstRelationsList(ArrayList<SKOSRelation> relationsList, String idConcept, String idThesaurus, int idUser) {
ConceptHelper conceptHelper = new ConceptHelper();
HierarchicalRelationship hierarchicalRelationship = new HierarchicalRelationship();
for (SKOSRelation relation : relationsList) {
switch(relation.getProperty()) {
case SKOSProperty.narrower:
hierarchicalRelationship.setIdConcept1(idConcept);
hierarchicalRelationship.setIdConcept2(getId(relation.getTargetUri()));
hierarchicalRelationship.setIdThesaurus(idThesaurus);
hierarchicalRelationship.setRole("NT");
try {
try (Connection conn = ds.getConnection()) {
conn.setAutoCommit(false);
if (!conceptHelper.addLinkHierarchicalRelation(conn, hierarchicalRelationship, idUser)) {
conn.rollback();
conn.close();
}
conn.commit();
conn.close();
}
} catch (SQLException ex) {
Logger.getLogger(WriteBranchSkosBDD.class.getName()).log(Level.SEVERE, null, ex);
}
// query.addRelation(id_terme, "NT", getId(relation.getTargetUri()), id_thesaurus);
break;
default:
break;
}
}
}
use of skos.SKOSRelation in project opentheso by miledrousset.
the class WriteBranchSkosBDD method writeRelationsList.
public void writeRelationsList(ArrayList<SKOSRelation> relationsList, String idConcept, String idThesaurus, int idUser) {
ConceptHelper conceptHelper = new ConceptHelper();
HierarchicalRelationship hierarchicalRelationship = new HierarchicalRelationship();
for (SKOSRelation relation : relationsList) {
switch(relation.getProperty()) {
case SKOSProperty.narrower:
hierarchicalRelationship.setIdConcept1(idConcept);
hierarchicalRelationship.setIdConcept2(getId(relation.getTargetUri()));
hierarchicalRelationship.setIdThesaurus(idThesaurus);
hierarchicalRelationship.setRole("NT");
try {
try (Connection conn = ds.getConnection()) {
conn.setAutoCommit(false);
if (!conceptHelper.addLinkHierarchicalRelation(conn, hierarchicalRelationship, idUser)) {
conn.rollback();
conn.close();
}
conn.commit();
conn.close();
}
} catch (SQLException ex) {
Logger.getLogger(WriteBranchSkosBDD.class.getName()).log(Level.SEVERE, null, ex);
}
// query.addRelation(id_terme, "NT", getId(relation.getTargetUri()), id_thesaurus);
break;
case SKOSProperty.broader:
hierarchicalRelationship.setIdConcept1(idConcept);
hierarchicalRelationship.setIdConcept2(getId(relation.getTargetUri()));
hierarchicalRelationship.setIdThesaurus(idThesaurus);
hierarchicalRelationship.setRole("BT");
try {
try (Connection conn = ds.getConnection()) {
conn.setAutoCommit(false);
if (!conceptHelper.addLinkHierarchicalRelation(conn, hierarchicalRelationship, idUser)) {
conn.rollback();
conn.close();
}
conn.commit();
conn.close();
}
} catch (SQLException ex) {
Logger.getLogger(WriteBranchSkosBDD.class.getName()).log(Level.SEVERE, null, ex);
}
// query.addRelation(id_terme, "BT", getId(relation.getTargetUri()), id_thesaurus);
break;
default:
break;
}
}
}
Aggregations