Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4259 - Opening a document viewing a specific annotator from the activities list does not work #4260

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public abstract class AnnotationPageBase
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

public static final String PAGE_PARAM_DOCUMENT = "d";
public static final String PAGE_PARAM_USER = "u";
public static final String PAGE_PARAM_DATA_OWNER = "u";
public static final String PAGE_PARAM_FOCUS = "f";

private @SpringBean AnnotationSchemaService annotationService;
Expand All @@ -103,7 +103,7 @@ protected AnnotationPageBase(PageParameters aParameters)

var params = getPageParameters();
StringValue documentParameter = params.get(PAGE_PARAM_DOCUMENT);
StringValue userParameter = params.get(PAGE_PARAM_USER);
StringValue userParameter = params.get(PAGE_PARAM_DATA_OWNER);

// If the page was accessed using an URL form ending in a document ID, let's move
// the document ID into the fragment and redirect to the form without the document ID.
Expand All @@ -118,8 +118,8 @@ protected AnnotationPageBase(PageParameters aParameters)
fragmentParams.add(format("%s=%s", PAGE_PARAM_DOCUMENT, documentParameter.toString()));
params.remove(PAGE_PARAM_DOCUMENT);
if (!userParameter.isEmpty()) {
fragmentParams.add(format("%s=%s", PAGE_PARAM_USER, userParameter.toString()));
params.remove(PAGE_PARAM_USER);
fragmentParams.add(format("%s=%s", PAGE_PARAM_DATA_OWNER, userParameter.toString()));
params.remove(PAGE_PARAM_DATA_OWNER);
}
for (var namedParam : params.getAllNamed()) {
clientUrl.setQueryParameter(namedParam.getKey(), namedParam.getValue());
Expand Down Expand Up @@ -200,7 +200,7 @@ protected void onParameterArrival(IRequestParameters aRequestParameters,
{
StringValue document = aRequestParameters.getParameterValue(PAGE_PARAM_DOCUMENT);
StringValue focus = aRequestParameters.getParameterValue(PAGE_PARAM_FOCUS);
StringValue user = aRequestParameters.getParameterValue(PAGE_PARAM_USER);
StringValue user = aRequestParameters.getParameterValue(PAGE_PARAM_DATA_OWNER);

// nothing changed, do not check for project, because inception always opens
// on a project
Expand Down Expand Up @@ -549,10 +549,10 @@ public void onTargetRespond(AjaxRequestTarget aTarget)
// the CURATION_USER here.
if (Set.of(userRepository.getCurrentUsername(), CURATION_USER)
.contains(state.getUser().getUsername())) {
fragment.removeParameter(PAGE_PARAM_USER);
fragment.removeParameter(PAGE_PARAM_DATA_OWNER);
}
else {
fragment.putParameter(PAGE_PARAM_USER, state.getUser().getUsername());
fragment.putParameter(PAGE_PARAM_DATA_OWNER, state.getUser().getUsername());
}

// If we do not manually set editedFragment to false, then changing the URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public AnnotationPage(final PageParameters aPageParameters)

StringValue document = aPageParameters.get(PAGE_PARAM_DOCUMENT);
StringValue focus = aPageParameters.get(PAGE_PARAM_FOCUS);
StringValue user = aPageParameters.get(PAGE_PARAM_USER);
StringValue user = aPageParameters.get(PAGE_PARAM_DATA_OWNER);

handleParameters(document, focus, user);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package de.tudarmstadt.ukp.clarin.webanno.ui.annotation;

import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.page.AnnotationPageBase.PAGE_PARAM_DATA_OWNER;
import static de.tudarmstadt.ukp.clarin.webanno.model.PermissionLevel.ANNOTATOR;
import static de.tudarmstadt.ukp.clarin.webanno.model.PermissionLevel.CURATOR;
import static java.lang.String.format;
Expand Down Expand Up @@ -66,12 +67,19 @@ public String getPath()

public String getUrl(Project aProject, long aDocumentId)
{
String p = aProject.getSlug() != null ? aProject.getSlug()
: String.valueOf(aProject.getId());
var p = aProject.getSlug() != null ? aProject.getSlug() : String.valueOf(aProject.getId());

return format("%s/p/%s%s/%d", servletContext.getContextPath(), p, getPath(), aDocumentId);
}

public String getUrl(Project aProject, long aDocumentId, String aDataOwner)
{
var p = aProject.getSlug() != null ? aProject.getSlug() : String.valueOf(aProject.getId());

return format("%s/p/%s%s/%d?%s=%s", servletContext.getContextPath(), p, getPath(),
aDocumentId, PAGE_PARAM_DATA_OWNER, aDataOwner);
}

@Override
public IconType getIcon()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import static org.apache.commons.collections4.SetUtils.unmodifiableSet;

import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

Expand All @@ -41,10 +40,8 @@

import de.tudarmstadt.ukp.clarin.webanno.api.DocumentService;
import de.tudarmstadt.ukp.clarin.webanno.api.ProjectService;
import de.tudarmstadt.ukp.clarin.webanno.model.Project;
import de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument;
import de.tudarmstadt.ukp.clarin.webanno.security.UserDao;
import de.tudarmstadt.ukp.clarin.webanno.security.model.User;
import de.tudarmstadt.ukp.clarin.webanno.ui.annotation.AnnotationPageMenuItem;
import de.tudarmstadt.ukp.clarin.webanno.ui.curation.page.CurationPageMenuItem;
import de.tudarmstadt.ukp.inception.annotation.events.FeatureValueUpdatedEvent;
Expand All @@ -58,7 +55,6 @@
import de.tudarmstadt.ukp.inception.annotation.layer.span.SpanDeletedEvent;
import de.tudarmstadt.ukp.inception.curation.service.CurationDocumentService;
import de.tudarmstadt.ukp.inception.log.EventRepository;
import de.tudarmstadt.ukp.inception.log.model.LoggedEvent;

@ConditionalOnWebApplication
@RestController
Expand Down Expand Up @@ -117,27 +113,27 @@ public String listActivitiesUrl(long aProjectId)
@GetMapping(LIST_PATH)
public List<Activity> listActivities(@PathVariable("projectId") long aProjectId)
{
User user = userRepository.getCurrentUser();
Project project = projectRepository.getProject(aProjectId);
var user = userRepository.getCurrentUser();
var project = projectRepository.getProject(aProjectId);

if (!projectRepository.hasAnyRole(user, project)) {
return emptyList();
}

Map<Long, SourceDocument> annotatableSourceDocuments = documentService
.listAnnotatableDocuments(project, user).keySet().stream()
var annotatableSourceDocuments = documentService.listAnnotatableDocuments(project, user)
.keySet().stream() //
.collect(toMap(SourceDocument::getId, identity()));

Map<Long, SourceDocument> curatableSourceDocuments = curationService
.listCuratableSourceDocuments(project).stream()
var curatableSourceDocuments = curationService.listCuratableSourceDocuments(project)
.stream() //
.collect(toMap(SourceDocument::getId, identity()));

boolean isCurator = projectRepository.hasRole(user, project, CURATOR);
var isCurator = projectRepository.hasRole(user, project, CURATOR);

// get last annotation events
// return filtered by user rights and document state
List<LoggedEvent> recentEvents = eventRepository.listRecentActivity(project,
user.getUsername(), annotationEvents, 10);
var recentEvents = eventRepository.listRecentActivity(project, user.getUsername(),
annotationEvents, 10);
return recentEvents.stream() //
.filter(Objects::nonNull) //
.filter(event -> event.getDocument() != -1l) //
Expand All @@ -164,7 +160,8 @@ public List<Activity> listActivities(@PathVariable("projectId") long aProjectId)
else {
return new Activity(event,
annotatableSourceDocuments.get(event.getDocument()),
annotationPageMenuItem.getUrl(project, event.getDocument()));
annotationPageMenuItem.getUrl(project, event.getDocument(),
event.getAnnotator()));
}
})//
.collect(toList());
Expand Down