@@ -14,11 +14,15 @@
import java.util.ArrayList;

/**
* Created by Anthony on 4/20/2017.
* Status: needs work.
* TODO: this is currently not used anywhere. May need to move this to searchResultsPageController
* TODO: - once advanced options are created in UI
*/
public class searchPageController {
public class searchPageController extends UIController{

//VARIABLES FOR SEARCH CRITERIA:
//Search bar info
protected String searchBarContent;
//Date info
protected String from;
protected String to;
@@ -39,6 +43,8 @@ public class searchPageController {

//Variables for JavaFX buttons
@FXML
private TextField searchBar;
@FXML
private DatePicker dpDateRangeStart;
@FXML
private DatePicker dpDateRangeEnd;
@@ -47,11 +53,17 @@ public class searchPageController {
@FXML
private TextField fancifulName;
@FXML
private CheckBox maltBeverageCheckbox;
private CheckBox simpleMaltBeverageCheckbox;
@FXML
private CheckBox simpleOtherCheckbox;
@FXML
private CheckBox simpleWineCheckbox;
@FXML
private CheckBox otherCheckbox;
private CheckBox advMaltBeverageCheckbox;
@FXML
private CheckBox wineCheckbox;
private CheckBox advOtherCheckbox;
@FXML
private CheckBox advWineCheckbox;
@FXML
private TextField state;
@FXML
@@ -78,7 +90,7 @@ protected void returnToMain() throws IOException{
// Handle a search - effectively a "main" function for our program
protected void displayResults() throws IOException {
// Display our new data in the TableView
displayData(searchCriteria());
//displayData(searchCriteria());
}

//Populates the results table with data from the database
@@ -90,18 +102,51 @@ protected void displayData(ObservableList<AppRecord> list) {
}
}

protected ObservableList<AppRecord> searchCriteria() {
@FXML
ObservableList<AppRecord> handleInlineSearch() {
try {
//Set all variables equal to input data
searchBarContent = searchBar.getText();
boolean isMalt = advMaltBeverageCheckbox.isSelected();
boolean isSpirit = advOtherCheckbox.isSelected();
boolean isWine = advWineCheckbox.isSelected();
String params = " WHERE STATUS = 'Accepted' AND";
if (isMalt || isSpirit || isWine) {
params += " (ALCOHOL_TYPE = ";
if (isWine) {params += "'Wine'";}
if (isSpirit && !isWine) {params += "'Distilled Spirits'";}
if (isSpirit && isWine){params += " OR ALCOHOL_TYPE = 'Distilled Spirits'";}
if (isMalt && !(isWine || isSpirit)) {params += "'Malt Beverages'";}
if (isMalt && (isWine || isSpirit)) {params += " OR ALCOHOL_TYPE = 'Malt Beverages'";}
params += ")";
}
if (isMalt || isSpirit || isWine) {
params += " AND (UPPER(BRAND_NAME) LIKE UPPER('%" + searchBarContent +
"%') OR UPPER(FANCIFUL_NAME) LIKE UPPER('%" + searchBarContent + "%'))";
} else {
params += " (UPPER(BRAND_NAME) LIKE UPPER('%" + searchBarContent +
"%') OR UPPER(FANCIFUL_NAME) LIKE UPPER('%" + searchBarContent + "%'))";
}
ArrayList<ArrayList<String>> searchParams = new ArrayList<>();
ObservableList<AppRecord> array = db.findLabels(searchParams, params);
resultsTable.setItems(array);
resultsTable.refresh();
return array;
} catch (Exception e) {
e.printStackTrace();
System.out.println("Could not build a query from search criteria.");
return null;
}
}

protected ObservableList<AppRecord> simpleSearch() {
try {
//Set all variables equal to input data
from = (dpDateRangeStart.getValue()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
to = (dpDateRangeEnd.getValue()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
brand = brandName.getText();
fanciful = fancifulName.getText();
isMalt = maltBeverageCheckbox.isSelected();
isSpirit = otherCheckbox.isSelected();
isWine = wineCheckbox.isSelected();
stateInfo = state.getText();
countryInfo = country.getText();
isMalt = simpleMaltBeverageCheckbox.isSelected();
isSpirit = simpleOtherCheckbox.isSelected();
isWine = simpleWineCheckbox.isSelected();

String params = "APPROVED_DATE BETWEEN '" + from + "' AND '" + to + "'";

@@ -37,23 +37,13 @@ public class searchResultsPageController extends UIController{
//@FXML
//protected void handleInlineSearch() throws SQLException {searchInlineCriteria();}

// TODO:Replace this with returnToMain???
@FXML
public void returnToSearch() throws IOException {
Stage stage;
stage = (Stage) return_to_search.getScene().getWindow();
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("searchPage.fxml"));
Scene scene = new Scene(loader.load());
stage.setScene(scene);
stage.show();
}
//TODO Find out what people want for the goofy wacky and zany COLA search page

@FXML
public void returnToMainPage() throws IOException{
super.returnToMainPage();
}

/**
* This function opens a pop up for the CSV display
* @throws Exception
*/
@FXML
public void displayCSVOptionsPage() throws Exception {
try {
@@ -75,42 +65,10 @@ public void displayCSVOptionsPage() throws Exception {
}
}

@FXML
ObservableList<AppRecord> handleInlineSearch() {
try {
//Set all variables equal to input data
search = search_box.getText();
boolean isMalt = malt_beverage_checkbox.isSelected();
boolean isSpirit = distilled_spirit_checkbox.isSelected();
boolean isWine = wine_checkbox.isSelected();
String params = " WHERE STATUS = 'Accepted' AND";
if (isMalt || isSpirit || isWine) {
params += " (ALCOHOL_TYPE = ";
if (isWine) {params += "'Wine'";}
if (isSpirit && !isWine) {params += "'Distilled Spirits'";}
if (isSpirit && isWine){params += " OR ALCOHOL_TYPE = 'Distilled Spirits'";}
if (isMalt && !(isWine || isSpirit)) {params += "'Malt Beverages'";}
if (isMalt && (isWine || isSpirit)) {params += " OR ALCOHOL_TYPE = 'Malt Beverages'";}
params += ")";
}
if (isMalt || isSpirit || isWine) {
params += " AND (UPPER(BRAND_NAME) LIKE UPPER('%" + search +
"%') OR UPPER(FANCIFUL_NAME) LIKE UPPER('%" + search + "%'))";
} else {
params += " (UPPER(BRAND_NAME) LIKE UPPER('%" + search +
"%') OR UPPER(FANCIFUL_NAME) LIKE UPPER('%" + search + "%'))";
}
ArrayList<ArrayList<String>> searchParams = new ArrayList<>();
ObservableList<AppRecord> array = db.findLabels(searchParams, params);
resultsTable.setItems(array);
resultsTable.refresh();
return array;
} catch (Exception e) {
e.printStackTrace();
System.out.println("Could not build a query from search criteria.");
return null;
}
}
/**
* Function handles all the searching functionality
* @return
*/

private void displayApprovedLabel(Form form) {
try {
File renamed without changes.
@@ -252,7 +252,7 @@ public void displaySearchResultsPage(ObservableList<AppRecord> list) throws Exce
try {
//System.out.println("Hiiiiii");
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("searchResultsPage.fxml"));
loader.setLocation(getClass().getResource("searchPage.fxml"));
AnchorPane page = loader.load();
primaryStage.setTitle("Search Results");
primaryStage.getScene().setRoot(page);
@@ -12,20 +12,6 @@
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="850.0" prefWidth="1000.0">
<children>
<TableView prefHeight="850.0" prefWidth="725.0">
<columns>
<TableColumn prefWidth="75.0" text="Applicant Name" />
<TableColumn prefWidth="75.0" text="Form ID" />
<TableColumn prefWidth="75.0" text="Permit No." />
<TableColumn prefWidth="75.0" text="Serial No." />
<TableColumn prefWidth="75.0" text="Completed Date" />
<TableColumn prefWidth="75.0" text="Fanciful Name" />
<TableColumn prefWidth="75.0" text="Brand Name" />
<TableColumn prefWidth="75.0" text="Country" />
<TableColumn prefWidth="41.0" text="State" />
<TableColumn prefWidth="81.0" text="Alcohol Type" />
</columns>
</TableView>
<Accordion layoutX="740.0" layoutY="30.0" prefHeight="780.0" prefWidth="200.0">
<panes>
<TitledPane animated="false" text="Simple Filters">
@@ -69,6 +55,28 @@
</TitledPane>
</panes>
</Accordion>
<ScrollPane prefHeight="830.0" prefWidth="725.0">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="830.0" prefWidth="1000.0">
<children>
<TableView layoutY="-10.0" prefHeight="850.0" prefWidth="1000.0">
<columns>
<TableColumn prefWidth="100.0" text="Applicant Name" />
<TableColumn prefWidth="100.0" text="Form ID" />
<TableColumn prefWidth="100.0" text="Permit No." />
<TableColumn prefWidth="100.0" text="Serial No." />
<TableColumn prefWidth="100.0" text="Completed Date" />
<TableColumn prefWidth="100.0" text="Fanciful Name" />
<TableColumn prefWidth="100.0" text="Brand Name" />
<TableColumn prefWidth="100.0" text="Country" />
<TableColumn prefWidth="100.0" text="State" />
<TableColumn prefWidth="100.0" text="Alcohol Type" />
</columns>
</TableView>
</children>
</AnchorPane>
</content>
</ScrollPane>
</children></AnchorPane>
</content>
</ScrollPane>
@@ -1,25 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.shape.Rectangle?>
<?import javafx.scene.text.Font?>

<ScrollPane fitToHeight="true" fitToWidth="true" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1000.0" style="-fx-background-color: #ffffff;" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.mainPageController">
<content>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1000.0" style="-fx-background-color: #ffffff;">
<children>
<HBox fx:id="imagebox" layoutX="350.0" layoutY="132.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="300.0" prefWidth="300.0" AnchorPane.bottomAnchor="368.0" AnchorPane.leftAnchor="350.0" AnchorPane.rightAnchor="350.0" AnchorPane.topAnchor="132.0" />
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="WHITE" height="352.0" layoutY="105.0" stroke="WHITE" strokeType="INSIDE" width="354.0" />
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="WHITE" height="352.0" layoutX="649.0" layoutY="107.0" stroke="WHITE" strokeType="INSIDE" width="350.0" />
<Button fx:id="searchButton" layoutX="385.0" layoutY="501.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="45.0" prefWidth="230.0" text="Database Search" AnchorPane.leftAnchor="385.0" AnchorPane.rightAnchor="385.0">
<font>
<Font size="24.0" />
</font>
</Button>
</children>
</AnchorPane>
</content>
</ScrollPane>
<AnchorPane prefHeight="500.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.mainPageController">
<children>
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#FFFFFF" height="1000.0" layoutX="551.0" layoutY="129.0" stroke="BLACK" strokeType="INSIDE" width="1500.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="100.0" />
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#e8491d" height="110.0" stroke="BLACK" strokeType="INSIDE" width="1500.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#35424a" height="100.0" stroke="BLACK" strokeType="INSIDE" width="1500.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
<Button fx:id="searchButton" layoutX="387.0" layoutY="190.0" mnemonicParsing="false" onMouseClicked="#setDisplayToSearch" text="Database Search">
<font>
<Font size="24.0" />
</font></Button>
<Button fx:id="loginButton" layoutX="453.0" layoutY="282.0" mnemonicParsing="false" onMouseClicked="#setDisplayToLoginPage" text="Log In">
<font>
<Font size="24.0" />
</font></Button>
<Label fx:id="currentUserLabel" layoutX="126.0" layoutY="465.0" prefHeight="21.0" prefWidth="147.0" />
<Label layoutX="14.0" layoutY="465.0" prefHeight="21.0" prefWidth="112.0" text="LOGIN STATUS:" />
<Label layoutX="173.0" layoutY="30.0" text="Welcome to the COLA Database System">
<font>
<Font size="36.0" />
</font>
</Label>
<Hyperlink fx:id="aboutLink" layoutX="924.0" layoutY="458.0" onMouseClicked="#setDisplayToAboutPageTemp" text="About" textAlignment="CENTER" underline="true">
<font>
<Font size="16.0" />
</font>
</Hyperlink>
</children>
</AnchorPane>

This file was deleted.

@@ -14,14 +14,14 @@
<children>
<TableView prefHeight="850.0" prefWidth="725.0">
<columns>
<TableColumn prefWidth="50.0" text="User ID" />
<TableColumn prefWidth="100.0" text="Username" />
<TableColumn prefWidth="100.0" text="First Name" />
<TableColumn prefWidth="50.0" text="Middle Initial" />
<TableColumn prefWidth="100.0" text="Last Name" />
<TableColumn prefWidth="78.0" text="User ID" />
<TableColumn prefWidth="110.0" text="Username" />
<TableColumn prefWidth="94.0" text="First Name" />
<TableColumn prefWidth="54.0" text="Middle Initial" />
<TableColumn prefWidth="92.0" text="Last Name" />
<TableColumn prefWidth="100.0" text="Email" />
<TableColumn prefWidth="100.0" text="Phone Number" />
<TableColumn prefWidth="100.0" text="Authentication" />
<TableColumn prefWidth="122.0" text="Phone Number" />
<TableColumn minWidth="0.0" prefWidth="74.0" text="Authentication" />
</columns>
</TableView>
<Accordion layoutX="740.0" layoutY="30.0" prefHeight="780.0" prefWidth="233.0">
@@ -43,19 +43,6 @@
</AnchorPane>
</content>
</TitledPane>
<TitledPane animated="false" text="Save Results">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<TextField layoutX="30.0" layoutY="140.0" prefHeight="25.0" prefWidth="189.0" />
<Label layoutX="62.0" layoutY="14.0" text="CSV Format Options" />
<RadioButton layoutX="15.0" layoutY="50.0" mnemonicParsing="false" text="Generate comma separated values" />
<RadioButton layoutX="15.0" layoutY="80.0" mnemonicParsing="false" text="Generate tab separated values" />
<RadioButton layoutX="15.0" layoutY="110.0" mnemonicParsing="false" text="Generate user specifiec separation:" />
</children>
</AnchorPane>
</content>
</TitledPane>
</panes>
</Accordion>
</children></AnchorPane>