use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.
the class MoveProjectsToTrashActionHandler method execute.
@Nonnull
@Override
public MoveProjectsToTrashResult execute(@Nonnull MoveProjectsToTrashAction action, @Nonnull ExecutionContext executionContext) {
List<ProjectMovedToTrashEvent> events = new ArrayList<>();
ProjectId projectId = action.getProjectId();
projectDetailsManager.setInTrash(projectId, true);
events.add(new ProjectMovedToTrashEvent(projectId));
return new MoveProjectsToTrashResult(new EventList<>(EventTag.getFirst(), events, EventTag.getFirst()));
}
use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.
the class GetProjectEventsActionHandler method execute.
@Nonnull
@Override
public GetProjectEventsResult execute(@Nonnull GetProjectEventsAction action, @Nonnull ExecutionContext executionContext) {
EventTag sinceTag = action.getSinceTag();
ProjectId projectId = action.getProjectId();
UserId userId = executionContext.getUserId();
if (!accessManager.hasPermission(forUser(userId), forProject(action.getProjectId()), VIEW_PROJECT)) {
return getEmptyResult(projectId, sinceTag);
}
if (!projectManager.isActive(projectId)) {
return getEmptyResult(projectId, sinceTag);
}
Optional<Project> project = projectManager.getProjectIfActive(projectId);
if (!project.isPresent()) {
return getEmptyResult(projectId, sinceTag);
}
EventManager<ProjectEvent<?>> eventManager = project.get().getEventManager();
EventList<ProjectEvent<?>> eventList = eventManager.getEventsFromTag(sinceTag);
ProjectEventList projectEventList = ProjectEventList.builder(eventList.getStartTag(), projectId, eventList.getEndTag()).addEvents(eventList.getEvents()).build();
return new GetProjectEventsResult(projectEventList);
}
use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.
the class ProjectEntityCrudKitSettingsTestCase method equalsShouldReturnTrueForEqualProjectIdAndEqualSettings.
@Test
public void equalsShouldReturnTrueForEqualProjectIdAndEqualSettings() {
ProjectId projectId = mock(ProjectId.class);
EntityCrudKitSettings<?> settings = mock(EntityCrudKitSettings.class);
ProjectEntityCrudKitSettings settingsA = new ProjectEntityCrudKitSettings(projectId, settings);
ProjectEntityCrudKitSettings settingsB = new ProjectEntityCrudKitSettings(projectId, settings);
assertEquals(settingsA, settingsB);
}
use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.
the class ProjectIdReadConverterTestCase method convertShouldReturnProjectIdWithSuppliedId.
@Test
public void convertShouldReturnProjectIdWithSuppliedId() {
ProjectIdReadConverter converter = new ProjectIdReadConverter();
String suppliedId = UUID.randomUUID().toString();
ProjectId projectId = converter.convert(suppliedId);
assertEquals(suppliedId, projectId.getId());
}
use of edu.stanford.bmir.protege.web.shared.project.ProjectId in project webprotege by protegeproject.
the class ProjectSharingSettingsManagerImpl method setProjectSharingSettings.
@Override
public void setProjectSharingSettings(ProjectSharingSettings settings) {
ProjectId projectId = settings.getProjectId();
ProjectResource projectResource = new ProjectResource(projectId);
// Remove existing assignments
accessManager.getSubjectsWithAccessToResource(projectResource).forEach(subject -> accessManager.setAssignedRoles(subject, projectResource, Collections.emptySet()));
Map<PersonId, SharingSetting> map = settings.getSharingSettings().stream().collect(toMap(SharingSetting::getPersonId, s -> s, (s1, s2) -> s1));
Optional<SharingPermission> linkSharingPermission = settings.getLinkSharingPermission();
linkSharingPermission.ifPresent(permission -> {
Collection<RoleId> roleId = Roles.fromSharingPermission(permission);
accessManager.setAssignedRoles(forAnySignedInUser(), projectResource, roleId);
});
if (!linkSharingPermission.isPresent()) {
accessManager.setAssignedRoles(forAnySignedInUser(), projectResource, emptySet());
}
for (SharingSetting setting : map.values()) {
PersonId personId = setting.getPersonId();
Optional<UserId> userId = userLookup.getUserByUserIdOrEmail(personId.getId());
if (userId.isPresent()) {
ImmutableSet<RoleId> roles = Roles.fromSharingPermission(setting.getSharingPermission());
accessManager.setAssignedRoles(forUser(userId.get()), projectResource, roles);
} else {
logger.info("User in sharing setting not found. An email invitation needs to be sent");
// TODO
// We need to send the user an email invitation
}
}
}
Aggregations