Skip to content

Instantly share code, notes, and snippets.

View hongwei1's full-sized avatar

Hongwei hongwei1

View GitHub Profile
import net.liftweb.common.{Box, Empty, Failure, Full}
//val option: Option[Null] = Option(null)
val box1 = Full(null)
val box2 = Full("")
val box3 = Empty
val box4 = None
val box5 = Failure("hongwei")
import net.liftweb.common.{Box, Empty, Failure, Full}
import net.liftweb.util.Helpers.tryo
//val option: Option[Null] = Option(null)
val box1 = Full(null)
val box2 = Full("")
val box3 = Empty
val box4 = None
val box5 = Failure("hongwei")
successJsonResponse(Extraction.decompose(json)(formats = new Formats {
import java.text.{ParseException, SimpleDateFormat}
val dateFormat = new DateFormat {
def parse(s: String) = try {
Some(formatter.parse(s))
} catch {
case e: ParseException => None
}
@hongwei1
hongwei1 / ObpJvmMappedConnector.scala
Created March 12, 2017 13:21
do not know what is it doing ??
def updateUserAccountViews( user: ResourceUser ) = {
val accounts = getBanks.flatMap { bank => {
val bankId = bank.bankId.value
logger.debug(s"ObpJvm updateUserAccountViews for user.email ${user.email} user.name ${user.name} at bank ${bankId}")
val parameters = new JHashMap
parameters.put("userId", user.name)
parameters.put("bankId", bankId)
val response = jvmNorth.get("getAccounts", Transport.Target.accounts, parameters)
// todo response.error().isPresent
@hongwei1
hongwei1 / AllTransferCases.sc
Created October 12, 2017 21:30
All Liftweb Json
import net.liftweb.json._
import scala.text.Document
implicit val formats = net.liftweb.json.DefaultFormats
case class InternalCaseClass(
text: String
)
@hongwei1
hongwei1 / List[String] -- Liftweb-mapped
Created October 16, 2017 09:37
object mPinResets extends MappedOneToMany(PinReset, PinReset.card, OrderBy(PinReset.id, Ascending))
object mPinResets extends MappedOneToMany(PinReset, PinReset.card, OrderBy(PinReset.id, Ascending))
@hongwei1
hongwei1 / lift-json-trait.sc
Created October 20, 2017 11:49
lift-web- json , trait
import net.liftweb.json._
//implicit val formats = net.liftweb.json.DefaultFormats
trait InternalCaseClassTrait{
def text: String
}
case class InternalCaseClass(
text: String
) extends InternalCaseClassTrait
val string = "https://demo.openbankproject.com/obp/v4.0.0/config/obp/v4.0.0/dynamic/pet/PET_ID/PET_A_ID"
val pattern = ".*/(([A-Z]+_)*ID$)".r
//val string = "bankId=1&accountId=2&transactionId=3"
//val pattern = "bankId=(.+)&accountId=(.+)&transactionId=(.+)".r
string match {
case pattern(a,b) => println(a,b) //matched group(1) assigned to variable a483
case _ => println("nothing")
}