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