Search in sources :

Example 6 with ProjectId

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

the class ProjectEntityCrudKitSettingsTestCase method getProjectIdShouldReturnValueEqualToProjectIdSuppliedInConstructor.

@Test
public void getProjectIdShouldReturnValueEqualToProjectIdSuppliedInConstructor() {
    ProjectId projectId = mock(ProjectId.class);
    ProjectEntityCrudKitSettings settings = new ProjectEntityCrudKitSettings(projectId, mock(EntityCrudKitSettings.class));
    assertEquals(projectId, settings.getProjectId());
}
Also used : EntityCrudKitSettings(edu.stanford.bmir.protege.web.shared.crud.EntityCrudKitSettings) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) Test(org.junit.Test)

Example 7 with ProjectId

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

the class WebProtegeActivityMapper method getActivity.

public Activity getActivity(final Place place) {
    GWT.log("[WebProtegeActivityMapper] Map place: " + place);
    if (shouldRedirectToLogin(place)) {
        GWT.log("[WebProtegeActivityMapper] User is not logged in.  Redirecting to login.");
        loginPresenter.setNextPlace(place);
        Scheduler.get().scheduleFinally(() -> placeController.goTo(new LoginPlace(place)));
        return new LoginActivity(loginPresenter);
    }
    if (place instanceof ApplicationSettingsPlace) {
        return new AdminActivity(applicationSettingsPresenter);
    }
    if (place instanceof ProjectSettingsPlace) {
        ProjectSettingsPlace projectSettingsPlace = (ProjectSettingsPlace) place;
        ClientProjectComponent projectComponent = applicationComponent.getClientProjectComponent(new ClientProjectModule(projectSettingsPlace.getProjectId()));
        return new ProjectSettingsActivity(projectComponent.getProjectSettingsPresenter(), projectSettingsPlace.getNextPlace());
    }
    if (place instanceof ProjectPrefixDeclarationsPlace) {
        ProjectPrefixDeclarationsPlace projectPrefixDeclarationsPlace = (ProjectPrefixDeclarationsPlace) place;
        ClientProjectComponent projectComponent = applicationComponent.getClientProjectComponent(new ClientProjectModule(projectPrefixDeclarationsPlace.getProjectId()));
        return new ProjectPrefixDeclarationsActivity(projectPrefixDeclarationsPlace.getProjectId(), projectComponent.getProjectPrefixesPresenter());
    }
    if (place instanceof ProjectTagsPlace) {
        ProjectTagsPlace projectTagsPlace = (ProjectTagsPlace) place;
        ClientProjectComponent projectComponent = applicationComponent.getClientProjectComponent(new ClientProjectModule(projectTagsPlace.getProjectId()));
        return new ProjectTagsActivity(projectTagsPlace.getProjectId(), projectComponent.getProjectTagsPresenter(), projectTagsPlace.getNextPlace());
    }
    if (place instanceof LoginPlace) {
        if (!loggedInUserProvider.getCurrentUserId().isGuest()) {
            Scheduler.get().scheduleFinally(() -> placeController.goTo(new ProjectListPlace()));
        } else {
            LoginPlace loginPlace = (LoginPlace) place;
            Optional<Place> continueTo = loginPlace.getContinueTo();
            if (continueTo.isPresent()) {
                loginPresenter.setNextPlace(continueTo.get());
            } else {
                loginPresenter.setNextPlace(new ProjectListPlace());
            }
            return new LoginActivity(loginPresenter);
        }
    }
    if (place instanceof SignUpPlace) {
        SignUpPlace signUpPlace = (SignUpPlace) place;
        Optional<Place> continueTo = signUpPlace.getContinueTo();
        continueTo.ifPresent(signUpPresenter::setContinueTo);
        return new SignUpActivity(signUpPresenter);
    }
    if (place instanceof ProjectListPlace) {
        return new ProjectListActivity(projectManagerPresenter);
    }
    if (place instanceof ProjectViewPlace) {
        ProjectViewPlace projectViewPlace = (ProjectViewPlace) place;
        ProjectPresenter presenter = getProjectPresenter(projectViewPlace);
        lastProjectPresenter = Optional.of(presenter);
        lastUser = Optional.of(loggedInUserProvider.getCurrentUserId());
        return new ProjectViewActivity(presenter, projectViewPlace);
    }
    if (place instanceof SharingSettingsPlace) {
        SharingSettingsPlace sharingSettingsPlace = (SharingSettingsPlace) place;
        ProjectId projectId = sharingSettingsPlace.getProjectId();
        ClientProjectComponent projectComponent = applicationComponent.getClientProjectComponent(new ClientProjectModule(projectId));
        SharingSettingsPresenter presenter = projectComponent.getSharingSettingsPresenter();
        return new SharingSettingsActivity(presenter, sharingSettingsPlace);
    }
    if (place instanceof CollectionViewPlace) {
        CollectionViewPlace collectionViewPlace = (CollectionViewPlace) place;
        CollectionPresenter collectionPresenter = getCollectionPresenter(collectionViewPlace);
        // lastUser = Optional.of(loggedInUserProvider.getCurrentUserId());
        return new CollectionViewActivity(collectionPresenter, collectionViewPlace);
    }
    return null;
}
Also used : SharingSettingsActivity(edu.stanford.bmir.protege.web.client.sharing.SharingSettingsActivity) CollectionPresenter(edu.stanford.bmir.protege.web.client.collection.CollectionPresenter) ClientProjectModule(edu.stanford.bmir.protege.web.client.inject.ClientProjectModule) ClientProjectComponent(edu.stanford.bmir.protege.web.client.inject.ClientProjectComponent) ProjectSettingsActivity(edu.stanford.bmir.protege.web.client.projectsettings.ProjectSettingsActivity) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) ProjectPresenter(edu.stanford.bmir.protege.web.client.project.ProjectPresenter) LoginPlace(edu.stanford.bmir.protege.web.shared.login.LoginPlace) SharingSettingsPlace(edu.stanford.bmir.protege.web.shared.sharing.SharingSettingsPlace) ProjectTagsActivity(edu.stanford.bmir.protege.web.client.tag.ProjectTagsActivity) Place(com.google.gwt.place.shared.Place) LoginPlace(edu.stanford.bmir.protege.web.shared.login.LoginPlace) SharingSettingsPlace(edu.stanford.bmir.protege.web.shared.sharing.SharingSettingsPlace) SharingSettingsPresenter(edu.stanford.bmir.protege.web.client.sharing.SharingSettingsPresenter)

Example 8 with ProjectId

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

the class PermissionManager method firePermissionsChanged.

/**
 * Fires a {@link PermissionsChangedEvent} for the
 * current project on the event bus.
 */
public void firePermissionsChanged() {
    GWT.log("[PermissionManager] Firing permissions changed");
    permittedActionCache.clear();
    final UserId userId = loggedInUserProvider.getCurrentUserId();
    final Optional<ProjectId> projectId = activeProjectManager.getActiveProjectId();
    if (!projectId.isPresent()) {
        return;
    }
    final ProjectId theProjectId = projectId.get();
    dispatchServiceManager.execute(new GetProjectPermissionsAction(projectId.get(), userId), result -> {
        UserIdProjectIdKey key = new UserIdProjectIdKey(userId, theProjectId);
        permittedActionCache.putAll(key, result.getAllowedActions());
        GWT.log("[PermissionManager] Firing permissions changed for project: " + projectId);
        eventBus.fireEventFromSource(new PermissionsChangedEvent(theProjectId).asGWTEvent(), theProjectId);
    });
}
Also used : PermissionsChangedEvent(edu.stanford.bmir.protege.web.shared.permissions.PermissionsChangedEvent) GetProjectPermissionsAction(edu.stanford.bmir.protege.web.shared.permissions.GetProjectPermissionsAction) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) UserIdProjectIdKey(edu.stanford.bmir.protege.web.shared.user.UserIdProjectIdKey)

Example 9 with ProjectId

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

the class HighLevelEventGenerator method translateOntologyChanges.

@Override
public void translateOntologyChanges(Revision revision, ChangeApplicationResult<?> changes, final List<ProjectEvent<?>> projectEventList) {
    // TODO: NEED TIDYING AND SPLITTING UP
    final Set<OWLEntity> changedEntities = new HashSet<>();
    for (OWLOntologyChange change : changes.getChangeList()) {
        change.accept(new OWLOntologyChangeVisitor() {

            @Override
            public void visit(@Nonnull AddAxiom change) {
                final OWLAxiom axiom = change.getAxiom();
                handleAxiomChange(axiom);
            }

            @Override
            public void visit(@Nonnull RemoveAxiom change) {
                handleAxiomChange(change.getAxiom());
            }

            @Override
            public void visit(@Nonnull SetOntologyID change) {
                projectEventList.add(new OntologyFrameChangedEvent(change.getOntology().getOntologyID(), projectId));
            }

            @Override
            public void visit(@Nonnull AddImport change) {
                projectEventList.add(new OntologyFrameChangedEvent(change.getOntology().getOntologyID(), projectId));
            }

            @Override
            public void visit(@Nonnull RemoveImport change) {
                projectEventList.add(new OntologyFrameChangedEvent(change.getOntology().getOntologyID(), projectId));
            }

            @Override
            public void visit(@Nonnull AddOntologyAnnotation change) {
                projectEventList.add(new OntologyFrameChangedEvent(change.getOntology().getOntologyID(), projectId));
            }

            @Override
            public void visit(@Nonnull RemoveOntologyAnnotation change) {
                projectEventList.add(new OntologyFrameChangedEvent(change.getOntology().getOntologyID(), projectId));
            }

            private void handleAxiomChange(OWLAxiom axiom) {
                AxiomSubjectProvider p = new AxiomSubjectProvider();
                OWLObject subject = p.getSubject(axiom);
                Set<OWLEntity> entities;
                if (subject instanceof IRI) {
                    entities = hasGetEntitiesWithIRI.getEntitiesWithIRI((IRI) subject);
                } else if (subject instanceof OWLEntity) {
                    entities = Collections.singleton((OWLEntity) subject);
                } else {
                    entities = Collections.emptySet();
                }
                for (OWLEntity e : entities) {
                    if (!changedEntities.contains(e)) {
                        changedEntities.add(e);
                        ProjectEvent<?> event = e.accept(new OWLEntityVisitorEx<ProjectEvent<?>>() {

                            @Nonnull
                            @Override
                            public ProjectEvent<?> visit(@Nonnull OWLClass cls) {
                                return new ClassFrameChangedEvent(cls, projectId, revision.getUserId());
                            }

                            @Nonnull
                            @Override
                            public ProjectEvent<?> visit(@Nonnull OWLObjectProperty property) {
                                return new ObjectPropertyFrameChangedEvent(property, projectId, revision.getUserId());
                            }

                            @Nonnull
                            @Override
                            public ProjectEvent<?> visit(@Nonnull OWLDataProperty property) {
                                return new DataPropertyFrameChangedEvent(property, projectId, revision.getUserId());
                            }

                            @Nonnull
                            @Override
                            public ProjectEvent<?> visit(@Nonnull OWLNamedIndividual individual) {
                                return new NamedIndividualFrameChangedEvent(individual, projectId, revision.getUserId());
                            }

                            @Nonnull
                            @Override
                            public ProjectEvent<?> visit(@Nonnull OWLDatatype datatype) {
                                return new DatatypeFrameChangedEvent(datatype, projectId, revision.getUserId());
                            }

                            @Nonnull
                            @Override
                            public ProjectEvent<?> visit(@Nonnull OWLAnnotationProperty property) {
                                return new AnnotationPropertyFrameChangedEvent(property, projectId, revision.getUserId());
                            }
                        });
                        projectEventList.add(event);
                    }
                }
            }
        });
    }
    Set<OWLEntityData> changedEntitiesData = new HashSet<>();
    Object subject = changes.getSubject();
    if (subject instanceof OWLEntity) {
        OWLEntity entity = (OWLEntity) subject;
        if (rootOntology.containsEntityInSignature(entity)) {
            String browserText = browserTextProvider.getOWLEntityBrowserText(entity).orElse("");
            changedEntitiesData.add(DataFactory.getOWLEntityData(entity, browserText));
        }
    } else if (subject instanceof OWLEntityData) {
        OWLEntityData entityData = (OWLEntityData) subject;
        if (rootOntology.containsEntityInSignature(entityData.getEntity())) {
            changedEntitiesData.add(entityData);
        }
    } else if (subject instanceof Collection) {
        Collection<?> collection = (Collection<?>) subject;
        collection.stream().filter(element -> element instanceof OWLEntity).map(element -> (OWLEntity) element).filter(rootOntology::containsEntityInSignature).forEach(entity -> {
            String browserText = browserTextProvider.getOWLEntityBrowserText(entity).orElse("");
            changedEntitiesData.add(DataFactory.getOWLEntityData(entity, browserText));
        });
    }
    Optional<RevisionSummary> revisionSummary = hasGetRevisionSummary.getRevisionSummary(revision.getRevisionNumber());
    if (revisionSummary.isPresent()) {
        ProjectEvent<?> event = new ProjectChangedEvent(projectId, revisionSummary.get(), changedEntitiesData);
        projectEventList.add(event);
    }
}
Also used : BrowserTextProvider(edu.stanford.bmir.protege.web.shared.BrowserTextProvider) Revision(edu.stanford.bmir.protege.web.server.revision.Revision) java.util(java.util) org.semanticweb.owlapi.model(org.semanticweb.owlapi.model) HasGetRevisionSummary(edu.stanford.bmir.protege.web.server.change.HasGetRevisionSummary) AxiomSubjectProvider(org.semanticweb.owlapi.util.AxiomSubjectProvider) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) DataFactory(edu.stanford.bmir.protege.web.shared.DataFactory) HasGetEntitiesWithIRI(edu.stanford.bmir.protege.web.shared.HasGetEntitiesWithIRI) Inject(javax.inject.Inject) edu.stanford.bmir.protege.web.shared.event(edu.stanford.bmir.protege.web.shared.event) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) Nonnull(javax.annotation.Nonnull) ChangeApplicationResult(edu.stanford.bmir.protege.web.server.change.ChangeApplicationResult) RevisionSummary(edu.stanford.bmir.protege.web.shared.revision.RevisionSummary) HasGetEntitiesWithIRI(edu.stanford.bmir.protege.web.shared.HasGetEntitiesWithIRI) Nonnull(javax.annotation.Nonnull) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) AxiomSubjectProvider(org.semanticweb.owlapi.util.AxiomSubjectProvider) HasGetRevisionSummary(edu.stanford.bmir.protege.web.server.change.HasGetRevisionSummary) RevisionSummary(edu.stanford.bmir.protege.web.shared.revision.RevisionSummary)

Example 10 with ProjectId

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

the class GetClassFrameActionHandler method execute.

@Nonnull
@Override
public GetClassFrameResult execute(@Nonnull GetClassFrameAction action, @Nonnull ExecutionContext executionContext) {
    OWLClass subject = action.getSubject();
    FrameActionResultTranslator<ClassFrame, OWLClassData> translator = new FrameActionResultTranslator<>(renderingManager, translatorProvider.get(), renderingManager.getRendering(subject));
    LabelledFrame<ClassFrame> f = translator.doIT();
    ProjectId projectId = action.getProjectId();
    logger.info(BROWSING, "{} {} retrieved Class frame for {} ({})", projectId, executionContext.getUserId(), subject, f.getDisplayName());
    return new GetClassFrameResult(f);
}
Also used : OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) GetClassFrameResult(edu.stanford.bmir.protege.web.shared.frame.GetClassFrameResult) ClassFrame(edu.stanford.bmir.protege.web.shared.frame.ClassFrame) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) OWLClass(org.semanticweb.owlapi.model.OWLClass) Nonnull(javax.annotation.Nonnull)

Aggregations

ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)51 Nonnull (javax.annotation.Nonnull)19 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)16 Inject (javax.inject.Inject)14 AccessManager (edu.stanford.bmir.protege.web.server.access.AccessManager)8 java.util (java.util)7 HasProjectId (edu.stanford.bmir.protege.web.shared.project.HasProjectId)6 Collectors.toList (java.util.stream.Collectors.toList)6 Nullable (javax.annotation.Nullable)6 Test (org.junit.Test)6 Logger (org.slf4j.Logger)6 LoggerFactory (org.slf4j.LoggerFactory)6 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)5 ExecutionContext (edu.stanford.bmir.protege.web.server.dispatch.ExecutionContext)5 Optional (java.util.Optional)5 OWLEntity (org.semanticweb.owlapi.model.OWLEntity)5 Subject.forUser (edu.stanford.bmir.protege.web.server.access.Subject.forUser)4 ProjectDetails (edu.stanford.bmir.protege.web.shared.project.ProjectDetails)4 List (java.util.List)4 ImmutableSet (com.google.common.collect.ImmutableSet)3