use of mom.trd.opentheso.bdd.helper.ThesaurusHelper in project opentheso by miledrousset.
the class CurrentUser method getThesaurusPreferences.
/**
* cette fonction permet de retourner les préférences d'un thésaurus, s'il y
* en a pas, on les initialises par les valeurs par defaut
*
* @param idThesaurus
* @param workLanguage
* @return
*/
public NodePreference getThesaurusPreferences(String idThesaurus, String workLanguage) {
if (user.getId() == 1) {
// superAdmin
authorizedTheso = new ThesaurusHelper().getAllIdOfThesaurus(connect.getPoolConnexion());
} else {
authorizedTheso = new UserHelper().getAuthorizedThesaurus(connect.getPoolConnexion(), user.getId());
}
PreferencesHelper preferencesHelper = new PreferencesHelper();
if (connect.getPoolConnexion() != null) {
nodePreference = preferencesHelper.getThesaurusPreference(connect.getPoolConnexion(), idThesaurus);
if (nodePreference == null) {
// cas où il n'y a pas de préférence pour ce thésaurus, il faut les créer
preferencesHelper.initPreferences(connect.getPoolConnexion(), idThesaurus, workLanguage);
nodePreference = preferencesHelper.getThesaurusPreference(connect.getPoolConnexion(), idThesaurus);
} else {
langSourceEdit = nodePreference.getSourceLang();
// alertNbCdtEdit = nodePreference.getNbAlertCdt();
// alertCdtEdit = nodePreference.isAlertCdt();
selectedThesaurus = new ArrayList<>();
selectedThesaurus.add(idTheso);
}
idTheso = idThesaurus;
versionOfOpentheso = new BaseDeDoneesHelper().getVersionOfOpentheso(connect.getPoolConnexion());
return nodePreference;
}
return null;
}
use of mom.trd.opentheso.bdd.helper.ThesaurusHelper in project opentheso by miledrousset.
the class ExportRdf4jHelper method addThesaurus.
public void addThesaurus(String idThesaurus, List<NodeLang> selectedLanguages) {
nodeThesaurus = new ThesaurusHelper().getNodeThesaurus(ds, idThesaurus);
String uri = getUriFromId(nodeThesaurus.getIdThesaurus());
SKOSResource conceptScheme = new SKOSResource(uri, SKOSProperty.ConceptScheme);
idTheso = nodeThesaurus.getIdThesaurus();
String creator;
String contributor;
String title;
String language;
for (Thesaurus thesaurus : nodeThesaurus.getListThesaurusTraduction()) {
boolean isInSelectedLanguages = false;
for (NodeLang nodeLang : selectedLanguages) {
if (nodeLang.getCode().equals(thesaurus.getLanguage())) {
isInSelectedLanguages = true;
break;
}
}
if (!isInSelectedLanguages) {
break;
}
creator = thesaurus.getCreator();
contributor = thesaurus.getContributor();
title = thesaurus.getTitle();
language = thesaurus.getLanguage();
/*[...]*/
if (creator != null && !creator.equalsIgnoreCase("null")) {
conceptScheme.addCreator(creator, SKOSProperty.creator);
}
if (contributor != null && !contributor.equalsIgnoreCase("null")) {
conceptScheme.addCreator(creator, SKOSProperty.contributor);
}
if (title != null && language != null) {
conceptScheme.addLabel(title, language, SKOSProperty.prefLabel);
}
// dates
String created = thesaurus.getCreated().toString();
String modified = thesaurus.getModified().toString();
if (created != null) {
conceptScheme.addDate(created, SKOSProperty.created);
}
if (modified != null) {
conceptScheme.addDate(modified, SKOSProperty.modified);
}
}
skosXmlDocument.setConceptScheme(conceptScheme);
}
use of mom.trd.opentheso.bdd.helper.ThesaurusHelper 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
* en filrant par langue et Groupe
*
* @param ds
* @param idThesaurus
* @param selectedLanguages
* @param selectedGroups
* @return
*/
public boolean exportAllDatas(HikariDataSource ds, String idThesaurus, List<NodeLang> selectedLanguages, List<NodeGroup> selectedGroups) {
// récupération du thésaurus
this.nodeThesaurus = new ThesaurusHelper().getNodeThesaurus(ds, idThesaurus);
// ArrayList<String> idGroups = new GroupHelper().getListIdOfGroup(ds, idThesaurus);
for (NodeGroup nodeGroup : selectedGroups) {
this.nodeGroupLabels.add(new GroupHelper().getNodeGroupLabel(ds, nodeGroup.getConceptGroup().getIdgroup(), idThesaurus));
// System.out.println("idGroup = : " + idGroup);
}
// récupération des ids des Tops Concepts
// nodeTTs = new ConceptHelper().getAllListIdsOfTopConcepts(ds, idThesaurus);
ArrayList<String> listTopConcept;
for (NodeGroup nodeGroup : selectedGroups) {
listTopConcept = new ConceptHelper().getListIdsOfTopConcepts(ds, nodeGroup.getConceptGroup().getIdgroup(), idThesaurus);
// récupération de tous les concepts
for (String idTop : listTopConcept) {
new ConceptHelper().exportAllConcepts(ds, idTop, idThesaurus, nodeConceptExports);
}
}
return true;
}
use of mom.trd.opentheso.bdd.helper.ThesaurusHelper in project opentheso by miledrousset.
the class ImportSkosHelper method addLangsToThesaurus.
private void addLangsToThesaurus(HikariDataSource ds, String idThesaurus) {
ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
Thesaurus thesaurus2 = new Thesaurus();
ArrayList<String> tabListLang = thesaurusHelper.getAllUsedLanguagesOfThesaurus(ds, idThesaurus);
for (String tabListLang1 : tabListLang) {
if (!thesaurusHelper.isLanguageExistOfThesaurus(ds, idThesaurus, tabListLang1)) {
thesaurus2.setId_thesaurus(idThesaurus);
thesaurus2.setContributor("");
thesaurus2.setCoverage("");
thesaurus2.setCreator("");
thesaurus2.setDescription("");
thesaurus2.setFormat("");
thesaurus2.setLanguage(tabListLang1);
thesaurus2.setPublisher("");
thesaurus2.setRelation("");
thesaurus2.setRights("");
thesaurus2.setSource("");
thesaurus2.setSubject("");
thesaurus2.setTitle("theso_" + idThesaurus);
thesaurus2.setType("");
thesaurusHelper.addThesaurusTraduction(ds, thesaurus2);
}
}
}
use of mom.trd.opentheso.bdd.helper.ThesaurusHelper in project opentheso by miledrousset.
the class ImportSkosHelper method addThesaurus.
/**
* Fonction qui permet d'importer les informations d'un thésaurus
* @return
*/
public boolean addThesaurus() {
ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
idGroupDefault = getNewId();
for (SKOSConceptScheme scheme : dataSet.getSKOSConceptSchemes()) {
// récupération du nom de thésaurus
thesaurus.setTitle(getIdFromUri(scheme.getURI().toString()));
conceptsCount = dataSet.getSKOSConcepts().size();
for (SKOSAnnotation anno : scheme.getSKOSAnnotations(dataSet)) {
if (anno.isAnnotationByConstant()) {
if (anno.getAnnotationValueAsConstant().isTyped()) {
SKOSTypedLiteral con = anno.getAnnotationValueAsConstant().getAsSKOSTypedLiteral();
// System.err.print(con.getLiteral() + " Type: " + con.getDataType().getURI());
} else {
SKOSUntypedLiteral con = anno.getAnnotationValueAsConstant().getAsSKOSUntypedLiteral();
if (anno.getURI().toString().contains("title")) {
DcElement dcElement = new DcElement();
dcElement.setName("title");
dcElement.setValue(con.getLiteral());
if (con.hasLang()) {
dcElement.setLanguage(con.getLang());
} else
dcElement.setLanguage(langueSource);
thesaurus.addDcElement(dcElement);
} else {
DcElement dcElement = new DcElement();
dcElement.setName("title");
dcElement.setValue(con.getLiteral());
if (con.hasLang()) {
dcElement.setLanguage(con.getLang());
} else
dcElement.setLanguage(langueSource);
thesaurus.addDcElement(dcElement);
}
}
// * created or date;
// if(anno.getURI().getPath().contains("date") ){
// getThesaurusAnnotation(anno);
// }
// // * modified;
// if(anno.getURI().getPath().contains("modified") ){
// getThesaurusAnnotation(anno);
// }
// * @param coverage
// * @param creator
// * @param description
// * @param format
// * @param id_langue
// * @param publisher
// * @param relation
// * @param rights
// * @param source
// * @param subject
// * @param title
// * @param type
} else // la liste des TopConcept
{
idTopConcept.add(getIdFromUri(anno.getAnnotationValue().getURI().toString()));
// System.err.println(anno.getAnnotationValue().getURI().toString());
}
}
if (!addThesaurusToBdd(thesaurusHelper)) {
return false;
}
if (thesaurus.getDcElement().isEmpty()) {
if (thesaurus.getTitle().isEmpty()) {
thesaurus.setTitle("theso_" + thesaurus.getId_thesaurus());
} else {
thesaurus.setTitle(thesaurus.getTitle());
}
thesaurus.setLanguage(langueSource);
thesaurusHelper.addThesaurusTraduction(ds, thesaurus);
} else {
for (DcElement dcElement : thesaurus.getDcElement()) {
thesaurus.setTitle(dcElement.getValue());
thesaurus.setLanguage(dcElement.getLanguage());
thesaurusHelper.addThesaurusTraduction(ds, thesaurus);
}
}
return true;
}
return false;
}
Aggregations