In this presentation, we'll explore React’s “Component” based world. We'll go through Virtual DOM, how it works, and React's Virtual DOM vs. the real DOM.
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Bill Buchan
Co-presented with Jens Augustini
Object Oriented Programming (OOP) may drastically reduce your coding time in projects that reach a higher degree of complexity, as it brings re-usable and consistent logic in the form of your own objects to your fingertips. This session will show how to create and use your own classes and how they can relate to the LotusScript Object Model. If you are familiar with LotusScript but don't know how to create your own classes, this session is for you!
In this presentation, we'll explore React’s “Component” based world. We'll go through Virtual DOM, how it works, and React's Virtual DOM vs. the real DOM.
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Bill Buchan
Co-presented with Jens Augustini
Object Oriented Programming (OOP) may drastically reduce your coding time in projects that reach a higher degree of complexity, as it brings re-usable and consistent logic in the form of your own objects to your fingertips. This session will show how to create and use your own classes and how they can relate to the LotusScript Object Model. If you are familiar with LotusScript but don't know how to create your own classes, this session is for you!
Spring boot is a suite, pre-configured, pre-sugared set of frameworks/technologies to reduce boilerplate configuration providing you the shortest way to have a Spring web application up and running with smallest line of code/configuration out-of-the-box.
Copy of the slides from the Advanced Web Development Workshop presented by Ed Bachta, Charlie Moad and Robert Stein of the Indianapolis Museum of Art during the Museums and the Web 2008 conference in Montreal
Builiding Modular monoliths that can scale to microservices. JBCNConf 2021David Gómez García
It’s easy these days to fall into the trap of starting to design your whole application with a microservices architecture…. Because, you know, that’s what everyone is doing. Aren't they?
But, are we considering the microservices architecture as a goal or as a means to a purpose?
In this talk, we will go back to the basics and see how DDD, CQRS and EventSourcing practices drive our application design and evolution so that we will start with a monolith. Still, we will have the ability to scale into microservices more or less easily when (and more importantly: if) we need to.
These are the slides I used in my talk at JBCNConf 2021.
Reaching for the Future with Web Components and PolymerFITC
Save 10% off ANY FITC event with discount code 'slideshare'
See our upcoming events at www.fitc.ca
OVERVIEW
Web Components allow us to view web applications as a set of encapsulated, maintainable and reusable components, an approach which is necessary for scalability and large applications. However, they rely on the use of emerging web platform features such as the Shadow DOM, HTML Imports and Custom elements, which currently have limited browser support. But thanks to the Polymer project - a set of polyfills and an application framework using these principles – Web Components can be used today. They are bleeding edge, likely to change a bit and simultaneously insanely cool and undeniably useful. Michael Labriola invites attendees to learn how to integrate these pieces into their processes today, to bring sanity and reuse to their worlds as a result.
A distributed computer system consists of multiple software components that are on multiple computers, but run as a single system. The computers that are in a distributed system can be physically close together and connected by a local network, or they can be geographically distant and connected by a wide area network.
How Android Architecture Components can Help You Improve Your App’s Design?Paul Cook
Choosing the right app architecture can be quite challenging at times? But not anymore with Android app architecture and companion architecture components! Find out how new architecture components can help you enhance your app’s design and make your Android app development profitable.
Spring boot is a suite, pre-configured, pre-sugared set of frameworks/technologies to reduce boilerplate configuration providing you the shortest way to have a Spring web application up and running with smallest line of code/configuration out-of-the-box.
Copy of the slides from the Advanced Web Development Workshop presented by Ed Bachta, Charlie Moad and Robert Stein of the Indianapolis Museum of Art during the Museums and the Web 2008 conference in Montreal
Builiding Modular monoliths that can scale to microservices. JBCNConf 2021David Gómez García
It’s easy these days to fall into the trap of starting to design your whole application with a microservices architecture…. Because, you know, that’s what everyone is doing. Aren't they?
But, are we considering the microservices architecture as a goal or as a means to a purpose?
In this talk, we will go back to the basics and see how DDD, CQRS and EventSourcing practices drive our application design and evolution so that we will start with a monolith. Still, we will have the ability to scale into microservices more or less easily when (and more importantly: if) we need to.
These are the slides I used in my talk at JBCNConf 2021.
Reaching for the Future with Web Components and PolymerFITC
Save 10% off ANY FITC event with discount code 'slideshare'
See our upcoming events at www.fitc.ca
OVERVIEW
Web Components allow us to view web applications as a set of encapsulated, maintainable and reusable components, an approach which is necessary for scalability and large applications. However, they rely on the use of emerging web platform features such as the Shadow DOM, HTML Imports and Custom elements, which currently have limited browser support. But thanks to the Polymer project - a set of polyfills and an application framework using these principles – Web Components can be used today. They are bleeding edge, likely to change a bit and simultaneously insanely cool and undeniably useful. Michael Labriola invites attendees to learn how to integrate these pieces into their processes today, to bring sanity and reuse to their worlds as a result.
A distributed computer system consists of multiple software components that are on multiple computers, but run as a single system. The computers that are in a distributed system can be physically close together and connected by a local network, or they can be geographically distant and connected by a wide area network.
How Android Architecture Components can Help You Improve Your App’s Design?Paul Cook
Choosing the right app architecture can be quite challenging at times? But not anymore with Android app architecture and companion architecture components! Find out how new architecture components can help you enhance your app’s design and make your Android app development profitable.
Similar to create-netflix-clone-03-server_transcript.pdf (20)
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
UiPath Test Automation using UiPath Test Suite series, part 4
create-netflix-clone-03-server_transcript.pdf
1. Creating a Netflix Clone
III
In the 3rd part we’ll dive right into the model objects representing the server and ultimately the front end code. If you’re unfamiliar with entities, JPA, UUID etc. I suggest
going back to the previous modules and refreshing your memory a bit as we’ll build a lot on top of that.
One way in which this will be different though is the usage of Lombok which will make the code far more terse.
Still the code here is mostly mock. The real world Netflix has a lot of code but most of it applies to algorithmic scheduling, user management, scaling etc. All of these
aren’t applicable here.
In this lesson our focus will be on entities and Data Transfer Objects also known as DTOs which I sometimes mixed with data access objects or DAO. There is overlap
between both of those concepts but what we have is generally DTOs as they transfer data to the client. They don’t just abstract the database layer.
2. codenameone.com github.com/codenameone/CodenameOne
Server Internals
In the 3rd part we’ll dive right into the model objects representing the server and ultimately the front end code. If you’re unfamiliar with entities, JPA, UUID etc. I suggest
going back to the previous modules and refreshing your memory a bit as we’ll build a lot on top of that.
One way in which this will be different though is the usage of Lombok which will make the code far more terse.
Still the code here is mostly mock. The real world Netflix has a lot of code but most of it applies to algorithmic scheduling, user management, scaling etc. All of these
aren’t applicable here.
In this lesson our focus will be on entities and Data Transfer Objects also known as DTOs which I sometimes mixed with data access objects or DAO. There is overlap
between both of those concepts but what we have is generally DTOs as they transfer data to the client. They don’t just abstract the database layer.
3. codenameone.com github.com/codenameone/CodenameOne
Server Internals
Now that we know Lombok basics we can move on to the server
The code is mostly mock code
We’ll start with the entity model code first
In the 3rd part we’ll dive right into the model objects representing the server and ultimately the front end code. If you’re unfamiliar with entities, JPA, UUID etc. I suggest
going back to the previous modules and refreshing your memory a bit as we’ll build a lot on top of that.
One way in which this will be different though is the usage of Lombok which will make the code far more terse.
Still the code here is mostly mock. The real world Netflix has a lot of code but most of it applies to algorithmic scheduling, user management, scaling etc. All of these
aren’t applicable here.
In this lesson our focus will be on entities and Data Transfer Objects also known as DTOs which I sometimes mixed with data access objects or DAO. There is overlap
between both of those concepts but what we have is generally DTOs as they transfer data to the client. They don’t just abstract the database layer.
4. @Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Content {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
private String name;
private String description;
@OneToOne
private Media heroImage;
@OneToOne
private Media icon;
@OneToOne
private Media logo;
@ManyToMany
private Set<Media> videos;
public ContentDTO getDTO() {
Map<VideoQuality, String> qualityUrls = videos.stream().
collect(Collectors.
Source Listing - Content
codenameone.com github.com/codenameone/CodenameOne
Writing an entity with Lombok is much easier. There are no, getters, setters, constructors, equals, hash code etc. Notice we still use JPA just like we used to so we have
the JPA entity annotation and then the Lombok annotations.
5. @Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Content {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
private String name;
private String description;
@OneToOne
private Media heroImage;
@OneToOne
private Media icon;
@OneToOne
private Media logo;
@ManyToMany
private Set<Media> videos;
public ContentDTO getDTO() {
Map<VideoQuality, String> qualityUrls = videos.stream().
collect(Collectors.
Source Listing - Content
codenameone.com github.com/codenameone/CodenameOne
Everything works as you would expect including the primary key definition etc. Notice I chose to go with a UUID object as a primary key coupled with auto-generation.
That’s a much simpler trick than the one I picked in previous modules.
6. codenameone.com github.com/codenameone/CodenameOne
UUID Keys
Strings as keys are important, they eliminate scanning attacks
JPA lets us use the UUID class and the rest is pretty much seamless
This could be costly for RDBMS inserts
Unless you’re doing millions of inserts this shouldn’t be a problem
We already talked about using strings for keys. When we use a UUID object we get a long string that isn’t guessable in the database. That means that we can expose
that primary key to the end user without worrying that he might use it to scan through details of other users as the string is pretty long and hard to guess.
As we saw, we just need to use the UUID object type. There are several other strategies for generating a UUID in JPA. I chose the simplest one, it might not be the best
one but it is convenient.
So why doesn’t everyone use this approach?
Turns out it’s much slower than using numeric auto-increment values on a database column. DB’s such as MySQL are heavily optimised for auto-increment fields and
String based primary keys are just slower to insert. Some developers consider that a non-starter especially when looking at the performance graph which is “scary”.
Performance really takes a dive for insert operations while it remains flat when using long auto-increment fields.
Personally I don’t think that’s a problem even for a video app like this. You wouldn’t insert too often and read operations are still pretty fast. This might become an issue if
you have a log or auditing table that might include multiple insert operations per second. At that point you’d need to use a long for the primary key and make sure never
to expose it externally.
7. @Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Content {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
private String name;
private String description;
@OneToOne
private Media heroImage;
@OneToOne
private Media icon;
@OneToOne
private Media logo;
@ManyToMany
private Set<Media> videos;
public ContentDTO getDTO() {
Map<VideoQuality, String> qualityUrls = videos.stream().
collect(Collectors.
toMap(Media::getQuality,
Media::getMediaURL));
return new ContentDTO(id.toString(),
Source Listing - Content
codenameone.com github.com/codenameone/CodenameOne
The name and description fields correspond to these fields in the database. This is the entire definition as the accessors are generated automatically
8. @Data
@AllArgsConstructor
@NoArgsConstructor
public class Content {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
private String name;
private String description;
@OneToOne
private Media heroImage;
@OneToOne
private Media icon;
@OneToOne
private Media logo;
@ManyToMany
private Set<Media> videos;
public ContentDTO getDTO() {
Map<VideoQuality, String> qualityUrls = videos.stream().
collect(Collectors.
toMap(Media::getQuality,
Media::getMediaURL));
return new ContentDTO(id.toString(),
name, description,
getMedia(heroImage), getMedia(icon),
getMedia(logo), qualityUrls);
Source Listing - Content
codenameone.com github.com/codenameone/CodenameOne
We have three one to one media relations. These include the three images for every content item. Specifically:
- The hero image which is the big picture that appears on top of the application
- The show logo is displayed on top of the hero image. It’s a separate image to support different device aspect ratio and layout
- The icon is the image representing a show within the list
9. @Data
@AllArgsConstructor
@NoArgsConstructor
public class Content {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
private String name;
private String description;
@OneToOne
private Media heroImage;
@OneToOne
private Media icon;
@OneToOne
private Media logo;
@ManyToMany
private Set<Media> videos;
public ContentDTO getDTO() {
Map<VideoQuality, String> qualityUrls = videos.stream().
collect(Collectors.
toMap(Media::getQuality,
Media::getMediaURL));
return new ContentDTO(id.toString(),
name, description,
getMedia(heroImage), getMedia(icon),
getMedia(logo), qualityUrls);
Source Listing - Content
codenameone.com github.com/codenameone/CodenameOne
Finally we have the actual video files which we store in media objects as well. We can have multiple video files representing different quality levels of the video. In real life
we can have even more options such as different aspect ratios, languages etc.
Normally I would like this to be a Map between quality and media but this is a bit challenging to represent correctly in JPA so I left this as a simple set.
10. @OneToOne
private Media heroImage;
@OneToOne
private Media icon;
@OneToOne
private Media logo;
@ManyToMany
private Set<Media> videos;
public ContentDTO getDTO() {
Map<VideoQuality, String> qualityUrls = videos.stream().
collect(Collectors.
toMap(Media::getQuality,
Media::getMediaURL));
return new ContentDTO(id.toString(),
name, description,
getMedia(heroImage), getMedia(icon),
getMedia(logo), qualityUrls);
}
private byte[] getMedia(Media m) {
return m == null ? null : m.getMedia();
}
}
Source Listing - Content
codenameone.com github.com/codenameone/CodenameOne
For convenience we place the DTO creation within the entity object. This code is mostly just the construction but it there’s one block where we convert the media objects
11. @OneToOne
private Media heroImage;
@OneToOne
private Media icon;
@OneToOne
private Media logo;
@ManyToMany
private Set<Media> videos;
public ContentDTO getDTO() {
Map<VideoQuality, String> qualityUrls = videos.stream().
collect(Collectors.
toMap(Media::getQuality,
Media::getMediaURL));
return new ContentDTO(id.toString(),
name, description,
getMedia(heroImage), getMedia(icon),
getMedia(logo), qualityUrls);
}
private byte[] getMedia(Media m) {
return m == null ? null : m.getMedia();
}
}
Source Listing - Content
codenameone.com github.com/codenameone/CodenameOne
Map<VideoQuality, String> qualityUrls = new HashMap<>();
for (Media video : videos) {
qualityUrls.put(video.getQuality(), video.getMediaURL());
}
In the DTO it makes more sense to hold the media as a map instead of a list or set. So we translate the video to to a map.
I find the stream syntax a bit obtuse sometimes. This is how it would look with a standard for loop. Essentially for each element we replace the content with a map where
the key is the quality and the value is the media URL.
12. @OneToOne
private Media heroImage;
@OneToOne
private Media icon;
@OneToOne
private Media logo;
@ManyToMany
private Set<Media> videos;
public ContentDTO getDTO() {
Map<VideoQuality, String> qualityUrls = videos.stream().
collect(Collectors.
toMap(Media::getQuality,
Media::getMediaURL));
return new ContentDTO(id.toString(),
name, description,
getMedia(heroImage), getMedia(icon),
getMedia(logo), qualityUrls);
}
private byte[] getMedia(Media m) {
return m == null ? null : m.getMedia();
}
}
Source Listing - Content
codenameone.com github.com/codenameone/CodenameOne
Once this is done we create a new DTO object with the automatic constructor and return it.
13. @OneToOne
private Media heroImage;
@OneToOne
private Media icon;
@OneToOne
private Media logo;
@ManyToMany
private Set<Media> videos;
public ContentDTO getDTO() {
Map<VideoQuality, String> qualityUrls = videos.stream().
collect(Collectors.
toMap(Media::getQuality,
Media::getMediaURL));
return new ContentDTO(id.toString(),
name, description,
getMedia(heroImage), getMedia(icon),
getMedia(logo), qualityUrls);
}
private byte[] getMedia(Media m) {
return m == null ? null : m.getMedia();
}
}
Source Listing - Content
codenameone.com github.com/codenameone/CodenameOne
And finally I also added a small helper method to make the code above a bit simpler. So we won’t get a null pointer exception if the media is null.
14. @Data
@AllArgsConstructor
@NoArgsConstructor
public class ContentDTO {
private String id;
private String name;
private String description;
private byte[] heroImage;
private byte[] icon;
private byte[] logo;
private Map<VideoQuality, String> videoUrls;
}
Source Listing - ContentDTO
codenameone.com github.com/codenameone/CodenameOne
This is the DTO object we just created. Notice it’s super simple and mostly consists of the Lombok annotations.
15. @Data
@AllArgsConstructor
@NoArgsConstructor
public class ContentDTO {
private String id;
private String name;
private String description;
private byte[] heroImage;
private byte[] icon;
private byte[] logo;
private Map<VideoQuality, String> videoUrls;
}
Source Listing - ContentDTO
codenameone.com github.com/codenameone/CodenameOne
The strings just map directly to the entity. There’s nothing to say here.
16. @Data
@AllArgsConstructor
@NoArgsConstructor
public class ContentDTO {
private String id;
private String name;
private String description;
private byte[] heroImage;
private byte[] icon;
private byte[] logo;
private Map<VideoQuality, String> videoUrls;
}
Source Listing - ContentDTO
codenameone.com github.com/codenameone/CodenameOne
For the media I chose to include the icons themselves. I could have taken the approach of returning URLs for the media which might have advantages in the future. For
now this is simpler but possibly not as efficient. Using a URL would have had the advantage of caching the data locally for future refreshes. Using the actual icon means
all the data is transferred with one request.
17. @Data
@AllArgsConstructor
@NoArgsConstructor
public class ContentDTO {
private String id;
private String name;
private String description;
private byte[] heroImage;
private byte[] icon;
private byte[] logo;
private Map<VideoQuality, String> videoUrls;
}
Source Listing - ContentDTO
codenameone.com github.com/codenameone/CodenameOne
This is the map we created for the media items. We already discussed this in the stream part before. It maps between the video quality enum and the string URL.
18. package com.codename1.demos.netflixclone.model;
public enum VideoQuality {
NONE,
LOW,
MEDIUM,
HIGH
}
Source Listing - VideoQuality
codenameone.com github.com/codenameone/CodenameOne
For the sake of completeness this is the video quality enum. Pretty simple but matches what we need right now.
19. @Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Media {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
private String name;
private String mimeType;
private Instant modified;
private long size;
@Lob
@Column(name = "media", columnDefinition="BLOB")
private byte[] media;
private String mediaURL;
private VideoQuality quality;
}
Source Listing - Media
codenameone.com github.com/codenameone/CodenameOne
The media entity is another standard Lombok entity with the standard trimmings.
20. @Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Media {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
private String name;
private String mimeType;
private Instant modified;
private long size;
@Lob
@Column(name = "media", columnDefinition="BLOB")
private byte[] media;
private String mediaURL;
private VideoQuality quality;
}
Source Listing - Media
codenameone.com github.com/codenameone/CodenameOne
We use the same UUID primary key generation logic
21. @Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Media {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
private String name;
private String mimeType;
private Instant modified;
private long size;
@Lob
@Column(name = "media", columnDefinition="BLOB")
private byte[] media;
private String mediaURL;
private VideoQuality quality;
}
Source Listing - Media
codenameone.com github.com/codenameone/CodenameOne
Rest of the stuff is pretty standard, notice that we store the modified time as an Instant instead of Date. Instant is a Java 8 date/time API class. It represents a timestamp
and is more convenient to use than date.
22. @Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Media {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
private String name;
private String mimeType;
private Instant modified;
private long size;
@Lob
@Column(name = "media", columnDefinition="BLOB")
private byte[] media;
private String mediaURL;
private VideoQuality quality;
}
Source Listing - Media
codenameone.com github.com/codenameone/CodenameOne
The media data is stored in blob storage in the database
23. @Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Media {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
private String name;
private String mimeType;
private Instant modified;
private long size;
@Lob
@Column(name = "media", columnDefinition="BLOB")
private byte[] media;
private String mediaURL;
private VideoQuality quality;
}
Source Listing - Media
codenameone.com github.com/codenameone/CodenameOne
Finally the URL to the media and the video quality enum are stored as well. That means we can have multiple instances of the same media object for various quality
levels.
One thing I didn’t cover here is the repositories for the entity objects. They’re all empty as we don’t need any finder methods for this specific demo so it’s all pretty trivial.