no.arktekk.atom.extension.thr.AtomLinkThreadingExtension.scala Maven / Gradle / Ivy
/*
* Copyright 2012 Arktekk AS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package no.arktekk.atom.extension.thr
import org.joda.time.DateTime
import no.arktekk.atom.extension.AtomExtension
import no.arktekk.atom._
import com.codecommit.antixml.QName
/**
* @author Erlend Hamnaberg
*/
object AtomLinkThreadingExtension extends AtomExtension[Link, AtomThreading] {
val count = QName(Some(ThreadingConstants.prefix), "count")
val updated = QName(Some(ThreadingConstants.prefix), "updated")
def fromLike(like: Link) = {
val c = like.attr(count).map(_.toInt)
val u = like.attr(updated).map(parseDateTime(_))
AtomThreading(c, u)
}
override def toAttributes(a: AtomThreading) = {
a.count.map(x => count -> x.toString).toSeq ++
a.updated.map(x => updated -> dateTimeToString(x)).toSeq
}
def toChildren(a: AtomThreading) = IndexedSeq.empty
}
case class AtomThreading(count: Option[Int] = None, updated: Option[DateTime] = None)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy