Search in sources :

Example 11 with SKOSResource

use of skos.SKOSResource in project opentheso by miledrousset.

the class WriteFileSKOS method writeGroup.

/**
 * @param nodeGroupLabel
 * @param listIdOfTopConcept
 * @param selectedLanguages
 *
 * @return true ou false
 */
public boolean writeGroup(NodeGroupLabel nodeGroupLabel, ArrayList<NodeUri> listIdOfTopConcept, List<NodeLang> selectedLanguages) {
    SKOSResource concept;
    if (nodeGroupLabel.getIdArk() == null || nodeGroupLabel.getIdArk().trim().isEmpty()) {
        /*
            Cette partie est pour l'export des PACTOLS pour Frantiq
             */
        // concept = new SKOSResource(serverAdress + "#" + nodeGroupLabel.getIdGroup());
        concept = new SKOSResource(serverAdress + "?idg=" + nodeGroupLabel.getIdGroup() + "&amp;idt=" + nodeGroupLabel.getIdThesaurus());
    } else {
        concept = new SKOSResource(serverArk + nodeGroupLabel.getIdArk());
    }
    for (int i = 0; i < nodeGroupLabel.getNodeGroupTraductionses().size(); i++) {
        if (selectedLanguages != null) {
            // nodeGroupLabel.getNodeGroupTraductionses().get(i).getIdLang().equalsIgnoreCase("fr"))
            for (NodeLang selectedLanguage : selectedLanguages) {
                if (nodeGroupLabel.getNodeGroupTraductionses().get(i).getIdLang().equalsIgnoreCase(selectedLanguage.getCode())) {
                    concept.addLabel(nodeGroupLabel.getNodeGroupTraductionses().get(i).getTitle(), nodeGroupLabel.getNodeGroupTraductionses().get(i).getIdLang(), SKOSProperty.prefLabel);
                }
            }
        } else {
            concept.addLabel(nodeGroupLabel.getNodeGroupTraductionses().get(i).getTitle(), nodeGroupLabel.getNodeGroupTraductionses().get(i).getIdLang(), SKOSProperty.prefLabel);
        }
    }
    if (!nodeGroupLabel.getNodeGroupTraductionses().isEmpty()) {
        concept.addDate(nodeGroupLabel.getNodeGroupTraductionses().get(0).getCreated().toString(), SKOSProperty.created);
        concept.addDate(nodeGroupLabel.getNodeGroupTraductionses().get(0).getModified().toString(), SKOSProperty.modified);
    }
    if (!nodeGroupLabel.getIdGroup().isEmpty()) {
        concept.addIdentifier(nodeGroupLabel.getIdGroup(), SKOSProperty.identifier);
    }
    for (NodeUri listIdOfTopConcept1 : listIdOfTopConcept) {
        if (listIdOfTopConcept1.getIdArk() == null || listIdOfTopConcept1.getIdArk().trim().isEmpty()) {
            concept.addRelation(serverAdress + "?idc=" + listIdOfTopConcept1.getIdConcept() + "&amp;idt=" + nodeGroupLabel.getIdThesaurus(), SKOSProperty.narrower);
        } else {
            concept.addRelation(serverArk + listIdOfTopConcept1.getIdArk(), SKOSProperty.narrower);
        }
    }
    skosBuff.append("    ").append(concept.toString());
    return true;
}
Also used : SKOSResource(skos.SKOSResource) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri)

Example 12 with SKOSResource

use of skos.SKOSResource in project opentheso by miledrousset.

the class WriteFileSKOS_Frantiq method writeDescriptor.

/**
 * Cette fonction permet d'exporter un Concept au format SKOS,
 * Si l'identifiant Ark existe, on l'exporte comme URI, sinon, on utilise l'adresse URI du Site par defaut.
 *
 * @param nodeConceptExport
 *
 * @return true ou false
 */
public boolean writeDescriptor(NodeConceptExport nodeConceptExport) {
    // getUri(nodeConceptExport));
    SKOSResource concept = new SKOSResource(serverAdress + "concept#" + nodeConceptExport.getConcept().getIdConcept());
    for (int i = 0; i < nodeConceptExport.getNodeTermTraductions().size(); i++) {
        concept.addLabel(nodeConceptExport.getNodeTermTraductions().get(i).getLexicalValue(), nodeConceptExport.getNodeTermTraductions().get(i).getLang(), SKOSProperty.prefLabel);
    }
    concept.addDate(nodeConceptExport.getConcept().getCreated().toString(), SKOSProperty.created);
    concept.addDate(nodeConceptExport.getConcept().getModified().toString(), SKOSProperty.modified);
    if (!nodeConceptExport.getConcept().getIdConcept().isEmpty()) {
        concept.addIdentifier(nodeConceptExport.getConcept().getIdConcept(), SKOSProperty.identifier);
    }
    for (int i = 0; i < nodeConceptExport.getNodeListIdsOfConceptGroup().size(); i++) {
        concept.addRelation(URI + "concept#" + nodeConceptExport.getNodeListIdsOfConceptGroup().get(i).getIdConcept(), SKOSProperty.inScheme);
    /*    concept.addRelation(
                    getRelationUri_inScheme(nodeConceptExport.getNodeListIdsOfConceptGroup().get(i),
                            nodeConceptExport.getConcept().getIdThesaurus()),
                    SKOSProperty.inScheme);*/
    }
    for (int i = 0; i < nodeConceptExport.getNodeListOfBT().size(); i++) {
        concept.addRelation(URI + "concept#" + nodeConceptExport.getNodeListOfBT().get(i).getUri().getIdConcept(), SKOSProperty.broader);
    /*    concept.addRelation(
                    getRelationUri(nodeConceptExport.getNodeListIdsOfBT().get(i),
                            nodeConceptExport.getConcept().getIdThesaurus()),
                    SKOSProperty.broader);
            */
    }
    for (int i = 0; i < nodeConceptExport.getNodeListOfNT().size(); i++) {
        concept.addRelation(URI + "concept#" + nodeConceptExport.getNodeListOfNT().get(i).getUri().getIdConcept(), SKOSProperty.narrower);
    /*    concept.addRelation(
                    getRelationUri(nodeConceptExport.getNodeListIdsOfNT().get(i),
                            nodeConceptExport.getConcept().getIdThesaurus()),
                    SKOSProperty.narrower);
            */
    }
    for (int i = 0; i < nodeConceptExport.getNodeListIdsOfRT().size(); i++) {
        concept.addRelation(URI + "concept#" + nodeConceptExport.getNodeListIdsOfRT().get(i).getUri().getIdConcept(), SKOSProperty.related);
    /*    concept.addRelation(
                    getRelationUri(nodeConceptExport.getNodeListIdsOfRT().get(i),
                            nodeConceptExport.getConcept().getIdThesaurus()),
                    SKOSProperty.related);
            */
    }
    for (int i = 0; i < nodeConceptExport.getNodeEM().size(); i++) {
        if (nodeConceptExport.getNodeEM().get(i).isHiden()) {
            concept.addLabel(nodeConceptExport.getNodeEM().get(i).getLexical_value(), nodeConceptExport.getNodeEM().get(i).getLang(), SKOSProperty.hiddenLabel);
        } else {
            concept.addLabel(nodeConceptExport.getNodeEM().get(i).getLexical_value(), nodeConceptExport.getNodeEM().get(i).getLang(), SKOSProperty.altLabel);
        }
    }
    for (NodeAlignment alignment : nodeConceptExport.getNodeAlignmentsList()) {
        // alignement exactMatch
        if (alignment.getAlignement_id_type() == 1) {
            concept.addMapping(alignment.getUri_target().trim(), SKOSMapping.exactMatch);
        }
        // alignement closeMatch
        if (alignment.getAlignement_id_type() == 2) {
            concept.addMapping(alignment.getUri_target().trim(), SKOSMapping.closeMatch);
        }
    }
    for (NodeNote nodeNote : nodeConceptExport.getNodeNoteTerm()) {
        if (nodeNote.getNotetypecode().equalsIgnoreCase("scopeNote")) {
            concept.addDocumentation(nodeNote.getLexicalvalue(), nodeNote.getLang(), SKOSProperty.scopeNote);
        }
        if (nodeNote.getNotetypecode().equalsIgnoreCase("historyNote")) {
            concept.addDocumentation(nodeNote.getLexicalvalue(), nodeNote.getLang(), SKOSProperty.historyNote);
        }
        if (nodeNote.getNotetypecode().equalsIgnoreCase("editorialNote")) {
            concept.addDocumentation(nodeNote.getLexicalvalue(), nodeNote.getLang(), SKOSProperty.editorialNote);
        }
        if (nodeNote.getNotetypecode().equalsIgnoreCase("definition")) {
            concept.addDocumentation(nodeNote.getLexicalvalue(), nodeNote.getLang(), SKOSProperty.definition);
        }
    }
    skosBuff.append("    ").append(concept.toString());
    return true;
}
Also used : NodeAlignment(mom.trd.opentheso.bdd.helper.nodes.NodeAlignment) SKOSResource(skos.SKOSResource) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)

Aggregations

SKOSResource (skos.SKOSResource)12 NodeAlignment (mom.trd.opentheso.bdd.helper.nodes.NodeAlignment)3 NodeLang (mom.trd.opentheso.bdd.helper.nodes.NodeLang)2 NodeUri (mom.trd.opentheso.bdd.helper.nodes.NodeUri)2 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)2 SKOSConceptScheme (skos.SKOSConceptScheme)2 SKOSLabel (skos.SKOSLabel)2 HttpURLConnection (java.net.HttpURLConnection)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 Thesaurus (mom.trd.opentheso.bdd.datas.Thesaurus)1 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)1 UserHelper (mom.trd.opentheso.bdd.helper.UserHelper)1 ReadFileSKOS (mom.trd.opentheso.core.imports.old.ReadFileSKOS)1 SAXException (org.xml.sax.SAXException)1 SKOSDocumentation (skos.SKOSDocumentation)1 SKOSRelation (skos.SKOSRelation)1 SKOSTopConcept (skos.SKOSTopConcept)1