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