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