Search in sources :

Example 86 with ConceptHelper

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

the class SelectedThesaurus method regenerateHAndleIdOfConcepts.

/**
 * Cette fonction regenère tous les idHandle des concepts du théso
 * puis met à jour les identifiants Handle
 */
private boolean regenerateHAndleIdOfConcepts(String idTheso, ArrayList<String> idConcepts) throws Exception {
    // récup les concepts
    ConceptHelper conceptHelper = new ConceptHelper();
    conceptHelper.setNodePreference(nodePreference);
    /*Vérification et génération des nouveaux id Ark*/
    for (String idConcept : idConcepts) {
        if (!conceptHelper.updateIdHandle(connect.getPoolConnexion(), idConcept, idTheso)) {
            throw new Exception("Error Handle :" + conceptHelper.getMessage());
        }
    }
    return true;
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) SQLException(java.sql.SQLException)

Example 87 with ConceptHelper

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

the class SelectedThesaurus method regenerateAllHandleId.

/**
 * Permet de vérifier si les Identifiants Handle sont valides s'ils n'existent
 * pas, on les ajoutes s'ils exient, on ne fait rien.
 *
 * @param idTheso #MR
 */
public void regenerateAllHandleId(String idTheso) {
    ConceptHelper conceptHelper = new ConceptHelper();
    try {
        ArrayList<String> idGroup = null;
        // concept
        try {
            ArrayList<String> idConcepts = conceptHelper.getAllIdConceptOfThesaurus(connect.getPoolConnexion(), idTheso);
            if (idConcepts == null || idConcepts.isEmpty()) {
                throw new Exception("No concept in this thesaurus");
            }
            regenerateHAndleIdOfConcepts(idTheso, idConcepts);
        } catch (Exception ex) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error while regen id concept:", ex.getMessage()));
            throw new Exception("Error while regen id concept ");
        }
        maj();
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Info :", "Regen id finished"));
    } catch (SQLException ex) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "SQL Error :", ex.getMessage()));
    } catch (Exception ex) {
    }
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) SQLException(java.sql.SQLException) FacesMessage(javax.faces.application.FacesMessage) SQLException(java.sql.SQLException)

Example 88 with ConceptHelper

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

the class Rest method getConceptJsonArk.

/**
 * retourne un concept à partir de son identifiant Ark
 *
 * @param naan
 * @param ark
 * @return
 */
@Path("/jsonld/ark:/{naan}/{ark}")
@GET
// @Produces("application/json")
@Produces("application/json;charset=UTF-8")
public Response getConceptJsonArk(@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(messageEmptyJson()).header("Access-Control-Allow-Origin", "*").build();
    }
    JsonHelper jsonHelper = new JsonHelper();
    SKOSXmlDocument sKOSXmlDocument = jsonHelper.readSkosDocument(skos);
    StringBuffer jsonLd = jsonHelper.getJsonLd(sKOSXmlDocument);
    ds.close();
    return Response.ok(jsonLd.toString()).header("Access-Control-Allow-Origin", "*").build();
// return jsonLd.toString();
}
Also used : JsonHelper(mom.trd.opentheso.core.jsonld.helper.JsonHelper) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) SKOSXmlDocument(skos.SKOSXmlDocument) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 89 with ConceptHelper

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

the class Rest method getBranchOfConceptSkosArk.

/**
 * Permet de renvoyer la branche complète en SKOS en partant d'un
 * identifiant ARK
 *
 * @param naan
 * @param ark
 * @return
 */
@Path("/skos/all/ark:/{naan}/{ark}")
@GET
@Produces("application/xml;charset=UTF-8")
public Response getBranchOfConceptSkosArk(@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 90 with ConceptHelper

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

the class Rest method brancheOfConceptsToSkosTop.

/**
 * Fonction qui permet de récupérer une branche complète en partant d'un
 * concept vers le haut
 *
 * @param idGroup
 * @param idThesaurus
 * @return skos
 */
private StringBuffer brancheOfConceptsToSkosTop(String idConcept, String idTheso) {
    if (ds == null) {
        return null;
    }
    nodePreference = new PreferencesHelper().getThesaurusPreference(ds, idTheso);
    if (nodePreference == null) {
        return null;
    }
    ArrayList<String> path = new ArrayList<>();
    ArrayList<ArrayList<String>> tabId = new ArrayList<>();
    ConceptHelper conceptHelper = new ConceptHelper();
    path.add(idConcept);
    tabId = conceptHelper.getPathOfConceptWithoutGroup(ds, idConcept, idTheso, path, tabId);
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerArk(nodePreference.getServeurArk());
    exportFromBDD.setServerAdress(nodePreference.getCheminSite());
    exportFromBDD.setNodePreference(nodePreference);
    StringBuffer skos = exportFromBDD.exportConceptByLot(ds, idTheso, tabId);
    return skos;
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ArrayList(java.util.ArrayList) ExportFromBDD(mom.trd.opentheso.core.exports.old.ExportFromBDD) PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper)

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