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
package org.craftsrecords.talkadvisor.recommendation.spi.stubs | |
import org.craftsrecords.hexarch.Stub | |
import org.craftsrecords.talkadvisor.recommendation.preferences.Topic | |
import org.craftsrecords.talkadvisor.recommendation.spi.SearchTalks | |
import org.craftsrecords.talkadvisor.recommendation.talk.Talk | |
import org.craftsrecords.talkadvisor.recommendation.talk.TalkFormat | |
import java.util.* | |
@Stub | |
class HardCodedTalksSearcher : SearchTalks { | |
override val maxNumberOfTalks: Int = 5//ignored value | |
override fun forTopics(topics: Set<Topic>): Set<Talk> { | |
return createTalks(topics) | |
} | |
private fun createTalks(topics: Set<Topic>): Set<Talk> { | |
return topics.flatMap { createTalksForTopic(it.name) }.toSet() | |
} | |
private fun createTalksForTopic(topicName: String): Set<Talk> { | |
return TalkFormat.values().map { | |
Talk.with { | |
id = UUID.randomUUID().toString() | |
title = "${it.name} $topicName" | |
duration = it.durationRange.start.plusSeconds(30) | |
}.build() | |
}.toSet() | |
} | |
} |
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
package org.craftsrecords.talkadvisor.recommendation.spi.stubs | |
import org.craftsrecords.hexarch.Stub | |
import org.craftsrecords.talkadvisor.recommendation.profile.Profile | |
import org.craftsrecords.talkadvisor.recommendation.spi.Profiles | |
@Stub | |
class InMemoryProfiles(private val profiles: MutableMap<String, Profile> = HashMap()) : Profiles { | |
override fun fetch(userId: String): Profile? { | |
return profiles[userId] | |
} | |
override fun save(profile: Profile): Profile { | |
profiles[profile.id] = profile | |
return profile | |
} | |
} |
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
package org.craftsrecords.talkadvisor.recommendation.spi.stubs | |
import org.craftsrecords.hexarch.Stub | |
import org.craftsrecords.talkadvisor.recommendation.Recommendation | |
import org.craftsrecords.talkadvisor.recommendation.spi.Recommendations | |
import java.util.* | |
@Stub | |
class InMemoryRecommendations(private val recommendations: MutableMap<UUID, Recommendation> = HashMap()) : Recommendations { | |
override fun save(recommendation: Recommendation): Recommendation { | |
recommendations[recommendation.id] = recommendation | |
return recommendation | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment