use of mom.trd.opentheso.bdd.helper.nodes.NodeUri in project opentheso by miledrousset.
the class ConceptHelper method getListIdsOfTopConceptsForExport.
/**
* Cettte fonction permet de retourner la liste des TopConcept avec IdArk et
* handle pour un groupe
*
* @param ds
* @param idGroup
* @param idThesaurus
* @return
*/
public ArrayList<NodeUri> getListIdsOfTopConceptsForExport(HikariDataSource ds, String idGroup, String idThesaurus) {
ArrayList<NodeUri> NodeUris = new ArrayList<>();
Connection conn;
Statement stmt;
ResultSet resultSet;
try {
// Get connection from pool
conn = ds.getConnection();
try {
stmt = conn.createStatement();
try {
String query = "select id_concept, id_ark, id_handle from concept" + " left join concept_group_concept on id_concept = idconcept" + " and id_thesaurus = idthesaurus" + " where id_thesaurus = '" + idThesaurus + "'" + " and idgroup = '" + idGroup + "'" + " and top_concept = true";
stmt.executeQuery(query);
resultSet = stmt.getResultSet();
while (resultSet.next()) {
NodeUri nodeUri = new NodeUri();
if ((resultSet.getString("id_ark") == null) || (resultSet.getString("id_ark").trim().isEmpty())) {
nodeUri.setIdArk("");
} else {
nodeUri.setIdArk(resultSet.getString("id_ark"));
}
if ((resultSet.getString("id_handle") == null) || (resultSet.getString("id_handle").trim().isEmpty())) {
nodeUri.setIdHandle("");
} else {
nodeUri.setIdHandle(resultSet.getString("id_handle"));
}
nodeUri.setIdConcept(resultSet.getString("id_concept"));
NodeUris.add(nodeUri);
}
} finally {
stmt.close();
}
} finally {
conn.close();
}
} catch (SQLException sqle) {
// Log exception
log.error("Error while getting Liste ID of TT of Group with ark and handle : " + idGroup, sqle);
}
return NodeUris;
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeUri 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.nodes.NodeUri in project opentheso by miledrousset.
the class ExportTxtHelper method writeConcepts.
/**
* Permet d'écrire les concepts en bouclant par récursivité pour définir les
* niveaux
*
* @param idGroup
*/
private void writeConcepts(String idGroup) {
ConceptHelper conceptHelper = new ConceptHelper();
ArrayList<NodeUri> nodeUris;
// la liste des TopConcepts pour un Groupe
nodeUris = conceptHelper.getListIdsOfTopConceptsForExport(ds, idGroup, idTheso);
if (nodeUris == null) {
return;
}
// pour compter le décalage (indentations)
nodeUris.forEach((nodeUri) -> {
String indentation = "";
countIndentation(nodeUri.getIdConcept(), indentation);
});
// on écrit les concepts et le décalage par tabulation
nodeUris.forEach((nodeUri) -> {
String indentation = "";
writeConceptsInfo(nodeUri.getIdConcept(), indentation);
writeConceptRecursive(nodeUri.getIdConcept(), indentation);
});
writeColumnHeader();
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeUri in project opentheso by miledrousset.
the class ExportFromBDD method exportThesaurusAdvanced.
/**
* Fonction récursive permettant d'exporter le thésaurus de la tête jusqu'au
* dernier descripteur en filtrant par langues et domaines choisis
*
* @param ds
* @param idThesaurus
* @param selectedLanguages
* @param selectedGroups
* @param downloadBean
* @return
*/
public StringBuffer exportThesaurusAdvanced(HikariDataSource ds, String idThesaurus, List<NodeLang> selectedLanguages, List<NodeGroup> selectedGroups, DownloadBean downloadBean) {
/*
* Ecriture du thésaurus
*/
this.downloadBean = downloadBean;
ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
NodeThesaurus nodeThesaurus = thesaurusHelper.getNodeThesaurus(ds, idThesaurus);
WriteFileSKOS writeFileSKOS = new WriteFileSKOS();
// inititialisation des URI
writeFileSKOS.setServerArk(serverArk);
writeFileSKOS.setServerAdress(serverAdress);
writeFileSKOS.writeHeader();
String idArk = thesaurusHelper.getIdArkOfThesaurus(ds, idThesaurus);
if (idArk == null || idArk.trim().isEmpty()) {
writeFileSKOS.setURI(serverAdress);
} else {
writeFileSKOS.setURI(serverArk);
}
// writeFileSKOS.setURI("http://opentheso.frantiq.fr/" + nodeThesaurus.getListThesaurusTraduction().get(0).getTitle());
// thesaurus.description);
writeFileSKOS.writeThesaurus(nodeThesaurus);
// ecriture des TopConcept
GroupHelper conceptGroupHelper = new GroupHelper();
ArrayList<String> tabIdGroup = conceptGroupHelper.getListIdOfGroup(ds, idThesaurus);
for (String tabIdGroup1 : tabIdGroup) {
writeFileSKOS.writeTopConcepts(tabIdGroup1, idThesaurus);
}
writeFileSKOS.writeEndOfMicroThesaurusList();
// fin du bloc thésaurus et id of TopConcept
// écriture des Domaines et Descripteurs avec traductions
ArrayList<NodeUri> idOfTopConcept;
for (String tabIdGroup1 : tabIdGroup) {
for (NodeGroup nodeGroup : selectedGroups) {
if (nodeGroup.getConceptGroup().getIdgroup().equalsIgnoreCase(tabIdGroup1)) {
NodeGroupLabel nodeGroupLabel = conceptGroupHelper.getNodeGroupLabel(ds, tabIdGroup1, idThesaurus);
idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, tabIdGroup1, idThesaurus);
writeFileSKOS.writeGroup(nodeGroupLabel, idOfTopConcept, selectedLanguages);
}
}
}
for (String tabIdGroup1 : tabIdGroup) {
for (NodeGroup nodeGroup : selectedGroups) {
if (nodeGroup.getConceptGroup().getIdgroup().equalsIgnoreCase(tabIdGroup1)) {
idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, tabIdGroup1, idThesaurus);
for (NodeUri idOfTopConcept1 : idOfTopConcept) {
exportAllConceptsAdvanced(ds, idOfTopConcept1.getIdConcept(), idThesaurus, writeFileSKOS, selectedLanguages);
}
}
}
}
writeFileSKOS.endSkos();
return writeFileSKOS.getSkosBuff();
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeUri in project opentheso by miledrousset.
the class ExportFromBDD method exportThesaurus.
/**
* Fonction récursive permettant d'exporter le thésaurus de la tête jusqu'au
* dernier descripteur
*
* @param ds
* @param idThesaurus
* @return
*/
public StringBuffer exportThesaurus(HikariDataSource ds, String idThesaurus) {
/*
* Ecriture du thésaurus
*/
ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
NodeThesaurus nodeThesaurus = thesaurusHelper.getNodeThesaurus(ds, idThesaurus);
WriteFileSKOS writeFileSKOS = new WriteFileSKOS();
// inititialisation des URI
writeFileSKOS.setServerArk(serverArk);
writeFileSKOS.setServerAdress(serverAdress);
writeFileSKOS.writeHeader();
String idArk = thesaurusHelper.getIdArkOfThesaurus(ds, idThesaurus);
if (idArk == null || idArk.trim().isEmpty()) {
writeFileSKOS.setURI(serverAdress);
} else {
writeFileSKOS.setURI(serverArk);
}
// writeFileSKOS.setURI("http://opentheso.frantiq.fr/" + nodeThesaurus.getListThesaurusTraduction().get(0).getTitle());
// thesaurus.description);
writeFileSKOS.writeThesaurus(nodeThesaurus);
// ecriture des TopConcept
GroupHelper conceptGroupHelper = new GroupHelper();
ArrayList<String> tabIdGroup = conceptGroupHelper.getListIdOfGroup(ds, idThesaurus);
for (String tabIdGroup1 : tabIdGroup) {
writeFileSKOS.writeTopConcepts(tabIdGroup1, idThesaurus);
}
writeFileSKOS.writeEndOfMicroThesaurusList();
// fin du bloc thésaurus et id of TopConcept
// écriture des Domaines et Descripteurs avec traductions
ArrayList<NodeUri> idOfTopConcept;
for (String tabIdGroup1 : tabIdGroup) {
NodeGroupLabel nodeGroupLabel = conceptGroupHelper.getNodeGroupLabel(ds, tabIdGroup1, idThesaurus);
idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, tabIdGroup1, idThesaurus);
writeFileSKOS.writeGroup(nodeGroupLabel, idOfTopConcept, null);
}
for (String tabIdGroup1 : tabIdGroup) {
idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, tabIdGroup1, idThesaurus);
for (NodeUri idOfTopConcept1 : idOfTopConcept) {
exportAllConcepts(ds, idOfTopConcept1.getIdConcept(), idThesaurus, writeFileSKOS);
}
}
writeFileSKOS.endSkos();
return writeFileSKOS.getSkosBuff();
}
Aggregations