Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controlled vocabularies not working #39

Closed
mardo opened this issue Aug 29, 2017 · 4 comments
Closed

Controlled vocabularies not working #39

mardo opened this issue Aug 29, 2017 · 4 comments
Labels

Comments

@mardo
Copy link
Member

mardo commented Aug 29, 2017

I have followed the steps here:
http://longevityframework.org/manual/poly/cv.html

My Model looks like this:

@polyComponent[DomainModel]
sealed trait TicketType

@derivedComponent[DomainModel, TicketType]
case object Congratulation extends TicketType

@derivedComponent[DomainModel, TicketType]
case object Observation extends TicketType

@persistent[DomainModel]
case class User(
  username: Username,
  email: Email,
  fullName: FullName,
  ticketType: TicketType
)

When trying to persist a user, I am presented with the following error:

[error] Exception in thread "main" java.lang.ExceptionInInitializerError
[error] 	at blockingApplication$.delayedEndpoint$blockingApplication$1(blockingApplication.scala:10)
[error] 	at blockingApplication$delayedInit$body.apply(blockingApplication.scala:3)
[error] 	at scala.Function0.apply$mcV$sp(Function0.scala:34)
[error] 	at scala.Function0.apply$mcV$sp$(Function0.scala:34)
[error] 	at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
[error] 	at scala.App.$anonfun$main$1$adapted(App.scala:76)
[error] 	at scala.collection.immutable.List.foreach(List.scala:378)
[error] 	at scala.App.main(App.scala:76)
[error] 	at scala.App.main$(App.scala:74)
[error] 	at blockingApplication$.main(blockingApplication.scala:3)
[error] 	at blockingApplication.main(blockingApplication.scala)
[error] Caused by: java.util.NoSuchElementException: None.get
[error] 	at scala.None$.get(Option.scala:349)
[error] 	at scala.None$.get(Option.scala:347)
[error] 	at typekey.TypeKeyMap.apply(TypeKeyMap.scala:64)
[error] 	at longevity.model.ModelType$$anon$3.apply(ModelType.scala:154)
[error] 	at longevity.model.ModelType$$anon$3.apply(ModelType.scala:152)
[error] 	at typekey.BaseTypeBoundMap.mapValue$1(BaseTypeBoundMap.scala:68)
[error] 	at typekey.BaseTypeBoundMap.$anonfun$mapValuesUnderlying$1(BaseTypeBoundMap.scala:71)
[error] 	at scala.collection.MapLike$MappedValues.$anonfun$foreach$3(MapLike.scala:253)
[error] 	at scala.collection.TraversableLike$WithFilter.$anonfun$foreach$1(TraversableLike.scala:789)
[error] 	at scala.collection.Iterator.foreach(Iterator.scala:929)
[error] 	at scala.collection.Iterator.foreach$(Iterator.scala:929)
[error] 	at scala.collection.AbstractIterator.foreach(Iterator.scala:1406)
[error] 	at scala.collection.IterableLike.foreach(IterableLike.scala:71)
[error] 	at scala.collection.IterableLike.foreach$(IterableLike.scala:70)
[error] 	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
[error] 	at scala.collection.immutable.HashMap$HashMapCollision1.foreach(HashMap.scala:283)
[error] 	at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:788)
[error] 	at scala.collection.MapLike$MappedValues.foreach(MapLike.scala:253)
[error] 	at scala.collection.TraversableOnce.foldLeft(TraversableOnce.scala:157)
[error] 	at scala.collection.TraversableOnce.foldLeft$(TraversableOnce.scala:155)
[error] 	at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104)
[error] 	at scala.collection.TraversableOnce.$div$colon(TraversableOnce.scala:151)
[error] 	at scala.collection.TraversableOnce.$div$colon$(TraversableOnce.scala:151)
[error] 	at scala.collection.AbstractTraversable.$div$colon(Traversable.scala:104)
[error] 	at scala.collection.immutable.MapLike.$plus$plus(MapLike.scala:88)
[error] 	at scala.collection.immutable.MapLike.$plus$plus$(MapLike.scala:87)
[error] 	at scala.collection.immutable.AbstractMap.$plus$plus(Map.scala:216)
[error] 	at typekey.TypeKeyMap.$plus$plus(TypeKeyMap.scala:134)
[error] 	at longevity.emblem.emblematic.Emblematic.reflectives$lzycompute(Emblematic.scala:22)
[error] 	at longevity.emblem.emblematic.Emblematic.reflectives(Emblematic.scala:22)
[error] 	at longevity.emblem.emblematic.EmblematicPropPath$.lookupReflective$1(EmblematicPropPath.scala:97)
[error] 	at longevity.emblem.emblematic.EmblematicPropPath$.unbounded(EmblematicPropPath.scala:116)
[error] 	at longevity.model.realized.RealizedProp$.validatePath(RealizedProp.scala:97)
[error] 	at longevity.model.realized.RealizedProp$.apply(RealizedProp.scala:82)
[error] 	at longevity.model.realized.RealizedPType.pair$1(RealizedPType.scala:34)
[error] 	at longevity.model.realized.RealizedPType.$anonfun$myRealizedProps$1(RealizedPType.scala:35)
[error] 	at scala.collection.TraversableOnce.$anonfun$foldLeft$1(TraversableOnce.scala:157)
[error] 	at scala.collection.TraversableOnce.$anonfun$foldLeft$1$adapted(TraversableOnce.scala:157)
[error] 	at scala.collection.immutable.HashSet$HashSet1.foreach(HashSet.scala:320)
[error] 	at scala.collection.immutable.HashSet$HashTrieSet.foreach(HashSet.scala:976)
[error] 	at scala.collection.TraversableOnce.foldLeft(TraversableOnce.scala:157)
[error] 	at scala.collection.TraversableOnce.foldLeft$(TraversableOnce.scala:155)
[error] 	at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104)
[error] 	at longevity.model.realized.RealizedPType.<init>(RealizedPType.scala:33)
[error] 	at longevity.model.ModelType.addPair$1(ModelType.scala:87)
[error] 	at longevity.model.ModelType.$anonfun$realizedPTypes$1(ModelType.scala:90)
[error] 	at scala.collection.TraversableOnce.$anonfun$foldLeft$1(TraversableOnce.scala:157)
[error] 	at scala.collection.TraversableOnce.$anonfun$foldLeft$1$adapted(TraversableOnce.scala:157)
[error] 	at scala.collection.Iterator.foreach(Iterator.scala:929)
[error] 	at scala.collection.Iterator.foreach$(Iterator.scala:929)
[error] 	at scala.collection.AbstractIterator.foreach(Iterator.scala:1406)
[error] 	at scala.collection.MapLike$DefaultValuesIterable.foreach(MapLike.scala:210)
[error] 	at scala.collection.TraversableOnce.foldLeft(TraversableOnce.scala:157)
[error] 	at scala.collection.TraversableOnce.foldLeft$(TraversableOnce.scala:155)
[error] 	at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104)
[error] 	at longevity.model.ModelType.<init>(ModelType.scala:75)
[error] 	at domainModel.DomainModel$modelType$.<init>(domainModel.scala:9)
[error] 	at domainModel.DomainModel$modelType$.<clinit>(domainModel.scala)
[error] 	... 11 more
@sullivan-
Copy link
Member

Good catch! My existing test for this (https://github.com/longevityframework/longevity/tree/master/longevity/src/test/scala/longevity/integration/model/controlledVocab) didn't catch the bug because the problem only comes up when all the deriveds are case objects. In my test case, one of the deriveds was a case class.

I have a fix locally, it will take a bit to go through the rigamarole of creating a bugfix release..

@mardo
Copy link
Member Author

mardo commented Aug 29, 2017

@sullivan- One thing to note is that while adding a case class as a derived component, it will compile, but it still won't work if you try to persist an instance with a case object. Not sure if you already noted that, but just making sure.

@sullivan-
Copy link
Member

@mardo can you please try with version 0.25.1 and let me know if it fixes the problem? Thanks

@mardo
Copy link
Member Author

mardo commented Aug 30, 2017

It works, @sullivan-! Thanks a lot!

@mardo mardo closed this as completed Aug 30, 2017
@sullivan- sullivan- added the bug label Sep 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants