Skip to content

Commit

Permalink
- ADD: Added synchronization handling of plot geography location info…
Browse files Browse the repository at this point in the history
…rmation.
  • Loading branch information
sebastian-raubach committed Feb 28, 2024
1 parent ff87b2a commit 9d07c0e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/jhi/gridscore/server/pojo/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ public class Transaction
private Map<String, List<PlotCommentContent>> plotCommentDeletedTransactions;
private Map<String, Boolean> plotMarkedTransactions;
private Map<String, List<TraitMeasurement>> plotTraitDataChangeTransactions;
private Map<String, PlotGeographyContent> plotGeographyChangeTransactions;
private List<TrialCommentContent> trialCommentAddedTransactions;
private List<TrialCommentContent> trialCommentDeletedTransactions;
private List<String> trialGermplasmAddedTransactions;
private List<Trait> trialTraitAddedTransactions;
private List<TraitEditContent> traitChangeTransactions;
private TrialContent trialEditTransaction;
private BrapiIdChangeContent brapiIdChangeTransaction;
private BrapiConfig brapiConfigChangeTransaction;
private BrapiConfig brapiConfigChangeTransaction;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package jhi.gridscore.server.pojo.transaction;

import jhi.gridscore.server.pojo.LatLng;
import lombok.*;
import lombok.experimental.Accessors;

@Getter
@Setter
@Accessors(chain = true)
@NoArgsConstructor
@ToString(callSuper = true)
public class PlotGeographyContent extends PlotContent
{
private LatLng center;
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,39 @@ public Response postTransactions(Transaction transaction)
cell.setIsMarked(change);
}

// Check if the plot geography (center) has changed
if (transaction.getPlotGeographyChangeTransactions() != null)
{
PlotGeographyContent geography = transaction.getPlotGeographyChangeTransactions().get(key);

if (geography != null)
{
if (cell.getGeography() != null && cell.getGeography().getCenter() != null)
{
// Geography and center exist, so take average
LatLng cellCenter = cell.getGeography().getCenter();

if (cellCenter.getLat() != null)
cellCenter.setLat((cellCenter.getLat() + geography.getCenter().getLat()) / 2);
else
cellCenter.setLat(geography.getCenter().getLat());
if (cellCenter.getLng() != null)
cellCenter.setLng((cellCenter.getLng() + geography.getCenter().getLng()) / 2);
else
cellCenter.setLng(geography.getCenter().getLng());
}
else
{
// There's no geography or no center. Make sure the geography exists.
if (cell.getGeography() == null)
cell.setGeography(new Geography());

// Then set the center.
cell.getGeography().setCenter(geography.getCenter());
}
}
}

// Check if comments have been added
if (transaction.getPlotCommentAddedTransactions() != null)
{
Expand Down

0 comments on commit 9d07c0e

Please # to comment.