use of mom.trd.opentheso.skosapi.SKOSLabel in project opentheso by miledrousset.
the class rdf4jFileBean method insertCandidatesBDD.
/**
* insrt un thésaurus dans la BDD
*
* #### temporaire ###
* ### permet d'ajouter une liste de candidats d'après un fichier SKOS ####
*/
public void insertCandidatesBDD() {
error = new StringBuffer();
info = "";
warning = "";
CandidateHelper candidateHelper = new CandidateHelper();
String idParentConcept;
String notes;
String idArk;
String idConcept = null;
progress = 0;
progress_abs = 0;
for (SKOSResource sKOSResource : sKOSXmlDocument.getConceptList()) {
for (SKOSLabel sKOSLabel : sKOSResource.getLabelsList()) {
idParentConcept = "";
if (sKOSLabel.getProperty() == SKOSProperty.prefLabel) {
if (sKOSLabel.getLanguage().equalsIgnoreCase("fr")) {
notes = getNotes(sKOSResource);
idArk = getIdParentConcept(sKOSResource);
if (idArk != null)
idParentConcept = new ConceptHelper().getIdConceptFromArkId(connect.getPoolConnexion(), idArk);
try {
Connection conn = connect.getPoolConnexion().getConnection();
idConcept = candidateHelper.addCandidat_rollBack(conn, sKOSLabel.getLabel(), sKOSLabel.getLanguage(), roleOnTheso.getIdTheso(), currentUser.getUser().getIdUser(), notes, idParentConcept, "");
if (idConcept == null) {
conn.rollback();
conn.close();
continue;
}
conn.commit();
conn.close();
} catch (SQLException ex) {
java.util.logging.Logger.getLogger(rdf4jFileBean.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
if (idConcept != null) {
candidateHelper.addTermCandidatTraduction(connect.getPoolConnexion(), idConcept, sKOSLabel.getLabel(), sKOSLabel.getLanguage(), roleOnTheso.getIdTheso(), currentUser.getUser().getIdUser());
}
}
}
}
}
}
use of mom.trd.opentheso.skosapi.SKOSLabel in project opentheso by miledrousset.
the class AgrovocHelper method getTraductions.
/**
* récupération des traductions
*
* @param jsonDatas
* @param entity
* @param languages
* @return
*/
private ArrayList<SelectedResource> getTraductions(String xmlDatas, ArrayList<String> languages) {
ArrayList<SelectedResource> traductions = new ArrayList<>();
ArrayList<SelectedResource> descriptions = new ArrayList<>();
String lang;
String value;
InputStream inputStream;
SKOSXmlDocument sxd;
try {
inputStream = new ByteArrayInputStream(xmlDatas.getBytes("UTF-8"));
// / read XML SKOS
ReadRdf4j readRdf4j = new ReadRdf4j(inputStream, 0);
sxd = readRdf4j.getsKOSXmlDocument();
for (SKOSResource resource : sxd.getConceptList()) {
for (SKOSLabel label : resource.getLabelsList()) {
switch(label.getProperty()) {
case SKOSProperty.prefLabel:
lang = label.getLanguage();
value = label.getLabel();
if (lang == null || value == null || lang.isEmpty() || value.isEmpty())
continue;
if (languages.contains(lang)) {
SelectedResource selectedResource = new SelectedResource();
selectedResource.setIdLang(lang);
selectedResource.setGettedValue(value);
traductions.add(selectedResource);
}
break;
default:
break;
}
}
for (SKOSDocumentation sd : resource.getDocumentationsList()) {
if (sd.getProperty() == SKOSProperty.definition) {
value = sd.getText();
lang = sd.getLanguage();
if (lang == null || value == null || lang.isEmpty() || value.isEmpty())
continue;
if (languages.contains(lang)) {
SelectedResource selectedResource = new SelectedResource();
selectedResource.setIdLang(lang);
selectedResource.setGettedValue(value);
descriptions.add(selectedResource);
}
}
}
}
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(OpenthesoHelper.class.getName()).log(Level.SEVERE, null, ex);
}
resourceDefinitions = descriptions;
return traductions;
}
use of mom.trd.opentheso.skosapi.SKOSLabel in project opentheso by miledrousset.
the class WriteRdf4j method writeLabel.
private void writeLabel(SKOSResource resource) {
int prop;
for (SKOSLabel label : resource.getLabelsList()) {
prop = label.getProperty();
Literal literal = vf.createLiteral(label.getLabel(), label.getLanguage());
switch(prop) {
case SKOSProperty.prefLabel:
builder.add(SKOS.PREF_LABEL, literal);
break;
case SKOSProperty.altLabel:
builder.add(SKOS.ALT_LABEL, literal);
break;
case SKOSProperty.hiddenLabel:
builder.add(SKOS.HIDDEN_LABEL, literal);
break;
default:
break;
}
}
}
use of mom.trd.opentheso.skosapi.SKOSLabel in project opentheso by miledrousset.
the class ImportRdf4jHelper method addGroup.
private String addGroup(SKOSResource group) {
// récupération des groups ou domaine
GroupHelper groupHelper = new GroupHelper();
String idGroup = getIdFromUri(group.getUri());
ArrayList<SKOSNotation> notationList = group.getNotationList();
SKOSNotation notation = null;
if (notationList != null && !notationList.isEmpty()) {
notation = notationList.get(0);
}
String notationValue;
if (notation == null) {
notationValue = "";
} else {
notationValue = notation.getNotation();
}
String type;
switch(group.getProperty()) {
case SKOSProperty.Collection:
type = "C";
break;
case SKOSProperty.ConceptGroup:
type = "G";
break;
case SKOSProperty.MicroThesaurus:
default:
type = "MT";
break;
case SKOSProperty.Theme:
type = "T";
break;
}
groupHelper.insertGroup(ds, idGroup, idTheso, type, notationValue, "", false, idUser);
// sub group
String idSubGroup;
// concept group concept
String idSubConcept;
for (SKOSRelation relation : group.getRelationsList()) {
int prop = relation.getProperty();
switch(prop) {
case SKOSProperty.subGroup:
idSubGroup = getIdFromUri(relation.getTargetUri());
groupHelper.addSubGroup(ds, idGroup, idSubGroup, idTheso);
break;
case SKOSProperty.member:
// option cochée
/* if(identifierType.equalsIgnoreCase("sans")){
idSubConcept = getIdFromUri(relation.getTargetUri());
} else {*/
// Récupération de l'Id d'origine sauvegardé à l'import (idArk -> identifier)
idSubConcept = getOriginalId(relation.getTargetUri());
// }
groupHelper.addConceptGroupConcept(ds, idGroup, idSubConcept, idTheso);
memberHashMap.put(relation.getTargetUri(), idGroup);
break;
case SKOSProperty.hasTopConcept:
hasTopConcceptList.add(relation.getTargetUri());
break;
default:
break;
}
}
for (SKOSLabel label : group.getLabelsList()) {
// ajouter les traductions des Groupes
ConceptGroupLabel conceptGroupLabel = new ConceptGroupLabel();
conceptGroupLabel.setIdgroup(idGroup);
conceptGroupLabel.setIdthesaurus(idTheso);
conceptGroupLabel.setLang(label.getLanguage());
conceptGroupLabel.setLexicalvalue(label.getLabel());
groupHelper.addGroupTraduction(ds, conceptGroupLabel, idUser);
}
return idGroup;
}
use of mom.trd.opentheso.skosapi.SKOSLabel in project opentheso by miledrousset.
the class ImportRdf4jHelper method addGroups.
public void addGroups(rdf4jFileBean fileBean) {
// récupération des groups ou domaine
GroupHelper groupHelper = new GroupHelper();
String idGroup;
for (SKOSResource group : skosXmlDocument.getGroupList()) {
fileBean.setAbs_progress(fileBean.getAbs_progress() + 1);
fileBean.setProgress(fileBean.getAbs_progress() / fileBean.getTotal() * 100);
idGroup = getIdFromUri(group.getUri());
if (idGroup == null || idGroup.isEmpty())
idGroup = group.getUri();
ArrayList<SKOSNotation> notationList = group.getNotationList();
SKOSNotation notation = null;
if (notationList != null && !notationList.isEmpty()) {
notation = notationList.get(0);
}
String notationValue;
if (notation == null) {
notationValue = "";
} else {
notationValue = notation.getNotation();
}
String type;
switch(group.getProperty()) {
case SKOSProperty.Collection:
type = "C";
break;
case SKOSProperty.ConceptGroup:
type = "G";
break;
case SKOSProperty.MicroThesaurus:
default:
type = "MT";
break;
case SKOSProperty.Theme:
type = "T";
break;
}
groupHelper.insertGroup(ds, idGroup, thesaurus.getId_thesaurus(), type, notationValue, "", false, idUser);
// / permet de grouper tous les id des groupes du thésaurus à importer.
idGroups.add(idGroup);
// sub group
String idSubGroup;
// concept group concept
String idSubConcept;
for (SKOSRelation relation : group.getRelationsList()) {
int prop = relation.getProperty();
switch(prop) {
case SKOSProperty.subGroup:
idSubGroup = getIdFromUri(relation.getTargetUri());
groupHelper.addSubGroup(ds, idGroup, idSubGroup, thesaurus.getId_thesaurus());
break;
case SKOSProperty.member:
// option cochée
/* if(identifierType.equalsIgnoreCase("sans")){
idSubConcept = getIdFromUri(relation.getTargetUri());
} else {*/
// Récupération de l'Id d'origine sauvegardé à l'import (idArk -> identifier)
idSubConcept = getOriginalId(relation.getTargetUri());
// }
groupSubGroup.put(idSubConcept, idGroup);
// groupHelper.addConceptGroupConcept(ds, idGroup, idSubConcept, thesaurus.getId_thesaurus());
memberHashMap.put(relation.getTargetUri(), idGroup);
break;
case SKOSProperty.hasTopConcept:
hasTopConcceptList.add(relation.getTargetUri());
break;
default:
break;
}
}
for (SKOSLabel label : group.getLabelsList()) {
// ajouter les traductions des Groupes
ConceptGroupLabel conceptGroupLabel = new ConceptGroupLabel();
conceptGroupLabel.setIdgroup(idGroup);
conceptGroupLabel.setIdthesaurus(thesaurus.getId_thesaurus());
conceptGroupLabel.setLang(label.getLanguage());
conceptGroupLabel.setLexicalvalue(label.getLabel());
groupHelper.addGroupTraduction(ds, conceptGroupLabel, idUser);
}
}
addGroupConceptGroup();
/*
groupHelper.insertGroup(ds,
idGroupDefault,
thesaurus.getId_thesaurus(),
"MT",
"", //notation
adressSite,
useArk,
idUser);
*/
// Création du domaine par défaut
// ajouter les traductions des Groupes
/*ConceptGroupLabel conceptGroupLabel = new ConceptGroupLabel();
conceptGroupLabel.setIdgroup(idGroupDefault);
conceptGroupLabel.setIdthesaurus(thesaurus.getId_thesaurus());
conceptGroupLabel.setLang(langueSource);
conceptGroupLabel.setLexicalvalue("groupDefault");
groupHelper.addGroupTraduction(ds, conceptGroupLabel, idUser);*/
}
Aggregations