Advertisement
Guest User

Untitled

a guest
Nov 14th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.34 KB | None | 0 0
  1. private def equalsArrayDataLink(a1: FArrayDataLink, a2: FArrayDataLink): Boolean = {
  2.     if (a1.uuids.size != a2.uuids.size) {
  3.       false
  4.     } else {
  5.       var equals = true
  6.       a2.uuids.foreach(id =>
  7.         if (!a1.uuids.toSet.contains(id)) {
  8.           equals = false
  9.         }
  10.       )
  11.       equals
  12.     }
  13.   }
  14.  
  15.   private def columnValues(column: Column, entities: Iterable[Entity]): Map[Type, Iterable[UUID]] = {
  16.     val result = scala.collection.mutable.Map[Type, ListBuffer[UUID]]()
  17.     val links = scala.collection.mutable.Map[String, Type]()
  18.     entities.foreach{
  19.       case (entity) =>
  20.         val value = entity.properties.find(_._1 == column).orNull
  21.         if (value != null) {
  22.           var key = value._2
  23.  
  24.           value._2 match {
  25.             case links: FArrayDataLink =>
  26.               val link = result.keys.filter(_.isInstanceOf[FArrayDataLink]).find(v => equalsArrayDataLink(v.asInstanceOf[FArrayDataLink], links)).orNull
  27.               if (link == null) {
  28.                 result.put(key, new ListBuffer[UUID]())
  29.               } else {
  30.                 key = link
  31.               }
  32.             case _ =>
  33.               if (!result.keys.exists(_ == key)) {
  34.                 result.put(key, new ListBuffer[UUID]())
  35.               }
  36.           }
  37.  
  38.           result(key) += entity.key
  39.         }
  40.     }
  41.     result.toMap
  42.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement