Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix deprecation for 2.9 compliance

  • Loading branch information...
commit 587dd29b77bba062975c21923c7fc6ecf8b84b6c 1 parent 7c7e704
@indrajitr indrajitr authored
View
4 persistence/mapper/src/main/scala/net/liftweb/mapper/ManyToMany.scala
@@ -138,14 +138,14 @@ trait ManyToMany extends BaseKeyedMapper {
protected def childAt(n: Int) = children(n)
def apply(n: Int) = childAt(n)
def indexOf(e: T2) =
- children.findIndexOf(e eq)
+ children.indexWhere(e eq)
// 2.7
// def insertAll(n: Int, iter: Iterable[T2]) {
// 2.8
def insertAll(n: Int, traversable: Traversable[T2]) {
val ownedJoins = traversable map own
- val n2 = joins.findIndexOf(isJoinForChild(children(n)))
+ val n2 = joins.indexWhere(isJoinForChild(children(n)))
val before = joins.take(n2)
val after = joins.drop(n2)
View
4 persistence/mapper/src/main/scala/net/liftweb/mapper/MappedInt.scala
@@ -33,7 +33,7 @@ import js._
abstract class MappedEnum[T<:Mapper[T], ENUM <: Enumeration](val fieldOwner: T, val enum: ENUM) extends MappedField[ENUM#Value, T] {
private var data: ENUM#Value = defaultValue
private var orgData: ENUM#Value = defaultValue
- def defaultValue: ENUM#Value = enum.iterator.next
+ def defaultValue: ENUM#Value = enum.values.iterator.next
def dbFieldClass = classOf[ENUM#Value]
/**
@@ -132,7 +132,7 @@ abstract class MappedEnum[T<:Mapper[T], ENUM <: Enumeration](val fieldOwner: T,
* Build a list for the select. Return a tuple of (String, String) where the first string
* is the id.string of the Value and the second string is the Text name of the Value.
*/
- def buildDisplayList: List[(Int, String)] = enum.map(a => (a.id, a.toString)).toList
+ def buildDisplayList: List[(Int, String)] = enum.values.map(a => (a.id, a.toString)).toList
/**
* Create an input field for the item
View
10 persistence/mapper/src/main/scala/net/liftweb/mapper/MappedLong.scala
@@ -58,7 +58,7 @@ extends MappedLong[T](theOwner) with MappedForeignKey[Long,T,O] with BaseForeign
def asSafeJs(obs: Box[KeyObfuscator]): JsExp =
obs.map(o => JE.Str(o.obscure(dbKeyToTable, is))).openOr(JE.Num(is))
- override def asJsonValue: Box[JsonAST.JValue] =
+ override def asJsonValue: Box[JsonAST.JValue] =
if (defined_?) super.asJsonValue else Full(JsonAST.JNull)
override def setFromAny(in: Any): Long =
@@ -81,7 +81,7 @@ extends MappedLong[T](theOwner) with MappedForeignKey[Long,T,O] with BaseForeign
primeObj(v)
fieldOwner
}
-
+
def apply(v: O): T = {
apply(v.primaryKeyField.is)
primeObj(Full(v))
@@ -187,7 +187,7 @@ abstract class MappedEnumList[T<:Mapper[T], ENUM <: Enumeration](val fieldOwner:
private def toLong: Long = is.foldLeft(0L)((a,b) => a + rot(b.id))
def fromLong(in: Long): Seq[ENUM#Value] =
- enum.iterator.toList.filter(v => (in & rot(v.id)) != 0)
+ enum.values.iterator.toList.filter(v => (in & rot(v.id)) != 0)
def jdbcFriendly(field: String) = new java.lang.Long(toLong)
override def jdbcFriendly = new java.lang.Long(toLong)
@@ -241,7 +241,7 @@ abstract class MappedEnumList[T<:Mapper[T], ENUM <: Enumeration](val fieldOwner:
* Create an input field for the item
*/
override def _toForm: Box[NodeSeq] =
- Full(SHtml.checkbox[ENUM#Value](enum.iterator.toList, is,this(_)).toForm)
+ Full(SHtml.checkbox[ENUM#Value](enum.values.iterator.toList, is,this(_)).toForm)
}
/**
@@ -283,7 +283,7 @@ abstract class MappedNullableLong[T<:Mapper[T]](val fieldOwner: T) extends Mappe
def asJsExp: JsExp = is.map(v => JE.Num(v)) openOr JE.JsNull
- def asJsonValue: Box[JsonAST.JValue] =
+ def asJsonValue: Box[JsonAST.JValue] =
Full(is.map(v => JsonAST.JInt(v)) openOr JsonAST.JNull)
override def readPermission_? = true
View
2  persistence/mapper/src/main/scala/net/liftweb/mapper/OneToMany.scala
@@ -156,7 +156,7 @@ trait OneToMany[K,T<:KeyedMapper[K, T]] extends KeyedMapper[K,T] { this: T =>
}
override def indexOf[B >: O](e: B): Int =
- delegate.findIndexOf(e.asInstanceOf[AnyRef].eq)
+ delegate.indexWhere(e.asInstanceOf[AnyRef].eq)
// 2.7
// def insertAll(n: Int, iter: Iterable[O]) {
View
22 persistence/mapper/src/main/scala/net/liftweb/mapper/view/Paginator.scala
@@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.liftweb
-package mapper
-package view
+package net.liftweb
+package mapper
+package view
import scala.xml.{NodeSeq, Text, Elem}
import net.liftweb.common.Loggable
@@ -25,12 +25,12 @@ import net.liftweb.http.S.?
import net.liftweb.util.Helpers._
import net.liftweb.mapper.{Mapper, MetaMapper, MappedField,
QueryParam, OrderBy, StartAt, MaxRows, Ascending, Descending}
-
+
/**
* Helper for when using paginators with a ModelSnippet.
* Adds a dispatch that delegates the "paginate" snippet to the paginator member.
* @author nafg and Timothy Perrett
- */
+ */
trait PaginatedModelSnippet[T <: Mapper[T]] extends ModelSnippet[T] {
abstract override def dispatch: DispatchIt = super.dispatch orElse Map("paginate" -> paginator.paginate _ )
/**
@@ -39,8 +39,8 @@ trait PaginatedModelSnippet[T <: Mapper[T]] extends ModelSnippet[T] {
val paginator: PaginatorSnippet[T]
}
-/**
- * Paginate mapper instances by supplying the model you
+/**
+ * Paginate mapper instances by supplying the model you
* wish to paginate and Paginator will run your query for you etc.
*
* @param meta The singleton of the Mapper class you're paginating
@@ -51,7 +51,7 @@ class MapperPaginator[T <: Mapper[T]](val meta: MetaMapper[T]) extends Paginator
* QueryParams to use always
*/
var constantParams: Seq[QueryParam[T]] = Nil
-
+
def count = meta.count(constantParams: _*)
def page = meta.findAll(constantParams ++ Seq[QueryParam[T]](MaxRows(itemsPerPage), StartAt(first)): _*)
}
@@ -73,10 +73,10 @@ class SortedMapperPaginator[T <: Mapper[T]](meta: MetaMapper[T],
initialSort: net.liftweb.mapper.MappedField[_, T],
_headers: (String, MappedField[_, T])*)
extends MapperPaginator[T](meta) with SortedPaginator[T, MappedField[_, T]] {
-
+
val headers = _headers.toList
- sort = (headers.findIndexOf{case (_,`initialSort`)=>true; case _ => false}, true)
-
+ sort = (headers.indexWhere{case (_,`initialSort`)=>true; case _ => false}, true)
+
override def page = meta.findAll(constantParams ++ Seq[QueryParam[T]](mapperSort, MaxRows(itemsPerPage), StartAt(first)): _*)
private def mapperSort = sort match {
case (fieldIndex, ascending) =>
View
32 persistence/mapper/src/main/scala/net/liftweb/mapper/view/TableEditor.scala
@@ -72,15 +72,15 @@ trait ItemsList[T <: Mapper[T]] {
* The sort direction
*/
var ascending = true
-
+
/**
* Returns the items (current + added - removed), sorted.
* Sorting sorts strings case-insensitive, as well as Ordered and java.lang.Comparable.
* Anything else where both values are nonnull are sorted via their toString method (case sensitive)
*/
def items: Seq[T] = {
- import scala.util.Sorting._
- val unsorted: List[T] = current -- removed ++ added
+ import scala.util.Sorting._
+ val unsorted: List[T] = current.filterNot(removed.contains) ++ added
sortField match {
case None =>
unsorted
@@ -138,17 +138,17 @@ trait ItemsList[T <: Mapper[T]] {
def save {
val (successAdd, failAdd) = added.partition(_.save)
added = failAdd
-
+
val (successRemove, failRemove) = removed.partition(_.delete_!)
- current --= successRemove
+ current = current.filterNot(successRemove.contains)
removed = failRemove
-
+
for(c <- current if c.validate.isEmpty) c.save
-
+
current ++= successAdd
}
-
-
+
+
def sortBy(field: MappedField[_, T]) = (sortField, ascending) match {
case (Some(f), true) if f eq field =>
ascending = false
@@ -165,7 +165,7 @@ trait ItemsList[T <: Mapper[T]] {
ascending = true
}
}
-
+
reload
}
@@ -180,7 +180,7 @@ trait ItemsList[T <: Mapper[T]] {
*/
object TableEditor {
net.liftweb.http.LiftRules.addToPackages("net.liftweb.mapper.view")
-
+
private[view] val map = new scala.collection.mutable.HashMap[String, TableEditorImpl[_]]
def registerTable[T<:Mapper[T]](name: String, meta: T with MetaMapper[T], title: String) =
map(name) = new TableEditorImpl(title, meta)
@@ -229,7 +229,7 @@ protected class TableEditorImpl[T <: Mapper[T]](val title: String, meta: T with
trait ItemsListEditor[T<:Mapper[T]] {
def items: ItemsList[T]
def title: String
-
+
def onInsert: Unit = items.add
def onRemove(item: T): Unit = items.remove(item)
def onSubmit: Unit = try {
@@ -239,11 +239,11 @@ trait ItemsListEditor[T<:Mapper[T]] {
S.error("Not all items could be saved!")
}
def sortFn(f: MappedField[_, T]): ()=>Unit = items.sortFn(f)
-
+
val fieldFilter: MappedField[_,T]=>Boolean = (f: MappedField[_,T])=>true
-
+
def customBind(item: T): NodeSeq=>NodeSeq = (ns: NodeSeq) => ns
-
+
def edit(xhtml: NodeSeq): NodeSeq = {
def unsavedScript = (<head><script type="text/javascript">
var safeToContinue = false
@@ -307,5 +307,5 @@ trait ItemsListEditor[T<:Mapper[T]] {
"saveBtn" -> SHtml.submit(?("Save"), onSubmit _, noPrompt)
)
}
-
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.