use of mom.trd.opentheso.skosapi.SKOSResource 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.skosapi.SKOSResource 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.skosapi.SKOSResource in project opentheso by miledrousset.
the class ReadRdf4j method readModel.
/**
* Permet de lire un fichier RDF précédament charger avec la fonction
* laodModel() les données sont stoqué dans la variable thesaurus
*/
private void readModel(rdf4jFileBean fileBean) {
ReadStruct readStruct = new ReadStruct();
readStruct.resource = null;
// pour le debug :
ArrayList<String> nonReco = new ArrayList();
for (Statement st : model) {
readStruct.value = st.getObject();
readStruct.property = st.getPredicate();
if (readStruct.value instanceof Literal) {
readStruct.literal = (Literal) readStruct.value;
}
// Concept or ConceptScheme or Collection or ConceptGroup
if (readStruct.property.getLocalName().equals("type")) {
int prop = -1;
String type = readStruct.value.toString();
type = type.toUpperCase();
if (type.contains("ConceptScheme".toUpperCase())) {
prop = SKOSProperty.ConceptScheme;
sKOSXmlDocument.setTitle(st.getSubject().stringValue());
} else if (type.contains("ConceptGroup".toUpperCase())) {
prop = SKOSProperty.ConceptGroup;
} else if (type.contains("Theme".toUpperCase())) {
prop = SKOSProperty.Theme;
} else if (type.contains("MicroThesaurus".toUpperCase())) {
prop = SKOSProperty.MicroThesaurus;
} else if (type.contains("Collection".toUpperCase())) {
prop = SKOSProperty.Collection;
} else if (type.contains("Concept".toUpperCase())) {
prop = SKOSProperty.Concept;
}
String uri = st.getSubject().stringValue();
readStruct.resource = new SKOSResource(uri, prop);
if (prop == SKOSProperty.ConceptScheme) {
sKOSXmlDocument.setConceptScheme(readStruct.resource);
} else if (prop == SKOSProperty.ConceptGroup || prop == SKOSProperty.Collection || prop == SKOSProperty.Theme || prop == SKOSProperty.MicroThesaurus) {
sKOSXmlDocument.addGroup(readStruct.resource);
} else if (prop == SKOSProperty.Concept) {
sKOSXmlDocument.addconcept(readStruct.resource);
}
} else // Labelling Properties
if (readLabellingProperties(readStruct)) {
// Dates
if (readDate(readStruct)) {
// Semantic Relationships
if (readRelationships(readStruct)) {
// Documentation Properties
if (readDocumentation(readStruct)) {
if (readCreator(readStruct)) {
if (readGPSCoordinates(readStruct)) {
if (readNotation(readStruct)) {
if (readIdentifier(readStruct)) {
if (readMatch(readStruct)) {
// debug
if (!nonReco.contains(readStruct.property.getLocalName())) {
// System.out.println("non reconue : " + readStruct.property.getLocalName());
nonReco.add(readStruct.property.getLocalName());
}
}
}
}
}
}
}
}
}
}
}
if (!nonReco.isEmpty()) {
String balises = "";
for (String b : nonReco) {
balises += " " + b + "\n";
}
fileBean.setWarning("Not readed RDF tag\n" + balises);
}
}
use of mom.trd.opentheso.skosapi.SKOSResource in project opentheso by miledrousset.
the class ImportRdf4jHelper method addConcepts.
public void addConcepts(rdf4jFileBean fileBean) throws SQLException, ParseException {
AddConceptsStruct acs = new AddConceptsStruct();
acs.conceptHelper = new ConceptHelper();
for (SKOSResource conceptResource : skosXmlDocument.getConceptList()) {
fileBean.setAbs_progress(fileBean.getAbs_progress() + 1);
fileBean.setProgress(fileBean.getAbs_progress() / fileBean.getTotal() * 100);
initAddConceptsStruct(acs, conceptResource);
addRelation(acs);
// envoie du concept à la BDD
if (!isConceptEmpty(acs.nodeTermTraductionList)) {
if (acs.idGrps.isEmpty()) {
acs.concept.setTopConcept(acs.isTopConcept);
acs.concept.setIdGroup(idGroupDefault);
acs.conceptHelper.insertConceptInTable(ds, acs.concept, idUser);
new GroupHelper().addConceptGroupConcept(ds, idGroupDefault, acs.concept.getIdConcept(), acs.concept.getIdThesaurus());
defaultGroupToAdd = true;
} else {
for (String idGrp : acs.idGrps) {
acs.concept.setTopConcept(acs.isTopConcept);
acs.concept.setIdGroup(idGrp);
if (!acs.conceptHelper.insertConceptInTable(ds, acs.concept, idUser)) {
System.out.println("Erreur sur le Concept = " + acs.concept.getIdConcept());
}
}
}
finalizeAddConceptStruct(acs);
}
}
addLangsToThesaurus(ds, idTheso);
addGroupDefault();
}
use of mom.trd.opentheso.skosapi.SKOSResource in project opentheso by miledrousset.
the class ImportRdf4jHelper method detectRootOfBranch.
/**
* detecte la racine d'une branche
*
* @return root
*/
private SKOSResource detectRootOfBranch() {
SKOSResource root = null;
HashMap<String, String> uriRessourcePere = new HashMap<>();
ArrayList<String> uriList = new ArrayList<>();
for (SKOSResource resource : skosXmlDocument.getConceptList()) {
String uri = resource.getUri();
uriList.add(uri);
for (SKOSRelation relation : resource.getRelationsList()) {
int relationProp = relation.getProperty();
if (relationProp == SKOSProperty.broader || relationProp == SKOSProperty.broaderGeneric || relationProp == SKOSProperty.broaderInstantive || relationProp == SKOSProperty.broaderPartitive) {
uriRessourcePere.put(uri, relation.getTargetUri());
}
}
}
for (SKOSResource resource : skosXmlDocument.getConceptList()) {
String uri = resource.getUri();
// si la ressource n'a pas de père alors c'est la racine
if (uriRessourcePere.get(uri) == null || !uriList.contains(uriRessourcePere.get(uri))) {
root = resource;
}
}
return root;
}
Aggregations