This file contains 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 models | |
import org.mindrot.jbcrypt.BCrypt | |
import scalikejdbc._ | |
case class Account(id: Int, email: String, password: String, name: String, role: Role) | |
case class newAccount(email: String, password: String, firstName: String, role: String) | |
object Account extends SQLSyntaxSupport[Account] { |
This file contains 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
def addAccount(title: String, name: String) = StackAction(AuthorityKey -> Administrator) { implicit request => | |
val user = loggedIn | |
accountForm.bindFromRequest.fold( | |
formWithErrors => BadRequest(html.Admin.landing.create(formWithErrors, title, name)), | |
newAccount => { | |
val id = addNewAccount(newAccount.email, newAccount.password, newAccount.firstName, Role.valueOf(newAccount.role)) | |
Redirect(controllers.auth.routes.Landing.createUser(name)).flashing("success" -> "Account %s has been created".format(newAccount.firstName)) | |
} | |
) | |
} |
This file contains 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
@(form: Form[newAccount], title: String, name: String)(implicit flash: play.api.mvc.Flash) | |
@views.html.Admin.fullTemplate(name, title) { | |
<main> | |
<section class="hero create"> | |
<div class="container"> | |
<h1>Create User</h1> | |
<p>"Administrator" or "NormalUser"</p> |
This file contains 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
in root/app/binders.scala: | |
package binders | |
import controllers.CloudData | |
import play.api.mvc.QueryStringBindable | |
/** | |
* Created by plamb on 9/7/16. | |
*/ | |
//case class CloudData(clusterName: String, keyPair: String, instance: String, storage: String, volumeSize: Int) |
This file contains 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
import net.ruippeixotog.scalascraper.browser.HtmlUnitBrowser | |
/** | |
* Created by plamb on 9/16/16. | |
*/ | |
class HtmlUnitBrowserFactory{ | |
} |
This file contains 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
val csvDF = snContext.read | |
.format("com.databricks.spark.csv") // Custom data source which can read from a CSV file | |
.option("header", "true") // Use first line of all files as header | |
.option("inferSchema", "true") // Automatically infer data types | |
.load("filePath") |
This file contains 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
snappyContext.createTable(rowTable, "row", csvDF.schema, Map.empty[String, String]) |
This file contains 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
snappyContext.sql("CREATE TABLE PR_TABLE1(OrderId INT NOT NULL,description String, OrderRef INT)" + | |
"USING row " + | |
"options " + | |
"(" + | |
"PARTITION_BY 'OrderId, OrderRef',"+ | |
"BUCKETS '113')") |
This file contains 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
snappyContext.sql("CREATE TABLE PR_TABLE2(OrderId INT NOT NULL,description String, OrderRef INT)" + | |
"USING row " + | |
"options " + | |
"(" + | |
"PARTITION_BY 'OrderId,OrderRef',"+ | |
"BUCKETS '113')") |
This file contains 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
snappyContext.sql(s"select P.OrderRef, P.description from " + | |
s"PR_TABLE1 P JOIN PR_TABLE2 R ON P.OrderId = R.OrderId AND P.OrderRef = R.OrderRef") |