Search in sources :

Example 6 with NodeUri

use of mom.trd.opentheso.bdd.helper.nodes.NodeUri in project opentheso by miledrousset.

the class ExportFromBDD_Frantiq method exportThisGroup.

/**
 * Fonction permettant d'exporter un noeud Groupe (un seul identifiant group)
 *
 * @param ds
 * @param idThesaurus
 * @param idGroup
 * @return  Skos
 */
public StringBuffer exportThisGroup(HikariDataSource ds, String idThesaurus, String idGroup) {
    WriteFileSKOS writeFileSKOS = new WriteFileSKOS();
    // inititialisation des URI
    writeFileSKOS.setServerArk(serverArk);
    writeFileSKOS.setServerAdress(serverAdress);
    writeFileSKOS.writeHeader();
    // ecriture des TopConcept
    GroupHelper conceptGroupHelper = new GroupHelper();
    // écriture des Domaines et Descripteurs avec traductions
    NodeGroupLabel nodeGroupLabel = conceptGroupHelper.getNodeGroupLabel(ds, idGroup, idThesaurus);
    nodeGroupLabel.setIdArk(new GroupHelper().getIdArkOfGroup(ds, idGroup, idThesaurus));
    ArrayList<NodeUri> idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, idGroup, idThesaurus);
    writeFileSKOS.writeGroup(nodeGroupLabel, idOfTopConcept, null);
    writeFileSKOS.endSkos();
    return writeFileSKOS.getSkosBuff();
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NodeGroupLabel(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 7 with NodeUri

use of mom.trd.opentheso.bdd.helper.nodes.NodeUri in project opentheso by miledrousset.

the class WriteFileSKOS_Frantiq method writeGroup.

/**
 * @param nodeGroupLabel
 * @param listIdOfTopConcept
 *
 * @return true ou false
 */
public boolean writeGroup(NodeGroupLabel nodeGroupLabel, ArrayList<NodeUri> listIdOfTopConcept) {
    SKOSResource concept;
    // if(nodeGroupLabel.getIdArk() == null || nodeGroupLabel.getIdArk().trim().isEmpty()) {
    /*
            Cette partie est pour l'export des PACTOLS pour Frantiq
            */
    concept = new SKOSResource(serverAdress + "concept#" + nodeGroupLabel.getIdGroup());
    for (int i = 0; i < nodeGroupLabel.getNodeGroupTraductionses().size(); i++) {
        concept.addLabel(nodeGroupLabel.getNodeGroupTraductionses().get(i).getTitle(), nodeGroupLabel.getNodeGroupTraductionses().get(i).getIdLang(), SKOSProperty.prefLabel);
    }
    if (!nodeGroupLabel.getNodeGroupTraductionses().isEmpty()) {
        concept.addDate(nodeGroupLabel.getNodeGroupTraductionses().get(0).getCreated().toString(), SKOSProperty.created);
        concept.addDate(nodeGroupLabel.getNodeGroupTraductionses().get(0).getModified().toString(), SKOSProperty.modified);
    }
    if (!nodeGroupLabel.getIdGroup().isEmpty()) {
        concept.addIdentifier(nodeGroupLabel.getIdGroup(), SKOSProperty.identifier);
    }
    for (NodeUri listIdOfTopConcept1 : listIdOfTopConcept) {
        // if(listIdOfTopConcept1.getIdArk() == null || listIdOfTopConcept1.getIdArk().trim().isEmpty()) {
        concept.addRelation(URI + "concept#" + listIdOfTopConcept1.getIdConcept(), SKOSProperty.narrower);
    /*
                concept.addRelation(serverAdress +
                        "?idc=" + listIdOfTopConcept1.getIdConcept() +
                        "&amp;idt=" + nodeGroupLabel.getIdThesaurus(),
                        SKOSProperty.narrower);*/
    /*    }
            else {
                concept.addRelation(serverArk +
                    listIdOfTopConcept1.getIdArk(),
                    SKOSProperty.narrower);
            }*/
    }
    skosBuff.append("    ").append(concept.toString());
    return true;
}
Also used : SKOSResource(skos.SKOSResource) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri)

Example 8 with NodeUri

use of mom.trd.opentheso.bdd.helper.nodes.NodeUri in project opentheso by miledrousset.

the class RelationsHelper method getListNT.

/**
 * Cette fonction permet de récupérer la liste des Id des termes
 * spécifiques d'un concept avec les identifiants pérennes (Ark, Handle)
 * sert à l'export des données
 *
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @return Objet class Concept
 * #MR
 */
public ArrayList<NodeHieraRelation> getListNT(HikariDataSource ds, String idConcept, String idThesaurus) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<NodeHieraRelation> nodeListIdOfConcept = new ArrayList<>();
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "select id_concept2, role, id_ark, id_handle " + " from hierarchical_relationship as hr" + " left join concept as con on id_concept = id_concept2" + " and hr.id_thesaurus = con.id_thesaurus" + " where hr.id_thesaurus = '" + idThesaurus + "'" + " and id_concept1 = '" + idConcept + "'" + " and role LIKE 'NT%'";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                while (resultSet.next()) {
                    NodeHieraRelation nodeHieraRelation = new NodeHieraRelation();
                    NodeUri nodeUri = new NodeUri();
                    if ((resultSet.getString("id_ark") == null) || (resultSet.getString("id_ark").trim().isEmpty())) {
                        nodeUri.setIdArk("");
                    } else {
                        nodeUri.setIdArk(resultSet.getString("id_ark"));
                    }
                    if ((resultSet.getString("id_handle") == null) || (resultSet.getString("id_handle").trim().isEmpty())) {
                        nodeUri.setIdHandle("");
                    } else {
                        nodeUri.setIdHandle(resultSet.getString("id_handle"));
                    }
                    nodeUri.setIdConcept(resultSet.getString("id_concept2"));
                    nodeHieraRelation.setRole(resultSet.getString("role"));
                    nodeHieraRelation.setUri(nodeUri);
                    nodeListIdOfConcept.add(nodeHieraRelation);
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting Liste ID of NT Concept with ark and handle : " + idConcept, sqle);
    }
    return nodeListIdOfConcept;
}
Also used : NodeHieraRelation(mom.trd.opentheso.bdd.helper.nodes.NodeHieraRelation) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri)

Example 9 with NodeUri

use of mom.trd.opentheso.bdd.helper.nodes.NodeUri in project opentheso by miledrousset.

the class ConceptHelper method getMultiConceptForExport.

/**
 * Cette fonction permet de récupérer toutes les informations concernant un
 * ou plusieurs Concept par une chaîne de caractère, suivant le thésaurus,
 * la langue et le group
 *
 * @param ds
 * @param value
 * @param idThesaurus
 * @param idGroup
 * @param idLang
 * @param isArkActif
 * @return Objet class NodeConcept
 */
public ArrayList<NodeConceptExport> getMultiConceptForExport(HikariDataSource ds, String value, String idLang, String idGroup, String idThesaurus, boolean isArkActif) {
    ArrayList<NodeConceptExport> listNce = new ArrayList<>();
    // Récupération des concept
    ArrayList<NodeSearch> listRes = new SearchHelper().searchTerm(ds, value, idLang, idThesaurus, idGroup, 1, false);
    for (NodeSearch ns : listRes) {
        Concept concept = getThisConcept(ds, ns.getIdConcept(), idThesaurus);
        NodeConceptExport nce = new NodeConceptExport();
        nce.setConcept(concept);
        listNce.add(nce);
    }
    for (NodeConceptExport nce : listNce) {
        String idConcept = nce.getConcept().getIdConcept();
        RelationsHelper relationsHelper = new RelationsHelper();
        // récupération des BT
        ArrayList<NodeHieraRelation> nodeListIdOfBT_Ark = relationsHelper.getListBT(ds, idConcept, idThesaurus);
        nce.setNodeListOfBT(nodeListIdOfBT_Ark);
        // récupération des termes spécifiques
        ArrayList<NodeHieraRelation> nodeListIdOfNT_Ark = relationsHelper.getListNT(ds, idConcept, idThesaurus);
        nce.setNodeListOfNT(nodeListIdOfNT_Ark);
        // récupération des termes associés
        ArrayList<NodeHieraRelation> nodeListIdOfRT_Ark = relationsHelper.getListRT(ds, idConcept, idThesaurus);
        nce.setNodeListIdsOfRT(nodeListIdOfRT_Ark);
        // récupération des Non Prefered Term
        nce.setNodeEM(new TermHelper().getAllNonPreferredTerms(ds, new TermHelper().getIdTermOfConcept(ds, idConcept, idThesaurus), idThesaurus));
        // récupération des traductions
        nce.setNodeTermTraductions(new TermHelper().getAllTraductionsOfConcept(ds, idConcept, idThesaurus));
        // récupération des Groupes
        ArrayList<NodeUri> nodeListIdsOfConceptGroup_Ark = getListIdArkOfGroup(ds, new GroupHelper().getListIdGroupOfConcept(ds, idThesaurus, idConcept), idThesaurus);
        nce.setNodeListIdsOfConceptGroup(nodeListIdsOfConceptGroup_Ark);
        // récupération des notes du Terme
        String idTerm = new TermHelper().getIdTermOfConcept(ds, idConcept, idThesaurus);
        nce.setNodeNoteTerm(new NoteHelper().getListNotesTermAllLang(ds, idTerm, idThesaurus));
        // récupération des Notes du Concept
        nce.setNodeNoteConcept(new NoteHelper().getListNotesConceptAllLang(ds, idConcept, idThesaurus));
        // récupération des Alignements
        nce.setNodeAlignmentsList(new AlignmentHelper().getAllAlignmentOfConcept(ds, idConcept, idThesaurus));
    }
    return listNce;
}
Also used : NodeConcept(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept) Concept(mom.trd.opentheso.bdd.datas.Concept) NodeConceptExport(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport) ArrayList(java.util.ArrayList) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) NodeHieraRelation(mom.trd.opentheso.bdd.helper.nodes.NodeHieraRelation) NodeSearch(mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch)

Example 10 with NodeUri

use of mom.trd.opentheso.bdd.helper.nodes.NodeUri in project opentheso by miledrousset.

the class ConceptHelper method getListIdArkOfGroup.

/**
 * Cette fonction permet de récupérer les Id Ark d'une liste d'Identifiants
 * de Groups et les rajouter dans le tableau de NodeUri
 *
 * @param nodeListIdOfGroup
 * @param idThesaurus
 * @return ArrayList<NodeUri>
 */
private ArrayList<NodeUri> getListIdArkOfGroup(HikariDataSource ds, ArrayList<String> nodeListIdOfGroup, String idThesaurus) {
    ArrayList<NodeUri> nodeListIdOfGroup_idArk = new ArrayList<>();
    String idArk;
    for (String nodeListIdOfGroup1 : nodeListIdOfGroup) {
        idArk = new GroupHelper().getIdArkOfGroup(ds, nodeListIdOfGroup1, idThesaurus);
        NodeUri nodeUri = new NodeUri();
        if (idArk == null || idArk.trim().isEmpty()) {
            nodeUri.setIdArk("");
        } else {
            nodeUri.setIdArk(idArk);
        }
        nodeUri.setIdConcept(nodeListIdOfGroup1);
        nodeListIdOfGroup_idArk.add(nodeUri);
    }
    return nodeListIdOfGroup_idArk;
}
Also used : ArrayList(java.util.ArrayList) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri)

Aggregations

NodeUri (mom.trd.opentheso.bdd.helper.nodes.NodeUri)20 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)9 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)8 NodeGroupLabel (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel)8 ArrayList (java.util.ArrayList)5 NodeHieraRelation (mom.trd.opentheso.bdd.helper.nodes.NodeHieraRelation)4 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)3 NodeLang (mom.trd.opentheso.bdd.helper.nodes.NodeLang)3 NodeConceptExport (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport)3 NodeThesaurus (mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus)3 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 Statement (java.sql.Statement)2 Concept (mom.trd.opentheso.bdd.datas.Concept)2 NodeAlignment (mom.trd.opentheso.bdd.helper.nodes.NodeAlignment)2 NodeConcept (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept)2 SKOSResource (skos.SKOSResource)2 PrefixString (com.k_int.IR.QueryModels.PrefixString)1