Search in sources :

Example 1 with OWLEntity

use of org.semanticweb.owlapi.model.OWLEntity 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 OWLEntity

use of org.semanticweb.owlapi.model.OWLEntity 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 OWLEntity

use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.

the class DeleteEntityPresenter method start.

/**
 * Start the deletion of the entities represented by the selected nodes in the specified tree.
 * @param treeWidget The tree.
 */
public void start(@Nonnull TreeWidget<EntityHierarchyNode, OWLEntity> treeWidget) {
    final Optional<EntityHierarchyNode> currentSelection = treeWidget.getFirstSelectedUserObject();
    currentSelection.ifPresent(sel -> {
        OWLEntity entity = sel.getEntity();
        String browserText = sel.getBrowserText();
        MessageBox.showConfirmBox(getDeleteConfirmationTitle(entity), getDeleteConfirmationMessage(entity, browserText), CANCEL, DELETE, () -> deleteEntity(entity, treeWidget), CANCEL);
    });
}
Also used : EntityHierarchyNode(edu.stanford.bmir.protege.web.shared.hierarchy.EntityHierarchyNode) OWLEntity(org.semanticweb.owlapi.model.OWLEntity)

Example 4 with OWLEntity

use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.

the class IndividualsListPresenter method deleteSelectedIndividuals.

private void deleteSelectedIndividuals() {
    Collection<OWLNamedIndividualData> selection = view.getSelectedIndividuals();
    Set<OWLEntity> entities = view.getSelectedIndividuals().stream().map(OWLNamedIndividualData::getEntity).collect(toSet());
    dispatchServiceManager.execute(new DeleteEntitiesAction(projectId, entities), view, result -> updateList());
}
Also used : OWLEntity(org.semanticweb.owlapi.model.OWLEntity) OWLNamedIndividualData(edu.stanford.bmir.protege.web.shared.entity.OWLNamedIndividualData) DeleteEntitiesAction(edu.stanford.bmir.protege.web.shared.entity.DeleteEntitiesAction)

Example 5 with OWLEntity

use of org.semanticweb.owlapi.model.OWLEntity in project webprotege by protegeproject.

the class DeleteEntityChangeListGenerator method generateChanges.

@Override
public OntologyChangeList<OWLEntity> generateChanges(ChangeGenerationContext context) {
    OntologyChangeList.Builder<OWLEntity> builder = new OntologyChangeList.Builder<>();
    OWLEntityRemover remover = new OWLEntityRemover(rootOntology.getImportsClosure());
    entity.accept(remover);
    List<RemoveAxiom> changeList = remover.getChanges();
    builder.addAll(changeList);
    return builder.build(entity);
}
Also used : OntologyChangeList(edu.stanford.bmir.protege.web.server.change.OntologyChangeList) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) OWLEntityRemover(org.semanticweb.owlapi.util.OWLEntityRemover) RemoveAxiom(org.semanticweb.owlapi.model.RemoveAxiom)

Aggregations

OWLEntity (org.semanticweb.owlapi.model.OWLEntity)45 Test (org.junit.Test)13 OWLOntologyChange (org.semanticweb.owlapi.model.OWLOntologyChange)7 OWLEntityData (edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)6 ArrayList (java.util.ArrayList)6 Nonnull (javax.annotation.Nonnull)6 Inject (javax.inject.Inject)6 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)5 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)4 AccessManager (edu.stanford.bmir.protege.web.server.access.AccessManager)3 IRI (org.semanticweb.owlapi.model.IRI)3 DBObject (com.mongodb.DBObject)2 EntitySuggestion (edu.stanford.bmir.protege.web.client.library.suggest.EntitySuggestion)2 AbstractProjectActionHandler (edu.stanford.bmir.protege.web.server.dispatch.AbstractProjectActionHandler)2 ExecutionContext (edu.stanford.bmir.protege.web.server.dispatch.ExecutionContext)2 VIEW_PROJECT (edu.stanford.bmir.protege.web.shared.access.BuiltInAction.VIEW_PROJECT)2 ColumnType (edu.stanford.bmir.protege.web.shared.csv.ColumnType)2 OWLPrimitiveData (edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData)2 ProjectEvent (edu.stanford.bmir.protege.web.shared.event.ProjectEvent)2 Comparator.comparing (java.util.Comparator.comparing)2