The following document contains the results of PMD's CPD 6.0.1.
File | Line |
---|---|
Controllers/AddYearController.java | 84 |
Controllers/UsersGroupsAndYearsController.java | 1402 |
public AddYearController() {} /** * Create the dialog. */ @FXML private void tableFrmXML(ActionEvent event) { FileChooser chooser = new FileChooser(); FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("XML files", "*.xml", "*.XML"); chooser.getExtensionFilters().add(filter); chooser.setSelectedExtensionFilter(filter); // logoLoc.setText(chooser.showOpenDialog(settings).getAbsolutePath()); File xmlFile = chooser.showOpenDialog(parentWindow); if (xmlFile != null) { String path = xmlFile.getAbsolutePath(); createTable(path); } } private void convert(String csvLoc, String xmlLoc) { List<String> headers = new ArrayList<>(5); File file = new File(csvLoc); try (BufferedReader reader = new BufferedReader(new FileReader(file))) { DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder domBuilder = domFactory.newDocumentBuilder(); Document newDoc = domBuilder.newDocument(); // Root element Element rootElement = newDoc.createElement("LawnGarden"); newDoc.appendChild(rootElement); int line = 0; String text; while ((text = reader.readLine()) != null) { StringTokenizer st = new StringTokenizer(text, ";", false); String[] rowValues = new String[st.countTokens()]; int index = 0; while (st.hasMoreTokens()) { String next = st.nextToken(); rowValues[index] = next; index++; } //String[] rowValues = text.split(","); if (line == 0) { // Header row Collections.addAll(headers, rowValues); } else { // Data row Element rowElement = newDoc.createElement("Products"); rootElement.appendChild(rowElement); Attr attr = newDoc.createAttribute("id"); attr.setValue(Integer.toString(line - 1)); rowElement.setAttributeNode(attr); for (int col = 0; col < headers.size(); col++) { String header = headers.get(col); String value; if (col < rowValues.length) { value = rowValues[col].trim(); } else { // ?? Default value value = ""; } Element curElement = newDoc.createElement(header); curElement.appendChild(newDoc.createTextNode(value)); rowElement.appendChild(curElement); } } line++; } OutputStreamWriter osw = null; try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { osw = new OutputStreamWriter(baos); TransformerFactory tranFactory = TransformerFactory.newInstance(); Transformer aTransformer = tranFactory.newTransformer(); aTransformer.setOutputProperty(OutputKeys.INDENT, "yes"); aTransformer.setOutputProperty(OutputKeys.METHOD, "xml"); //aTransformer.setOutputProperty(OutputKeys.ENCODING, "utf-8"); aTransformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); Source src = new DOMSource(newDoc); Result result = new StreamResult(osw); aTransformer.transform(src, result); osw.flush(); //System.out.println(new String(baos.toByteArray())); try (OutputStream outStream = new FileOutputStream(xmlLoc)) {// writing bytes in to byte output stream baos.writeTo(outStream); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error writing XML file. Please try again."); } } catch (Exception exp) { LogToFile.log(exp, Severity.SEVERE, "Error writing XML file. Please try again."); } finally { try { if (osw != null) { osw.close(); } } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error closing file. Please try again."); } } } catch (Exception e) { LogToFile.log(e, Severity.SEVERE, "Error reading CSV file. Ensure the path exists, and the software has permission to read it."); } } @FXML private void csvToXml(ActionEvent event) { // Create the custom dialog. Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("CSV to XML conversion"); // Set the button types. ButtonType convertButtonType = new ButtonType("Convert", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(convertButtonType, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField csvLoc = new TextField(); csvLoc.setPromptText("CSV file Location"); TextField xmlLoc = new TextField(); xmlLoc.setPromptText("XML Location"); Button getCsvLoc = new Button("..."); getCsvLoc.setOnAction(e -> { FileChooser chooser = new FileChooser(); FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("CSV files", "*.csv", "*.CSV"); chooser.getExtensionFilters().add(filter); chooser.setSelectedExtensionFilter(filter); File csv = chooser.showOpenDialog(grid.getScene().getWindow()); if (csv != null) { String path = csv.getAbsolutePath(); if (!path.toLowerCase().endsWith(".csv")) { path += ".csv"; } csvLoc.setText(path); } }); Button getXmlLoc = new Button("..."); getXmlLoc.setOnAction(e -> { FileChooser chooser = new FileChooser(); FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("XML files", "*.xml", "*.XML"); chooser.getExtensionFilters().add(filter); chooser.setSelectedExtensionFilter(filter); File XML = chooser.showSaveDialog(grid.getScene().getWindow()); if (XML != null) { String path = XML.getAbsolutePath(); if (!path.toLowerCase().endsWith(".xml")) { path += ".xml"; } xmlLoc.setText(path); } }); grid.add(new Label("CSV file Location:"), 0, 0); grid.add(csvLoc, 1, 0); grid.add(getCsvLoc, 2, 0); grid.add(new Label("XML Location:"), 0, 1); grid.add(xmlLoc, 1, 1); grid.add(getXmlLoc, 2, 1); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node convertButton = dialog.getDialogPane().lookupButton(convertButtonType); convertButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). csvLoc.textProperty().addListener((observable, oldValue, newValue) -> convertButton.setDisable(newValue.trim().isEmpty())); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> csvLoc.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == convertButtonType) { return new Pair<>(csvLoc.getText(), xmlLoc.getText()); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); result.ifPresent(fileLocations -> { convert(fileLocations.getKey(), fileLocations.getValue()); createTable(fileLocations.getValue()); }); /* CSV2XML csv = new CSV2XML(parent); String xmlFile = csv.getXML(); if (!xmlFile.isEmpty()) { createTable(xmlFile); }*/ } @FXML private void catCmbxChanged(ActionEvent event) { if (Objects.equals(categoriesCmbx.getSelectionModel().getSelectedItem(), "Add Category")) { Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("Add new category"); // Set the button types. ButtonType addCat = new ButtonType("Add", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(addCat, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField catName = new TextField(); catName.setPromptText("Category Name"); DatePicker catDate = new DatePicker(LocalDate.now()); catDate.setPromptText("Category Due Date"); grid.add(new Label("Category Name:"), 0, 0); grid.add(catName, 1, 0); grid.add(new Label("Category Due Date:"), 0, 1); grid.add(catDate, 1, 1); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node addCatButton = dialog.getDialogPane().lookupButton(addCat); addCatButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). catName.textProperty().addListener((observable, oldValue, newValue) -> addCatButton.setDisable(newValue.trim().isEmpty())); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> catName.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == addCat) { return new Pair<String, String>(catName.getText(), catDate.getValue().toString()); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); result.ifPresent(category -> { rowsCats.add(new Year.category(category.getKey(), category.getValue())); Platform.runLater(() -> refreshCmbx()); }); } } private String catCmbxChanged(String newVal) { final Year.category newCat = new Year.category("", ""); if (Objects.equals(newVal, "Add Category")) { Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("Add new category"); // Set the button types. ButtonType addCat = new ButtonType("Add", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(addCat, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField catName = new TextField(); catName.setPromptText("Category Name"); DatePicker catDate = new DatePicker(LocalDate.now()); catDate.setPromptText("Category Due Date"); grid.add(new Label("Category Name:"), 0, 0); grid.add(catName, 1, 0); grid.add(new Label("Category Due Date:"), 0, 1); grid.add(catDate, 1, 1); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node addCatButton = dialog.getDialogPane().lookupButton(addCat); addCatButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). catName.textProperty().addListener((observable, oldValue, newValue) -> addCatButton.setDisable(newValue.trim().isEmpty())); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> catName.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == addCat) { return new Pair<String, String>(catName.getText(), catDate.getValue().toString()); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); result.ifPresent(category -> { newCat.catName = category.getKey(); newCat.catDate = category.getValue(); rowsCats.add(newCat); Platform.runLater(() -> refreshCmbx()); }); } return newCat.catName; } @FXML private void addBtnPressed(ActionEvent event) { int count = ProductTable.getItems().size() + 1; data.add(new formattedProductProps(0, idTb.getText(), itemTb.getText(), sizeTb.getText(), new BigDecimal(rateTb.getText()), categoriesCmbx.getSelectionModel().getSelectedItem(), 0, BigDecimal.ZERO)); ProductTable.setItems(data); } |
File | Line |
---|---|
ABOS/Derby/AddYearController.java | 80 |
Controllers/AddYearController.java | 81 |
private ObservableList<Product.formattedProductProps> data = FXCollections.observableArrayList(); private Window parentWindow; public AddYearController() {} /** * Create the dialog. */ @FXML private void tableFrmXML(ActionEvent event) { FileChooser chooser = new FileChooser(); FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("XML files", "*.xml", "*.XML"); chooser.getExtensionFilters().add(filter); chooser.setSelectedExtensionFilter(filter); // logoLoc.setText(chooser.showOpenDialog(settings).getAbsolutePath()); File xmlFile = chooser.showOpenDialog(parentWindow); if (xmlFile != null) { String path = xmlFile.getAbsolutePath(); createTable(path); } } private void convert(String csvLoc, String xmlLoc) { List<String> headers = new ArrayList<>(5); File file = new File(csvLoc); try (BufferedReader reader = new BufferedReader(new FileReader(file))) { DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder domBuilder = domFactory.newDocumentBuilder(); Document newDoc = domBuilder.newDocument(); // Root element Element rootElement = newDoc.createElement("LawnGarden"); newDoc.appendChild(rootElement); int line = 0; String text; while ((text = reader.readLine()) != null) { StringTokenizer st = new StringTokenizer(text, ";", false); String[] rowValues = new String[st.countTokens()]; int index = 0; while (st.hasMoreTokens()) { String next = st.nextToken(); rowValues[index] = next; index++; } //String[] rowValues = text.split(","); if (line == 0) { // Header row Collections.addAll(headers, rowValues); } else { // Data row Element rowElement = newDoc.createElement("Products"); rootElement.appendChild(rowElement); Attr attr = newDoc.createAttribute("id"); attr.setValue(Integer.toString(line - 1)); rowElement.setAttributeNode(attr); for (int col = 0; col < headers.size(); col++) { String header = headers.get(col); String value; if (col < rowValues.length) { value = rowValues[col].trim(); } else { // ?? Default value value = ""; } Element curElement = newDoc.createElement(header); curElement.appendChild(newDoc.createTextNode(value)); rowElement.appendChild(curElement); } } line++; } OutputStreamWriter osw = null; try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { osw = new OutputStreamWriter(baos); TransformerFactory tranFactory = TransformerFactory.newInstance(); Transformer aTransformer = tranFactory.newTransformer(); aTransformer.setOutputProperty(OutputKeys.INDENT, "yes"); aTransformer.setOutputProperty(OutputKeys.METHOD, "xml"); //aTransformer.setOutputProperty(OutputKeys.ENCODING, "utf-8"); aTransformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); Source src = new DOMSource(newDoc); Result result = new StreamResult(osw); aTransformer.transform(src, result); osw.flush(); //System.out.println(new String(baos.toByteArray())); try (OutputStream outStream = new FileOutputStream(xmlLoc)) {// writing bytes in to byte output stream baos.writeTo(outStream); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error writing XML file. Please try again."); } } catch (Exception exp) { LogToFile.log(exp, Severity.SEVERE, "Error writing XML file. Please try again."); } finally { try { if (osw != null) { osw.close(); } } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error closing file. Please try again."); } } } catch (Exception e) { LogToFile.log(e, Severity.SEVERE, "Error reading CSV file. Ensure the path exists, and the software has permission to read it."); } } @FXML private void csvToXml(ActionEvent event) { // Create the custom dialog. Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("CSV to XML conversion"); // Set the button types. ButtonType convertButtonType = new ButtonType("Convert", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(convertButtonType, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField csvLoc = new TextField(); csvLoc.setPromptText("CSV file Location"); TextField xmlLoc = new TextField(); xmlLoc.setPromptText("XML Location"); Button getCsvLoc = new Button("..."); getCsvLoc.setOnAction(e -> { FileChooser chooser = new FileChooser(); FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("CSV files", "*.csv", "*.CSV"); chooser.getExtensionFilters().add(filter); chooser.setSelectedExtensionFilter(filter); File csv = chooser.showOpenDialog(grid.getScene().getWindow()); if (csv != null) { String path = csv.getAbsolutePath(); if (!path.toLowerCase().endsWith(".csv")) { path += ".csv"; } csvLoc.setText(path); } }); Button getXmlLoc = new Button("..."); getXmlLoc.setOnAction(e -> { FileChooser chooser = new FileChooser(); FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("XML files", "*.xml", "*.XML"); chooser.getExtensionFilters().add(filter); chooser.setSelectedExtensionFilter(filter); File XML = chooser.showSaveDialog(grid.getScene().getWindow()); if (XML != null) { String path = XML.getAbsolutePath(); if (!path.toLowerCase().endsWith(".xml")) { path += ".xml"; } xmlLoc.setText(path); } }); grid.add(new Label("CSV file Location:"), 0, 0); grid.add(csvLoc, 1, 0); grid.add(getCsvLoc, 2, 0); grid.add(new Label("XML Location:"), 0, 1); grid.add(xmlLoc, 1, 1); grid.add(getXmlLoc, 2, 1); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node convertButton = dialog.getDialogPane().lookupButton(convertButtonType); convertButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). csvLoc.textProperty().addListener((observable, oldValue, newValue) -> convertButton.setDisable(newValue.trim().isEmpty())); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> csvLoc.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == convertButtonType) { return new Pair<>(csvLoc.getText(), xmlLoc.getText()); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); result.ifPresent(fileLocations -> { convert(fileLocations.getKey(), fileLocations.getValue()); createTable(fileLocations.getValue()); }); /* CSV2XML csv = new CSV2XML(parent); String xmlFile = csv.getXML(); if (!xmlFile.isEmpty()) { createTable(xmlFile); }*/ } @FXML private void catCmbxChanged(ActionEvent event) { if (Objects.equals(categoriesCmbx.getSelectionModel().getSelectedItem(), "Add Category")) { Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("Add new category"); // Set the button types. ButtonType addCat = new ButtonType("Add", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(addCat, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField catName = new TextField(); catName.setPromptText("Category Name"); DatePicker catDate = new DatePicker(LocalDate.now()); catDate.setPromptText("Category Due Date"); grid.add(new Label("Category Name:"), 0, 0); grid.add(catName, 1, 0); grid.add(new Label("Category Due Date:"), 0, 1); grid.add(catDate, 1, 1); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node addCatButton = dialog.getDialogPane().lookupButton(addCat); addCatButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). catName.textProperty().addListener((observable, oldValue, newValue) -> addCatButton.setDisable(newValue.trim().isEmpty())); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> catName.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == addCat) { return new Pair<String, String>(catName.getText(), catDate.getValue().toString()); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); result.ifPresent(category -> { rowsCats.add(new Year.category(category.getKey(), category.getValue())); |
File | Line |
---|---|
ABOS/Derby/AddYearController.java | 83 |
Controllers/UsersGroupsAndYearsController.java | 1402 |
public AddYearController() {} /** * Create the dialog. */ @FXML private void tableFrmXML(ActionEvent event) { FileChooser chooser = new FileChooser(); FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("XML files", "*.xml", "*.XML"); chooser.getExtensionFilters().add(filter); chooser.setSelectedExtensionFilter(filter); // logoLoc.setText(chooser.showOpenDialog(settings).getAbsolutePath()); File xmlFile = chooser.showOpenDialog(parentWindow); if (xmlFile != null) { String path = xmlFile.getAbsolutePath(); createTable(path); } } private void convert(String csvLoc, String xmlLoc) { List<String> headers = new ArrayList<>(5); File file = new File(csvLoc); try (BufferedReader reader = new BufferedReader(new FileReader(file))) { DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder domBuilder = domFactory.newDocumentBuilder(); Document newDoc = domBuilder.newDocument(); // Root element Element rootElement = newDoc.createElement("LawnGarden"); newDoc.appendChild(rootElement); int line = 0; String text; while ((text = reader.readLine()) != null) { StringTokenizer st = new StringTokenizer(text, ";", false); String[] rowValues = new String[st.countTokens()]; int index = 0; while (st.hasMoreTokens()) { String next = st.nextToken(); rowValues[index] = next; index++; } //String[] rowValues = text.split(","); if (line == 0) { // Header row Collections.addAll(headers, rowValues); } else { // Data row Element rowElement = newDoc.createElement("Products"); rootElement.appendChild(rowElement); Attr attr = newDoc.createAttribute("id"); attr.setValue(Integer.toString(line - 1)); rowElement.setAttributeNode(attr); for (int col = 0; col < headers.size(); col++) { String header = headers.get(col); String value; if (col < rowValues.length) { value = rowValues[col].trim(); } else { // ?? Default value value = ""; } Element curElement = newDoc.createElement(header); curElement.appendChild(newDoc.createTextNode(value)); rowElement.appendChild(curElement); } } line++; } OutputStreamWriter osw = null; try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { osw = new OutputStreamWriter(baos); TransformerFactory tranFactory = TransformerFactory.newInstance(); Transformer aTransformer = tranFactory.newTransformer(); aTransformer.setOutputProperty(OutputKeys.INDENT, "yes"); aTransformer.setOutputProperty(OutputKeys.METHOD, "xml"); //aTransformer.setOutputProperty(OutputKeys.ENCODING, "utf-8"); aTransformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); Source src = new DOMSource(newDoc); Result result = new StreamResult(osw); aTransformer.transform(src, result); osw.flush(); //System.out.println(new String(baos.toByteArray())); try (OutputStream outStream = new FileOutputStream(xmlLoc)) {// writing bytes in to byte output stream baos.writeTo(outStream); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error writing XML file. Please try again."); } } catch (Exception exp) { LogToFile.log(exp, Severity.SEVERE, "Error writing XML file. Please try again."); } finally { try { if (osw != null) { osw.close(); } } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error closing file. Please try again."); } } } catch (Exception e) { LogToFile.log(e, Severity.SEVERE, "Error reading CSV file. Ensure the path exists, and the software has permission to read it."); } } @FXML private void csvToXml(ActionEvent event) { // Create the custom dialog. Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("CSV to XML conversion"); // Set the button types. ButtonType convertButtonType = new ButtonType("Convert", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(convertButtonType, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField csvLoc = new TextField(); csvLoc.setPromptText("CSV file Location"); TextField xmlLoc = new TextField(); xmlLoc.setPromptText("XML Location"); Button getCsvLoc = new Button("..."); getCsvLoc.setOnAction(e -> { FileChooser chooser = new FileChooser(); FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("CSV files", "*.csv", "*.CSV"); chooser.getExtensionFilters().add(filter); chooser.setSelectedExtensionFilter(filter); File csv = chooser.showOpenDialog(grid.getScene().getWindow()); if (csv != null) { String path = csv.getAbsolutePath(); if (!path.toLowerCase().endsWith(".csv")) { path += ".csv"; } csvLoc.setText(path); } }); Button getXmlLoc = new Button("..."); getXmlLoc.setOnAction(e -> { FileChooser chooser = new FileChooser(); FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("XML files", "*.xml", "*.XML"); chooser.getExtensionFilters().add(filter); chooser.setSelectedExtensionFilter(filter); File XML = chooser.showSaveDialog(grid.getScene().getWindow()); if (XML != null) { String path = XML.getAbsolutePath(); if (!path.toLowerCase().endsWith(".xml")) { path += ".xml"; } xmlLoc.setText(path); } }); grid.add(new Label("CSV file Location:"), 0, 0); grid.add(csvLoc, 1, 0); grid.add(getCsvLoc, 2, 0); grid.add(new Label("XML Location:"), 0, 1); grid.add(xmlLoc, 1, 1); grid.add(getXmlLoc, 2, 1); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node convertButton = dialog.getDialogPane().lookupButton(convertButtonType); convertButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). csvLoc.textProperty().addListener((observable, oldValue, newValue) -> convertButton.setDisable(newValue.trim().isEmpty())); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> csvLoc.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == convertButtonType) { return new Pair<>(csvLoc.getText(), xmlLoc.getText()); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); result.ifPresent(fileLocations -> { convert(fileLocations.getKey(), fileLocations.getValue()); createTable(fileLocations.getValue()); }); /* CSV2XML csv = new CSV2XML(parent); String xmlFile = csv.getXML(); if (!xmlFile.isEmpty()) { createTable(xmlFile); }*/ } @FXML private void catCmbxChanged(ActionEvent event) { if (Objects.equals(categoriesCmbx.getSelectionModel().getSelectedItem(), "Add Category")) { Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("Add new category"); // Set the button types. ButtonType addCat = new ButtonType("Add", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(addCat, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField catName = new TextField(); catName.setPromptText("Category Name"); DatePicker catDate = new DatePicker(LocalDate.now()); catDate.setPromptText("Category Due Date"); grid.add(new Label("Category Name:"), 0, 0); grid.add(catName, 1, 0); grid.add(new Label("Category Due Date:"), 0, 1); grid.add(catDate, 1, 1); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node addCatButton = dialog.getDialogPane().lookupButton(addCat); addCatButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). catName.textProperty().addListener((observable, oldValue, newValue) -> addCatButton.setDisable(newValue.trim().isEmpty())); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> catName.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == addCat) { return new Pair<String, String>(catName.getText(), catDate.getValue().toString()); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); result.ifPresent(category -> { rowsCats.add(new Year.category(category.getKey(), category.getValue())); |
File | Line |
---|---|
Controllers/AddYearController.java | 640 |
Controllers/UsersGroupsAndYearsController.java | 1812 |
if ((int) nNode.getNodeType() == (int) Node.ELEMENT_NODE) { Element eElement = (Element) nNode; //String productID, String productName, String productSize, String productUnitPrice, String productCategory, int orderedQuantity, BigDecimal extendedCost formattedProductProps prodProps = new formattedProductProps(0, eElement.getElementsByTagName( "ProductID").item(0).getTextContent(), eElement.getElementsByTagName("ProductName").item(0).getTextContent(), eElement.getElementsByTagName("Size").item(0).getTextContent(), new BigDecimal(eElement.getElementsByTagName("UnitCost").item(0).getTextContent()), (eElement.getElementsByTagName("Category").item(0) != null) ? eElement.getElementsByTagName("Category").item(0).getTextContent() : "", 0, BigDecimal.ZERO ); data.add(prodProps); ProductTable.setItems(data); } } } catch (Exception e) { LogToFile.log(e, Severity.SEVERE, "Error Converting XML file to table. Please try again or contact support."); } refreshCmbx(); } /** * Creates an XML file from the table * * @param SavePath Path to save the created XML file */ private void createXML(String SavePath) { try { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder; docBuilder = docFactory.newDocumentBuilder(); // root elements Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement("LawnGarden"); doc.appendChild(rootElement); Iterable<Year.category> caters; caters = rowsCats; int[] i = {0}; //caters = getCategories(yearText.getText()); caters.forEach(cat -> { Element cats = doc.createElement("Categories"); rootElement.appendChild(cats); Attr attr = doc.createAttribute("id"); attr.setValue(Integer.toString(i[0])); cats.setAttributeNode(attr); //CateName elements Element ProductID = doc.createElement("CategoryName"); ProductID.appendChild(doc.createTextNode(cat.catName)); cats.appendChild(ProductID); //CatDate elements Element ProductName = doc.createElement("CategoryDate"); ProductName.appendChild(doc.createTextNode(cat.catDate)); cats.appendChild(ProductName); i[0]++; } ); // staff elements // set attribute to staff element for (int i2 = 0; i2 < ProductTable.getItems().size(); i2++) { Element staff = doc.createElement("Products"); rootElement.appendChild(staff); Attr attr = doc.createAttribute("id"); attr.setValue(Integer.toString(i2)); staff.setAttributeNode(attr); //ProductID elements Element ProductID = doc.createElement("ProductID"); ProductID.appendChild(doc.createTextNode(ProductTable.getItems().get(i2).getProductID())); staff.appendChild(ProductID); // Prodcut Name elements Element ProductName = doc.createElement("ProductName"); ProductName.appendChild(doc.createTextNode(ProductTable.getItems().get(i2).getProductName())); staff.appendChild(ProductName); // Unit COst elements Element UnitCost = doc.createElement("UnitCost"); UnitCost.appendChild(doc.createTextNode(ProductTable.getItems().get(i2).getProductUnitPrice().toPlainString())); staff.appendChild(UnitCost); // Size elements Element Size = doc.createElement("Size"); Size.appendChild(doc.createTextNode(ProductTable.getItems().get(i2).getProductSize())); staff.appendChild(Size); // Category elements String cat = (ProductTable.getItems().get(i2).getProductCategory() != null) ? ProductTable.getItems().get(i2).getProductCategory() : ""; Element category = doc.createElement("Category"); category.appendChild(doc.createTextNode(cat)); staff.appendChild(category); } // write the content into xml file TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); Source source = new DOMSource(doc); Result result = new StreamResult(new FileOutputStream(SavePath)); // Output to console for testing // StreamResult result = new StreamResult(System.out); transformer.transform(source, result); //System.out.println("File saved!"); } catch (ParserConfigurationException e) { LogToFile.log(e, Severity.SEVERE, "Error creating XML file: Parser error. Contact support."); } catch (TransformerException e) { LogToFile.log(e, Severity.SEVERE, "Error creating XML file: Parser Error. Contact support."); } catch (FileNotFoundException e) { LogToFile.log(e, Severity.SEVERE, "Error creating XML file: Error writing to file. Make sure the directory is readable by the software."); } } /** * Fills the table from a DB table */ private void fillTable() { |
File | Line |
---|---|
Controllers/AddCustomerController.java | 440 |
Controllers/AddCustomerController.java | 551 |
(TableColumn<formattedProductProps, String> p) -> {return new EditingCell();}; if (!columnsFilled) { String[][] columnNames = {{"ID", "productID"}, {"Item", "productName"}, {"Size", "productSize"}, {"Price/Item", "productUnitPrice"}}; for (String[] column : columnNames) { TableColumn<formattedProductProps, String> tbCol = new TableColumn<>(column[0]); tbCol.setCellValueFactory(new PropertyValueFactory<>(column[1])); ProductTable.getColumns().add(tbCol); } } //{"Quantity", "orderedQuantity"}, {"Price", "extendedCost"} TableColumn<formattedProductProps, String> quantityCol = new TableColumn<>("Quantity"); TableColumn<formattedProductProps, String> priceCol = new TableColumn<>("Price"); quantityCol.setCellValueFactory(new PropertyValueFactory<>("orderedQuantityString")); quantityCol.setCellFactory(txtCellFactory); quantityCol.setOnEditCommit(t -> { //t.getTableView().getItems().get(t.getTablePosition().getRow()).orderedQuantity.set(Integer.valueOf(t.getNewValue())); try { int quantity = Integer.valueOf(t.getNewValue()); BigDecimal unitCost = t.getTableView().getItems().get(t.getTablePosition().getRow()).productUnitPrice.get(); //Removes $ from cost and multiplies to get the total cost for that item BigDecimal ItemTotalCost = unitCost.multiply(new BigDecimal(quantity)); t.getRowValue().extendedCost.set(ItemTotalCost); t.getRowValue().orderedQuantity.set(quantity); t.getRowValue().orderedQuantityString.set(String.valueOf(quantity)); data.get(t.getTablePosition().getRow()).orderedQuantity.set(quantity); data.get(t.getTablePosition().getRow()).extendedCost.set(ItemTotalCost); t.getTableView().refresh(); totalCostFinal = new BigDecimal(DonationsT.getText()); t.getTableView().getItems().forEach(item -> { totalCostFinal = totalCostFinal.add(item.getExtendedCost());//Recalculate Utilities.Order total }); runningTotalLabel.setText("Total: " + totalCostFinal.toPlainString()); } catch (NumberFormatException e) { Alert alert = new Alert(Alert.AlertType.ERROR, "Invalid number"); alert.setHeaderText("You have entered an invalid number."); alert.show(); t.getRowValue().productUnitPriceString.set(t.getOldValue()); t.getTableView().getSelectionModel().selectAboveCell(); t.getTableView().refresh(); } }); priceCol.setCellValueFactory(new PropertyValueFactory<>("extendedCost")); ProductTable.getColumns().addAll(quantityCol, priceCol); columnsFilled = true; ProductTable.setItems(data); |
File | Line |
---|---|
ABOS/Derby/AddCustomerController.java | 242 |
ABOS/Derby/AddCustomerController.java | 318 |
for (Product.formattedProduct productOrder : productArray) { //String productID, String productName, String productSize, String productUnitPrice, String productCategory, int orderedQuantity, BigDecimal extendedCost Product.formattedProductProps prodProps = new Product.formattedProductProps(productOrder.productID, productOrder.productName, productOrder.productSize, productOrder.productUnitPrice, productOrder.productCategory, productOrder.orderedQuantity, productOrder.extendedCost); data.add(prodProps); i++; } if (!columnsFilled) { String[][] columnNames = {{"ID", "productID"}, {"Item", "productName"}, {"Size", "productSize"}, {"Price/Item", "productUnitPrice"}}; for (String[] column : columnNames) { TableColumn<Product.formattedProductProps, String> tbCol = new TableColumn<>(column[0]); tbCol.setCellValueFactory(new PropertyValueFactory<>(column[1])); ProductTable.getColumns().add(tbCol); } } //{"Quantity", "orderedQuantity"}, {"Price", "extendedCost"} TableColumn<Product.formattedProductProps, String> quantityCol = new TableColumn<>("Quantity"); TableColumn<Product.formattedProductProps, String> priceCol = new TableColumn<>("Price"); quantityCol.setCellValueFactory(new PropertyValueFactory<>("orderedQuantityString")); quantityCol.setCellFactory(TextFieldTableCell.forTableColumn()); quantityCol.setOnEditCommit(t -> { //t.getTableView().getItems().get(t.getTablePosition().getRow()).orderedQuantity.set(Integer.valueOf(t.getNewValue())); int quantity = Integer.valueOf(t.getNewValue()); BigDecimal unitCost = new BigDecimal(t.getTableView().getItems().get(t.getTablePosition().getRow()).productUnitPrice.get().replaceAll("\\$", "")); //Removes $ from cost and multiplies to get the total cost for that item BigDecimal ItemTotalCost = unitCost.multiply(new BigDecimal(quantity)); t.getRowValue().extendedCost.set(ItemTotalCost); t.getRowValue().orderedQuantity.set(quantity); t.getRowValue().orderedQuantityString.set(String.valueOf(quantity)); data.get(t.getTablePosition().getRow()).orderedQuantity.set(quantity); data.get(t.getTablePosition().getRow()).extendedCost.set(ItemTotalCost); t.getTableView().refresh(); totalCostFinal = BigDecimal.ZERO; t.getTableView().getItems().forEach(item -> { totalCostFinal = totalCostFinal.add((BigDecimal) item.getExtendedCost());//Recalculate Utilities.Order total }); }); priceCol.setCellValueFactory(new PropertyValueFactory<>("extendedCost")); /* priceCol.setCellValueFactory(cellData -> { Product.Utilities.formattedProductProps data = cellData.getValue(); return Bindings.createStringBinding( () -> { try { BigDecimal price = new BigDecimal(data.getProductUnitPrice()); int quantity = data.getOrderedQuantity(); return price.multiply(new BigDecimal(quantity)).toPlainString(); } catch (NumberFormatException nfe) { return "0.0" ; } }, data.productUnitPrice, data.orderedQuantity ); });*/ ProductTable.getColumns().addAll(quantityCol, priceCol); columnsFilled = true; ProductTable.setItems(data); |
File | Line |
---|---|
ABOS/Derby/AddYearController.java | 631 |
Controllers/AddYearController.java | 650 |
Controllers/UsersGroupsAndYearsController.java | 1822 |
eElement.getElementsByTagName("UnitCost").item(0).getTextContent(), (eElement.getElementsByTagName("Category").item(0) != null) ? eElement.getElementsByTagName("Category").item(0).getTextContent() : "", 0, BigDecimal.ZERO ); data.add(prodProps); ProductTable.setItems(data); } } } catch (Exception e) { LogToFile.log(e, Severity.SEVERE, "Error Converting XML file to table. Please try again or contact support."); } refreshCmbx(); } /** * Creates an XML file from the table * * @param SavePath Path to save the created XML file */ private void createXML(String SavePath) { try { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder; docBuilder = docFactory.newDocumentBuilder(); // root elements Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement("LawnGarden"); doc.appendChild(rootElement); Iterable<Year.category> caters; caters = rowsCats; int[] i = {0}; //caters = getCategories(yearText.getText()); caters.forEach(cat -> { Element cats = doc.createElement("Categories"); rootElement.appendChild(cats); Attr attr = doc.createAttribute("id"); attr.setValue(Integer.toString(i[0])); cats.setAttributeNode(attr); //CateName elements Element ProductID = doc.createElement("CategoryName"); ProductID.appendChild(doc.createTextNode(cat.catName)); cats.appendChild(ProductID); //CatDate elements Element ProductName = doc.createElement("CategoryDate"); ProductName.appendChild(doc.createTextNode(cat.catDate)); cats.appendChild(ProductName); i[0]++; } ); // staff elements // set attribute to staff element for (int i2 = 0; i2 < ProductTable.getItems().size(); i2++) { Element staff = doc.createElement("Products"); rootElement.appendChild(staff); Attr attr = doc.createAttribute("id"); attr.setValue(Integer.toString(i2)); staff.setAttributeNode(attr); //ProductID elements Element ProductID = doc.createElement("ProductID"); ProductID.appendChild(doc.createTextNode(ProductTable.getItems().get(i2).getProductID())); staff.appendChild(ProductID); // Prodcut Name elements Element ProductName = doc.createElement("ProductName"); ProductName.appendChild(doc.createTextNode(ProductTable.getItems().get(i2).getProductName())); staff.appendChild(ProductName); // Unit COst elements Element UnitCost = doc.createElement("UnitCost"); UnitCost.appendChild(doc.createTextNode(ProductTable.getItems().get(i2).getProductUnitPrice())); |
File | Line |
---|---|
ABOS/Derby/AddYearController.java | 306 |
ABOS/Derby/AddYearController.java | 364 |
if (Objects.equals(categoriesCmbx.getSelectionModel().getSelectedItem(), "Add Category")) { Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("Add new category"); // Set the button types. ButtonType addCat = new ButtonType("Add", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(addCat, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField catName = new TextField(); catName.setPromptText("Category Name"); DatePicker catDate = new DatePicker(LocalDate.now()); catDate.setPromptText("Category Due Date"); grid.add(new Label("Category Name:"), 0, 0); grid.add(catName, 1, 0); grid.add(new Label("Category Due Date:"), 0, 1); grid.add(catDate, 1, 1); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node addCatButton = dialog.getDialogPane().lookupButton(addCat); addCatButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). catName.textProperty().addListener((observable, oldValue, newValue) -> addCatButton.setDisable(newValue.trim().isEmpty())); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> catName.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == addCat) { return new Pair<String, String>(catName.getText(), catDate.getValue().toString()); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); result.ifPresent(category -> { rowsCats.add(new Year.category(category.getKey(), category.getValue())); refreshCmbx(); }); } } |
File | Line |
---|---|
ABOS/Derby/AddYearController.java | 364 |
Controllers/AddYearController.java | 307 |
Controllers/UsersGroupsAndYearsController.java | 1621 |
if (Objects.equals(newVal, "Add Category")) { Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("Add new category"); // Set the button types. ButtonType addCat = new ButtonType("Add", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(addCat, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField catName = new TextField(); catName.setPromptText("Category Name"); DatePicker catDate = new DatePicker(LocalDate.now()); catDate.setPromptText("Category Due Date"); grid.add(new Label("Category Name:"), 0, 0); grid.add(catName, 1, 0); grid.add(new Label("Category Due Date:"), 0, 1); grid.add(catDate, 1, 1); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node addCatButton = dialog.getDialogPane().lookupButton(addCat); addCatButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). catName.textProperty().addListener((observable, oldValue, newValue) -> addCatButton.setDisable(newValue.trim().isEmpty())); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> catName.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == addCat) { return new Pair<String, String>(catName.getText(), catDate.getValue().toString()); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); result.ifPresent(category -> { rowsCats.add(new Year.category(category.getKey(), category.getValue())); |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 131 |
Workers/ReportsWorker.java | 143 |
Iterable<String> customers = year.getCustomerNames(); // String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime()); DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder domBuilder; domBuilder = domFactory.newDocumentBuilder(); doc = domBuilder.newDocument(); Element rootElement = doc.createElement("LawnGardenReports"); doc.appendChild(rootElement); //Info Elements Element info = doc.createElement("info"); rootElement.appendChild(info); { // Scoutname elements { Element ScoutName = doc.createElement("name"); ScoutName.appendChild(doc.createTextNode(scoutName)); info.appendChild(ScoutName); } // StreetAddress elements { Element StreetAddress = doc.createElement("streetAddress"); StreetAddress.appendChild(doc.createTextNode(scoutStAddr)); info.appendChild(StreetAddress); } // City elements { Element city = doc.createElement("city"); city.appendChild(doc.createTextNode(addrFormat)); info.appendChild(city); } // Rank elements { Element rank = doc.createElement("rank"); rank.appendChild(doc.createTextNode(scoutRank)); info.appendChild(rank); } // phone elements { Element rank = doc.createElement("PhoneNumber"); rank.appendChild(doc.createTextNode(scoutPhone)); info.appendChild(rank); } // Logo elements { Element logo = doc.createElement("logo"); logo.appendChild(doc.createTextNode("file:///" + logoLoc.replace("\\", "/"))); info.appendChild(logo); } } //Column Elements { Element columns = doc.createElement("columns"); rootElement.appendChild(columns); String[] Columns = {"ID", "Name", "Unit Size", "Unit Cost", "Quantity", "Extended Price"}; for (String Column : Columns) { //Column { Element columnName = doc.createElement("column"); Element cName = doc.createElement("name"); cName.appendChild(doc.createTextNode(Column)); columnName.appendChild(cName); columns.appendChild(columnName); } } } setProgress(10); int custProgressIncValue = 90 / ((customers instanceof Collection<?>) ? ((Collection<?>) customers).size() : 1); |
File | Line |
---|---|
Controllers/UsersGroupsAndYearsController.java | 687 |
Controllers/UsersGroupsAndYearsController.java | 753 |
ButtonType addGrp = new ButtonType("Remove", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(addGrp, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField verifyUNameTF = new TextField(); char[] possibleCharacters = ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-=").toCharArray(); String randomStr = RandomStringUtils.random(7, 0, possibleCharacters.length - 1, false, false, possibleCharacters, new SecureRandom()); grid.add(new Label("Please enter the verification code for confirmation:"), 0, 0); grid.add(verifyUNameTF, 1, 0); Label verificationCode = new Label(randomStr); verificationCode.setStyle("-fx-font-size: 20px; -fx-font-weight: 600; -fx-color: black"); grid.add(new Label("Verification Code: "), 0, 1); grid.add(verificationCode, 1, 1); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node deleteUserButton = dialog.getDialogPane().lookupButton(addGrp); deleteUserButton.setDisable(true); deleteUserButton.setStyle("fx-background-color: Red; fx-color: White"); // Do some validation (using the Java 8 lambda syntax). verifyUNameTF.textProperty().addListener((observable, oldValue, newValue) -> { if (Objects.equals(newValue, randomStr)) { deleteUserButton.setDisable(false); } else { deleteUserButton.setDisable(true); } }); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> verifyUNameTF.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == addGrp) { return verifyUNameTF.getText(); } return null; }); Optional<String> result = dialog.showAndWait(); result.ifPresent(res -> { if (res.equals(randomStr)) { selectedUsers.forEach((user, status) -> { |
File | Line |
---|---|
Controllers/UsersGroupsAndYearsController.java | 685 |
Controllers/UsersGroupsAndYearsController.java | 911 |
dialog.setHeaderText("This will delete ALL customers and data associated with these users for the selected year."); // Set the button types. ButtonType addGrp = new ButtonType("Remove", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(addGrp, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField verifyUNameTF = new TextField(); char[] possibleCharacters = ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-=").toCharArray(); String randomStr = RandomStringUtils.random(7, 0, possibleCharacters.length - 1, false, false, possibleCharacters, new SecureRandom()); grid.add(new Label("Please enter the verification code for confirmation:"), 0, 0); grid.add(verifyUNameTF, 1, 0); Label verificationCode = new Label(randomStr); verificationCode.setStyle("-fx-font-size: 20px; -fx-font-weight: 600; -fx-color: black"); grid.add(new Label("Verification Code: "), 0, 1); grid.add(verificationCode, 1, 1); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node deleteUserButton = dialog.getDialogPane().lookupButton(addGrp); deleteUserButton.setDisable(true); deleteUserButton.setStyle("fx-background-color: Red; fx-color: White"); // Do some validation (using the Java 8 lambda syntax). verifyUNameTF.textProperty().addListener((observable, oldValue, newValue) -> { if (Objects.equals(newValue, randomStr)) { deleteUserButton.setDisable(false); } else { deleteUserButton.setDisable(true); } }); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> verifyUNameTF.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == addGrp) { return verifyUNameTF.getText(); } return null; }); Optional<String> result = dialog.showAndWait(); result.ifPresent(res -> { if (res.equals(randomStr)) { |
File | Line |
---|---|
ABOS/Derby/AddYearController.java | 364 |
Controllers/AddYearController.java | 367 |
Controllers/UsersGroupsAndYearsController.java | 1681 |
if (Objects.equals(newVal, "Add Category")) { Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("Add new category"); // Set the button types. ButtonType addCat = new ButtonType("Add", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(addCat, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField catName = new TextField(); catName.setPromptText("Category Name"); DatePicker catDate = new DatePicker(LocalDate.now()); catDate.setPromptText("Category Due Date"); grid.add(new Label("Category Name:"), 0, 0); grid.add(catName, 1, 0); grid.add(new Label("Category Due Date:"), 0, 1); grid.add(catDate, 1, 1); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node addCatButton = dialog.getDialogPane().lookupButton(addCat); addCatButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). catName.textProperty().addListener((observable, oldValue, newValue) -> addCatButton.setDisable(newValue.trim().isEmpty())); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> catName.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == addCat) { return new Pair<String, String>(catName.getText(), catDate.getValue().toString()); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); result.ifPresent(category -> { |
File | Line |
---|---|
Controllers/UsersGroupsAndYearsController.java | 687 |
Controllers/UsersGroupsAndYearsController.java | 975 |
ButtonType addGrp = new ButtonType("Remove", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(addGrp, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField verifyUNameTF = new TextField(); char[] possibleCharacters = ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-=").toCharArray(); String randomStr = RandomStringUtils.random(7, 0, possibleCharacters.length - 1, false, false, possibleCharacters, new SecureRandom()); grid.add(new Label("Please enter the verification code for confirmation:"), 0, 0); grid.add(verifyUNameTF, 1, 0); Label verificationCode = new Label(randomStr); verificationCode.setStyle("-fx-font-size: 20px; -fx-font-weight: 600; -fx-color: black"); grid.add(new Label("Verification Code: "), 0, 1); grid.add(verificationCode, 1, 1); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node deleteUserButton = dialog.getDialogPane().lookupButton(addGrp); deleteUserButton.setDisable(true); deleteUserButton.setStyle("fx-background-color: Red; fx-color: White"); // Do some validation (using the Java 8 lambda syntax). verifyUNameTF.textProperty().addListener((observable, oldValue, newValue) -> { if (Objects.equals(newValue, randomStr)) { deleteUserButton.setDisable(false); } else { deleteUserButton.setDisable(true); } }); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> verifyUNameTF.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == addGrp) { return verifyUNameTF.getText(); } return null; }); Optional<String> result = dialog.showAndWait(); result.ifPresent(res -> { if (res.equals(randomStr)) { |
File | Line |
---|---|
Controllers/UsersGroupsAndYearsController.java | 753 |
Controllers/UsersGroupsAndYearsController.java | 913 |
ButtonType addGrp = new ButtonType("Archive", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(addGrp, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField verifyUNameTF = new TextField(); char[] possibleCharacters = ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-=").toCharArray(); String randomStr = RandomStringUtils.random(7, 0, possibleCharacters.length - 1, false, false, possibleCharacters, new SecureRandom()); grid.add(new Label("Please enter the verification code for confirmation:"), 0, 0); grid.add(verifyUNameTF, 1, 0); Label verificationCode = new Label(randomStr); verificationCode.setStyle("-fx-font-size: 20px; -fx-font-weight: 600; -fx-color: black"); grid.add(new Label("Verification Code: "), 0, 1); grid.add(verificationCode, 1, 1); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node deleteUserButton = dialog.getDialogPane().lookupButton(addGrp); deleteUserButton.setDisable(true); deleteUserButton.setStyle("fx-background-color: Red; fx-color: White"); // Do some validation (using the Java 8 lambda syntax). verifyUNameTF.textProperty().addListener((observable, oldValue, newValue) -> { if (Objects.equals(newValue, randomStr)) { deleteUserButton.setDisable(false); } else { deleteUserButton.setDisable(true); } }); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> verifyUNameTF.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == addGrp) { return verifyUNameTF.getText(); } return null; }); Optional<String> result = dialog.showAndWait(); result.ifPresent(res -> { if (res.equals(randomStr)) { |
File | Line |
---|---|
ABOS/Derby/AddYearController.java | 306 |
Controllers/AddYearController.java | 307 |
Controllers/AddYearController.java | 367 |
Controllers/UsersGroupsAndYearsController.java | 1621 |
Controllers/UsersGroupsAndYearsController.java | 1681 |
if (Objects.equals(categoriesCmbx.getSelectionModel().getSelectedItem(), "Add Category")) { Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("Add new category"); // Set the button types. ButtonType addCat = new ButtonType("Add", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(addCat, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField catName = new TextField(); catName.setPromptText("Category Name"); DatePicker catDate = new DatePicker(LocalDate.now()); catDate.setPromptText("Category Due Date"); grid.add(new Label("Category Name:"), 0, 0); grid.add(catName, 1, 0); grid.add(new Label("Category Due Date:"), 0, 1); grid.add(catDate, 1, 1); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node addCatButton = dialog.getDialogPane().lookupButton(addCat); addCatButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). catName.textProperty().addListener((observable, oldValue, newValue) -> addCatButton.setDisable(newValue.trim().isEmpty())); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> catName.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == addCat) { return new Pair<String, String>(catName.getText(), catDate.getValue().toString()); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); result.ifPresent(category -> { |
File | Line |
---|---|
ABOS/Derby/MainController.java | 195 |
Controllers/MainController.java | 382 |
addCustCont.initAddCust(cell.getParent().getValue(), this, openInNewWindow(NewPane2, tabTitle)); }, null); break; } case "Reports": cmContent = createContextMenuContent( //Open () -> new Reports(tabPane2.getScene().getWindow()), null, null, null); // new Launchers.Reports(tabPane2.getScene().getWindow()); break; case "View Map": /* loader = new FXMLLoader(getClass().getResource("/UI/Map.fxml")); try { newPane = loader.load(); } catch (IOException e) { e.printStackTrace(); } // Controllers.MapController mapCont = loader.getController(); // mapCont.initMap(this); // addTab(newPane, "Map"); finalNewPane = newPane;*/ cmContent = createContextMenuContent( //Open () -> { FXMLLoader loader2 = new FXMLLoader(getClass().getResource("/UI/Map.fxml")); Pane NewPane2 = null; try { NewPane2 = loader2.load(); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error loading window. Please retry then reinstall application. If error persists, contact the developers."); } MapController mapCont = loader2.getController(); mapCont.initMap(this); String tabTitle = ("Map"); openTabInCurrentWindow(NewPane2, tabTitle); }, () -> { //Open In New Tab FXMLLoader loader2 = new FXMLLoader(getClass().getResource("/UI/Map.fxml")); Pane NewPane2 = null; try { NewPane2 = loader2.load(); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error loading window. Please retry then reinstall application. If error persists, contact the developers."); } MapController mapCont = loader2.getController(); mapCont.initMap(this); String tabTitle = ("Map"); addTab(NewPane2, tabTitle); }, () -> { //Open In New Window FXMLLoader loader2 = new FXMLLoader(getClass().getResource("/UI/Map.fxml")); Pane NewPane2 = null; try { NewPane2 = loader2.load(); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error loading window. Please retry then reinstall application. If error persists, contact the developers."); } MapController mapCont = loader2.getController(); mapCont.initMap(this); String tabTitle = ("Map"); openInNewWindow(NewPane2, tabTitle); }, null); break; case "Add Year": cmContent = createContextMenuContent( //Open () -> new AddYear(getWindow()), null, null, null); // new Launchers.AddYear(getWindow()); break; case "Settings": |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 802 |
Workers/ReportsWorker.java | 897 |
} setProgress(100); } break; } } OutputStreamWriter osw = null; try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { osw = new OutputStreamWriter(baos); TransformerFactory tranFactory = TransformerFactory.newInstance(); Transformer aTransformer = tranFactory.newTransformer(); aTransformer.setOutputProperty(OutputKeys.ENCODING, osw.getEncoding()); aTransformer.setOutputProperty(OutputKeys.INDENT, "yes"); aTransformer.setOutputProperty(OutputKeys.METHOD, "xml"); aTransformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); Source src = new DOMSource(doc); Result result = new StreamResult(osw); aTransformer.transform(src, result); osw.flush(); String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime()); String tmpDirectoryOp = System.getProperty("java.io.tmpdir"); File tmpDirectory = new File(tmpDirectoryOp); xmlTempFile = File.createTempFile("LGReport" + timeStamp, ".xml", tmpDirectory); xmlTempFile.deleteOnExit(); try (OutputStream outStream = new FileOutputStream(xmlTempFile)) {// writing bytes in to byte output stream baos.writeTo(outStream); //fstream.deleteOnExit(); } catch (IOException e) { updateMessage("Error writing temporary XML. Please try again."); throw e; } } catch (Exception exp) { updateMessage("Error while genertating tempory XML. Please try again or contact support."); throw exp; } finally { try { if (osw != null) { osw.close(); } } catch (IOException | RuntimeException e) { LogToFile.log(e, Severity.FINE, "Error closing temporary XML file."); } } convertXSLToPDF(); updateMessage("Done"); // Return the number of matches found return 1; } private void convertXSLToPDF() throws Exception { OutputStream os = new ByteArrayOutputStream(); Processor proc = new Processor(false); XsltCompiler comp = proc.newXsltCompiler(); try (InputStream in = getClass().getClassLoader().getResourceAsStream("/Report.xsl")) { |
File | Line |
---|---|
ABOS/Derby/AddCustomerController.java | 477 |
ABOS/Derby/CustomerController.java | 164 |
addCustWork.run(); } /** * Loops through Table to get total amount of Bulk Mulch ordered. * * @return The amount of Bulk mulch ordered */ private int getNoMulchOrdered() { int quantMulchOrdered = 0; for (Product.formattedProductProps aData : data) { if ((aData.getProductName().contains("Mulch")) && (aData.getProductName().contains("Bulk"))) { quantMulchOrdered += aData.getOrderedQuantity(); } } return quantMulchOrdered; } /** * Loops through Table to get total amount of Lawn and Garden Products ordered. * * @return The amount of Lawn and Garden Products ordered */ private int getNoLivePlantsOrdered() { int livePlantsOrdered = 0; for (Product.formattedProductProps aData : data) { if (aData.getProductName().contains("-P") || aData.getProductName().contains("-FV")) { livePlantsOrdered += aData.getOrderedQuantity(); } } return livePlantsOrdered; } /** * Loops through Table to get total amount of Lawn Products ordered. * * @return The amount of Live Plants ordered */ private int getNoLawnProductsOrdered() { int lawnProductsOrdered = 0; for (Product.formattedProductProps aData : data) { if (aData.getProductName().contains("-L")) { lawnProductsOrdered += aData.getOrderedQuantity(); } } return lawnProductsOrdered; } /** * Calculates the amount of commission to be earned. * * @param totalCost the Sub total for all orders * @return Commission to be earned */ private BigDecimal getCommission(BigDecimal totalCost) { BigDecimal commision = BigDecimal.ZERO; if ((totalCost.compareTo(new BigDecimal("299.99")) > 0) && (totalCost.compareTo(new BigDecimal("500.01")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.05")); } else if ((totalCost.compareTo(new BigDecimal("500.01")) > 0) && (totalCost.compareTo(new BigDecimal("1000.99")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.1")); } else if (totalCost.compareTo(new BigDecimal("1000")) >= 0) { commision = totalCost.multiply(new BigDecimal("0.15")); } return commision; } /** * Anaylizes if any text was entered into both the Address and Name field and if both are empty returns false, else true * * @return if required info was entered */ private boolean infoEntered() { |
File | Line |
---|---|
ABOS/Derby/MainController.java | 384 |
Controllers/MainController.java | 628 |
} } cm.getItems().addAll(cmContent.getItems()); MenuItem refresh = new MenuItem("Refresh"); refresh.setOnAction(event -> fillTreeView()); cm.getItems().add(refresh); // other menu items... return cm; } private ContextMenu createContextMenuContent(contextActionCallback open, contextActionCallback openInNewTab, contextActionCallback openInNewWindow, contextActionCallback edit) { ContextMenu cm = new ContextMenu(); if (open != null) { MenuItem openItem = new MenuItem("Open"); openItem.setOnAction(event -> open.doAction()); cm.getItems().add(openItem); } if (openInNewTab != null) { MenuItem openItem = new MenuItem("Open in New Tab"); openItem.setOnAction(event -> openInNewTab.doAction()); cm.getItems().add(openItem); } if (openInNewWindow != null) { MenuItem openItem = new MenuItem("Open in New Window"); openItem.setOnAction(event -> openInNewWindow.doAction()); cm.getItems().add(openItem); } if (edit != null) { MenuItem openItem = new MenuItem("Edit"); openItem.setOnAction(event -> edit.doAction()); cm.getItems().add(openItem); } return cm; } public javafx.stage.Window getWindow() { return tabPane2.getScene().getWindow(); } public Tab addTab(Pane fillPane, String tabTitle) { Tab tab = new Tab(tabTitle); AnchorPane tabContentPane = new AnchorPane(fillPane); AnchorPane.setBottomAnchor(tabContentPane, 0.0); AnchorPane.setTopAnchor(tabContentPane, 0.0); AnchorPane.setLeftAnchor(tabContentPane, 0.0); AnchorPane.setRightAnchor(tabContentPane, 0.0); |
File | Line |
---|---|
Controllers/AddCustomerController.java | 723 |
Controllers/CustomerController.java | 214 |
new Thread(addCustWork).start(); } /** * Loops through Table to get total amount of Bulk Mulch ordered. * * @return The amount of Bulk mulch ordered */ private int getNoMulchOrdered() { int quantMulchOrdered = 0; for (formattedProductProps aData : data) { if ((aData.getProductName().contains("Mulch")) && (aData.getProductName().contains("Bulk"))) { quantMulchOrdered += aData.getOrderedQuantity(); } } return quantMulchOrdered; } /** * Loops through Table to get total amount of Lawn and Garden Products ordered. * * @return The amount of Lawn and Garden Products ordered */ private int getNoLivePlantsOrdered() { int livePlantsOrdered = 0; for (formattedProductProps aData : data) { if (aData.getProductName().contains("-P") || aData.getProductName().contains("-FV")) { livePlantsOrdered += aData.getOrderedQuantity(); } } return livePlantsOrdered; } /** * Loops through Table to get total amount of Lawn Products ordered. * * @return The amount of Live Plants ordered */ private int getNoLawnProductsOrdered() { int lawnProductsOrdered = 0; for (formattedProductProps aData : data) { if (aData.getProductName().contains("-L")) { lawnProductsOrdered += aData.getOrderedQuantity(); } } return lawnProductsOrdered; } /** * Calculates the amount of commission to be earned. * * @param totalCost the Sub total for all orders * @return Commission to be earned */ private BigDecimal getCommission(BigDecimal totalCost) { BigDecimal commision = BigDecimal.ZERO; if ((totalCost.compareTo(new BigDecimal("299.99")) > 0) && (totalCost.compareTo(new BigDecimal("500.01")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.05")); } else if ((totalCost.compareTo(new BigDecimal("500.01")) > 0) && (totalCost.compareTo(new BigDecimal("1000.99")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.1")); } else if (totalCost.compareTo(new BigDecimal("1000")) >= 0) { commision = totalCost.multiply(new BigDecimal("0.15")); } return commision; } /** * Anaylizes if any text was entered into both the Address and Name field and if both are empty returns false, else true * * @return if required info was entered */ private boolean infoEntered() { |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 870 |
Workers/ReportsWorker.java | 966 |
try (InputStream in = getClass().getClassLoader().getResourceAsStream("/Report.xsl")) { XsltExecutable exp = comp.compile(new StreamSource(in)); XdmNode source = proc.newDocumentBuilder().build(new StreamSource(xmlTempFile)); Serializer out = proc.newSerializer(os); out.setOutputProperty(Serializer.Property.METHOD, "html"); out.setOutputProperty(Serializer.Property.INDENT, "yes"); XsltTransformer trans = exp.load(); trans.setInitialContextNode(source); trans.setDestination(out); trans.transform(); ByteArrayOutputStream baos; baos = (ByteArrayOutputStream) os; InputStream is = new ByteArrayInputStream(baos.toByteArray()); Tidy tidy = new Tidy(); // obtain a new Tidy instance // set desired config options using tidy setters OutputStream osT = new ByteArrayOutputStream(); tidy.setQuiet(true); tidy.setIndentContent(true); tidy.setDocType("loose"); tidy.setFixBackslash(true); tidy.setFixUri(true); tidy.setShowWarnings(false); tidy.setEscapeCdata(true); tidy.setXHTML(true); tidy.setInputEncoding("utf8"); tidy.setOutputEncoding("utf8"); File xhtml; String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime()); String tmpDirectoryOp = System.getProperty("java.io.tmpdir"); File tmpDirectory = new File(tmpDirectoryOp); xhtml = File.createTempFile("LGReportXhtml" + timeStamp, ".xhtml", tmpDirectory); xhtml.deleteOnExit(); try (FileOutputStream fos = new FileOutputStream(pdfLoc); FileOutputStream xhtmlfos = new FileOutputStream(xhtml)) { tidy.parse(is, osT); // run tidy, providing an input and output streamp ByteArrayOutputStream baosT; baosT = (ByteArrayOutputStream) osT; baosT.writeTo(xhtmlfos); String cssText = " .LBordered {\n" + |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 916 |
Workers/ReportsWorker.java | 1016 |
String cssText = " .LBordered {\n" + " border-left: 1px solid black;\n" + " border-bottom: 1px solid black;\n" + " border-collapse: collapse;\n" + " }\n" + " .Bordered {\n" + " border: 1px solid black;\n" + " border-collapse: collapse;\n" + " }\n" + " .UBordered {\n" + " border: 0px solid black;\n" + " border-collapse: collapse;\n" + " }\n" + " .splitTitle {display:inline;}\n" + " h4{\n" + " margin:1px;\n" + " padding:1px;\n" + " }\n" + " table {\n" + " width:100%;\n" + " margin-bottom: 0.4pt;\n" + " margin-top: 0;\n" + " margin-left: 0;\n" + " margin-right: 0;\n" + " text-indent: 0;\n" + " }\n" + " tr {\n" + " vertical-align: inherit;\n" + " }\n" + " table > tr {\n" + " vertical-align: middle;\n" + " }\n" + " table, td {\n" + " background-color:#FFF;\n" + " font-size:10pt;\n" + " padding: 50px;\n" + " border-spacing: 50px;\n" + " text-align: inherit;\n" + " vertical-align: inherit;\n" + " }\n" + " th {\n" + " background-color: #FFF;\n" + " font-size:10pt;\n" + " color:#000;\n" + " display: table-cell;\n" + " font-weight: bold;\n" + " padding: 1px;\n" + " vertical-align: inherit;\n" + " }"; //fstream.deleteOnExit(); com.itextpdf.text.Document document = new com.itextpdf.text.Document(); // step 2 PdfWriter writer = PdfWriter.getInstance(document, fos); writer.setInitialLeading(12.5f); writer.setTagged(); // step 3 document.open(); // step 4 // CSS CSSResolver cssResolver = XMLWorkerHelper.getInstance().getDefaultCssResolver(true); CssFile cssFile = XMLWorkerHelper.getCSS(new ByteArrayInputStream(cssText.getBytes())); cssResolver.addCss(cssFile); // HTML HtmlPipelineContext htmlContext = new HtmlPipelineContext(null); htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory()); htmlContext.autoBookmark(false); // Pipelines PdfWriterPipeline pdf = new PdfWriterPipeline(document, writer); HtmlPipeline html = new HtmlPipeline(htmlContext, pdf); CssResolverPipeline css = new CssResolverPipeline(cssResolver, html); // XML Worker XMLWorker worker = new XMLWorker(css, true); XMLParser p = new XMLParser(worker); p.parse(new FileInputStream(xhtml)); // step 5 document.close(); /*com.itextpdf.text.Document document = new com.itextpdf.text.Document(); // step 2 PdfWriter writer = PdfWriter.getInstance(document, fos); // step 3 document.open(); // step 4 XMLWorkerHelper.getInstance().parseXHtml(writer, document, new FileInputStream(xhtml)); // step 5 document.close();*/ } catch (Exception e) { updateMessage("Error ocurred while converting temporary XML to pdf. Try again or contact support."); throw e; } } catch (IOException e) { updateMessage("Error writing PDF file. Please try again."); throw e; } /* Compile and execute a simple transformation that applies a stylesheet to an input file, and serializing the result to an output file */ } private void setProgress(double progress) { |
File | Line |
---|---|
ABOS/Derby/AddYearController.java | 565 |
Controllers/AddYearController.java | 584 |
yearToCreate.CreateDb(ProductTable.getItems(), rowsCats); } private void updateDb(String year) { Year yearToUpdate = new Year(year); yearToUpdate.updateDb(year, ProductTable.getItems(), rowsCats); } private void addYear() { Year yearToAdd = new Year(yearText.getText()); yearToAdd.addYear(); } /** * Parses XML file to insert into products table on screen * * @param FLoc the location of the XML file */ private void createTable(String FLoc) { try { File fXmlFile = new File(FLoc); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(fXmlFile); //optional, but recommended //read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work doc.getDocumentElement().normalize(); //System.out.println("Root element :" + doc.getDocumentElement().getNodeName()); NodeList nListCats = doc.getElementsByTagName("Categories"); // Collection<String[]> rowsCatsL = new ArrayList<>(); for (int temp = 0; temp < nListCats.getLength(); temp++) { Node nNode = nListCats.item(temp); if ((int) nNode.getNodeType() == (int) Node.ELEMENT_NODE) { Element eElement = (Element) nNode; rowsCats.add(new Year.category(eElement.getElementsByTagName("CategoryName").item(0).getTextContent(), eElement.getElementsByTagName("CategoryDate").item(0).getTextContent())); } } //rowsCats = rowsCatsL; NodeList nList = doc.getElementsByTagName("Products"); Object[][] rows = new Object[nList.getLength()][5]; for (int temp = 0; temp < nList.getLength(); temp++) { Node nNode = nList.item(temp); if ((int) nNode.getNodeType() == (int) Node.ELEMENT_NODE) { Element eElement = (Element) nNode; |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 217 |
Workers/ReportsWorker.java | 230 |
{ //Product Elements Element products = doc.createElement("customerYear"); //YearTitle { Element custAddr = doc.createElement("custAddr"); custAddr.appendChild(doc.createTextNode("true")); products.appendChild(custAddr); } // customername elements { Element custName = doc.createElement("name"); custName.appendChild(doc.createTextNode(customer)); products.appendChild(custName); } // StreetAddress elements { Element StreetAddress = doc.createElement("streetAddress"); StreetAddress.appendChild(doc.createTextNode(cust.getAddr())); products.appendChild(StreetAddress); } // City elements { Element city = doc.createElement("city"); String addr = cust.getTown() + ' ' + cust.getState() + ", " + cust.getZip(); city.appendChild(doc.createTextNode(addr)); products.appendChild(city); } // phone elements { Element phone = doc.createElement("PhoneNumber"); phone.appendChild(doc.createTextNode(cust.getPhone())); products.appendChild(phone); } { Element header = doc.createElement("header"); header.appendChild(doc.createTextNode("true")); products.appendChild(header); } { Element title = doc.createElement("title"); title.appendChild(doc.createTextNode(customer + ' ' + selectedYear + " Order")); products.appendChild(title); } { if (includeHeader && !Objects.equals(category, "All")) { Element title = doc.createElement("specialInfo"); { Element text = doc.createElement("text"); String notice = "*Notice: These products will be delivered to your house on " + DbInt.getCategoryDate(category, selectedYear) + ". Please have the total payment listed below ready and be present on that date."; |
File | Line |
---|---|
Utilities/DbInt.java | 130 |
Utilities/DbInt.java | 309 |
String url = String.format("jdbc:mysql://%s/%s?useSSL=%s", Config.getDbLoc(), prefix + Db, Config.getSSL()); try { if (connectionPools.containsKey(url)) { Connection con = connectionPools.get(url).getConnection(); // fetch a connection if (con == null) { throw new SQLException("Unable to acquire connection", "08001"); } return con; } else { HikariConfig config = new HikariConfig(); config.setJdbcUrl(url); config.setUsername(username); config.setPassword(password); config.addDataSourceProperty("cachePrepStmts", "true"); config.addDataSourceProperty("prepStmtCacheSize", "250"); config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); config.addDataSourceProperty("useServerPrepStmts", "true"); config.addDataSourceProperty("useLocalSessionState", "true"); config.addDataSourceProperty("useLocalTransactionState", "true"); config.addDataSourceProperty("rewriteBatchedStatements", "true"); config.addDataSourceProperty("cacheResultSetMetadata", "true"); config.addDataSourceProperty("cacheServerConfiguration", "true"); config.addDataSourceProperty("elideSetAutoCommits", "true"); config.addDataSourceProperty("maintainTimeStats", "false"); HikariDataSource ds = new HikariDataSource(config); connectionPools.put(url, ds); Connection con = ds.getConnection(); // fetch a connection if (con == null) { throw new SQLException("Unable to acquire connection", "08001"); } databaseVersion.setIfNot(new Version(con.getMetaData().getDatabaseProductVersion())); return con; } } catch (CommunicationsException e) { promptConfig(); } catch (SQLException ex) { if (((ex.getErrorCode() == 50000) && ("XJ015".equals(ex.getSQLState())))) { LogToFile.log(ex, Severity.FINER, "Derby shut down normally"); } else { |
File | Line |
---|---|
Controllers/SettingsController.java | 143 |
Controllers/SettingsController.java | 216 |
ButtonType login = new ButtonType("Login", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(login, ButtonType.CANCEL); // Create the username and password labels and fields. GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField userNameTextField = new TextField(); userNameTextField.setPromptText("Username"); PasswordField passwordField = new PasswordField(); passwordField.setPromptText("Password"); grid.add(new Label("Username:"), 0, 0); grid.add(userNameTextField, 1, 0); grid.add(new Label("Password:"), 0, 1); grid.add(passwordField, 1, 1); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node loginButton = dialog.getDialogPane().lookupButton(login); loginButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). userNameTextField.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(newValue.trim().isEmpty())); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> userNameTextField.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == login) { return new Pair<String, String>(userNameTextField.getText(), passwordField.getText()); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); result.ifPresent(userPass -> { saveData(); if (DbInt.verifyLoginAndUser(userPass)) { |
File | Line |
---|---|
ABOS/Derby/ReportsController.java | 440 |
Controllers/ReportsController.java | 441 |
reportsWorker.run(); } private void close() { Stage stage = (Stage) pdfLoc.getScene().getWindow(); // do what you have to do stage.close(); } //SetBounds(X,Y,Width,Height) public void initUI(Reports reps) { reports = reps; cmbxReportType.getSelectionModel().select(Config.getProp("ReportType")); // includeHeaderL.setVisible(false); scoutName.setText(Config.getProp("ScoutName")); scoutStAddr.setText(Config.getProp("ScoutAddress")); scoutZip.setText(Config.getProp("ScoutZip")); scoutTown.setText(Config.getProp("ScoutTown")); scoutState.setText(Config.getProp("ScoutState")); scoutPhone.setText(Config.getProp("ScoutPhone")); scoutRank.setText(Config.getProp("ScoutRank")); logoLoc.setText(Config.getProp("logoLoc")); pdfLoc.setText(Config.getProp("pdfLoc")); scoutZip.setOnKeyTyped(keyEvent -> { if (scoutZip.getCharacters().length() >= 4) { String zip = scoutZip.getText() + keyEvent.getCharacter(); String cityAndState; try { cityAndState = Geolocation.getCityState(zip); String[] StateTown = cityAndState.split("&"); String state = StateTown[1]; String town = StateTown[0]; scoutTown.setText(town); scoutState.setText(state); } catch (IOException e1) { LogToFile.log(e1, Severity.WARNING, "Couldn't contact geolocation service. Please try again or enter the adress manually and contact suport."); } } }); } private void updateCombos() { Iterable<String> years = DbInt.getYears(); |
File | Line |
---|---|
Workers/ReportsWorker.java | 294 |
Workers/ReportsWorker.java | 686 |
int productProgressIncValue = ((custProgressIncValue / 10) * 9) / orderArray.orderData.length; //For each product ordered, enter info for (formattedProduct aRowDataF : orderArray.orderData) { if (Objects.equals(aRowDataF.productCategory, category) || (Objects.equals(category, "All"))) { { Element Product = doc.createElement("Product"); products.appendChild(Product); //ID { Element ID = doc.createElement("ID"); ID.appendChild(doc.createTextNode(aRowDataF.productID)); Product.appendChild(ID); } //Name { Element Name = doc.createElement("Name"); Name.appendChild(doc.createTextNode(aRowDataF.productName)); Product.appendChild(Name); } //Size { Element Size = doc.createElement("Size"); Size.appendChild(doc.createTextNode(aRowDataF.productSize)); Product.appendChild(Size); } //UnitCost { Element UnitCost = doc.createElement("UnitCost"); UnitCost.appendChild(doc.createTextNode(aRowDataF.productUnitPrice.toPlainString())); Product.appendChild(UnitCost); } //Quantity { Element Quantity = doc.createElement("Quantity"); Quantity.appendChild(doc.createTextNode(String.valueOf(aRowDataF.orderedQuantity))); Product.appendChild(Quantity); } //TotalCost { Element TotalCost = doc.createElement("TotalCost"); TotalCost.appendChild(doc.createTextNode(String.valueOf(aRowDataF.extendedCost))); tCost = tCost.add(aRowDataF.extendedCost); Product.appendChild(TotalCost); } } } setProgress(getProg() + productProgressIncValue); |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 281 |
ABOS/Derby/ReportsWorker.java | 625 |
int productProgressIncValue = ((custProgressIncValue / 10) * 9) / orderArray.orderData.length; //For each product ordered, enter info for (Product.formattedProduct aRowDataF : orderArray.orderData) { if (Objects.equals(aRowDataF.productCategory, category) || (Objects.equals(category, "All"))) { { Element Product = doc.createElement("Product"); products.appendChild(Product); //ID { Element ID = doc.createElement("ID"); ID.appendChild(doc.createTextNode(aRowDataF.productID)); Product.appendChild(ID); } //Name { Element Name = doc.createElement("Name"); Name.appendChild(doc.createTextNode(aRowDataF.productName)); Product.appendChild(Name); } //Size { Element Size = doc.createElement("Size"); Size.appendChild(doc.createTextNode(aRowDataF.productSize)); Product.appendChild(Size); } //UnitCost { Element UnitCost = doc.createElement("UnitCost"); UnitCost.appendChild(doc.createTextNode(aRowDataF.productUnitPrice)); Product.appendChild(UnitCost); } //Quantity { Element Quantity = doc.createElement("Quantity"); Quantity.appendChild(doc.createTextNode(String.valueOf(aRowDataF.orderedQuantity))); Product.appendChild(Quantity); } //TotalCost { Element TotalCost = doc.createElement("TotalCost"); TotalCost.appendChild(doc.createTextNode(String.valueOf(aRowDataF.extendedCost))); tCost = tCost.add(aRowDataF.extendedCost); Product.appendChild(TotalCost); } } } setProgress(getProgress() + productProgressIncValue); |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 383 |
Workers/ReportsWorker.java | 405 |
} }); } else { DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder domBuilder; domBuilder = domFactory.newDocumentBuilder(); doc = domBuilder.newDocument(); // Root element Element rootElement = doc.createElement("LawnGardenReports"); doc.appendChild(rootElement); //Info Elements Element info = doc.createElement("info"); rootElement.appendChild(info); { // Scoutname elements { Element ScoutName = doc.createElement("name"); ScoutName.appendChild(doc.createTextNode(scoutName)); info.appendChild(ScoutName); } // StreetAddress elements { Element StreetAddress = doc.createElement("streetAddress"); StreetAddress.appendChild(doc.createTextNode(scoutStAddr)); info.appendChild(StreetAddress); } // City elements { Element city = doc.createElement("city"); city.appendChild(doc.createTextNode(addrFormat)); info.appendChild(city); } // Rank elements { Element rank = doc.createElement("rank"); rank.appendChild(doc.createTextNode(scoutRank)); info.appendChild(rank); } // phone elements { Element rank = doc.createElement("PhoneNumber"); rank.appendChild(doc.createTextNode(scoutPhone)); info.appendChild(rank); } // Logo elements { Element logo = doc.createElement("logo"); logo.appendChild(doc.createTextNode("file:///" + logoLoc.replace("\\", "/"))); info.appendChild(logo); } // ReportTitle elements { Element reportTitle = doc.createElement("reportTitle"); reportTitle.appendChild(doc.createTextNode(repTitle)); info.appendChild(reportTitle); } // Splitter elements { |
File | Line |
---|---|
Controllers/CustomerController.java | 63 |
Controllers/CustomerController.java | 99 |
cID = customerDbInfo.getId(); fillTable(); //frame.setTitle("ABOS - Utilities.Customer View - " + name + " - " + year); List<infoValPair> customerInfoStrings = new ArrayList<>(); customerInfoStrings.add(new infoValPair("Name", name)); customerInfoStrings.add(new infoValPair("Address", customerDbInfo.getAddr())); customerInfoStrings.add(new infoValPair("Phone #", customerDbInfo.getPhone())); customerInfoStrings.add(new infoValPair("Email", customerDbInfo.getEmail())); customerInfoStrings.add(new infoValPair("Total Quantity", totQuant)); customerInfoStrings.add(new infoValPair("Donations", customerDbInfo.getDontation().toPlainString())); customerInfoStrings.add(new infoValPair("Total Cost", totCost)); customerInfoStrings.add(new infoValPair("Paid", customerDbInfo.getPaid().toPlainString())); customerInfoStrings.add(new infoValPair("Delivered", customerDbInfo.getDelivered() ? "yes" : "no")); customerInfoStrings.forEach((pair) -> { javafx.scene.control.Label keyLabel = new javafx.scene.control.Label(pair.info + ":"); javafx.scene.control.Label valLabel = new javafx.scene.control.Label(pair.value); keyLabel.setId("CustomerDescription"); valLabel.setId("CustomerValue"); VBox info = new VBox(keyLabel, valLabel); info.getStyleClass().add("informationPane"); customerInfo.getChildren().add(info); }); } |
File | Line |
---|---|
ABOS/Derby/ReportsController.java | 379 |
Controllers/ReportsController.java | 380 |
ReportsWorker reportsWorker = new ReportsWorker(cmbxReportType.getSelectionModel().getSelectedItem().toString(), selectedYear, scoutName.getText(), scoutStAddr.getText(), addrFormat, scoutRank.getText(), scoutPhone.getText(), logoLoc.getText(), cmbxCategory.getSelectionModel().getSelectedItem().toString(), selectedCustomer, repTitle, Splitting, includeHeader.isSelected(), pdfLoc.getText()); progDial.activateProgressBar(reportsWorker); reportsWorker.setOnSucceeded(event -> { progDial.getDialogStage().close(); try { if (Desktop.isDesktopSupported()) { new Thread(() -> { try { File myFile = new File(pdfLoc.getText()); Desktop.getDesktop().open(myFile); } catch (IOException ex) { LogToFile.log(ex, Severity.SEVERE, "Error writing pdf file. Please try again or contacting support."); } }).start(); } } catch (CancellationException e1) { LogToFile.log(e1, Severity.INFO, "The process was cancelled."); } catch (Exception e1) { LogToFile.log(e1, Severity.SEVERE, "The process failed."); } close(); }); reportsWorker.setOnFailed(event -> { progDial.getDialogStage().close(); Throwable e = reportsWorker.getException(); if (e instanceof ParserConfigurationException) { LogToFile.log((ParserConfigurationException) e, Severity.WARNING, "Error configuring parser. Please reinstall or contact support."); } if (e instanceof SQLException) { LogToFile.log((SQLException) e, Severity.SEVERE, CommonErrors.returnSqlMessage(((SQLException) reportsWorker.getException()))); } if (e instanceof InterruptedException) { if (reportsWorker.isCancelled()) { LogToFile.log((InterruptedException) e, Severity.FINE, "Add Customer process canceled."); |
File | Line |
---|---|
Controllers/UsersGroupsAndYearsController.java | 1061 |
Controllers/UsersGroupsAndYearsController.java | 1202 |
grid.add(adminCheckBox, 1, 3); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> userNameTextField.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == login) { return new Pair<Pair<String, Boolean>, Pair<String, String>>(new Pair<>(fullNameField.getText(), adminCheckBox.isSelected()), new Pair<>(userNameTextField.getText(), passwordField.getText())); } return null; }); Optional<Pair<Pair<String, Boolean>, Pair<String, String>>> result = dialog.showAndWait(); result.ifPresent(userInfo -> { Pattern p = Pattern.compile("[^a-zA-Z0-9]"); String uName = userInfo.getValue().getKey(); String pass = userInfo.getValue().getValue(); String fName = userInfo.getKey().getKey(); Boolean admin = userInfo.getKey().getValue(); boolean hasSpecialChar = p.matcher(userInfo.getValue().getKey()).find(); if (hasSpecialChar) { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle(""); alert.setHeaderText("You have entered an invalid character in the username"); alert.setContentText("Only Alphanumeric characters are aloud."); alert.show(); } else { Set<String> years = new HashSet<>(); //Utilities.User.createUser(uName, pass, fullNameField.getText(), admin); User.updateUser(uName, pass, fName, admin); |
File | Line |
---|---|
Utilities/Group.java | 67 |
Utilities/Group.java | 189 |
groupUsers.orElseGetAndSet(() -> { ArrayList<User> users = new ArrayList<>(); if (Objects.equals(name, "Ungrouped")) { try (Connection con = DbInt.getConnection(year); PreparedStatement prep = con.prepareStatement("SELECT * FROM users WHERE groupId IS NULL", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { try (ResultSet rs = prep.executeQuery()) { while (rs.next()) { users.add(new User(rs.getString("userName"), year)); ////Utilities.DbInt.pCon.close(); } } } catch (SQLException e) { LogToFile.log(e, Severity.SEVERE, CommonErrors.returnSqlMessage(e)); } } try (Connection con = DbInt.getConnection(year); PreparedStatement prep = con.prepareStatement("SELECT * FROM users WHERE groupId=?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { prep.setInt(1, getID()); try (ResultSet rs = prep.executeQuery()) { while (rs.next()) { users.add(new User(rs.getString("userName"), year)); ////Utilities.DbInt.pCon.close(); } } } catch (SQLException e) { LogToFile.log(e, Severity.SEVERE, CommonErrors.returnSqlMessage(e)); } catch (GroupNotFoundException e) { LogToFile.log(e, Severity.WARNING, "Group not found. Please retry the action."); } return users; }); |
File | Line |
---|---|
Controllers/MainController.java | 801 |
Controllers/UsersGroupsAndYearsController.java | 2176 |
interface contextActionCallback { void doAction(); } abstract class AbstractTreeItem extends TreeItem { protected abstract ContextMenu getMenu(); } public class contextTreeItem<K, V> extends AbstractTreeItem { // make class vars here like psswd public contextTreeItem(String key, Pair<String, String> value) { this.setValue(new TreeItemPair<>(key, value)); } public contextTreeItem(String key, String value) { this.setValue(new TreeItemPair<>(key, new Pair<String, String>(value, ""))); } public contextTreeItem(String key) { this.setValue(new TreeItemPair<>(key, null)); } @Override public ContextMenu getMenu() { return createContextMenu(this); } } private final class TreeCellImpl<K, V> extends TreeCell<TreeItemPair<String, Pair<String, String>>> { @Override public void updateItem(TreeItemPair<String, Pair<String, String>> item, boolean empty) { super.updateItem(item, empty); if (empty) { setText(null); setGraphic(null); } else { setText(getItem() == null ? "" : getItem().getKey()); setGraphic(getTreeItem().getGraphic()); setContextMenu(((AbstractTreeItem) getTreeItem()).getMenu()); } } } } |
File | Line |
---|---|
Utilities/User.java | 308 |
Utilities/User.java | 365 |
public void addToYear(String year) { String[] createAndGrantCommand = {"GRANT SELECT, INSERT, UPDATE, DELETE ON `" + DbInt.prefix + year + "`.customerview TO '" + userName + "'@'%'", "GRANT SELECT, INSERT, UPDATE, DELETE ON `" + DbInt.prefix + year + "`.orderedproductsview TO '" + userName + "'@'%'", "GRANT SELECT, INSERT, UPDATE, DELETE ON `" + DbInt.prefix + year + "`.ordersview TO '" + userName + "'@'%'", "GRANT SELECT, INSERT, UPDATE, DELETE ON `" + DbInt.prefix + year + "`.usersview TO '" + userName + "'@'%'", "GRANT SELECT ON `" + DbInt.prefix + year + "`.products TO '" + userName + "'@'%'", "GRANT SELECT ON `" + DbInt.prefix + year + "`.groups TO '" + userName + "'@'%'", "GRANT SELECT ON `" + DbInt.prefix + year + "`.categories TO '" + userName + "'@'%'"}; try (Connection con = DbInt.getConnection(); PreparedStatement prep = con.prepareStatement("", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { prep.addBatch(createAndGrantCommand[0]); prep.addBatch(createAndGrantCommand[1]); prep.addBatch(createAndGrantCommand[2]); prep.addBatch(createAndGrantCommand[3]); prep.addBatch(createAndGrantCommand[4]); prep.addBatch(createAndGrantCommand[5]); prep.addBatch(createAndGrantCommand[6]); prep.executeBatch(); } catch (SQLException e) { LogToFile.log(e, Severity.SEVERE, CommonErrors.returnSqlMessage(e)); } try (Connection con = DbInt.getConnection("Commons"); PreparedStatement prep = con.prepareStatement("UPDATE Users SET Years=CONCAT(Years, ',', ?) WHERE userName=?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { |
File | Line |
---|---|
ABOS/Derby/SettingsController.java | 209 |
Controllers/SettingsController.java | 360 |
CreateDb.setSelected(!Config.doesConfExist()); Name.setText(Config.getProp("CustomerName")); Address.setText(Config.getProp("CustomerAddress")); ZipCode.setText(Config.getProp("CustomerZipCode")); ZipCode.setOnKeyTyped(keyEvent -> { if (ZipCode.getCharacters().length() >= 4) { String zip = ZipCode.getText() + keyEvent.getCharacter(); String cityAndState = ""; try { cityAndState = Geolocation.getCityState(zip); } catch (IOException e1) { LogToFile.log(e1, Severity.WARNING, "Couldn't contact geolocation service. Please try again or enter the adress manually and contact suport."); } String[] StateTown = cityAndState.split("&"); String state = StateTown[1]; String town = StateTown[0]; Town.setText(town); State.setText(state); } }); Town.setText(Config.getProp("CustomerTown")); State.setText(Config.getProp("CustomerState")); Phone.setText(Config.getProp("CustomerPhone")); Email.setText(Config.getProp("CustomerEmail")); Paid.setSelected(Boolean.valueOf(Config.getProp("CustomerPaid"))); Delivered.setSelected(Boolean.valueOf(Config.getProp("CustomerDelivered"))); DonationsT.setText(Config.getProp("CustomerDonations")); if (Config.getProp("CustomerDonations") == null) { |
File | Line |
---|---|
ABOS/Derby/AddYearController.java | 716 |
Controllers/AddYearController.java | 735 |
UnitCost.appendChild(doc.createTextNode(ProductTable.getItems().get(i2).getProductUnitPrice())); staff.appendChild(UnitCost); // Size elements Element Size = doc.createElement("Size"); Size.appendChild(doc.createTextNode(ProductTable.getItems().get(i2).getProductSize())); staff.appendChild(Size); // Category elements String cat = (ProductTable.getItems().get(i2).getProductCategory() != null) ? ProductTable.getItems().get(i2).getProductCategory() : ""; Element category = doc.createElement("Category"); category.appendChild(doc.createTextNode(cat)); staff.appendChild(category); } // write the content into xml file TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); Source source = new DOMSource(doc); Result result = new StreamResult(new FileOutputStream(SavePath)); // Output to console for testing // StreamResult result = new StreamResult(System.out); transformer.transform(source, result); //System.out.println("File saved!"); } catch (ParserConfigurationException e) { LogToFile.log(e, Severity.SEVERE, "Error creating XML file: Parser error. Contact support."); } catch (TransformerException e) { LogToFile.log(e, Severity.SEVERE, "Error creating XML file: Parser Error. Contact support."); } catch (FileNotFoundException e) { LogToFile.log(e, Severity.SEVERE, "Error creating XML file: Error writing to file. Make sure the directory is readable by the software."); } } /** * Fills the table from a DB table */ private void fillTable() { String year = yearText.getText(); Year yearInfo = new Year(year); |
File | Line |
---|---|
ABOS/Derby/AddYear.java | 33 |
Launchers/AddYear.java | 53 |
public class AddYear extends Window { public AddYear(Window owner) { Stage stage = new Stage(); FXMLLoader loader; Scene root; try { loader = new FXMLLoader(getClass().getResource("/UI/AddYear.fxml")); root = new Scene(loader.load()); AddYearController addYearController = loader.getController(); addYearController.initAddYear(this); stage.setScene(root); stage.setTitle("Reports"); stage.initModality(Modality.APPLICATION_MODAL); stage.initOwner(owner); stage.showAndWait(); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error loading window. Please retry then reinstall application. If error persists, contact the developers."); } } public AddYear(String year, Window owner) { Stage stage = new Stage(); FXMLLoader loader; Scene root; try { loader = new FXMLLoader(getClass().getResource("/UI/AddYear.fxml")); root = new Scene(loader.load()); AddYearController addYearController = loader.getController(); addYearController.initAddYear(year, this); stage.setScene(root); stage.setTitle("Reports"); stage.initModality(Modality.APPLICATION_MODAL); stage.initOwner(owner); stage.showAndWait(); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error loading window. Please retry then reinstall application. If error persists, contact the developers."); } } } |
File | Line |
---|---|
ABOS/Derby/Config.java | 208 |
Utilities/Config.java | 208 |
prop.setProperty("databaseLocation", ""); //AddCustomer { prop.setProperty("CustomerName", ""); prop.setProperty("CustomerAddress", ""); prop.setProperty("CustomerZipCode", ""); prop.setProperty("CustomerTown", ""); prop.setProperty("CustomerState", ""); prop.setProperty("CustomerPhone", ""); prop.setProperty("CustomerEmail", ""); prop.setProperty("CustomerPaid", ""); prop.setProperty("CustomerDelivered", ""); prop.setProperty("CustomerDonation", ""); } //Maps //Launchers.Reports { prop.setProperty("ReportType", ""); prop.setProperty("ScoutName", ""); prop.setProperty("ScoutAddress", ""); prop.setProperty("ScoutZip", ""); prop.setProperty("ScoutTown", ""); prop.setProperty("ScoutState", ""); prop.setProperty("ScoutPhone", ""); prop.setProperty("ScoutRank", ""); prop.setProperty("logoLoc", ""); prop.setProperty("pdfLoc", ""); } prop.store(output, null); } catch (IOException io) { LogToFile.log(io, Severity.SEVERE, "Error writing settings file. Please try again."); } finally { if (output != null) { try { output.close(); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error closing settings file. Please try again."); } } } } } |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 133 |
ABOS/Derby/ReportsWorker.java | 388 |
Workers/ReportsWorker.java | 145 |
Workers/ReportsWorker.java | 410 |
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder domBuilder; domBuilder = domFactory.newDocumentBuilder(); doc = domBuilder.newDocument(); Element rootElement = doc.createElement("LawnGardenReports"); doc.appendChild(rootElement); //Info Elements Element info = doc.createElement("info"); rootElement.appendChild(info); { // Scoutname elements { Element ScoutName = doc.createElement("name"); ScoutName.appendChild(doc.createTextNode(scoutName)); info.appendChild(ScoutName); } // StreetAddress elements { Element StreetAddress = doc.createElement("streetAddress"); StreetAddress.appendChild(doc.createTextNode(scoutStAddr)); info.appendChild(StreetAddress); } // City elements { Element city = doc.createElement("city"); city.appendChild(doc.createTextNode(addrFormat)); info.appendChild(city); } // Rank elements { Element rank = doc.createElement("rank"); rank.appendChild(doc.createTextNode(scoutRank)); info.appendChild(rank); } // phone elements { Element rank = doc.createElement("PhoneNumber"); rank.appendChild(doc.createTextNode(scoutPhone)); info.appendChild(rank); } // Logo elements { Element logo = doc.createElement("logo"); logo.appendChild(doc.createTextNode("file:///" + logoLoc.replace("\\", "/"))); info.appendChild(logo); } |
File | Line |
---|---|
Controllers/AddYearController.java | 469 |
Controllers/AddYearController.java | 517 |
categoriesTb.addAll("", "Add Category"); categoriesCmbx.getItems().setAll(categoriesTb); String[][] columnNames = {{"ID", "productID"}, {"Item", "productName"}, {"Size", "productSize"}, {"Price/Item", "productUnitPriceString"}}; for (String[] column : columnNames) { javafx.scene.control.TableColumn<formattedProductProps, String> tbCol = new javafx.scene.control.TableColumn<>(column[0]); tbCol.setCellValueFactory(new PropertyValueFactory<>(column[1])); tbCol.setCellFactory(TextFieldTableCell.forTableColumn()); ProductTable.getColumns().add(tbCol); } javafx.scene.control.TableColumn<formattedProductProps, String> categoryColumn = new javafx.scene.control.TableColumn<>("Category"); categoryColumn.setCellValueFactory(new PropertyValueFactory<>("productCategory")); categoryColumn.setCellFactory(ComboBoxTableCell.forTableColumn(categoriesTb)); categoryColumn.setOnEditCommit(t -> { String newVal = catCmbxChanged(t.getNewValue()); t.getRowValue().productCategory.set(newVal); data.get(t.getTablePosition().getRow()).productCategory.set(newVal); }); ProductTable.getColumns().add(categoryColumn); |
File | Line |
---|---|
ABOS/Derby/Geolocation.java | 153 |
Utilities/Geolocation.java | 227 |
return parseCoords(response.toString()); } } private static Object[][] parseCoords(String xml) throws addressException { Object[][] coords = new Object[1][2]; try { InputSource is = new InputSource(new StringReader(xml)); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(is); //optional, but recommended //read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work doc.getDocumentElement().normalize(); //System.out.println("Root element :" + doc.getDocumentElement().getNodeName()); NodeList nList = doc.getElementsByTagName("place"); if (nList.getLength() < 1) { throw new addressException();} for (int temp = 0; temp < nList.getLength(); temp++) { Node nNode = nList.item(temp); if ((int) nNode.getNodeType() == (int) Node.ELEMENT_NODE) { coords[0][0] = ((Element) nNode).getAttributeNode("lat").getValue(); coords[0][1] = ((Element) nNode).getAttributeNode("lon").getValue(); //final Object[] columnNames = {"Product Name", "Size", "Price/Item", "Quantity", "Total Cost"}; } } } catch (IOException | ParserConfigurationException | SAXException e) { LogToFile.log(e, Severity.WARNING, "Error parsing geolocation server response. Please try again or contact support."); } return coords; } } |
File | Line |
---|---|
ABOS/Derby/SettingsController.java | 250 |
Controllers/SettingsController.java | 400 |
if (Config.getProp("CustomerDonations") == null) { DonationsT.setText("0.0"); } scoutName.setText(Config.getProp("ScoutName")); scoutStAddr.setText(Config.getProp("ScoutAddress")); scoutZip.setText(Config.getProp("ScoutZip")); scoutTown.setText(Config.getProp("ScoutTown")); scoutState.setText(Config.getProp("ScoutState")); scoutPhone.setText(Config.getProp("ScoutPhone")); scoutRank.setText(Config.getProp("ScoutRank")); logoLoc.setText(Config.getProp("logoLoc")); scoutZip.setOnKeyTyped(keyEvent -> { if (scoutZip.getCharacters().length() >= 4) { String zip = scoutZip.getText() + keyEvent.getCharacter(); String cityAndState; try { cityAndState = Geolocation.getCityState(zip); String[] StateTown = cityAndState.split("&"); String state = StateTown[1]; String town = StateTown[0]; scoutTown.setText(town); scoutState.setText(state); } catch (IOException e1) { LogToFile.log(e1, Severity.WARNING, "Couldn't contact geolocation service. Please try again or enter the adress manually and contact suport."); } } }); pdfLoc.setText(Config.getProp("pdfLoc")); /* final URI uri; try { uri = new URI("https://www.gnu.org/licenses/agpl.html"); class OpenUrlAction implements ActionListener { @Override public void actionPerformed(ActionEvent e) { open(uri); } } JButton button = new JButton(); button.setText("<HTML><h2>This software is released under the AGPLv3 license.</h2> Click <FONT size=14px color=\"#000099\"><U>Here</U></FONT>" + " to access the AGPLv3 license.</HTML>"); button.setHorizontalAlignment(SwingConstants.LEFT); button.setBorderPainted(false); button.setOpaque(false); button.setBackground(Color.WHITE); button.setToolTipText(uri.toString()); button.addActionListener(new OpenUrlAction()); License.add(button); } catch (URISyntaxException ignored) { } JLabel libs = new JLabel("<HTML><h2>Included Libraries:</h2>" + "<ul>" + "<li>jDatePicker Utilities.Version 1.3.4</li>" + "<li>Apache Derby Utilities.Version 10.11</li>" + "<li>iText Utilities.Version 5.5.10</li>" + "<li>JMapViewer Utilities.Version 1.0.0</li>" + "<li>JTidy Utilities.Version 938</li>" + "<li>Saxon Utilities.Version 9</li>" + "</ul></HTML>"); License.add(libs); } north.addTab("License", License); contentPanel.add(north, BorderLayout.CENTER); */ } private void saveData() { |
File | Line |
---|---|
ABOS/Derby/MainController.java | 431 |
Controllers/MainController.java | 678 |
AnchorPane.setRightAnchor(tabContentPane, 0.0); tab.setContent(tabContentPane); tab.setClosable(true); tabPane2.getTabs().add(tab); tabPane2.getSelectionModel().select(tab); return tab; } public void closeTab(Tab tab) { tabPane2.getTabs().remove(tab); } private Tab openTabInCurrentWindow(Pane fillPane, String tabTitle) { Tab tab = new Tab(tabTitle); AnchorPane tabContentPane = new AnchorPane(fillPane); AnchorPane.setBottomAnchor(tabContentPane, 0.0); AnchorPane.setTopAnchor(tabContentPane, 0.0); AnchorPane.setLeftAnchor(tabContentPane, 0.0); AnchorPane.setRightAnchor(tabContentPane, 0.0); tab.setContent(tabContentPane); tab.setClosable(true); if (tabPane2.getTabs().isEmpty()) { tabPane2.getTabs().add(tab); } else { tabPane2.getTabs().set(tabPane2.getSelectionModel().getSelectedIndex(), tab); } tabPane2.getSelectionModel().select(tab); return tab; } private Stage openInNewWindow(Pane fillPane, String tabTitle) { Stage stage = new Stage(); stage.setTitle(tabTitle); stage.setScene(new Scene(fillPane)); stage.show(); |
File | Line |
---|---|
Controllers/MainController.java | 93 |
Controllers/SettingsController.java | 147 |
Controllers/SettingsController.java | 220 |
GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField userNameTextField = new TextField(); userNameTextField.setPromptText("Username"); PasswordField passwordField = new PasswordField(); passwordField.setPromptText("Password"); grid.add(new Label("Username:"), 0, 0); grid.add(userNameTextField, 1, 0); grid.add(new Label("Password:"), 0, 1); grid.add(passwordField, 1, 1); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node loginButton = dialog.getDialogPane().lookupButton(login); loginButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). userNameTextField.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(newValue.trim().isEmpty())); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> userNameTextField.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == login) { return new Pair<String, String>(userNameTextField.getText(), passwordField.getText()); } |
File | Line |
---|---|
ABOS/Derby/AddYearController.java | 716 |
Controllers/UsersGroupsAndYearsController.java | 1907 |
UnitCost.appendChild(doc.createTextNode(ProductTable.getItems().get(i2).getProductUnitPrice())); staff.appendChild(UnitCost); // Size elements Element Size = doc.createElement("Size"); Size.appendChild(doc.createTextNode(ProductTable.getItems().get(i2).getProductSize())); staff.appendChild(Size); // Category elements String cat = (ProductTable.getItems().get(i2).getProductCategory() != null) ? ProductTable.getItems().get(i2).getProductCategory() : ""; Element category = doc.createElement("Category"); category.appendChild(doc.createTextNode(cat)); staff.appendChild(category); } // write the content into xml file TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); Source source = new DOMSource(doc); Result result = new StreamResult(new FileOutputStream(SavePath)); // Output to console for testing // StreamResult result = new StreamResult(System.out); transformer.transform(source, result); //System.out.println("File saved!"); } catch (ParserConfigurationException e) { LogToFile.log(e, Severity.SEVERE, "Error creating XML file: Parser error. Contact support."); } catch (TransformerException e) { LogToFile.log(e, Severity.SEVERE, "Error creating XML file: Parser Error. Contact support."); } catch (FileNotFoundException e) { LogToFile.log(e, Severity.SEVERE, "Error creating XML file: Error writing to file. Make sure the directory is readable by the software."); } } /** * Fills the table from a DB table */ private void fillTable() { |
File | Line |
---|---|
ABOS/Derby/AddYearController.java | 463 |
ABOS/Derby/AddYearController.java | 510 |
categoriesTb.addAll("", "Add Category"); categoriesCmbx.getItems().setAll(categoriesTb); String[][] columnNames = {{"ID", "productID"}, {"Item", "productName"}, {"Size", "productSize"}, {"Price/Item", "productUnitPrice"}}; for (String[] column : columnNames) { TableColumn<Product.formattedProductProps, String> tbCol = new TableColumn<>(column[0]); tbCol.setCellValueFactory(new PropertyValueFactory<>(column[1])); tbCol.setCellFactory(TextFieldTableCell.forTableColumn()); ProductTable.getColumns().add(tbCol); } TableColumn<Product.formattedProductProps, String> categoryColumn = new TableColumn<>("Category"); categoryColumn.setCellValueFactory(new PropertyValueFactory<>("productCategory")); categoryColumn.setCellFactory(ComboBoxTableCell.forTableColumn(categoriesTb)); categoryColumn.setOnEditCommit(t -> { t.getRowValue().productCategory.set(t.getNewValue()); data.get(t.getTablePosition().getRow()).productCategory.set(t.getNewValue()); catCmbxChanged(t.getNewValue()); }); ProductTable.getColumns().add(categoryColumn); |
File | Line |
---|---|
ABOS/Derby/AddYearController.java | 430 |
Controllers/AddYearController.java | 436 |
DbInt.getYears().forEach(year -> { if (Objects.equals(year, yearText.getText())) { newYear = false; } }); if (chkboxCreateDatabase.isSelected() && newYear) { CreateDb(); } else if (newYear) { addYear(); updateDb(yearText.getText()); } else { updateDb(yearText.getText()); } close(); } @FXML private void cancel(ActionEvent event) { close(); } private void close() { Stage stage = (Stage) yearText.getScene().getWindow(); // do what you have to do stage.close(); } public void initAddYear(Window parWindow) { parentWindow = parWindow; newYear = true; chkboxCreateDatabase.setSelected(true); yearText.setText(Integer.toString(Calendar.getInstance().get(Calendar.YEAR))); categoriesTb.addAll("", "Add Category"); categoriesCmbx.getItems().setAll(categoriesTb); String[][] columnNames = {{"ID", "productID"}, {"Item", "productName"}, {"Size", "productSize"}, {"Price/Item", "productUnitPrice"}}; |
File | Line |
---|---|
ABOS/Derby/AddCustomerController.java | 518 |
Controllers/AddCustomerController.java | 763 |
for (Product.formattedProductProps aData : data) { if (aData.getProductName().contains("-L")) { lawnProductsOrdered += aData.getOrderedQuantity(); } } return lawnProductsOrdered; } /** * Calculates the amount of commission to be earned. * * @param totalCost the Sub total for all orders * @return Commission to be earned */ private BigDecimal getCommission(BigDecimal totalCost) { BigDecimal commision = BigDecimal.ZERO; if ((totalCost.compareTo(new BigDecimal("299.99")) > 0) && (totalCost.compareTo(new BigDecimal("500.01")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.05")); } else if ((totalCost.compareTo(new BigDecimal("500.01")) > 0) && (totalCost.compareTo(new BigDecimal("1000.99")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.1")); } else if (totalCost.compareTo(new BigDecimal("1000")) >= 0) { commision = totalCost.multiply(new BigDecimal("0.15")); } return commision; } /** * Anaylizes if any text was entered into both the Address and Name field and if both are empty returns false, else true * * @return if required info was entered */ private boolean infoEntered() { return !((Name.getText().isEmpty()) && (Address.getText().isEmpty())); } /** * Updates the totals tables */ private void updateTots() { |
File | Line |
---|---|
ABOS/Derby/CustomerController.java | 206 |
Controllers/CustomerController.java | 256 |
for (Product.formattedProductProps aData : data) { if (aData.getProductName().contains("-L")) { lawnProductsOrdered += aData.getOrderedQuantity(); } } return lawnProductsOrdered; } /** * Calculates the amount of commission to be earned. * * @param totalCost the Sub total for all orders * @return Commission to be earned */ private BigDecimal getCommission(BigDecimal totalCost) { BigDecimal commision = BigDecimal.ZERO; if ((totalCost.compareTo(new BigDecimal("299.99")) > 0) && (totalCost.compareTo(new BigDecimal("500.01")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.05")); } else if ((totalCost.compareTo(new BigDecimal("500.01")) > 0) && (totalCost.compareTo(new BigDecimal("1000.99")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.1")); } else if (totalCost.compareTo(new BigDecimal("1000")) >= 0) { commision = totalCost.multiply(new BigDecimal("0.15")); } return commision; } // --Commented out by Inspection START (1/2/2016 12:01 PM): // public void setTable(JTable customerOrders) { // this.customerOrders = customerOrders; // } // --Commented out by Inspection STOP (1/2/2016 12:01 PM) private class infoValPair { public String info; public String value; public infoValPair(String inf, String val) { this.info = inf; this.value = val; } } } |
File | Line |
---|---|
ABOS/Derby/AddCustomerController.java | 258 |
ABOS/Derby/AddCustomerController.java | 334 |
Launchers/ConvertDerbyToSQL.java | 171 |
TableColumn<Product.formattedProductProps, String> priceCol = new TableColumn<>("Price"); quantityCol.setCellValueFactory(new PropertyValueFactory<>("orderedQuantityString")); quantityCol.setCellFactory(TextFieldTableCell.forTableColumn()); quantityCol.setOnEditCommit(t -> { //t.getTableView().getItems().get(t.getTablePosition().getRow()).orderedQuantity.set(Integer.valueOf(t.getNewValue())); int quantity = Integer.valueOf(t.getNewValue()); BigDecimal unitCost = new BigDecimal(t.getTableView().getItems().get(t.getTablePosition().getRow()).productUnitPrice.get().replaceAll("\\$", "")); //Removes $ from cost and multiplies to get the total cost for that item BigDecimal ItemTotalCost = unitCost.multiply(new BigDecimal(quantity)); t.getRowValue().extendedCost.set(ItemTotalCost); t.getRowValue().orderedQuantity.set(quantity); t.getRowValue().orderedQuantityString.set(String.valueOf(quantity)); data.get(t.getTablePosition().getRow()).orderedQuantity.set(quantity); data.get(t.getTablePosition().getRow()).extendedCost.set(ItemTotalCost); t.getTableView().refresh(); |
File | Line |
---|---|
ABOS/Derby/SettingsController.java | 161 |
Controllers/SettingsController.java | 311 |
} @FXML public void promptPDF(ActionEvent event) { //Creates a JFileChooser to select save location of XML file FileChooser chooser = new FileChooser(); FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("Portable Document files", "*.pdf", "*.PDF"); chooser.getExtensionFilters().add(filter); chooser.setSelectedExtensionFilter(filter); File pdf = chooser.showSaveDialog(settings); if (pdf != null) { String path = pdf.getAbsolutePath(); if (!path.toLowerCase().endsWith(".pdf")) { path += ".pdf"; } pdfLoc.setText(path); } } @FXML public void submit(ActionEvent event) { saveData(); // get a handle to the stage Stage stage = (Stage) pdfLoc.getScene().getWindow(); // do what you have to do stage.close(); } @FXML public void cancel(ActionEvent event) { Stage stage = (Stage) pdfLoc.getScene().getWindow(); // do what you have to do stage.close(); } //SetBounds(X,Y,Width,Height) public void initUI(Settings settingsWindow) { settings = settingsWindow; if (!Config.doesConfExist()) { Config.createConfigFile(); } //Launchers.Main Content DbLoc.setText(Config.getDbLoc()); |
File | Line |
---|---|
Workers/ReportsWorker.java | 539 |
Workers/ReportsWorker.java | 686 |
int productIncValue = 90 / orderArray.orderData.length; for (formattedProduct aRowDataF : orderArray.orderData) { if (Objects.equals(aRowDataF.productCategory, category) || (Objects.equals(category, "All"))) { { Element Product = doc.createElement("Product"); products.appendChild(Product); //ID { Element ID = doc.createElement("ID"); ID.appendChild(doc.createTextNode(aRowDataF.productID)); Product.appendChild(ID); } //Name { Element Name = doc.createElement("Name"); Name.appendChild(doc.createTextNode(aRowDataF.productName)); Product.appendChild(Name); } //Size { Element Size = doc.createElement("Size"); Size.appendChild(doc.createTextNode(aRowDataF.productSize)); Product.appendChild(Size); } //UnitCost { Element UnitCost = doc.createElement("UnitCost"); UnitCost.appendChild(doc.createTextNode(aRowDataF.productUnitPrice.toPlainString())); Product.appendChild(UnitCost); } //Quantity { Element Quantity = doc.createElement("Quantity"); |
File | Line |
---|---|
ABOS/Derby/Customer.java | 344 |
Utilities/Customer.java | 351 |
for (Product.formattedProduct productOrder : order.orderData) { if ((productOrder.productName.contains("Mulch")) && (productOrder.productName.contains("Bulk"))) { quantMulchOrdered += productOrder.orderedQuantity; } } return quantMulchOrdered; } private BigDecimal getCommission(BigDecimal totalCost) { BigDecimal commision = BigDecimal.ZERO; if ((totalCost.compareTo(new BigDecimal("299.99")) > 0) && (totalCost.compareTo(new BigDecimal("500.01")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.05")); } else if ((totalCost.compareTo(new BigDecimal("500.01")) > 0) && (totalCost.compareTo(new BigDecimal("1000.99")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.1")); } else if (totalCost.compareTo(new BigDecimal("1000")) >= 0) { commision = totalCost.multiply(new BigDecimal("0.15")); } return commision; } /** * Loops through Table to get total amount of Lawn and Garden Products ordered. * * @return The amount of Lawn and Garden Products ordered */ public int getNoLivePlantsOrdered() { Order.orderArray order = new Order().createOrderArray(year, name, true); |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 513 |
ABOS/Derby/ReportsWorker.java | 625 |
int productIncValue = 90 / orderArray.orderData.length; for (Product.formattedProduct aRowDataF : orderArray.orderData) { if (Objects.equals(aRowDataF.productCategory, category) || (Objects.equals(category, "All"))) { { Element Product = doc.createElement("Product"); products.appendChild(Product); //ID { Element ID = doc.createElement("ID"); ID.appendChild(doc.createTextNode(aRowDataF.productID)); Product.appendChild(ID); } //Name { Element Name = doc.createElement("Name"); Name.appendChild(doc.createTextNode(aRowDataF.productName)); Product.appendChild(Name); } //Size { Element Size = doc.createElement("Size"); Size.appendChild(doc.createTextNode(aRowDataF.productSize)); Product.appendChild(Size); } //UnitCost { Element UnitCost = doc.createElement("UnitCost"); UnitCost.appendChild(doc.createTextNode(aRowDataF.productUnitPrice)); Product.appendChild(UnitCost); } //Quantity { Element Quantity = doc.createElement("Quantity"); |
File | Line |
---|---|
Workers/ReportsWorker.java | 294 |
Workers/ReportsWorker.java | 539 |
int productProgressIncValue = ((custProgressIncValue / 10) * 9) / orderArray.orderData.length; //For each product ordered, enter info for (formattedProduct aRowDataF : orderArray.orderData) { if (Objects.equals(aRowDataF.productCategory, category) || (Objects.equals(category, "All"))) { { Element Product = doc.createElement("Product"); products.appendChild(Product); //ID { Element ID = doc.createElement("ID"); ID.appendChild(doc.createTextNode(aRowDataF.productID)); Product.appendChild(ID); } //Name { Element Name = doc.createElement("Name"); Name.appendChild(doc.createTextNode(aRowDataF.productName)); Product.appendChild(Name); } //Size { Element Size = doc.createElement("Size"); Size.appendChild(doc.createTextNode(aRowDataF.productSize)); Product.appendChild(Size); } //UnitCost { Element UnitCost = doc.createElement("UnitCost"); UnitCost.appendChild(doc.createTextNode(aRowDataF.productUnitPrice.toPlainString())); Product.appendChild(UnitCost); } //Quantity { Element Quantity = doc.createElement("Quantity"); |
File | Line |
---|---|
ABOS/Derby/AddCustomerController.java | 150 |
Controllers/AddCustomerController.java | 228 |
yearInfo = new Year(year); Name.setText(Config.getProp("CustomerName")); Address.setText(Config.getProp("CustomerAddress")); Town.setText(Config.getProp("CustomerTown")); State.setText(Config.getProp("CustomerState")); ZipCode.setText(Config.getProp("CustomerZipCode")); ZipCode.setOnKeyTyped(keyEvent -> { if (ZipCode.getCharacters().length() >= 4) { String zip = ZipCode.getText() + keyEvent.getCharacter(); String cityAndState = ""; try { cityAndState = Geolocation.getCityState(zip); } catch (IOException e1) { LogToFile.log(e1, Severity.WARNING, "Couldn't contact geolocation service. Please try again or enter the adress manually and contact suport."); } String[] StateTown = cityAndState.split("&"); String state = StateTown[1]; String town = StateTown[0]; Town.setText(town); State.setText(state); } }); Phone.setText(Config.getProp("CustomerPhone")); Email.setText(Config.getProp("CustomerEmail")); Paid.setSelected(Boolean.valueOf(Config.getProp("CustomerPaid"))); |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 281 |
ABOS/Derby/ReportsWorker.java | 513 |
int productProgressIncValue = ((custProgressIncValue / 10) * 9) / orderArray.orderData.length; //For each product ordered, enter info for (Product.formattedProduct aRowDataF : orderArray.orderData) { if (Objects.equals(aRowDataF.productCategory, category) || (Objects.equals(category, "All"))) { { Element Product = doc.createElement("Product"); products.appendChild(Product); //ID { Element ID = doc.createElement("ID"); ID.appendChild(doc.createTextNode(aRowDataF.productID)); Product.appendChild(ID); } //Name { Element Name = doc.createElement("Name"); Name.appendChild(doc.createTextNode(aRowDataF.productName)); Product.appendChild(Name); } //Size { Element Size = doc.createElement("Size"); Size.appendChild(doc.createTextNode(aRowDataF.productSize)); Product.appendChild(Size); } //UnitCost { Element UnitCost = doc.createElement("UnitCost"); UnitCost.appendChild(doc.createTextNode(aRowDataF.productUnitPrice)); Product.appendChild(UnitCost); } //Quantity { Element Quantity = doc.createElement("Quantity"); |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 474 |
ABOS/Derby/ReportsWorker.java | 589 |
Order.orderArray orderArray = order.createOrderArray(selectedYear); //Products for year { //Product Elements Element products = doc.createElement("customerYear"); rootElement.appendChild(products); { Element header = doc.createElement("header"); header.appendChild(doc.createTextNode("true")); products.appendChild(header); } { Element prodTable = doc.createElement("prodTable"); prodTable.appendChild(doc.createTextNode("true")); products.appendChild(prodTable); } //YearTitle { Element title = doc.createElement("title"); title.appendChild(doc.createTextNode(selectedYear)); products.appendChild(title); } { if (includeHeader && !Objects.equals(category, "All")) { Element title = doc.createElement("specialInfo"); { Element text = doc.createElement("text"); String notice = "*Notice: These products will be delivered to your house on " + DbInt.getCategoryDate(category, selectedYear) + ". Please Have the total payment listed below ready and be present on that date."; text.appendChild(doc.createTextNode(notice)); title.appendChild(text); } info.appendChild(title); } } setProgress(10); |
File | Line |
---|---|
Controllers/AddCustomerController.java | 151 |
Controllers/AddCustomerController.java | 258 |
Name.setText(customerInfo.getName()); DecimalFormat format = new DecimalFormat("#.0"); DonationsT.setTextFormatter(new TextFormatter<>(c -> { if (c.getControlNewText().isEmpty()) { return c; } ParsePosition parsePosition = new ParsePosition(0); Object object = format.parse(c.getControlNewText(), parsePosition); if (object == null || parsePosition.getIndex() < c.getControlNewText().length()) { return null; } else { return c; } })); Paid.setTextFormatter(new TextFormatter<>(c -> { if (c.getControlNewText().isEmpty()) { return c; } ParsePosition parsePosition = new ParsePosition(0); Object object = format.parse(c.getControlNewText(), parsePosition); if (object == null || parsePosition.getIndex() < c.getControlNewText().length()) { return null; } else { return c; } })); |
File | Line |
---|---|
Workers/ReportsWorker.java | 620 |
Workers/ReportsWorker.java | 786 |
{ Element custAddr = doc.createElement("custAddr"); custAddr.appendChild(doc.createTextNode("true")); products.appendChild(custAddr); } // customername elements { Element custName = doc.createElement("name"); custName.appendChild(doc.createTextNode(cust.getName())); products.appendChild(custName); } // StreetAddress elements { Element StreetAddress = doc.createElement("streetAddress"); StreetAddress.appendChild(doc.createTextNode(cust.getAddr())); products.appendChild(StreetAddress); } // City elements { Element city = doc.createElement("city"); String addr = cust.getTown() + ' ' + cust.getState() + ", " + cust.getZip(); city.appendChild(doc.createTextNode(addr)); products.appendChild(city); } // phone elements { Element phone = doc.createElement("PhoneNumber"); phone.appendChild(doc.createTextNode(cust.getPhone())); products.appendChild(phone); } { Element header = doc.createElement("header"); |
File | Line |
---|---|
ABOS/Derby/AddCustomerController.java | 518 |
Controllers/CustomerController.java | 256 |
for (Product.formattedProductProps aData : data) { if (aData.getProductName().contains("-L")) { lawnProductsOrdered += aData.getOrderedQuantity(); } } return lawnProductsOrdered; } /** * Calculates the amount of commission to be earned. * * @param totalCost the Sub total for all orders * @return Commission to be earned */ private BigDecimal getCommission(BigDecimal totalCost) { BigDecimal commision = BigDecimal.ZERO; if ((totalCost.compareTo(new BigDecimal("299.99")) > 0) && (totalCost.compareTo(new BigDecimal("500.01")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.05")); } else if ((totalCost.compareTo(new BigDecimal("500.01")) > 0) && (totalCost.compareTo(new BigDecimal("1000.99")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.1")); } else if (totalCost.compareTo(new BigDecimal("1000")) >= 0) { commision = totalCost.multiply(new BigDecimal("0.15")); } return commision; } /** * Anaylizes if any text was entered into both the Address and Name field and if both are empty returns false, else true * * @return if required info was entered */ private boolean infoEntered() { |
File | Line |
---|---|
ABOS/Derby/CustomerController.java | 206 |
Controllers/AddCustomerController.java | 763 |
for (Product.formattedProductProps aData : data) { if (aData.getProductName().contains("-L")) { lawnProductsOrdered += aData.getOrderedQuantity(); } } return lawnProductsOrdered; } /** * Calculates the amount of commission to be earned. * * @param totalCost the Sub total for all orders * @return Commission to be earned */ private BigDecimal getCommission(BigDecimal totalCost) { BigDecimal commision = BigDecimal.ZERO; if ((totalCost.compareTo(new BigDecimal("299.99")) > 0) && (totalCost.compareTo(new BigDecimal("500.01")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.05")); } else if ((totalCost.compareTo(new BigDecimal("500.01")) > 0) && (totalCost.compareTo(new BigDecimal("1000.99")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.1")); } else if (totalCost.compareTo(new BigDecimal("1000")) >= 0) { commision = totalCost.multiply(new BigDecimal("0.15")); } return commision; } // --Commented out by Inspection START (1/2/2016 12:01 PM): // public void setTable(JTable customerOrders) { // this.customerOrders = customerOrders; // } // --Commented out by Inspection STOP (1/2/2016 12:01 PM) private class infoValPair { |
File | Line |
---|---|
ABOS/Derby/Year.java | 326 |
ABOS/Derby/Year.java | 413 |
String col = ""; for (int i = 0; i < products.size(); i++) { Product.formattedProductProps curRow = products.get(i); String cat = (curRow.getProductCategory() != null) ? curRow.getProductCategory() : ""; col = String.format("%s, \"%s\" VARCHAR(255)", col, Integer.toString(i)); try (PreparedStatement prep = DbInt.getPrep(year, "INSERT INTO PRODUCTS(ID, PName, Unit, Size, Category) VALUES (?,?,?,?,?)")) { prep.setString(1, curRow.getProductID()); prep.setString(2, curRow.getProductName()); prep.setString(3, curRow.getProductUnitPrice()); prep.setString(4, curRow.getProductSize()); prep.setString(5, cat); prep.execute(); } catch (SQLException e) { LogToFile.log(e, Severity.SEVERE, CommonErrors.returnSqlMessage(e)); } } |
File | Line |
---|---|
Utilities/Order.java | 179 |
Utilities/Order.java | 202 |
prep.setInt(2, OrderID); try (ResultSet rs = prep.executeQuery()) { while (rs.next()) { quant = rs.getInt("SUM(Quantity)"); if (((quant > 0) && excludeZeroOrders) || !excludeZeroOrders) { BigDecimal unitCost = rs.getBigDecimal("Cost"); allProducts.add(new formattedProduct(rs.getInt("idproducts"), rs.getString("ID"), rs.getString("Name"), rs.getString("UnitSize"), rs.getBigDecimal("Cost"), rs.getString("Category"), quant, unitCost.multiply(new BigDecimal(quant)))); totL = unitCost.multiply(new BigDecimal(quant)).add(totL); QuantL += quant; noProductsOrdered++; } } } } catch (SQLException e) { LogToFile.log(e, Severity.SEVERE, CommonErrors.returnSqlMessage(e)); } } else { |
File | Line |
---|---|
ABOS/Derby/Geolocation.java | 51 |
ABOS/Derby/SettingsController.java | 396 |
public static String getCityState(String zipCode) throws IOException { //String AddressF = Address.replace(" ","+"); //The URL for the MapquestAPI String url = String.format("http://open.mapquestapi.com/nominatim/v1/search.php?key=CCBtW1293lbtbxpRSnImGBoQopnvc4Mz&format=xml&q=%s&addressdetails=1&limit=1&accept-language=en-US", zipCode); //Defines connection URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); //add request header con.setRequestProperty("User-Agent", "Mozilla/5.0"); String city = ""; String State = ""; //Creates Response buffer for Web response try (BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream()))) { String inputLine; StringBuilder response = new StringBuilder(); //Fill String buffer with response while ((inputLine = in.readLine()) != null) { //inputLine = StringEscapeUtils.escapeHtml4(inputLine); //inputLine = StringEscapeUtils.escapeXml11(inputLine); response.append(inputLine); } //Parses XML response and fills City and State Variables try { InputSource is = new InputSource(new StringReader(response.toString())); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(is); doc.getDocumentElement().normalize(); |
File | Line |
---|---|
ABOS/Derby/AddCustomerWorker.java | 75 |
Workers/AddCustomerWorker.java | 84 |
} private static void failIfInterrupted() throws InterruptedException { if (Thread.currentThread().isInterrupted()) { throw new InterruptedException("Interrupted while Adding Order"); } } private int IntegerLength(int n) { if (n < 100000) { // 5 or less if (n < 100) { // 1 or 2 if (n < 10) { return 1; } else { return 2; } } else { // 3 or 4 or 5 if (n < 1000) { return 3; } else { // 4 or 5 if (n < 10000) { return 4; } else { return 5; } } } } else { // 6 or more if (n < 10000000) { // 6 or 7 if (n < 1000000) { return 6; } else { return 7; } } else { // 8 to 10 if (n < 100000000) { return 8; } else { // 9 or 10 if (n < 1000000000) { return 9; } else { return 10; } } } } } /* @Override protected void process(List<String> chunks) { // Updates the messages text area chunks.forEach(StatusLbl::setText); }*/ @Override protected Integer call() throws Exception { |
File | Line |
---|---|
Workers/LoadMainWorker.java | 45 |
Workers/LoadUGYWorker.java | 48 |
} private static void failIfInterrupted() throws InterruptedException { if (Thread.currentThread().isInterrupted()) { throw new InterruptedException("Interrupted while loading application"); } } private int IntegerLength(int n) { if (n < 100000) { // 5 or less if (n < 100) { // 1 or 2 if (n < 10) { return 1; } else { return 2; } } else { // 3 or 4 or 5 if (n < 1000) { return 3; } else { // 4 or 5 if (n < 10000) { return 4; } else { return 5; } } } } else { // 6 or more if (n < 10000000) { // 6 or 7 if (n < 1000000) { return 6; } else { return 7; } } else { // 8 to 10 if (n < 100000000) { return 8; } else { // 9 or 10 if (n < 1000000000) { return 9; } else { return 10; } } } } } /* @Override protected void process(List<String> chunks) { // Updates the messages text area chunks.forEach(StatusLbl::setText); }*/ @Override protected TreeItem<TreeItemPair<String, Pair<String, Object>>> call() { |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 283 |
ABOS/Derby/ReportsWorker.java | 514 |
ABOS/Derby/ReportsWorker.java | 628 |
Workers/ReportsWorker.java | 296 |
Workers/ReportsWorker.java | 540 |
Workers/ReportsWorker.java | 689 |
for (Product.formattedProduct aRowDataF : orderArray.orderData) { if (Objects.equals(aRowDataF.productCategory, category) || (Objects.equals(category, "All"))) { { Element Product = doc.createElement("Product"); products.appendChild(Product); //ID { Element ID = doc.createElement("ID"); ID.appendChild(doc.createTextNode(aRowDataF.productID)); Product.appendChild(ID); } //Name { Element Name = doc.createElement("Name"); Name.appendChild(doc.createTextNode(aRowDataF.productName)); Product.appendChild(Name); } //Size { Element Size = doc.createElement("Size"); Size.appendChild(doc.createTextNode(aRowDataF.productSize)); Product.appendChild(Size); } //UnitCost { Element UnitCost = doc.createElement("UnitCost"); UnitCost.appendChild(doc.createTextNode(aRowDataF.productUnitPrice)); |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 354 |
Workers/ReportsWorker.java | 375 |
if (!Objects.equals(donation, "0.0") && !Objects.equals(donation, "0")) { Element title = doc.createElement("DonationThanks"); { Element text = doc.createElement("text"); String notice = "Thank you for your $" + donation + " donation "; text.appendChild(doc.createTextNode(notice)); title.appendChild(text); } products.appendChild(title); { Element prodTable = doc.createElement("includeDonation"); prodTable.appendChild(doc.createTextNode("true")); products.appendChild(prodTable); } { Element text = doc.createElement("Donation"); text.appendChild(doc.createTextNode(donation)); products.appendChild(text); } { Element text = doc.createElement("GrandTotal"); text.appendChild(doc.createTextNode(tCost.add(new BigDecimal(donation)).toPlainString())); products.appendChild(text); } } rootElement.appendChild(products); } }); |
File | Line |
---|---|
ABOS/Derby/CustomerController.java | 131 |
ABOS/Derby/YearController.java | 129 |
data = FXCollections.observableArrayList(); int i = 0; for (Product.formattedProduct productOrder : order.orderData) { //String productID, String productName, String productSize, String productUnitPrice, String productCategory, int orderedQuantity, BigDecimal extendedCost Product.formattedProductProps prodProps = new Product.formattedProductProps(productOrder.productID, productOrder.productName, productOrder.productSize, productOrder.productUnitPrice, productOrder.productCategory, productOrder.orderedQuantity, productOrder.extendedCost); data.add(prodProps); i++; } if (!columnsFilled) { String[][] columnNames = {{"Item", "productName"}, {"Size", "productSize"}, {"Price/Item", "productUnitPrice"}, {"Quantity", "orderedQuantity"}, {"Price", "extendedCost"}}; for (String[] column : columnNames) { TableColumn<Product.formattedProductProps, String> tbCol = new TableColumn<>(column[0]); tbCol.setCellValueFactory(new PropertyValueFactory<>(column[1])); |
File | Line |
---|---|
ABOS/Derby/AddYearController.java | 768 |
Controllers/AddYearController.java | 787 |
Product.formattedProductProps prodProps = new Product.formattedProductProps(productOrder.productID, productOrder.productName, productOrder.productSize, productOrder.productUnitPrice, productOrder.productCategory, productOrder.orderedQuantity, productOrder.extendedCost); data.add(prodProps); i++; } ProductTable.setItems(data); } @FXML private void tablefromDb(ActionEvent event) { fillTable(); } @FXML private void xmlFromTable(ActionEvent event) { FileChooser chooser = new FileChooser(); FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("XML files", "*.xml", "*.XML"); chooser.getExtensionFilters().add(filter); chooser.setSelectedExtensionFilter(filter); File XML = chooser.showSaveDialog(parentWindow); if (XML != null) { String path = XML.getAbsolutePath(); if (!path.toLowerCase().endsWith(".xml")) { path += ".xml"; } createXML(path); } } } |
File | Line |
---|---|
ABOS/Derby/Order.java | 228 |
ABOS/Derby/Order.java | 294 |
if (((quant > 0) && excludeZeroOrders) || !excludeZeroOrders) { BigDecimal unitCost = new BigDecimal(ProductInfoArray.get(i).productUnitPrice.replaceAll("\\$", "")); allProducts[noProductsOrdered] = new Product.formattedProduct(ProductInfoArray.get(i).productID, ProductInfoArray.get(i).productName, ProductInfoArray.get(i).productSize, ProductInfoArray.get(i).productUnitPrice, ProductInfoArray.get(i).productCategory, quant, unitCost.multiply(new BigDecimal(quant))); totL = unitCost.multiply(new BigDecimal(quant)).add(totL); QuantL += quant; noProductsOrdered++; } } //Re create rows to remove blank rows Product.formattedProduct[] orderedProducts = new Product.formattedProduct[noProductsOrdered]; System.arraycopy(allProducts, 0, orderedProducts, 0, noProductsOrdered); return new orderArray(orderedProducts, totL, QuantL); } public orderArray createOrderArray(String year) { |
File | Line |
---|---|
ABOS/Derby/AddCustomerController.java | 450 |
Launchers/ConvertDerbyToSQL.java | 256 |
}); addCustWork.setOnFailed(event -> { progDial.getDialogStage().close(); Throwable e = addCustWork.getException(); if (e instanceof addressException) { LogToFile.log(null, Severity.WARNING, "Invalid Address. Please Verify spelling and numbers are correct."); } if (e instanceof SQLException) { LogToFile.log((SQLException) e, Severity.SEVERE, CommonErrors.returnSqlMessage(((SQLException) addCustWork.getException()))); } if (e instanceof InterruptedException) { if (addCustWork.isCancelled()) { LogToFile.log((InterruptedException) e, Severity.FINE, "Add Customer process canceled."); } } if (e instanceof IOException) { LogToFile.log((IOException) e, Severity.WARNING, "Error contacting geolaction service. Please try again or contasct support."); } }); progDial.getDialogStage().show(); addCustWork.run(); } |
File | Line |
---|---|
ABOS/Derby/Main.java | 95 |
Launchers/Main.java | 104 |
final FXMLLoader loader = new FXMLLoader(getClass().getResource("/UI/Main.fxml")); final Parent root = loader.load(); final MainController controller = loader.getController(); if (checkUpdates()) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Update Available"); alert.setHeaderText("An Update is Available"); alert.setContentText("If you choose to download, download the latest tag's java Artifacts"); ButtonType buttonTypeOne = new ButtonType("Download"); ButtonType buttonTypeTwo = new ButtonType("Remind Me Later", ButtonBar.ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeTwo); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == buttonTypeOne) { if (Desktop.isDesktopSupported()) { new Thread(() -> { try { Desktop.getDesktop().browse(new URI("https://gitlab.com/RoatingFans/ABOS/tags")); |
File | Line |
---|---|
Utilities/DbInt.java | 138 |
Utilities/DbInt.java | 260 |
Utilities/DbInt.java | 318 |
} else { HikariConfig config = new HikariConfig(); config.setJdbcUrl(url); config.setUsername(username); config.setPassword(password); config.addDataSourceProperty("cachePrepStmts", "true"); config.addDataSourceProperty("prepStmtCacheSize", "250"); config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); config.addDataSourceProperty("useServerPrepStmts", "true"); config.addDataSourceProperty("useLocalSessionState", "true"); config.addDataSourceProperty("useLocalTransactionState", "true"); config.addDataSourceProperty("rewriteBatchedStatements", "true"); config.addDataSourceProperty("cacheResultSetMetadata", "true"); config.addDataSourceProperty("cacheServerConfiguration", "true"); config.addDataSourceProperty("elideSetAutoCommits", "true"); config.addDataSourceProperty("maintainTimeStats", "false"); HikariDataSource ds = new HikariDataSource(config); connectionPools.put(url, ds); Connection con = ds.getConnection(); // fetch a connection if (con == null) { throw new SQLException("Unable to acquire connection", "08001"); } |
File | Line |
---|---|
Utilities/Group.java | 68 |
Utilities/Group.java | 124 |
Utilities/Group.java | 190 |
ArrayList<User> users = new ArrayList<>(); if (Objects.equals(name, "Ungrouped")) { try (Connection con = DbInt.getConnection(year); PreparedStatement prep = con.prepareStatement("SELECT * FROM users WHERE groupId IS NULL", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { try (ResultSet rs = prep.executeQuery()) { while (rs.next()) { users.add(new User(rs.getString("userName"), year)); ////Utilities.DbInt.pCon.close(); } } } catch (SQLException e) { LogToFile.log(e, Severity.SEVERE, CommonErrors.returnSqlMessage(e)); } } try (Connection con = DbInt.getConnection(year); PreparedStatement prep = con.prepareStatement("SELECT * FROM users WHERE groupId=?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { prep.setInt(1, getID()); |
File | Line |
---|---|
Controllers/CustomerController.java | 180 |
Controllers/YearController.java | 150 |
data = FXCollections.observableArrayList(); int i = 0; for (formattedProduct productOrder : order.orderData) { //String productID, String productName, String productSize, String productUnitPrice, String productCategory, int orderedQuantity, BigDecimal extendedCost formattedProductProps prodProps = new formattedProductProps(productOrder.productKey, productOrder.productID, productOrder.productName, productOrder.productSize, productOrder.productUnitPrice, productOrder.productCategory, productOrder.orderedQuantity, productOrder.extendedCost); data.add(prodProps); i++; } if (!columnsFilled) { String[][] columnNames = {{"Item", "productName"}, {"Size", "productSize"}, {"Price/Item", "productUnitPrice"}, {"Quantity", "orderedQuantity"}, {"Price", "extendedCost"}}; for (String[] column : columnNames) { TableColumn<formattedProductProps, String> tbCol = new TableColumn<>(column[0]); tbCol.setCellValueFactory(new PropertyValueFactory<>(column[1])); |
File | Line |
---|---|
ABOS/Derby/Customer.java | 291 |
ABOS/Derby/Year.java | 144 |
try (PreparedStatement totalInsertString = DbInt.getPrep(year, "INSERT INTO TOTALS(DONATIONS,LG,LP,MULCH,TOTAL,CUSTOMERS,COMMISSIONS,GRANDTOTAL) VALUES(?,?,?,?,?,?,?,?)")) { totalInsertString.setBigDecimal(1, (donations.setScale(2, BigDecimal.ROUND_HALF_EVEN))); totalInsertString.setInt(2, Lg); totalInsertString.setInt(3, (LP)); totalInsertString.setInt(4, (Mulch)); totalInsertString.setBigDecimal(5, (OT.setScale(2, BigDecimal.ROUND_HALF_EVEN))); totalInsertString.setInt(6, (Customers)); totalInsertString.setBigDecimal(7, (Commis.setScale(2, BigDecimal.ROUND_HALF_EVEN))); totalInsertString.setBigDecimal(8, (GTot.setScale(2, BigDecimal.ROUND_HALF_EVEN))); totalInsertString.execute(); } catch (SQLException e) { LogToFile.log(e, Severity.SEVERE, "Could not update year totals. Please delete and recreate the order."); } |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 229 |
Workers/ReportsWorker.java | 242 |
Workers/ReportsWorker.java | 628 |
custName.appendChild(doc.createTextNode(customer)); products.appendChild(custName); } // StreetAddress elements { Element StreetAddress = doc.createElement("streetAddress"); StreetAddress.appendChild(doc.createTextNode(cust.getAddr())); products.appendChild(StreetAddress); } // City elements { Element city = doc.createElement("city"); String addr = cust.getTown() + ' ' + cust.getState() + ", " + cust.getZip(); city.appendChild(doc.createTextNode(addr)); products.appendChild(city); } // phone elements { Element phone = doc.createElement("PhoneNumber"); phone.appendChild(doc.createTextNode(cust.getPhone())); products.appendChild(phone); } { Element header = doc.createElement("header"); header.appendChild(doc.createTextNode("true")); products.appendChild(header); } { |
File | Line |
---|---|
ABOS/Derby/AddCustomerController.java | 450 |
Controllers/AddCustomerController.java | 696 |
Launchers/ConvertDerbyToSQL.java | 256 |
}); addCustWork.setOnFailed(event -> { progDial.getDialogStage().close(); Throwable e = addCustWork.getException(); if (e instanceof addressException) { LogToFile.log(null, Severity.WARNING, "Invalid Address. Please Verify spelling and numbers are correct."); } if (e instanceof SQLException) { LogToFile.log((SQLException) e, Severity.SEVERE, CommonErrors.returnSqlMessage(((SQLException) addCustWork.getException()))); } if (e instanceof InterruptedException) { if (addCustWork.isCancelled()) { LogToFile.log((InterruptedException) e, Severity.FINE, "Add Customer process canceled."); } } if (e instanceof IOException) { LogToFile.log((IOException) e, Severity.WARNING, "Error contacting geolaction service. Please try again or contasct support."); } }); progDial.getDialogStage().show(); |
File | Line |
---|---|
ABOS/Derby/Geolocation.java | 80 |
ABOS/Derby/ReportsController.java | 212 |
InputSource is = new InputSource(new StringReader(response.toString())); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(is); doc.getDocumentElement().normalize(); //System.out.println("Root element :" + doc.getDocumentElement().getNodeName()); NodeList nList = doc.getElementsByTagName("place"); for (int temp = 0; temp < nList.getLength(); temp++) { Node nNode = nList.item(temp); if ((int) nNode.getNodeType() == (int) Node.ELEMENT_NODE) { Element eElement = (Element) nNode; city = eElement.getElementsByTagName("city").item(0).getTextContent(); State = eElement.getElementsByTagName("state").item(0).getTextContent(); //final Object[] columnNames = {"Product Name", "Size", "Price/Item", "Quantity", "Total Cost"}; } } } catch (Exception e) { |
File | Line |
---|---|
ABOS/Derby/AddYearController.java | 480 |
Controllers/AddYearController.java | 487 |
catCmbxChanged(t.getNewValue()); }); ProductTable.getColumns().add(categoryColumn); //{"Category", "productCategory"} //categoryColumn.setCellEditor(new DefaultCellEditor(categoriesTb)); } /** * Create the dialog. */ public void initAddYear(String year, Window parWindow) { newYear = false; parentWindow = parWindow; Year thisYear = new Year(year); yearText.setText(year); yearText.setEditable(false); categoriesCmbx.getItems().clear(); categoriesTb.clear(); categoriesTb.add(""); String browse = "Add Category"; thisYear.getCategories().forEach((category) -> { categoriesTb.add(category.catName); rowsCats.add(category); }); categoriesTb.add(browse); categoriesCmbx.getItems().setAll(categoriesTb); String[][] columnNames = {{"ID", "productID"}, {"Item", "productName"}, {"Size", "productSize"}, {"Price/Item", "productUnitPrice"}}; |
File | Line |
---|---|
Utilities/DbInt.java | 178 |
Utilities/DbInt.java | 207 |
if (Objects.equals(ex.getSQLState(), "42000")) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("ERROR!"); alert.setHeaderText("The program cannot find the specified database"); alert.setContentText("Would you like to open the settings Dialog to create it?"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { new Settings(null); return getConnection(Db); } else { Alert closingWarning = new Alert(Alert.AlertType.WARNING); closingWarning.setTitle("Warning!"); closingWarning.setHeaderText("The program cannot run without the database"); closingWarning.setContentText("Application is closing. Please restart application and create the database in the setting dialog."); closingWarning.showAndWait(); System.exit(0); } LogToFile.log(ex, Severity.SEVERE, ""); } else { LogToFile.log(ex, Severity.WARNING, CommonErrors.returnSqlMessage(ex)); |
File | Line |
---|---|
ABOS/Derby/AddCustomerController.java | 524 |
ABOS/Derby/Customer.java | 351 |
ABOS/Derby/CustomerController.java | 212 |
Controllers/AddCustomerController.java | 769 |
Controllers/CustomerController.java | 262 |
Utilities/Customer.java | 358 |
} /** * Calculates the amount of commission to be earned. * * @param totalCost the Sub total for all orders * @return Commission to be earned */ private BigDecimal getCommission(BigDecimal totalCost) { BigDecimal commision = BigDecimal.ZERO; if ((totalCost.compareTo(new BigDecimal("299.99")) > 0) && (totalCost.compareTo(new BigDecimal("500.01")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.05")); } else if ((totalCost.compareTo(new BigDecimal("500.01")) > 0) && (totalCost.compareTo(new BigDecimal("1000.99")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.1")); } else if (totalCost.compareTo(new BigDecimal("1000")) >= 0) { commision = totalCost.multiply(new BigDecimal("0.15")); } return commision; } |
File | Line |
---|---|
Controllers/AddCustomerController.java | 392 |
Controllers/AddCustomerController.java | 510 |
} // ProductTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); //ProductTable.getSelectionModel().setCellSelectionEnabled(true); // ProductTable.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); ProductTable.addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent t) -> { if (ProductTable.getEditingCell() == null && t.getCode() == KeyCode.ENTER) { if (t.isShiftDown()) { ProductTable.getSelectionModel().selectAboveCell(); } else { ProductTable.getSelectionModel().selectBelowCell(); } t.consume(); } else { TablePosition tp; if (!t.isControlDown() && (t.getCode().isDigitKey())) { lastKey = t.getText(); tp = ProductTable.getFocusModel().getFocusedCell(); ProductTable.edit(tp.getRow(), tp.getTableColumn()); lastKey = null; } } /*//I decided not to override the default tab behavior //using ctrl tab for cell traversal, but arrow keys are better if (t.isControlDown() && t.getCode() == KeyCode.TAB) { if (t.isShiftDown()) { tv.getSelectionModel().selectLeftCell(); } else { tv.getSelectionModel().selectRightCell(); } t.consume(); }*/ }); |
File | Line |
---|---|
ABOS/Derby/AddCustomerWorker.java | 79 |
Workers/AddCustomerWorker.java | 88 |
Workers/LoadMainWorker.java | 49 |
Workers/LoadUGYWorker.java | 52 |
throw new InterruptedException("Interrupted while Adding Order"); } } private int IntegerLength(int n) { if (n < 100000) { // 5 or less if (n < 100) { // 1 or 2 if (n < 10) { return 1; } else { return 2; } } else { // 3 or 4 or 5 if (n < 1000) { return 3; } else { // 4 or 5 if (n < 10000) { return 4; } else { return 5; } } } } else { // 6 or more if (n < 10000000) { // 6 or 7 if (n < 1000000) { return 6; } else { return 7; } } else { // 8 to 10 if (n < 100000000) { return 8; } else { // 9 or 10 if (n < 1000000000) { return 9; } else { return 10; } } } } } /* @Override protected void process(List<String> chunks) { // Updates the messages text area chunks.forEach(StatusLbl::setText); }*/ @Override protected Integer call() throws Exception { |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 737 |
Workers/ReportsWorker.java | 830 |
for (Product.formattedProduct orderedProduct : orderArray.orderData) { Element Product = doc.createElement("Product"); products.appendChild(Product); //ID { Element ID = doc.createElement("ID"); ID.appendChild(doc.createTextNode(orderedProduct.productID)); Product.appendChild(ID); } //Name { Element Name = doc.createElement("Name"); Name.appendChild(doc.createTextNode(orderedProduct.productName)); Product.appendChild(Name); } //Size { Element Size = doc.createElement("Size"); Size.appendChild(doc.createTextNode(orderedProduct.productSize)); Product.appendChild(Size); } //UnitCost { Element UnitCost = doc.createElement("UnitCost"); UnitCost.appendChild(doc.createTextNode(orderedProduct.productUnitPrice)); |
File | Line |
---|---|
ABOS/Derby/Customer.java | 354 |
Utilities/Customer.java | 361 |
Utilities/Year.java | 961 |
BigDecimal commision = BigDecimal.ZERO; if ((totalCost.compareTo(new BigDecimal("299.99")) > 0) && (totalCost.compareTo(new BigDecimal("500.01")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.05")); } else if ((totalCost.compareTo(new BigDecimal("500.01")) > 0) && (totalCost.compareTo(new BigDecimal("1000.99")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.1")); } else if (totalCost.compareTo(new BigDecimal("1000")) >= 0) { commision = totalCost.multiply(new BigDecimal("0.15")); } return commision; } /** * Loops through Table to get total amount of Lawn and Garden Products ordered. * * @return The amount of Lawn and Garden Products ordered */ public int getNoLivePlantsOrdered() { |
File | Line |
---|---|
Controllers/MainController.java | 353 |
Controllers/MainController.java | 368 |
addCustCont.initAddCust(data.getKey(), this, openTabInCurrentWindow(NewPane2, tabTitle), data.getValue(), cell.getParent()); }, () -> { //Open In New Tab FXMLLoader loader2 = new FXMLLoader(getClass().getResource("/UI/AddCustomer.fxml")); Pane NewPane2 = null; try { NewPane2 = loader2.load(); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error loading window. Please retry then reinstall application. If error persists, contact the developers."); } Pair<String, String> data = (Pair<String, String>) cell.getValue().getValue().getValue(); AddCustomerController addCustCont = loader2.getController(); String tabTitle = ("Add Customer - " + data.getKey()); addCustCont.initAddCust(data.getKey(), this, addTab(NewPane2, tabTitle), data.getValue(), cell.getParent()); |
File | Line |
---|---|
ABOS/Derby/AddCustomerController.java | 533 |
ABOS/Derby/CustomerController.java | 221 |
Controllers/AddCustomerController.java | 778 |
Controllers/CustomerController.java | 271 |
Utilities/Year.java | 961 |
BigDecimal commision = BigDecimal.ZERO; if ((totalCost.compareTo(new BigDecimal("299.99")) > 0) && (totalCost.compareTo(new BigDecimal("500.01")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.05")); } else if ((totalCost.compareTo(new BigDecimal("500.01")) > 0) && (totalCost.compareTo(new BigDecimal("1000.99")) < 0)) { commision = totalCost.multiply(new BigDecimal("0.1")); } else if (totalCost.compareTo(new BigDecimal("1000")) >= 0) { commision = totalCost.multiply(new BigDecimal("0.15")); } return commision; } |
File | Line |
---|---|
ABOS/Derby/Order.java | 138 |
Utilities/Order.java | 249 |
return Ids.get(Ids.size() - 1); } private static int IntegerLength(int n) { if (n < 100000) { // 5 or less if (n < 100) { // 1 or 2 if (n < 10) { return 1; } else { return 2; } } else { // 3 or 4 or 5 if (n < 1000) { return 3; } else { // 4 or 5 if (n < 10000) { return 4; } else { return 5; } } } } else { // 6 or more if (n < 10000000) { // 6 or 7 if (n < 1000000) { return 6; } else { return 7; } } else { // 8 to 10 if (n < 100000000) { return 8; } else { // 9 or 10 if (n < 1000000000) { return 9; } else { return 10; } } } } } public orderArray createOrderArray(String year, String name, Boolean excludeZeroOrders) { |
File | Line |
---|---|
Controllers/MainController.java | 531 |
Controllers/MainController.java | 544 |
openTabInCurrentWindow(NewPane2, tabTitle); }, () -> { //Open In New Tab FXMLLoader loader2 = new FXMLLoader(getClass().getResource("/UI/Customer.fxml")); Pane NewPane2 = null; try { NewPane2 = loader2.load(); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error loading window. Please retry then reinstall application. If error persists, contact the developers."); } CustomerController customerCont = loader2.getController(); customerCont.initCustomer((Customer) cell.getValue().getValue().getValue(), this); String tabTitle = ("Customer View - " + cell.getValue().getKey() + " - " + ((Customer) cell.getValue().getValue().getValue()).getYear()); |
File | Line |
---|---|
Controllers/MainController.java | 585 |
Controllers/MainController.java | 600 |
openTabInCurrentWindow(NewPane2, tabTitle); }, () -> { FXMLLoader loader2 = new FXMLLoader(getClass().getResource("/UI/Year.fxml")); Pane NewPane2 = null; try { NewPane2 = loader2.load(); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error loading window. Please retry then reinstall application. If error persists, contact the developers."); } YearController yearCont = loader2.getController(); yearCont.initYear(cell.getValue().getValue().getValue().toString(), cell.getValue().getKey()); String tabTitle = ("Year View - " + cell.getValue().getValue().getValue() + " - " + cell.getValue().getKey()); |
File | Line |
---|---|
ABOS/Derby/CustomerController.java | 63 |
ABOS/Derby/CustomerController.java | 94 |
fillTable(); //frame.setTitle("ABOS - Utilities.Customer View - " + name + " - " + year); List<infoValPair> customerInfoStrings = new ArrayList<>(); customerInfoStrings.add(new infoValPair("Name", name)); customerInfoStrings.add(new infoValPair("Address", customerDbInfo.getAddr())); customerInfoStrings.add(new infoValPair("Phone #", customerDbInfo.getPhone())); customerInfoStrings.add(new infoValPair("Email", customerDbInfo.getEmail())); customerInfoStrings.add(new infoValPair("Paid", customerDbInfo.getPaid())); customerInfoStrings.add(new infoValPair("Delivered", customerDbInfo.getDelivered())); customerInfoStrings.add(new infoValPair("Total Quantity", totQuant)); customerInfoStrings.add(new infoValPair("Total Cost", totCost)); |
File | Line |
---|---|
Utilities/User.java | 334 |
Utilities/User.java | 393 |
prep.setString(2, getUserName()); prep.execute(); } catch (SQLException e) { LogToFile.log(e, Severity.SEVERE, CommonErrors.returnSqlMessage(e)); } Integer CommonsID = 0; try (Connection con = DbInt.getConnection("Commons"); PreparedStatement prep = con.prepareStatement("SELECT idUsers FROM Users where userName=?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { prep.setString(1, getUserName()); try (ResultSet rs = prep.executeQuery()) { rs.next(); CommonsID = rs.getInt("idUsers"); } } catch (SQLException e) { LogToFile.log(e, Severity.SEVERE, CommonErrors.returnSqlMessage(e)); } |
File | Line |
---|---|
Controllers/UsersGroupsAndYearsController.java | 170 |
Controllers/UsersGroupsAndYearsController.java | 180 |
String year = ""; if (summaryList.getSelectionModel().getSelectedItem().getParent().getValue().getValue().getKey().equals("Year")) { year = summaryList.getSelectionModel().getSelectedItem().getParent().getValue().getKey(); } else if (summaryList.getSelectionModel().getSelectedItem().getParent().getParent().getValue().getValue().getKey().equals("Year")) { year = summaryList.getSelectionModel().getSelectedItem().getParent().getParent().getValue().getKey(); } |
File | Line |
---|---|
ABOS/Derby/AddCustomerWorker.java | 83 |
ABOS/Derby/Order.java | 141 |
Utilities/Order.java | 253 |
Workers/AddCustomerWorker.java | 92 |
Workers/LoadMainWorker.java | 53 |
Workers/LoadUGYWorker.java | 56 |
private int IntegerLength(int n) { if (n < 100000) { // 5 or less if (n < 100) { // 1 or 2 if (n < 10) { return 1; } else { return 2; } } else { // 3 or 4 or 5 if (n < 1000) { return 3; } else { // 4 or 5 if (n < 10000) { return 4; } else { return 5; } } } } else { // 6 or more if (n < 10000000) { // 6 or 7 if (n < 1000000) { return 6; } else { return 7; } } else { // 8 to 10 if (n < 100000000) { return 8; } else { // 9 or 10 if (n < 1000000000) { return 9; } else { return 10; } } } } } |
File | Line |
---|---|
ABOS/Derby/CustomerController.java | 54 |
Controllers/CustomerController.java | 55 |
private ObservableList<Product.formattedProductProps> data; private MainController mainController; public void initCustomer(String cYear, String cName, MainController mainCont) { year = cYear; name = cName; mainController = mainCont; customerDbInfo = new Customer(name, year); cID = customerDbInfo.getId(); fillTable(); //frame.setTitle("ABOS - Utilities.Customer View - " + name + " - " + year); List<infoValPair> customerInfoStrings = new ArrayList<>(); customerInfoStrings.add(new infoValPair("Name", name)); customerInfoStrings.add(new infoValPair("Address", customerDbInfo.getAddr())); customerInfoStrings.add(new infoValPair("Phone #", customerDbInfo.getPhone())); customerInfoStrings.add(new infoValPair("Email", customerDbInfo.getEmail())); customerInfoStrings.add(new infoValPair("Paid", customerDbInfo.getPaid())); |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 229 |
Workers/ReportsWorker.java | 242 |
Workers/ReportsWorker.java | 794 |
custName.appendChild(doc.createTextNode(customer)); products.appendChild(custName); } // StreetAddress elements { Element StreetAddress = doc.createElement("streetAddress"); StreetAddress.appendChild(doc.createTextNode(cust.getAddr())); products.appendChild(StreetAddress); } // City elements { Element city = doc.createElement("city"); String addr = cust.getTown() + ' ' + cust.getState() + ", " + cust.getZip(); city.appendChild(doc.createTextNode(addr)); products.appendChild(city); } // phone elements { Element phone = doc.createElement("PhoneNumber"); phone.appendChild(doc.createTextNode(cust.getPhone())); products.appendChild(phone); } { Element header = doc.createElement("header"); |
File | Line |
---|---|
ABOS/Derby/YearController.java | 80 |
Controllers/YearController.java | 91 |
yearDbInfo.getCategories().forEach(category -> yearInfoStrings.add(new infoValPair(category.catName + " Products", Integer.toString(yearDbInfo.getLG())))); /*yearInfoStrings.add(new infoValPair("Lawn and Garden Products", Integer.toString(yearDbInfo.getLG()))); yearInfoStrings.add(new infoValPair("Live Plant Products", Integer.toString(yearDbInfo.getLP()))); yearInfoStrings.add(new infoValPair("Mulch", Integer.toString(yearDbInfo.getMulch())));*/ yearInfoStrings.add(new infoValPair("Order Total", yearDbInfo.getOT().toPlainString())); yearInfoStrings.add(new infoValPair("Donations", yearDbInfo.getDonations().toPlainString())); yearInfoStrings.add(new infoValPair("Grand Total", yearDbInfo.getGTot().toPlainString())); yearInfoStrings.add(new infoValPair("Commission", yearDbInfo.getCommis().toPlainString())); yearInfoStrings.forEach((pair) -> { Label keyLabel = new Label(pair.info + ":"); Label valLabel = new Label(pair.value); keyLabel.setId("YearDescription"); valLabel.setId("YearValue"); |
File | Line |
---|---|
Utilities/User.java | 175 |
Utilities/User.java | 315 |
Utilities/User.java | 372 |
"REVOKE SELECT ON `" + DbInt.prefix + year + "`.categories FROM '" + userName + "'@'%'"}; try (Connection con = DbInt.getConnection(); PreparedStatement prep = con.prepareStatement("", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { prep.addBatch(createAndGrantCommand[0]); prep.addBatch(createAndGrantCommand[1]); prep.addBatch(createAndGrantCommand[2]); prep.addBatch(createAndGrantCommand[3]); prep.addBatch(createAndGrantCommand[4]); prep.addBatch(createAndGrantCommand[5]); prep.addBatch(createAndGrantCommand[6]); prep.executeBatch(); } catch (SQLException e) { LogToFile.log(e, Severity.SEVERE, CommonErrors.returnSqlMessage(e)); } |
File | Line |
---|---|
ABOS/Derby/LogToFile.java | 37 |
Utilities/LogToFile.java | 37 |
class LogToFile { private static final Logger logger = Logger.getLogger("MYLOG"); /* Severities SEVERE WARNING INFO CONFIG FINE FINER FINEST */ /** * log Method * enable to log all exceptions to a file and display user message on demand * * @param ex the exception * @param level the severity level * SEVERE * WARNING * INFO * CONFIG * FINE * FINER * FINEST * @param msg the message to print */ public static void log(Exception ex, Severity level, String msg) { FileHandler fh = null; try { // Create a file with append set to true. Also limit the file to 10000 bytes fh = new FileHandler("log.txt", 10000, 1, true); // Set the file format to a simple text file. fh.setFormatter(new SimpleFormatter()); logger.addHandler(fh); switch (level) { case SEVERE: logger.log(Level.SEVERE, msg, ex); if (!msg.isEmpty()) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Error"); alert.setHeaderText("Error"); alert.setContentText(msg); alert.showAndWait(); |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 761 |
Workers/ReportsWorker.java | 854 |
UnitCost.appendChild(doc.createTextNode(orderedProduct.productUnitPrice)); Product.appendChild(UnitCost); } //Quantity { Element Quantity = doc.createElement("Quantity"); Quantity.appendChild(doc.createTextNode(String.valueOf(orderedProduct.orderedQuantity))); Product.appendChild(Quantity); } //TotalCost { Element TotalCost = doc.createElement("TotalCost"); TotalCost.appendChild(doc.createTextNode(String.valueOf(orderedProduct.extendedCost))); tCost = tCost.add(orderedProduct.extendedCost); Product.appendChild(TotalCost); } } //Total for current customerName { Element tCostE = doc.createElement("totalCost"); tCostE.appendChild(doc.createTextNode(String.valueOf(tCost))); products.appendChild(tCostE); } ////Utilities.DbInt.pCon.close(); setProgress(getProgress() + yearProgressInc); |
File | Line |
---|---|
Controllers/MainController.java | 519 |
Controllers/MainController.java | 532 |
Controllers/MainController.java | 545 |
() -> { FXMLLoader loader2 = new FXMLLoader(getClass().getResource("/UI/Customer.fxml")); Pane NewPane2 = null; try { NewPane2 = loader2.load(); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error loading window. Please retry then reinstall application. If error persists, contact the developers."); } CustomerController customerCont = loader2.getController(); customerCont.initCustomer((Customer) cell.getValue().getValue().getValue(), this); String tabTitle = ("Customer View - " + cell.getValue().getKey() + " - " + ((Customer) cell.getValue().getValue().getValue()).getYear()); |
File | Line |
---|---|
Controllers/MainController.java | 572 |
Controllers/MainController.java | 587 |
Controllers/MainController.java | 602 |
() -> { FXMLLoader loader2 = new FXMLLoader(getClass().getResource("/UI/Year.fxml")); Pane NewPane2 = null; try { NewPane2 = loader2.load(); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error loading window. Please retry then reinstall application. If error persists, contact the developers."); } YearController yearCont = loader2.getController(); yearCont.initYear(cell.getValue().getValue().getValue().toString(), cell.getValue().getKey()); String tabTitle = ("Year View - " + cell.getValue().getValue().getValue() + " - " + cell.getValue().getKey()); |
File | Line |
---|---|
Utilities/Order.java | 127 |
Utilities/Order.java | 185 |
Utilities/Order.java | 208 |
if (quant > 0) { BigDecimal unitCost = rs.getBigDecimal("Cost"); allProducts.add(new formattedProduct(rs.getInt("idproducts"), rs.getString("ID"), rs.getString("Name"), rs.getString("UnitSize"), rs.getBigDecimal("Cost"), rs.getString("Category"), quant, unitCost.multiply(new BigDecimal(quant)))); totL = unitCost.multiply(new BigDecimal(quant)).add(totL); QuantL += quant; noProductsOrdered++; } } } } catch (SQLException e) { LogToFile.log(e, Severity.SEVERE, CommonErrors.returnSqlMessage(e)); } |
File | Line |
---|---|
ABOS/Derby/AddCustomerController.java | 156 |
ABOS/Derby/SettingsController.java | 214 |
Controllers/AddCustomerController.java | 233 |
Controllers/SettingsController.java | 364 |
State.setText(Config.getProp("CustomerState")); ZipCode.setText(Config.getProp("CustomerZipCode")); ZipCode.setOnKeyTyped(keyEvent -> { if (ZipCode.getCharacters().length() >= 4) { String zip = ZipCode.getText() + keyEvent.getCharacter(); String cityAndState = ""; try { cityAndState = Geolocation.getCityState(zip); } catch (IOException e1) { LogToFile.log(e1, Severity.WARNING, "Couldn't contact geolocation service. Please try again or enter the adress manually and contact suport."); } String[] StateTown = cityAndState.split("&"); String state = StateTown[1]; String town = StateTown[0]; Town.setText(town); State.setText(state); } }); |
File | Line |
---|---|
ABOS/Derby/Order.java | 185 |
ABOS/Derby/Order.java | 253 |
while (ProductInfoResultSet.next()) { ProductInfoArray.add(new Product(ProductInfoResultSet.getString("ID"), ProductInfoResultSet.getString("PNAME"), ProductInfoResultSet.getString("SIZE"), ProductInfoResultSet.getString("UNIT"), ProductInfoResultSet.getString("Category"))); DbInt.pCon.commit(); } //Close prepared statement ProductInfoResultSet.close(); if (DbInt.pCon != null) { //Utilities.DbInt.pCon.close(); DbInt.pCon = null; } } catch (SQLException e) { LogToFile.log(e, Severity.SEVERE, CommonErrors.returnSqlMessage(e)); } //Table rows array Product.formattedProduct[] allProducts = new Product.formattedProduct[ProductInfoArray.size()]; |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 562 |
Workers/ReportsWorker.java | 588 |
setProgress(getProgress() + productIncValue); } //Total Cost for list { Element tCostE = doc.createElement("totalCost"); tCostE.appendChild(doc.createTextNode(String.valueOf(tCost))); products.appendChild(tCostE); } // OverallTotalCost elements { Element TotalCost = doc.createElement("TotalCost"); TotalCost.appendChild(doc.createTextNode((orderArray.totalCost).toPlainString())); info.appendChild(TotalCost); } // OverallTotalQuantity elements { Element TotalQuantity = doc.createElement("totalQuantity"); TotalQuantity.appendChild(doc.createTextNode(Integer.toString(orderArray.totalQuantity))); info.appendChild(TotalQuantity); } } setProgress(100); } break; case "Customer Year Totals": { Order order = new Order(); |
File | Line |
---|---|
Controllers/UsersGroupsAndYearsController.java | 619 |
Controllers/UsersGroupsAndYearsController.java | 855 |
grid.add(new Label("Group:"), 0, 0); grid.add(groupComboBox, 1, 0); // Enable/Disable login button depending on whether a username was entered. javafx.scene.Node loginButton = dialog.getDialogPane().lookupButton(login); loginButton.setDisable(true); // Do some validation (using the Java 8 lambda syntax). groupComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(newValue == null)); dialog.getDialogPane().setContent(grid); // Request focus on the username field by default. Platform.runLater(() -> groupComboBox.requestFocus()); // Convert the result to a username-password-pair when the login button is clicked. dialog.setResultConverter(dialogButton -> { if (dialogButton == login) { return groupComboBox.getSelectionModel().getSelectedItem(); } return null; }); Optional<Group> result = dialog.showAndWait(); |
File | Line |
---|---|
Controllers/AddUserController.java | 312 |
Controllers/UsersGroupsAndYearsController.java | 375 |
userItem.setSelected(true); /* checkedUsers.computeIfPresent(year, (k, v) -> { v.add(user.getUserName()); return v; }); checkedUsers.computeIfAbsent(year, k -> { ArrayList<String> v = new ArrayList(); v.add(user.getUserName()); return v; }); checkedFullName.compute(year, (k, v) -> { ArrayList<String> vArray = new ArrayList(); vArray.addAll(v); vArray.add(user.getFullName()); return vArray; });*/ /* checkedFullName.computeIfAbsent(year, k -> { ArrayList<String> v = new ArrayList(); v.add(user.getFullName()); return v; });*/ } groupItem.getChildren().add(userItem); }); yearItem.getChildren().add(groupItem); try { groupBox.getItems().add(new TreeItemPair<String, Integer>(group.getName(), group.getID())); if (currentUser.getGroupId() == group.getID()) { groupBox.getSelectionModel().selectLast(); } else if (currentUser.getGroupId() == 0) { groupBox.getSelectionModel().selectFirst(); } } catch (Group.GroupNotFoundException ignored) { } }); yearTView = new TreeView(yearItem); |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 541 |
Workers/ReportsWorker.java | 567 |
UnitCost.appendChild(doc.createTextNode(aRowDataF.productUnitPrice)); Product.appendChild(UnitCost); } //Quantity { Element Quantity = doc.createElement("Quantity"); orderArray.totalQuantity = orderArray.totalQuantity + aRowDataF.orderedQuantity; Quantity.appendChild(doc.createTextNode(String.valueOf(aRowDataF.orderedQuantity))); Product.appendChild(Quantity); } //TotalCost { Element TotalCost = doc.createElement("TotalCost"); orderArray.totalCost = orderArray.totalCost.add(aRowDataF.extendedCost); TotalCost.appendChild(doc.createTextNode(String.valueOf(aRowDataF.extendedCost))); tCost = tCost.add(aRowDataF.extendedCost); Product.appendChild(TotalCost); } } } setProgress(getProgress() + productIncValue); |
File | Line |
---|---|
Controllers/AddYearController.java | 524 |
Controllers/UsersGroupsAndYearsController.java | 1369 |
ProductTable.getColumns().add(tbCol); } javafx.scene.control.TableColumn<formattedProductProps, String> categoryColumn = new javafx.scene.control.TableColumn<>("Category"); categoryColumn.setCellValueFactory(new PropertyValueFactory<>("productCategory")); categoryColumn.setCellFactory(ComboBoxTableCell.forTableColumn(categoriesTb)); categoryColumn.setOnEditCommit(t -> { String newVal = catCmbxChanged(t.getNewValue()); t.getRowValue().productCategory.set(newVal); data.get(t.getTablePosition().getRow()).productCategory.set(newVal); }); ProductTable.getColumns().add(categoryColumn); // boolean updateDb = true; fillTable(); |
File | Line |
---|---|
Controllers/MainController.java | 773 |
Controllers/UsersGroupsAndYearsController.java | 217 |
}); loadWorker.setOnFailed(event -> { progDial.getDialogStage().close(); Throwable e = loadWorker.getException(); if (e instanceof SQLException) { LogToFile.log((SQLException) e, Severity.SEVERE, CommonErrors.returnSqlMessage(((SQLException) loadWorker.getException()))); } if (e instanceof InterruptedException) { if (loadWorker.isCancelled()) { LogToFile.log((InterruptedException) e, Severity.FINE, "Load process canceled."); } } }); progDial.getDialogStage().show(); new Thread(loadWorker).start(); } |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 673 |
Workers/ReportsWorker.java | 734 |
setProgress(getProgress() + productIncValue); } //Total Cost for this Utilities.Year { Element tCostE = doc.createElement("totalCost"); tCostE.appendChild(doc.createTextNode(String.valueOf(tCost))); products.appendChild(tCostE); } // OverallTotalCost elements { Element TotalCost = doc.createElement("TotalCost"); TotalCost.appendChild(doc.createTextNode(orderArray.totalCost.toPlainString())); info.appendChild(TotalCost); } // OverallTotalQuantity elements { Element TotalQuantity = doc.createElement("totalQuantity"); TotalQuantity.appendChild(doc.createTextNode(Integer.toString(orderArray.totalQuantity))); info.appendChild(TotalQuantity); } } setProgress(100); } break; case "Customer All-time Totals": { |
File | Line |
---|---|
Controllers/MapController.java | 191 |
Controllers/MapController.java | 231 |
String PhoneD = customer.getPhone(); /* if (m.infoPanel.getComponentCount() > 8) { m.infoPanel.remove(m.infoPanel.getComponentCount() - 1); }*/ Button b = new Button(customer.getYear()); b.setOnAction(e1 -> { Pane newPane = null; FXMLLoader loader; String tabTitle; loader = new FXMLLoader(getClass().getResource("/UI/Customer.fxml")); try { newPane = loader.load(); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error loading window. Please retry then reinstall application. If error persists, contact the developers."); } CustomerController customerCont = loader.getController(); customerCont.initCustomer(customer, mainCont); tabTitle = ("Customer View - " + customer.getName() + " - " + customer.getYear()); mainCont.addTab(newPane, tabTitle); }); |
File | Line |
---|---|
Controllers/AddYearController.java | 476 |
Controllers/UsersGroupsAndYearsController.java | 1369 |
ProductTable.getColumns().add(tbCol); } javafx.scene.control.TableColumn<formattedProductProps, String> categoryColumn = new javafx.scene.control.TableColumn<>("Category"); categoryColumn.setCellValueFactory(new PropertyValueFactory<>("productCategory")); categoryColumn.setCellFactory(ComboBoxTableCell.forTableColumn(categoriesTb)); categoryColumn.setOnEditCommit(t -> { String newVal = catCmbxChanged(t.getNewValue()); t.getRowValue().productCategory.set(newVal); data.get(t.getTablePosition().getRow()).productCategory.set(newVal); }); ProductTable.getColumns().add(categoryColumn); |
File | Line |
---|---|
ABOS/Derby/ReportsController.java | 422 |
Controllers/ReportsController.java | 423 |
LogToFile.log((InterruptedException) e, Severity.FINE, "Add Customer process canceled."); } } if (e instanceof Exception) { LogToFile.log((Exception) e, Severity.WARNING, reportsWorker.getMessage()); } if (e instanceof FileNotFoundException) { LogToFile.log((FileNotFoundException) e, Severity.WARNING, "Error accessing PDF file. Please check if it is open in any other programs and close it."); } if (e instanceof IOException) { LogToFile.log((IOException) e, Severity.WARNING, reportsWorker.getMessage()); } if (e instanceof SaxonApiException) { LogToFile.log((SaxonApiException) e, Severity.SEVERE, "Error converting temporary XML to pdf. Try again or contact support."); } }); progDial.getDialogStage().show(); |
File | Line |
---|---|
ABOS/Derby/Geolocation.java | 51 |
ABOS/Derby/ReportsController.java | 185 |
public static String getCityState(String zipCode) throws IOException { //String AddressF = Address.replace(" ","+"); //The URL for the MapquestAPI String url = String.format("http://open.mapquestapi.com/nominatim/v1/search.php?key=CCBtW1293lbtbxpRSnImGBoQopnvc4Mz&format=xml&q=%s&addressdetails=1&limit=1&accept-language=en-US", zipCode); //Defines connection URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); //add request header con.setRequestProperty("User-Agent", "Mozilla/5.0"); String city = ""; String State = ""; //Creates Response buffer for Web response try (BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream()))) { String inputLine; StringBuilder response = new StringBuilder(); //Fill String buffer with response while ((inputLine = in.readLine()) != null) { //inputLine = StringEscapeUtils.escapeHtml4(inputLine); //inputLine = StringEscapeUtils.escapeXml11(inputLine); response.append(inputLine); } |
File | Line |
---|---|
ABOS/Derby/Geolocation.java | 86 |
ABOS/Derby/SettingsController.java | 432 |
doc.getDocumentElement().normalize(); //System.out.println("Root element :" + doc.getDocumentElement().getNodeName()); NodeList nList = doc.getElementsByTagName("place"); for (int temp = 0; temp < nList.getLength(); temp++) { Node nNode = nList.item(temp); if ((int) nNode.getNodeType() == (int) Node.ELEMENT_NODE) { Element eElement = (Element) nNode; city = eElement.getElementsByTagName("city").item(0).getTextContent(); State = eElement.getElementsByTagName("state").item(0).getTextContent(); //final Object[] columnNames = {"Product Name", "Size", "Price/Item", "Quantity", "Total Cost"}; } } } catch (Exception e) { LogToFile.log(e, Severity.WARNING, "Error parsing geolocation server response. Please Check the address and try again"); |
File | Line |
---|---|
ABOS/Derby/LogToFile.java | 104 |
Utilities/LogToFile.java | 108 |
alert.setContentText(msg); alert.showAndWait(); } break; case CONFIG: logger.log(Level.CONFIG, msg, ex); break; case FINE: logger.log(Level.FINE, msg, ex); break; case FINER: logger.log(Level.FINER, msg, ex); break; case FINEST: logger.log(Level.FINEST, msg, ex); break; //default: // logger.log(Level.CONFIG, msg, ex); // break; } } catch (IOException | SecurityException ex1) { logger.log(Level.SEVERE, null, ex1); } finally { if (fh != null) { fh.close(); } } } } |
File | Line |
---|---|
ABOS/Derby/MainController.java | 350 |
ABOS/Derby/MainController.java | 363 |
openTabInCurrentWindow(NewPane2, tabTitle); }, () -> { //Open In New Tab FXMLLoader loader2 = new FXMLLoader(getClass().getResource("/UI/Customer.fxml")); Pane NewPane2 = null; try { NewPane2 = loader2.load(); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error loading window. Please retry then reinstall application. If error persists, contact the developers."); } CustomerController customerCont = loader2.getController(); customerCont.initCustomer(cell.getParent().getValue(), cell.getValue(), this); String tabTitle = ("Customer View - " + cell.getValue() + " - " + cell.getParent().getValue()); |
File | Line |
---|---|
Controllers/AddYearController.java | 778 |
Controllers/UsersGroupsAndYearsController.java | 1949 |
Year yearInfo = new Year(year); formattedProduct[] productArray = yearInfo.getAllProducts(); Object[][] rows = new Object[productArray.length][6]; // data = FXCollections.observableArrayList(); int i = 0; for (formattedProduct productOrder : productArray) { //String productID, String productName, String productSize, String productUnitPrice, String productCategory, int orderedQuantity, BigDecimal extendedCost formattedProductProps prodProps = new formattedProductProps(productOrder.productKey, productOrder.productID, productOrder.productName, productOrder.productSize, productOrder.productUnitPrice, productOrder.productCategory, productOrder.orderedQuantity, productOrder.extendedCost); data.add(prodProps); i++; } ProductTable.setItems(data); } @FXML private void tablefromDb(ActionEvent event) { fillTable(); |
File | Line |
---|---|
Utilities/Year.java | 318 |
Utilities/Year.java | 358 |
PreparedStatement prep = con.prepareStatement("CREATE DEFINER=`" + year + "`@`localhost` TRIGGER `" + prefix + year + "`.`ordered_products_AFTER_INSERT` AFTER INSERT ON `ordered_products` FOR EACH ROW\n" + "BEGIN\n" + "UPDATE orders \n" + "SET \n" + " Cost = (SELECT \n" + " SUM(ExtendedCost)\n" + " FROM\n" + " ordered_products\n" + " WHERE\n" + " orderID = NEW.orderID)\n" + "WHERE\n" + " idOrders = NEW.orderID;\n" + "UPDATE orders \n" + "SET \n" + " Quant = (SELECT \n" + " SUM(Quantity)\n" + " FROM\n" + " ordered_products\n" + " WHERE\n" + " orderID = NEW.orderID)\n" + "WHERE\n" + " idOrders = NEW.orderID;\n" + "END", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { prep.execute(); } catch (SQLException e) { LogToFile.log(e, Severity.SEVERE, CommonErrors.returnSqlMessage(e)); } //Create Triggers try (Connection con = DbInt.getConnection(year); PreparedStatement prep = con.prepareStatement("CREATE DEFINER=`" + year + "`@`localhost` TRIGGER `" + prefix + year + "`.`ordered_products_BEFORE_UPDATE` BEFORE UPDATE ON `ordered_products` FOR EACH ROW\n" + |
File | Line |
---|---|
ABOS/Derby/ReportsController.java | 185 |
ABOS/Derby/SettingsController.java | 396 |
private static String getCityState(String zipCode) throws IOException { //String AddressF = Address.replace(" ","+"); //The URL for the MapquestAPI String url = String.format("http://open.mapquestapi.com/nominatim/v1/search.php?key=CCBtW1293lbtbxpRSnImGBoQopnvc4Mz&format=xml&q=%s&addressdetails=1&limit=1&accept-language=en-US", zipCode); //Defines connection URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); //add request header con.setRequestProperty("User-Agent", "Mozilla/5.0"); String city = ""; String State = ""; //Creates Response buffer for Web response try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) { String inputLine; StringBuilder response = new StringBuilder(); //Fill String buffer with response while ((inputLine = in.readLine()) != null) { //inputLine = StringEscapeUtils.escapeHtml4(inputLine); //inputLine = StringEscapeUtils.escapeXml11(inputLine); response.append(inputLine); } |
File | Line |
---|---|
Utilities/DbInt.java | 819 |
Utilities/DbInt.java | 910 |
public static Boolean verifyLoginAndUser(Pair<String, String> userPass) { username = userPass.getKey(); password = userPass.getValue(); Boolean successful = false; try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { LogToFile.log(e, Severity.SEVERE, "Error loading database library. Please try reinstalling or contacting support."); } Statement st = null; ResultSet rs = null; Connection pCon; //String Db = String.format("L&G%3",year); String url = String.format("jdbc:mysql://%s/?useSSL=%s", Config.getDbLoc(), Config.getSSL()); try { pCon = DriverManager.getConnection(url, username, password); if (pCon.isValid(2)) { |
File | Line |
---|---|
ABOS/Derby/Geolocation.java | 65 |
Utilities/Geolocation.java | 86 |
try (BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream()))) { String inputLine; StringBuilder response = new StringBuilder(); //Fill String buffer with response while ((inputLine = in.readLine()) != null) { //inputLine = StringEscapeUtils.escapeHtml4(inputLine); //inputLine = StringEscapeUtils.escapeXml11(inputLine); response.append(inputLine); } //Parses XML response and fills City and State Variables try { InputSource is = new InputSource(new StringReader(response.toString())); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(is); doc.getDocumentElement().normalize(); //System.out.println("Root element :" + doc.getDocumentElement().getNodeName()); NodeList nList = doc.getElementsByTagName("place"); |
File | Line |
---|---|
ABOS/Derby/ReportsController.java | 465 |
ABOS/Derby/SettingsController.java | 263 |
Controllers/ReportsController.java | 467 |
Controllers/SettingsController.java | 413 |
pdfLoc.setText(Config.getProp("pdfLoc")); scoutZip.setOnKeyTyped(keyEvent -> { if (scoutZip.getCharacters().length() >= 4) { String zip = scoutZip.getText() + keyEvent.getCharacter(); String cityAndState; try { cityAndState = Geolocation.getCityState(zip); String[] StateTown = cityAndState.split("&"); String state = StateTown[1]; String town = StateTown[0]; scoutTown.setText(town); scoutState.setText(state); } catch (IOException e1) { LogToFile.log(e1, Severity.WARNING, "Couldn't contact geolocation service. Please try again or enter the adress manually and contact suport."); } } }); |
File | Line |
---|---|
ABOS/Derby/AddCustomerController.java | 182 |
Controllers/AddCustomerController.java | 299 |
fillTable(); } public void initialize() { } @FXML public void submit(ActionEvent event) { if (infoEntered()) { if (!edit && yearInfo.addressExists(Address.getText(), ZipCode.getText())) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Duplicate"); alert.setHeaderText("The address you have entered appears to be a duplicate"); alert.setContentText("Would you like to continue?"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { commitChanges(); //updateTots(); //close // ... user chose OK } } else { |
File | Line |
---|---|
ABOS/Derby/AddYearController.java | 527 |
Controllers/AddYearController.java | 535 |
catCmbxChanged(t.getNewValue()); }); ProductTable.getColumns().add(categoryColumn); // boolean updateDb = true; fillTable(); } /* public static void main(String... args) { try { Launchers.AddYear dialog = new Launchers.AddYear(); dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); dialog.setVisible(true); } catch (RuntimeException e) { e.printStackTrace(); } }*/ private void refreshCmbx() { categoriesCmbx.getItems().clear(); categoriesTb.clear(); categoriesTb.add(""); String browse = "Add Category"; rowsCats.forEach(cat -> categoriesTb.add(cat.catName)); categoriesTb.add(browse); categoriesCmbx.getItems().setAll(categoriesTb); } /** * Creates Database for the year specified. */ private void CreateDb() { Year yearToCreate = new Year(yearText.getText()); yearToCreate.CreateDb(ProductTable.getItems(), rowsCats); |
File | Line |
---|---|
ABOS/Derby/AddCustomerController.java | 266 |
ABOS/Derby/AddCustomerController.java | 342 |
Controllers/AddCustomerController.java | 464 |
Controllers/AddCustomerController.java | 572 |
BigDecimal unitCost = new BigDecimal(t.getTableView().getItems().get(t.getTablePosition().getRow()).productUnitPrice.get().replaceAll("\\$", "")); //Removes $ from cost and multiplies to get the total cost for that item BigDecimal ItemTotalCost = unitCost.multiply(new BigDecimal(quantity)); t.getRowValue().extendedCost.set(ItemTotalCost); t.getRowValue().orderedQuantity.set(quantity); t.getRowValue().orderedQuantityString.set(String.valueOf(quantity)); data.get(t.getTablePosition().getRow()).orderedQuantity.set(quantity); data.get(t.getTablePosition().getRow()).extendedCost.set(ItemTotalCost); t.getTableView().refresh(); totalCostFinal = BigDecimal.ZERO; |
File | Line |
---|---|
ABOS/Derby/MainController.java | 338 |
ABOS/Derby/MainController.java | 351 |
ABOS/Derby/MainController.java | 364 |
() -> { FXMLLoader loader2 = new FXMLLoader(getClass().getResource("/UI/Customer.fxml")); Pane NewPane2 = null; try { NewPane2 = loader2.load(); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error loading window. Please retry then reinstall application. If error persists, contact the developers."); } CustomerController customerCont = loader2.getController(); customerCont.initCustomer(cell.getParent().getValue(), cell.getValue(), this); String tabTitle = ("Customer View - " + cell.getValue() + " - " + cell.getParent().getValue()); |
File | Line |
---|---|
Controllers/AddCustomerController.java | 464 |
Controllers/AddCustomerController.java | 572 |
Launchers/ConvertDerbyToSQL.java | 179 |
BigDecimal unitCost = t.getTableView().getItems().get(t.getTablePosition().getRow()).productUnitPrice.get(); //Removes $ from cost and multiplies to get the total cost for that item BigDecimal ItemTotalCost = unitCost.multiply(new BigDecimal(quantity)); t.getRowValue().extendedCost.set(ItemTotalCost); t.getRowValue().orderedQuantity.set(quantity); t.getRowValue().orderedQuantityString.set(String.valueOf(quantity)); data.get(t.getTablePosition().getRow()).orderedQuantity.set(quantity); data.get(t.getTablePosition().getRow()).extendedCost.set(ItemTotalCost); t.getTableView().refresh(); |
File | Line |
---|---|
Controllers/UsersGroupsAndYearsController.java | 2019 |
Controllers/UsersGroupsAndYearsController.java | 2034 |
case "Group": cmContent = createContextMenuContent( //Open () -> { String year = ""; if (cell.getParent().getValue().getValue().getKey().equals("Year")) { year = cell.getParent().getValue().getKey(); } else if (cell.getParent().getParent().getValue().getValue().getKey().equals("Year")) { year = cell.getParent().getParent().getValue().getKey(); } |
File | Line |
---|---|
ABOS/Derby/cPoint.java | 22 |
Utilities/cPoint.java | 22 |
class cPoint { private final String AddressM; private final String CityM; private final String StateM; private final Double LatM; private final Double LonM; public cPoint(Double Lat, Double Lon, String Address, String City, String State) { AddressM = Address; LonM = Lon; LatM = Lat; CityM = City; StateM = State; } public Double getLat() { return LatM; } // --Commented out by Inspection START (1/2/2016 12:01 PM): // public void setLat(Double Lat) { // LatM = Lat; // } // --Commented out by Inspection STOP (1/2/2016 12:01 PM) public Double getLon() { return LonM; } // --Commented out by Inspection START (1/2/2016 12:01 PM): // public void setLon(Double Lon) { // LonM = Lon; // } // --Commented out by Inspection STOP (1/2/2016 12:01 PM) public String getAddress() { return AddressM; } public String getCity() { return CityM; } public String getState() { return StateM; } // --Commented out by Inspection START (1/2/2016 12:01 PM): // public void setAddress(String Address) { // AddressM = Address; // } // --Commented out by Inspection STOP (1/2/2016 12:01 PM) } |
File | Line |
---|---|
Utilities/Order.java | 350 |
Utilities/Order.java | 413 |
try (Connection con = DbInt.getConnection(year); PreparedStatement writeOrd = con.prepareStatement("INSERT INTO orderedproductsview(uName,custId, orderID, ProductID, Quantity) VALUES(?,?,?,?,?)", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { for (formattedProductProps prod : orderNoZero) { writeOrd.setString(1, uName); writeOrd.setInt(2, custID); writeOrd.setInt(3, OrderID); writeOrd.setInt(4, prod.getProductKey()); writeOrd.setInt(5, prod.getOrderedQuantity()); fail.doAction(); message.set("Adding Order"); writeOrd.executeUpdate(); } } |
File | Line |
---|---|
ABOS/Derby/ReportsWorker.java | 449 |
Workers/ReportsWorker.java | 474 |
} } //Column Elements { Element columns = doc.createElement("columns"); rootElement.appendChild(columns); String[] Columns = {"ID", "Name", "Unit Size", "Unit Cost", "Quantity", "Extended Price"}; for (String Column : Columns) { //Column { Element columnName = doc.createElement("column"); Element cName = doc.createElement("name"); cName.appendChild(doc.createTextNode(Column)); columnName.appendChild(cName); columns.appendChild(columnName); } } } setProgress(5); switch (reportType) { case "Year Totals": { Order order = new Order(); |
File | Line |
---|---|
ABOS/Derby/SettingsController.java | 59 |
Controllers/SettingsController.java | 59 |
@FXML private CheckBox Delivered; @FXML private CheckBox Paid; @FXML private TextField Name; @FXML private TextField Address; @FXML private TextField ZipCode; @FXML private TextField Town; @FXML private TextField State; @FXML private TextField Phone; @FXML private TextField Email; @FXML private TextField DonationsT; //Report @FXML private ComboBox<Object> cmbxReportType; @FXML private TextField scoutName; @FXML private TextField scoutStAddr; @FXML private TextField scoutZip; @FXML private TextField scoutTown; @FXML private TextField scoutState; @FXML private TextField scoutPhone; @FXML private TextField scoutRank; @FXML private TextField logoLoc; @FXML private TextField pdfLoc; |
File | Line |
---|---|
ABOS/Derby/SettingsController.java | 410 |
Utilities/Geolocation.java | 86 |
try (BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream()))) { String inputLine; StringBuilder response = new StringBuilder(); //Fill String buffer with response while ((inputLine = in.readLine()) != null) { //inputLine = StringEscapeUtils.escapeHtml4(inputLine); //inputLine = StringEscapeUtils.escapeXml11(inputLine); response.append(inputLine); } //Parses XML response and fills City and State Variables try { InputSource is = new InputSource(new StringReader(response.toString())); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(is); doc.getDocumentElement().normalize(); |
File | Line |
---|---|
ABOS/Derby/AddYearController.java | 605 |
Controllers/AddYearController.java | 624 |
Controllers/UsersGroupsAndYearsController.java | 1796 |
if ((int) nNode.getNodeType() == (int) Node.ELEMENT_NODE) { Element eElement = (Element) nNode; rowsCats.add(new Year.category(eElement.getElementsByTagName("CategoryName").item(0).getTextContent(), eElement.getElementsByTagName("CategoryDate").item(0).getTextContent())); } } //rowsCats = rowsCatsL; NodeList nList = doc.getElementsByTagName("Products"); Object[][] rows = new Object[nList.getLength()][5]; for (int temp = 0; temp < nList.getLength(); temp++) { |
File | Line |
---|---|
ABOS/Derby/ReportsController.java | 218 |
ABOS/Derby/SettingsController.java | 432 |
doc.getDocumentElement().normalize(); //System.out.println("Root element :" + doc.getDocumentElement().getNodeName()); NodeList nList = doc.getElementsByTagName("place"); for (int temp = 0; temp < nList.getLength(); temp++) { Node nNode = nList.item(temp); if ((int) nNode.getNodeType() == (int) Node.ELEMENT_NODE) { Element eElement = (Element) nNode; city = eElement.getElementsByTagName("city").item(0).getTextContent(); State = eElement.getElementsByTagName("state").item(0).getTextContent(); //final Object[] columnNames = {"Product Name", "Size", "Price/Item", "Quantity", "Total Cost"}; } } } catch (ParserConfigurationException | SAXException e) { |
File | Line |
---|---|
ABOS/Derby/AddYearController.java | 780 |
Controllers/AddYearController.java | 799 |
Controllers/UsersGroupsAndYearsController.java | 1969 |
fillTable(); } @FXML private void xmlFromTable(ActionEvent event) { FileChooser chooser = new FileChooser(); FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("XML files", "*.xml", "*.XML"); chooser.getExtensionFilters().add(filter); chooser.setSelectedExtensionFilter(filter); File XML = chooser.showSaveDialog(parentWindow); if (XML != null) { String path = XML.getAbsolutePath(); if (!path.toLowerCase().endsWith(".xml")) { path += ".xml"; } createXML(path); } } |
File | Line |
---|---|
ABOS/Derby/MainController.java | 170 |
ABOS/Derby/MainController.java | 183 |
addCustCont.initAddCust(cell.getParent().getValue(), this, openTabInCurrentWindow(NewPane2, tabTitle)); }, () -> { //Open In New Tab FXMLLoader loader2 = new FXMLLoader(getClass().getResource("/UI/AddCustomer.fxml")); Pane NewPane2 = null; try { NewPane2 = loader2.load(); } catch (IOException e) { LogToFile.log(e, Severity.SEVERE, "Error loading window. Please retry then reinstall application. If error persists, contact the developers."); } AddCustomerController addCustCont = loader2.getController(); String tabTitle = ("Add Customer - " + cell.getParent().getValue()); addCustCont.initAddCust(cell.getParent().getValue(), this, addTab(NewPane2, tabTitle)); |
File | Line |
---|---|
Controllers/AddUserController.java | 266 |
Controllers/AddUserController.java | 352 |
yearTView.setCellFactory(CheckBoxTreeCell.forTreeView()); groupBox.getSelectionModel().selectedItemProperty().addListener(observable -> { groups.put(year, groupBox.getSelectionModel().getSelectedItem().getValue()); }); BorderPane contents = new BorderPane(new VBox(10, new Label("Users to manage"), yearTView), new HBox(10, new Label("Group to be a part of"), groupBox), null, null, null); yPane.setText(year); yPane.setContent(contents); yearsPanel.getPanes().add(yPane); |
File | Line |
---|---|
Utilities/Order.java | 332 |
Utilities/Order.java | 398 |
try (Connection con = DbInt.getConnection(year); PreparedStatement prep = con.prepareStatement("SELECT idOrders FROM ordersview WHERE custId=?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { prep.setInt(1, custID); try (ResultSet rs = prep.executeQuery()) { while (rs.next()) { Ids.add(rs.getInt(1)); } } } int OrderID = Ids.get(Ids.size() - 1); try (Connection con = DbInt.getConnection(year); PreparedStatement prep = con.prepareStatement("DELETE FROM orderedproductsview WHERE orderID=?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { |