Search in sources :

Example 1 with OWLPrimitiveData

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

the class CSVColumnRelationEditorViewImpl method handleRelationTypeFieldChanged.

@UiHandler("relationTypeField")
protected void handleRelationTypeFieldChanged(ChangeEvent event) {
    final Optional<OWLPrimitiveData> property = propertyField.getValue();
    if (property.isPresent()) {
        EntityType<?> propertyType = ((OWLEntity) property.get().getObject()).getEntityType();
        if (getColumnType().isPresent()) {
            ColumnType type = getColumnType().get();
            List<EntityType<?>> propertyTypes = type.getPropertyTypes();
            if (!propertyTypes.contains(propertyType)) {
                final EntityType<?> firstPermissiblePropertyType = propertyTypes.get(0);
                propertyField.coerceToEntityType(firstPermissiblePropertyType);
            }
        }
    }
    ValueChangeEvent.fire(this, property);
}
Also used : EntityType(org.semanticweb.owlapi.model.EntityType) ColumnType(edu.stanford.bmir.protege.web.shared.csv.ColumnType) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) OWLPrimitiveData(edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData) UiHandler(com.google.gwt.uibinder.client.UiHandler)

Example 2 with OWLPrimitiveData

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

the class CSVColumnRelationEditorViewImpl method updateRelationTypeField.

private void updateRelationTypeField() {
    Optional<OWLPrimitiveData> property = propertyField.getValue();
    int selIndex = relationTypeField.getSelectedIndex();
    Optional<String> selectedItem;
    if (selIndex != -1) {
        selectedItem = Optional.of(relationTypeField.getItemText(selIndex));
    } else {
        selectedItem = Optional.empty();
    }
    List<String> nextItems = new ArrayList<>();
    if (property.isPresent()) {
        OWLPrimitiveData primitiveData = property.get();
        final OWLEntity prop = (OWLEntity) primitiveData.getObject();
        boolean freshEntity = DataFactory.isFreshEntity(prop);
        if (freshEntity) {
            for (ColumnType columnType : ColumnType.values()) {
                nextItems.add(columnType.getDisplayName());
            }
        } else {
            for (ColumnType columnType : ColumnType.values()) {
                if (columnType.isPropertyType(prop.getEntityType())) {
                    nextItems.add(columnType.getDisplayName());
                }
            }
        }
    }
    int nextSelIndex = 0;
    relationTypeField.clear();
    for (int i = 0; i < nextItems.size(); i++) {
        String nextItem = nextItems.get(i);
        relationTypeField.addItem(nextItem);
        if (selectedItem.orElse("").equals(nextItem)) {
            nextSelIndex = i;
        }
    }
    relationTypeField.setSelectedIndex(nextSelIndex);
}
Also used : ColumnType(edu.stanford.bmir.protege.web.shared.csv.ColumnType) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) ArrayList(java.util.ArrayList) OWLPrimitiveData(edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData)

Example 3 with OWLPrimitiveData

use of edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData 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 4 with OWLPrimitiveData

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

the class NamedIndividualFrameEditor method getRawTypes.

private Set<OWLClassData> getRawTypes() {
    Set<OWLClassData> rawTypes = new HashSet<>();
    Optional<List<OWLPrimitiveData>> typesList = types.getValue();
    if (typesList.isPresent()) {
        for (OWLPrimitiveData data : typesList.get()) {
            rawTypes.add((OWLClassData) data);
        }
    }
    return rawTypes;
}
Also used : OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) PropertyValueList(edu.stanford.bmir.protege.web.shared.frame.PropertyValueList) OWLPrimitiveData(edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData)

Example 5 with OWLPrimitiveData

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

the class ClassNameFieldEditor method getValue.

@Override
public Optional<FormDataValue> getValue() {
    Optional<OWLPrimitiveData> value = editor.getValue();
    if (!value.isPresent()) {
        return Optional.empty();
    }
    OWLPrimitiveData theValue = value.get();
    if (!(theValue instanceof OWLClassData)) {
        return Optional.empty();
    }
    return Optional.of(FormDataPrimitive.get(((OWLClassData) theValue).getEntity()));
}
Also used : OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) OWLPrimitiveData(edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData)

Aggregations

OWLPrimitiveData (edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData)12 OWLClassData (edu.stanford.bmir.protege.web.shared.entity.OWLClassData)5 OWLLiteralData (edu.stanford.bmir.protege.web.shared.entity.OWLLiteralData)3 ColumnType (edu.stanford.bmir.protege.web.shared.csv.ColumnType)2 PropertyValueList (edu.stanford.bmir.protege.web.shared.frame.PropertyValueList)2 OWLEntity (org.semanticweb.owlapi.model.OWLEntity)2 UiHandler (com.google.gwt.uibinder.client.UiHandler)1 OWLAnnotationPropertyData (edu.stanford.bmir.protege.web.shared.entity.OWLAnnotationPropertyData)1 OWLDatatypeData (edu.stanford.bmir.protege.web.shared.entity.OWLDatatypeData)1 OWLEntityData (edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)1 OWLNamedIndividualData (edu.stanford.bmir.protege.web.shared.entity.OWLNamedIndividualData)1 OWLObjectPropertyData (edu.stanford.bmir.protege.web.shared.entity.OWLObjectPropertyData)1 OWLPropertyData (edu.stanford.bmir.protege.web.shared.entity.OWLPropertyData)1 AnnotationPropertyFrame (edu.stanford.bmir.protege.web.shared.frame.AnnotationPropertyFrame)1 DataPropertyFrame (edu.stanford.bmir.protege.web.shared.frame.DataPropertyFrame)1 ArrayList (java.util.ArrayList)1 EntityType (org.semanticweb.owlapi.model.EntityType)1 OWLLiteral (org.semanticweb.owlapi.model.OWLLiteral)1