use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class ExportRdf4jHelper method addFilsConceptRecursif.
private void addFilsConceptRecursif(String idThesaurus, String idPere, SKOSResource sKOSResource) {
ConceptHelper conceptHelper = new ConceptHelper();
ArrayList<String> listIdsOfConceptChildren = conceptHelper.getListChildrenOfConcept(ds, idPere, idThesaurus);
writeConceptInfo(conceptHelper, sKOSResource, idThesaurus, idPere);
for (String idOfConceptChildren : listIdsOfConceptChildren) {
sKOSResource = new SKOSResource();
// writeConceptInfo(conceptHelper, concept, idThesaurus, idOfConceptChildren, downloadBean, selectedLanguages);
// if (conceptHelper.haveChildren(ds, idThesaurus, idOfConceptChildren)) {
addFilsConceptRecursif(idThesaurus, idOfConceptChildren, sKOSResource);
// }
}
}
use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class ExportRdf4jHelper method addSignleConcept.
public void addSignleConcept(String idThesaurus, String idConcept) {
idTheso = idThesaurus;
ConceptHelper conceptHelper = new ConceptHelper();
SKOSResource sKOSResource = new SKOSResource();
NodeConceptExport nodeConcept = conceptHelper.getConceptForExport(ds, idConcept, idThesaurus, false);
if (nodeConcept == null) {
return;
}
// concept.setUri(getUriFromId(idConcept));
sKOSResource.setUri(getUri(nodeConcept));
sKOSResource.setProperty(SKOSProperty.Concept);
// prefLabel
for (NodeTermTraduction traduction : nodeConcept.getNodeTermTraductions()) {
sKOSResource.addLabel(traduction.getLexicalValue(), traduction.getLang(), SKOSProperty.prefLabel);
}
// altLabel
for (NodeEM nodeEM : nodeConcept.getNodeEM()) {
sKOSResource.addLabel(nodeEM.getLexical_value(), nodeEM.getLang(), SKOSProperty.altLabel);
}
ArrayList<NodeNote> nodeNotes = nodeConcept.getNodeNoteConcept();
nodeNotes.addAll(nodeConcept.getNodeNoteTerm());
addNoteGiven(nodeNotes, sKOSResource);
addGPSGiven(nodeConcept.getNodeGps(), sKOSResource);
addAlignementGiven(nodeConcept.getNodeAlignmentsList(), sKOSResource);
addRelationGiven(nodeConcept.getNodeListOfBT(), nodeConcept.getNodeListOfNT(), nodeConcept.getNodeListIdsOfRT(), sKOSResource, nodeConcept.getConcept().getIdThesaurus());
String notation = nodeConcept.getConcept().getNotation();
String created = nodeConcept.getConcept().getCreated().toString();
String modified = nodeConcept.getConcept().getModified().toString();
if (notation != null && !notation.equals("null")) {
sKOSResource.addNotation(notation);
}
if (created != null) {
sKOSResource.addDate(created, SKOSProperty.created);
}
if (modified != null) {
sKOSResource.addDate(modified, SKOSProperty.modified);
}
sKOSResource.addRelation(getUriFromId(idTheso), SKOSProperty.inScheme);
sKOSResource.addIdentifier(idConcept, SKOSProperty.identifier);
skosXmlDocument.addconcept(sKOSResource);
}
use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class CompareConceptTest method testExportAllDatas.
/**
* Test of Get datas for SiteMap.
*/
@org.junit.Test
public void testExportAllDatas() {
ConnexionTest connexionTest = new ConnexionTest();
HikariDataSource conn = connexionTest.getConnexionPool();
String idTheso = "TH_1";
String idLang = "fr";
String idGroup = "6";
ConceptHelper conceptHelper = new ConceptHelper();
StringPlus stringPlus = new StringPlus();
NodeConcept nodeConcept;
SearchHelper searchHelper = new SearchHelper();
ArrayList<NodeSearch> nodeSearchs;
StringBuilder stringBuilder = new StringBuilder();
// lecture du fichier tabulé /Users/Miled/
String path = "/Users/Miled/Desktop/inist.csv";
FileInputStream file = readFile(path);
if (file == null)
return;
String line;
String lineTmp;
String[] lineOrigine;
boolean first = true;
stringBuilder.append("Numéro BDD\tnom d'origine\tnom PACTOLS\tId PACTOLS\tURL Ark\tDéfinition\tTerme générique\tSynonyme\n");
BufferedReader bf = new BufferedReader(new InputStreamReader(file));
try {
while ((line = bf.readLine()) != null) {
lineOrigine = line.split("\t");
if (lineOrigine.length < 2)
continue;
lineTmp = removeStopWords(lineOrigine[1]);
nodeSearchs = searchHelper.searchTerm(conn, lineTmp, idLang, idTheso, idGroup, 2, false);
stringBuilder.append(lineOrigine[0]);
stringBuilder.append("\t");
stringBuilder.append(lineOrigine[1]);
// stringBuilder.append(" #### ");
stringBuilder.append("\t");
first = true;
for (NodeSearch nodeSearch : nodeSearchs) {
if (!first) {
// stringBuilder.append(" $$$$ ");
stringBuilder.append("\n");
stringBuilder.append("\t");
stringBuilder.append("\t");
}
stringBuilder.append(nodeSearch.getLexical_value());
stringBuilder.append("\t");
stringBuilder.append(nodeSearch.getIdConcept());
// récupération des données d'un Concept
nodeConcept = conceptHelper.getConcept(conn, nodeSearch.getIdConcept(), idTheso, idLang);
// URL
stringBuilder.append("\t");
if (nodeConcept.getConcept().getIdArk() != null || !nodeConcept.getConcept().getIdArk().isEmpty()) {
stringBuilder.append("http://ark.frantiq.fr/ark:/");
stringBuilder.append(nodeConcept.getConcept().getIdArk());
}
// définition
stringBuilder.append("\t");
for (NodeNote nodeNote : nodeConcept.getNodeNotesTerm()) {
if (nodeNote.getNotetypecode().equalsIgnoreCase("definition"))
stringBuilder.append(stringPlus.clearNewLine(nodeNote.getLexicalvalue()));
}
// BT
stringBuilder.append("\t");
for (NodeBT nodeBT : nodeConcept.getNodeBT()) {
stringBuilder.append(nodeBT.getTitle());
}
// UF
stringBuilder.append("\t");
for (NodeEM nodeEM : nodeConcept.getNodeEM()) {
stringBuilder.append(nodeEM.getLexical_value());
}
first = false;
}
System.out.println(stringBuilder.toString());
stringBuilder.delete(0, stringBuilder.capacity());
}
} catch (IOException ex) {
Logger.getLogger(CompareConceptTest.class.getName()).log(Level.SEVERE, null, ex);
}
// ArrayList<NodeConceptArkId> allIds = conceptHelper.getAllConceptArkIdOfThesaurus(conn, idTheso);
// StringBuilder file = new StringBuilder();
/* ArrayList<String> allIds = conceptHelper.getAllIdConceptOfThesaurusByGroup(conn, idTheso, idGroup);
for (String idConcept : allIds) {
nodeConcept = conceptHelper.getConcept(conn, idConcept, idTheso, idLang);
System.out.println("idConcept = " + idConcept + " " + nodeConcept.getTerm().getLexical_value());
}*/
conn.close();
}
use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class TreeChange method getPathFromSelectedConcept.
public ArrayList<String> getPathFromSelectedConcept(Connexion conn, MyTreeNode selectedNode) {
String id = selectedNode.getIdConcept();
String theso = selectedNode.getIdTheso();
GroupHelper gh = new GroupHelper();
ArrayList<NodeGroup> groups = gh.getListGroupOfConcept(conn.getPoolConnexion(), theso, id, selectedNode.getLangue());
ConceptHelper ch = new ConceptHelper();
ArrayList<String> result = new ArrayList<>();
ArrayList<String> bt = new ArrayList<>();
ArrayList<String> groupIds = new ArrayList<>();
for (NodeGroup ng : groups) {
groupIds.add(ng.getConceptGroup().getIdgroup());
bt.addAll(ch.getAllBTOfConceptOfThisGroup(conn.getPoolConnexion(), id, ng.getConceptGroup().getIdgroup(), theso));
}
result.addAll(bt);
while (!bt.isEmpty()) {
ArrayList<String> tmp = new ArrayList<>();
for (String idBt : bt) {
for (String idGroup : groupIds) {
tmp.addAll(ch.getAllBTOfConceptOfThisGroup(conn.getPoolConnexion(), idBt, idGroup, theso));
}
}
bt = new ArrayList<>(tmp);
result.addAll(bt);
}
for (String idGroup : groupIds) {
String fat = gh.getIdFather(conn.getPoolConnexion(), idGroup, theso);
result.add(fat);
while (fat != null && !fat.isEmpty()) {
fat = gh.getIdFather(conn.getPoolConnexion(), fat, theso);
result.add(fat);
}
}
result.addAll(groupIds);
return result;
}
use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class Rest method brancheOfConceptsToSkosFromDate.
/**
* Fonction qui permet de récupérer les concepts à partir d'une date donnée
* (modifiés ou crées)
*
* @param idConcept
* @param idThesaurus
* @return skos
*/
private StringBuffer brancheOfConceptsToSkosFromDate(String idTheso, String date) {
if (ds == null) {
return null;
}
nodePreference = new PreferencesHelper().getThesaurusPreference(ds, idTheso);
if (nodePreference == null) {
return null;
}
ArrayList<String> tabId;
ArrayList<ArrayList<String>> multiTabId = new ArrayList<>();
ConceptHelper conceptHelper = new ConceptHelper();
tabId = conceptHelper.getConceptsDelta(ds, idTheso, date);
if (tabId == null) {
ds.close();
return null;
}
if (tabId.isEmpty()) {
ds.close();
return new StringBuffer("");
}
multiTabId.add(tabId);
ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setServerArk(nodePreference.getServeurArk());
exportFromBDD.setServerAdress(nodePreference.getCheminSite());
exportFromBDD.setNodePreference(nodePreference);
StringBuffer skos = exportFromBDD.exportConceptByLot(ds, idTheso, multiTabId);
return skos;
}
Aggregations