ラベル Scala の投稿を表示しています。 すべての投稿を表示
ラベル Scala の投稿を表示しています。 すべての投稿を表示

7/05/2014

GitBucket News launched

A new blog GitBucket News which provides information about GitBucket is launched on Github Pages.


Information about GitBucket such as release announcement and development status will be provided on this blog from now on.

Please check it!

5/31/2014

GitBucket 2.0 released!

Today, we are pleased to announce the availability of  new version of Scala based Github clone GitBucket 2.0.


This is a first major version up includes modern Github UI and following new features:

Preview in AceEditor
You can preview Markdown in direct file editing in the repository viewer. And you can also confirm diff for files other than Markdown.

Select lines by clicking line number
GitBucket has been supported selecting lines by URL hash like #L10 or #L10-L12. In this version, it's possible by clicking in the source viewer.

This release contains some improvements and bug fix. See all closed issues in this release to know details. Upgrade your GitBucket and try new UI and these excellent features.

Enjoy!

4/29/2014

GitBucket 1.13 released!

Today, we are pleased to announce the availability of  new version of Scala based Github clone GitBucket 1.13.

I introduce new features in GitBucket 1.13 in this entry.

Online file editing
Online file editing using AceEditor is available. Commiters can create, edit and remove files in repository on the browser.

File attachment to issues
Now, we can attach image to issue and its comment. Drop image file into the area under textarea, or click this area and choose image file.

Atom feed of user activity
Atom feed is available in the dashboard and user activity page.


And also this release contains some improvements and many bug fix. See all closed issues in this release to know details. We highly recommend upgrading your GitBucket.

Enjoy!

3/29/2014

GitBucket 1.12 released!

Today, we are pleased to announce the availability of  new version of Scala based Github clone GitBucket 1.12.

This release contains some new features as below:

SSH repository access is available
SSH repository access can be enabled in system settings:
Users can register public keys in account settings:
And ssh repository url can be checked in the repository viewer:
Group management enhancement
All users can create new group. User can manage their groups and group repositories.
It's possible to configure permission in the group in group settings:
Git submodule support
Display the link to the repository for submodules.
In addition, in the previous version of GitBucket, downloading as the zip file had not been worked if the repository contains submodule. This issue is fixed in this release.
Close issues via commit messages
Issue can be closed by commit message like "Fix #123" or "Close #123".

Show repository description below the name on repository page
Fix presentation of the source viewer
before:
after:

And also this release contains some improvements and bug fix so we recommend upgrading your GitBucket.

Enjoy!

3/01/2014

GitBucket 1.11 released!

Today, we released a new version of Scala based Github clone GitBucket 1.11.

This release contains some new features as below:
  • Base URL for redirection, notification and repository URL box is configurable
  • Remove --https option because it's possible to substitute in the base url
  • Headline anchor is available for Markdown contents such as Wiki page
  • Label is available for pull requests not only issues
  • Delete branch button is added

  • Repository icons are updated
  • Select lines of source code by URL hash like #L10 or #L10-L15 in repository viewer
  • Display reference to issue from others in comment list
And also this release contains some improvements and bug fix so we recommend upgrading your GitBucket.

Enjoy!

2/01/2014

GitBucket 1.10 released!

Today, we released a new version of Scala based Github clone GitBucket 1.10.

This release contains some new features as below:
  • Rename repository
  • Transfer repository owner
  • Change default data directory to HOME/.gitbucket from HOME/gitbucket, but if data directory already exist at HOME/gitbucket, it continues being used.
  • Add LDAP display name attribute
  • Response performance improvement
Running GitBucket is very easy:
  1. Download gitbucket.war from here and hit java -jar gitbucket.war in console
  2. Access http://localhost:8080/ by your browser
And also some bugs are fixed in this release. Please upgrade your GitBucket, it's also very easy. You have to only replace gitbucket.war.

Enjoy!

9/08/2013

GitBucket 1.5 released!

We've released GitBucket 1.5 several days before.

GitBucket is a Github clone written with Scala. It's based on Scalatra, Slick and JGit.

This release contains many important new features such as:

  • Fork and pull request
  • LDAP authentication
  • Mail notification

See here to know how to setup GitBucket. It's very easy. Please try GitBucket and any feedback is welcome!

8/02/2013

Non-blocking API for Apache Solr

Today, we've released solr-scala-client 0.0.8!!

This release includes asynchronous and non-blocking API based on AsyncHttpClient and Scala 2.10's Future. See the following simple example:

val client = new AsyncSolrClient("http://localhost:8983/solr")

// Register
client
  .register(Map(
    "id"   -> "005", 
    "name" -> "ThinkPad X1 Carbon", 
    "manu" -> "Lenovo"))
  .onComplete{
    case Success(x) => println("registered!")
    case Failure(t) => t.printStackTrace()
  }

// Query
client.query("name:%name%")
  .fields("id", "manu", "name")
  .facetFields("manu")
  .sortBy("id", Order.asc)
  .getResultAsMap(Map("name" -> "ThinkPad X201s"))
  .onComplete {
    case Success(x) => println(x)
    case Failure(t) => t.printStackTrace()
  }

Methods of AsyncSolrClient return Future. You can process result by callback handler. See more example at here.

This release also contains some other new features such as recommendation search and automatic transaction management. Check the github site to know details of solr-scala-client!

7/04/2013

GitBucket 1.0 released!

Today, we released a first public version of GitBucket which is a Github clone by Scala, it very easy to setup.

The current version of GitBucket provides a basic features below:

  • Public / Private Git repository (http access only)
  • Repository viewer (some advanced features are not implemented)
  • Wiki
  • Issues
  • User management (for Administrators)

Following features are not implemented, but we will make them in the future release!

  • Fork and pull request
  • Activity timeline
  • Search
  • Notification
  • Network graph
  • Statics
  • Watch / Star
  • Team management (like Organization in Github)

You can setup GitBucket by only putting war into your servlet container such as Tomcat or Jetty. Please try it and feedback is welcome!

4/19/2013

eclipse-scala-tools 0.0.4 released!

eclipse-scala-tools is an Eclipse plug-in for sbt.

This is a list of new features and changes in this version:

  • Use system proxy setting
  • SBT 0.12 Support (SBT 0.7 and 0.10 are removed)
  • Use sbteclipse to generate Eclipse project configuration files
  • Outline view

And I have a plan about new features in the future release:

  • Scala IDE 3.x and sbt 0.13 support
  • Select some major libraries at the project creation wizard
  • Multi project support
  • Wizard to import existing sbt project from out of workspace

I hope this plug-in helps you. Enjoy!

4/04/2013

solr-scala-client 0.0.7 is now available!

solr-scala-client is a simple Apache Solr client for Scala based on SolrJ.

The list of new features in 0.0.7:

  • Add build for Scala 2.10
  • Upgrade to SolrJ 4.2.0
  • Support search result highlighting

In this entry, I introduce search result highlighting which is a new feature in this release.

How to Highlight?

You can configure the query to return the highlighted content using QueryBuilder#highlight(). The highlighted field is required, but prefix and suffix is not required. They are optional(default is <em>...</em>).

The highlighted content is set as the "highlight" property to the Map or the case class.

val result = client.query("content: Scala")
  // NOTE: unique key field is required.
  .fields("id")
  // Specify the highlighted field, prefix and postfix (prefix and postfix is optional).
  .highlight("content", "", "")
  .getResultAsMap()

result.documents.foreach { doc: Product =>
  println("id: " + doc("id"))
  println(doc("highlight")) // highlighted content is set as the "highlight" property
}

In SolrJ, we have to map retrieved documents and highlighted contents using the unique key of the index schema. solr-scala-client expects that the unique key is "id".

If your schema has the different field as the unique key, you can specify the unique key name as following:

val result = client.query("content: Scala")
  .id("documentId") // Specify the unique key name
  .fields("documentId")
  .highlight("content", "", "")
  .getResultAsMap()

2/25/2013

Accelerate Play2 development mode

Play2 development mode is very heavy because it checks file modification and reload classes for each requests. And it seems to process requests in serial. So loading web pages which contain many resources such as external CSS, JavaScript files or images is stressful.

play2-fastassets accelerates Play2 development mode by leveraging browser cache.

Replace the routing to controllers.Assets.at by jp.sf.amateras.play2.fastassets.FastAssets.get in conf/routes. This method returns a response which has a header: Cache-Control: private, max-age=3600.

#GET /assets/*file controllers.Assets.at(path="/public", file)
GET /assets/*file jp.sf.amateras.play2.fastassets.FastAssets.get(file)

And add following configurations into conf/application.conf.

fastassets.urlPath=/assets
fastassets.realPath=/public

Use FastAssets.at instead of routes.Assets.at in HTML templates.

@(title: String)(content: Html)
@import jp.sf.amateras.play2.fastassets.FastAssets
<!DOCTYPE html>
<html>
  <head>
    <title>@title</title>
    <link rel="stylesheet" media="screen" href="@FastAssets.at("stylesheets/main.css")">
    <link rel="shortcut icon" type="image/png" href="@FastAssets.at("images/favicon.png")">
    <script src="@FastAssets.at("javascripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
  </head>
  <body>
    @content
  </body>
</html>

FastAssets.at appends a last modified timestamp to the filename and your browser cache it. When you update the file, this timestamp is also updated. So the browser retrieves a new file from the server instead of the cached contents.

8/25/2012

Jerkson in Play2 development mode

Play2 includes Jerkson which is a Scala wrapper for the Java based JSON library Jackson.

It's very useful and I'm loving it. However when we use it in the Play2 application, it fails to deserialize case classes after reloading in development mode. See the following code:

import com.codahale.jerkson.Json

val json = Json.generate(UserInfo("Naoki Takezoe"))
val info = Json.parse[UserInfo](json)

After reloading in the development mode, this code throws an exception such as ParsingException: Unable to find a case accessor for models.UserInfo.

The reason of this problem is Jerkson hold a class loader in the singleton object.

So this problem could be solved to create new instance which is mixed-in com.codahale.jerkson.Json trait for each Json serialization / deserialization as following:

// This code works in the development mode!
import com.codahale.jerkson.Json

val json = new Json{}.generate(UserInfo("Naoki Takezoe"))
val info = new Json{}.parse[UserInfo](json)

Some of hotswap solutions (reloading recompiled classes) on JVM have similar problem because they are based on classloader swapping. They can make rapid development on JVM and very helpful for our work. However sometimes they trouble us like this.

6/24/2012

Scalagen - A Source Code Generator for ORMs

Scalagen is a source code generator for ORMs. In the current version of Scalagen supports ScalaQuery and Anorm.

It's possible to use as a sbt plug-in. I show how to use Scalagen as a sbt plug-in for ScalaQuery. Scalagen generates table definition objects and case classes which correnspond to them.

In project/plugins.sbt, add:

resolvers += ("amateras snapshot" at "http://amateras.sourceforge.jp/mvn-snapshot/")

addSbtPlugin("jp.sf.amateras.scalagen" % "scalagen-sbtplugin" % "0.1-SNAPSHOT")

libraryDependencies ++= Seq(
  // for ScalaQuery
  "jp.sf.amateras.scalagen" %% "scalagen-scalaquery" % "0.1-SNAPSHOT",
  // for Anorm
  //"jp.sf.amateras.scalagen" %% "scalagen-anorm" % "0.1-SNAPSHOT",
  // JDBC driver for your database
  "org.hsqldb" % "hsqldb" % "2.2.8"
)

In build.sbt, add:

seq(jp.sf.amateras.scalagen.ScalagenPlugin.scalagenSettings: _*)

scalagenConfiguration := jp.sf.amateras.scalagen.Settings(
  // for ScalaQuery
  generator = new jp.sf.amateras.scalagen.ScalaQueryGenerator(),
  // for Anorm
  //generator = new jp.sf.amateras.scalagen.ScalaQueryGenerator(),
  driver = "org.hsqldb.jdbcDriver",
  url = "jdbc:hsqldb:hsql://localhost/",
  username = "sa",
  password = "",
  catalog = null,
  schemaPattern = null,
  tablePattern = null
)

Execute sbt scalagen, source files are generated into src/main/scala/models.

See more details about Scalagen at the following URL:
https://github.com/takezoe/scalagen

5/27/2012

solr-scala-client 0.0.2 is now available!

solr-scala-client is a Apache Solr client for Scala wrapping SolrJ.

The list of new features in 0.0.2:

  • Added initializer which configures SolrClient.
  • Added basic authentication support as initializer.
  • Added facet search support.
  • Added case class support as query results and query parameters.

The query result became to be returned as MapQueryResult or CaseClassQueryResult instead of List[Map[String, Any]]. This object contains both of documents and facet counts.

val result = client.query("name:%name%")
      .fields("id", "manu", "name")
      .facetFields("manu")
      .sortBy("id", Order.asc)
      .getResultAsMap(Map("name" -> "ThinkPad X201s"))

// retreive documents
result.documents.foreach { doc =>
  println("id: " + doc("id"))
  println("  manu: " + doc("manu"))
  println("  name: " + doc("name"))
}

// retreive facet counts
result.facetFields.foreach { case (field, counts) =>
  println("field: " + field)
  counts.foreach { case (manu, count) =>
    println("  " + manu + ": " + count)
  }
}

It's possible to use the case class as the query result and the query parameter instead of Map[String, Any]. Note: update operations don't support the case class in 0.0.2. It will be supported in the next version.

// the case class for the document
case class Product(id: String, manu: Option[String], name: String)
// the case class for the parameter
case class Param(name: String)

// query using case classes
val result = client.query("name:%name%")
      .fields("id", "manu", "name")
      .facetFields("manu")
      .sortBy("id", Order.asc)
      .getResultAs[Product](Param("ThinkPad"))

result.documents.foreach { product =>
  println(product)
}

As small improvement of SolrClient, it became to accept the initializer function. This function takes CommonsHttpSolrServer and can do any processing for it.

val client = new SolrClient("http://localhost:8983/solr", {
  server: CommonsHttpSolrServer => // initialize...
})

0.0.2 contains the BASIC authentication support as the initializer. see the following example.

val client = new SolrClient("http://localhost:8983/solr", 
  Auth.basic("username", "password"))

I think solr-scala-client does not have enough features to use in production yet. Therefore I will improve it through use in my project.

4/29/2012

The simple Apache Solr client for Scala

I pushed solr-scala-client into github. This is a simple Apache Solr client for Scala wrapping SolrJ.

The basic concept of solr-scala-client is providing fluent interface and wrapping SolrJ classes by Scala collection API. This is an example to register documents into the Solr server which is working at localhost:8983.

import jp.sf.amateras.solr.scala._

val client = new SolrClient("http://localhost:8983/solr")

client
  .add(Map("id"->"1", "name" -> "ThinkPad X201s"))
  .add(Map("id"->"2", "name" -> "ThinkPad X220"))
  .add(Map("id"->"3", "name" -> "ThinkPad X121e"))
  .commit

add() takes a variable-length argument. So an example above could be rewritten as follows:

client.add(
  Map("id"->"1", "name" -> "ThinkPad X201s"),
  Map("id"->"2", "name" -> "ThinkPad X220"),
  Map("id"->"3", "name" -> "ThinkPad X121e")
).commit

Next, see the following example to search document using the query.

// query
val result: List[Map[String, Any]] =
  client.query("name:%name%")
    .fields("id", "manu", "name")
    .sortBy("id", Order.asc)
    .getResult(Map("name" -> "ThinkPad"))

result.foreach { doc =>
  println("id: " + doc("id"))
  println("name: " + doc("name"))
  println("--")
}

%VARNAME% in the query is replaced by given parameters as Map and the result is returned as List[Map[String, Any]].

The current version of solr-scala-client does not support facet search yet. I wish to support it in the near future. And I'm also planning about using case class to specify document or parameters instead of Map.

4/15/2012

mirage 1.1.5 and mirage-scala 0.0.4 is now available!

Today, we released Mirage 1.1.5 and mirage-scala 0.0.4!

Mirage is a simple SQL centric database access library and mirage-scala is the wrapper of Mirage for Scala. See the following URL to know about Mirage:

This release contains some important new features for mirage-scala. Mirage update is only small bug fix. So I introduce new features of mirage-scala 0.0.4 in this entry.

Improvement of SqlManager interface

Some methods of SqlManager had a java.lang.Class parameter which specifies the entity class in the previous version. But in mirage-scala 0.0.4, it modified to the generics type parameter.

// Until mirage-scala 0.0.3
val books = sqlManager.getResultList(
  classOf[Book], 
  Sql("SELECT * FROM BOOK"))

// In mirage-scala 0.0.4
val books = sqlManager.getResultList[Book](
  Sql("SELECT * FROM BOOK"))

Improvement of case class entity

mirage-scala can handle case class as the entity. But it required the default constructor as below:

@Table(name="BOOK")
case class Book(
  @(PrimaryKey @field)(generationType = IDENTITY)
  bookId: java.lang.Long,
  bookName: String,
  author: String,
  price: Option[Int]) {

  // This is not required in mirage-scala 0.0.4
  def this() = this(null, null, null, None)

}

The default constructor of case class is not required no longer in mirage-scala 0.0.4.

Wrapping primary key by Pk[T]

In mirage-scala 0.0.4, Pk[T], Id[T] and Auto are added. You can use Pk[T] to wrap the property which corresponds to the primary key. It is useful when the primary key is set by the database. For example, it's auto incremented column.

@Table(name="BOOK")
case class Book(
  @(PrimaryKey @field)(generationType = IDENTITY)
  bookId: Pk[Long],
  bookName: String,
  author: String,
  price: Option[Int])

val book = Book(
  Auto, 
  "Mirage in Action",
  "Naki Takezoe",
  25)

sqlManager.insertEntity(book)

If you have to set the value of the primary key, you can use Id[T] instead of Auto.

@Table(name="BOOK")
case class Book(
  @(PrimaryKey @field)(generationType = APPLICATION)
  bookId: Pk[Long],
  bookName: String,
  author: String,
  price: Option[Int])

val book = Book(
  Id(1), 
  "Mirage in Action",
  "Naki Takezoe",
  25)

sqlManager.insertEntity(book)

Anyway, mirage-scala became more scalanized database access library in 0.0.4. I hope mirage-scala will help your development with Scala!

4/08/2012

Simple wrapper of PicoContainer for Scala

I tried SubCut to resolve dependency of components in Scala. However I think The Cake Pattern might be better than SubCut because it's so complex more than necessary and not transparent.It's similar to the service locator, not the DI container. I need a DI container which is more simple and intuitive. It's sufficient that supports constructor injection.

There are PicoContainer in Java World. So I wrote a simple wrapper of PicoContainer for Scala:

It does not cover all features of PicoContainer. But it might be enough for my current use :-)

2/12/2012

Getting Started with mirage-scala

mirage-scala is the simple and powerful library to access RDBMS from Scala. I introduce how to use mirage-scala with sbt.

At first, add the following dependency into your build.sbt:

And create the jdbc.properties and put it on the root of classpath.

Next, you have to create the entity class. mirage-scala supports both of mutable and immutable style as entity class. This is the example of immutable style entity class:

Ready for mirage-scala. Let's try to use it!

You can insert, update and delete a record using SqlManager and entity classes. And also you can select a record by the primary key.

When you must select records by the more complex query, you can do it using 2way-SQL which is the powerful feature of mirage-scala. I would like to write about it in the next entiry.

mirage-scala 0.0.3 is now available!

mirage-scala is the wrapper of Mirage for Scala. It provides the best solution to access RDBMS from Scala.

New features in mirage-scala 0.0.3:

  • Case class (immutable model) is available as entity.
  • Option[T] is available as property type.

By these new features, mirage-scala became the more suitable library for Scala to access RDBMS.

mirage-scala is still under preview release. So any request or feedback welcome!