Skip to content

Commit

Permalink
ID-779 Add some new fields to user profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
tlangs committed Sep 8, 2023
1 parent e6df83b commit fe7269b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ object ModelJsonProtocol extends WorkspaceJsonSupport with SprayJsonSupport {
implicit val impFireCloudKeyValue = jsonFormat2(FireCloudKeyValue)
implicit val impThurloeKeyValue = jsonFormat2(ThurloeKeyValue)
implicit val impThurloeKeyValues = jsonFormat2(ThurloeKeyValues)
implicit val impBasicProfile = jsonFormat10(BasicProfile)
implicit val impProfile = jsonFormat11(Profile.apply)
implicit val impBasicProfile = jsonFormat12(BasicProfile)
implicit val impProfile = jsonFormat13(Profile.apply)
implicit val impProfileWrapper = jsonFormat2(ProfileWrapper)
implicit val impProfileKVP = jsonFormat2(ProfileKVP)
implicit val impTerraPreference = jsonFormat2(TerraPreference)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ case class BasicProfile (
programLocationState: String,
programLocationCountry: String,
termsOfService: Option[String],
researchArea: Option[String]
researchArea: Option[String],
department: String,
interestInTerra: Option[String],
) extends mappedPropVals {
require(ProfileValidator.nonEmpty(firstName), "first name must be non-empty")
require(ProfileValidator.nonEmpty(lastName), "last name must be non-empty")
Expand All @@ -39,6 +41,7 @@ case class BasicProfile (
require(ProfileValidator.nonEmpty(programLocationCity), "program location city must be non-empty")
require(ProfileValidator.nonEmpty(programLocationState), "program location state must be non-empty")
require(ProfileValidator.nonEmpty(programLocationCountry), "program location country must be non-empty")
require(ProfileValidator.nonEmpty(department), "department must be non-empty")
}

case class Profile (
Expand All @@ -52,7 +55,9 @@ case class Profile (
programLocationCountry: String,
researchArea: Option[String],
linkedNihUsername: Option[String] = None,
linkExpireTime: Option[Long] = None
linkExpireTime: Option[Long] = None,
department: String,
interestInTerra: Option[String],
) extends mappedPropVals {
require(ProfileValidator.nonEmpty(firstName), "first name must be non-empty")
require(ProfileValidator.nonEmpty(lastName), "last name must be non-empty")
Expand All @@ -62,14 +67,15 @@ case class Profile (
require(ProfileValidator.nonEmpty(programLocationCity), "program location city must be non-empty")
require(ProfileValidator.nonEmpty(programLocationState), "program location state must be non-empty")
require(ProfileValidator.nonEmpty(programLocationCountry), "program location country must be non-empty")
require(ProfileValidator.nonEmpty(department), "department must be non-empty")
}

object Profile {

// increment this number every time you make a change to the user-provided profile fields
val currentVersion:Int = 4
val currentVersion:Int = 5

val requiredKeys = List("firstName", "lastName", "title", "institute", "programLocationCity",
val requiredKeys = List("firstName", "lastName", "title", "institute", "department", "programLocationCity",
"programLocationState", "programLocationCountry")

def apply(wrapper: ProfileWrapper): Profile = {
Expand All @@ -95,7 +101,9 @@ object Profile {
linkExpireTime = mappedKVPs.get("linkExpireTime") match {
case Some(time) => Some(time.toLong)
case _ => None
}
},
department = mappedKVPs("department"),
interestInTerra = mappedKVPs.get("interestInTerra")
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class ProfileSpec extends AnyFreeSpec with Matchers {
programLocationCity = randomString,
programLocationState = randomString,
programLocationCountry = randomString,
termsOfService = Some(termsOfServiceUrl)
termsOfService = Some(termsOfServiceUrl),
department = randomString,
interestInTerra = Some(randomString)
)
basicProfile shouldNot be(null)
}
Expand All @@ -38,7 +40,9 @@ class ProfileSpec extends AnyFreeSpec with Matchers {
programLocationCity = randomString,
programLocationState = randomString,
programLocationCountry = randomString,
termsOfService = Some(termsOfServiceUrl)
termsOfService = Some(termsOfServiceUrl),
department = randomString,
interestInTerra = Some(randomString)
)
basicProfile shouldNot be(null)
}
Expand All @@ -52,7 +56,9 @@ class ProfileSpec extends AnyFreeSpec with Matchers {
researchArea = Some(randomString),
programLocationCity = randomString,
programLocationState = randomString,
programLocationCountry = randomString
programLocationCountry = randomString,
department = randomString,
interestInTerra = Some(randomString)
)
profile shouldNot be(null)
}
Expand All @@ -66,7 +72,9 @@ class ProfileSpec extends AnyFreeSpec with Matchers {
researchArea = Some(randomString),
programLocationCity = randomString,
programLocationState = randomString,
programLocationCountry = randomString
programLocationCountry = randomString,
department = randomString,
interestInTerra = Some(randomString)
)
profile shouldNot be(null)
}
Expand All @@ -80,7 +88,9 @@ class ProfileSpec extends AnyFreeSpec with Matchers {
researchArea = Some(randomString),
programLocationCity = randomString,
programLocationState = randomString,
programLocationCountry = randomString
programLocationCountry = randomString,
department = randomString,
interestInTerra = Some(randomString)
)
profile shouldNot be(null)
}
Expand All @@ -99,6 +109,8 @@ class ProfileSpec extends AnyFreeSpec with Matchers {
programLocationState = "",
programLocationCountry = "",
None,
None,
"",
None
)
}
Expand All @@ -115,7 +127,9 @@ class ProfileSpec extends AnyFreeSpec with Matchers {
researchArea = Some(randomString),
programLocationCity = randomString,
programLocationState = randomString,
programLocationCountry = randomString
programLocationCountry = randomString,
department = randomString,
interestInTerra = Some(randomString)
)
}
ex shouldNot be(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ final class RegisterApiServiceSpec extends BaseServiceSpec with RegisterApiServi
programLocationCity = randomString,
programLocationState = randomString,
programLocationCountry = randomString,
termsOfService = if (hasTermsOfService) Some(termsOfServiceUrl) else None
termsOfService = if (hasTermsOfService) Some(termsOfServiceUrl) else None,
department = randomString,
interestInTerra = Some(randomString)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ class UserApiServiceSpec extends BaseServiceSpec with SamMockserverUtils
programLocationCity = randomAlpha(),
programLocationState = randomAlpha(),
programLocationCountry = randomAlpha(),
termsOfService = None
termsOfService = None,
department = randomAlpha(),
interestInTerra = Some(randomAlpha())
)
val allProperties: Map[String, String] = fullProfile.propertyValueMap

Expand Down

0 comments on commit fe7269b

Please sign in to comment.