OSDN Git Service

Many many refactoring.
authoruyaji <yuichiro.uyama@gmail.com>
Fri, 27 Sep 2013 09:18:14 +0000 (18:18 +0900)
committeruyaji <yuichiro.uyama@gmail.com>
Fri, 27 Sep 2013 09:18:14 +0000 (18:18 +0900)
PartsList/PartsList/app/controllers/NotifyController.scala
PartsList/PartsList/app/controllers/PartsListController.scala
PartsList/PartsList/app/controllers/services/Check.scala
PartsList/PartsList/app/controllers/services/PartRecursion.scala
PartsList/PartsList/app/controllers/services/ReplyRecursion.scala
PartsList/PartsList/app/views/notifylist.scala.html

index 87a6a99..2b50406 100644 (file)
@@ -88,7 +88,7 @@ object NotifyController extends Controller{
     }
   }
 
-  def updateState(id: Long, partId: Long, designChangeId: Long, notifyType: Long, state: Long) = Action {
+  def updateState(id: Long, partId: Long, designChangeId: Long, notifyType: Long, state: Long) = Action { implicit request =>
     inTransaction {
       val notify = NotifyManager().getById(id)
       notify.state = 1
@@ -126,7 +126,10 @@ object NotifyController extends Controller{
          var i:Int =0
          notifyBuffer += NotifyBean(i, notify.message, notify.user.head.name, notify.id, Messages("notify.state" + notify.state), notify.atachs)
          for(reply <- notify.replies) {
-           ReplyRecursion().down(reply, notifyBuffer, i)
+//         ReplyRecursion().down(reply, notifyBuffer, i)
+           for(returnNotifyBuffer <- ReplyRecursion().down(reply, i)) {
+             notifyBuffer += returnNotifyBuffer
+           }
          }
        }
       Ok(views.html.notifylist(notifyBuffer.drop(page*row).take(row), notifyBuffer.size, partId, 0, notifyPart.name, page, notifyType, state))
@@ -148,10 +151,13 @@ object NotifyController extends Controller{
         var i:Int =0
         notifyBuffer += NotifyBean(i, notify.message, notify.user.assign(notify.user.head).name, notify.id, Messages("notify.state" + notify.state), notify.atachs)
         for(reply <- notify.replies) {
-          ReplyRecursion().down(reply, notifyBuffer, i)
+         for(returnNotifyBuffer <- ReplyRecursion().down(reply, i)) {
+            notifyBuffer += returnNotifyBuffer 
+          }
         }
       }
       Ok(views.html.notifylist(notifyBuffer.drop(page*row).take(row), notifyBuffer.size, 0, designChange.id, designChange.dcNo, page, notifyType, state))
     }
   }
+  
 }
\ No newline at end of file
index 8a72d7b..58b0804 100644 (file)
@@ -7,6 +7,7 @@ import play.api.mvc._
 import play.api.i18n._
 import org.squeryl._
 import org.squeryl.PrimitiveTypeMode._
+import models._
 import models.services._
 import beans._
 import forms._
@@ -30,7 +31,9 @@ object PartsListController extends Controller{
                var partBuffer = ArrayBuffer[PartsListBean]()
            inTransaction {
                  for (parentPart <- PartManager().getByLikeName(key)) {
-                   PartRecursion().down(parentPart, partBuffer, opt)
+                   for(returnPartBuffer <- PartRecursion().down(parentPart, opt)) {
+                     partBuffer += returnPartBuffer
+                   }
                  }
            }
          val row = Integer.decode(Messages("list.row"))
@@ -107,5 +110,5 @@ object PartsListController extends Controller{
                  PartsListBean(parentNo, childNo, PartManager().getByName(parentNo).partRelation(PartManager().getByName(childNo).id).quantity)
          }
        }
-
+       
 }
\ No newline at end of file
index 283a2a2..588e10c 100644 (file)
@@ -20,7 +20,10 @@ case class Check() {
     var message:String = null
     var partBuffer = ArrayBuffer[PartsListBean]()
     for (parentPart <- PartsListDb.parts.where(p => p.name === child )) {
-      PartRecursion().down(parentPart, partBuffer, 1)
+//      PartRecursion().down(parentPart, partBuffer, 1)
+      for(returnPartBuffer <- PartRecursion().down(parentPart, 1)) {
+        partBuffer += returnPartBuffer
+      }
      }
      // 親品番逆展開配列
     var upPartBuffer = ArrayBuffer[PartsListBean]()
index 322769b..7fceea5 100644 (file)
@@ -2,9 +2,9 @@ package controllers.services
 import models._
 import beans._
 import scala.collection.mutable.ArrayBuffer
-case class PartRecursion() {
+case class PartRecursion(){
   
-  def down(parentPart: Part, partBuffer: ArrayBuffer[PartsListBean], opt: Int):Unit = {
+/*  def down(parentPart: Part, partBuffer: ArrayBuffer[PartsListBean], opt: Int):Unit = {
     for(child <-parentPart.parts) {
       if(parentPart.partRelation(child.id).delDcId==0) {
         if(opt!=3 || opt==3 && child.name.startsWith("Unit")) {
@@ -15,8 +15,26 @@ case class PartRecursion() {
            }
           }
     }
-  }
+  }*/
   
+  def down(parentPart: Part, opt: Int):ArrayBuffer[PartsListBean] = {
+    val partBuffer = ArrayBuffer[PartsListBean]()
+    for(child <-parentPart.parts) {
+      if(parentPart.partRelation(child.id).delDcId==0) {
+        if(opt!=3 || opt==3 && child.name.startsWith("Unit")) {
+               partBuffer += PartsListBean(parentPart.name, child.name, parentPart.partRelation(child.id).quantity)
+            }
+           if(opt==1 || opt==2 && !child.name.startsWith("Part") || opt==3) {
+             val partBuffers = PartRecursion().down(child, opt)
+             for (returnPartBuffer <- partBuffers) {
+               partBuffer += returnPartBuffer 
+             }
+           }
+          }
+    }
+    return partBuffer
+  }
+
   def up(childPart: Part, partBuffer: ArrayBuffer[PartsListBean], opt: Int):Unit = {
     if(childPart.parentParts.size == 0 && opt == 2) {
           partBuffer += PartsListBean("", childPart.name,0)
index 8393797..2babca1 100644 (file)
@@ -4,20 +4,31 @@ import beans._
 import play.api.i18n._
 import scala.collection.mutable.ArrayBuffer
 
-case class ReplyRecursion() {
-  def down(reply: Reply, notifyBuffer: ArrayBuffer[NotifyBean], i: Int):Unit ={
+case class ReplyRecursion(){
+/*  def down(reply: Reply, notifyBuffer: ArrayBuffer[NotifyBean], i: Int):Unit ={
     var level = i+1
     notifyBuffer += NotifyBean(level, reply.message, reply.user.assign(reply.user.head).name, reply.id, Messages("notify.state9"), reply.atachs)
     for( childReply <- reply.childReplies) {
       ReplyRecursion().down(childReply, notifyBuffer, level)
     }
+  }*/
+
+  def down(reply: Reply, i: Int): ArrayBuffer[NotifyBean]  ={
+    val notifyBuffer = ArrayBuffer[NotifyBean]()
+    var level = i+1
+    notifyBuffer += NotifyBean(level, reply.message, reply.user.assign(reply.user.head).name, reply.id, Messages("notify.state9"), reply.atachs)
+    for( childReply <- reply.childReplies) {
+      for(returnNotifyBuffer <- ReplyRecursion().down(childReply, level)) {
+        notifyBuffer += returnNotifyBuffer 
+      }
+    }
+    return notifyBuffer
   }
 
   def up(reply: Reply):Reply = {
     if(reply.parentReply.size == 0) {
       return reply
     } else {
-      println("Messages " + reply.message)
       ReplyRecursion().up(reply.parentReply.head)
     }
 
index 2659ab4..7d41fa4 100644 (file)
@@ -79,6 +79,6 @@
        @if(partId != 0) {
                <a href="/partModify?id=@partId">@Messages("list.link6")</a>
        } else {
-               <a href="/designChangeCoverModify?id=@designChangeId">@Messages("title22")</a>
+               <a href="/designChangeCoverModify?designChangeId=@designChangeId&dcSeq=0&message=">@Messages("title22")</a>
        }
 }