本文整理汇总了Scala中com.google.inject.name.Named类的典型用法代码示例。如果您正苦于以下问题:Scala Named类的具体用法?Scala Named怎么用?Scala Named使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Named类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: StoryServiceFactory
//设置package包名称以及导入依赖的类
package io.soheila.cms.services.stories
import com.google.inject.Inject
import com.google.inject.name.Named
import io.soheila.cms.daos.StoryDAO
import io.soheila.cms.services.stories.fsm.{ Edited, Published, StoryState }
class StoryServiceFactory @Inject() (@Named("storyDAO") val storyDAO: StoryDAO, @Named("publishedStoryDAO") val publishedStory: StoryDAO) {
private val StoryServiceMap: Map[String, StoryService] = Map(
Published.getClass.getSimpleName -> new StoryServiceImpl(publishedStory)
).withDefaultValue(new StoryServiceImpl(storyDAO))
def getStoryService(storyState: StoryState): StoryService = {
StoryServiceMap(storyState.getClass.getSimpleName)
}
def getStoryService(published: Boolean): StoryService = {
if (published) getStoryService(Published)
else getStoryService(Edited)
}
def getDefaultStoryService: StoryService = {
getStoryService(Edited)
}
def getPublishedStoryService: StoryService = {
getStoryService(Published)
}
}
示例2: AppDependencyModule
//设置package包名称以及导入依赖的类
package modules
import com.google.inject.name.Named
import com.google.inject.{AbstractModule, Singleton, Provides}
import com.redis.RedisClientPool
import infrastructures.SomeModelDAO
import play.api.Configuration
import services.SomeModelStore
class AppDependencyModule extends AbstractModule {
override def configure(): Unit = {
bind(classOf[SomeModelStore]).to(classOf[SomeModelDAO])
}
@Provides
@Singleton
@Named("some_model")
def provideStoreDetailRedisClientPool(
configuration: Configuration
): RedisClientPool = new RedisClientPool(
configuration.getString("redis.host").get,
configuration.getInt("redis.port").get,
database = 1
)
}
示例3: SSEDebug
//设置package包名称以及导入依赖的类
package jobs
import java.util.UUID
import akka.actor.Actor.Receive
import akka.actor.{ Actor, ActorRef }
import com.google.inject.Inject
import com.google.inject.name.Named
import utils.actors.SSEPublisher
import play.Logger
class SSEDebug @Inject() (
@Named("sse-publisher") ssepublish: ActorRef
) extends Actor {
override def receive: Receive = {
case SSEDebug.OnStart => {
Logger.info("Sending debug Classification Start")
ssepublish ! SSEPublisher.ClassificationStart(UUID.fromString("1298ae9d-1b2b-4465-b81c-27e230091ff7"))
}
}
}
object SSEDebug {
case object OnStart
}
示例4: CoreActor
//设置package包名称以及导入依赖的类
package play.modules.io.joaovasques.playspark.core
import akka.actor.{Actor, ActorRef}
import play.modules.io.joaovasques.playspark.akkaguice.NamedActor
import com.google.inject.{BindingAnnotation, Inject}
import com.google.inject.name.Named
import play.modules.io.joaovasques.playspark.persistence.PersistenceMessages._
import play.modules.io.joaovasques.playspark.stats.StatsMessages._
import play.modules.io.joaovasques.playspark.persistence.{MyPersistenceActor}
import play.modules.io.joaovasques.playspark.stats.StatsActor
import play.modules.io.joaovasques.playspark.spark.SparkActor
import play.modules.io.joaovasques.playspark.spark.SparkMessages._
object CoreActor extends NamedActor {
override final val name = "CoreActor"
}
class CoreActor @Inject()(
@Named(MyPersistenceActor.name) persistenceActor: ActorRef,
@Named(StatsActor.name) statsActor: ActorRef,
@Named(SparkActor.name) sparkActor: ActorRef
) extends Actor {
private def handlePersistenceRequest: Receive = {
case m @ (Find(_,_,_,_) | Insert(_,_) | Update(_,_,_,_,_) | Delete(_,_,_)) => persistenceActor forward m
}
private def handleStatsRequest: Receive = {
case m @ (GetJobsInExecution(_) | GetCompletedJobs(_) | GetFailedJobs(_)) => statsActor forward m
}
private def handleSparkRequest: Receive = {
case m @ (GetContexts() | SaveContext(_) | DeleteContext(_) | StopContext() | StartSparkJob(_,_,_)) => {
sparkActor forward m
}
}
private def unhandled: Receive = {
case m @ _ => sender ! akka.actor.Status.Failure(new MatchError(m))
}
def receive = handlePersistenceRequest orElse handleStatsRequest orElse handleSparkRequest orElse unhandled
}
示例5: DigitalElementIndexModule
//设置package包名称以及导入依赖的类
package utils
import java.io.{BufferedInputStream, InputStream}
import java.nio.file.{Files, Paths}
import com.amazonaws.services.s3.{AmazonS3, AmazonS3ClientBuilder}
import com.google.inject.name.Named
import com.google.inject.{AbstractModule, Provides, Singleton}
import play.api.Logger
class DigitalElementIndexModule extends AbstractModule {
private[this] val fileUri = "^file:(.*)".r
private[this] val s3Uri = "^s3://([^/]+)/(.*)".r
override def configure(): Unit = ()
@Provides
@Named("DigitalElementIndex")
@Singleton
def getIndex(@javax.inject.Inject() environmentVariables: EnvironmentVariables): DigitalElementIndex = {
val is: InputStream = environmentVariables.digitalElementFileUri match {
case fileUri(path) => new BufferedInputStream(Files.newInputStream(Paths.get(path)))
case s3Uri(bucket, key) => {
val s3: AmazonS3 = AmazonS3ClientBuilder.standard().build()
s3.getObject(bucket, key).getObjectContent()
}
case _ => throw new IllegalArgumentException("Invalid digitalElementFileUri. Must use either s3:// or file:// protocol")
}
Logger.info(s"Building index from ${environmentVariables.digitalElementFileUri}")
val start = System.currentTimeMillis()
val index = DigitalElement.buildIndex(is, ';', '\n')
is.close()
Logger.info(s"Indexed ${index.size} records in ${(System.currentTimeMillis() - start) / 1000} seconds")
index
}
}
示例6: FoodCompositionServiceImpl
//设置package包名称以及导入依赖的类
package uk.ac.ncl.openlab.intake24.foodsql.user
import javax.sql.DataSource
import anorm.{Macro, SQL, SqlParser, sqlToSimple}
import com.google.inject.name.Named
import com.google.inject.{Inject, Singleton}
import org.slf4j.LoggerFactory
import uk.ac.ncl.openlab.intake24.errors.{FoodCompositionTableError, RecordNotFound, UnexpectedDatabaseError}
import uk.ac.ncl.openlab.intake24.services.nutrition.{FoodCompositionService, NutrientDescription}
import uk.ac.ncl.openlab.intake24.sql.{SqlDataService, SqlResourceLoader}
@Singleton
class FoodCompositionServiceImpl @Inject()(@Named("intake24_foods") val dataSource: DataSource) extends FoodCompositionService with SqlDataService with SqlResourceLoader {
private val logger = LoggerFactory.getLogger(classOf[FoodCompositionServiceImpl])
private case class NutrientDescriptionRow(id: Long, description: String, symbol: String)
def getSupportedNutrients(): Either[UnexpectedDatabaseError, Seq[NutrientDescription]] = tryWithConnection {
implicit conn =>
Right(SQL("SELECT nutrient_types.id, nutrient_types.description, nutrient_units.symbol FROM nutrient_types INNER JOIN nutrient_units ON nutrient_types.unit_id = nutrient_units.id")
.executeQuery()
.as(Macro.namedParser[NutrientDescriptionRow].*)
.map {
row => NutrientDescription(row.id, row.description, row.symbol)
})
}
private case class NutrientsRow(nutrient_type_id: Long, units_per_100g: Double)
def getFoodCompositionRecord(table_id: String, record_id: String): Either[FoodCompositionTableError, Map[Long, Double]] = tryWithConnection {
implicit conn =>
val validation = SQL("SELECT 1 FROM nutrient_table_records WHERE id={record_id} AND nutrient_table_id={table_id}")
.on('record_id -> record_id, 'table_id -> table_id)
.executeQuery().as(SqlParser.long(1).singleOpt).isDefined
if (!validation)
Left(RecordNotFound(new RuntimeException(s"table_id: $table_id, record_id: $record_id")))
else {
val rows = SQL("SELECT nutrient_type_id, units_per_100g FROM nutrient_table_records_nutrients WHERE nutrient_table_record_id={record_id} and nutrient_table_id={table_id}")
.on('record_id -> record_id, 'table_id -> table_id)
.as(Macro.namedParser[NutrientsRow].*)
val result = rows.map(row => (row.nutrient_type_id -> row.units_per_100g)).toMap
Right(result)
}
}
def getEnergyKcalNutrientId(): Long = 1
}
示例7: ImageMapServiceImpl
//设置package包名称以及导入依赖的类
package uk.ac.ncl.openlab.intake24.foodsql.user
import javax.inject.Inject
import javax.sql.DataSource
import anorm.NamedParameter.symbol
import anorm.{Macro, SQL, sqlToSimple}
import com.google.inject.Singleton
import com.google.inject.name.Named
import uk.ac.ncl.openlab.intake24.errors.{LookupError, RecordNotFound}
import uk.ac.ncl.openlab.intake24.services.fooddb.user.{ImageMapService, UserImageMap, UserImageMapObject}
import uk.ac.ncl.openlab.intake24.sql.{SqlDataService, SqlResourceLoader}
@Singleton
class ImageMapServiceImpl @Inject()(@Named("intake24_foods") val dataSource: DataSource) extends ImageMapService with SqlDataService with SqlResourceLoader {
private case class ResultRow(id: String, base_image_path: String, object_id: Long, description: String, outline: Array[Double], overlay_image_path: String)
private lazy val imageMapObjectsQuery = sqlFromResource("user/get_image_map_objects.sql")
def getImageMaps(ids: Seq[String]): Either[LookupError, Seq[UserImageMap]] = tryWithConnection {
implicit conn =>
val result = SQL(imageMapObjectsQuery).on('ids -> ids).as(Macro.namedParser[ResultRow].*).groupBy(_.id).map {
case (id, rows) =>
val objects = rows.map {
row => UserImageMapObject(row.object_id.toInt, row.description, row.overlay_image_path, row.outline)
}
id -> UserImageMap(rows.head.base_image_path, objects)
}
val missing = ids.filterNot(result.contains(_))
if (missing.nonEmpty)
Left(RecordNotFound(new RuntimeException(s"Missing image maps: ${missing.mkString(", ")}")))
else
Right(ids.map(result(_)))
}
def getImageMap(id: String): Either[LookupError, UserImageMap] = getImageMaps(Seq(id)).right.map {
_.head
}
}
示例8: DrinkwareServiceImpl
//设置package包名称以及导入依赖的类
package uk.ac.ncl.openlab.intake24.foodsql.user
import java.sql.Connection
import javax.inject.Inject
import javax.sql.DataSource
import anorm.NamedParameter.symbol
import anorm.{Macro, SQL, SqlParser, sqlToSimple}
import com.google.inject.Singleton
import com.google.inject.name.Named
import uk.ac.ncl.openlab.intake24.errors.{LookupError, RecordNotFound}
import uk.ac.ncl.openlab.intake24.services.fooddb.user.DrinkwareService
import uk.ac.ncl.openlab.intake24.sql.{SqlDataService, SqlResourceLoader}
import uk.ac.ncl.openlab.intake24.{DrinkScale, DrinkwareSet, VolumeFunction, VolumeSample}
@Singleton
class DrinkwareServiceImpl @Inject()(@Named("intake24_foods") val dataSource: DataSource) extends DrinkwareService with SqlDataService with SqlResourceLoader {
protected case class DrinkwareResultRow(id: String, scale_id: Long, description: String, guide_image_id: String,
width: Int, height: Int, empty_level: Int, full_level: Int, choice_id: Int, base_image_url: String,
overlay_image_url: String)
protected case class VolumeSampleResultRow(scale_id: Long, fill: Double, volume: Double)
private lazy val drinkwareScalesQuery = sqlFromResource("user/drinkware_scales.sql")
private lazy val drinkwareVolumeSamplesQuery = sqlFromResource("user/drinkware_volume_samples.sql")
def getDrinkwareSet(id: String): Either[LookupError, DrinkwareSet] = tryWithConnection {
implicit conn =>
conn.setAutoCommit(false)
conn.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ)
val validation = SQL("SELECT true AS v FROM drinkware_sets WHERE id={drinkware_id}").on('drinkware_id -> id).executeQuery().as(SqlParser.bool("v").singleOpt)
if (validation.isEmpty) {
conn.commit()
Left(RecordNotFound(new RuntimeException(id)))
} else {
val result = SQL(drinkwareScalesQuery).on('drinkware_id -> id).executeQuery().as(Macro.namedParser[DrinkwareResultRow].*)
val scale_ids = result.map(_.scale_id)
val volume_sample_results = SQL(drinkwareVolumeSamplesQuery).on('scale_ids -> scale_ids).executeQuery().as(Macro.namedParser[VolumeSampleResultRow].*)
val scales = result.map(r => DrinkScale(r.choice_id, r.base_image_url, r.overlay_image_url, r.width, r.height, r.empty_level, r.full_level,
volume_sample_results.filter(_.scale_id == r.scale_id).map(s => VolumeSample(s.fill, s.volume))))
conn.commit()
Right(DrinkwareSet(id, result.head.description, result.head.guide_image_id, scales))
}
}
}
示例9: BrandNamesServiceImpl
//设置package包名称以及导入依赖的类
package uk.ac.ncl.openlab.intake24.foodsql.user
import javax.inject.Inject
import javax.sql.DataSource
import anorm._
import com.google.inject.Singleton
import com.google.inject.name.Named
import uk.ac.ncl.openlab.intake24.errors.LocalLookupError
import uk.ac.ncl.openlab.intake24.foodsql.{FirstRowValidation, FirstRowValidationClause}
import uk.ac.ncl.openlab.intake24.services.fooddb.user.BrandNamesService
import uk.ac.ncl.openlab.intake24.sql.{SqlDataService, SqlResourceLoader}
@Singleton
class BrandNamesServiceImpl @Inject()(@Named("intake24_foods") val dataSource: DataSource) extends BrandNamesService with SqlDataService with FirstRowValidation with SqlResourceLoader {
private lazy val getBrandNamesQuery = sqlFromResource("user/get_brand_names_frv.sql")
protected def getBrandNamesComposable(foodCode: String, locale: String)(implicit conn: java.sql.Connection): Either[LocalLookupError, Seq[String]] = {
val result = SQL(getBrandNamesQuery).on('food_code -> foodCode, 'locale_id -> locale).executeQuery()
parseWithLocaleAndFoodValidation(foodCode, result, SqlParser.str("name").+)(Seq(FirstRowValidationClause("name", () => Right(List()))))
}
def getBrandNames(foodCode: String, locale: String): Either[LocalLookupError, Seq[String]] = tryWithConnection {
implicit conn =>
getBrandNamesComposable(foodCode, locale)
}
}
示例10: GuideImageServiceImpl
//设置package包名称以及导入依赖的类
package uk.ac.ncl.openlab.intake24.foodsql.user
import javax.inject.Inject
import javax.sql.DataSource
import anorm.NamedParameter.symbol
import anorm.{Macro, SQL, sqlToSimple}
import com.google.inject.Singleton
import com.google.inject.name.Named
import uk.ac.ncl.openlab.intake24.errors.{LookupError, RecordNotFound}
import uk.ac.ncl.openlab.intake24.services.fooddb.user.{GuideImageService, UserGuideImage}
import uk.ac.ncl.openlab.intake24.sql.{SqlDataService, SqlResourceLoader}
@Singleton
class GuideImageServiceImpl @Inject()(@Named("intake24_foods") val dataSource: DataSource) extends GuideImageService with SqlDataService with SqlResourceLoader {
private case class GuideResultRow(description: String, image_map_id: String, object_id: Array[Long], object_weight: Array[Double])
private lazy val guideImageQuery = sqlFromResource("user/get_guide_image.sql")
def getGuideImage(id: String): Either[LookupError, UserGuideImage] = tryWithConnection {
implicit conn =>
withTransaction {
val imageResult = SQL(guideImageQuery).on('id -> id).executeQuery().as(Macro.namedParser[GuideResultRow].singleOpt)
imageResult match {
case Some(row) => {
Right(UserGuideImage(row.description, row.image_map_id, row.object_id.map(_.toInt).zip(row.object_weight).toMap))
}
case None => Left(RecordNotFound(new RuntimeException(s"Guide image $id not found")))
}
}
}
}
示例11: AssociatedFoodsServiceImpl
//设置package包名称以及导入依赖的类
package uk.ac.ncl.openlab.intake24.foodsql.user
import javax.inject.Inject
import javax.sql.DataSource
import anorm.{Macro, SQL, sqlToSimple}
import com.google.inject.Singleton
import com.google.inject.name.Named
import uk.ac.ncl.openlab.intake24.AssociatedFood
import uk.ac.ncl.openlab.intake24.errors.LocalLookupError
import uk.ac.ncl.openlab.intake24.foodsql.{FirstRowValidation, FirstRowValidationClause}
import uk.ac.ncl.openlab.intake24.services.fooddb.user.AssociatedFoodsService
import uk.ac.ncl.openlab.intake24.sql.{SqlDataService, SqlResourceLoader}
@Singleton
class AssociatedFoodsServiceImpl @Inject()(@Named("intake24_foods") val dataSource: DataSource) extends AssociatedFoodsService with SqlDataService with SqlResourceLoader with FirstRowValidation {
private case class AssociatedFoodPromptsRow(associated_food_code: Option[String], associated_category_code: Option[String],
text: String, link_as_main: Boolean, generic_name: String, locale_id: String, af_locale_id: String)
private val getAssociatedFoodsQuery = sqlFromResource("user/get_associated_foods_frv.sql")
def getAssociatedFoods(foodCode: String, locale: String): Either[LocalLookupError, Seq[AssociatedFood]] = tryWithConnection {
implicit conn =>
val result = SQL(getAssociatedFoodsQuery).on('food_code -> foodCode, 'locale_id -> locale).executeQuery()
val parser = Macro.namedParser[AssociatedFoodPromptsRow].+
def mkPrompt(row: AssociatedFoodPromptsRow) = {
val foodOrCategory: Either[String, String] = (row.associated_food_code, row.associated_category_code) match {
case (Some(foodCode), None) => Left(foodCode)
case (None, Some(categoryCode)) => Right(categoryCode)
case _ => throw new RuntimeException(s"Unexpected associated food row format: ${row.toString()}")
}
AssociatedFood(foodOrCategory, row.text, row.link_as_main, row.generic_name)
}
parseWithLocaleAndFoodValidation(foodCode, result, parser)(Seq(FirstRowValidationClause("id", () => Right(List())))).right.map {
rows =>
val (local, prototype) = rows.partition(_.af_locale_id == locale)
if (local.nonEmpty)
local.map(mkPrompt)
else
prototype.map(mkPrompt)
}
}
}
示例12: AsServedSetsServiceImpl
//设置package包名称以及导入依赖的类
package uk.ac.ncl.openlab.intake24.foodsql.user
import javax.inject.Inject
import javax.sql.DataSource
import anorm.NamedParameter.symbol
import anorm.{Macro, SQL, sqlToSimple}
import com.google.inject.Singleton
import com.google.inject.name.Named
import uk.ac.ncl.openlab.intake24.errors.{LookupError, RecordNotFound}
import uk.ac.ncl.openlab.intake24.services.fooddb.user.{AsServedSetsService, UserAsServedImage, UserAsServedSet}
import uk.ac.ncl.openlab.intake24.sql.{SqlDataService, SqlResourceLoader}
@Singleton
class AsServedSetsServiceImpl @Inject()(@Named("intake24_foods") val dataSource: DataSource) extends AsServedSetsService with SqlDataService with SqlResourceLoader {
private case class AsServedImageRow(image_path: String, thumbnail_path: String, weight: Double)
private case class AsServedSetRow(selection_image_path: String)
private lazy val setQuery = sqlFromResource("user/get_as_served_set.sql")
private lazy val imagesQuery = sqlFromResource("user/get_as_served_images.sql")
def getAsServedSet(id: String): Either[LookupError, UserAsServedSet] = tryWithConnection {
implicit conn =>
withTransaction {
SQL(setQuery).on('id -> id).executeQuery().as(Macro.namedParser[AsServedSetRow].singleOpt) match {
case Some(set) => {
val result = SQL(imagesQuery).on('as_served_set_id -> id).executeQuery().as(Macro.namedParser[AsServedImageRow].*)
val images = result.map(row => UserAsServedImage(row.image_path, row.thumbnail_path, row.weight))
Right(UserAsServedSet(set.selection_image_path, images))
}
case None => Left(RecordNotFound(new RuntimeException(id)))
}
}
}
}
示例13: BrandNamesAdminImpl
//设置package包名称以及导入依赖的类
package uk.ac.ncl.openlab.intake24.foodsql.admin
import javax.sql.DataSource
import anorm.{SQL, sqlToSimple}
import com.google.inject.Inject
import com.google.inject.name.Named
import org.slf4j.LoggerFactory
import uk.ac.ncl.openlab.intake24.errors.{LocalLookupError, LocaleError, LocaleOrParentError}
import uk.ac.ncl.openlab.intake24.foodsql.SimpleValidation
import uk.ac.ncl.openlab.intake24.foodsql.modular.BrandNamesAdminQueries
import uk.ac.ncl.openlab.intake24.services.fooddb.admin.BrandNamesAdminService
import uk.ac.ncl.openlab.intake24.services.fooddb.user.BrandNamesService
import uk.ac.ncl.openlab.intake24.sql.SqlDataService
class BrandNamesAdminImpl @Inject()(@Named("intake24_foods") val dataSource: DataSource, brandNamesService: BrandNamesService) extends BrandNamesAdminService with BrandNamesAdminQueries with SqlDataService with SimpleValidation {
private val logger = LoggerFactory.getLogger(classOf[BrandNamesAdminImpl])
def deleteAllBrandNames(locale: String): Either[LocaleError, Unit] = tryWithConnection {
implicit conn =>
logger.debug(s"Deleting all brand definitions for locale $locale")
withTransaction {
validateLocale(locale).right.flatMap {
_ =>
SQL("DELETE FROM brands WHERE locale_id={locale_id}").on('locale_id -> locale).execute()
Right(())
}
}
}
def createBrandNames(brandNames: Map[String, Seq[String]], locale: String): Either[LocaleOrParentError, Unit] = tryWithConnection {
implicit conn =>
withTransaction {
createBrandNamesQuery(brandNames, locale)
}
}
override def getBrandNames(foodCode: String, locale: String): Either[LocalLookupError, Seq[String]] =
brandNamesService.getBrandNames(foodCode, locale)
}
示例14: AssociatedFoodsAdminImpl
//设置package包名称以及导入依赖的类
package uk.ac.ncl.openlab.intake24.foodsql.admin
import javax.sql.DataSource
import com.google.inject.name.Named
import com.google.inject.{Inject, Singleton}
import org.slf4j.LoggerFactory
import uk.ac.ncl.openlab.intake24.errors.{LocalLookupError, LocaleOrParentError, UnexpectedDatabaseError}
import uk.ac.ncl.openlab.intake24.foodsql.SimpleValidation
import uk.ac.ncl.openlab.intake24.foodsql.modular.AssociatedFoodsAdminQueries
import uk.ac.ncl.openlab.intake24.services.fooddb.admin.AssociatedFoodsAdminService
import uk.ac.ncl.openlab.intake24.services.fooddb.user.AssociatedFoodsService
import uk.ac.ncl.openlab.intake24.sql.SqlDataService
import uk.ac.ncl.openlab.intake24.{AssociatedFood, AssociatedFoodWithHeader}
@Singleton
class AssociatedFoodsAdminImpl @Inject()(@Named("intake24_foods") val dataSource: DataSource, associatedFoodsService: AssociatedFoodsService) extends AssociatedFoodsAdminService with AssociatedFoodsAdminQueries with SimpleValidation with SqlDataService {
private val logger = LoggerFactory.getLogger(classOf[AssociatedFoodsAdminImpl])
def getAssociatedFoodsWithHeaders(foodCode: String, locale: String): Either[LocalLookupError, Seq[AssociatedFoodWithHeader]] = tryWithConnection {
implicit conn =>
withTransaction {
for (
_ <- validateFoodAndLocale(foodCode, locale).right;
result <- getAssociatedFoodsWithHeadersQuery(foodCode, locale).right
) yield result
}
}
def createAssociatedFoods(assocFoods: Map[String, Seq[AssociatedFood]], locale: String): Either[LocaleOrParentError, Unit] = tryWithConnection {
implicit conn =>
withTransaction {
createAssociatedFoodsQuery(assocFoods, locale)
}
}
def deleteAllAssociatedFoods(locale: String): Either[UnexpectedDatabaseError, Unit] = tryWithConnection {
implicit conn =>
deleteAllAssociatedFoodsQuery(locale)
}
def updateAssociatedFoods(foodCode: String, assocFoods: Seq[AssociatedFood], locale: String): Either[LocaleOrParentError, Unit] = tryWithConnection {
implicit conn =>
withTransaction {
for (
_ <- deleteAssociatedFoodsQuery(foodCode, locale).right;
_ <- createAssociatedFoodsQuery(Map(foodCode -> assocFoods), locale).right
) yield ()
}
}
def getAssociatedFoods(foodCode: String, locale: String): Either[LocalLookupError, Seq[AssociatedFood]] =
associatedFoodsService.getAssociatedFoods(foodCode, locale)
}
示例15: AchievementTimerScheduler
//设置package包名称以及导入依赖的类
package achievements
import achievements.actors.TimingAchievementActor
import achievements.actors.TimingAchievementActor.ProcessTimingAchievement
import akka.actor.ActorRef
import com.google.inject.Inject
import com.google.inject.name.Named
import com.markatta.akron.{CronExpression, CronTab}
import play.api.Logger
class AchievementTimerScheduler @Inject()(
@Named("crontab") crontab: ActorRef,
@Named(TimingAchievementActor.name) timingAchievementActor: ActorRef
) {
val logger = Logger(this.getClass)
logger.info("Initializing timeing achievements...")
AchievementDefinitionsTiming.achievements
.foreach { achievementDefinition =>
crontab ! CronTab.Schedule(
timingAchievementActor,
ProcessTimingAchievement(achievementDefinition),
CronExpression(achievementDefinition.pattern))
}
}