SlideShare a Scribd company logo
1 of 19
Download to read offline
Filtering data with D2W
Philippe Rabier - twitter.com/prabier
Sophiacom
What is the problem to solve?
Company
EOEntityA
EOEntityB
User
EOEntityC
• Use D2W
• Limit the visibility of the data
• Use conventions to name relationships (for example, any toOne
relationship to Company entity, is called company)
• Minimize the code
• Be magic!
The Requirements
Feedback fromYou ’N Push
First Solution
Working at the editingContext level
modified fetchspec
notification
ec factory
ec
company
objectsWithFetch
Specification()
creates
businessFP
fetchspec
How the qualifier is modified?
	 public void alterFetchSpecification(final NSNotification aNotification)
	 {
	 	 EOEditingContext ec = (EOEditingContext) aNotification.object();
	 	 if (shouldAddRestrictionQualifier)
	 	 {
	 	 	 Company aCompany = (NOClient) ec.userInfoForKey(NBEditingContextFactory.COMPANY_KEY);
	 	 	 final EOFetchSpecification fs = (EOFetchSpecification) aNotification.userInfo().valueForKey(COEditingContext.FETCH_SPEC_KEY);
	 	 	 if (aCompany != null && fs != null)
	 	 	 {
	 	 	 	 EOEntity aEntity = EOUtilities.entityNamed(ec, fs.entityName());
	 	 	 	 EOQualifier fsQualifier = fs.qualifier();
	 	 	 	 if (fsQualifier != null)
	 	 	 	 {
	 	 	 	 	 NSSet<String> keys = fsQualifier.allQualifierKeys();
	 	 	 	 	 for (String aKey : keys)
	 	 	 	 	 {
	 	 	 	 	 	 if (aKey.contains("company"))
	 	 	 	 	 	 {
	 	 	 	 	 	 	 shouldAddRestrictionQualifier = false;
	 	 	 	 	 	 	 break;
	 	 	 	 	 	 }
	 	 	 	 	 }
	 	 	 	 }
	 	 	 	 if (shouldAddRestrictionQualifier)
	 	 	 	 {
	 	 	 	 	 EOQualifier aRestrictionQualifier = clientRestrictionQualifier(aEntity, aClient);
	 	 	 	 	 if (aRestrictionQualifier != null)
	 	 	 	 	 {
	 	 	 	 	 	 if (fsQualifier != null)
	 	 	 	 	 	 	 fsQualifier = new EOAndQualifier(new NSArray<EOQualifier>(new EOQualifier[] {fsQualifier, aRestrictionQualifier}));
	 	 	 	 	 	 else
	 	 	 	 	 	 	 fsQualifier = aRestrictionQualifier;
	 	 	 	 	 	 fs.setQualifier(fsQualifier);
	 	 	 	 	 }
	 	 	 	 }
	 	 	 }
	 	 }
	 }
How the qualifier is modified?
	 public EOQualifier companyRestrictionQualifier(final EOEntity entity, final Company company)
	 {
	 	 EOQualifier aQualifier = null;
	 	 if (entity.name().equals(Company.Keys.ENTITY_NAME))
	 	 	 aQualifier = new EOKeyValueQualifier(Company.Keys.NAME, EOQualifier.QualifierOperatorEqual, company.name());
	 	 else if (entity.relationshipNamed("company") != null)
	 	 	 aQualifier = new EOKeyValueQualifier("company", EOQualifier.QualifierOperatorEqual, company);
	 	 else if (entity.relationshipNamed("entityB") != null)
	 	 	 aQualifier = new EOKeyValueQualifier("entityB.company", EOQualifier.QualifierOperatorEqual, client);
	 	 else if (entity.relationshipNamed("entityC") != null)
	 	 	 ...;
	 	 if (log.isDebugEnabled())
	 	 	 log.debug("method: qualifier: " + aQualifier);
	 	 return aQualifier;
	 }
It works great
but there is a little problem
it’s too low level
An Example of Problem
	 public void validateForSave() throws ValidationException
	 {
	 	 super.validateForSave();
	 	 ERXEOControlUtilities.validateUniquenessOf(this, NOUser.Keys.LOGIN);
	 	 ERXEOControlUtilities.validateUniquenessOf(this, NOUser.Keys.EMAIL);
	 }
	 public void validateForSave() throws ValidationException
	 {
	 	 super.validateForSave();
	 	 editingContext().setUserInfoForKey(Boolean.FALSE, NBEditingContextFactory.NO_RESTRICTION_QUAL_KEY);
	 	 ERXEOControlUtilities.validateUniquenessOf(this, NOUser.Keys.LOGIN);
	 	 ERXEOControlUtilities.validateUniquenessOf(this, NOUser.Keys.EMAIL);
	 	 editingContext().setUserInfoForKey(Boolean.TRUE, NBEditingContextFactory.NO_RESTRICTION_QUAL_KEY);
	 }
Second Solution
• Displaying a list
• Using a query component
• Using ERD2WEditToManyRelationship component
• Using ERD2WEditToOneRelationship component
When should we filter?
• Modify the NavigationController object
• Change the data source
Displaying a list
	 public WOComponent listPageForEntityName(final String entityName)
	 {
	 	 ListPageInterface newListPageInterface = D2W.factory().listPageForEntityNamed(entityName, session());
	 	 EODatabaseDataSource dataSource = new EODatabaseDataSource(ERXEC.newEditingContext(), entityName);
	 	 EOEntity entity = ERXEOAccessUtilities.entityNamed(null, entityName);
	 	 EOQualifier auxQual = NBBusinessLogicPrincipal.getSharedInstance().clientRestrictionQualifier(entity,
	 	 	 	 ((Session)session()).getCompany());
	 	 dataSource.setAuxiliaryQualifier(auxQual);
	 	 newListPageInterface.setDataSource(dataSource);
	 	 return (WOComponent) newListPageInterface;
	 }
• Use a query delegate
• Override the method queryDataSource(ERD2WQueryPage sender)
Using a query component
{
author = 100;
class = "com.webobjects.directtoweb.Rule";
lhs = {
class = "com.webobjects.eocontrol.EOKeyValueQualifier";
key = pageConfiguration;
selectorName = isEqualTo;
value = QueryMyEntity;
};
rhs = {
class = "er.directtoweb.ERDDelayedObjectCreationAssignment";
keyPath = queryDataSourceDelegate;
value = "ca.wowodc.very.util.pascal.delegate.SomeOneElse";
};
}
• Maybe subclass the 2 component is the best solution
• Use restrictingFetchSpecification key. If all fetchspec have the
same name, it’s possible to build a generic rule.
• Need to be modified to add the possibility to set a binding to
the fetchspec
• Maybe a lot of pain to create many fetchspec in the EOModel
EditRelationship components
How the qualifier is modified?
public Object restrictedChoiceList() {
String restrictedChoiceKey=(String)d2wContext().valueForKey("restrictedChoiceKey");
if( restrictedChoiceKey!=null && restrictedChoiceKey.length()>0 )
return valueForKeyPath(restrictedChoiceKey);
String fetchSpecName=(String)d2wContext().valueForKey("restrictingFetchSpecification");
if(fetchSpecName != null) {
EORelationship relationship = ERXUtilities.relationshipWithObjectAndKeyPath(object(),
(String)d2wContext().valueForKey("propertyKey"));
if(relationship != null)
return EOUtilities.objectsWithFetchSpecificationAndBindings(object().editingContext(),
relationship.destinationEntity().name(),fetchSpecName,null);
}
return null;
}
@prabier
Follow me!
Q&A
TBD

More Related Content

What's hot

JavaScript
JavaScriptJavaScript
JavaScriptSunil OS
 
Intro To Hibernate
Intro To HibernateIntro To Hibernate
Intro To HibernateAmit Himani
 
Hibernate inheritance and relational mappings with examples
Hibernate inheritance and relational mappings with examplesHibernate inheritance and relational mappings with examples
Hibernate inheritance and relational mappings with examplesEr. Gaurav Kumar
 
Expression Language in JSP
Expression Language in JSPExpression Language in JSP
Expression Language in JSPcorneliuskoo
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of JavascriptTarek Yehia
 
Introduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesIntroduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesecosio GmbH
 
Efficient Rails Test-Driven Development - Week 6
Efficient Rails Test-Driven Development - Week 6Efficient Rails Test-Driven Development - Week 6
Efficient Rails Test-Driven Development - Week 6Marakana Inc.
 
Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007Rabble .
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginningAnis Ahmad
 
Web весна 2013 лекция 6
Web весна 2013 лекция 6Web весна 2013 лекция 6
Web весна 2013 лекция 6Technopark
 
Web2py tutorial to create db driven application.
Web2py tutorial to create db driven application.Web2py tutorial to create db driven application.
Web2py tutorial to create db driven application.fRui Apps
 
Designing a JavaFX Mobile application
Designing a JavaFX Mobile applicationDesigning a JavaFX Mobile application
Designing a JavaFX Mobile applicationFabrizio Giudici
 
Domain Driven Design using Laravel
Domain Driven Design using LaravelDomain Driven Design using Laravel
Domain Driven Design using Laravelwajrcs
 

What's hot (19)

JavaScript
JavaScriptJavaScript
JavaScript
 
Deployment
DeploymentDeployment
Deployment
 
Intro To Hibernate
Intro To HibernateIntro To Hibernate
Intro To Hibernate
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
hibernate with JPA
hibernate with JPAhibernate with JPA
hibernate with JPA
 
Hibernate inheritance and relational mappings with examples
Hibernate inheritance and relational mappings with examplesHibernate inheritance and relational mappings with examples
Hibernate inheritance and relational mappings with examples
 
Expression Language in JSP
Expression Language in JSPExpression Language in JSP
Expression Language in JSP
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of Javascript
 
Introduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesIntroduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examples
 
Efficient Rails Test-Driven Development - Week 6
Efficient Rails Test-Driven Development - Week 6Efficient Rails Test-Driven Development - Week 6
Efficient Rails Test-Driven Development - Week 6
 
Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007
 
Hibernate in Nutshell
Hibernate in NutshellHibernate in Nutshell
Hibernate in Nutshell
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
 
Web весна 2013 лекция 6
Web весна 2013 лекция 6Web весна 2013 лекция 6
Web весна 2013 лекция 6
 
Web2py tutorial to create db driven application.
Web2py tutorial to create db driven application.Web2py tutorial to create db driven application.
Web2py tutorial to create db driven application.
 
Hibernate
HibernateHibernate
Hibernate
 
Designing a JavaFX Mobile application
Designing a JavaFX Mobile applicationDesigning a JavaFX Mobile application
Designing a JavaFX Mobile application
 
Jquery 4
Jquery 4Jquery 4
Jquery 4
 
Domain Driven Design using Laravel
Domain Driven Design using LaravelDomain Driven Design using Laravel
Domain Driven Design using Laravel
 

Viewers also liked

iOS for ERREST - alternative version
iOS for ERREST - alternative versioniOS for ERREST - alternative version
iOS for ERREST - alternative versionWO Community
 
Reenabling SOAP using ERJaxWS
Reenabling SOAP using ERJaxWSReenabling SOAP using ERJaxWS
Reenabling SOAP using ERJaxWSWO Community
 
Chaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real WorldChaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real WorldWO Community
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO DevsWO Community
 
Migrating existing Projects to Wonder
Migrating existing Projects to WonderMigrating existing Projects to Wonder
Migrating existing Projects to WonderWO Community
 
D2W Stateful Controllers
D2W Stateful ControllersD2W Stateful Controllers
D2W Stateful ControllersWO Community
 
Using Nagios to monitor your WO systems
Using Nagios to monitor your WO systemsUsing Nagios to monitor your WO systems
Using Nagios to monitor your WO systemsWO Community
 
Advanced Apache Cayenne
Advanced Apache CayenneAdvanced Apache Cayenne
Advanced Apache CayenneWO Community
 
Unit Testing with WOUnit
Unit Testing with WOUnitUnit Testing with WOUnit
Unit Testing with WOUnitWO Community
 
Build and deployment
Build and deploymentBuild and deployment
Build and deploymentWO Community
 
Deploying WO on Windows
Deploying WO on WindowsDeploying WO on Windows
Deploying WO on WindowsWO Community
 
"Framework Principal" pattern
"Framework Principal" pattern"Framework Principal" pattern
"Framework Principal" patternWO Community
 
In memory OLAP engine
In memory OLAP engineIn memory OLAP engine
In memory OLAP engineWO Community
 

Viewers also liked (17)

iOS for ERREST
iOS for ERRESTiOS for ERREST
iOS for ERREST
 
iOS for ERREST - alternative version
iOS for ERREST - alternative versioniOS for ERREST - alternative version
iOS for ERREST - alternative version
 
Reenabling SOAP using ERJaxWS
Reenabling SOAP using ERJaxWSReenabling SOAP using ERJaxWS
Reenabling SOAP using ERJaxWS
 
WOver
WOverWOver
WOver
 
Chaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real WorldChaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real World
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
 
Migrating existing Projects to Wonder
Migrating existing Projects to WonderMigrating existing Projects to Wonder
Migrating existing Projects to Wonder
 
D2W Stateful Controllers
D2W Stateful ControllersD2W Stateful Controllers
D2W Stateful Controllers
 
Using Nagios to monitor your WO systems
Using Nagios to monitor your WO systemsUsing Nagios to monitor your WO systems
Using Nagios to monitor your WO systems
 
Advanced Apache Cayenne
Advanced Apache CayenneAdvanced Apache Cayenne
Advanced Apache Cayenne
 
Life outside WO
Life outside WOLife outside WO
Life outside WO
 
Unit Testing with WOUnit
Unit Testing with WOUnitUnit Testing with WOUnit
Unit Testing with WOUnit
 
Build and deployment
Build and deploymentBuild and deployment
Build and deployment
 
High availability
High availabilityHigh availability
High availability
 
Deploying WO on Windows
Deploying WO on WindowsDeploying WO on Windows
Deploying WO on Windows
 
"Framework Principal" pattern
"Framework Principal" pattern"Framework Principal" pattern
"Framework Principal" pattern
 
In memory OLAP engine
In memory OLAP engineIn memory OLAP engine
In memory OLAP engine
 

Similar to Filtering data with D2W relationships in Direct to Web

A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo Ali Parmaksiz
 
Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#Vagif Abilov
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsJeff Durta
 
Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Patterngoodfriday
 
Cocoa heads testing and viewcontrollers
Cocoa heads testing and viewcontrollersCocoa heads testing and viewcontrollers
Cocoa heads testing and viewcontrollersStijn Willems
 
Test-driven Development with AEM
Test-driven Development with AEMTest-driven Development with AEM
Test-driven Development with AEMJan Wloka
 
PHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4DevelopersPHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4DevelopersKacper Gunia
 
Functional programming in C#
Functional programming in C#Functional programming in C#
Functional programming in C#Thomas Jaskula
 
react-hooks.pdf
react-hooks.pdfreact-hooks.pdf
react-hooks.pdfchengbo xu
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation洪 鹏发
 
Devoxx 2012 hibernate envers
Devoxx 2012   hibernate enversDevoxx 2012   hibernate envers
Devoxx 2012 hibernate enversRomain Linsolas
 
Windows 8 Training Fundamental - 1
Windows 8 Training Fundamental - 1Windows 8 Training Fundamental - 1
Windows 8 Training Fundamental - 1Kevin Octavian
 
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09Daniel Bryant
 

Similar to Filtering data with D2W relationships in Direct to Web (20)

Clean coding-practices
Clean coding-practicesClean coding-practices
Clean coding-practices
 
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
 
Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#
 
Rails is not just Ruby
Rails is not just RubyRails is not just Ruby
Rails is not just Ruby
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Pattern
 
Cocoa heads testing and viewcontrollers
Cocoa heads testing and viewcontrollersCocoa heads testing and viewcontrollers
Cocoa heads testing and viewcontrollers
 
Requery overview
Requery overviewRequery overview
Requery overview
 
Test-driven Development with AEM
Test-driven Development with AEMTest-driven Development with AEM
Test-driven Development with AEM
 
Quick Fix Sample
Quick Fix SampleQuick Fix Sample
Quick Fix Sample
 
Deep dive into Oracle ADF
Deep dive into Oracle ADFDeep dive into Oracle ADF
Deep dive into Oracle ADF
 
PHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4DevelopersPHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4Developers
 
Functional programming in C#
Functional programming in C#Functional programming in C#
Functional programming in C#
 
react-hooks.pdf
react-hooks.pdfreact-hooks.pdf
react-hooks.pdf
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
 
Ecom lec4 fall16_jpa
Ecom lec4 fall16_jpaEcom lec4 fall16_jpa
Ecom lec4 fall16_jpa
 
Devoxx 2012 hibernate envers
Devoxx 2012   hibernate enversDevoxx 2012   hibernate envers
Devoxx 2012 hibernate envers
 
Jsr 303
Jsr 303Jsr 303
Jsr 303
 
Windows 8 Training Fundamental - 1
Windows 8 Training Fundamental - 1Windows 8 Training Fundamental - 1
Windows 8 Training Fundamental - 1
 
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
 

More from WO Community

Localizing your apps for multibyte languages
Localizing your apps for multibyte languagesLocalizing your apps for multibyte languages
Localizing your apps for multibyte languagesWO Community
 
D2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRollerD2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRollerWO Community
 
CMS / BLOG and SnoWOman
CMS / BLOG and SnoWOmanCMS / BLOG and SnoWOman
CMS / BLOG and SnoWOmanWO Community
 
Persistent Session Storage
Persistent Session StoragePersistent Session Storage
Persistent Session StorageWO Community
 
WebObjects Optimization
WebObjects OptimizationWebObjects Optimization
WebObjects OptimizationWO Community
 
ERRest: the Basics
ERRest: the BasicsERRest: the Basics
ERRest: the BasicsWO Community
 

More from WO Community (12)

Localizing your apps for multibyte languages
Localizing your apps for multibyte languagesLocalizing your apps for multibyte languages
Localizing your apps for multibyte languages
 
WOdka
WOdkaWOdka
WOdka
 
ERGroupware
ERGroupwareERGroupware
ERGroupware
 
D2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRollerD2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRoller
 
CMS / BLOG and SnoWOman
CMS / BLOG and SnoWOmanCMS / BLOG and SnoWOman
CMS / BLOG and SnoWOman
 
Using GIT
Using GITUsing GIT
Using GIT
 
Persistent Session Storage
Persistent Session StoragePersistent Session Storage
Persistent Session Storage
 
Back2 future
Back2 futureBack2 future
Back2 future
 
WebObjects Optimization
WebObjects OptimizationWebObjects Optimization
WebObjects Optimization
 
Dynamic Elements
Dynamic ElementsDynamic Elements
Dynamic Elements
 
Practical ERSync
Practical ERSyncPractical ERSync
Practical ERSync
 
ERRest: the Basics
ERRest: the BasicsERRest: the Basics
ERRest: the Basics
 

Recently uploaded

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Recently uploaded (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Filtering data with D2W relationships in Direct to Web

  • 1. Filtering data with D2W Philippe Rabier - twitter.com/prabier Sophiacom
  • 2. What is the problem to solve?
  • 4. • Use D2W • Limit the visibility of the data • Use conventions to name relationships (for example, any toOne relationship to Company entity, is called company) • Minimize the code • Be magic! The Requirements
  • 6. First Solution Working at the editingContext level
  • 8. How the qualifier is modified? public void alterFetchSpecification(final NSNotification aNotification) { EOEditingContext ec = (EOEditingContext) aNotification.object(); if (shouldAddRestrictionQualifier) { Company aCompany = (NOClient) ec.userInfoForKey(NBEditingContextFactory.COMPANY_KEY); final EOFetchSpecification fs = (EOFetchSpecification) aNotification.userInfo().valueForKey(COEditingContext.FETCH_SPEC_KEY); if (aCompany != null && fs != null) { EOEntity aEntity = EOUtilities.entityNamed(ec, fs.entityName()); EOQualifier fsQualifier = fs.qualifier(); if (fsQualifier != null) { NSSet<String> keys = fsQualifier.allQualifierKeys(); for (String aKey : keys) { if (aKey.contains("company")) { shouldAddRestrictionQualifier = false; break; } } } if (shouldAddRestrictionQualifier) { EOQualifier aRestrictionQualifier = clientRestrictionQualifier(aEntity, aClient); if (aRestrictionQualifier != null) { if (fsQualifier != null) fsQualifier = new EOAndQualifier(new NSArray<EOQualifier>(new EOQualifier[] {fsQualifier, aRestrictionQualifier})); else fsQualifier = aRestrictionQualifier; fs.setQualifier(fsQualifier); } } } } }
  • 9. How the qualifier is modified? public EOQualifier companyRestrictionQualifier(final EOEntity entity, final Company company) { EOQualifier aQualifier = null; if (entity.name().equals(Company.Keys.ENTITY_NAME)) aQualifier = new EOKeyValueQualifier(Company.Keys.NAME, EOQualifier.QualifierOperatorEqual, company.name()); else if (entity.relationshipNamed("company") != null) aQualifier = new EOKeyValueQualifier("company", EOQualifier.QualifierOperatorEqual, company); else if (entity.relationshipNamed("entityB") != null) aQualifier = new EOKeyValueQualifier("entityB.company", EOQualifier.QualifierOperatorEqual, client); else if (entity.relationshipNamed("entityC") != null) ...; if (log.isDebugEnabled()) log.debug("method: qualifier: " + aQualifier); return aQualifier; }
  • 10. It works great but there is a little problem it’s too low level
  • 11. An Example of Problem public void validateForSave() throws ValidationException { super.validateForSave(); ERXEOControlUtilities.validateUniquenessOf(this, NOUser.Keys.LOGIN); ERXEOControlUtilities.validateUniquenessOf(this, NOUser.Keys.EMAIL); } public void validateForSave() throws ValidationException { super.validateForSave(); editingContext().setUserInfoForKey(Boolean.FALSE, NBEditingContextFactory.NO_RESTRICTION_QUAL_KEY); ERXEOControlUtilities.validateUniquenessOf(this, NOUser.Keys.LOGIN); ERXEOControlUtilities.validateUniquenessOf(this, NOUser.Keys.EMAIL); editingContext().setUserInfoForKey(Boolean.TRUE, NBEditingContextFactory.NO_RESTRICTION_QUAL_KEY); }
  • 13. • Displaying a list • Using a query component • Using ERD2WEditToManyRelationship component • Using ERD2WEditToOneRelationship component When should we filter?
  • 14. • Modify the NavigationController object • Change the data source Displaying a list public WOComponent listPageForEntityName(final String entityName) { ListPageInterface newListPageInterface = D2W.factory().listPageForEntityNamed(entityName, session()); EODatabaseDataSource dataSource = new EODatabaseDataSource(ERXEC.newEditingContext(), entityName); EOEntity entity = ERXEOAccessUtilities.entityNamed(null, entityName); EOQualifier auxQual = NBBusinessLogicPrincipal.getSharedInstance().clientRestrictionQualifier(entity, ((Session)session()).getCompany()); dataSource.setAuxiliaryQualifier(auxQual); newListPageInterface.setDataSource(dataSource); return (WOComponent) newListPageInterface; }
  • 15. • Use a query delegate • Override the method queryDataSource(ERD2WQueryPage sender) Using a query component { author = 100; class = "com.webobjects.directtoweb.Rule"; lhs = { class = "com.webobjects.eocontrol.EOKeyValueQualifier"; key = pageConfiguration; selectorName = isEqualTo; value = QueryMyEntity; }; rhs = { class = "er.directtoweb.ERDDelayedObjectCreationAssignment"; keyPath = queryDataSourceDelegate; value = "ca.wowodc.very.util.pascal.delegate.SomeOneElse"; }; }
  • 16. • Maybe subclass the 2 component is the best solution • Use restrictingFetchSpecification key. If all fetchspec have the same name, it’s possible to build a generic rule. • Need to be modified to add the possibility to set a binding to the fetchspec • Maybe a lot of pain to create many fetchspec in the EOModel EditRelationship components
  • 17. How the qualifier is modified? public Object restrictedChoiceList() { String restrictedChoiceKey=(String)d2wContext().valueForKey("restrictedChoiceKey"); if( restrictedChoiceKey!=null && restrictedChoiceKey.length()>0 ) return valueForKeyPath(restrictedChoiceKey); String fetchSpecName=(String)d2wContext().valueForKey("restrictingFetchSpecification"); if(fetchSpecName != null) { EORelationship relationship = ERXUtilities.relationshipWithObjectAndKeyPath(object(), (String)d2wContext().valueForKey("propertyKey")); if(relationship != null) return EOUtilities.objectsWithFetchSpecificationAndBindings(object().editingContext(), relationship.destinationEntity().name(),fetchSpecName,null); } return null; }