vim: fdm=marker et sw=2 ts=2

{{{1 Refactor Actions ?? STARTED, I'll finish this a bit at a time

Now:

Debate(posts: List[Post], deletions: List[Delete], ...)


abstract Action
  def id: String
  def loginId: String
  def newIp: Option[String]
  def ctime: ju.Date
  def textLengthUtf8: Int = 0

Rating
  postId
  tags: List[String]

Flag
  postId
  reason: FlagReason = Spam | Illegal | CopyVio | Other
  details: String

Post
  parent
  text
  markup
  tyype: Text | Publish | Meta  (bad!)
  where

PostMeta  -- oops!
  isArticleQuestion
  fixedPos

Edit
  postId
  text
  newMarkup

EditApp
  editId
  result  -- should remove

Delete
  postId
  wholeTree
  reason

Review
  approval: Option[Approval]


**Need:**

Summary(text: String)
CloseThread
PinThread(position: Int?)


{{{ Alt 8 - chosen!  (Similar to alt 6 but with different names)

PostActionDto:

CreatePostAction
FlagPostAction
RatePostAction
EditPostAction
ApplyEditPostAction
ReviewAction
DeleteAction
PinPostAction
CloseThreadAction
CollapseThreadAction
MoveThreadAction


PostAction:  (Or PagePart?)

Post
PostFlag
PostRating
PostPatch
PostPatchApp
PostReview
PostDeletion
PostPin
PostCloser
PostCollapser
PostMovement


}}}
{{{ Alt 7 (2013-03-02)


RichPostAction(action: PostAction) {

  def isDeleted(implicit page: Page) = ... page. ...

}

}}}
{{{ Alt 6 (2013-02-18)

Debate --> PageParts

Action --> PostAction

RawPostAction:

  id: String
  postId: String

  userId: String
  loginId: String
  ip: Option[String]

  creationDati: ju.Date


  Payload:

  Create(text)
  Flag(reason, details)
  Rate(tags)
  Edit(diff, newMarkup)
  ApplyEdit(editId)
  Review
  Delete(commandId)

  Pin(position)
  Close
  Collapse
  Move(newPostId)

-- Worse: ---
DbDaoPostAction
extended by:
CreatePostAction
FlagPostAction
RatePostAction
EditPostAction
ApplyEditPostAction
ReviewAction
DeleteAction
PinPostAction
CloseThreadAction
CollapseThreadAction
MoveThreadAction



ViAc --> PostAction

  ((no, --> PagePart?
  But "PagePart" + "Move" = weird!  .. PostAction is better?))


ViPo -->
  Post extends PostAction

ViEd -->
  Patch extends PostAction



}}}
{{{2 Alt 5. Generic base class, w/o text?

abstract Action
  def id: String
  def targetId: String
  def loginId: String
  def newIp: Option[String]
  def ctime: ju.Date

abstract ActionWithText
  def text: String

Rating
  tags: List[String]

Flag
  reason: FlagReason = Spam | Illegal | CopyVio | Other
  text = details

Post
  markup
  where
  text = comment / article

META
  text = metadata

PUBLISH

UNPUBLISH

Edit
  newMarkup
  `diff` field, add?
  `where`, add?

DELETE
  text = reason (optional)

DELETETREE
  text = reason (optional)

APPROVE

REJECT

Move
  newParentId


}}}2
{{{2 Alt 4. ActionWithType, + others as is?


abstract Action
  def id: String
  def targetId: String
  def loginId: String
  def newIp: Option[String]
  def ctime: ju.Date


abstract SimpleActionType

abstract ActionPayload
  def payload: SimpleActionType


case class ActionWithType extends Action
  def id: String
  def targetId: String
  def loginId: String
  def newIp: Option[String]
  def ctime: ju.Date

  def tyype: SimpleActionType


case class ActionWithPayload extends Action
  def id: String
  def targetId: String
  def loginId: String
  def newIp: Option[String]
  def ctime: ju.Date

  def payload: ActionPayload


Rating
  tags: List[String]
  text = unsupported

Flag
  reason: FlagReason = Spam | Illegal | CopyVio | Other
  text = details

Post
  text = comment / article
  markup
  where

META
  text = metadata

Publish extends ActionWithType

Unpublish extends ActionWithType

Edit
  newMarkup
  text = commit message
  `diff` field, add?
  `where`, add?

Delete extends ActionWithType

DeleteTree extends ActionWithType

Approve extends ActionWithType

Reject extends SimpleActionType

Move
  newParentId
  text = reason (optional)


}}}2
{{{2 Alt 1. Replace inheritance with delegation ??  (I did that eventually, yes, but somewhat different names)

case class Action[PayloadType <: ?? >: ActionPayload](
  id: String
  targetId: String
  loginId: String
  newIp: Option[String]
  ctime: ju.Date
  payload: PayloadType)

sealed abstract class ActionPayload

abstract class TextPayload extends ActionPayload
  def text: String

Rating extends ActionPayload
  tags: List[String]

Flag extends TextPayload
  reason FlagReason = Spam | Illegal | CopyVio | Other
  text = details

Post extends TextPayload
  text = comment / article
  markup
  where

Meta extends TextPayload
  text = meta

Publish extends ActionPayload

Edit extends ActionPayload
  diff
  newMarkup

Approve extends ActionPayload

Reject extends ActionPayload

Delete extends TextPayload
  recursvely
  text = reason


}}}2
{{{2 Alt 2. Very generic base class ??

abstract Action
  def id: String
  def targetId: String
  def loginId: String
  def newIp: Option[String]
  def ctime: ju.Date
  def text: String

Rating
  tags: List[String]
  text = unsupported

Flag
  reason: FlagReason = Spam | Illegal | CopyVio | Other
  text = details

Post
  text = comment / article
  markup
  where

META
  text = metadata

PUBLISH
  text = ((reason, rather useless))

UNPUBLISH
  text = reason (optional)

Edit
  newMarkup
  text = commit message
  `diff` field, add?
  `where`, add?

DELETE
  text = reason

DELETETREE
  text = reason

APPROVE
  text = ((reason, rather useless))

REJECT
  text = reason (optional)

Move
  newParentId
  text = reason (optional)


}}}2
{{{2 Alt 3. Very reused comment class - bad ? ...

... bad, since hard to know what a Post with targetId = X means?
Is it someone's comment to the Edit? Or is it the committ message?
Would have to compare author ids to know.

abstract Action
  def id: String
  def loginId: String
  def newIp: Option[String]
  def ctime: ju.Date

Rating
  postId
  tags: List[String]

Flag
  postId
  reason: FlagReason = Spam | Illegal | CopyVio | Other

Post
  targetId
    could be, and means:
    - Rating - reason
    - Flag - reason
    - Post - comment
    - no: Meta
    - no: Publish
    - Unpublish - reason
    - Edit - commit messge
    - Delete/Tree - reason
    - no: Approve
    - Reject - reason
    - Move - reason
  text = comment / article
  markup
  where

Meta
  postId
  text = metadata

Publish
  postId

Unpublish
  postId

Edit
  postId
  newMarkup
  `diff` field, add?
  `where`, add?

Delete
  actionId

DeleteTree
  actionId

Approve
  actionId

Reject
  actionId

Move
  postId
  newParentId

}}}1
