1 /* 2 * Make.org Core API 3 * Copyright (C) 2018 Make.org 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU Affero General Public License as 7 * published by the Free Software Foundation, either version 3 of the 8 * License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Affero General Public License for more details. 14 * 15 * You should have received a copy of the GNU Affero General Public License 16 * along with this program. If not, see <https://www.gnu.org/licenses/>. 17 * 18 */ 19 20 package org.make.api.feature 21 22 import org.make.api.technical._ 23 import org.make.core.technical.Pagination 24 import org.make.core.feature._ 25 import org.make.core.question.QuestionId 26 import org.make.core.Order 27 28 import scala.concurrent.Future 29 30 trait DefaultActiveFeatureServiceComponent extends ActiveFeatureServiceComponent with ShortenedNames { 31 this: PersistentActiveFeatureServiceComponent with IdGeneratorComponent => 32 33 override lazy val activeFeatureService: ActiveFeatureService = new DefaultActiveFeatureService 34 35 class DefaultActiveFeatureService extends ActiveFeatureService { 36 37 override def getActiveFeature(activeFeatureId: ActiveFeatureId): Future[Option[ActiveFeature]] = { 38 persistentActiveFeatureService.get(activeFeatureId) 39 } 40 41 override def createActiveFeature( 42 featureId: FeatureId, 43 maybeQuestionId: Option[QuestionId] 44 ): Future[ActiveFeature] = { 45 persistentActiveFeatureService.persist( 46 ActiveFeature( 47 activeFeatureId = idGenerator.nextActiveFeatureId(), 48 featureId = featureId, 49 maybeQuestionId = maybeQuestionId 50 ) 51 ) 52 } 53 54 override def deleteActiveFeature(activeFeatureId: ActiveFeatureId): Future[Unit] = { 55 persistentActiveFeatureService.remove(activeFeatureId) 56 } 57 58 override def find( 59 offset: Pagination.Offset = Pagination.Offset.zero, 60 end: Option[Pagination.End] = None, 61 sort: Option[String] = None, 62 order: Option[Order] = None, 63 maybeQuestionId: Option[Seq[QuestionId]] = None, 64 featureIds: Option[Seq[FeatureId]] = None 65 ): Future[Seq[ActiveFeature]] = 66 persistentActiveFeatureService.find(offset, end, sort, order, maybeQuestionId, featureIds) 67 68 override def count(maybeQuestionId: Option[QuestionId]): Future[Int] = { 69 persistentActiveFeatureService.count(maybeQuestionId) 70 } 71 } 72 }
| Line | Stmt Id | Pos | Tree | Symbol | Tests | Code |
|---|---|---|---|---|---|---|
| 38 | 25239 | 1437 - 1488 | Apply | org.make.api.feature.PersistentActiveFeatureService.get | org.make.api.feature.activefeatureservicetest | DefaultActiveFeatureServiceComponent.this.persistentActiveFeatureService.get(activeFeatureId) |
| 45 | 24464 | 1643 - 1863 | Apply | org.make.api.feature.PersistentActiveFeatureService.persist | org.make.api.feature.activefeatureservicetest | DefaultActiveFeatureServiceComponent.this.persistentActiveFeatureService.persist(org.make.core.feature.ActiveFeature.apply(DefaultActiveFeatureServiceComponent.this.idGenerator.nextActiveFeatureId(), featureId, maybeQuestionId)) |
| 46 | 26638 | 1691 - 1855 | Apply | org.make.core.feature.ActiveFeature.apply | org.make.api.feature.activefeatureservicetest | org.make.core.feature.ActiveFeature.apply(DefaultActiveFeatureServiceComponent.this.idGenerator.nextActiveFeatureId(), featureId, maybeQuestionId) |
| 47 | 22971 | 1734 - 1767 | Apply | org.make.core.technical.IdGenerator.nextActiveFeatureId | org.make.api.feature.activefeatureservicetest | DefaultActiveFeatureServiceComponent.this.idGenerator.nextActiveFeatureId() |
| 55 | 23289 | 1966 - 2020 | Apply | org.make.api.feature.PersistentActiveFeatureService.remove | DefaultActiveFeatureServiceComponent.this.persistentActiveFeatureService.remove(activeFeatureId) | |
| 66 | 27105 | 2366 - 2456 | Apply | org.make.api.feature.PersistentActiveFeatureService.find | org.make.api.feature.activefeatureservicetest | DefaultActiveFeatureServiceComponent.this.persistentActiveFeatureService.find(offset, end, sort, order, maybeQuestionId, featureIds) |
| 69 | 24696 | 2541 - 2594 | Apply | org.make.api.feature.PersistentActiveFeatureService.count | DefaultActiveFeatureServiceComponent.this.persistentActiveFeatureService.count(maybeQuestionId) |