Search in sources :

Example 11 with NodeAlignment

use of mom.trd.opentheso.bdd.helper.nodes.NodeAlignment in project opentheso by miledrousset.

the class GpsQuery method queryGps2.

public ArrayList<NodeAlignment> queryGps2(String idC, String idTheso, String lexicalValue, String lang, String requete) {
    ArrayList<NodeLang> nodeLangs;
    try {
        lexicalValue = URLEncoder.encode(lexicalValue, "UTF-8");
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(GpsQuery.class.getName()).log(Level.SEVERE, null, ex);
    }
    lexicalValue = lexicalValue.replaceAll(" ", "%20");
    requete = requete.replace("##lang##", lang);
    requete = requete.replace("##value##", lexicalValue);
    try {
        // URL url = new URL("https://" + lang + ".wikipedia.org/w/api.php?action=query&list=search&srwhat=text&format=xml&srsearch=" + lexicalValue + "&srnamespace=0");
        // requete = URLEncoder.encode(requete, "UTF-8");
        URL url = new URL(requete);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("GET");
        conn.setRequestProperty("Accept", "application/xml");
        if (conn.getResponseCode() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
        }
        BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
        String output;
        String xmlRecord = "";
        while ((output = br.readLine()) != null) {
            xmlRecord += output;
        }
        byte[] bytes = xmlRecord.getBytes();
        xmlRecord = new String(bytes, Charset.forName("UTF-8"));
        conn.disconnect();
        try {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            InputSource is = new InputSource();
            is.setCharacterStream(new StringReader(xmlRecord));
            org.w3c.dom.Document doc = db.parse(is);
            NodeList nodes = doc.getElementsByTagName("geoname");
            listeAlign = new ArrayList<>();
            // iterate the employees
            for (int i = 0; i < nodes.getLength(); i++) {
                nodeLangs = new ArrayList<>();
                org.w3c.dom.Element element = (org.w3c.dom.Element) nodes.item(i);
                NodeAlignment nodeAlignment = new NodeAlignment();
                NodeList nodeList = element.getElementsByTagName("name");
                for (int j = 0; j < nodeList.getLength(); j++) {
                    nodeAlignment.setName(nodeList.item(j).getTextContent());
                }
                nodeList = element.getElementsByTagName("lat");
                if (nodeList != null && nodeList.getLength() > 0) {
                    for (int j = 0; j < nodeList.getLength(); j++) {
                        nodeAlignment.setLat(Double.parseDouble(nodeList.item(j).getTextContent()));
                    }
                }
                nodeList = element.getElementsByTagName("lng");
                if (nodeList != null && nodeList.getLength() > 0) {
                    for (int j = 0; j < nodeList.getLength(); j++) {
                        nodeAlignment.setLng(Double.parseDouble(nodeList.item(j).getTextContent()));
                    }
                }
                nodeList = element.getElementsByTagName("geonameId");
                if (nodeList != null && nodeList.getLength() > 0) {
                    for (int j = 0; j < nodeList.getLength(); j++) {
                        nodeAlignment.setIdUrl("http://www.geonames.org/" + (nodeList.item(j).getTextContent()));
                    }
                }
                nodeList = element.getElementsByTagName("countryName");
                if (nodeList != null && nodeList.getLength() > 0) {
                    for (int j = 0; j < nodeList.getLength(); j++) {
                        nodeAlignment.setCountryName(nodeList.item(j).getTextContent());
                    }
                }
                nodeList = element.getElementsByTagName("toponymName");
                if (nodeList != null && nodeList.getLength() > 0) {
                    for (int j = 0; j < nodeList.getLength(); j++) {
                        nodeAlignment.setToponymName(nodeList.item(j).getTextContent());
                    }
                }
                nodeList = element.getElementsByTagName("adminName1");
                if (nodeList != null && nodeList.getLength() > 0) {
                    for (int j = 0; j < nodeList.getLength(); j++) {
                        nodeAlignment.setAdminName1(nodeList.item(j).getTextContent());
                    }
                }
                nodeList = element.getElementsByTagName("adminName2");
                if (nodeList != null && nodeList.getLength() > 0) {
                    for (int j = 0; j < nodeList.getLength(); j++) {
                        nodeAlignment.setAdminName2(nodeList.item(j).getTextContent());
                    }
                }
                nodeList = element.getElementsByTagName("alternateName");
                if (nodeList != null && nodeList.getLength() > 0) {
                    for (int j = 0; j < nodeList.getLength(); j++) {
                        NodeLang nodeLang = new NodeLang();
                        // nodeAlignment.setToponymName(p.item(j).getTextContent());
                        ArrayList<String> langueFound = new ArrayList<>();
                        org.w3c.dom.Element el = (org.w3c.dom.Element) nodeList.item(j);
                        if (el.hasAttribute("lang")) {
                            nodeLang.setCode(el.getAttribute("lang"));
                            nodeLang.setValue(nodeList.item(j).getTextContent());
                        }
                        nodeLangs.add(nodeLang);
                    }
                    nodeAlignment.setAlltraductions(nodeLangs);
                }
                listeAlign.add(nodeAlignment);
            }
        } catch (ParserConfigurationException | SAXException | IOException e) {
        }
    } catch (MalformedURLException e) {
    } catch (IOException e) {
    }
    return listeAlign;
}
Also used : InputSource(org.xml.sax.InputSource) MalformedURLException(java.net.MalformedURLException) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Element(org.jdom2.Element) ArrayList(java.util.ArrayList) URL(java.net.URL) SAXException(org.xml.sax.SAXException) HttpURLConnection(java.net.HttpURLConnection) StringReader(java.io.StringReader) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) InputStreamReader(java.io.InputStreamReader) NodeList(org.w3c.dom.NodeList) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) NodeAlignment(mom.trd.opentheso.bdd.helper.nodes.NodeAlignment) DocumentBuilder(javax.xml.parsers.DocumentBuilder) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) BufferedReader(java.io.BufferedReader)

Example 12 with NodeAlignment

use of mom.trd.opentheso.bdd.helper.nodes.NodeAlignment in project opentheso by miledrousset.

the class ExportTabulateHelper method writeConcepts.

private boolean writeConcepts() {
    ArrayList<NodeConceptExport> nodeConceptExports = thesaurusDatas.getNodeConceptExports();
    boolean first = true;
    ArrayList<NodeNote> nodeNoteDefinition = new ArrayList<>();
    ArrayList<NodeNote> nodeNoteScope = new ArrayList<>();
    ArrayList<NodeNote> nodeNoteHistory = new ArrayList<>();
    ArrayList<NodeNote> nodeNoteEditorial = new ArrayList<>();
    ArrayList<String> listLangues = new ArrayList<>();
    for (NodeLang selectedLanguage : selectedLanguages) {
        listLangues.add(selectedLanguage.getCode());
    }
    for (NodeConceptExport nodeConceptExport : nodeConceptExports) {
        nodeNoteDefinition.clear();
        nodeNoteScope.clear();
        nodeNoteHistory.clear();
        nodeNoteEditorial.clear();
        // id
        tabulateBuff.append(nodeConceptExport.getConcept().getIdConcept());
        tabulateBuff.append(";");
        // idArk
        if (nodeConceptExport.getConcept().getIdArk() == null) {
            tabulateBuff.append("");
        } else {
            tabulateBuff.append(nodeConceptExport.getConcept().getIdArk());
        }
        tabulateBuff.append(";");
        // type
        if (nodeConceptExport.getConcept().isTopConcept()) {
            tabulateBuff.append("TT");
        } else {
            tabulateBuff.append("DE");
        }
        tabulateBuff.append(";");
        // preflabel
        for (NodeTermTraduction nodeTermTraduction : nodeConceptExport.getNodeTermTraductions()) {
            if (listLangues.contains(nodeTermTraduction.getLang())) {
                if (!first) {
                    tabulateBuff.append("##");
                }
                tabulateBuff.append(nodeTermTraduction.getLexicalValue());
                tabulateBuff.append("::");
                tabulateBuff.append(nodeTermTraduction.getLang());
                first = false;
            }
        }
        tabulateBuff.append(";");
        // altLabel
        first = true;
        for (NodeEM nodeEM : nodeConceptExport.getNodeEM()) {
            if (listLangues.contains(nodeEM.getLang())) {
                if (!first) {
                    tabulateBuff.append("##");
                }
                tabulateBuff.append(nodeEM.getLexical_value());
                tabulateBuff.append("::");
                tabulateBuff.append(nodeEM.getLang());
                first = false;
            }
        }
        tabulateBuff.append(";");
        // inScheme
        first = true;
        for (NodeUri nodeUri : nodeConceptExport.getNodeListIdsOfConceptGroup()) {
            if (!first) {
                tabulateBuff.append("##");
            }
            tabulateBuff.append(nodeUri.getIdConcept());
            first = false;
        }
        tabulateBuff.append(";");
        // broader
        first = true;
        for (NodeHieraRelation node : nodeConceptExport.getNodeListOfBT()) {
            if (!first) {
                tabulateBuff.append("##");
            }
            tabulateBuff.append(node.getUri().getIdConcept());
            first = false;
        }
        tabulateBuff.append(";");
        // narrower
        first = true;
        for (NodeHieraRelation node : nodeConceptExport.getNodeListOfNT()) {
            if (!first) {
                tabulateBuff.append("##");
            }
            tabulateBuff.append(node.getUri().getIdConcept());
            first = false;
        }
        tabulateBuff.append(";");
        // related
        first = true;
        for (NodeHieraRelation nodeUri : nodeConceptExport.getNodeListIdsOfRT()) {
            if (!first) {
                tabulateBuff.append("##");
            }
            tabulateBuff.append(nodeUri.getUri().getIdConcept());
            first = false;
        }
        tabulateBuff.append(";");
        // alignment
        first = true;
        for (NodeAlignment nodeAlignment : nodeConceptExport.getNodeAlignmentsList()) {
            if (!first) {
                tabulateBuff.append("##");
            }
            if (nodeAlignment.getAlignement_id_type() == 1) {
                tabulateBuff.append("exactMatch::");
                tabulateBuff.append(nodeAlignment.getUri_target());
            }
            if (nodeAlignment.getAlignement_id_type() == 2) {
                tabulateBuff.append("closeMatch::");
                tabulateBuff.append(nodeAlignment.getUri_target());
            }
            first = false;
        }
        tabulateBuff.append(";");
        // types : definition; editorialNote; historyNote ; scopeNote
        for (NodeNote nodeNote : nodeConceptExport.getNodeNoteConcept()) {
            nodeNote.setLexicalvalue(nodeNote.getLexicalvalue().replace('\r', ' '));
            nodeNote.setLexicalvalue(nodeNote.getLexicalvalue().replace('\n', ' '));
            if (nodeNote.getNotetypecode().equalsIgnoreCase("definition")) {
                nodeNoteDefinition.add(nodeNote);
            }
            if (nodeNote.getNotetypecode().equalsIgnoreCase("editorialNote")) {
                nodeNoteEditorial.add(nodeNote);
            }
            if (nodeNote.getNotetypecode().equalsIgnoreCase("historyNote")) {
                nodeNoteHistory.add(nodeNote);
            }
            if (nodeNote.getNotetypecode().equalsIgnoreCase("scopeNote")) {
                nodeNoteScope.add(nodeNote);
            }
        }
        // types : definition; editorialNote; historyNote ; scopeNote
        for (NodeNote nodeNote : nodeConceptExport.getNodeNoteTerm()) {
            nodeNote.setLexicalvalue(nodeNote.getLexicalvalue().replace('\r', ' '));
            nodeNote.setLexicalvalue(nodeNote.getLexicalvalue().replace('\n', ' '));
            if (nodeNote.getNotetypecode().equalsIgnoreCase("definition")) {
                nodeNoteDefinition.add(nodeNote);
            }
            if (nodeNote.getNotetypecode().equalsIgnoreCase("editorialNote")) {
                nodeNoteEditorial.add(nodeNote);
            }
            if (nodeNote.getNotetypecode().equalsIgnoreCase("historyNote")) {
                nodeNoteHistory.add(nodeNote);
            }
            if (nodeNote.getNotetypecode().equalsIgnoreCase("scopeNote")) {
                nodeNoteScope.add(nodeNote);
            }
        }
        // definition
        first = true;
        for (NodeNote nodeNote : nodeNoteDefinition) {
            if (listLangues.contains(nodeNote.getLang())) {
                if (!first) {
                    tabulateBuff.append("##");
                }
                tabulateBuff.append(nodeNote.getLexicalvalue());
                tabulateBuff.append("::");
                tabulateBuff.append(nodeNote.getLang());
                first = false;
            }
        }
        tabulateBuff.append(";");
        // scopeNote
        first = true;
        for (NodeNote nodeNote : nodeNoteScope) {
            if (listLangues.contains(nodeNote.getLang())) {
                if (!first) {
                    tabulateBuff.append("##");
                }
                tabulateBuff.append(nodeNote.getLexicalvalue());
                tabulateBuff.append("::");
                tabulateBuff.append(nodeNote.getLang());
                first = false;
            }
        }
        tabulateBuff.append(";");
        // historyNote
        first = true;
        for (NodeNote nodeNote : nodeNoteHistory) {
            if (listLangues.contains(nodeNote.getLang())) {
                if (!first) {
                    tabulateBuff.append("##");
                }
                tabulateBuff.append(nodeNote.getLexicalvalue());
                tabulateBuff.append("::");
                tabulateBuff.append(nodeNote.getLang());
                first = false;
            }
        }
        tabulateBuff.append(";");
        // editorialNote
        first = true;
        for (NodeNote nodeNote : nodeNoteEditorial) {
            if (listLangues.contains(nodeNote.getLang())) {
                if (!first) {
                    tabulateBuff.append("##");
                }
                tabulateBuff.append(nodeNote.getLexicalvalue());
                tabulateBuff.append("::");
                tabulateBuff.append(nodeNote.getLang());
                first = false;
            }
        }
        tabulateBuff.append(";");
        // dates
        tabulateBuff.append(nodeConceptExport.getConcept().getCreated());
        tabulateBuff.append(";");
        tabulateBuff.append(nodeConceptExport.getConcept().getModified());
        tabulateBuff.append("\n");
        first = true;
    }
    return true;
}
Also used : NodeConceptExport(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport) ArrayList(java.util.ArrayList) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM) NodeAlignment(mom.trd.opentheso.bdd.helper.nodes.NodeAlignment) NodeHieraRelation(mom.trd.opentheso.bdd.helper.nodes.NodeHieraRelation) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)

Example 13 with NodeAlignment

use of mom.trd.opentheso.bdd.helper.nodes.NodeAlignment in project opentheso by miledrousset.

the class ImportRdf4jHelper method addMatch.

private void addMatch(AddConceptsStruct acs) {
    int prop;
    int id_type = -1;
    NodeAlignment nodeAlignment;
    for (SKOSMatch match : acs.conceptResource.getMatchList()) {
        prop = match.getProperty();
        nodeAlignment = new NodeAlignment();
        switch(prop) {
            case SKOSProperty.closeMatch:
                id_type = 2;
                break;
            case SKOSProperty.exactMatch:
                id_type = 1;
                break;
            case SKOSProperty.broadMatch:
                id_type = 3;
                break;
            case SKOSProperty.narrowMatch:
                id_type = 5;
                break;
            case SKOSProperty.relatedMatch:
                id_type = 4;
                break;
        }
        nodeAlignment.setId_author(idUser);
        nodeAlignment.setConcept_target("");
        nodeAlignment.setThesaurus_target("");
        nodeAlignment.setUri_target(match.getValue());
        nodeAlignment.setInternal_id_concept(acs.concept.getIdConcept());
        nodeAlignment.setInternal_id_thesaurus(idTheso);
        nodeAlignment.setAlignement_id_type(id_type);
        acs.nodeAlignments.add(nodeAlignment);
    }
}
Also used : NodeAlignment(mom.trd.opentheso.bdd.helper.nodes.NodeAlignment) SKOSMatch(mom.trd.opentheso.skosapi.SKOSMatch)

Example 14 with NodeAlignment

use of mom.trd.opentheso.bdd.helper.nodes.NodeAlignment in project opentheso by miledrousset.

the class ConceptHelper method getConceptForExport.

/**
 * Cette fonction permet de récupérer toutes les informations concernant un
 * Concept par son id et son thésaurus et la langue On récupère aussi les
 * IdArk si Ark est actif
 *
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @param isArkActive
 * @return Objet class NodeConcept
 */
public NodeConceptExport getConceptForExport(HikariDataSource ds, String idConcept, String idThesaurus, boolean isArkActive) {
    NodeConceptExport nodeConceptExport = new NodeConceptExport();
    // récupération des BT
    RelationsHelper relationsHelper = new RelationsHelper();
    ArrayList<NodeHieraRelation> nodeListOfBT_Ark = relationsHelper.getListBT(ds, idConcept, idThesaurus);
    nodeConceptExport.setNodeListOfBT(nodeListOfBT_Ark);
    // récupération du Concept
    Concept concept = getThisConcept(ds, idConcept, idThesaurus);
    /**
     * Attention si on passe par le null, ca veut dire qu'il y a une
     * incohérence dans la base à corriger !!!!!
     */
    if (concept == null) {
        return null;
    }
    nodeConceptExport.setConcept(concept);
    AlignmentHelper alignmentHelper = new AlignmentHelper();
    ArrayList<NodeAlignment> nodeAlignmentList = alignmentHelper.getAllAlignmentOfConcept(ds, idConcept, idThesaurus);
    nodeConceptExport.setNodeAlignmentsList(nodeAlignmentList);
    // récupération des termes spécifiques
    ArrayList<NodeHieraRelation> nodeListIdsOfNT_Ark = relationsHelper.getListNT(ds, idConcept, idThesaurus);
    nodeConceptExport.setNodeListOfNT(nodeListIdsOfNT_Ark);
    // récupération des termes associés
    ArrayList<NodeHieraRelation> nodeListIdsOfRT_Ark = relationsHelper.getListRT(ds, idConcept, idThesaurus);
    nodeConceptExport.setNodeListIdsOfRT(nodeListIdsOfRT_Ark);
    // récupération des Non Prefered Term
    nodeConceptExport.setNodeEM(new TermHelper().getAllNonPreferredTerms(ds, new TermHelper().getIdTermOfConcept(ds, idConcept, idThesaurus), idThesaurus));
    // récupération des traductions
    nodeConceptExport.setNodeTermTraductions(new TermHelper().getAllTraductionsOfConcept(ds, idConcept, idThesaurus));
    // récupération des Groupes ou domaines
    ArrayList<NodeUri> nodeListIdsOfConceptGroup_Ark = getListIdArkOfGroup(ds, new GroupHelper().getListIdGroupOfConcept(ds, idThesaurus, idConcept), idThesaurus);
    nodeConceptExport.setNodeListIdsOfConceptGroup(nodeListIdsOfConceptGroup_Ark);
    // récupération des notes du Terme
    String idTerm = new TermHelper().getIdTermOfConcept(ds, idConcept, idThesaurus);
    nodeConceptExport.setNodeNoteTerm(new NoteHelper().getListNotesTermAllLang(ds, idTerm, idThesaurus));
    // récupération des Notes du Concept
    nodeConceptExport.setNodeNoteConcept(new NoteHelper().getListNotesConceptAllLang(ds, idConcept, idThesaurus));
    // récupération des coordonnées GPS
    GpsHelper gpsHelper = new GpsHelper();
    NodeGps nodeGps = gpsHelper.getCoordinate(ds, idConcept, idThesaurus);
    if (nodeGps != null) {
        nodeConceptExport.setNodeGps(nodeGps);
    }
    return nodeConceptExport;
}
Also used : NodeConcept(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept) Concept(mom.trd.opentheso.bdd.datas.Concept) NodeConceptExport(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport) NodeGps(mom.trd.opentheso.bdd.helper.nodes.NodeGps) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) NodeAlignment(mom.trd.opentheso.bdd.helper.nodes.NodeAlignment) NodeHieraRelation(mom.trd.opentheso.bdd.helper.nodes.NodeHieraRelation)

Example 15 with NodeAlignment

use of mom.trd.opentheso.bdd.helper.nodes.NodeAlignment in project opentheso by miledrousset.

the class WriteFileSKOS 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
 * @param selectedLanguages
 *
 * @return true ou false
 */
public boolean writeDescriptor(NodeConceptExport nodeConceptExport, List<NodeLang> selectedLanguages) {
    /*
        // test pour savoir si le concept n'a pas de PrefLabel dans cette langue, il sera ignoré
        boolean havePrefLabel = false;
        if(selectedLanguages != null) {
            for (int i = 0; i < nodeConceptExport.getNodeTermTraductions().size(); i++) {
                for (NodeLang selectedLanguage : selectedLanguages) {
                    if (nodeConceptExport.getNodeTermTraductions().get(i).getLang().equalsIgnoreCase(
                            selectedLanguage.getCode())) {
                        havePrefLabel = true;
                    }
                }
            }
            if(!havePrefLabel) return true; // on ignore le concept
        }*/
    SKOSResource concept = new SKOSResource(getUri(nodeConceptExport));
    if (nodeConceptExport == null) {
        return true;
    }
    if (nodeConceptExport.getNodeTermTraductions() == null) {
        return true;
    }
    for (int i = 0; i < nodeConceptExport.getNodeTermTraductions().size(); i++) {
        if (selectedLanguages != null) {
            // if(nodeConceptExport.getNodeTermTraductions().get(i).getLang().equalsIgnoreCase("fr"))
            for (NodeLang selectedLanguage : selectedLanguages) {
                if (nodeConceptExport.getNodeTermTraductions().get(i).getLang().equalsIgnoreCase(selectedLanguage.getCode())) {
                    concept.addLabel(nodeConceptExport.getNodeTermTraductions().get(i).getLexicalValue(), nodeConceptExport.getNodeTermTraductions().get(i).getLang(), SKOSProperty.prefLabel);
                }
            }
        } else {
            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().getNotation().isEmpty()) {
        concept.addNotation(nodeConceptExport.getConcept().getNotation(), SKOSProperty.notation);
    }
    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), 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.getNodeListIdsOfBT().get(i), SKOSProperty.broader);
        concept.addRelation(getRelationUri(nodeConceptExport.getNodeListOfBT().get(i).getUri(), nodeConceptExport.getConcept().getIdThesaurus()), SKOSProperty.broader);
    }
    for (int i = 0; i < nodeConceptExport.getNodeListOfNT().size(); i++) {
        // concept.addRelation(URI + "/concept#" + nodeConceptExport.getNodeListIdsOfNT().get(i), SKOSProperty.narrower);
        concept.addRelation(getRelationUri(nodeConceptExport.getNodeListOfNT().get(i).getUri(), nodeConceptExport.getConcept().getIdThesaurus()), SKOSProperty.narrower);
    }
    for (int i = 0; i < nodeConceptExport.getNodeListIdsOfRT().size(); i++) {
        // concept.addRelation(URI + "/concept#" + nodeConceptExport.getNodeListIdsOfRT().get(i), SKOSProperty.related);
        concept.addRelation(getRelationUri(nodeConceptExport.getNodeListIdsOfRT().get(i).getUri(), 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(prepareUriTohtml(alignment.getUri_target()), SKOSMapping.exactMatch);
        }
        // alignement closeMatch
        if (alignment.getAlignement_id_type() == 2) {
            concept.addMapping(prepareUriTohtml(alignment.getUri_target()), SKOSMapping.closeMatch);
        }
        // alignement broadMatch
        if (alignment.getAlignement_id_type() == 3) {
            concept.addMapping(prepareUriTohtml(alignment.getUri_target()), SKOSMapping.broadMatch);
        }
        // alignement relatedMatch
        if (alignment.getAlignement_id_type() == 4) {
            concept.addMapping(prepareUriTohtml(alignment.getUri_target()), SKOSMapping.relatedMatch);
        }
        // alignement narrowMatch
        if (alignment.getAlignement_id_type() == 5) {
            concept.addMapping(prepareUriTohtml(alignment.getUri_target()), SKOSMapping.narrowMatch);
        }
    }
    for (NodeNote nodeNote : nodeConceptExport.getNodeNoteTerm()) {
        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);
        }
    }
    for (NodeNote nodeNote : nodeConceptExport.getNodeNoteConcept()) {
        if (nodeNote.getNotetypecode().equalsIgnoreCase("note")) {
            concept.addDocumentation(nodeNote.getLexicalvalue(), nodeNote.getLang(), SKOSProperty.note);
        }
        if (nodeNote.getNotetypecode().equalsIgnoreCase("scopeNote")) {
            concept.addDocumentation(nodeNote.getLexicalvalue(), nodeNote.getLang(), SKOSProperty.scopeNote);
        }
    }
    if (nodeConceptExport.getNodeGps() != null) {
        concept.addSkosGps(nodeConceptExport.getNodeGps().getLatitude(), SKOSProperty.latitude);
        concept.addSkosGps(nodeConceptExport.getNodeGps().getLongitude(), SKOSProperty.longitude);
    }
    skosBuff.append("    ").append(concept.toString());
    return true;
}
Also used : NodeAlignment(mom.trd.opentheso.bdd.helper.nodes.NodeAlignment) SKOSResource(skos.SKOSResource) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)

Aggregations

NodeAlignment (mom.trd.opentheso.bdd.helper.nodes.NodeAlignment)24 ArrayList (java.util.ArrayList)7 AlignmentHelper (mom.trd.opentheso.bdd.helper.AlignmentHelper)7 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)7 Concept (mom.trd.opentheso.bdd.datas.Concept)5 HierarchicalRelationship (mom.trd.opentheso.bdd.datas.HierarchicalRelationship)5 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)5 Connection (java.sql.Connection)4 SQLException (java.sql.SQLException)4 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)4 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)4 NodeTerm (mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm)4 NodeTermTraduction (mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction)4 Query (org.apache.jena.query.Query)4 QueryExecution (org.apache.jena.query.QueryExecution)4 QuerySolution (org.apache.jena.query.QuerySolution)4 ResultSet (org.apache.jena.query.ResultSet)4 HttpURLConnection (java.net.HttpURLConnection)3 MalformedURLException (java.net.MalformedURLException)3 URL (java.net.URL)3