Project Wonder 5.0

er.directtoweb.assignments.delayed
Class ERDDelayedExtraQualifierAssignment

java.lang.Object
  extended by com.webobjects.directtoweb.Assignment
      extended by er.directtoweb.assignments.delayed.ERDDelayedAssignment
          extended by er.directtoweb.assignments.delayed.ERDDelayedExtraQualifierAssignment
All Implemented Interfaces:
com.webobjects.eocontrol.EOKeyValueArchiving, java.io.Serializable

public class ERDDelayedExtraQualifierAssignment
extends ERDDelayedAssignment

Very useful when you want to restrict the things a user can see during searches or in list pages.
set it up via a rule like:

  entity.name = "Movie" and session.user.role <> "admin"
   =>
  extraRestrictingQualifier = {
      "studio" = "session.user.studios";
  } [er.directtoweb.ERDDelayedExtraQualifierAssignment]
then in your query page use sth like:
 public EODataSource queryDataSource() {
    EODataSource ds = super.queryDataSource();
    if (ds != null && (ds instanceof EODatabaseDataSource)) {
        EOFetchSpecification fs = ((EODatabaseDataSource)ds).fetchSpecification();
        EOQualifier q = fs.qualifier();
        EOQualifier extraQualifier = (EOQualifier)d2wContext().valueForKey("extraRestrictingQualifier");
        if(q != null && extraQualifier != null) {
            q = new EOAndQualifier(new NSArray(new Object[] {q, extraQualifier}));
        } else if(extraQualifier != null) {
            q = extraQualifier;
        }
        fs.setQualifier(q);
    }
    return ds;
 }
This should guarantee that the user can only see the Movies that are made by studios contained in his studio relationship. If the value is null, then this qualifier will not be added. To search for NULL, return NSKeyValueCoding.NullValue.

See Also:
Serialized Form
Author:
ak

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.webobjects.eocontrol.EOKeyValueArchiving
com.webobjects.eocontrol.EOKeyValueArchiving._NullValueSupport, com.webobjects.eocontrol.EOKeyValueArchiving._NumberSupport, com.webobjects.eocontrol.EOKeyValueArchiving._TimestampSupport, com.webobjects.eocontrol.EOKeyValueArchiving.Awaking, com.webobjects.eocontrol.EOKeyValueArchiving.FinishInitialization, com.webobjects.eocontrol.EOKeyValueArchiving.Support
 
Field Summary
static org.apache.log4j.Logger log
          logging support
 
Fields inherited from class com.webobjects.directtoweb.Assignment
KeyPathKey, ValueKey
 
Fields inherited from interface com.webobjects.eocontrol.EOKeyValueArchiving
_CLASS
 
Constructor Summary
ERDDelayedExtraQualifierAssignment(com.webobjects.eocontrol.EOKeyValueUnarchiver u)
          Public constructor
ERDDelayedExtraQualifierAssignment(java.lang.String key, java.lang.Object value)
          Public constructor
 
Method Summary
static java.lang.Object decodeWithKeyValueUnarchiver(com.webobjects.eocontrol.EOKeyValueUnarchiver eokeyvalueunarchiver)
          Static constructor required by the EOKeyValueUnarchiver interface.
protected  com.webobjects.eocontrol.EOQualifier extraQualifier(com.webobjects.directtoweb.D2WContext c, com.webobjects.foundation.NSDictionary dict)
           
 java.lang.Object fireNow(com.webobjects.directtoweb.D2WContext c)
          Implemented by subclasses.
protected  com.webobjects.eocontrol.EOQualifier qualifierForArray(java.lang.String key, com.webobjects.foundation.NSArray objects)
           
protected  com.webobjects.eocontrol.EOQualifier qualifierForObject(java.lang.String key, java.lang.Object object)
           
 
Methods inherited from class er.directtoweb.assignments.delayed.ERDDelayedAssignment
fire
 
Methods inherited from class com.webobjects.directtoweb.Assignment
encodeWithKeyValueArchiver, keyPath, toString, value, value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

public static final org.apache.log4j.Logger log
logging support

Constructor Detail

ERDDelayedExtraQualifierAssignment

public ERDDelayedExtraQualifierAssignment(com.webobjects.eocontrol.EOKeyValueUnarchiver u)
Public constructor

Parameters:
u - key-value unarchiver used when unarchiving from rule files.

ERDDelayedExtraQualifierAssignment

public ERDDelayedExtraQualifierAssignment(java.lang.String key,
                                          java.lang.Object value)
Public constructor

Parameters:
key - context key
value - of the assignment
Method Detail

decodeWithKeyValueUnarchiver

public static java.lang.Object decodeWithKeyValueUnarchiver(com.webobjects.eocontrol.EOKeyValueUnarchiver eokeyvalueunarchiver)
Static constructor required by the EOKeyValueUnarchiver interface. If this isn't implemented then the default behavior is to construct the first super class that does implement this method. Very lame.

Parameters:
eokeyvalueunarchiver - to be unarchived
Returns:
decoded assignment of this class

qualifierForArray

protected com.webobjects.eocontrol.EOQualifier qualifierForArray(java.lang.String key,
                                                                 com.webobjects.foundation.NSArray objects)

qualifierForObject

protected com.webobjects.eocontrol.EOQualifier qualifierForObject(java.lang.String key,
                                                                  java.lang.Object object)

extraQualifier

protected com.webobjects.eocontrol.EOQualifier extraQualifier(com.webobjects.directtoweb.D2WContext c,
                                                              com.webobjects.foundation.NSDictionary dict)

fireNow

public java.lang.Object fireNow(com.webobjects.directtoweb.D2WContext c)
Description copied from class: ERDDelayedAssignment
Implemented by subclasses.

Specified by:
fireNow in class ERDDelayedAssignment

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.