{"issue":{"title":"Grater has trouble dealing with List-s and Option-s that live next to eachother","user":{"login":"manuelbernhardt","id":459669,"url":"https://api.github.com/users/manuelbernhardt","avatar_url":"https://secure.gravatar.com/avatar/06156f543560f9fddcfdab87393ac816?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"06156f543560f9fddcfdab87393ac816"},"created_at":"2011-12-23T08:30:34Z","milestone":null,"state":"open","updated_at":"2011-12-24T18:40:42Z","labels":[],"id":2645454,"html_url":"https://github.com/novus/salat/issues/24","closed_at":null,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"body":"This happened to me a few times already: basically, whenever I have a case class with a collection member followed by an Option, I get a grater glitch on `wrong number of arguments`. For example (simplified):\r\n\r\n    case class MetadataRecord(\r\n      validOutputFormats: List[String] = List.empty[String], // valid formats this records can be mapped to\r\n      transferIdx: Option[Int] = None, // 0-based index for the transfer order\r\n      deleted: Boolean = false, // if the record has been deleted\r\n    )\r\n\r\nwill not work, whilst\r\n\r\n    case class MetadataRecord(\r\n      validOutputFormats: List[String] = List.empty[String], // valid formats this records can be mapped to\r\n      deleted: Boolean = false, // if the record has been deleted\r\n      transferIdx: Option[Int] = None, // 0-based index for the transfer order\r\n    )\r\n\r\ndoes work.","number":24,"url":"https://api.github.com/repos/novus/salat/issues/24","comments":6,"assignee":{"login":"rktoomey","id":293393,"url":"https://api.github.com/users/rktoomey","avatar_url":"https://secure.gravatar.com/avatar/07db618a46f03285f40bec46a80c903e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"07db618a46f03285f40bec46a80c903e"}},"comment":{"user":{"login":"manuelbernhardt","id":459669,"url":"https://api.github.com/users/manuelbernhardt","avatar_url":"https://secure.gravatar.com/avatar/06156f543560f9fddcfdab87393ac816?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"06156f543560f9fddcfdab87393ac816"},"created_at":"2011-12-24T18:40:42Z","updated_at":"2011-12-24T18:40:42Z","id":3268651,"body":"Indeed, good to know. I used s DBObiect here (and in other places)\r\nbecause Map[String, List[String]] would not work. This works in\r\nproduction code - at least to what I saw so far.\r\n\r\nThe MetadataRecord also works when inverting the order of the members\r\n(ie not having the List next to the Option). May the usage of DBObject\r\ninside of the Map be at the origin of the gratet glitch?\r\n\r\nBy the way: happy christmas!\r\n\r\nOn 24.12.2011, at 16:34, Rose Toomey\r\n<reply@reply.github.com>\r\nwrote:\r\n\r\n> DBObject is not a case class and so not a supported type for a Map value.\r\n>\r\n> On 24 December 2011 15:53, Manuel Bernhardt\r\n> <reply@reply.github.com>\r\n> wrote:\r\n>> While I try to get that test to work, here's already the full model and trace (you'll notice that the `MetadataRecord` is slightly more complex than the simplified version I posted -- my bad, I suppose this is a bit more complex than having a list next to an option).\r\n>>\r\n>>    case class MetadataRecord(_id: ObjectId = new ObjectId,\r\n>>                          hubId: String,\r\n>>                          rawMetadata: Map[String, String],\r\n>>                          mappedMetadata: Map[String, DBObject] = Map.empty[String, DBObject],\r\n>>                          modified: Date = new Date(),\r\n>>                          validOutputFormats: List[String] = List.empty[String],\r\n>>                          transferIdx: Option[Int] = None,\r\n>>                          deleted: Boolean = false,\r\n>>                          localRecordKey: String,\r\n>>                          links: List[EmbeddedLink] = List.empty[EmbeddedLink],\r\n>>                          globalHash: String,\r\n>>                          hash: Map[String, String]\r\n>>                         )\r\n>>\r\n>>\r\n>> And the trace:\r\n>>\r\n>>    com.novus.salat.util.ToObjectGlitch:\r\n>>\r\n>>      wrong number of arguments\r\n>>\r\n>>      $anon$3(class models.MetadataRecord @ models.package$$anon$1@2d366f2c) toObject failed on:\r\n>>      SYM: models.MetadataRecord\r\n>>      CONSTRUCTOR: public models.MetadataRecord(org.bson.types.ObjectId,java.lang.String,scala.collection.immutable.Map,scala.collection.immutable.Map,java.util.Date,scala.collection.immutable.List,scala.Option,boolean,java.lang.String,scala.collection.immutable.List,java.lang.String,scala.collection.immutable.Map)\r\n>>      ARGS:\r\n>>    [0] class org.bson.types.ObjectId\r\n>>                4ef4679d0364cbb8c3a9719f\r\n>>    [1] class java.lang.String\r\n>>                delving_EmptyCollection_7117\r\n>>    [2] class scala.collection.immutable.Map$Map1\r\n>>                Map(raw -> <priref>7117</priref>\r\n>>    <edit.source>collect>intern</edit.source>\r\n>>    <edit.source>collect>intern</edit.source>\r\n>>    <edit.time>10:16:55</edit.time>\r\n>>    <edit.time>14:03:08</edit.time>\r\n>>    <edit.name>d.terpstra</edit.name>\r\n>>    ...\r\n>>    <percentH>N</percentH>\r\n>>    )\r\n>>    [3] class scala.collection.immutable.Map$Map1\r\n>>    Map(icn -> { \"europeana_isShownAt_string\" : [ \"http://fries-museum.delving.org/portal/object/EmptyCollection/A007E5D701A49C3927E896C57368C8F2A545E09D.html\"] , \"europeana_type_string\" : [ \"IMAGE\"] , \"europeana_dataProvider_string\" : [ \"Fries Museum\"] , \"europeana_rights_string\" : [ \"http://creativecommons.org/publicdomain/mark/1.0/\"] , \"icn_physicalState_text\" : [ \"matig\"] , \"dc_rights_text\" : [ \"Verzetsmuseum Friesland\"] , \"europeana_language_string\" : [ \"nl\"] , \"europeana_provider_string\" : [ \"Fries Museum\"] , \"delving_description\" : [ \"-\"] , \"dc_title_text\" : [ \"Postzegel, serie, bevrijding/Verenigde Naties\"] , \"delving_title\" : [ \"Postzegel, serie, bevrijding/Verenigde Naties\"] , \"dc_identifier_string\" : [ \"22954\"] , \"dc_source_text\" : [ \"Verzetsmuseum Friesland\"] , \"europeana_uri_string\" : [ \"EmptyCollection/A007E5D701A49C3927E896C57368C8F2A545E09D\"] , \"delving_owner\" : [ \"Fries Museum\"] , \"europeana_country_text\" : [ \"netherlands\"] , \"delving_landingPage\" : [ \"htt\r\n> p:/\r\n>>  /fries-museum.delving.org/portal/object/EmptyCollection/A007E5D701A49C3927E896C57368C8F2A545E09D.html\"] , \"europeana_collectionTitle_text\" : [ \"Fries Museum3\"] , \"icn_collectionType_text\" : [ \"all\"] , \"icn_acquisitionYear_string\" : [ \"1995-07-05\"] , \"dc_description_text\" : [ \"-\"] , \"delving_snippet\" : [ \"Fries Museum3\"] , \"dc_type_text\" : [ \"document\"] , \"dc_coverage_text\" : [ \"-\"]})\r\n>>    [4] class java.util.Date\r\n>>                Fri Dec 23 12:35:57 CET 2011\r\n>>    [5] class scala.collection.immutable.$colon$colon\r\n>>                List(icn)\r\n>>    [6] class scala.Some\r\n>>                Some(6815)\r\n>>    [7] class java.lang.String\r\n>>                7117\r\n>>    [8] class scala.collection.immutable.Nil$\r\n>>                List()\r\n>>    [9] class java.lang.String\r\n>>                35BA231B394DAF27F0738EA3A6854C58\r\n>>    [10]        class scala.collection.immutable.HashMap$HashTrieMap\r\n>>                Map(3AA5E4AED92FD3AAB99B9BC934A62504 -> /percentH, B49896AB8CAAFAF4CFDE7C0A48D4E95D -> /input.date, 6583A5F3CD06AF71E468562AA73EC682 -> /acquisition.date, 4EB43703FE4E906E5B621E72D24C449B -> /association.subject.type/text, CA52F7A15CE21CB8E7ECA32DCB504082 -> /institution.code, 17CFBB5A1116B9E4A891A8FB2CE39A8D -> /edit.date_1, 3C8F045606754013EFB692ABDD6A0736 -> /content.motif.specific, C403E32BA8417A813D060526F1924685 -> /production.date.notes, E30ED3FF1232ABEFE806E86E071895D0 -> /valuation.value.currency, AF06F0C534CE6B4990DE37B89982EBF5 -> /condition, 860B37E28EC7BA614F00F9246949561D -> /priref, 33606CB9E03683F2324FC00FFDACB88B -> /edit.source, D547C8A5EADD9790D23C842D42443814 -> /number_of_parts, 1D32896986170D7004DCC7C53F364AD7 -> /input.name, BBCDEC9E42C3C13619DB70D7E0398BAF -> /acquisition.method, 9B8FB4DAB35D8BF214B1FBD76628D232 -> /free_field.content, 84A4F82FA43E10D7F9FFD72B0BAC70C7 -> /association.subject.type/text_1, B406FD0B1170C305E22B8ED\r\n> 9BFC09EC2 -> /assoc\r\n>>  iation.period.date.start, 3FAF395CFC3A792ADF4679D81CB348BD -> /description, 2B161DE272714C6522E99E769A45BB45 -> /content.motif.general, 9D46F20233F9CE20D3C38AB80B5358BF -> /object_name, 278C9EEF88B7ED791ED9C15424B33579 -> /association.subject.type/text_2, 131546183B649C53F08F262A19DB1F3C -> /association.subject.type/text_3, 8BD3BABB41B14CCC609A87722289594C -> /edit.time, E25D02D16732B0E9BBF23E3FB9B95A80 -> /association.subject.type/text_4, 2612D605DE11E8D560D4E4A6EAF9A11C -> /free_field.type, 98193332FF6AE7419E3840C27CA55492 -> /production.place, A5433DEF771CED1739C3F593143FEE88 -> /valuation.date, 0323A72446CDF9A56CAA79698FCAD062 -> /edit.name_1, 752B60DA6B31CCA3F787CE0369D78EA6 -> /association.subject.type/text_5, 4CC77C4665FC57CFC98195014DC39A58 -> /administration_name, 30D2F455DC0B6D149C02290793AF2103 -> /edit.date, 8A92F1009D99B3E37FF784D20C760318 -> /institution.name, 0D98BC395CC21F6FD452DDB8D4E274DC -> /object_number, 4827A486FA42FA1A315853752EF402B3 -> /location.d\r\n> efa\r\n>>  ult, C43A820D082A6D7D04B7A20B322D0319 -> /edit.time_1, 68B329DA9893E34099C7D8AD5CB9C940 -> /institution.place, 30C3AFC8A8C60A30E9AFEFFA4E95B557 -> /edit.name, 8B7FF2C277A9D3B12196A9CCF09EDCDF -> /related_object.notes, 58EF6CBBDB3D7B36B920527033A4D255 -> /valuation.value, D3FA390B69DE58A42CCC3E1DF257CAAE -> /title)\r\n>>\r\n>>\r\n>>        at com.novus.salat.ConcreteGrater.asObject(Grater.scala:276)\r\n>>        at com.novus.salat.ConcreteGrater.asObject(Grater.scala:53)\r\n>>        at com.novus.salat.dao.SalatMongoCursorBase$class.next(SalatMongoCursor.scala:43)\r\n>>        at com.novus.salat.dao.SalatMongoCursor.next(SalatMongoCursor.scala:145)\r\n>>        at com.novus.salat.dao.SalatMongoCursor.next(SalatMongoCursor.scala:145)\r\n>>        at scala.collection.Iterator$class.foreach(Iterator.scala:631)\r\n>>        at com.novus.salat.dao.SalatMongoCursor.foreach(SalatMongoCursor.scala:145)\r\n>>        at components.Indexing$.indexInSolr(Indexing.scala:64)\r\n>>        at jobs.DataSetIndexing.doJob(DatasetIndexing.scala:41)\r\n>>        at play.jobs.Job.doJobWithResult(Job.java:50)\r\n>>        at play.jobs.Job.call(Job.java:146)\r\n>>        at play.jobs.Job.run(Job.java:132)\r\n>>        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)\r\n>>        at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)\r\n>>        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)\r\n>>        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)\r\n>>        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)\r\n>>        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)\r\n>>        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)\r\n>>        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)\r\n>>        at java.lang.Thread.run(Thread.java:680)\r\n>>    Caused by: java.lang.IllegalArgumentException: wrong number of arguments\r\n>>        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)\r\n>>        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)\r\n>>        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)\r\n>>        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)\r\n>>        at com.novus.salat.ConcreteGrater.asObject(Grater.scala:269)\r\n>>        ... 20 more\r\n>>\r\n>> ---\r\n>> Reply to this email directly or view it on GitHub:\r\n>> https://github.com/novus/salat/issues/24#issuecomment-3267503\r\n>\r\n> ---\r\n> Reply to this email directly or view it on GitHub:\r\n> https://github.com/novus/salat/issues/24#issuecomment-3268077","url":"https://api.github.com/repos/novus/salat/issues/comments/3268651"},"action":"created"}