On Nov 11, 2015, at 6:11 PM, Flavio Donadio <[email protected]> wrote:

> Hello, list! Hello, Ramsey!
> 
> 
> I want to implement ERCAuditTrail from Ponder (ERCoreBL framework, not 
> ERCoreBusinessLogic) in a new app.
> 
> Searching through the archives, I’ve found this:
> 
> On 29 Jun 2012, at 12:31, Dieter Stollorcz wrote:
> 
>> here is how i set up ERCAuditTrails and ERCPreference:
>> 
>> 1. Add the ERCoreBusinessLogic to build path
>> 
>> 2. Create the ERCoreBusinessLogic Tables in DB 
>> Run migrations or add the relevant tables to DB
>> 
>> 3. Implement ERCoreUserInterface on user entity ( my UserEntity is 
>> ECOM_Actor)
>> public class ECOM_Actor extends _ECOM_Actor implements ERCoreUserInterface {
>>      ...
>>      public static final String      PreferencesKey = "preferences";
>>      @Override
>>      public NSArray preferences() {
>>              return (NSArray)storedValueForKey(PreferencesKey);
>>      }
>> 
>>      @Override
>>      public void setPreferences(NSArray array) {
>>              takeStoredValueForKey(array.mutableClone(), PreferencesKey);
>> 
>>      }
>> 
>>      @Override
>>      public void newPreference(EOEnterpriseObject pref) {
>>              addObjectToBothSidesOfRelationshipWithKey(pref, PreferencesKey);
>>      }
>> 
>> 
>> 
>> 4. In Application.java add 
>> @Override
>>      public void finishInitialization() {
>>              super.finishInitialization();
>>              
>> ERCoreBusinessLogic.sharedInstance().addPreferenceRelationshipToActorEntity("ECOM_Actor");
>>      }
>>      
>> 5.  Set the user as the actor at login (DirectAction.java)
>> public WOActionResults loginAction() {
>>      ...
>>      ((Session)session()).setCurrentUser(user);
>>      ....
>> }
>> 
>> 6.  Set the Actor in session.java 
>> public void setCurrentUser(ECOM_Actor user) {
>>              ERCoreBusinessLogic.setActor(user);
>>              _currentUser = user;
>>      }
>>      
>>    public void awake() {
>>        super.awake();
>>        if (currentUser() != null) {
>>            ERCoreBusinessLogic.setActor(currentUser());
>>        }
>>    }
>> 
>>    public void sleep() {
>>        ERCoreBusinessLogic.setActor(null);
>>        super.sleep();
>>    }
>> 
>> 7. In EntityModeler add the ERXAuditKeys 
>> Include your list of ERXAuditKeys in the userInfo dictionary for the Entity.
>> If you include the ERXAuditKeys key with an empty value, it will log all 
>> your attributes by default. 
> 
> I have some questions:
> 
> 1. Is this the way to do it? Has something changed from 2012?

For ERCoreBL, it’s basically the same thing, yes. The main difference from 
ERCoreBL and ERCoreBusinessLogic is a significantly improved email system. At 
work, we send ~20,000 emails a day with ERCoreBL + AWSPlugIn. It’s very 
flexible and allows for all the crazy business rules your team might want to 
implement.

The audit trails stuff is essentially a copy paste job. I’ve never really used 
it so it probably could use some love.

> 
> 2. Dieter says “[r]un migrations or add the relevant tables to DB”. If my app 
> migrates automatically on startup, do I still need to do this?

If you auto migrate, that should do the trick.

> 
> 3. Does the UserEntity have to be a subclass of ERUser?

No, the ERCoreBL is completely ignorant of ERAuth which is in turn completely 
ignorant of ERUsers. If you just want to use ERCoreBL, you can. It won’t hurt 
to poke around in the other two frameworks though.

For example, ERStageManager is a nice way to set/unset your actor on the 
session without needing to modify your application’s session at all. If you 
have a lot of different applications that need to use your user framework, this 
will save a lot of boilerplate in the Session.java files. It takes advantage of 
the object store and sticks the user in session.objectStore.user using 
NSNotifications, so it’s completely invisible to the session class.


> 
> 
> Cheers,
> Flavio


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to