Last active
October 25, 2016 01:31
-
-
Save mslinn/4415732 to your computer and use it in GitHub Desktop.
Attempt to persist entities with >22 fields via Slick. Cannot find documentation on how nested tuples are supposed to work; tried creating two helper classes (CustomerAddress and PaymentDetail). Compiler error is: scala: overloaded method value <> with alternatives: [R(in method <>)(in method <>)(in method <>)(in method <>)(in method <>)(in meth…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.micronautics.paypal | |
import java.util.{ List, Map } | |
import collection.JavaConversions._ | |
import collection.immutable.HashMap | |
import controllers.Email | |
import org.joda.time.DateTime | |
import slick.driver.MySQLDriver.simple._ | |
import java.util | |
/** The customerAddress table does not actually exist; this is my attempt to somehow put together nested tuples in the absence of any documentation */ | |
object CustomerAddresses extends Table[(Int, String, String, String, String, String, String, String, String)]("customerAddress") { | |
def id = column[Int]("id", O NotNull) | |
def addressCity = column[String]("address_city") | |
def addressCountry = column[String]("address_country") | |
def addressCountryCode = column[String]("address_country_code") | |
def addressName = column[String]("address_name") | |
def addressState = column[String]("address_state") | |
def addressStatus = column[String]("address_status") | |
def addressStreet = column[String]("address_street") | |
def addressZip = column[String]("address_zip") | |
def * = id ~ addressCity ~ addressCountry ~ addressCountryCode ~ addressName ~ addressState ~ addressStatus ~ addressStreet ~ addressZip | |
} | |
case class CustomerAddress( | |
addressCity: String, | |
addressCountry: String, | |
addressCountryCode: String, | |
addressName: String, | |
addressState: String, | |
addressStatus: String, | |
addressStreet: String, | |
addressZip: String) | |
/** The paymentDetail table does not actually exist; this is my attempt to somehow put together nested tuples in the absence of any documentation */ | |
object PaymentDetails extends Table[(Int, String, String, String, String, String, String)]("paymentDetail") { | |
def id = column[Int]("id", O NotNull) // this field does not exist separately | |
def paymentDate = column[String]("payment_date") | |
def paymentStatus = column[String]("payment_status") | |
def paymentType = column[String]("payment_type") | |
def pendingReason = column[String]("pending_reason") | |
def reasonCode = column[String]("reason_code") | |
def tax = column[String]("tax") | |
def * = id ~ paymentDate ~ paymentStatus ~ paymentType ~ pendingReason ~ reasonCode ~ tax | |
} | |
case class PaymentDetail( | |
paymentDate: DateTime, | |
paymentStatus: String, | |
paymentType: String, | |
pendingReason: String, | |
reasonCode: String, | |
tax: String) | |
/** This is the only object that actually exists in persisted form */ | |
object PaypalTransactions extends Table[PaypalTransaction]("paypal_transaction") { | |
new File("txLogs").mkdirs() | |
def id = column[Int]("id", O.PrimaryKey, O.AutoInc) | |
def charset = column[String]("charset") | |
def contactPhone = column[String]("contactPhone") | |
def custom = column[String]("custom") | |
def firstName = column[String]("firstName") | |
def getsUpdates = column[Boolean]("getsUpdates") // todo add to schema | |
def lastName = column[String]("lastName") | |
def mcCurrency = column[String]("mcCurrency") | |
def mcFee = column[String]("mcFee") | |
def mcGross = column[String]("mcGross") | |
def memo = column[String]("memo") | |
def payerBusinessName = column[String]("payerBusinessName") | |
def payerEmail = column[String]("payerEmail") | |
def payerId = column[String]("payerId") | |
def payerStatus = column[String]("payerStatus") | |
def txnId = column[String]("txnId") | |
def verifySign = column[String]("verifySign") | |
def isComplementary = column[Boolean]("isComplementary") | |
// Took a wild guess at what the def for nested tuples might look like (CustomerAddress & PaymentDetail) | |
// The following seems to want a TypeMapper. What would that look like? Here is a cheap shot to make it compile: | |
implicit val bogusTypeMapper1: TypeMapper[CustomerAddress] = null | |
implicit val bogusTypeMapper2: TypeMapper[PaymentDetail] = null | |
def customerAddress = column[CustomerAddress]("customerAddress")(bogusTypeMapper1) | |
def paymentDetail = column[PaymentDetail]("paymentDetail")(bogusTypeMapper2) | |
def * = id ~ charset ~ contactPhone ~ custom ~ firstName ~ getsUpdates ~ lastName ~ mcCurrency ~ mcFee ~ mcGross ~ | |
memo ~ payerBusinessName ~ payerEmail ~ payerId ~ payerStatus ~ txnId ~ verifySign ~ isComplementary ~ | |
customerAddress ~ paymentDetail <> (PaypalTransaction, PaypalTransaction.unapply _) | |
} | |
case class PaypalTransaction( | |
id: Int, | |
charset: String, | |
contactPhone: String, | |
custom: String, | |
firstName: String, | |
getsUpdates: Boolean, | |
lastName: String, | |
mcCurrency: String, | |
mcFee: String, | |
mcGross: String, | |
memo: String, | |
payerBusinessName: String, | |
payerEmail: String, | |
payerId: String, | |
payerStatus: String, | |
txnId: String, | |
verifySign: String, | |
customerAddress: CustomerAddress, | |
paymentDetail: PaymentDetail, | |
isComplementary: Boolean = false | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment