Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ HELP.md
mvnw
mvnw.cmd
target/

68 changes: 68 additions & 0 deletions EmployeeCreateCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
@Service
public class EmployeeCreateCommand implements ResultCommandInterface<Employee> {
private Employee employee;
private boolean initialEmployee;
private EmployeeRepository employeeRepository;
final EmployeeEntity employeeEntity;

public Employee validate() {

if (initialEmployee == true) {
employee.setClassification(
EmployeeClassification.GENERAL_MANAGER.getClassification());
}


employeeEntity =
this.employeeRepository.save(employeeEntity(this.employee));
this.employee.setId(employeeEntity.getId());

this.employee.setPassword(StringUtils.EMPTY);
this.employee.setCreatedOn(employeeEntity.getCreatedOn());
this.employee.setEmployeeId(
employeeEntity.getEmployeeId());

return this.employee;
}

private void checkIfEmpty() {
if (StringUtils.isBlank(this.eployee.getFirstName())) {
throw new Exception("firstNameIsEmpty");
}
if (StringUtils.isBlank(this.employee.getLastName())) {
throw new Exception("lastNameIsEmpty");
}
if (StringUtils.isBlank(this.employee.getPassword())) {
throw new Exception("passwordIsEmpty");
}

if (isInitialEmployee == false
&& (EmployeeClassification.map(this.employee.getClassification()) == EmployeeClassification.NOT_DEFINED)) {

throw new Exception("classification");
}
}

public Employee getEmployee() {
return employee;
}

public EmployeeCreateCommand setEmployee(final Employee employee) {
this.employee = employee;
return this.employee;
}

public boolean getInitialEmployee() {
return this.initialEmployee;
}

public EmployeeCreateCommand setInitialEmployee(final boolean setInitial) {

initialEmployee = setInitial;
return initialEmployee;
}

public EmployeeCreate() {
initialEmployee = false;
}
}
28 changes: 28 additions & 0 deletions EmployeeQuery.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import java.util.UUID;

public class EmployeeQuery {
private UUID employeeID;

public Employee returnEmployee() {
@Autowired
EmployeeRepository idFinder;
EmployeeEntity findID = idFinder.findById(this.employeeID);
Employee employee = new Employee(findID.get()); ;

if (findID){
return employee;
}
else {
throw new Exception("NotFoundException");
}
}

public UUID getEmployeeID() {
return this.employeeID;
}

public setEmployeeID(final UUID idSet) {
employeeID = idSet;
return employeeID;
}
}
31 changes: 31 additions & 0 deletions EmployeeSignIn.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package edu.uark.registerapp.models.api;
//This is from ApiResponse.java, aka under models/api
import org.apache.commons.lang3.StringUtils;

public class EmployeeSignIn {
private String employeeId;

public String getId() {
return this.employeeId;
}

public SignIn setId(final String employeeId) {
this.employeeId = employeeId;
return this;
}

private String password;
public String getPword() {
return this.password;
}
public EmployeeSignIn setPword( final String password) {
this.password = password;
return this;
}

public EmployeeSignIn(final String password, final String employeeId) {
this.password = StringUtils.EMPTY;
this.employeeId = StringUtils.EMPTY;
}

}
59 changes: 59 additions & 0 deletions EmployeeUpdateCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@Service
public class EmployeeUpdateCommand implements ResultCommandInterface<Employee> {

private Employee employee;
private EmployeeRepository employeeRepository;
private UUID employeeId;

public Employee validate() {
this.validateProperties();

this.updateEntity();

return this.employee;
}

// Helper methods
private void validateProperties() {
if (StringUtils.isBlank(this.employee.getFirstName())) {
throw new Exception("firstNameIsEmpty");
}
if (StringUtils.isBlank(this.employee.getLastName())) {
throw new Exception("lastNameIsEmpty");
}
if (EmployeeClassification.map(this.employee.getClassification()) == EmployeeClassification.NOT_DEFINED) {
throw new Exception("classification");
}
}

private void updateEntity() {
final EmployeeEntity employeeEntity =
this.employeeRepository.findById(this.employeeId);

if (employeeEntity) {
throw new Exception("employeeDoesNotExist");
}

this.employee = employeeEntity.get()
.synchronize(this.employee);

this.employeeRepository.save(employeeEntity.get());
}

public UUID getEmployeeId() {
return this.employeeId;
}
public EmployeeUpdateCommand setEmployeeId(final UUID idSet) {
this.employeeId = idSet;
return this.employeeId;
}

public Employee getEmployee() {
return this.employee;
}

public EmployeeUpdate setEmployee(final Employee employee) {
this.employee = employee;
return this;
}
}
59 changes: 59 additions & 0 deletions Main_Menu_View.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<html xmlns:th="https://www.thymeleaf.org">

<head>
<title>Main Menu</title>

</head>
<body>


<br />
<div>
<button id="start_TransactionButton" type="button" class="action" >Start Transaction</button>
<br /><br />
<button id="view_ProductsButton" type="button" class="action">View Products</button>
<br /><br />

<div th:switch="${isElevatedUser} ? ${true} : ${false} ">
<span th:case="${false}">
<p hidden>
<button id="Create_EmployeeButton" type="button" class="action">Create Employee</button>
<br /><br />
<button id="Sales_ReportButton" type="button" class="action">Sales Report </button>
<br /><br />
<button id="Cashier_ReportButton" type="button" class="action">Cashier Report</button>
<br />
</p>
</span>
</div>
<span th:case="${true}">
<div th:unless="${isElevatedUser}" >
<button id="Create_EmployeeButton" type="button" class="action">Create Employee</button>
<br /><br />
<button id="Sales_ReportButton" type="button" class="action">Sales Report </button>
<br /><br />
<button id="Cashier_ReportButton" type="button" class="action">Cashier Report</button>
<br />
</div>
</span>
</div>




<div style="float:right">
<form align="right" name="form1" method="post" action="/">
<img id="signOutImg" style='height:50px' src="power_settings_new-24px.svg" alt="Sign Out" >
</label>
</form>
</div>
<script type="text/javascript" src="file:///C:/Users/NARMINE%20BEN%20AISSA/Desktop/Fall2020/CSCE%203513/Sprint2-V1/scripts/mainMenu.js" ></script>
<script type="text/javascript" src="file:///C:/Users/NARMINE%20BEN%20AISSA/Desktop/Fall2020/CSCE%203513/Sprint2-V1/scripts/master.js" >

</script>



</body>
</html>

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ The application defaults to port 8080.
To start from the IDE press F5 to run. This will open the debug and run view. You will need to create a launch configuration which Visual Studio Code will help you with.

# Landing page (list available products)
`https://uarkregappjava.herokuapp.com/`
`https://uarkregappjava.herokuapp.com/`
34 changes: 34 additions & 0 deletions SignIn.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org">
<head>
<title>Sign In</title>

<link rel="stylesheet" type="text/css" href="/styles/master.css">
<link rel="stylesheet" type="text/css" href="/styles/s=SignIn.css">

<script type="text/javascript" src="/scripts/master.js" defer></script>
<script type="text/javascript" src="/scripts/SignIn.js" defer></script>
</head>
<body>
<div>
<h1>Sign In</h1>
</div>

<div id="main" class="main">
<div id="error" th:class="${#strings.isEmpty(errorMessage)} ? hidden : ''">
<h4 id="errorMessage" class="error-message" th:text="${errorMessage}"></h4>
</div>



<form action = "/" method = "POST" onsubmit="return ValidationEvent()">
<input id = "number" type = "number" name = "number" placeholder = "Employee ID" th:value="${number}"/> <br>
<input id = "password" type = "password" name = "password" placeholder = "Password" /> <br>
<input type = "submit" value = "Sign In" />
</form>



</body>

</html>
51 changes: 51 additions & 0 deletions SignIn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
document.addEventListener("DOMContentLoaded",function(event){
const changeID = getchangeID();
changeID.focus();
changeID.select();
});

function getchangePword(){
//getter for password
return document.getElementById("password");
}

function getchangeID(){
//getter for ID
return document.getElementById("number");
}

function ValidationEvent(){
// This part deals with invalid inputs for the Employee ID
const changeID = getchangeID();
if(isNaN(Number(changeID.value))){
displayError("Enter a real ID");
changeID.focus();
changeID.select();
return false;
}
else if (Number(changeID.value) <= 0){
displayError("Enter a real ID");
changeID.focus();
changeID.select();
return false;
}
//This part deals with invalid inputs for the Password
const changePword = getchangePword();
if (changePword.value == null){
displayError("Enter real password");
changePword.focus();
changePword.select();
return false;
}
else if (changePword.value.trim() === ""){
displayError("Enter a real password);
changePword.focus();
changePword.select();
return false;

}
// Since this is a validation function, it should return true if valid input

return true;

}
Loading