Search in sources :

Example 1 with AvailableProject

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

the class ProjectManagerPresenter method handleProjectCreated.

private void handleProjectCreated(ProjectCreatedEvent event) {
    AvailableProject availableProject = new AvailableProject(event.getProjectDetails(), true, true, UNKNOWN);
    insertAndSelectAvailableProject(availableProject, event.getProjectId());
}
Also used : AvailableProject(edu.stanford.bmir.protege.web.shared.project.AvailableProject)

Example 2 with AvailableProject

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

the class GetAvailableProjectsHandler method execute.

@Nonnull
@Override
public GetAvailableProjectsResult execute(@Nonnull GetAvailableProjectsAction action, @Nonnull ExecutionContext executionContext) {
    UserId userId = executionContext.getUserId();
    Optional<UserActivityRecord> userActivityRecord = userActivityManager.getUserActivityRecord(executionContext.getUserId());
    Map<ProjectId, Long> lastOpenedMap = new HashMap<>();
    userActivityRecord.ifPresent(record -> record.getRecentProjects().forEach(recent -> lastOpenedMap.put(recent.getProjectId(), recent.getTimestamp())));
    List<AvailableProject> availableProjects = projectPermissionsManager.getReadableProjects(userId).stream().map(details -> {
        Subject user = forUser(userId);
        ProjectResource projectResource = new ProjectResource(details.getProjectId());
        boolean downloadable = accessManager.hasPermission(user, projectResource, DOWNLOAD_PROJECT);
        boolean trashable = details.getOwner().equals(userId) || accessManager.hasPermission(user, projectResource, MOVE_ANY_PROJECT_TO_TRASH);
        long lastOpened = lastOpenedMap.getOrDefault(details.getProjectId(), 0L);
        return new AvailableProject(details, downloadable, trashable, lastOpened);
    }).collect(toList());
    return new GetAvailableProjectsResult(availableProjects);
}
Also used : AvailableProject(edu.stanford.bmir.protege.web.shared.project.AvailableProject) UserActivityManager(edu.stanford.bmir.protege.web.server.user.UserActivityManager) ApplicationActionHandler(edu.stanford.bmir.protege.web.server.dispatch.ApplicationActionHandler) UserActivityRecord(edu.stanford.bmir.protege.web.server.user.UserActivityRecord) HashMap(java.util.HashMap) Inject(javax.inject.Inject) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) AccessManager(edu.stanford.bmir.protege.web.server.access.AccessManager) DOWNLOAD_PROJECT(edu.stanford.bmir.protege.web.shared.access.BuiltInAction.DOWNLOAD_PROJECT) Map(java.util.Map) ProjectResource(edu.stanford.bmir.protege.web.server.access.ProjectResource) Nonnull(javax.annotation.Nonnull) Subject(edu.stanford.bmir.protege.web.server.access.Subject) NullValidator(edu.stanford.bmir.protege.web.server.dispatch.validators.NullValidator) Subject.forUser(edu.stanford.bmir.protege.web.server.access.Subject.forUser) RequestValidator(edu.stanford.bmir.protege.web.server.dispatch.RequestValidator) MOVE_ANY_PROJECT_TO_TRASH(edu.stanford.bmir.protege.web.shared.access.BuiltInAction.MOVE_ANY_PROJECT_TO_TRASH) ProjectPermissionsManager(edu.stanford.bmir.protege.web.server.permissions.ProjectPermissionsManager) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) ExecutionContext(edu.stanford.bmir.protege.web.server.dispatch.ExecutionContext) Optional(java.util.Optional) GetAvailableProjectsResult(edu.stanford.bmir.protege.web.shared.project.GetAvailableProjectsResult) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) RequestContext(edu.stanford.bmir.protege.web.server.dispatch.RequestContext) GetAvailableProjectsAction(edu.stanford.bmir.protege.web.shared.project.GetAvailableProjectsAction) HashMap(java.util.HashMap) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) Subject(edu.stanford.bmir.protege.web.server.access.Subject) UserActivityRecord(edu.stanford.bmir.protege.web.server.user.UserActivityRecord) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) GetAvailableProjectsResult(edu.stanford.bmir.protege.web.shared.project.GetAvailableProjectsResult) AvailableProject(edu.stanford.bmir.protege.web.shared.project.AvailableProject) ProjectResource(edu.stanford.bmir.protege.web.server.access.ProjectResource) Nonnull(javax.annotation.Nonnull)

Example 3 with AvailableProject

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

the class AvailableProjectsCache method setInTrash.

public boolean setInTrash(ProjectId projectId, boolean inTrash) {
    AvailableProject availableProject = cache.get(projectId);
    if (availableProject == null) {
        return false;
    }
    if (availableProject.getProjectDetails().isInTrash() == inTrash) {
        return false;
    }
    ProjectDetails replacementDetails = availableProject.getProjectDetails().builder().setInTrash(inTrash).build();
    cache.put(projectId, new AvailableProject(replacementDetails, availableProject.isDownloadable(), availableProject.isTrashable(), availableProject.getLastOpenedAt()));
    return true;
}
Also used : ProjectDetails(edu.stanford.bmir.protege.web.shared.project.ProjectDetails) AvailableProject(edu.stanford.bmir.protege.web.shared.project.AvailableProject)

Example 4 with AvailableProject

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

the class ProjectManagerPresenter method displayProjectDetails.

private void displayProjectDetails() {
    List<AvailableProject> entries = Lists.newArrayList();
    List<AvailableProject> availableProjectsList = availableProjectsCache.getAvailableProjectsList();
    availableProjectsList.sort(sortingComparator);
    for (AvailableProject pd : availableProjectsList) {
        if (currentFilter.isIncluded(pd)) {
            entries.add(pd);
        }
    }
    projectManagerView.setAvailableProjects(entries);
}
Also used : AvailableProject(edu.stanford.bmir.protege.web.shared.project.AvailableProject)

Example 5 with AvailableProject

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

the class AvailableProjectsListViewImpl method setListData.

@Override
public void setListData(List<AvailableProject> availableProjects) {
    itemContainer.clear();
    entries.clear();
    for (final AvailableProject project : availableProjects) {
        AvailableProjectPresenter itemPresenter = presenterFactory.create(project);
        itemPresenter.start();
        entries.add(itemPresenter);
        itemContainer.add(itemPresenter.getView());
    }
}
Also used : AvailableProject(edu.stanford.bmir.protege.web.shared.project.AvailableProject)

Aggregations

AvailableProject (edu.stanford.bmir.protege.web.shared.project.AvailableProject)5 AccessManager (edu.stanford.bmir.protege.web.server.access.AccessManager)1 ProjectResource (edu.stanford.bmir.protege.web.server.access.ProjectResource)1 Subject (edu.stanford.bmir.protege.web.server.access.Subject)1 Subject.forUser (edu.stanford.bmir.protege.web.server.access.Subject.forUser)1 ApplicationActionHandler (edu.stanford.bmir.protege.web.server.dispatch.ApplicationActionHandler)1 ExecutionContext (edu.stanford.bmir.protege.web.server.dispatch.ExecutionContext)1 RequestContext (edu.stanford.bmir.protege.web.server.dispatch.RequestContext)1 RequestValidator (edu.stanford.bmir.protege.web.server.dispatch.RequestValidator)1 NullValidator (edu.stanford.bmir.protege.web.server.dispatch.validators.NullValidator)1 ProjectPermissionsManager (edu.stanford.bmir.protege.web.server.permissions.ProjectPermissionsManager)1 UserActivityManager (edu.stanford.bmir.protege.web.server.user.UserActivityManager)1 UserActivityRecord (edu.stanford.bmir.protege.web.server.user.UserActivityRecord)1 DOWNLOAD_PROJECT (edu.stanford.bmir.protege.web.shared.access.BuiltInAction.DOWNLOAD_PROJECT)1 MOVE_ANY_PROJECT_TO_TRASH (edu.stanford.bmir.protege.web.shared.access.BuiltInAction.MOVE_ANY_PROJECT_TO_TRASH)1 GetAvailableProjectsAction (edu.stanford.bmir.protege.web.shared.project.GetAvailableProjectsAction)1 GetAvailableProjectsResult (edu.stanford.bmir.protege.web.shared.project.GetAvailableProjectsResult)1 ProjectDetails (edu.stanford.bmir.protege.web.shared.project.ProjectDetails)1 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)1 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)1