QuestionQuestion

Crowdfunding is a phenomenon and is growing rapidly as a means of getting funding for a variety of purposes e.g. charitable endeavours, self-improvement, start-up companies etc.
You are to develop a crowdfunding website with the following features:

• Anyone can view a list of projects
• Anyone can view the details of a project
• Users can register to use the service using their email and password, also providing a name
• Authenticated users can add a project to be crowdfunded, giving it a name, description, a target amount and the date of creation of the project, including:
o pledge to a project (but not his own project)
o view a list of his/her projects
o view the full details of a project including list of pledges
o edit the description of a project but not the target amount
• A project is closed when it achieves its target amount You must also provide
• Two REST API's to return the following data in json format to authorised users
o List of active projects
o List of a particular user's projects, given an id
• An example of consuming these two APIs (requires another Spring project) – nothing fancy is needed here, just another project which has two controllers that send authentication data to the REST APIs and present retrieved data in HTML – no CSS is needed. Do not waste time on making it look good – the focus is on functionality.
• Internationalisation (must work for 2 languages) but there is no need to actually translate - just add _DE, for example, to the English messages.

Technical Notes
• You should use an in-memory database to create an "out of the box" application
i.e. h2.
• Essentially this project has 3 entities: user, project and pledge along with the Role table required by Spring Security
o A Pledge is has a Member and Project
o A Project has several pledges but only one Member
o A Member has several project and several pledges
 only one of these can be EAGER, the other must be LAZY and accessed as needed through the DAO
• Use the Security module for authentication and authorisation.
• I am not interested in visual styling – just make the web site well structured, readable, navigable, etc. Credit any template (CSS/HTML) if you use them.

• You must validate user input with suitable (international) error message.
• You must use the following:
o Spring Boot
o Spring MVC
o Thymeleaf
o Spring Data JPA
o Spring Security
o H2 for the embedded database

Guideline for Project

Spring JPA project for an Embedded H2 Database The following works for an embedded database.
If you were using MySQL, there would be a few minor changes e.g. no data loading would be required because the database would already exist, you would switch off the ddl-auto and you would add the MySQL dependencies to the project, removing H2 dependency.

1. Create a Spring Starter project adding
o JPA
o Web
o Thymeleaf
o H2
2. Create your index controller and associated Thymeleaf view with some CSS. Get this working as proof-of-concept that your architecture and project work properly.
3. Add a second language to your project.
4. Design the database on paper, establishing clearly the relationships between entities.
o You must create a Role table for security authentication purposes.
5. Create the associated JPA domain classes i.e. POJOs with JPA annotations
6. Create the DAOs by extending the JPARepository class
o Add other methods if neccessary by name or @Query
7. Create the Service classes (@Service) only including the methods which you need from the DAO.
8. Create a DataLoader class (refer Outline of Spring and JPA - Two Tables)
9. Enable the H2 console in the application.properties file (refer Outline of Spring and JPA - Two Tables)
10. Run the program to see that the database has been created and populated with data.


The easiest to start with is viewing a single project using a path parameter or request variable e.g. localhost:8080/viewproject/2 would show the project with ID of 1. The project is retrieved from the database through the service layer, added to the model and sent to the view to be displayed using Thymeleaf. If this works, you have coded MVC in Spring. Now try for more than one project and see how that goes.

Adding controllers

1. Create a controller class @Controller
2. Create a @GetMapping handler for index and the associated Thymeleaf HTML file. Test this as proof of concept.
3. Create more controllers as you need them (see right).
Use @GetMapping and @PostMapping annotations to map requests to particular methods. Each of these methods returns a String which should have an associated HTML file (in Thymeleaf).
o If necessary, add data to the model
4. Create the views using Thymeleaf.
5. Add a different language through the use of the externalised message system and the locale change beans.

Forms

You will have to create one or more forms.

1. Decide on the data that should be gathered through the form.
2. If necessary, create a class for the form. Otherwise use an existing class.
3. Send an instance of the class through the model to the view (HTML form) using the controller.
4. Create the Thymeleaf HTML view which binds the data from the form to the fields in the object. Specify the POST request.
5. Create the post handler which will process the data received.
6. Add validation to the form
7. Code for the validation errors in HTML and in the controller.

And...

1. Add security
o require authentication for specified functions
o restrict access to certain pages based upon authorisations
2. Add REST capabilities
o create the required endpoints and demonstrate how they might be used

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

@Configuration
public class CrowdFundingConfig {

@Autowired
    private IAuthenticationFacade authenticationFacade;


@Bean
    public WebMvcConfigurerAdapter forwardToIndex() {
return new WebMvcConfigurerAdapter() {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController("/login").setViewName("login");
    registry.addViewController("/").setViewName("login");
    registry.addViewController("/register").setViewName("register");
    //registry.addViewController("/addProjectPage").setViewName("add-project");
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(localeChangeInterceptor());
}
};
}

@Bean
public Authentication authentication(){
Authentication authentication = authenticationFacade.getAuthentication();
return authentication;
}

@Bean
public CommonsRequestLoggingFilter requestLoggingFilter() {
    CommonsRequestLoggingFilter crlf = new CommonsRequestLoggingFilter();
    crlf.setIncludeClientInfo(true);
    crlf.setIncludeQueryString(true);
    crlf.setIncludePayload(true);
    return crlf;
}

@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
   // Do any additional configuration here
   RestTemplate restTemplate=builder.build();
   MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
   mappingJackson2HttpMessageConverter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON, MediaType.TEXT_HTML));
   ObjectMapper mapper = new ObjectMapper();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
   mappingJackson2HttpMessageConverter.setObjectMapper(mapper);
   restTemplate.getMessageConverters().add(mappingJackson2HttpMessageConverter);
   return restTemplate;
}...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$365.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats