Search in sources :

Example 1 with SKOSMatch

use of mom.trd.opentheso.skosapi.SKOSMatch 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 2 with SKOSMatch

use of mom.trd.opentheso.skosapi.SKOSMatch in project opentheso by miledrousset.

the class WritePdf method writeTerm.

/**
 * ajoute un paragraphe qui decri le term dans le document PDF
 *
 * @param concept
 * @param paragraphs
 */
private void writeTerm(SKOSResource concept, ArrayList<Paragraph> paragraphs, String langue, String langue2) {
    String id = getIdFromUri(concept.getUri());
    int altLabelCount = 0;
    ArrayList<Integer> tradList = idToIsTrad.get(id);
    if (tradList != null) {
        for (int lab : tradList) {
            if (lab == SKOSProperty.altLabel) {
                altLabelCount++;
            }
        }
    }
    int altLabelWrite = 0;
    for (SKOSLabel label : concept.getLabelsList()) {
        if (label.getLanguage().equals(langue) || label.getLanguage().equals(langue2)) {
            String labelValue;
            boolean prefIsTrad = false;
            boolean altIsTrad = false;
            if (label.getLanguage().equals(langue)) {
                labelValue = label.getLabel();
            } else {
                if (tradList != null) {
                    if (tradList.contains(SKOSProperty.prefLabel) && label.getProperty() == SKOSProperty.prefLabel) {
                        prefIsTrad = true;
                    }
                    if (tradList.contains(SKOSProperty.altLabel) && label.getProperty() == SKOSProperty.altLabel) {
                        if (altLabelCount > altLabelWrite) {
                            altIsTrad = true;
                        }
                        altLabelWrite++;
                    }
                }
                labelValue = "-";
            }
            if (label.getProperty() == SKOSProperty.prefLabel && !prefIsTrad) {
                Chunk chunk = new Chunk(labelValue, termFont);
                chunk.setLocalDestination(id);
                paragraphs.add(new Paragraph(chunk));
            } else if (label.getProperty() == SKOSProperty.altLabel && !altIsTrad) {
                paragraphs.add(new Paragraph("    USE: " + labelValue, textFont));
            }
        }
    }
    paragraphs.add(new Paragraph("    ID: " + id, textFont));
    for (SKOSRelation relation : concept.getRelationsList()) {
        int prop = relation.getProperty();
        String codeRelation;
        switch(prop) {
            case SKOSProperty.broader:
                codeRelation = "BT";
                break;
            case SKOSProperty.narrower:
                codeRelation = "NT";
                break;
            case SKOSProperty.related:
                codeRelation = "RT";
                break;
            case SKOSProperty.relatedHasPart:
                codeRelation = "RHP";
                break;
            case SKOSProperty.relatedPartOf:
                codeRelation = "RPO";
                break;
            case SKOSProperty.narrowerGeneric:
                codeRelation = "NTG";
                break;
            case SKOSProperty.narrowerInstantive:
                codeRelation = "NTI";
                break;
            case SKOSProperty.narrowerPartitive:
                codeRelation = "NTP";
                break;
            case SKOSProperty.broaderGeneric:
                codeRelation = "BTG";
                break;
            case SKOSProperty.broaderInstantive:
                codeRelation = "BTI";
                break;
            case SKOSProperty.broaderPartitive:
                codeRelation = "BTP";
                break;
            default:
                continue;
        }
        String key = getIdFromUri(relation.getTargetUri());
        String targetName = idToNameHashMap.get(key);
        if (targetName == null) {
            targetName = key;
        }
        Chunk chunk = new Chunk("    " + codeRelation + ": " + targetName, relationFont);
        chunk.setLocalGoto(getIdFromUri(relation.getTargetUri()));
        paragraphs.add(new Paragraph(chunk));
    }
    for (SKOSDocumentation doc : concept.getDocumentationsList()) {
        if (!doc.getLanguage().equals(langue) && !doc.getLanguage().equals(langue2)) {
            continue;
        }
        int docCount = 0;
        if (tradList != null) {
            for (int lab : tradList) {
                if (lab == SKOSProperty.note) {
                    docCount++;
                }
            }
        }
        int docWrite = 0;
        int prop = doc.getProperty();
        String docTypeName;
        switch(prop) {
            case SKOSProperty.definition:
                docTypeName = "definition";
                break;
            case SKOSProperty.scopeNote:
                docTypeName = "scopeNote";
                break;
            case SKOSProperty.example:
                docTypeName = "example";
                break;
            case SKOSProperty.historyNote:
                docTypeName = "historyNote";
                break;
            case SKOSProperty.editorialNote:
                docTypeName = "editorialNote";
                break;
            case SKOSProperty.changeNote:
                docTypeName = "changeNote";
                break;
            case SKOSProperty.note:
                docTypeName = "note";
                break;
            default:
                docTypeName = "note";
                break;
        }
        String docText = "";
        boolean docIsTrad = false;
        if (doc.getLanguage().equals(langue)) {
            docText = doc.getText();
        } else {
            if (tradList != null && tradList.contains(SKOSProperty.note)) {
                if (docCount > docWrite) {
                    docIsTrad = true;
                }
                docWrite++;
            }
        }
        if (!docIsTrad) {
            paragraphs.add(new Paragraph("    " + docTypeName + ": " + docText, textFont));
        }
    }
    for (SKOSMatch match : concept.getMatchList()) {
        int prop = match.getProperty();
        String matchTypeName = null;
        switch(prop) {
            case SKOSProperty.exactMatch:
                matchTypeName = "exactMatch";
                break;
            case SKOSProperty.closeMatch:
                matchTypeName = "closeMatch";
                break;
            case SKOSProperty.broadMatch:
                matchTypeName = "broadMatch";
                break;
            case SKOSProperty.relatedMatch:
                matchTypeName = "relatedMatch";
                break;
            case SKOSProperty.narrowMatch:
                matchTypeName = "narrowMatch";
                break;
        }
        paragraphs.add(new Paragraph("    " + matchTypeName + ": " + match.getValue(), textFont));
    }
    SKOSGPSCoordinates gps = concept.getGPSCoordinates();
    String lat = gps.getLat();
    String lon = gps.getLon();
    if (lat != null && lon != null) {
        paragraphs.add(new Paragraph("    lat: " + lat, textFont));
        paragraphs.add(new Paragraph("    lat: " + lon, textFont));
    }
}
Also used : SKOSDocumentation(mom.trd.opentheso.skosapi.SKOSDocumentation) SKOSMatch(mom.trd.opentheso.skosapi.SKOSMatch) SKOSRelation(mom.trd.opentheso.skosapi.SKOSRelation) SKOSLabel(mom.trd.opentheso.skosapi.SKOSLabel) Chunk(com.itextpdf.text.Chunk) SKOSGPSCoordinates(mom.trd.opentheso.skosapi.SKOSGPSCoordinates) Paragraph(com.itextpdf.text.Paragraph)

Example 3 with SKOSMatch

use of mom.trd.opentheso.skosapi.SKOSMatch in project opentheso by miledrousset.

the class WriteRdf4j method writeMatch.

private void writeMatch(SKOSResource resource) {
    int prop;
    IRI uri;
    for (SKOSMatch match : resource.getMatchList()) {
        prop = match.getProperty();
        try {
            uri = vf.createIRI(match.getValue());
            switch(prop) {
                case SKOSProperty.exactMatch:
                    builder.add(SKOS.EXACT_MATCH, uri);
                    break;
                case SKOSProperty.closeMatch:
                    builder.add(SKOS.CLOSE_MATCH, uri);
                    break;
                case SKOSProperty.broadMatch:
                    builder.add(SKOS.BROAD_MATCH, uri);
                    break;
                case SKOSProperty.relatedMatch:
                    builder.add(SKOS.RELATED_MATCH, uri);
                    break;
                case SKOSProperty.narrowMatch:
                    builder.add(SKOS.NARROW_MATCH, uri);
                    break;
                default:
                    break;
            }
        } catch (Exception ex) {
            Logger.getLogger(WriteRdf4j.class.getName()).log(Level.SEVERE, "Error URI Alignement : " + resource.getUri(), ex);
        }
    }
}
Also used : IRI(org.eclipse.rdf4j.model.IRI) SKOSMatch(mom.trd.opentheso.skosapi.SKOSMatch)

Aggregations

SKOSMatch (mom.trd.opentheso.skosapi.SKOSMatch)3 Chunk (com.itextpdf.text.Chunk)1 Paragraph (com.itextpdf.text.Paragraph)1 NodeAlignment (mom.trd.opentheso.bdd.helper.nodes.NodeAlignment)1 SKOSDocumentation (mom.trd.opentheso.skosapi.SKOSDocumentation)1 SKOSGPSCoordinates (mom.trd.opentheso.skosapi.SKOSGPSCoordinates)1 SKOSLabel (mom.trd.opentheso.skosapi.SKOSLabel)1 SKOSRelation (mom.trd.opentheso.skosapi.SKOSRelation)1 IRI (org.eclipse.rdf4j.model.IRI)1