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.core.personality 21 22 import enumeratum.values.{StringCirceEnum, StringEnum, StringEnumEntry} 23 import io.circe.{Decoder, Encoder, Json} 24 import org.make.core.{SprayJsonFormatters, StringValue} 25 import org.make.core.question.QuestionId 26 import org.make.core.user.UserId 27 import spray.json.JsonFormat 28 29 final case class Personality( 30 personalityId: PersonalityId, 31 userId: UserId, 32 questionId: QuestionId, 33 personalityRoleId: PersonalityRoleId 34 ) 35 36 final case class PersonalityId(value: String) extends StringValue 37 38 object PersonalityId { 39 implicit lazy val personalityIdEncoder: Encoder[PersonalityId] = 40 (a: PersonalityId) => Json.fromString(a.value) 41 implicit lazy val personalityIdDecoder: Decoder[PersonalityId] = 42 Decoder.decodeString.map(PersonalityId(_)) 43 44 implicit val personalityIdFormatter: JsonFormat[PersonalityId] = 45 SprayJsonFormatters.forStringValue(PersonalityId.apply) 46 } 47 48 final case class PersonalityRole(personalityRoleId: PersonalityRoleId, name: String) 49 50 final case class PersonalityRoleField( 51 personalityRoleFieldId: PersonalityRoleFieldId, 52 personalityRoleId: PersonalityRoleId, 53 name: String, 54 fieldType: FieldType, 55 required: Boolean 56 ) 57 58 final case class PersonalityRoleFieldId(value: String) extends StringValue 59 60 object PersonalityRoleFieldId { 61 implicit lazy val personalityRoleFieldIdEncoder: Encoder[PersonalityRoleFieldId] = 62 (a: PersonalityRoleFieldId) => Json.fromString(a.value) 63 implicit lazy val personalityRoleFieldIdDecoder: Decoder[PersonalityRoleFieldId] = 64 Decoder.decodeString.map(PersonalityRoleFieldId(_)) 65 66 implicit val personalityRoleFieldIdFormatter: JsonFormat[PersonalityRoleFieldId] = 67 SprayJsonFormatters.forStringValue(PersonalityRoleFieldId.apply) 68 } 69 70 final case class PersonalityRoleId(value: String) extends StringValue 71 72 object PersonalityRoleId { 73 implicit lazy val personalityRoleIdEncoder: Encoder[PersonalityRoleId] = 74 (a: PersonalityRoleId) => Json.fromString(a.value) 75 implicit lazy val personalityRoleIdDecoder: Decoder[PersonalityRoleId] = 76 Decoder.decodeString.map(PersonalityRoleId(_)) 77 78 implicit val personalityRoleIdFormatter: JsonFormat[PersonalityRoleId] = 79 SprayJsonFormatters.forStringValue(PersonalityRoleId.apply) 80 } 81 82 sealed abstract class FieldType(val value: String) extends StringEnumEntry 83 84 object FieldType extends StringEnum[FieldType] with StringCirceEnum[FieldType] { 85 86 val defaultFieldType: FieldType = StringType 87 88 case object StringType extends FieldType("STRING") 89 case object IntType extends FieldType("INT") 90 case object BooleanType extends FieldType("BOOLEAN") 91 92 override val values: IndexedSeq[FieldType] = findValues 93 final val swaggerAllowableValues = "STRING,INT,BOOLEAN" 94 }
| Line | Stmt Id | Pos | Tree | Symbol | Tests | Code |
|---|---|---|---|---|---|---|
| 45 | 4180 | 1595 - 1650 | Apply | org.make.core.SprayJsonFormatters.forStringValue | org.make.core.SprayJsonFormatters.forStringValue[org.make.core.personality.PersonalityId](((value: String) => PersonalityId.apply(value))) | |
| 45 | 972 | 1630 - 1649 | Apply | org.make.core.personality.PersonalityId.apply | PersonalityId.apply(value) | |
| 67 | 2279 | 2451 - 2479 | Apply | org.make.core.personality.PersonalityRoleFieldId.apply | PersonalityRoleFieldId.apply(value) | |
| 67 | 5434 | 2416 - 2480 | Apply | org.make.core.SprayJsonFormatters.forStringValue | org.make.core.SprayJsonFormatters.forStringValue[org.make.core.personality.PersonalityRoleFieldId](((value: String) => PersonalityRoleFieldId.apply(value))) | |
| 79 | 3680 | 2953 - 2976 | Apply | org.make.core.personality.PersonalityRoleId.apply | PersonalityRoleId.apply(value) | |
| 79 | 2693 | 2918 - 2977 | Apply | org.make.core.SprayJsonFormatters.forStringValue | org.make.core.SprayJsonFormatters.forStringValue[org.make.core.personality.PersonalityRoleId](((value: String) => PersonalityRoleId.apply(value))) | |
| 86 | 546 | 3175 - 3185 | Select | org.make.core.personality.FieldType.StringType | FieldType.this.StringType | |
| 93 | 3950 | 3438 - 3458 | Literal | <nosymbol> | "STRING,INT,BOOLEAN" |