org.positronicnet.orm.ManagedRecord

HasMany

class HasMany [T <: ManagedRecord] extends HasManyAssociation[T]

One-to-many association. See discussion in the orm overview. Note that the name of the foreignKey need not be supplied if it follows common conventions. (If the class that owns the HasMany is named ParentClass, the conventional foreign key field is the one whose Scala name is parentClassId, in the "child" class. That is, if a TodoList has many TodoItems, the convention is for TodoItem to have a todoListId, and that's what we use.)

Otherwise it must be the column name for the org.positronicnet.orm.ContentRepository, not the name of the corresponding Scala record field.

Linear Supertypes
HasManyAssociation[T], AlternateViewScope[T], DerivedScope[T], Scope[T], NotifierDelegator[IndexedSeq[T]], Notifier[IndexedSeq[T]], NotificationManager, BaseNotificationDelegator[Scope[T]], AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. HasMany
  2. HasManyAssociation
  3. AlternateViewScope
  4. DerivedScope
  5. Scope
  6. NotifierDelegator
  7. Notifier
  8. NotificationManager
  9. BaseNotificationDelegator
  10. AnyRef
  11. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new HasMany (src: Scope[T])

  2. new HasMany (src: Scope[T], foreignKey: String)

Value Members

  1. def ! (action: Action[IndexedSeq[T]]): Unit

    Perform the action, usually on a worker thread associated with this notifier.

    Perform the action, usually on a worker thread associated with this notifier. Results may be posted back to the calling thread, viz. the conventions documented in org.positronicnet.notifications.Actions.

    Definition Classes
    ScopeNotifierDelegatorNotifier
  2. def != (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  3. def != (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  4. def ## (): Int

    Attributes
    final
    Definition Classes
    AnyRef → Any
  5. def == (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  6. def == (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  7. def asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  8. val baseQuery : org.positronicnet.content.ContentQuery[_, _]

    ContentQuery whose conditions match those declared for the Scope.

    ContentQuery whose conditions match those declared for the Scope.

    Definition Classes
    AlternateViewScope → Scope
  9. val baseScope : Scope[T]

    Definition Classes
    AlternateViewScope → DerivedScope
  10. def clone (): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  11. lazy val count : CachingNotifier[Long]

    Notifier which can be used to fetch, or to receive updates on, the number of records matching the scope's conditions.

    Notifier which can be used to fetch, or to receive updates on, the number of records matching the scope's conditions. One usage pattern:

        Bugs.count ! AddWatcher( this ) { bugCount =>
          if (bugCount == 0) {
            startActivity( new Intent( this, classOf[ CelebrationActivity ])
            Bugs ! StopWatcher( this )
            finish
          }
        }
    

    The onChangeTo method in PositronicActivityHelpers can simplify this a bit... but I digress.

    Note that count is supported only if it is supported by the underlying ContentRepository; e.g., by databases, but not by ContentProviders.

    Definition Classes
    Scope
  12. def countQuery [Q] (initial: Q)(fn: (Q) ⇒ Scope[T]): ValueQuery[Q, Long]

    As for recordsQuery, but returns a notifier of the count of records matching the extra conditions.

    As for recordsQuery, but returns a notifier of the count of records matching the extra conditions.

    Definition Classes
    Scope
  13. def create : T

    Create a new child record, with the foreign key field pre-populated.

    Create a new child record, with the foreign key field pre-populated.

    Definition Classes
    HasManyAssociation
  14. def cursorNotifier [T] (thunk: ⇒ T): Notifier[T]

    Definition Classes
    BaseNotificationDelegator
  15. def cursorQuery [Q, R] (initialVal: Q)(func: (Q) ⇒ R): NonSharedValueQuery[Q, R]

    Definition Classes
    BaseNotificationDelegator
  16. def doChange (thunk: ⇒ Unit): Unit

    Definition Classes
    BaseNotificationDelegator
  17. def eq (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  18. def equals (arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  19. val facility : AppFacility

    AppFacility associated with the content source.

    AppFacility associated with the content source.

    Definition Classes
    AlternateViewScope → Scope
  20. def fetchOnThisThread : IndexedSeq[T]

    Synchronously fetch the value being monitored by this Notifier.

    Synchronously fetch the value being monitored by this Notifier.

    Definition Classes
    NotifierDelegatorNotifier
  21. def finalize (): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  22. def findOnThisThread (id: RecordId[T]): T

    Find the record with the given id, if it exists, running the query on the current thread, and returning it as the value.

    Find the record with the given id, if it exists, running the query on the current thread, and returning it as the value.

    XXX should only find it if it matches conditions of the scope, as per Rails.

    Definition Classes
    Scope
  23. lazy val foreignKeyField : Field

    Definition Classes
    HasManyAssociation
  24. lazy val fullQuery : org.positronicnet.content.ContentQuery[_, _]

    ContentQuery whose conditions match those for the records in scope.

    ContentQuery whose conditions match those for the records in scope. Ordinarily the same as baseQuery, but some RecordManagers may add extra conditions to, e.g., make soft-deleted records invisible from an ordinary fetch.

    Definition Classes
    Scope
  25. def getClass (): java.lang.Class[_]

    Attributes
    final
    Definition Classes
    AnyRef
  26. def handleVanishingParent : Unit

    The code invoked when the "parent" in a HasMany vanishes, to mop up child records.

    The code invoked when the "parent" in a HasMany vanishes, to mop up child records.

    Definition Classes
    HasManyAssociation
  27. def hashCode (): Int

    Definition Classes
    AnyRef → Any
  28. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  29. def limit (lim: Int): Scope[T]

    Produce a modified subscope which supplies at most a given number of records.

    Produce a modified subscope which supplies at most a given number of records. The string supplied is used directly in a SQL limit clause. May not be supported by all repositories; in particular, it is not supported by ContentProviders.

    Definition Classes
    Scope
  30. def limit (str: String): Scope[T]

    Produce a modified subscope which supplies at most a given number of records.

    Produce a modified subscope which supplies at most a given number of records. The string supplied is used directly in a SQL limit clause. May not be supported by all repositories; in particular, it is not supported by ContentProviders.

    Definition Classes
    Scope
  31. def ne (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  32. def noteChange : Unit

    Definition Classes
    BaseNotificationDelegator
  33. val notificationManagerDelegate : Scope[T]

    Attributes
    protected
    Definition Classes
    BaseNotificationDelegator
  34. def notifierDelegate : CachingNotifier[IndexedSeq[T]]

    The Notifier to which the delegator forwards, well.

    The Notifier to which the delegator forwards, well... everything here.

    Definition Classes
    ScopeNotifierDelegator
  35. def notify (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  36. def notifyAll (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  37. def onThisThread (action: Action[IndexedSeq[T]]): Unit

    Perform the action, synchronously on the calling thread.

    Perform the action, synchronously on the calling thread.

    Definition Classes
    ScopeNotifierDelegatorNotifier
  38. def onThread (thunk: ⇒ Unit): Unit

    Definition Classes
    BaseNotificationDelegator
  39. def order (str: String): Scope[T]

    Produce a modified subscope which supplies records in a particular order.

    Produce a modified subscope which supplies records in a particular order. The string supplied is used directly in a SQL order clause (or passed to the underlying ContentProvider, if appropriate).

    Definition Classes
    Scope
  40. lazy val records : CachingNotifier[IndexedSeq[T]]

    Definition Classes
    Scope
  41. def recordsQuery [Q] (initial: Q)(fn: (Q) ⇒ Scope[T]): ValueQuery[Q, IndexedSeq[T]]

    Returns a notifier for a subset of the records covered by this scope, matching extra conditions, which can be changed later by sending a Requery message.

    Returns a notifier for a subset of the records covered by this scope, matching extra conditions, which can be changed later by sending a Requery message.

    This can be used, for example, as the source for an IndexedSeqSourceAdapter, which displays the rows matching the user's "current search condition", whatever it may be, and changes when the condition changes, but without having to rewire the IndexedSeqSourceAdapter, perhaps something like so:

        val matchingBugs =
          Bugs.recordsQuery( "" ){ pattern =>
            Bugs.where( "tag_line like ?", pattern )
          }
    
         // ... later ...
    
        matchingBugs ! Requery( "newpattern" )
    

    The Requery will cause any declared watchers of matchingBugs to be notified of the new query result.

    Definition Classes
    Scope
  42. def subScopeFor (query: org.positronicnet.content.ContentQuery[_, _]): Scope[T]

    Attributes
    protected[orm]
    Definition Classes
    Scope
  43. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  44. def toString (): String

    Definition Classes
    HasManyAssociation → AnyRef → Any
  45. def valueNotifier [T] (thunk: ⇒ T): CachingNotifier[T]

    Definition Classes
    BaseNotificationDelegator
  46. def valueQuery [Q, R] (initialVal: Q)(func: (Q) ⇒ R): ValueQuery[Q, R]

    Definition Classes
    BaseNotificationDelegator
  47. def wait (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  48. def wait (arg0: Long, arg1: Int): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  49. def wait (arg0: Long): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  50. def where (str: String, vals: ContentValue*): Scope[T]

    Produce a restricted subscope containing only records matching an extra SQL condition, possibly including ? placeholders which can get filled in by the supplied ContentValue arguments, if any.

    Produce a restricted subscope containing only records matching an extra SQL condition, possibly including ? placeholders which can get filled in by the supplied ContentValue arguments, if any. Example:

        val recentBugs =
          Bugs.where( "state != ? and create_date > ?",
                      "closed",
                      System.currentTimeMillis - 3*86400*1000 )
    

    Note that the columns are named using internal SQL column names, not the Java mapped versions.

    (Note for the future: we could consider changing this by allowing syntax like "{createDate}>?", where the string in curly-braces would be a Java field name to be mapped to the SQL equivalent. But that's not there yet.)

    Definition Classes
    Scope
  51. def whereEq (pairs: (String, ContentValue)*): Scope[T]

    Produce a restricted subscope containing only records where particular fields have particular values.

    Produce a restricted subscope containing only records where particular fields have particular values. The argument is a set of (String,[[org.positronicnet.content.ContentValue]]) pairs, often entered using -> notation, like so:

        Bugs.whereEq( "status"->"done", "ownerId"->joe.id )
    

    Note that columns can be designated by either the names of the columns in the underlying tables, or the names of the Scala vals in the classes that they get mapped to.

    Definition Classes
    Scope

Inherited from HasManyAssociation[T]

Inherited from AlternateViewScope[T]

Inherited from DerivedScope[T]

Inherited from Scope[T]

Inherited from NotifierDelegator[IndexedSeq[T]]

Inherited from Notifier[IndexedSeq[T]]

Inherited from NotificationManager

Inherited from BaseNotificationDelegator[Scope[T]]

Inherited from AnyRef

Inherited from Any