OSDN Git Service

Refactoring
authoruyaji <yuichiro.uyama@gmail.com>
Mon, 30 Sep 2013 03:03:06 +0000 (12:03 +0900)
committeruyaji <yuichiro.uyama@gmail.com>
Mon, 30 Sep 2013 03:03:06 +0000 (12:03 +0900)
PartsList/PartsList/app/controllers/DesignChangeController.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

index ae7b21e..da5ba94 100644 (file)
@@ -66,7 +66,9 @@ object DesignChangeController extends Controller{
       val designChangeBuffer = DesignChangeManager().getDesinChangeInformation(designChange)
       if(dcSeq != 0) {
         val delRelation = designChange.delPartRelation.where(pr => pr.dcSeq === dcSeq).head
-        PartRecursion().up(delRelation.child.head, partBuffer, 1)
+        for(returnPartBuffer <- PartRecursion().up(delRelation.child.head, 1)) {
+          partBuffer += returnPartBuffer
+        }
       }
       Ok(views.html.updateDesignChangeForm(designChangeRegistForm.fill(designChangeForm), designChangeId, designChangeBuffer, designChange.addPartRelation, partBuffer, dcSeq, message))
     }
index 58b0804..171067c 100644 (file)
@@ -44,7 +44,9 @@ object PartsListController extends Controller{
          var partBuffer = ArrayBuffer[PartsListBean]()
          inTransaction {
                  for (childPart <- PartManager().getByLikeName(key)) {
-                   PartRecursion().up(childPart, partBuffer, opt)
+                   for(returnPartBuffer <- PartRecursion().up(childPart, opt)) {
+                     partBuffer += returnPartBuffer
+                   }
                  }
           }
           val row = Integer.decode(Messages("list.row"))
index 8eb33ce..eed8523 100644 (file)
@@ -22,7 +22,6 @@ 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)
       for(returnPartBuffer <- PartRecursion().down(parentPart, 1)) {
         partBuffer += returnPartBuffer
       }
@@ -30,7 +29,9 @@ case class Check() {
      // 親品番逆展開配列
     var upPartBuffer = ArrayBuffer[PartsListBean]()
     for (childPart <- PartsListDb.parts.where(p => p.name === parent)) {
-      PartRecursion().up(childPart, upPartBuffer, 0)
+      for(returnPartBuffer <- PartRecursion().up(childPart, 0)) {
+        upPartBuffer += returnPartBuffer
+      }
     }
        // 部品表ループチェック
        // 親品番=子品番 の場合エラー
index 7fceea5..4503a0c 100644 (file)
@@ -3,20 +3,7 @@ import models._
 import beans._
 import scala.collection.mutable.ArrayBuffer
 case class PartRecursion(){
-  
-/*  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")) {
-               partBuffer += PartsListBean(parentPart.name, child.name, parentPart.partRelation(child.id).quantity)
-            }
-           if(opt==1 || opt==2 && !child.name.startsWith("Part") || opt==3) {
-             PartRecursion().down(child, partBuffer, opt)
-           }
-          }
-    }
-  }*/
-  
+   
   def down(parentPart: Part, opt: Int):ArrayBuffer[PartsListBean] = {
     val partBuffer = ArrayBuffer[PartsListBean]()
     for(child <-parentPart.parts) {
@@ -35,7 +22,8 @@ case class PartRecursion(){
     return partBuffer
   }
 
-  def up(childPart: Part, partBuffer: ArrayBuffer[PartsListBean], opt: Int):Unit = {
+  def up(childPart: Part, opt: Int): ArrayBuffer[PartsListBean] = {
+    val partBuffer = ArrayBuffer[PartsListBean]()
     if(childPart.parentParts.size == 0 && opt == 2) {
           partBuffer += PartsListBean("", childPart.name,0)
         }
@@ -45,11 +33,13 @@ case class PartRecursion(){
               partBuffer += PartsListBean(childPart.name, parent.name, parent.partRelation(childPart.id).quantity)
              }
                  if(opt != 1) {
-                   PartRecursion().up(parent, partBuffer, opt)
+                   for(returnPartBuffer <- PartRecursion().up(parent, opt)) {
+                     partBuffer += returnPartBuffer
+                   }
                  }
                }
          }
-
+        return partBuffer
   }
 
 }
\ No newline at end of file
index 2babca1..f7e5089 100644 (file)
@@ -5,13 +5,6 @@ import play.api.i18n._
 import scala.collection.mutable.ArrayBuffer
 
 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]()