Search in sources :

Example 1 with NodeGroupLabel

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

the class ExportFromBDD_Frantiq method exportThesaurus.

/**
 * Fonction récursive permettant d'exporter le thésaurus de la tête jusqu'au
 * dernier descripteur
 *
 * @param ds
 * @param idThesaurus
 * @return
 */
public StringBuffer exportThesaurus(HikariDataSource ds, String idThesaurus) {
    /*
         * Ecriture du thésaurus
         */
    ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
    NodeThesaurus nodeThesaurus = thesaurusHelper.getNodeThesaurus(ds, idThesaurus);
    WriteFileSKOS_Frantiq writeFileSKOS = new WriteFileSKOS_Frantiq();
    // inititialisation des URI
    writeFileSKOS.setServerArk(serverArk);
    writeFileSKOS.setServerAdress(serverAdress);
    writeFileSKOS.writeHeader();
    String idArk = thesaurusHelper.getIdArkOfThesaurus(ds, idThesaurus);
    if (idArk == null || idArk.trim().isEmpty()) {
        writeFileSKOS.setURI(serverAdress);
    } else {
        writeFileSKOS.setURI(serverArk);
    }
    // writeFileSKOS.setURI("http://opentheso.frantiq.fr/" + nodeThesaurus.getListThesaurusTraduction().get(0).getTitle());
    // thesaurus.description);
    writeFileSKOS.writeThesaurus(nodeThesaurus);
    // ecriture des TopConcept
    GroupHelper conceptGroupHelper = new GroupHelper();
    ArrayList<String> tabIdGroup = conceptGroupHelper.getListIdOfGroup(ds, idThesaurus);
    for (String tabIdGroup1 : tabIdGroup) {
        writeFileSKOS.writeTopConcepts(tabIdGroup1);
    }
    writeFileSKOS.writeEndOfMicroThesaurusList();
    // fin du bloc thésaurus et id of TopConcept
    // écriture des Domaines et Descripteurs avec traductions
    ArrayList<NodeUri> idOfTopConcept;
    for (String tabIdGroup1 : tabIdGroup) {
        NodeGroupLabel nodeGroupLabel = conceptGroupHelper.getNodeGroupLabel(ds, tabIdGroup1, idThesaurus);
        idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, tabIdGroup1, idThesaurus);
        writeFileSKOS.writeGroup(nodeGroupLabel, idOfTopConcept);
    }
    for (String tabIdGroup1 : tabIdGroup) {
        idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, tabIdGroup1, idThesaurus);
        for (NodeUri idOfTopConcept1 : idOfTopConcept) {
            exportAllConcepts(ds, idOfTopConcept1.getIdConcept(), idThesaurus, writeFileSKOS);
        }
    }
    writeFileSKOS.endSkos();
    return writeFileSKOS.getSkosBuff();
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) NodeGroupLabel(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 2 with NodeGroupLabel

use of mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel 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 3 with NodeGroupLabel

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

the class GroupHelper method getNodeGroupLabel.

/**
 * Permet de retourner un NodeGroupLable des Labels d'un Group / idThesaurus
 * Ce qui représente un domaine d'un thésaurus avec toutes les traductions
 *
 * @param ds le pool de connexion
 * @param idConceptGroup
 * @param idThesaurus
 * @return Objet ArrayLis ConceptGroupLabel
 */
public NodeGroupLabel getNodeGroupLabel(HikariDataSource ds, String idConceptGroup, String idThesaurus) {
    NodeGroupLabel nodeGroupLabel = new NodeGroupLabel();
    nodeGroupLabel.setIdGroup(idConceptGroup);
    nodeGroupLabel.setIdThesaurus(idThesaurus);
    nodeGroupLabel.setNodeGroupTraductionses(getAllGroupTraduction(ds, idConceptGroup, idThesaurus));
    return nodeGroupLabel;
}
Also used : NodeGroupLabel(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel)

Example 4 with NodeGroupLabel

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

the class ExportRdf4jHelper method writeGroupInfo.

private void writeGroupInfo(SKOSResource sKOSResource, String idThesaurus, String idOfGroupChildren, List<NodeLang> selectedLanguages) {
    NodeGroupLabel nodeGroupLabel;
    nodeGroupLabel = new GroupHelper().getNodeGroupLabel(ds, idOfGroupChildren, idThesaurus);
    sKOSResource.setUri(getUriFromId(idOfGroupChildren));
    sKOSResource.setProperty(SKOSProperty.ConceptGroup);
    for (NodeGroupTraductions traduction : nodeGroupLabel.getNodeGroupTraductionses()) {
        boolean isInSelectedLanguages = false;
        for (NodeLang nodeLang : selectedLanguages) {
            if (nodeLang.getCode().equals(traduction.getIdLang())) {
                isInSelectedLanguages = true;
                break;
            }
        }
        if (!isInSelectedLanguages) {
            continue;
        }
        sKOSResource.addLabel(traduction.getTitle(), traduction.getIdLang(), SKOSProperty.prefLabel);
        // dates
        String created;
        String modified;
        created = traduction.getCreated().toString();
        modified = traduction.getModified().toString();
        if (created != null) {
            sKOSResource.addDate(created, SKOSProperty.created);
        }
        if (modified != null) {
            sKOSResource.addDate(modified, SKOSProperty.modified);
        }
    }
    ArrayList<String> childURI = new GroupHelper().getListGroupChildIdOfGroup(ds, idOfGroupChildren, idThesaurus);
    ArrayList<NodeUri> nodeUris = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, idOfGroupChildren, idThesaurus);
    for (NodeUri nodeUri : nodeUris) {
        sKOSResource.addRelation(getUriFromNodeUri(nodeUri, idThesaurus), SKOSProperty.member);
        addMember(nodeUri.getIdConcept(), idThesaurus, sKOSResource);
    }
    for (String id : childURI) {
        sKOSResource.addRelation(getUriFromId(id), SKOSProperty.subGroup);
        superGroupHashMap.put(id, idOfGroupChildren);
    }
    // addNotes(idOfGroupChildren, group, selectedLanguages);
    // addGPS(idOfGroupChildren, group);
    // addAlignement(idOfGroupChildren, group);
    // addRelation(idOfGroupChildren, group);
    String idSuperGroup = superGroupHashMap.get(idOfGroupChildren);
    if (idSuperGroup != null) {
        sKOSResource.addRelation(getUriFromId(idSuperGroup), SKOSProperty.superGroup);
        superGroupHashMap.remove(idOfGroupChildren);
    }
    skosXmlDocument.addGroup(sKOSResource);
    // liste top concept
    nodeTTs.addAll(nodeUris);
    for (NodeUri topConcept : nodeTTs) {
        skosXmlDocument.getConceptScheme().addRelation(getUriFromNodeUri(topConcept, idThesaurus), SKOSProperty.hasTopConcept);
    }
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NodeGroupLabel(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroupTraductions(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions)

Example 5 with NodeGroupLabel

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

the class ExportTabulateHelper method writeGroups.

private boolean writeGroups() {
    ArrayList<NodeGroupLabel> nodeGroupLabel = thesaurusDatas.getNodeGroupLabels();
    boolean first;
    for (NodeGroupLabel nodeGroupLabel1 : nodeGroupLabel) {
        // idGroup
        tabulateBuff.append(nodeGroupLabel1.getIdGroup());
        tabulateBuff.append(";");
        // idArk
        if (nodeGroupLabel1.getIdArk() == null) {
            tabulateBuff.append("");
        } else {
            tabulateBuff.append(nodeGroupLabel1.getIdArk());
        }
        tabulateBuff.append(";");
        // type
        tabulateBuff.append("MT");
        tabulateBuff.append(";");
        // preflabel
        first = true;
        for (NodeGroupTraductions nodeGroupTraduction : nodeGroupLabel1.getNodeGroupTraductionses()) {
            if (!first) {
                tabulateBuff.append("##");
            }
            tabulateBuff.append(nodeGroupTraduction.getTitle());
            tabulateBuff.append("::");
            tabulateBuff.append(nodeGroupTraduction.getIdLang());
            first = false;
        }
        tabulateBuff.append(";");
        // altLabel
        tabulateBuff.append(";");
        // inScheme
        tabulateBuff.append(";");
        // broader
        tabulateBuff.append(";");
        // narrower
        tabulateBuff.append(";");
        // related
        tabulateBuff.append(";");
        // alignment
        tabulateBuff.append(";");
        // definition
        tabulateBuff.append(";");
        // scopeNote
        tabulateBuff.append(";");
        // historyNote
        tabulateBuff.append(";");
        // editorialNote
        tabulateBuff.append(";");
        // createdDate
        for (NodeGroupTraductions nodeGroupTraduction : nodeGroupLabel1.getNodeGroupTraductionses()) {
            tabulateBuff.append(nodeGroupTraduction.getCreated());
        }
        tabulateBuff.append(";");
        // modifiedDdate
        for (NodeGroupTraductions nodeGroupTraduction : nodeGroupLabel1.getNodeGroupTraductionses()) {
            tabulateBuff.append(nodeGroupTraduction.getModified());
        }
        tabulateBuff.append("\n");
    }
    return true;
}
Also used : NodeGroupLabel(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel) NodeGroupTraductions(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions)

Aggregations

NodeGroupLabel (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel)10 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)8 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)8 NodeUri (mom.trd.opentheso.bdd.helper.nodes.NodeUri)8 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)3 NodeThesaurus (mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus)3 NodeGroupTraductions (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions)2 NodeLang (mom.trd.opentheso.bdd.helper.nodes.NodeLang)1 NodeGroup (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)1