Search in sources :

Example 6 with SKOSResource

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);
    // }
    }
}
Also used : SKOSResource(mom.trd.opentheso.skosapi.SKOSResource) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper)

Example 7 with 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);
}
Also used : NodeConceptExport(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport) SKOSResource(mom.trd.opentheso.skosapi.SKOSResource) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM)

Example 8 with 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);
    }
}
Also used : SKOSResource(mom.trd.opentheso.skosapi.SKOSResource) Statement(org.eclipse.rdf4j.model.Statement) Literal(org.eclipse.rdf4j.model.Literal) ArrayList(java.util.ArrayList)

Example 9 with SKOSResource

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();
}
Also used : SKOSResource(mom.trd.opentheso.skosapi.SKOSResource) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 10 with SKOSResource

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;
}
Also used : SKOSResource(mom.trd.opentheso.skosapi.SKOSResource) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SKOSRelation(mom.trd.opentheso.skosapi.SKOSRelation)

Aggregations

SKOSResource (mom.trd.opentheso.skosapi.SKOSResource)20 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)5 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)5 SKOSLabel (mom.trd.opentheso.skosapi.SKOSLabel)3 SKOSRelation (mom.trd.opentheso.skosapi.SKOSRelation)3 Paragraph (com.itextpdf.text.Paragraph)2 ArrayList (java.util.ArrayList)2 Thesaurus (mom.trd.opentheso.bdd.datas.Thesaurus)2 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)2 DocumentException (com.itextpdf.text.DocumentException)1 PdfPCell (com.itextpdf.text.pdf.PdfPCell)1 PdfPTable (com.itextpdf.text.pdf.PdfPTable)1 Connection (java.sql.Connection)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 ConceptGroupLabel (mom.trd.opentheso.bdd.datas.ConceptGroupLabel)1 HierarchicalRelationship (mom.trd.opentheso.bdd.datas.HierarchicalRelationship)1 UserHelper (mom.trd.opentheso.bdd.helper.UserHelper)1 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)1 NodeLang (mom.trd.opentheso.bdd.helper.nodes.NodeLang)1