use of mom.trd.opentheso.bdd.datas.Thesaurus in project opentheso by miledrousset.
the class SelectedThesaurus method ajouterTraduction.
/**
* Création d'une traduction d'un thésaurus
*/
public void ajouterTraduction() {
if (nomTrad.trim().equals("")) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error1")));
} else {
vue.setTrad(false);
String id = editTheso.getId_thesaurus();
Thesaurus thesoTemp = new Thesaurus();
thesoTemp.setId_thesaurus(id);
thesoTemp.setLanguage(langueTrad);
thesoTemp.setTitle(nomTrad);
new ThesaurusHelper().addThesaurusTraduction(connect.getPoolConnexion(), thesoTemp);
remplirArrayTrad(editTheso.getId_thesaurus());
}
nomTrad = "";
}
use of mom.trd.opentheso.bdd.datas.Thesaurus in project opentheso by miledrousset.
the class WriteSkosBDD method addLangsToThesaurus.
public void addLangsToThesaurus(HikariDataSource ds, String idThesaurus) {
ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
ArrayList<String> tabListLang = thesaurusHelper.getAllUsedLanguagesOfThesaurus(ds, idThesaurus);
for (int i = 0; i < tabListLang.size(); i++) {
if (!thesaurusHelper.isLanguageExistOfThesaurus(ds, idThesaurus, tabListLang.get(i).trim())) {
Thesaurus thesaurus = new Thesaurus();
thesaurus.setId_thesaurus(idThesaurus);
thesaurus.setContributor("");
thesaurus.setCoverage("");
thesaurus.setCreator("");
thesaurus.setDescription("");
thesaurus.setFormat("");
thesaurus.setLanguage(tabListLang.get(i));
thesaurus.setPublisher("");
thesaurus.setRelation("");
thesaurus.setRights("");
thesaurus.setSource("");
thesaurus.setSubject("");
thesaurus.setTitle("theso_" + idThesaurus);
thesaurus.setType("");
thesaurusHelper.addThesaurusTraduction(ds, thesaurus);
}
}
}
use of mom.trd.opentheso.bdd.datas.Thesaurus in project opentheso by miledrousset.
the class WriteSkosBDD method writeThesaurus.
public void writeThesaurus(SKOSXmlDocument skosDocument, String dateFormat, boolean useArk, String adressSite, int idUser, String langueSource) {
SKOSConceptScheme conceptScheme = skosDocument.getConceptScheme();
ArrayList<SKOSTopConcept> topConceptsList = conceptScheme.getTopConceptsList();
ArrayList<SKOSResource> resourcesList = skosDocument.getResourcesList();
/*
* Création du Thésaurus
*/
String descriptionThesaurus = getThesaurusName(conceptScheme.getUri());
// if(!query.thesaurusExistLangue(descriptionThesaurus, id_langueSource)) {
ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
Thesaurus thesaurus = new Thesaurus();
thesaurus.setTitle(descriptionThesaurus);
thesaurus.setLanguage(langueSource);
String idThesaurus = thesaurusHelper.addThesaurus(ds, thesaurus, adressSite, useArk);
if (idThesaurus == null)
return;
thesaurus.setId_thesaurus(idThesaurus);
try {
Connection conn = ds.getConnection();
conn.setAutoCommit(false);
UserHelper userHelper = new UserHelper();
int idRole = userHelper.getRoleOfUser(ds, idUser);
if (!userHelper.addRole(conn, idUser, idRole, idThesaurus, "")) {
conn.rollback();
conn.close();
return;
}
conn.commit();
conn.close();
} catch (SQLException ex) {
Logger.getLogger(WriteSkosBDD.class.getName()).log(Level.SEVERE, null, ex);
}
// Si le Titre du thésaurus n'est pas detecter, on donne un nom par defaut
if (conceptScheme.getSkosLabels().isEmpty()) {
if (thesaurus.getTitle().isEmpty()) {
thesaurus.setTitle("Theso_" + idThesaurus);
thesaurusHelper.addThesaurusTraduction(ds, thesaurus);
}
}
for (SKOSLabel skosLabel : conceptScheme.getSkosLabels()) {
thesaurus.setTitle(skosLabel.getLabel());
thesaurus.setLanguage(skosLabel.getLanguage());
thesaurusHelper.addThesaurusTraduction(ds, thesaurus);
}
idsTopConcept = new ArrayList<>();
for (SKOSResource resource : resourcesList) {
if (resource != null) {
if (!isDescriptor(resource, topConceptsList)) {
// on insère un domaine
writeDomaine(resource, idThesaurus, "fr", adressSite, useArk, idUser);
} else {
// on insère un concept
writeConcept(resource, idThesaurus, "fr", dateFormat, adressSite, useArk, idUser);
}
}
}
// ici la fin du fichier on controle si le thésaurus a toutes les langues des concepts
// Vérifier l'existence de la langue et l'ajouter si elle n'existe pas déjà
addLangsToThesaurus(ds, idThesaurus);
}
use of mom.trd.opentheso.bdd.datas.Thesaurus in project opentheso by miledrousset.
the class ImportRdf4jHelper method addThesaurus.
/**
* Cette fonction permet de créer un thésaurus avec ses traductions (Import)
* elle retourne l'identifiant du thésaurus, sinon Null
*
* @return
* @throws java.sql.SQLException
*/
public String addThesaurus() throws SQLException {
thesaurus = new Thesaurus();
SKOSResource conceptScheme = skosXmlDocument.getConceptScheme();
String creator = null;
String contributor = null;
for (SKOSCreator c : conceptScheme.getCreatorList()) {
if (c.getProperty() == SKOSProperty.creator) {
creator = c.getCreator();
} else if (c.getProperty() == SKOSProperty.contributor) {
contributor = c.getCreator();
}
}
thesaurus.setCreator(creator);
thesaurus.setContributor(contributor);
ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
thesaurusHelper.setIdentifierType("2");
Connection conn = ds.getConnection();
conn.setAutoCommit(false);
String idTheso1;
if (thesaurus.getLanguage() == null) {
thesaurus.setLanguage(langueSource);
}
if ((idTheso1 = thesaurusHelper.addThesaurusRollBack(conn, adressSite, useArk)) == null) {
conn.rollback();
conn.close();
return null;
}
// Si le Titre du thésaurus n'est pas detecter, on donne un nom par defaut
if (skosXmlDocument.getConceptScheme().getLabelsList().isEmpty()) {
if (thesaurus.getTitle().isEmpty()) {
thesaurus.setTitle("theso_" + idTheso1);
// thesaurusHelper.addThesaurusTraduction(ds, thesaurus);
}
}
thesaurus.setId_thesaurus(idTheso1);
this.idTheso = idTheso1;
// boucler pour les traductions
for (SKOSLabel label : skosXmlDocument.getConceptScheme().getLabelsList()) {
if (thesaurus.getLanguage() == null) {
// test
String workLanguage = "fr";
thesaurus.setLanguage(workLanguage);
}
thesaurus.setTitle(label.getLabel());
thesaurus.setLanguage(label.getLanguage());
if (!thesaurusHelper.addThesaurusTraductionRollBack(conn, thesaurus)) {
conn.rollback();
conn.close();
return null;
}
}
UserHelper userHelper = new UserHelper();
if (!userHelper.addRole(conn, idUser, idRole, idTheso1, "")) {
conn.rollback();
conn.close();
return null;
}
conn.commit();
conn.close();
idGroupDefault = getNewGroupId();
for (SKOSRelation relation : skosXmlDocument.getConceptScheme().getRelationsList()) {
hasTopConcceptList.add(relation.getTargetUri());
}
return null;
}
use of mom.trd.opentheso.bdd.datas.Thesaurus in project opentheso by miledrousset.
the class ImportRdf4jHelper method addLangsToThesaurus.
public void addLangsToThesaurus(HikariDataSource ds, String idThesaurus) {
ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
ArrayList<String> tabListLang = thesaurusHelper.getAllUsedLanguagesOfThesaurus(ds, idThesaurus);
for (int i = 0; i < tabListLang.size(); i++) {
if (!thesaurusHelper.isLanguageExistOfThesaurus(ds, idThesaurus, tabListLang.get(i).trim())) {
Thesaurus thesaurus1 = new Thesaurus();
thesaurus1.setId_thesaurus(idThesaurus);
thesaurus1.setContributor("");
thesaurus1.setCoverage("");
thesaurus1.setCreator("");
thesaurus1.setDescription("");
thesaurus1.setFormat("");
thesaurus1.setLanguage(tabListLang.get(i));
thesaurus1.setPublisher("");
thesaurus1.setRelation("");
thesaurus1.setRights("");
thesaurus1.setSource("");
thesaurus1.setSubject("");
thesaurus1.setTitle("theso_" + idThesaurus);
thesaurus1.setType("");
thesaurusHelper.addThesaurusTraduction(ds, thesaurus1);
}
}
}
Aggregations