Search in sources :

Example 1 with OWLLiteralData

use of edu.stanford.bmir.protege.web.shared.entity.OWLLiteralData in project webprotege by protegeproject.

the class PrimitiveDataParserImpl_LiteralParsing_TestCase method verifyResult.

private void verifyResult(String lexicalValue, OWL2Datatype datatype) {
    OWLLiteral expected = dataFactory.getOWLLiteral(lexicalValue, datatype);
    Optional<OWLPrimitiveData> expectedData = Optional.of(new OWLLiteralData(expected));
    Mockito.verify(primitiveDataParserCallback).onSuccess(expectedData);
}
Also used : OWLLiteralData(edu.stanford.bmir.protege.web.shared.entity.OWLLiteralData) OWLLiteral(org.semanticweb.owlapi.model.OWLLiteral) OWLPrimitiveData(edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData)

Example 2 with OWLLiteralData

use of edu.stanford.bmir.protege.web.shared.entity.OWLLiteralData in project webprotege by protegeproject.

the class TextFieldEditor method getValue.

@Override
public Optional<FormDataValue> getValue() {
    Optional<OWLPrimitiveData> editedValue = editor.getValue();
    if (!editedValue.isPresent()) {
        return Optional.empty();
    }
    OWLLiteralData literalData = (OWLLiteralData) editedValue.get();
    if (literalData.getLiteral().getLiteral().trim().isEmpty()) {
        return Optional.empty();
    }
    if (stringType == StringType.SIMPLE_STRING) {
        return Optional.of(FormDataPrimitive.get(literalData.getLiteral().getLiteral()));
    } else {
        return Optional.of(FormDataPrimitive.get(literalData.getLiteral().getLiteral(), literalData.getLang()));
    }
}
Also used : OWLLiteralData(edu.stanford.bmir.protege.web.shared.entity.OWLLiteralData) OWLPrimitiveData(edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData)

Example 3 with OWLLiteralData

use of edu.stanford.bmir.protege.web.shared.entity.OWLLiteralData in project webprotege by protegeproject.

the class PrimitiveDataParserImpl method handleEntityDataParsingResult.

private void handleEntityDataParsingResult(Optional<OWLEntityData> result, PrimitiveDataParserCallback callback, String trimmedContent, java.util.Optional<String> lang, Set<PrimitiveType> allowedTypes) {
    if (result.isPresent()) {
        callback.onSuccess(java.util.Optional.of(result.get()));
    } else if (allowedTypes.contains(PrimitiveType.IRI) && isAbsoluteIRI(trimmedContent)) {
        IRIData iriData = new IRIData(IRI.create(trimmedContent));
        callback.onSuccess(java.util.Optional.of(iriData));
    } else if (allowedTypes.contains(PrimitiveType.LITERAL)) {
        OWLLiteralData literalData = parseLiteralData(trimmedContent, lang);
        callback.onSuccess(java.util.Optional.of(literalData));
    } else {
        callback.parsingFailure();
    }
}
Also used : IRIData(edu.stanford.bmir.protege.web.shared.entity.IRIData) OWLLiteralData(edu.stanford.bmir.protege.web.shared.entity.OWLLiteralData)

Example 4 with OWLLiteralData

use of edu.stanford.bmir.protege.web.shared.entity.OWLLiteralData in project webprotege by protegeproject.

the class PropertyValueComparator method compare.

@Override
public int compare(PropertyValue o1, PropertyValue o2) {
    // if(o1.getState() == State.DERIVED) {
    // if(o2.getState() != State.DERIVED) {
    // return -1;
    // }
    // }
    // else if(o2.getState() == State.DERIVED) {
    // return 1;
    // }
    // Sort property values by language, property rendering and then value rendering.
    // rdfs:label and then rdfs:comment get priority over other properties.
    OWLPrimitiveData val1 = o1.getValue();
    OWLPrimitiveData val2 = o2.getValue();
    if (val1 instanceof OWLLiteralData && val2 instanceof OWLLiteralData) {
        OWLLiteralData lit1 = (OWLLiteralData) val1;
        OWLLiteralData lit2 = (OWLLiteralData) val2;
        if (lit1.hasLang() && lit2.hasLang()) {
            if (isDefaultLanguage(lit1)) {
                if (!isDefaultLanguage(lit2)) {
                    return BEFORE;
                }
            } else {
                if (isDefaultLanguage(lit2)) {
                    return AFTER;
                }
            }
            int langDelta = lit1.getLang().compareToIgnoreCase(lit2.getLang());
            if (langDelta != 0) {
                return langDelta;
            }
        }
    }
    OWLPropertyData property1 = o1.getProperty();
    OWLPropertyData property2 = o2.getProperty();
    if (property1.isOWLAnnotationProperty()) {
        if (property2.isOWLAnnotationProperty()) {
            OWLAnnotationPropertyData annoProp1 = (OWLAnnotationPropertyData) property1;
            OWLAnnotationPropertyData annoProp2 = (OWLAnnotationPropertyData) property2;
            return annotationPropertyComparator.compare(annoProp1.getEntity(), annoProp2.getEntity());
        } else {
            return BEFORE;
        }
    } else if (property2.isOWLAnnotationProperty()) {
        return AFTER;
    }
    String prop1BrowserText = property1.getBrowserText();
    String prop2BrowserText = property2.getBrowserText();
    int delta = prop1BrowserText.compareToIgnoreCase(prop2BrowserText);
    if (delta != 0) {
        return delta;
    }
    String val1Rendering = val1.getBrowserText();
    String val2Rendering = val2.getBrowserText();
    return val1Rendering.compareToIgnoreCase(val2Rendering);
}
Also used : OWLAnnotationPropertyData(edu.stanford.bmir.protege.web.shared.entity.OWLAnnotationPropertyData) OWLLiteralData(edu.stanford.bmir.protege.web.shared.entity.OWLLiteralData) OWLPropertyData(edu.stanford.bmir.protege.web.shared.entity.OWLPropertyData) OWLPrimitiveData(edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData)

Example 5 with OWLLiteralData

use of edu.stanford.bmir.protege.web.shared.entity.OWLLiteralData in project webprotege by protegeproject.

the class TextFieldEditor method setValue.

@Override
public void setValue(FormDataValue object) {
    GWT.log("[TextFieldEditor] " + object);
    Optional<OWLLiteral> primitive = object.asLiteral();
    if (!primitive.isPresent()) {
        clearValue();
    } else {
        editor.setValue(new OWLLiteralData(primitive.get()));
        validateInput();
    }
}
Also used : OWLLiteralData(edu.stanford.bmir.protege.web.shared.entity.OWLLiteralData) OWLLiteral(org.semanticweb.owlapi.model.OWLLiteral)

Aggregations

OWLLiteralData (edu.stanford.bmir.protege.web.shared.entity.OWLLiteralData)6 OWLPrimitiveData (edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData)3 OWLLiteral (org.semanticweb.owlapi.model.OWLLiteral)2 PrimitiveType (edu.stanford.bmir.protege.web.shared.PrimitiveType)1 IRIData (edu.stanford.bmir.protege.web.shared.entity.IRIData)1 OWLAnnotationPropertyData (edu.stanford.bmir.protege.web.shared.entity.OWLAnnotationPropertyData)1 OWLPropertyData (edu.stanford.bmir.protege.web.shared.entity.OWLPropertyData)1 EntityType (org.semanticweb.owlapi.model.EntityType)1