Search in sources :

Example 6 with OWLEntity

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

the class FindAndReplaceIRIPrefixChangeGenerator method generateChanges.

@Override
public OntologyChangeList<Collection<OWLEntity>> generateChanges(ChangeGenerationContext context) {
    OntologyChangeList.Builder<Collection<OWLEntity>> builder = OntologyChangeList.builder();
    Map<OWLEntity, IRI> renameMap = new HashMap<>();
    for (OWLEntity entity : rootOntology.getSignature(Imports.INCLUDED)) {
        if (!entity.isBuiltIn()) {
            IRI iri = entity.getIRI();
            String iriString = iri.toString();
            if (iriString.startsWith(fromPrefix)) {
                IRI toIRI = IRI.create(toPrefix + iri.subSequence(fromPrefix.length(), iri.length()));
                renameMap.put(entity, toIRI);
            }
        }
    }
    OWLEntityRenamer entityRenamer = new OWLEntityRenamer(rootOntology.getOWLOntologyManager(), rootOntology.getImportsClosure());
    List<OWLOntologyChange> changeList = entityRenamer.changeIRI(renameMap);
    builder.addAll(changeList);
    return builder.build(renameMap.keySet());
}
Also used : IRI(org.semanticweb.owlapi.model.IRI) HashMap(java.util.HashMap) OWLOntologyChange(org.semanticweb.owlapi.model.OWLOntologyChange) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) Collection(java.util.Collection) OWLEntityRenamer(org.semanticweb.owlapi.util.OWLEntityRenamer)

Example 7 with OWLEntity

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

the class OBOTermRelationshipPortletPresenter method displayEntity.

@Override
protected void displayEntity(OWLEntity entity) {
    Optional<OWLEntity> current = getSelectedEntity();
    if (!current.isPresent()) {
        editor.clearValue();
        pristineValue = Optional.empty();
        return;
    }
    if (!(current.get() instanceof OWLClass)) {
        editor.clearValue();
        pristineValue = Optional.empty();
        return;
    }
    dispatch.execute(new GetOboTermRelationshipsAction(getProjectId(), entity.asOWLClass()), this, result -> {
        List<OBORelationship> listOfRels = new ArrayList<>(result.getRelationships().getRelationships());
        pristineValue = Optional.of(listOfRels);
        editor.setValue(listOfRels);
    });
}
Also used : OBORelationship(edu.stanford.bmir.protege.web.shared.obo.OBORelationship) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) ArrayList(java.util.ArrayList) GetOboTermRelationshipsAction(edu.stanford.bmir.protege.web.shared.obo.GetOboTermRelationshipsAction) OWLClass(org.semanticweb.owlapi.model.OWLClass)

Example 8 with OWLEntity

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

the class ClassNameFieldEditor method setValue.

@Override
public void setValue(FormDataValue object) {
    Optional<OWLEntity> entity = object.asOWLEntity();
    entity.ifPresent(e -> {
        dispatchServiceManager.execute(new GetEntityRenderingAction(projectId, e), result -> editor.setValue(result.getEntityData()));
    });
    if (!entity.isPresent()) {
        editor.clearValue();
    }
}
Also used : OWLEntity(org.semanticweb.owlapi.model.OWLEntity) GetEntityRenderingAction(edu.stanford.bmir.protege.web.shared.renderer.GetEntityRenderingAction)

Example 9 with OWLEntity

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

the class LookupEntitiesActionResultCachingStrategy method getInvalidationKeys.

@Override
public Collection<OWLEntity> getInvalidationKeys(LookupEntitiesAction action, LookupEntitiesResult result) {
    List<OWLEntity> entities = new ArrayList<OWLEntity>();
    for (EntityLookupResult res : result.getEntityLookupResults()) {
        OWLEntity entity = res.getOWLEntityData().getEntity();
        entities.add(entity);
    }
    return entities;
}
Also used : OWLEntity(org.semanticweb.owlapi.model.OWLEntity) ArrayList(java.util.ArrayList) EntityLookupResult(edu.stanford.bmir.protege.web.shared.entity.EntityLookupResult)

Example 10 with OWLEntity

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

the class WatchPresenter method start.

public void start(final OWLEntity forEntity) {
    final UserId userId = loggedInUserProvider.getCurrentUserId();
    dispatchServiceManager.execute(new GetWatchesAction(projectId, userId, forEntity), new DispatchServiceCallback<GetWatchesResult>() {

        @Override
        public void handleSuccess(GetWatchesResult result) {
            Set<Watch> watches = result.getWatches();
            updateDialog(watches);
            WebProtegeDialog<WatchTypeSelection> dlg = new WebProtegeDialog<>(controller);
            dlg.show();
            controller.setDialogButtonHandler(DialogButton.OK, (data, closer) -> {
                closer.hide();
                handleWatchTypeForEntity(data, forEntity);
            });
        }
    });
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) GWT(com.google.gwt.core.client.GWT) DispatchServiceCallback(edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceCallback) DialogButton(edu.stanford.bmir.protege.web.client.library.dlg.DialogButton) Inject(javax.inject.Inject) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) edu.stanford.bmir.protege.web.shared.watches(edu.stanford.bmir.protege.web.shared.watches) LoggedInUserProvider(edu.stanford.bmir.protege.web.client.user.LoggedInUserProvider) DispatchServiceManager(edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceManager) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) Optional(java.util.Optional) WebProtegeDialog(edu.stanford.bmir.protege.web.client.library.dlg.WebProtegeDialog) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) Collections(java.util.Collections) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) WebProtegeDialog(edu.stanford.bmir.protege.web.client.library.dlg.WebProtegeDialog)

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