For this assignment, you will need to use a Netbeans project which you will need to name using your Last name followed by your first name followed by “-Homework2” to name it After completing the assignment, zip the project directory and turn in via blackboard by the due date. For this assignment, you may begin with the result of homework #2 (note: you may use my solution if you want). If you do, please rename according to rules above. Part I: (25%): Validation 1. As a reminder, you were asked to create POST and PUT endpoints for reviews in homework #2. We’re going to setup validation requirements for BOTH of those endpoints. 2. (5%) You will need to ensure both endpoints are setup to ensure only valid products. 3. (10%) You need to setup the following constraints for the employee: a. SKU must be present and in the correct range (7-digit number) b. Name cannot be blank and must be no longer than 30 characters c. Description cannot be blank and must be no longer than 300 characters d. Category cannot be blank and must be no longer than 30 characters e. SellerID must be present and in the correct range (7-digit number) f. Price must be a positive value number 4. (10%) You will need to setup an exception handler which handles validation issues. Copy the exception handler we used in class for this purpose into your project. Part II: New GET endpoints 1. (15%) Get all products from a given seller (do NOT use custom queries) using the seller’s name a. If seller doesn’t exist, return an empty list b. otherwise, return all products listed by a given seller 2. (15%) Get all products offered in a given state (please use the two letter abbreviation) a. Given the state abbreviation, return all products that are sold in the given state. Part III: (30%) Generating HTML files for the project 1. All pages should be in static folder of the project so that they appear when the web server runs. 2. (20%) Create several web pages that show the products sorted in different ways (Hint: use orderby in your queries). Note I should see BOTH the code and the actual pages. a. index.html – a page which contains the products sorted by their SKUs (ascending) b. name.html – a page which contains the products sorted by their name (ascending) c. seller.html – a page which contains the products sorted by their sellers name (ascending) d. price.html – a page which contains the products sorted by their price (ascending) 3. (10%) The lists shown in these pages should be in a HTML table that shows the SKU, Names, Seller’s Name, and Price for each product. (you should alternate colors between rows and have a table header identifying what item goes where) Part IV: (20%) Creating an Add Product form 1. (20%) Create an addProduct.html page which has a form with the following elements: a. (2%) The action should be addProduct.html and the method should be GET b. (5%) The forms should have input text fields for all fields in the product except category and a textarea for the description. c. (5%) The form should have a select box to select from a list of categories available. d. (2%) The form should include a submit button and a reset button e. (1%) The title of the page and the heading on the page should read “Add New Product”. Part V: (25%) Creating the website 1. (10%) In the pages for the different review lists, change the column headers to be links to the appropriately sorted page. 2. (5%) In the pages for the different review lists, create a link to the add product page. 3. (5%) In the add product page, create a link to the list (index.html) 4. (10%) For all pages, use an external style sheet to beautify the pages in some way. Note: • For Part III/IV/V, the pages should be static and generated via java code within the project. You may handwrite Part IV/Part V, but not Part III. • If the project or the zipped file is NOT named correctly, I will take 10 points off the total score. • If the files within the project are named incorrectly, I will take 10 points off the total score. • If the project doesn’t contain sufficient comments, I will take 10 points off the total score. • This is an individual assignment and what you turn in should represent only your work. • Do NOT try to do this last minute!
-
CST367467-Homework2Setup.zip
-
homework2.pdf
CST367467-Homework2Setup/pom.xml
4.0.0 com.mycompany CST367467-Homework2Setup 1.0-SNAPSHOT jar UTF-8 21 21 com.mycompany.cst367467.homework2setup.CST367467Homework2Setup
CST367467-Homework2Setup/src/main/java/com/mycompany/cst367467/homework2setup/InitDB.java
CST367467-Homework2Setup/src/main/java/com/mycompany/cst367467/homework2setup/InitDB.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
*/
package com . mycompany . cst367467 . homework2setup ;
import java . sql . Connection ;
import java . sql . DriverManager ;
/**
* I actually just renamed SetupDB (MySQLTest) to InitDB
*
* and changed the table/column names...
* @author mruth
*/
public class InitDB {
/**
* @param args the command line arguments
*/
public static void main ( String [] args ) {
try {
Connection conn = DriverManager . getConnection (
"jdbc:mysql://localhost:3306/database" ,
"user" , "user" );
//jdbc:mysql://localhost/db?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
System . out . println ( "If Table Exists... drop it like it's hot" );
try {
String sql = "DROP TABLE PRODUCTS" ;
conn . createStatement (). execute ( sql );
System . out . println ( "Table Dropped!" );
} catch ( Exception e ) {
System . out . println ( "Table Didn't Exist" );
}
try {
String sql = "DROP TABLE SELLERS" ;
conn . createStatement (). execute ( sql );
System . out . println ( "Table Dropped!" );
} catch ( Exception e ) {
System . out . println ( "Table Didn't Exist" );
}
String sql = "CREATE TABLE SELLERS (" ;
sql = sql + " SID INTEGER PRIMARY KEY," ;
sql = sql + " NAME VARCHAR(50)," ;
sql = sql + " CITY VARCHAR(50)," ;
sql = sql + " STATE VARCHAR(2))" ;
conn . createStatement (). execute ( sql );
System . out . println ( "Table SELLERS created!" );
sql = "CREATE TABLE PRODUCTS (" ;
sql = sql + " SKU INTEGER PRIMARY KEY," ;
sql = sql + " NAME VARCHAR(50)," ;
sql = sql + " DESCRIPTION VARCHAR(200)," ;
sql = sql + " CATEGORY VARCHAR(50)," ;
sql = sql + " SID INTEGER," ;
sql = sql + " PRICE DOUBLE ," ;
sql = sql + " FOREIGN KEY (SID) REFERENCES SELLERS(SID))" ;
conn . createStatement (). execute ( sql );
System . out . println ( "Table PRODUCTS created!" );
System . out . println ( "DB Complete!" );
conn . close ();
} catch ( Exception e ) {
System . out . println ( e );
}
}
}
CST367467-Homework2Setup/src/main/java/com/mycompany/cst367467/homework2setup/PopulateDB.java
CST367467-Homework2Setup/src/main/java/com/mycompany/cst367467/homework2setup/PopulateDB.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
*/
package com . mycompany . cst367467 . homework2setup ;
import java . sql . Connection ;
import java . sql . DriverManager ;
import java . sql . ResultSet ;
import java . sql . SQLException ;
import java . util . ArrayList ;
import java . util . Random ;
/**
* Renamed PopulateDBFixedBetter (MySQLTest) to PopulateDB
* @author mruth
*/
public class PopulateDB {
public static Connection conn ;
/**
* @param args the command line arguments
*/
public static void main ( String [] args ) {
try {
conn = DriverManager . getConnection (
"jdbc:mysql://localhost:3306/database" ,
"user" , "user" );
generateSellers ();
generateProducts ( 50 );
} catch ( Exception e ) {
System . out . println ( e );
}
}
public static void generateSellers () {
- WE OFFER THE BEST CUSTOM PAPER WRITING SERVICES. WE HAVE DONE THIS QUESTION BEFORE, WE CAN ALSO DO IT FOR YOU.
- Assignment status: Already Solved By Our Experts
- (USA, AUS, UK & CA PhD. Writers)
- CLICK HERE TO GET A PROFESSIONAL WRITER TO WORK ON THIS PAPER AND OTHER SIMILAR PAPERS, GET A NON PLAGIARIZED PAPER FROM OUR EXPERTS
QUALITY: 100% ORIGINAL PAPER – NO ChatGPT.NO PLAGIARISM – CUSTOM PAPER
Looking for unparalleled custom paper writing services? Our team of experienced professionals at AcademicWritersBay.com is here to provide you with top-notch assistance that caters to your unique needs.
We understand the importance of producing original, high-quality papers that reflect your personal voice and meet the rigorous standards of academia. That’s why we assure you that our work is completely plagiarism-free—we craft bespoke solutions tailored exclusively for you.
Why Choose AcademicWritersBay.com?
- Our papers are 100% original, custom-written from scratch.
- We’re here to support you around the clock, any day of the year.
- You’ll find our prices competitive and reasonable.
- We handle papers across all subjects, regardless of urgency or difficulty.
- Need a paper urgently? We can deliver within 6 hours!
- Relax with our on-time delivery commitment.
- We offer money-back and privacy guarantees to ensure your satisfaction and confidentiality.
- Benefit from unlimited amendments upon request to get the paper you envisioned.
- We pledge our dedication to meeting your expectations and achieving the grade you deserve.
Our Process: Getting started with us is as simple as can be. Here’s how to do it:
- Click on the “Place Your Order” tab at the top or the “Order Now” button at the bottom. You’ll be directed to our order form.
- Provide the specifics of your paper in the “PAPER DETAILS” section.
- Select your academic level, the deadline, and the required number of pages.
- Click on “CREATE ACCOUNT & SIGN IN” to provide your registration details, then “PROCEED TO CHECKOUT.”
- Follow the simple payment instructions and soon, our writers will be hard at work on your paper.
AcademicWritersBay.com is dedicated to expediting the writing process without compromising on quality. Our roster of writers boasts individuals with advanced degrees—Masters and PhDs—in a myriad of disciplines, ensuring that no matter the complexity or field of your assignment, we have the expertise to tackle it with finesse. Our quick turnover doesn’t mean rushed work; it means efficiency and priority handling, ensuring your deadlines are met with the excellence your academics demand.