Search in sources :

Example 1 with ThesaurusHelper

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;
}
Also used : UserHelper(mom.trd.opentheso.bdd.helper.UserHelper) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) BaseDeDoneesHelper(mom.trd.opentheso.bdd.helper.BaseDeDoneesHelper) PreferencesHelper(mom.trd.opentheso.bdd.helper.PreferencesHelper)

Example 2 with ThesaurusHelper

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);
}
Also used : SKOSResource(mom.trd.opentheso.skosapi.SKOSResource) Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang)

Example 3 with ThesaurusHelper

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;
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 4 with ThesaurusHelper

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);
        }
    }
}
Also used : Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper)

Example 5 with ThesaurusHelper

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;
}
Also used : SKOSTypedLiteral(org.semanticweb.skos.SKOSTypedLiteral) DcElement(mom.trd.opentheso.bdd.datas.DcElement) SKOSUntypedLiteral(org.semanticweb.skos.SKOSUntypedLiteral) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) SKOSConceptScheme(org.semanticweb.skos.SKOSConceptScheme) SKOSAnnotation(org.semanticweb.skos.SKOSAnnotation)

Aggregations

ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)31 Thesaurus (mom.trd.opentheso.bdd.datas.Thesaurus)10 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)9 FacesMessage (javax.faces.application.FacesMessage)7 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)7 UserHelper (mom.trd.opentheso.bdd.helper.UserHelper)6 NodeThesaurus (mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus)6 Connection (java.sql.Connection)5 SQLException (java.sql.SQLException)5 NodeGroup (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)4 LanguageHelper (mom.trd.opentheso.bdd.helper.LanguageHelper)3 NodeUri (mom.trd.opentheso.bdd.helper.nodes.NodeUri)3 NodeGroupLabel (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel)3 FacesContext (javax.faces.context.FacesContext)2 BaseDeDoneesHelper (mom.trd.opentheso.bdd.helper.BaseDeDoneesHelper)2 MyTreeNode (mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)2 NodeLang (mom.trd.opentheso.bdd.helper.nodes.NodeLang)2 SKOSResource (mom.trd.opentheso.skosapi.SKOSResource)2 Concept (mom.trd.opentheso.bdd.datas.Concept)1 DcElement (mom.trd.opentheso.bdd.datas.DcElement)1