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);
}
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);
}
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);
}
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;
}
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()));
}
Aggregations