Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Commit

Permalink
finish README
Browse files Browse the repository at this point in the history
  • Loading branch information
L23de committed May 4, 2022
1 parent 17eddb6 commit b5699ac
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 153 deletions.
55 changes: 43 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,25 @@ levels at a fictional company, Northside Uncommons Management of Apartments (NUM

```dir
.
├── setup.sql # Driver script to setup the database relations
├── shutdown.sql # Script to bring down the entire database
├── triggers/ # Holds the individual trigger scripts
├── mock/ # CSV files containing mock data for populating the database
├── db/ # Static files for configuring the database [Some scripts are outdated]
| ├── setup.sql # Brings up the database from scratch
| ├── shutdown.sql # Shuts down the database taking into account dependencies
| ├── generate.py # Generate data
| ├── sqlconvert.py # Converts generated data to SQL statements
| ├── mock/ # Store for generated data
| ├── function/ # PL/SQL Functions
| ├── procedures/ # PL/SQL Procedures
| ├── triggers/ # SQL Triggers
| ├── types/ # SQL Custom Defined Types
| ├── queries/ # Queries used in the console
| └── updates/ # Database updated used in the console
|
├── numa/src/main/java/numa # NUMA Console Source Files
| ├── NUMA.java # Main Driver
| ├── Reader.java # Console in reader
| ├── Portals/ # Handles all the portal activities
| └── Exceptions/ # Custom exceptions
|
├── Schema.pdf # Database Schema Diagram
├── .git/
├── .gitignore
Expand All @@ -34,8 +49,21 @@ The following schemas were generated using the aid of [Mockaroo](https://www.moc

### Test Data

Below is some pre-populated data that can be used for testing purposes

> Note: Not all mock data has been updated. Some of the data values were manually converted to use PL/SQL Procedures/Functions once they were implemented
Properties:
![Properties Data](images/property.png)

Apartments:
![Apartment Data](images/apartments.png)

People:
![People Data](images/person.png)

Leases:
![Lease Data](images/lease.png)

> Note: Not all mock data scripts have been updated. Some of the data values were manually converted to use PL/SQL Procedures/Functions that were implemented later on
## Functions

Expand All @@ -44,13 +72,16 @@ The following schemas were generated using the aid of [Mockaroo](https://www.moc
- Make Payment - View upcoming payments and pay for them
- My Lease Details - View details about their lease and their personal information

- Management Portal
- Management Portal (Requires sign-in with a valid PIN)
- Properties - View properties and apartment details
- People - View personal information of people on file
- Lease - Create a new lease or modify a single lease's length
- Visits - Register a person's tour of an apartment (Add's person information if they don't already exist)
- Change PIN - change Management Portal's PIN)

### Assumptions

-


## Dev Notes

- When a user logins to the system, the system should automatically create a view for that user that only represents the info that they can see. All queries will be used on that
- Payments are made in full (Even for outstanding, late payments)
- Late payments don't have late fees
- Only one lease can be signed to each resident
- Everyone on a lease is treated the same (There are no primary signees)
33 changes: 0 additions & 33 deletions TODO.txt

This file was deleted.

Binary file added images/apartments.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/lease.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/person.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/property.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
147 changes: 72 additions & 75 deletions numa/src/main/java/numa/Portals/ManagementPortal.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,93 +111,90 @@ private void properties() throws SQLException, IOException, ExitException, MenuE
System.out.println(BOLD_ON + "Properties:" + BOLD_OFF);
System.out.println(outStr);

String prompt = String.format(
"View apartments under a property [1-%s], 'a' to add a property, 'm' to menu or 'q' to quit: ",
counter
);
String action = input.getPrompt(prompt).toLowerCase().replaceAll("\\s+","");
while(true) {

try (
PreparedStatement getApts = conn.prepareStatement("select * from apartment where prop_id = ?");
) {
int propId = Integer.parseInt(action);
getApts.setInt(1, propId);
ResultSet aptRes = getApts.executeQuery();
ArrayList<Apartment> aptList = new ArrayList<Apartment>();


System.out.format(
"%s%s Apartments:%s\n",
BOLD_ON,
props.get(counter - 1).toString(),
BOLD_OFF
String prompt = String.format(
"View apartments under a property [1-%s], 'a' to add a property, 'm' to menu or 'q' to quit: ",
counter
);
String action = input.getPrompt(prompt).toLowerCase().replaceAll("\\s+","");

try (
PreparedStatement getApts = conn.prepareStatement("select * from apartment where prop_id = ?");
) {
int propId = Integer.parseInt(action);
getApts.setInt(1, propId);
ResultSet aptRes = getApts.executeQuery();
ArrayList<Apartment> aptList = new ArrayList<Apartment>();


counter = 0;
while (aptRes.next()) {
int prop_id = aptRes.getInt("prop_id");
String apt = aptRes.getString("apt");
int square_footage = aptRes.getInt("square_footage");
int bed_count = aptRes.getInt("bed_count");
float bath_count = aptRes.getFloat("bath_count");
int rent = aptRes.getInt("rent");

Apartment tmp = new Apartment(prop_id, apt, square_footage, bed_count, bath_count, rent);
aptList.add(tmp);
System.out.format(
"[%d] %s\n",
++counter,
aptList.get(counter - 1).apt
"%s%s Apartments:%s\n",
BOLD_ON,
props.get(counter - 1).toString(),
BOLD_OFF
);
}

System.out.println();

int aptIndex = -1;

counter = 0;
while (aptRes.next()) {
int prop_id = aptRes.getInt("prop_id");
String apt = aptRes.getString("apt");
int square_footage = aptRes.getInt("square_footage");
int bed_count = aptRes.getInt("bed_count");
float bath_count = aptRes.getFloat("bath_count");
int rent = aptRes.getInt("rent");

Apartment tmp = new Apartment(prop_id, apt, square_footage, bed_count, bath_count, rent);
aptList.add(tmp);
System.out.format(
"[%d] %s\n",
++counter,
aptList.get(counter - 1).apt
);
}

while (true) {
prompt = String.format(
"View apartment details [1-%d], 'a' to add apartments, 'm' to menu or 'q' to quit: ",
counter
);
try {
String choice = input.getPrompt(prompt);

aptIndex = Integer.parseInt(choice);
if (aptIndex > 0 && aptIndex <= counter) {
// Show apt specific info
System.out.println(aptList.get(aptIndex - 1).toString());
break;
} else {
System.out.println("Invalid input. Try again\n");
}
} catch (NumberFormatException e) {
switch (action) {
case "a":
// TODO: Bulk add apartments (Same as properties, set property ID)
System.out.println();

int aptIndex = -1;

while (true) {
prompt = String.format(
"View apartment details [1-%d], 'a' to add apartments, 'm' to menu or 'q' to quit: ",
counter
);
try {
String choice = input.getPrompt(prompt);
aptIndex = Integer.parseInt(choice);
if (aptIndex > 0 && aptIndex <= counter) {
// Show apt specific info
System.out.println(aptList.get(aptIndex - 1).toString());
break;
case "m": throw new MenuException();
case "q": throw new ExitException();
default:
} else {
System.out.println("Invalid input. Try again\n");
System.out.println();
}
} catch (NumberFormatException e) {
switch (action) {
case "m": throw new MenuException();
case "q": throw new ExitException();
default:
System.out.println("Invalid input. Try again\n");
}
}
}
}
System.out.println();

} catch (NumberFormatException e ) {
switch (action) {
// "a": // Bulk add properties
case "m": throw new MenuException();
case "q": throw new ExitException();
default:
System.out.println("Invalid input. Try again\n");
System.out.println();
System.out.println();
break;

} catch (NumberFormatException e ) {
switch (action) {
// "a": // Bulk add properties
case "m": throw new MenuException();
case "q": throw new ExitException();
default:
System.out.println("Invalid input. Try again\n");
}
}
}
}
}
System.out.println();
}
}

Expand Down
28 changes: 14 additions & 14 deletions numa/src/main/java/numa/Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ public String getPrompt(String prompt) throws IOException {
}

/** Used for non-menu inputs that allows for input validation */
public String getPrompt(String prompt, Validate validation) throws IOException, ExitException, MenuException, TooManyTriesException {
int i = 0;
while (i++ < MAX_TRIES) {
System.out.print(prompt);
String input = super.readLine();
System.out.println();
Validated res = validation.validate(input);
if (res.valid) {
return res.validated;
}
System.out.println(res.errMsg);
}
throw new TooManyTriesException();
}
// public String getPrompt(String prompt, Validate validation) throws IOException, ExitException, MenuException, TooManyTriesException {
// int i = 0;
// while (i++ < MAX_TRIES) {
// System.out.print(prompt);
// String input = super.readLine();
// System.out.println();
// Validated res = validation.validate(input);
// if (res.valid) {
// return res.validated;
// }
// System.out.println(res.errMsg);
// }
// throw new TooManyTriesException();
// }
}
38 changes: 19 additions & 19 deletions numa/src/main/java/numa/Validated.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package numa;
// package numa;

public class Validated {
String validated;
String errMsg;
boolean valid;
// public class Validated {
// String validated;
// String errMsg;
// boolean valid;

public Validated(String validated, String errMsg, boolean valid) {
this.validated = validated;
this.errMsg = errMsg;
this.valid = valid;
}
}
// public Validated(String validated, String errMsg, boolean valid) {
// this.validated = validated;
// this.errMsg = errMsg;
// this.valid = valid;
// }
// }

interface Validate {
/**
* Validation function format
* Returns true on proper validation and false otherwise
* public boolean validateX();
*/
public Validated validate(String input);
}
// interface Validate {
// /**
// * Validation function format
// * Returns true on proper validation and false otherwise
// * public boolean validateX();
// */
// public Validated validate(String input);
// }

0 comments on commit b5699ac

Please sign in to comment.