Search in sources :

Example 1 with SKOSRelation

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;
        }
    }
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) HierarchicalRelationship(mom.trd.opentheso.bdd.datas.HierarchicalRelationship) SQLException(java.sql.SQLException) Connection(java.sql.Connection) SKOSRelation(skos.SKOSRelation)

Example 2 with SKOSRelation

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;
        }
    }
}
Also used : ConceptGroupLabel(mom.trd.opentheso.bdd.datas.ConceptGroupLabel) SKOSRelation(skos.SKOSRelation) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 3 with SKOSRelation

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);
}
Also used : SKOSRelation(skos.SKOSRelation)

Example 4 with SKOSRelation

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;
        }
    }
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) HierarchicalRelationship(mom.trd.opentheso.bdd.datas.HierarchicalRelationship) SQLException(java.sql.SQLException) Connection(java.sql.Connection) SKOSRelation(skos.SKOSRelation)

Example 5 with SKOSRelation

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;
        }
    }
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) HierarchicalRelationship(mom.trd.opentheso.bdd.datas.HierarchicalRelationship) SQLException(java.sql.SQLException) Connection(java.sql.Connection) SKOSRelation(skos.SKOSRelation)

Aggregations

SKOSRelation (skos.SKOSRelation)11 Connection (java.sql.Connection)5 SQLException (java.sql.SQLException)5 HierarchicalRelationship (mom.trd.opentheso.bdd.datas.HierarchicalRelationship)5 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)5 ArrayList (java.util.ArrayList)2 ConceptGroupLabel (mom.trd.opentheso.bdd.datas.ConceptGroupLabel)1 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)1 StringPlus (mom.trd.opentheso.bdd.tools.StringPlus)1 SKOSResource (skos.SKOSResource)1