-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#218 Changed evo script, Extracted trail-places populate logic
- Loading branch information
Showing
4 changed files
with
95 additions
and
65 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
backend/src/main/java/org/sc/processor/PlacesTrailSyncProcessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.sc.processor | ||
|
||
import org.sc.common.rest.TrailDto | ||
import org.sc.manager.PlaceManager | ||
import org.sc.manager.TrailManager | ||
import org.slf4j.LoggerFactory | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class PlacesTrailSyncProcessor @Autowired constructor(private val trailManager: TrailManager, | ||
private val placeManager: PlaceManager) { | ||
|
||
private val logger = LoggerFactory.getLogger(javaClass) | ||
|
||
fun populatePlacesWithTrailData(trailSaved: TrailDto) { | ||
trailSaved.locations.map { | ||
logger.info("Connecting place with Id '${it.placeId}' to newly created trail with Id '${trailSaved.id}'") | ||
trailManager.linkTrailToPlace(trailSaved.id, it) | ||
// Reload place | ||
val updatedPlace = placeManager.getById(it.placeId).first() | ||
updatedPlace.crossingTrailIds.filter { encounteredTrail -> encounteredTrail.equals(trailSaved.id) } | ||
.forEach { encounteredTrailNotTrailSaved -> | ||
run { | ||
logger.info("Ensuring also place with Id '${it.placeId}' " + | ||
"to other existing trail with Id '${encounteredTrailNotTrailSaved}'") | ||
trailManager.linkTrailToPlace(encounteredTrailNotTrailSaved, it) | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
db.getCollection("core.Place").updateMany({}, {$set : { "isDynamic": true}} ) | ||
db.getCollection("core.Place").updateMany({}, {$set : { "isDynamic": false}} ) |