Skip to content

Commit

Permalink
Merge pull request #5167 from inception-project/bugfix/5096-Relations…
Browse files Browse the repository at this point in the history
…-disappear-after-merging-their-target-or-source

#5096 - Relations disappear after merging their target/source
  • Loading branch information
reckart authored Nov 16, 2024
2 parents b233f26 + 7f7d1f1 commit 11c7ea9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2846,7 +2846,7 @@ export class Visualizer {
return path
}

// Render curve pointing to the rught annotation endpoint
// Render curve pointing to the right annotation endpoint
let cornerx = to - (this.rtlmode ? -1 : 1) * ufoCatcherMod * this.arcSlant

// TODO: duplicates above in part, make funcs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,23 @@ public boolean accepts(RenderRequest aRequest)
public void render(VDocument aVdoc, RenderRequest aRequest)
{
var sessionOwner = userRepository.getCurrentUsername();
var project = aRequest.getProject();

var selectedUsers = curationService.listUsersReadyForCuration(sessionOwner, project,
aRequest.getSourceDocument());
var selectedUsers = curationService.listUsersReadyForCuration(sessionOwner,
aRequest.getProject(), aRequest.getSourceDocument());
if (selectedUsers.isEmpty()) {
return;
}

var casDiff = createDiff(aRequest, selectedUsers);
renderDiff(aVdoc, aRequest, casDiff);
}

private void renderDiff(VDocument aVdoc, RenderRequest aRequest, CasDiff casDiff)
{
var project = aRequest.getProject();
var sessionOwner = userRepository.getCurrentUsername();
var targetUser = aRequest.getAnnotationUser().getUsername();

var casDiff = createDiff(aRequest, selectedUsers);
var diff = casDiff.toResult();
var totalAnnotatorCount = diff.getCasGroupIds().stream() //
.filter($ -> !$.equals(targetUser)) //
Expand Down Expand Up @@ -327,28 +333,26 @@ private CasDiff createDiff(RenderRequest aRequest, List<User> selectedUsers)
private void resolveArcEndpoints(String targetUser, DiffResult diff, boolean showAll,
Configuration cfg, VArc arc)
{
if (showAll) {
var representativeCasGroupId = cfg.getRepresentativeCasGroupId();
arc.setSource(new CurationVID(representativeCasGroupId, arc.getSource()));
arc.setTarget(resolveVisibleEndpoint(targetUser, diff, cfg, arc.getTarget()));
return;
}

if (cfg.getPosition() instanceof SpanPosition spanPosition
&& spanPosition.isLinkFeaturePosition()) {
arc.setSource(resolveVisibleLinkHost(targetUser, diff, cfg, arc.getSource()));
arc.setSource(resolveVisibleLinkHost(targetUser, diff, cfg, arc.getSource(), showAll));
}
else {
arc.setSource(resolveVisibleEndpoint(targetUser, diff, cfg, arc.getSource()));
arc.setSource(resolveVisibleEndpoint(targetUser, diff, cfg, arc.getSource(), showAll));
}
arc.setTarget(resolveVisibleEndpoint(targetUser, diff, cfg, arc.getTarget()));

arc.setTarget(resolveVisibleEndpoint(targetUser, diff, cfg, arc.getTarget(), showAll));
}

private VID resolveVisibleLinkHost(String aTargetUser, DiffResult aDiff, Configuration aCfg,
VID aVid)
VID aVid, boolean showAll)
{
var representativeCasGroupId = aCfg.getRepresentativeCasGroupId();

if (showAll) {
return new CurationVID(representativeCasGroupId, aVid);
}

// If this is a link feature position, derive the base span position (i.e. the span
// which owns the link feature) and check if that has already been merged. If yes, we
// need to return the merged position instead of the curator's position.
Expand Down Expand Up @@ -382,25 +386,28 @@ private VID resolveVisibleLinkHost(String aTargetUser, DiffResult aDiff, Configu
* annotation and then switching over to the configuration containing the curators annotation.
*/
private VID resolveVisibleEndpoint(String aTargetUser, DiffResult aDiff, Configuration aCfg,
VID aVid)
VID aVid, boolean showAll)
{
var representativeCasGroupId = aCfg.getRepresentativeCasGroupId();

var sourceConfiguration = aDiff.findConfiguration(representativeCasGroupId, new AID(aVid));
var sourceConfiguration = aDiff.findConfiguration(aCfg.getRepresentativeCasGroupId(),
new AID(aVid));

// This is for relation annotation endpoints and link targets. Here we can look for the
// configuration which contains the annotators annotation and find the corresponding
// curated version for it in the same configuration
if (sourceConfiguration.isPresent()) {
var curatedAID = sourceConfiguration.get().getAID(aTargetUser);
if (curatedAID != null) {

// If showAll is not enabled, we use the merged annotation of the target user
// If showAll is enabled though, we prefer to use the original un-merged annotation
if (!showAll && curatedAID != null) {
return new VID(curatedAID.addr);
}

var representativeCasGroupId = sourceConfiguration.get().getRepresentativeCasGroupId();
return new CurationVID(representativeCasGroupId,
new VID(sourceConfiguration.get().getAID(representativeCasGroupId).addr));
}

return new CurationVID(representativeCasGroupId, aVid);
return new CurationVID(aCfg.getRepresentativeCasGroupId(), aVid);
}
}

0 comments on commit 11c7ea9

Please sign in to comment.