Creating a Facebook Clone - Part XXXVIII.pdfShaiAlmog1
The document discusses the implementation of posts, media, and comments for a Facebook clone application. Key points include:
- A Post entity supports one media file per post, comments, likes, and attachments through relationships to other entities.
- The PostDAO converts Post entities to plain Java objects for transferring data to and from the client.
- The PostService allows creating and sharing posts to friends' newsfeeds through repositories for posts, users, newsfeeds, comments, and media.
- The MediaService supports getting media attachments by ID, checking permissions and returning file data and metadata.
Creating a Facebook Clone - Part XIX - Transcript.pdfShaiAlmog1
The document describes the implementation of a Post entity and related classes for the backend of a Facebook clone. It includes:
1) A Post entity with fields like user, date, title, content, visibility, styling, comments, and likes.
2) Post, Comment, and related DAO classes to transfer data to and from clients.
3) PostRepository and CommentRepository interfaces extending CrudRepository for database operations.
4) Methods in PostRepository like findPostsByUser() and findAllPostsByUser() to retrieve posts by user with paging support.
Creating a Facebook Clone - Part XXXVIII.pdfShaiAlmog1
The document discusses the implementation of posts, media, and comments for a Facebook clone application. Key points include:
- A Post entity supports one media file per post, comments, likes, and attachments through relationships to other entities.
- The PostDAO converts Post entities to plain Java objects for transferring data to and from the client.
- The PostService allows creating and sharing posts to friends' newsfeeds through repositories for posts, users, newsfeeds, comments, and media.
- The MediaService supports getting media attachments by ID, checking permissions and returning file data and metadata.
Creating a Facebook Clone - Part XIX - Transcript.pdfShaiAlmog1
The document describes the implementation of a Post entity and related classes for the backend of a Facebook clone. It includes:
1) A Post entity with fields like user, date, title, content, visibility, styling, comments, and likes.
2) Post, Comment, and related DAO classes to transfer data to and from clients.
3) PostRepository and CommentRepository interfaces extending CrudRepository for database operations.
4) Methods in PostRepository like findPostsByUser() and findAllPostsByUser() to retrieve posts by user with paging support.
Creating a Facebook Clone - Part XX - Transcript.pdfShaiAlmog1
The document discusses the implementation of a Notification entity class that maps to database table and represents notifications for a social media user. The Notification class uses annotations like @Id, @ManyToOne and has fields for the notification ID, associated user, text, reaction details, date, whether it was read, and post/comment IDs. Getter and setter methods are also implemented.
Testdrevet javautvikling på objektorienterte skinnerTruls Jørgensen
The document discusses test-driven development and object-oriented programming principles in Java. It provides examples of using test data builders, object mothers, embedded Jetty servers, JSR 303 validation, and Spring MVC. Additional resources are referenced on testdata builders, object mothers, embedding Jetty, JSR 303, and Spring MVC. The conference JavaZoneX is mentioned.
The document describes code for implementing the server-side functionality of a WhatsApp clone. It includes classes for representing users, messages, and server connections. The Server class initializes user and message data from files, handles login/signup, and establishes a websocket connection for real-time messaging. It can send and receive messages when connected, or queue messages when offline.
Creating a Facebook Clone - Part XXXIII.pdfShaiAlmog1
The document describes a SearchForm class that is used to search for users and posts in a Facebook clone mobile application. The SearchForm class initializes a text field for search input and handles searching the backend API as the user types. It displays search results in an infinite scroll container and allows switching between searching users or posts.
The document describes a lawyer's journey learning web development and building their first two web applications in Go. It outlines how they learned HTML, CSS, and JavaScript from May to July 2014 before learning Go in mid-July 2014. By mid-August 2014, they had deployed their first application - a CRUD app using MySQL for persistence. By the end of August 2014, they deployed their second application - an API client that retrieved photos from Flickr and weather data for a random city. The document provides details on the structure, libraries, data structures, database functions, handler functions, and main function used in developing the applications.
This document discusses how to build REST services using Web API 2 in ASP.NET. It covers creating a ValuesController with GET, POST, PUT, and DELETE methods to perform basic CRUD operations. It also discusses using OData to expose entity data and enable querying with IQueryable. The document provides examples of configuring routes and enabling CORS to allow cross-origin requests.
The Duck Teaches Learn to debug from the masters. Local to production- kill ...ShaiAlmog1
The document outlines an agenda for a workshop on debugging techniques. The workshop covers installing tools, flow and breakpoints debugging, watching variables, Kubernetes debugging, and developer observability. Key techniques discussed include tracepoints, memory debugging, exception breakpoints, object marking, and logs, snapshots, and metrics for observability. The goal is to teach practical debugging skills that can be applied at scale in production environments like Kubernetes.
Creating a Facebook Clone - Part XX - Transcript.pdfShaiAlmog1
The document discusses the implementation of a Notification entity class that maps to database table and represents notifications for a social media user. The Notification class uses annotations like @Id, @ManyToOne and has fields for the notification ID, associated user, text, reaction details, date, whether it was read, and post/comment IDs. Getter and setter methods are also implemented.
Testdrevet javautvikling på objektorienterte skinnerTruls Jørgensen
The document discusses test-driven development and object-oriented programming principles in Java. It provides examples of using test data builders, object mothers, embedded Jetty servers, JSR 303 validation, and Spring MVC. Additional resources are referenced on testdata builders, object mothers, embedding Jetty, JSR 303, and Spring MVC. The conference JavaZoneX is mentioned.
The document describes code for implementing the server-side functionality of a WhatsApp clone. It includes classes for representing users, messages, and server connections. The Server class initializes user and message data from files, handles login/signup, and establishes a websocket connection for real-time messaging. It can send and receive messages when connected, or queue messages when offline.
Creating a Facebook Clone - Part XXXIII.pdfShaiAlmog1
The document describes a SearchForm class that is used to search for users and posts in a Facebook clone mobile application. The SearchForm class initializes a text field for search input and handles searching the backend API as the user types. It displays search results in an infinite scroll container and allows switching between searching users or posts.
The document describes a lawyer's journey learning web development and building their first two web applications in Go. It outlines how they learned HTML, CSS, and JavaScript from May to July 2014 before learning Go in mid-July 2014. By mid-August 2014, they had deployed their first application - a CRUD app using MySQL for persistence. By the end of August 2014, they deployed their second application - an API client that retrieved photos from Flickr and weather data for a random city. The document provides details on the structure, libraries, data structures, database functions, handler functions, and main function used in developing the applications.
This document discusses how to build REST services using Web API 2 in ASP.NET. It covers creating a ValuesController with GET, POST, PUT, and DELETE methods to perform basic CRUD operations. It also discusses using OData to expose entity data and enable querying with IQueryable. The document provides examples of configuring routes and enabling CORS to allow cross-origin requests.
The Duck Teaches Learn to debug from the masters. Local to production- kill ...ShaiAlmog1
The document outlines an agenda for a workshop on debugging techniques. The workshop covers installing tools, flow and breakpoints debugging, watching variables, Kubernetes debugging, and developer observability. Key techniques discussed include tracepoints, memory debugging, exception breakpoints, object marking, and logs, snapshots, and metrics for observability. The goal is to teach practical debugging skills that can be applied at scale in production environments like Kubernetes.
Skybuffer SAM4U tool for SAP license adoptionTatiana Kojar
Manage and optimize your license adoption and consumption with SAM4U, an SAP free customer software asset management tool.
SAM4U, an SAP complimentary software asset management tool for customers, delivers a detailed and well-structured overview of license inventory and usage with a user-friendly interface. We offer a hosted, cost-effective, and performance-optimized SAM4U setup in the Skybuffer Cloud environment. You retain ownership of the system and data, while we manage the ABAP 7.58 infrastructure, ensuring fixed Total Cost of Ownership (TCO) and exceptional services through the SAP Fiori interface.
In the rapidly evolving landscape of technologies, XML continues to play a vital role in structuring, storing, and transporting data across diverse systems. The recent advancements in artificial intelligence (AI) present new methodologies for enhancing XML development workflows, introducing efficiency, automation, and intelligent capabilities. This presentation will outline the scope and perspective of utilizing AI in XML development. The potential benefits and the possible pitfalls will be highlighted, providing a balanced view of the subject.
We will explore the capabilities of AI in understanding XML markup languages and autonomously creating structured XML content. Additionally, we will examine the capacity of AI to enrich plain text with appropriate XML markup. Practical examples and methodological guidelines will be provided to elucidate how AI can be effectively prompted to interpret and generate accurate XML markup.
Further emphasis will be placed on the role of AI in developing XSLT, or schemas such as XSD and Schematron. We will address the techniques and strategies adopted to create prompts for generating code, explaining code, or refactoring the code, and the results achieved.
The discussion will extend to how AI can be used to transform XML content. In particular, the focus will be on the use of AI XPath extension functions in XSLT, Schematron, Schematron Quick Fixes, or for XML content refactoring.
The presentation aims to deliver a comprehensive overview of AI usage in XML development, providing attendees with the necessary knowledge to make informed decisions. Whether you’re at the early stages of adopting AI or considering integrating it in advanced XML development, this presentation will cover all levels of expertise.
By highlighting the potential advantages and challenges of integrating AI with XML development tools and languages, the presentation seeks to inspire thoughtful conversation around the future of XML development. We’ll not only delve into the technical aspects of AI-powered XML development but also discuss practical implications and possible future directions.
This presentation provides valuable insights into effective cost-saving techniques on AWS. Learn how to optimize your AWS resources by rightsizing, increasing elasticity, picking the right storage class, and choosing the best pricing model. Additionally, discover essential governance mechanisms to ensure continuous cost efficiency. Whether you are new to AWS or an experienced user, this presentation provides clear and practical tips to help you reduce your cloud costs and get the most out of your budget.
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...alexjohnson7307
Predictive maintenance is a proactive approach that anticipates equipment failures before they happen. At the forefront of this innovative strategy is Artificial Intelligence (AI), which brings unprecedented precision and efficiency. AI in predictive maintenance is transforming industries by reducing downtime, minimizing costs, and enhancing productivity.
Digital Marketing Trends in 2024 | Guide for Staying AheadWask
https://www.wask.co/ebooks/digital-marketing-trends-in-2024
Feeling lost in the digital marketing whirlwind of 2024? Technology is changing, consumer habits are evolving, and staying ahead of the curve feels like a never-ending pursuit. This e-book is your compass. Dive into actionable insights to handle the complexities of modern marketing. From hyper-personalization to the power of user-generated content, learn how to build long-term relationships with your audience and unlock the secrets to success in the ever-shifting digital landscape.
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfChart Kalyan
A Mix Chart displays historical data of numbers in a graphical or tabular form. The Kalyan Rajdhani Mix Chart specifically shows the results of a sequence of numbers over different periods.
HCL Notes and Domino License Cost Reduction in the World of DLAUpanagenda
Webinar Recording: https://www.panagenda.com/webinars/hcl-notes-and-domino-license-cost-reduction-in-the-world-of-dlau/
The introduction of DLAU and the CCB & CCX licensing model caused quite a stir in the HCL community. As a Notes and Domino customer, you may have faced challenges with unexpected user counts and license costs. You probably have questions on how this new licensing approach works and how to benefit from it. Most importantly, you likely have budget constraints and want to save money where possible. Don’t worry, we can help with all of this!
We’ll show you how to fix common misconfigurations that cause higher-than-expected user counts, and how to identify accounts which you can deactivate to save money. There are also frequent patterns that can cause unnecessary cost, like using a person document instead of a mail-in for shared mailboxes. We’ll provide examples and solutions for those as well. And naturally we’ll explain the new licensing model.
Join HCL Ambassador Marc Thomas in this webinar with a special guest appearance from Franz Walder. It will give you the tools and know-how to stay on top of what is going on with Domino licensing. You will be able lower your cost through an optimized configuration and keep it low going forward.
These topics will be covered
- Reducing license cost by finding and fixing misconfigurations and superfluous accounts
- How do CCB and CCX licenses really work?
- Understanding the DLAU tool and how to best utilize it
- Tips for common problem areas, like team mailboxes, functional/test users, etc
- Practical examples and best practices to implement right away
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxSitimaJohn
Ocean Lotus cyber threat actors represent a sophisticated, persistent, and politically motivated group that poses a significant risk to organizations and individuals in the Southeast Asian region. Their continuous evolution and adaptability underscore the need for robust cybersecurity measures and international cooperation to identify and mitigate the threats posed by such advanced persistent threat groups.
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfflufftailshop
When it comes to unit testing in the .NET ecosystem, developers have a wide range of options available. Among the most popular choices are NUnit, XUnit, and MSTest. These unit testing frameworks provide essential tools and features to help ensure the quality and reliability of code. However, understanding the differences between these frameworks is crucial for selecting the most suitable one for your projects.
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...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 integration of Salesforce with Bonterra Impact Management.
Interested in deploying an integration with Salesforce for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
Monitoring and Managing Anomaly Detection on OpenShift.pdfTosin Akinosho
Monitoring and Managing Anomaly Detection on OpenShift
Overview
Dive into the world of anomaly detection on edge devices with our comprehensive hands-on tutorial. This SlideShare presentation will guide you through the entire process, from data collection and model training to edge deployment and real-time monitoring. Perfect for those looking to implement robust anomaly detection systems on resource-constrained IoT/edge devices.
Key Topics Covered
1. Introduction to Anomaly Detection
- Understand the fundamentals of anomaly detection and its importance in identifying unusual behavior or failures in systems.
2. Understanding Edge (IoT)
- Learn about edge computing and IoT, and how they enable real-time data processing and decision-making at the source.
3. What is ArgoCD?
- Discover ArgoCD, a declarative, GitOps continuous delivery tool for Kubernetes, and its role in deploying applications on edge devices.
4. Deployment Using ArgoCD for Edge Devices
- Step-by-step guide on deploying anomaly detection models on edge devices using ArgoCD.
5. Introduction to Apache Kafka and S3
- Explore Apache Kafka for real-time data streaming and Amazon S3 for scalable storage solutions.
6. Viewing Kafka Messages in the Data Lake
- Learn how to view and analyze Kafka messages stored in a data lake for better insights.
7. What is Prometheus?
- Get to know Prometheus, an open-source monitoring and alerting toolkit, and its application in monitoring edge devices.
8. Monitoring Application Metrics with Prometheus
- Detailed instructions on setting up Prometheus to monitor the performance and health of your anomaly detection system.
9. What is Camel K?
- Introduction to Camel K, a lightweight integration framework built on Apache Camel, designed for Kubernetes.
10. Configuring Camel K Integrations for Data Pipelines
- Learn how to configure Camel K for seamless data pipeline integrations in your anomaly detection workflow.
11. What is a Jupyter Notebook?
- Overview of Jupyter Notebooks, an open-source web application for creating and sharing documents with live code, equations, visualizations, and narrative text.
12. Jupyter Notebooks with Code Examples
- Hands-on examples and code snippets in Jupyter Notebooks to help you implement and test anomaly detection models.
Driving Business Innovation: Latest Generative AI Advancements & Success StorySafe Software
Are you ready to revolutionize how you handle data? Join us for a webinar where we’ll bring you up to speed with the latest advancements in Generative AI technology and discover how leveraging FME with tools from giants like Google Gemini, Amazon, and Microsoft OpenAI can supercharge your workflow efficiency.
During the hour, we’ll take you through:
Guest Speaker Segment with Hannah Barrington: Dive into the world of dynamic real estate marketing with Hannah, the Marketing Manager at Workspace Group. Hear firsthand how their team generates engaging descriptions for thousands of office units by integrating diverse data sources—from PDF floorplans to web pages—using FME transformers, like OpenAIVisionConnector and AnthropicVisionConnector. This use case will show you how GenAI can streamline content creation for marketing across the board.
Ollama Use Case: Learn how Scenario Specialist Dmitri Bagh has utilized Ollama within FME to input data, create custom models, and enhance security protocols. This segment will include demos to illustrate the full capabilities of FME in AI-driven processes.
Custom AI Models: Discover how to leverage FME to build personalized AI models using your data. Whether it’s populating a model with local data for added security or integrating public AI tools, find out how FME facilitates a versatile and secure approach to AI.
We’ll wrap up with a live Q&A session where you can engage with our experts on your specific use cases, and learn more about optimizing your data workflows with AI.
This webinar is ideal for professionals seeking to harness the power of AI within their data management systems while ensuring high levels of customization and security. Whether you're a novice or an expert, gain actionable insights and strategies to elevate your data processes. Join us to see how FME and AI can revolutionize how you work with data!
Programming Foundation Models with DSPy - Meetup SlidesZilliz
Prompting language models is hard, while programming language models is easy. In this talk, I will discuss the state-of-the-art framework DSPy for programming foundation models with its powerful optimizers and runtime constraint system.
Trusted Execution Environment for Decentralized Process MiningLucaBarbaro3
Presentation of the paper "Trusted Execution Environment for Decentralized Process Mining" given during the CAiSE 2024 Conference in Cyprus on June 7, 2024.
5th LF Energy Power Grid Model Meet-up SlidesDanBrown980551
5th Power Grid Model Meet-up
It is with great pleasure that we extend to you an invitation to the 5th Power Grid Model Meet-up, scheduled for 6th June 2024. This event will adopt a hybrid format, allowing participants to join us either through an online Mircosoft Teams session or in person at TU/e located at Den Dolech 2, Eindhoven, Netherlands. The meet-up will be hosted by Eindhoven University of Technology (TU/e), a research university specializing in engineering science & technology.
Power Grid Model
The global energy transition is placing new and unprecedented demands on Distribution System Operators (DSOs). Alongside upgrades to grid capacity, processes such as digitization, capacity optimization, and congestion management are becoming vital for delivering reliable services.
Power Grid Model is an open source project from Linux Foundation Energy and provides a calculation engine that is increasingly essential for DSOs. It offers a standards-based foundation enabling real-time power systems analysis, simulations of electrical power grids, and sophisticated what-if analysis. In addition, it enables in-depth studies and analysis of the electrical power grid’s behavior and performance. This comprehensive model incorporates essential factors such as power generation capacity, electrical losses, voltage levels, power flows, and system stability.
Power Grid Model is currently being applied in a wide variety of use cases, including grid planning, expansion, reliability, and congestion studies. It can also help in analyzing the impact of renewable energy integration, assessing the effects of disturbances or faults, and developing strategies for grid control and optimization.
What to expect
For the upcoming meetup we are organizing, we have an exciting lineup of activities planned:
-Insightful presentations covering two practical applications of the Power Grid Model.
-An update on the latest advancements in Power Grid -Model technology during the first and second quarters of 2024.
-An interactive brainstorming session to discuss and propose new feature requests.
-An opportunity to connect with fellow Power Grid Model enthusiasts and users.
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slackshyamraj55
Discover the seamless integration of RPA (Robotic Process Automation), COMPOSER, and APM with AWS IDP enhanced with Slack notifications. Explore how these technologies converge to streamline workflows, optimize performance, and ensure secure access, all while leveraging the power of AWS IDP and real-time communication via Slack notifications.
2. @Service
public class PostService {
private static final int DAY = 24 * 60 * 60000;
@Autowired
private UserRepository users;
@Autowired
private PostRepository posts;
@Autowired
private NewsfeedRepository news;
@Autowired
private CommentRepository comments;
@Autowired
private NotificationService notifications;
public List<PostDAO> postsOf(String authToken, String userId,
int fromPage, int pageSize) {
PostService
3. @Service
public class PostService {
private static final int DAY = 24 * 60 * 60000;
@Autowired
private UserRepository users;
@Autowired
private PostRepository posts;
@Autowired
private NewsfeedRepository news;
@Autowired
private CommentRepository comments;
@Autowired
private NotificationService notifications;
public List<PostDAO> postsOf(String authToken, String userId,
int fromPage, int pageSize) {
PostService
4. @Autowired
private NotificationService notifications;
public List<PostDAO> postsOf(String authToken, String userId,
int fromPage, int pageSize) {
User u = users.findByAuthtoken(authToken).get(0);
Page<Post> postPage;
if(u.getId().equals(userId) || u.isFriendById(userId)) {
postPage = posts.findAllPostsByUser(
userId, PageRequest.of(fromPage, pageSize,
Sort.by(Sort.Direction.DESC, "date")));
} else {
postPage = posts.findPostsByUser(
userId, VisibilityConstants.PUBLIC.asString(),
PageRequest.of(fromPage, pageSize,
Sort.by(Sort.Direction.DESC, "date")));
}
List<PostDAO> response = new ArrayList<>();
for(Post p : postPage) {
response.add(p.getDAO());
}
return response;
}
PostService
5. @Autowired
private NotificationService notifications;
public List<PostDAO> postsOf(String authToken, String userId,
int fromPage, int pageSize) {
User u = users.findByAuthtoken(authToken).get(0);
Page<Post> postPage;
if(u.getId().equals(userId) || u.isFriendById(userId)) {
postPage = posts.findAllPostsByUser(
userId, PageRequest.of(fromPage, pageSize,
Sort.by(Sort.Direction.DESC, "date")));
} else {
postPage = posts.findPostsByUser(
userId, VisibilityConstants.PUBLIC.asString(),
PageRequest.of(fromPage, pageSize,
Sort.by(Sort.Direction.DESC, "date")));
}
List<PostDAO> response = new ArrayList<>();
for(Post p : postPage) {
response.add(p.getDAO());
}
return response;
}
PostService
6. @Autowired
private NotificationService notifications;
public List<PostDAO> postsOf(String authToken, String userId,
int fromPage, int pageSize) {
User u = users.findByAuthtoken(authToken).get(0);
Page<Post> postPage;
if(u.getId().equals(userId) || u.isFriendById(userId)) {
postPage = posts.findAllPostsByUser(
userId, PageRequest.of(fromPage, pageSize,
Sort.by(Sort.Direction.DESC, "date")));
} else {
postPage = posts.findPostsByUser(
userId, VisibilityConstants.PUBLIC.asString(),
PageRequest.of(fromPage, pageSize,
Sort.by(Sort.Direction.DESC, "date")));
}
List<PostDAO> response = new ArrayList<>();
for(Post p : postPage) {
response.add(p.getDAO());
}
return response;
}
PostService
7. @Autowired
private NotificationService notifications;
public List<PostDAO> postsOf(String authToken, String userId,
int fromPage, int pageSize) {
User u = users.findByAuthtoken(authToken).get(0);
Page<Post> postPage;
if(u.getId().equals(userId) || u.isFriendById(userId)) {
postPage = posts.findAllPostsByUser(
userId, PageRequest.of(fromPage, pageSize,
Sort.by(Sort.Direction.DESC, "date")));
} else {
postPage = posts.findPostsByUser(
userId, VisibilityConstants.PUBLIC.asString(),
PageRequest.of(fromPage, pageSize,
Sort.by(Sort.Direction.DESC, "date")));
}
List<PostDAO> response = new ArrayList<>();
for(Post p : postPage) {
response.add(p.getDAO());
}
return response;
}
PostService
8. @Autowired
private NotificationService notifications;
public List<PostDAO> postsOf(String authToken, String userId,
int fromPage, int pageSize) {
User u = users.findByAuthtoken(authToken).get(0);
Page<Post> postPage;
if(u.getId().equals(userId) || u.isFriendById(userId)) {
postPage = posts.findAllPostsByUser(
userId, PageRequest.of(fromPage, pageSize,
Sort.by(Sort.Direction.DESC, "date")));
} else {
postPage = posts.findPostsByUser(
userId, VisibilityConstants.PUBLIC.asString(),
PageRequest.of(fromPage, pageSize,
Sort.by(Sort.Direction.DESC, "date")));
}
List<PostDAO> response = new ArrayList<>();
for(Post p : postPage) {
response.add(p.getDAO());
}
return response;
}
PostService
9. for(Post p : postPage) {
response.add(p.getDAO());
}
return response;
}
public List<PostDAO> newsfeed(String authToken, int fromPage,
int pageSize) {
Page<Newsfeed> n = news.findNewsfeedForUser(authToken,
PageRequest.of(fromPage, pageSize,
Sort.by(Sort.Order.desc("postDay"),
Sort.Order.asc("rank"),
Sort.Order.desc("postTimestamp"))));
List<PostDAO> response = new ArrayList<>();
for(Newsfeed c : n) {
response.add(c.getEntry().getDAO());
}
return response;
}
public String post(String authToken, PostDAO pd) {
User u = users.findByAuthtoken(authToken).get(0);
Post p = new Post();
p.setContent(pd.getContent());
PostService
10. for(Post p : postPage) {
response.add(p.getDAO());
}
return response;
}
public List<PostDAO> newsfeed(String authToken, int fromPage,
int pageSize) {
Page<Newsfeed> n = news.findNewsfeedForUser(authToken,
PageRequest.of(fromPage, pageSize,
Sort.by(Sort.Order.desc("postDay"),
Sort.Order.asc("rank"),
Sort.Order.desc("postTimestamp"))));
List<PostDAO> response = new ArrayList<>();
for(Newsfeed c : n) {
response.add(c.getEntry().getDAO());
}
return response;
}
public String post(String authToken, PostDAO pd) {
User u = users.findByAuthtoken(authToken).get(0);
Post p = new Post();
p.setContent(pd.getContent());
PostService
11. for(Post p : postPage) {
response.add(p.getDAO());
}
return response;
}
public List<PostDAO> newsfeed(String authToken, int fromPage,
int pageSize) {
Page<Newsfeed> n = news.findNewsfeedForUser(authToken,
PageRequest.of(fromPage, pageSize,
Sort.by(Sort.Order.desc("postDay"),
Sort.Order.asc("rank"),
Sort.Order.desc("postTimestamp"))));
List<PostDAO> response = new ArrayList<>();
for(Newsfeed c : n) {
response.add(c.getEntry().getDAO());
}
return response;
}
public String post(String authToken, PostDAO pd) {
User u = users.findByAuthtoken(authToken).get(0);
Post p = new Post();
p.setContent(pd.getContent());
PostService
12. response.add(c.getEntry().getDAO());
}
return response;
}
public String post(String authToken, PostDAO pd) {
User u = users.findByAuthtoken(authToken).get(0);
Post p = new Post();
p.setContent(pd.getContent());
p.setDate(System.currentTimeMillis());
p.setStyling(pd.getStyling());
p.setTitle(pd.getTitle());
p.setUser(u);
p.setVisibility(pd.getVisibility());
posts.save(p);
addPostToNewsfeed(u, p);
if(u.getFriends() != null) {
for(User c : u.getFriends()) {
addPostToNewsfeed(c, p);
}
}
return p.getId();
}
PostService
13. response.add(c.getEntry().getDAO());
}
return response;
}
public String post(String authToken, PostDAO pd) {
User u = users.findByAuthtoken(authToken).get(0);
Post p = new Post();
p.setContent(pd.getContent());
p.setDate(System.currentTimeMillis());
p.setStyling(pd.getStyling());
p.setTitle(pd.getTitle());
p.setUser(u);
p.setVisibility(pd.getVisibility());
posts.save(p);
addPostToNewsfeed(u, p);
if(u.getFriends() != null) {
for(User c : u.getFriends()) {
addPostToNewsfeed(c, p);
}
}
return p.getId();
}
PostService
14. response.add(c.getEntry().getDAO());
}
return response;
}
public String post(String authToken, PostDAO pd) {
User u = users.findByAuthtoken(authToken).get(0);
Post p = new Post();
p.setContent(pd.getContent());
p.setDate(System.currentTimeMillis());
p.setStyling(pd.getStyling());
p.setTitle(pd.getTitle());
p.setUser(u);
p.setVisibility(pd.getVisibility());
posts.save(p);
addPostToNewsfeed(u, p);
if(u.getFriends() != null) {
for(User c : u.getFriends()) {
addPostToNewsfeed(c, p);
}
}
return p.getId();
}
PostService
15. response.add(c.getEntry().getDAO());
}
return response;
}
public String post(String authToken, PostDAO pd) {
User u = users.findByAuthtoken(authToken).get(0);
Post p = new Post();
p.setContent(pd.getContent());
p.setDate(System.currentTimeMillis());
p.setStyling(pd.getStyling());
p.setTitle(pd.getTitle());
p.setUser(u);
p.setVisibility(pd.getVisibility());
posts.save(p);
addPostToNewsfeed(u, p);
if(u.getFriends() != null) {
for(User c : u.getFriends()) {
addPostToNewsfeed(c, p);
}
}
return p.getId();
}
PostService
16. response.add(c.getEntry().getDAO());
}
return response;
}
public String post(String authToken, PostDAO pd) {
User u = users.findByAuthtoken(authToken).get(0);
Post p = new Post();
p.setContent(pd.getContent());
p.setDate(System.currentTimeMillis());
p.setStyling(pd.getStyling());
p.setTitle(pd.getTitle());
p.setUser(u);
p.setVisibility(pd.getVisibility());
posts.save(p);
addPostToNewsfeed(u, p);
if(u.getFriends() != null) {
for(User c : u.getFriends()) {
addPostToNewsfeed(c, p);
}
}
return p.getId();
}
PostService
17. for(User c : u.getFriends()) {
addPostToNewsfeed(c, p);
}
}
return p.getId();
}
private void addPostToNewsfeed(User u, Post p) {
Newsfeed n = new Newsfeed();
n.setEntry(p);
n.setParent(u);
n.setPostDay(System.currentTimeMillis() / DAY);
n.setPostTimestamp(System.currentTimeMillis());
news.save(n);
}
public String comment(String authToken, String postId, CommentDAO cd)
throws PermissionException {
User u = users.findByAuthtoken(authToken).get(0);
Post p = posts.findById(postId).get();
if(!VisibilityConstants.isPublic(p.getVisibility())) {
if(!u.getId().equals(p.getUser().getId())) {
if(!p.getUser().isFriendById(u.getId())) {
throw new
PostService
18. for(User c : u.getFriends()) {
addPostToNewsfeed(c, p);
}
}
return p.getId();
}
private void addPostToNewsfeed(User u, Post p) {
Newsfeed n = new Newsfeed();
n.setEntry(p);
n.setParent(u);
n.setPostDay(System.currentTimeMillis() / DAY);
n.setPostTimestamp(System.currentTimeMillis());
news.save(n);
}
public String comment(String authToken, String postId, CommentDAO cd)
throws PermissionException {
User u = users.findByAuthtoken(authToken).get(0);
Post p = posts.findById(postId).get();
if(!VisibilityConstants.isPublic(p.getVisibility())) {
if(!u.getId().equals(p.getUser().getId())) {
if(!p.getUser().isFriendById(u.getId())) {
throw new
PostService
19. news.save(n);
}
public String comment(String authToken, String postId, CommentDAO cd)
throws PermissionException {
User u = users.findByAuthtoken(authToken).get(0);
Post p = posts.findById(postId).get();
if(!VisibilityConstants.isPublic(p.getVisibility())) {
if(!u.getId().equals(p.getUser().getId())) {
if(!p.getUser().isFriendById(u.getId())) {
throw new
PermissionException("This is a private post!");
}
}
}
Comment c = new Comment();
c.setDate(System.currentTimeMillis());
if(cd.getParentComment() != null) {
c.setParentComment(comments.findById(cd.getParentComment()).
get());
}
c.setText(cd.getText());
c.setUser(u);
comments.save(c);
PostService
20. news.save(n);
}
public String comment(String authToken, String postId, CommentDAO cd)
throws PermissionException {
User u = users.findByAuthtoken(authToken).get(0);
Post p = posts.findById(postId).get();
if(!VisibilityConstants.isPublic(p.getVisibility())) {
if(!u.getId().equals(p.getUser().getId())) {
if(!p.getUser().isFriendById(u.getId())) {
throw new
PermissionException("This is a private post!");
}
}
}
Comment c = new Comment();
c.setDate(System.currentTimeMillis());
if(cd.getParentComment() != null) {
c.setParentComment(comments.findById(cd.getParentComment()).
get());
}
c.setText(cd.getText());
c.setUser(u);
comments.save(c);
PostService
21. if(!p.getUser().isFriendById(u.getId())) {
throw new
PermissionException("This is a private post!");
}
}
}
Comment c = new Comment();
c.setDate(System.currentTimeMillis());
if(cd.getParentComment() != null) {
c.setParentComment(comments.findById(cd.getParentComment()).
get());
}
c.setText(cd.getText());
c.setUser(u);
comments.save(c);
p.getComments().add(c);
posts.save(p);
notifications.sendNotification(u,
new NotificationDAO(null, u.getDAO(),
"commented on your post", "uE0B7",
0x00A400, 0, false,
postId, cd.getId()));
return c.getId();
}
PostService
22. if(!p.getUser().isFriendById(u.getId())) {
throw new
PermissionException("This is a private post!");
}
}
}
Comment c = new Comment();
c.setDate(System.currentTimeMillis());
if(cd.getParentComment() != null) {
c.setParentComment(comments.findById(cd.getParentComment()).
get());
}
c.setText(cd.getText());
c.setUser(u);
comments.save(c);
p.getComments().add(c);
posts.save(p);
notifications.sendNotification(u,
new NotificationDAO(null, u.getDAO(),
"commented on your post", "uE0B7",
0x00A400, 0, false,
postId, cd.getId()));
return c.getId();
}
PostService
23. p.getComments().add(c);
posts.save(p);
notifications.sendNotification(u,
new NotificationDAO(null, u.getDAO(),
"commented on your post", "uE0B7",
0x00A400, 0, false,
postId, cd.getId()));
return c.getId();
}
public void like(String authToken, String postId) {
User u = users.findByAuthtoken(authToken).get(0);
Post p = posts.findById(postId).get();
if(!p.getLikes().contains(u)) {
p.getLikes().add(u);
posts.save(p);
notifications.sendNotification(u,
new NotificationDAO(null, u.getDAO(),
"liked your post", "uE8DC",
0x587EBE, 0, false,
postId, null));
}
}
}
PostService
24. p.getComments().add(c);
posts.save(p);
notifications.sendNotification(u,
new NotificationDAO(null, u.getDAO(),
"commented on your post", "uE0B7",
0x00A400, 0, false,
postId, cd.getId()));
return c.getId();
}
public void like(String authToken, String postId) {
User u = users.findByAuthtoken(authToken).get(0);
Post p = posts.findById(postId).get();
if(!p.getLikes().contains(u)) {
p.getLikes().add(u);
posts.save(p);
notifications.sendNotification(u,
new NotificationDAO(null, u.getDAO(),
"liked your post", "uE8DC",
0x587EBE, 0, false,
postId, null));
}
}
}
PostService
25. p.getComments().add(c);
posts.save(p);
notifications.sendNotification(u,
new NotificationDAO(null, u.getDAO(),
"commented on your post", "uE0B7",
0x00A400, 0, false,
postId, cd.getId()));
return c.getId();
}
public void like(String authToken, String postId) {
User u = users.findByAuthtoken(authToken).get(0);
Post p = posts.findById(postId).get();
if(!p.getLikes().contains(u)) {
p.getLikes().add(u);
posts.save(p);
notifications.sendNotification(u,
new NotificationDAO(null, u.getDAO(),
"liked your post", "uE8DC",
0x587EBE, 0, false,
postId, null));
}
}
}
PostService