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;
}
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) {
}
}
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();
}
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();
}
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;
}
Aggregations