SlideShare a Scribd company logo
1 of 19
Build your datatypes
About me

•   Edi Modrić
•   Computer engineering masters degree
•   Working at Netgen for 5 years
    •   1 year of .Net development
    •   4 years of eZ Publish development
    •   Certified eZ Publish developer
    •   eZ Tags maintainer
    •   Collaborating with eZ Systems on ezp-next for 8 months


•   @emodric
•   edi@netgen.hr
Agenda

•   Primary agendas
    •   Build a field type using public API
    •   Test the hell out of it

•   Secondary agendas (if time permits)
    •   Comparison to legacy datatypes
    •   Integration with eZ Publish 5 using Symfony
Workshop

•   One hour of coding
    •   Try to build the field type and test it
•   Ideas
    •   Try to port your existing datatype OR
    •   Try to modify the one presented today OR
    •   Some examples
        •   Storing dates < 1.1.1970
        •   Storing and validating IP address
        •   Storing and validating social security number
        •   …
•   Work in groups, help each other
What is a datatype?

•   Base building block of all content in eZ Publish
    •   Collection of methods to store, read and validate content


•   Object oriented architecture of content model

•   Class – blueprint of a single piece of content
    •   Collection of class attributes, which are of some (data)type


•   Object – a single piece of content
    •   Instance of a class
    •   Collection of object attributes, values of class attribute
What is a datatype?
Datatype + public API = field type

•   Initial idea was to demo the eZ Tags datatype
    •   Complicated
    •   We’re time limited


•   eZ Publish 5 is nearly here
    •   Demo the future, not the past
Datatype + public API = field type

•   Content class = Content type
•   Content object = Content
•   Content class attribute = Field definition
•   Content object attribute = Field
•   Object attribute content = Field value
•   Datatype = Field type
Datatype + public API = field type

•   $ cd /var/www/ezp-next/
•   $ rm –rf settings/
•   $ git remote add emodric
    https://github.com/emodric/ezp-
    next.git
•   $ git checkout -b nginteger
•   $ git pull emodric nginteger
•   $ php composer.phar update --dev
•   $ ./Netgen/runtests.sh
Datatype + public API = field type
Datatype + public API = field type

•   eZPublishSPIFieldTypeFieldType
    •   getFieldTypeIdentifier
    •   acceptValue / getEmptyValue
    •   fromHash / toHash
    •   fromPersistenceValue / toPersistenceValue
    •   getSettingsSchema / getValidatorConfigurationSchema
    •   validateFieldSettings / validateValidatorConfiguration
    •   validate
    •   getName
    •   isSearchable
Datatype + public API = field type

•   eZPublishSPIFieldTypeFieldStorage
    •   storeFieldData
    •   getFieldData
    •   deleteFieldData
    •   hasFieldData
    •   getIndexData


•   eZPublishSPIFieldTypeIndexable

•   eZPublishSPIFieldTypeValidationError
Datatype + public API = field type

•   eZPublishCoreFieldTypeFieldType
    •   Abstract that implements …SPIFieldTypeFieldType
    •   Default behavior of some methods + validator handling


•   eZPublishCoreFieldType[GatewayBasedStorage|Null
    Storage]
    •   Abstracts that implement …SPIFieldTypeFieldStorage


•   eZPublishCoreFieldTypeStorageGateway
    •   Abstract for gateways to external storage
    •   used by GatewayBasedStorage
Datatype + public API = field type

•   eZPublishCoreFieldTypeValue
    •   Abstract for field value
    •   Optional, but should be included


•   eZPublishCoreFieldTypeValidationError
    •   Implementation of …SPIFieldTypeValidationError


•   eZPublishCoreFieldTypeValidator
    •   Abstract for all validators to extend


•   eZPublishCoreFieldTypeFileService
“I thought I fixed that” - why testing matters

•   Testing is an integral part of any software development
     •   Keeps your code rock solid
     •   Feature and future proof
     •   Gives you a piece of mind


•   Testing framework in ezp-next is preconfigured BUT
     •   One „hack” is needed if you’re using external storage
         •   Updating database schema fixtures
         •   eZPublishCorePersistenceLegacyTests_fixtures
             schema.sqlite.sql
     •   Dependency injection configuration
“I thought I fixed that” - why testing matters

•   Testing field type integration with public API
     •   Using real world implementation of repository
     •   Tests if our field type plays well with others


•   Testing field type integration with persistence SPI
     •   Hooks directly into persistence implementation
     •   Tests if our field type stores and loads data correctly


•   Unit testing of the field type
     •   Tests the field type methods (units), one by one
What about legacy stack?

•   Legacy datatypes are not going anywhere
    •   No admin interface based on Symfony stack
    •   To actually use your field type, you WILL need legacy datatype


•   https://github.com/emodric/nginteger.git
    •   Legacy datatype prepared for comparison
Field type vs. datatype

•   No difference in functionality

•   Advantages over datatypes is obvious
    •   Much much much easier testing
    •   Clear separation of concerns
        •   No POST variables
        •   No SQL
        •   No file uploads
    •   More readable and understandable code
    •   Object oriented code
Q&A


42

Edi Modrić
  emodric
edi@netgen.hr

More Related Content

What's hot

What's hot (20)

Design for scale
Design for scaleDesign for scale
Design for scale
 
Java Persistence API (JPA) - A Brief Overview
Java Persistence API (JPA) - A Brief OverviewJava Persistence API (JPA) - A Brief Overview
Java Persistence API (JPA) - A Brief Overview
 
.NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA...
.NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA....NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA...
.NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA...
 
Webservices: The RESTful Approach
Webservices: The RESTful ApproachWebservices: The RESTful Approach
Webservices: The RESTful Approach
 
AWS CDK: Infrastructure in TypeScript
AWS CDK: Infrastructure in TypeScriptAWS CDK: Infrastructure in TypeScript
AWS CDK: Infrastructure in TypeScript
 
TypeScript and Angular2 (Love at first sight)
TypeScript and Angular2 (Love at first sight)TypeScript and Angular2 (Love at first sight)
TypeScript and Angular2 (Love at first sight)
 
Not Just ORM: Powerful Hibernate ORM Features and Capabilities
Not Just ORM: Powerful Hibernate ORM Features and CapabilitiesNot Just ORM: Powerful Hibernate ORM Features and Capabilities
Not Just ORM: Powerful Hibernate ORM Features and Capabilities
 
ML Platform 2018 Q2 Meetup - Search Relevance Debugging at LinkedIn
ML Platform 2018 Q2 Meetup - Search Relevance Debugging at LinkedInML Platform 2018 Q2 Meetup - Search Relevance Debugging at LinkedIn
ML Platform 2018 Q2 Meetup - Search Relevance Debugging at LinkedIn
 
Hands on Gradle
Hands on GradleHands on Gradle
Hands on Gradle
 
Domain Specific Development using T4
Domain Specific Development using T4Domain Specific Development using T4
Domain Specific Development using T4
 
Solr
SolrSolr
Solr
 
Webium: Page Objects In Python (Eng)
Webium: Page Objects In Python (Eng)Webium: Page Objects In Python (Eng)
Webium: Page Objects In Python (Eng)
 
.NET Core 3.0 - What's new?
.NET Core 3.0 - What's new?.NET Core 3.0 - What's new?
.NET Core 3.0 - What's new?
 
Parse - Backend as a Service
Parse - Backend as a ServiceParse - Backend as a Service
Parse - Backend as a Service
 
PG Day'14 Russia, Secure PostgreSQL Deployment, Magnus Hagander
PG Day'14 Russia, Secure PostgreSQL Deployment, Magnus HaganderPG Day'14 Russia, Secure PostgreSQL Deployment, Magnus Hagander
PG Day'14 Russia, Secure PostgreSQL Deployment, Magnus Hagander
 
Tricks
TricksTricks
Tricks
 
C# 8 and .NET Core 3
C# 8 and .NET Core 3C# 8 and .NET Core 3
C# 8 and .NET Core 3
 
Selenium Online Training
Selenium Online Training Selenium Online Training
Selenium Online Training
 
Api mation
Api mationApi mation
Api mation
 
Core Data in Modern Times
Core Data in Modern TimesCore Data in Modern Times
Core Data in Modern Times
 

Viewers also liked

Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...
Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...
Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...
Michael Pirnat
 

Viewers also liked (12)

Proposal
ProposalProposal
Proposal
 
Ok shazam, "la la-lalaa"!
Ok shazam, "la la-lalaa"!Ok shazam, "la la-lalaa"!
Ok shazam, "la la-lalaa"!
 
Comparing web frameworks
Comparing web frameworksComparing web frameworks
Comparing web frameworks
 
BDD by example
BDD by exampleBDD by example
BDD by example
 
Neo4j: Graph-like power
Neo4j: Graph-like powerNeo4j: Graph-like power
Neo4j: Graph-like power
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 application
 
Symfony War Stories
Symfony War StoriesSymfony War Stories
Symfony War Stories
 
Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...
Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...
Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10 Web App Vulner...
 
Microservice architecture
Microservice architectureMicroservice architecture
Microservice architecture
 
Deploying Symfony2 app with Ansible
Deploying Symfony2 app with AnsibleDeploying Symfony2 app with Ansible
Deploying Symfony2 app with Ansible
 
Queue Data Structure (w/ php egs)
Queue Data Structure (w/ php egs)Queue Data Structure (w/ php egs)
Queue Data Structure (w/ php egs)
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
 

Similar to Build your datatypes

eZ Publish Summer Camp 2013 - Building custom field types
eZ Publish Summer Camp 2013 - Building custom field typeseZ Publish Summer Camp 2013 - Building custom field types
eZ Publish Summer Camp 2013 - Building custom field types
Edi Modrić
 

Similar to Build your datatypes (20)

eZ Publish Summer Camp 2013 - Building custom field types
eZ Publish Summer Camp 2013 - Building custom field typeseZ Publish Summer Camp 2013 - Building custom field types
eZ Publish Summer Camp 2013 - Building custom field types
 
Introduction to Monsoon PHP framework
Introduction to Monsoon PHP frameworkIntroduction to Monsoon PHP framework
Introduction to Monsoon PHP framework
 
Beyond Domino Designer
Beyond Domino DesignerBeyond Domino Designer
Beyond Domino Designer
 
Selenium-with-Java-Course-Content-Magnitia.pdf
Selenium-with-Java-Course-Content-Magnitia.pdfSelenium-with-Java-Course-Content-Magnitia.pdf
Selenium-with-Java-Course-Content-Magnitia.pdf
 
Selenium-with-Java-Course-Content-Magnitia.pdf
Selenium-with-Java-Course-Content-Magnitia.pdfSelenium-with-Java-Course-Content-Magnitia.pdf
Selenium-with-Java-Course-Content-Magnitia.pdf
 
DanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino APIDanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino API
 
Gaej For Beginners
Gaej For BeginnersGaej For Beginners
Gaej For Beginners
 
Typescript Fundamentals
Typescript FundamentalsTypescript Fundamentals
Typescript Fundamentals
 
Search api d8
Search api d8Search api d8
Search api d8
 
初心者向けGAE/Java説明資料
初心者向けGAE/Java説明資料初心者向けGAE/Java説明資料
初心者向けGAE/Java説明資料
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
State of search | drupal dinner
State of search | drupal dinnerState of search | drupal dinner
State of search | drupal dinner
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
Zero to Sixty with Oracle ApEx
Zero to Sixty with Oracle ApExZero to Sixty with Oracle ApEx
Zero to Sixty with Oracle ApEx
 
Pouring Coffee Into the Matrix: Building Java Applications on Neo4j
Pouring Coffee Into the Matrix: Building Java Applications on Neo4jPouring Coffee Into the Matrix: Building Java Applications on Neo4j
Pouring Coffee Into the Matrix: Building Java Applications on Neo4j
 
How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)
 
hibernateormfeatures-140223193044-phpapp02.pdf
hibernateormfeatures-140223193044-phpapp02.pdfhibernateormfeatures-140223193044-phpapp02.pdf
hibernateormfeatures-140223193044-phpapp02.pdf
 
Software design with Domain-driven design
Software design with Domain-driven design Software design with Domain-driven design
Software design with Domain-driven design
 
How to Use Selenium, Successfully
How to Use Selenium, SuccessfullyHow to Use Selenium, Successfully
How to Use Selenium, Successfully
 
Test driving Azure Search and DocumentDB
Test driving Azure Search and DocumentDBTest driving Azure Search and DocumentDB
Test driving Azure Search and DocumentDB
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 

Build your datatypes

  • 2. About me • Edi Modrić • Computer engineering masters degree • Working at Netgen for 5 years • 1 year of .Net development • 4 years of eZ Publish development • Certified eZ Publish developer • eZ Tags maintainer • Collaborating with eZ Systems on ezp-next for 8 months • @emodric • edi@netgen.hr
  • 3. Agenda • Primary agendas • Build a field type using public API • Test the hell out of it • Secondary agendas (if time permits) • Comparison to legacy datatypes • Integration with eZ Publish 5 using Symfony
  • 4. Workshop • One hour of coding • Try to build the field type and test it • Ideas • Try to port your existing datatype OR • Try to modify the one presented today OR • Some examples • Storing dates < 1.1.1970 • Storing and validating IP address • Storing and validating social security number • … • Work in groups, help each other
  • 5. What is a datatype? • Base building block of all content in eZ Publish • Collection of methods to store, read and validate content • Object oriented architecture of content model • Class – blueprint of a single piece of content • Collection of class attributes, which are of some (data)type • Object – a single piece of content • Instance of a class • Collection of object attributes, values of class attribute
  • 6. What is a datatype?
  • 7. Datatype + public API = field type • Initial idea was to demo the eZ Tags datatype • Complicated • We’re time limited • eZ Publish 5 is nearly here • Demo the future, not the past
  • 8. Datatype + public API = field type • Content class = Content type • Content object = Content • Content class attribute = Field definition • Content object attribute = Field • Object attribute content = Field value • Datatype = Field type
  • 9. Datatype + public API = field type • $ cd /var/www/ezp-next/ • $ rm –rf settings/ • $ git remote add emodric https://github.com/emodric/ezp- next.git • $ git checkout -b nginteger • $ git pull emodric nginteger • $ php composer.phar update --dev • $ ./Netgen/runtests.sh
  • 10. Datatype + public API = field type
  • 11. Datatype + public API = field type • eZPublishSPIFieldTypeFieldType • getFieldTypeIdentifier • acceptValue / getEmptyValue • fromHash / toHash • fromPersistenceValue / toPersistenceValue • getSettingsSchema / getValidatorConfigurationSchema • validateFieldSettings / validateValidatorConfiguration • validate • getName • isSearchable
  • 12. Datatype + public API = field type • eZPublishSPIFieldTypeFieldStorage • storeFieldData • getFieldData • deleteFieldData • hasFieldData • getIndexData • eZPublishSPIFieldTypeIndexable • eZPublishSPIFieldTypeValidationError
  • 13. Datatype + public API = field type • eZPublishCoreFieldTypeFieldType • Abstract that implements …SPIFieldTypeFieldType • Default behavior of some methods + validator handling • eZPublishCoreFieldType[GatewayBasedStorage|Null Storage] • Abstracts that implement …SPIFieldTypeFieldStorage • eZPublishCoreFieldTypeStorageGateway • Abstract for gateways to external storage • used by GatewayBasedStorage
  • 14. Datatype + public API = field type • eZPublishCoreFieldTypeValue • Abstract for field value • Optional, but should be included • eZPublishCoreFieldTypeValidationError • Implementation of …SPIFieldTypeValidationError • eZPublishCoreFieldTypeValidator • Abstract for all validators to extend • eZPublishCoreFieldTypeFileService
  • 15. “I thought I fixed that” - why testing matters • Testing is an integral part of any software development • Keeps your code rock solid • Feature and future proof • Gives you a piece of mind • Testing framework in ezp-next is preconfigured BUT • One „hack” is needed if you’re using external storage • Updating database schema fixtures • eZPublishCorePersistenceLegacyTests_fixtures schema.sqlite.sql • Dependency injection configuration
  • 16. “I thought I fixed that” - why testing matters • Testing field type integration with public API • Using real world implementation of repository • Tests if our field type plays well with others • Testing field type integration with persistence SPI • Hooks directly into persistence implementation • Tests if our field type stores and loads data correctly • Unit testing of the field type • Tests the field type methods (units), one by one
  • 17. What about legacy stack? • Legacy datatypes are not going anywhere • No admin interface based on Symfony stack • To actually use your field type, you WILL need legacy datatype • https://github.com/emodric/nginteger.git • Legacy datatype prepared for comparison
  • 18. Field type vs. datatype • No difference in functionality • Advantages over datatypes is obvious • Much much much easier testing • Clear separation of concerns • No POST variables • No SQL • No file uploads • More readable and understandable code • Object oriented code
  • 19. Q&A 42 Edi Modrić emodric edi@netgen.hr