Search in sources :

Example 91 with ConceptHelper

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

the class Rest method getConceptSkosArk.

/**
 * @param naan
 * @param ark
 * @return
 */
@Path("/skos/ark:/{naan}/{ark}")
@GET
@Produces("application/xml;charset=UTF-8")
public Response getConceptSkosArk(@PathParam("naan") String naan, @PathParam("ark") String ark) {
    String idTheso = new ConceptHelper().getIdThesaurusFromArkId(ds, naan + "/" + ark);
    if (idTheso == null) {
        ds.close();
        return Response.noContent().build();
    }
    if (!getStatusOfWebservices(idTheso)) {
        ds.close();
        return Response.status(Status.SERVICE_UNAVAILABLE).entity(messageJson()).type(MediaType.APPLICATION_JSON).build();
    }
    StringBuffer skos = conceptToSkosFromArk(naan + "/" + ark, idTheso);
    if (skos == null) {
        ds.close();
        return Response.ok(messageErreur()).header("Access-Control-Allow-Origin", "*").build();
    }
    if (skos.length() == 0) {
        ds.close();
        return Response.ok(messageEmptySkos()).header("Access-Control-Allow-Origin", "*").build();
    }
    ds.close();
    return Response.ok(skos.toString()).header("Access-Control-Allow-Origin", "*").build();
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 92 with ConceptHelper

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

the class GetAllArkTest method testExportAllDatas.

/**
 * Test of Get datas for SiteMap.
 */
@org.junit.Test
public void testExportAllDatas() {
    HikariDataSource conn = openConnexionPool();
    String idTheso = "TH_1";
    ConceptHelper conceptHelper = new ConceptHelper();
    ArrayList<NodeConceptArkId> allIds = conceptHelper.getAllConceptArkIdOfThesaurus(conn, idTheso);
    StringBuilder file = new StringBuilder();
    TermHelper termHelper = new TermHelper();
    NoteHelper noteHelper = new NoteHelper();
    ArrayList<NodeTermTraduction> nodeTermTraductions;
    String idTerme;
    ArrayList<NodeNote> nodeNote;
    boolean passed = false;
    boolean notePassed = false;
    String note = "";
    for (NodeConceptArkId ids : allIds) {
        file.append(ids.getIdConcept());
        file.append("\t");
        if (ids.getIdArk() == null || ids.getIdArk().isEmpty()) {
            file.append("");
        } else {
            file.append(ids.getIdArk().substring(ids.getIdArk().indexOf("/") + 1));
        }
        nodeTermTraductions = termHelper.getAllTraductionsOfConcept(conn, ids.getIdConcept(), idTheso);
        if (!nodeTermTraductions.isEmpty()) {
            for (NodeTermTraduction nodeTermTraduction : nodeTermTraductions) {
                if (nodeTermTraduction.getLang().equalsIgnoreCase("fr")) {
                    file.append("\t");
                    file.append(nodeTermTraduction.getLexicalValue());
                // file.append("(");
                // file.append(nodeTermTraduction.getLang());
                // file.append(")");
                }
            }
        }
        idTerme = termHelper.getIdTermOfConcept(conn, ids.getIdConcept(), idTheso);
        nodeNote = noteHelper.getListNotesTerm(conn, idTerme, idTheso, "fr");
        for (NodeNote nodeNote1 : nodeNote) {
            if (nodeNote1.getLang().equalsIgnoreCase("fr")) {
                if (nodeNote1.getNotetypecode().equalsIgnoreCase("definition")) {
                    note = nodeNote1.getLexicalvalue().replace('\r', ' ');
                    note = note.replace('\n', ' ');
                    if (!notePassed) {
                        file.append("\t");
                    } else {
                        file.append(" ## ");
                    }
                    file.append(note);
                    passed = true;
                    notePassed = true;
                }
            }
        }
        if (!passed) {
            file.append("\t");
            file.append(" ");
        }
        passed = false;
        notePassed = false;
        file.append("\n");
    }
    System.out.println(file.toString());
    conn.close();
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NoteHelper(mom.trd.opentheso.bdd.helper.NoteHelper) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) NodeConceptArkId(mom.trd.opentheso.bdd.helper.nodes.NodeConceptArkId) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 93 with ConceptHelper

use of mom.trd.opentheso.bdd.helper.ConceptHelper 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 94 with ConceptHelper

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

the class ExportRdf4jHelper method addFilsConceptRecursif.

private void addFilsConceptRecursif(String idThesaurus, String idPere, SKOSResource sKOSResource, DownloadBean downloadBean, List<NodeLang> selectedLanguages) {
    ConceptHelper conceptHelper = new ConceptHelper();
    ArrayList<String> listIdsOfConceptChildren = conceptHelper.getListChildrenOfConcept(ds, idPere, idThesaurus);
    writeConceptInfo(conceptHelper, sKOSResource, idThesaurus, idPere, downloadBean, selectedLanguages);
    for (String idOfConceptChildren : listIdsOfConceptChildren) {
        sKOSResource = new SKOSResource();
        // writeConceptInfo(conceptHelper, concept, idThesaurus, idOfConceptChildren, downloadBean, selectedLanguages);
        // if (conceptHelper.haveChildren(ds, idThesaurus, idOfConceptChildren)) {
        addFilsConceptRecursif(idThesaurus, idOfConceptChildren, sKOSResource, downloadBean, selectedLanguages);
    // }
    }
}
Also used : SKOSResource(mom.trd.opentheso.skosapi.SKOSResource) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper)

Example 95 with ConceptHelper

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

the class ThesaurusDatas method exportAllDatas.

/**
 * permet de récupérer toutes les données d'un thésaurus
 * puis les chargées dans les variables de la classe
 *
 * @param ds
 * @param idThesaurus
 * @return
 */
public boolean exportAllDatas(HikariDataSource ds, String idThesaurus) {
    // récupération du thésaurus
    this.nodeThesaurus = new ThesaurusHelper().getNodeThesaurus(ds, idThesaurus);
    // récupération des groupes
    ArrayList<String> idGroups = new GroupHelper().getListIdOfGroup(ds, idThesaurus);
    for (String idGroup : idGroups) {
        this.nodeGroupLabels.add(new GroupHelper().getNodeGroupLabel(ds, idGroup, idThesaurus));
    // System.out.println("idGroup = : " + idGroup);
    }
    // récupération des ids des Tops Concepts
    nodeTTs = new ConceptHelper().getAllListIdsOfTopConcepts(ds, idThesaurus);
    // récupération de tous les concepts
    for (NodeTT nodeTT1 : nodeTTs) {
        new ConceptHelper().exportAllConcepts(ds, nodeTT1.getIdConcept(), idThesaurus, nodeConceptExports);
    }
    return true;
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) NodeTT(mom.trd.opentheso.bdd.helper.nodes.NodeTT) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Aggregations

ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)125 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)38 SQLException (java.sql.SQLException)36 Connection (java.sql.Connection)29 ArrayList (java.util.ArrayList)28 FacesMessage (javax.faces.application.FacesMessage)23 Concept (mom.trd.opentheso.bdd.datas.Concept)18 AlignmentHelper (mom.trd.opentheso.bdd.helper.AlignmentHelper)16 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)16 Term (mom.trd.opentheso.bdd.datas.Term)15 PrefixString (com.k_int.IR.QueryModels.PrefixString)14 RelationsHelper (mom.trd.opentheso.bdd.helper.RelationsHelper)14 HierarchicalRelationship (mom.trd.opentheso.bdd.datas.HierarchicalRelationship)13 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)12 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)12 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)12 HashMap (java.util.HashMap)9 MyTreeNode (mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)9 NodeConceptExport (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport)9 NodeTerm (mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm)9