Exercises Summary Build a system based on previous work which uses an H2 in-memory database for storage following the lecture notes. Step 1 Follow through the lecture and build the demoed code. We...

1 answer below »
very easy all steps are already there just follow and complete


Exercises Summary Build a system based on previous work which uses an H2 in-memory database for storage following the lecture notes. Step 1 Follow through the lecture and build the demoed code. We will need this again, so be sure to do it! Preferably, NOW, while you can get help!!! Step 2 If you’re interested, create a data.sql file in the same place as your schema.sql file, and copy and paste the following line into it: INSERT INTO student(name) VALUES ('Sally'), ('Harminder'), ('Hao'), ('Jaspreet'); A data.sql is usually used to populate our database with any information we know we will require – at startup! Just like a schema.sql, but for info rather than structure! Explore the H2 console! If you type an SQL command to UPDATE or DELETE WHERE … something in a semi- populated database here, then re-load http://localhost:8080/ in a separate tab, does it reflect the modification in real time? Restart your Spring Boot app. Same thing? Take a screenshot of your H2 console Student table with your name as the filename, be sure it shows a few rows worth of student info inside, then submit your screenshot in SLATE for marks. http://localhost:8080/ Exercises Summary Build a system based on previous work continuing to use our H2 in-memory database for storage following the lecture notes. This time, use the MapSqlParameterSource to customize any and all data you insert, then retrieve all Students you’ve inserted for display! Step 1 Follow through the lecture and build the demoed code as ex52_jdbcTemplateContinued. We will need this next class one more time, so be sure to do it! Preferably, NOW, while you can get help!!! Don’t drown here! Our next exercise, building on this one, is one of the most important for the course! Honestly, don’t you want to see it all working on your own machine anyway though?! When you get it done, hand in a screenshot of your home page with your name already added to the studentList at the top (also with your name as filename as always), and make sure you add a bunch of other names added for good measure too! Style, style, style!!! Assignment 1 This assignment is individual work. You are not allowed to work on this with anyone, nor should you accept or offer help. Folks who offer help and hints generally produce very similar code to the folks receiving help and hints! Offenders will be prosecuted! Also note: these instructions are purposefully vague. There are an infinite number of ways to solve this problem! Choose ways that work! With that out of the way, put in the time, solve the problems, and get through it! It’s worth it, and it’s fun! The Ask… Your boss misses going to the theatre during COVID! They ask you if you can develop an application that allows your clients to review the few movies still playing in theatre, but preferably any recent ones you can find that were released straight to Netflix or other streaming services. You will hard-code static movie info that fits the criteria (in theatres now or recently released straight to television), and then users can add reviews for any of the movies as they see fit! Requirements Part 1 Begin with a POJO for each movie review and consider things you’d like to store. I might suggest the movie name and an id number for it, the review itself as a String of course, and also possibly the date and time the review was written, at bare minimum. Feel free to include anything else you feel is relevant! Set aside a memory hole for a POJOList (though please call it something more meaningful!), and inject an implementation of said List as we have done in the exercises. In a hard-coded constructor in your controller, hard-code at least three reviews for your favourite movies and add them to your List. Be honest and choose carefully! Your boss (and I) might decide to watch a few of them if you can sell us! Friendly tip, a brief hint about which streaming service each particular movie is playing on in the review itself is also super helpful for me, though it’s a better idea to store the streaming service info as an additional POJO property! Up to you! I mainly ask you keep the movie data real, and of course that you keep the reviews honest. There is no need to link to any movie poster images for this assignment. Part 2 Your Controller must dispatch to a form where the reviews are displayed. You need a method which can handle HTTP GET request to “/”, as well as one for POST requests with form data. In your “/” mapped method, grab all movie reviews thus far from your list and add them to the model. Additionally, add a blank Review to your Model for ModelAttribute binding in Thymeleaf. In your POST Mapped method, retrieve all form parameters as a @ModelAttribute annotation and pre-populated POJO. Add the retrieved POJO info to your list. Then, retrieve all movie reviews thus far from your list again and add them to the Model. Add a blank Review to your Model for Form Binding back at Thymeleaf again. Part 3 Create a Thymeleaf page or pages which display your dynamic review content! Display all review content for every review in a nicely formatted and styled fashion. Points for style here! Additionally, add a form which is bound to your blank Review POJO from the Model to make it easy to write, store, and retrieve the next review at our server side! Style the page(s)! Again, points for style! Things to consider 1. Think about the POJO properties you need in this application. Only one POJO is required. 2. For the purposes of this application, no functionality for keeping additional reviews in a more persistent state is wanted or required. They should all disappear, not counting anything you’ve hard coded, with each restart. 3. There can be any number of reviews for a particular movie stored in the database. 4. Ensure you pre-populate your list with a set of reviews for display so your users aren’t lonely! 5. You must inject an implementation of your pojo list interface as we have done in the exercises. 6. You must use Lombok. 7. Your view pages must use Thymeleaf, and they must look great! Most hackathons are won by the best “looking” idea, rather than the actual best idea! Spend the time! Submission Details Name your project A1. Please use regular ZIP to combine and compress your project’s directory from inside your workspace folder. Please DO NOT RAR or 7-Zip your project for submission! RAR’s usually come with viruses. 7-Zip is very appropriate for email, but is much harder to work with in Eclipse. Use a regular .zip and follow this naming convention – you have officially been told! Failure to follow these two simple rules will result in massive grade reductions. Submit your assignment to the SLATE Assignments folder for our course. You should attach/upload the zip of your Eclipse workspace project folder. Remember what you have learned and put it into practice! Best of luck! Grading • Controller Layer – appropriate calls, use of injection, etc. 5 • Model Layer – POJO, appropriate repository methods, etc. 5 • View Layer – Thymeleaf, Form Binding, etc. 5 • All best practices and instructions followed, and style! 5 / 20 Assignment 1 This assignment is individual work. You are not allowed to work on this with anyone, nor should you accept or offer help. Folks who offer help and hints generally produce very similar code to the folks receiving help and hints! Offenders will be prosecuted! Also note: these instructions are purposefully vague. There are an infinite number of ways to solve this problem! Choose ways that work! With that out of the way, put in the time, solve the problems, and get through it! It’s worth it, and it’s fun! The Ask… Your boss misses going to the theatre during COVID! They ask you if you can develop an application that allows your clients to review the few movies still playing in theatre, but preferably any recent ones you can find that were released straight to Netflix or other streaming services. You will hard-code static movie info that fits the criteria (in theatres now or recently released straight to television), and then users can add reviews for any of the movies as they see fit! Requirements Part 1 Begin with a POJO for each movie review and consider things you’d like to store. I might suggest the movie name and an id number for it, the review itself as a String of course, and also possibly the date and time the review was written, at bare minimum. Feel free to include anything else you feel is relevant! Set aside a memory hole for a POJOList (though please call it something more meaningful!), and inject an implementation of said List as we have done in the exercises. In a hard-coded constructor in your controller, hard-code at least three reviews for your favourite movies and add them to your List. Be honest and choose carefully! Your boss (and I) might decide to watch a few of them if you can sell us! Friendly tip, a brief hint about which streaming service each particular movie is playing on in the review itself is also super helpful for me, though it’s a better idea to store the streaming service info as an additional POJO property! Up to you! I mainly ask you keep the movie data real, and of course that you keep the reviews honest.
Answered 4 days AfterOct 06, 2021

Answer To: Exercises Summary Build a system based on previous work which uses an H2 in-memory database for...

Piyush answered on Oct 11 2021
115 Votes
A1/.classpath

    
        
            
            
        
    
    
        
            
        
    
    
        
            
            
            
        
    
    
        
            
        
    
    
        
            
        
    
    
A1/.gitignore
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
A1/.mvn/wrapper/MavenWrapperDownloader.java
A1/.mvn/wrapper/MavenWrapperDownloader.java
/*
 * Copyright 2007-present the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
    private static final String WRAPPER_VERSION = "0.5.6";
    /**
     * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
     */
    private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.a
pache.org/maven2/io/takari/maven-wrapper/"
        + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
    /**
     * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
     * use instead of the default one.
     */
    private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
            ".mvn/wrapper/maven-wrapper.properties";
    /**
     * Path where the maven-wrapper.jar will be saved to.
     */
    private static final String MAVEN_WRAPPER_JAR_PATH =
            ".mvn/wrapper/maven-wrapper.jar";
    /**
     * Name of the property which should be used to override the default download url for the wrapper.
     */
    private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
    public static void main(String args[]) {
        System.out.println("- Downloader started");
        File baseDirectory = new File(args[0]);
        System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
        // If the maven-wrapper.properties exists, read it and check if it contains a custom
        // wrapperUrl parameter.
        File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
        String url = DEFAULT_DOWNLOAD_URL;
        if(mavenWrapperPropertyFile.exists()) {
            FileInputStream mavenWrapperPropertyFileInputStream = null;
            try {
                mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
                Properties mavenWrapperProperties = new Properties();
                mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
                url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
            } catch (IOException e) {
                System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
            } finally {
                try {
                    if(mavenWrapperPropertyFileInputStream != null) {
                        mavenWrapperPropertyFileInputStream.close();
                    }
                } catch (IOException e) {
                    // Ignore ...
                }
            }
        }
        System.out.println("- Downloading from: " + url);
        File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
        if(!outputFile.getParentFile().exists()) {
            if(!outputFile.getParentFile().mkdirs()) {
                System.out.println(
                        "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
            }
        }
        System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
        try {
            downloadFileFromURL(url, outputFile);
            System.out.println("Done");
            System.exit(0);
        } catch (Throwable e) {
            System.out.println("- Error downloading");
            e.printStackTrace();
            System.exit(1);
        }
    }
    private static void downloadFileFromURL(String urlString, File destination) throws Exception {
        if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
            String username = System.getenv("MVNW_USERNAME");
            char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
            Authenticator.setDefault(new Authenticator() {
                @Override
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(username, password);
                }
            });
        }
        URL website = new URL(urlString);
        ReadableByteChannel rbc;
        rbc = Channels.newChannel(website.openStream());
        FileOutputStream fos = new FileOutputStream(destination);
        fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
        fos.close();
        rbc.close();
    }
}
A1/.mvn/wrapper/maven-wrapper.jar
META-INF/MANIFEST.MF
Manifest-Version: 1.0
Implementation-Title: maven-wrapper
Implementation-Version: 0.5.6
Archiver-Version: Provisio Archiver
Built-By: manfred
Specification-Title: maven-wrapper
Implementation-Vendor-Id: io.takari
Created-By: Takari Inc.
Build-Jdk: 1.8.0_232
Specification-Version: 0.5.6
META-INF/maven/io.takari/maven-wrapper/pom.properties
version=0.5.6
groupId=io.takari
artifactId=maven-wrapper
org/apache/maven/wrapper/BootstrapMainStarter.class
package org.apache.maven.wrapper;
public synchronized class BootstrapMainStarter {
public void BootstrapMainStarter();
public void start(String[], java.io.File) throws Exception;
private java.io.File findLauncherJar(java.io.File);
}
org/apache/maven/wrapper/DefaultDownloader$1.class
package org.apache.maven.wrapper;
synchronized class DefaultDownloader$1 extends java.net.Authenticator {
void DefaultDownloader$1(DefaultDownloader);
protected java.net.PasswordAuthentication getPasswordAuthentication();
}
org/apache/maven/wrapper/DefaultDownloader$SystemPropertiesProxyAuthenticator.class
package org.apache.maven.wrapper;
synchronized class DefaultDownloader$SystemPropertiesProxyAuthenticator extends java.net.Authenticator {
private void DefaultDownloader$SystemPropertiesProxyAuthenticator();
protected java.net.PasswordAuthentication getPasswordAuthentication();
}
org/apache/maven/wrapper/DefaultDownloader.class
package org.apache.maven.wrapper;
public synchronized class DefaultDownloader implements Downloader {
private static final int PROGRESS_CHUNK = 500000;
private static final int BUFFER_SIZE = 10000;
private final String applicationName;
private final String applicationVersion;
public void DefaultDownloader(String, String);
private void configureProxyAuthentication();
private void configureAuthentication();
public void download(java.net.URI, java.io.File) throws Exception;
private void downloadInternal(java.net.URI, java.io.File) throws Exception;
private void addBasicAuthentication(java.net.URI, java.net.URLConnection) throws java.io.IOException;
private String base64Encode(String);
private String calculateUserInfo(java.net.URI);
private String calculateUserAgent();
}
org/apache/maven/wrapper/Downloader.class
package org.apache.maven.wrapper;
public abstract interface Downloader {
public abstract void download(java.net.URI, java.io.File) throws Exception;
}
org/apache/maven/wrapper/Installer.class
package org.apache.maven.wrapper;
public synchronized class Installer {
public static final String DEFAULT_DISTRIBUTION_PATH = wrapper/dists;
private final Downloader download;
private final PathAssembler pathAssembler;
public void Installer(Downloader, PathAssembler);
public java.io.File createDist(WrapperConfiguration) throws Exception;
private java.util.List listDirs(java.io.File);
private void setExecutablePermissions(java.io.File);
private boolean isWindows();
private boolean deleteDir(java.io.File);
public void unzip(java.io.File, java.io.File) throws java.io.IOException;
public void copyInputStream(java.io.InputStream, java.io.OutputStream) throws java.io.IOException;
}
org/apache/maven/wrapper/Logger.class
package org.apache.maven.wrapper;
public synchronized class Logger {
private static final boolean VERBOSE;
static void ();
public void Logger();
public static void info(String);
public static void warn(String);
}
org/apache/maven/wrapper/MavenWrapperMain.class
package org.apache.maven.wrapper;
public synchronized class MavenWrapperMain {
public static final String DEFAULT_MAVEN_USER_HOME;
public static final String MAVEN_USER_HOME_PROPERTY_KEY = maven.user.home;
public static final String MAVEN_USER_HOME_ENV_KEY = MAVEN_USER_HOME;
public static final String MVNW_VERBOSE = MVNW_VERBOSE;
public static final String MVNW_USERNAME = MVNW_USERNAME;
public static final String MVNW_PASSWORD = MVNW_PASSWORD;
public static final String MVNW_REPOURL = MVNW_REPOURL;
public static final String MVN_VERSION = 3.6.3;
public static final String MVN_PATH = org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip;
static void ();
public void MavenWrapperMain();
public static void main(String[]) throws Exception;
private static java.util.Map parseSystemPropertiesFromArgs(String[]);
private static void addSystemProperties(java.io.File);
private static java.io.File rootDir(java.io.File);
private static java.io.File wrapperProperties(java.io.File);
private static java.io.File wrapperJar();
static String wrapperVersion();
private static java.io.File mavenUserHome();
}
org/apache/maven/wrapper/PathAssembler$LocalDistribution.class
package org.apache.maven.wrapper;
public synchronized class PathAssembler$LocalDistribution {
private final java.io.File distZip;
private final java.io.File distDir;
public void PathAssembler$LocalDistribution(PathAssembler, java.io.File, java.io.File);
public java.io.File getDistributionDir();
public java.io.File getZipFile();
}
org/apache/maven/wrapper/PathAssembler.class
package org.apache.maven.wrapper;
public synchronized class PathAssembler {
public static final String MAVEN_USER_HOME_STRING = MAVEN_USER_HOME;
public static final String PROJECT_STRING = PROJECT;
private java.io.File mavenUserHome;
public void PathAssembler();
public void PathAssembler(java.io.File);
public PathAssembler$LocalDistribution getDistribution(WrapperConfiguration);
private String rootDirName(String, WrapperConfiguration);
private String getMd5Hash(String);
private String removeExtension(String);
private String getDistName(java.net.URI);
private java.io.File getBaseDir(String);
}
org/apache/maven/wrapper/SystemPropertiesHandler.class
package org.apache.maven.wrapper;
public synchronized class SystemPropertiesHandler {
public void SystemPropertiesHandler();
public static java.util.Map getSystemProperties(java.io.File);
}
org/apache/maven/wrapper/WrapperConfiguration.class
package org.apache.maven.wrapper;
public synchronized class WrapperConfiguration {
public static final String ALWAYS_UNPACK_ENV = MAVEN_WRAPPER_ALWAYS_UNPACK;
public static final String ALWAYS_DOWNLOAD_ENV = MAVEN_WRAPPER_ALWAYS_DOWNLOAD;
private boolean alwaysUnpack;
private boolean alwaysDownload;
private java.net.URI distribution;
private String distributionBase;
private String distributionPath;
private String zipBase;
private String zipPath;
public void WrapperConfiguration();
public boolean isAlwaysDownload();
public void setAlwaysDownload(boolean);
public boolean isAlwaysUnpack();
public void setAlwaysUnpack(boolean);
public java.net.URI getDistribution();
public void setDistribution(java.net.URI);
public String getDistributionBase();
public void setDistributionBase(String);
public String getDistributionPath();
public void setDistributionPath(String);
public String getZipBase();
public void setZipBase(String);
public String getZipPath();
public void setZipPath(String);
}
org/apache/maven/wrapper/WrapperExecutor.class
package org.apache.maven.wrapper;
public synchronized class WrapperExecutor {
public static final String DISTRIBUTION_URL_PROPERTY = distributionUrl;
public static final String DISTRIBUTION_BASE_PROPERTY = distributionBase;
public static final String ZIP_STORE_BASE_PROPERTY = zipStoreBase;
public static final String DISTRIBUTION_PATH_PROPERTY = distributionPath;
public static final String ZIP_STORE_PATH_PROPERTY = zipStorePath;
private final java.util.Properties properties;
private final java.io.File propertiesFile;
private final Appendable warningOutput;
private final WrapperConfiguration config;
public static WrapperExecutor forProjectDirectory(java.io.File, Appendable);
public static WrapperExecutor forWrapperPropertiesFile(java.io.File, Appendable);
void WrapperExecutor(java.io.File, java.util.Properties, Appendable);
private java.net.URI prepareDistributionUri() throws java.net.URISyntaxException;
private java.net.URI readDistroUrl() throws java.net.URISyntaxException;
private static void loadProperties(java.io.File, java.util.Properties) throws java.io.IOException;
public java.net.URI getDistribution();
public WrapperConfiguration getConfiguration();
public void execute(String[], Installer, BootstrapMainStarter) throws Exception;
private String getProperty(String);
private String getProperty(String, String);
private String reportMissingProperty(String);
}
org/apache/maven/wrapper/cli/AbstractCommandLineConverter.class
package org.apache.maven.wrapper.cli;
public abstract synchronized class AbstractCommandLineConverter implements CommandLineConverter {
public void AbstractCommandLineConverter();
public Object convert(Iterable) throws CommandLineArgumentException;
public Object convert(ParsedCommandLine) throws CommandLineArgumentException;
public Object convert(Iterable, Object) throws CommandLineArgumentException;
protected abstract Object newInstance();
}
org/apache/maven/wrapper/cli/AbstractPropertiesCommandLineConverter.class
package org.apache.maven.wrapper.cli;
public abstract synchronized class AbstractPropertiesCommandLineConverter extends AbstractCommandLineConverter {
public void AbstractPropertiesCommandLineConverter();
protected abstract String getPropertyOption();
protected abstract String getPropertyOptionDetailed();
protected abstract String getPropertyOptionDescription();
public void configure(CommandLineParser);
protected java.util.Map newInstance();
public java.util.Map convert(ParsedCommandLine, java.util.Map) throws CommandLineArgumentException;
}
org/apache/maven/wrapper/cli/CommandLineArgumentException.class
package org.apache.maven.wrapper.cli;
public synchronized class CommandLineArgumentException extends RuntimeException {
public void CommandLineArgumentException(String);
public void CommandLineArgumentException(String, Throwable);
}
org/apache/maven/wrapper/cli/CommandLineConverter.class
package org.apache.maven.wrapper.cli;
public abstract interface CommandLineConverter {
public abstract Object convert(Iterable) throws CommandLineArgumentException;
public abstract Object convert(Iterable, Object) throws CommandLineArgumentException;
public abstract Object convert(ParsedCommandLine) throws CommandLineArgumentException;
public abstract Object convert(ParsedCommandLine, Object) throws CommandLineArgumentException;
public abstract void configure(CommandLineParser);
}
org/apache/maven/wrapper/cli/CommandLineOption.class
package org.apache.maven.wrapper.cli;
public synchronized class CommandLineOption {
private final java.util.Set options;
private Class argumentType;
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here