├── .gitignore ├── .mvn └── wrapper │ ├── MavenWrapperDownloader.java │ └── maven-wrapper.properties ├── LICENSE ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src └── main ├── java └── com │ └── github │ └── derickfelix │ └── bankapplication │ ├── BankApplication.java │ ├── database │ ├── BankAppTemplate.java │ └── RowMapper.java │ ├── models │ ├── Customer.java │ ├── Entity.java │ ├── Operation.java │ └── User.java │ ├── repositories │ ├── BaseRepository.java │ ├── CustomerRepository.java │ ├── OperationRepository.java │ ├── UserRepository.java │ ├── WithdrawRepository.java │ └── impl │ │ ├── CustomerRepositoryImpl.java │ │ ├── OperationRepositoryImpl.java │ │ ├── RepositoryFactory.java │ │ ├── UserRepositoryImpl.java │ │ └── WithdrawRepositoryImpl.java │ ├── securities │ └── AuthSecurity.java │ ├── utilities │ ├── DBUtility.java │ ├── FileUtility.java │ ├── MessageUtility.java │ └── ViewUtility.java │ └── views │ ├── AboutForm.form │ ├── AboutForm.java │ ├── LoginForm.form │ ├── LoginForm.java │ ├── custom │ ├── BackgroundDesktopPane.java │ └── StripedTableCellRenderer.java │ ├── customers │ ├── AccountInfoFrame.form │ ├── AccountInfoFrame.java │ ├── CustomerMainForm.form │ ├── CustomerMainForm.java │ ├── NewDepositFrame.form │ ├── NewDepositFrame.java │ ├── NewWithdrawFrame.form │ └── NewWithdrawFrame.java │ ├── dialogs │ ├── ExceptionDialog.form │ ├── ExceptionDialog.java │ ├── ExportDialog.form │ └── ExportDialog.java │ └── users │ ├── CustomersFrame.form │ ├── CustomersFrame.java │ ├── CustomersFrameForm.form │ ├── CustomersFrameForm.java │ ├── MainForm.form │ ├── MainForm.java │ ├── UsersFrame.form │ ├── UsersFrame.java │ ├── UsersFrameForm.form │ └── UsersFrameForm.java └── resources └── images ├── add.png ├── close.png ├── delete.png ├── demo.jpeg ├── desktop-background.png ├── edit.png ├── logo.png ├── logo.svg ├── print.png ├── save.png └── search.png /.gitignore: -------------------------------------------------------------------------------- 1 | # NetBeans specific # 2 | nbproject/private/ 3 | build/ 4 | nbbuild/ 5 | dist/ 6 | nbdist/ 7 | nbactions.xml 8 | nb-configuration.xml 9 | 10 | # Class Files # 11 | *.class 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.ear 17 | /target/ 18 | /nbproject/ -------------------------------------------------------------------------------- /.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2020 Derick Felix 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Banking System Management 2 | This application handles some of the basics operations of a bank, such as customer's deposit and withdraw, money transferences, and fixed income calculations (Interest Rate or Bonds calculations). Still in development, feel free to contribute! 3 | 4 | ![Image Demo](https://github.com/derickfelix/BankApplication/blob/master/src/main/resources/images/demo.jpeg) 5 | 6 | ### Getting Started 7 | #### Step 1: Clone this Repository 8 | `git clone https://github.com/derickfelix/BankApplication` 9 | #### Step 2: Build & Run 10 | ```shell 11 | ./mvn clean package 12 | java -jar target/BankApplication--jar-with-dependencies.jar 13 | ``` 14 | 15 | ### Development 16 | You'll need to use Netbeans for development, this IDE was chosen because it is widely used by most programmers due to its excellent tools for design forms of the Swing GUI. 17 | 18 | No database is required to be installed, since this project is using the H2 Database, and all the data will be generated on the home folder of the project ~/.zweibank/db (Unix) or C:\\zweibank\\db (Windows). You can open the console of the database when the application is running by looking into http://localhost:8082. 19 | Enjoy! 20 | 21 | ### Default Credentials 22 | user: root 23 | 24 | password: admin 25 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | com.github.derickfelix 5 | BankApplication 6 | 1.0.0 7 | jar 8 | 9 | UTF-8 10 | 1.8 11 | 1.8 12 | 13 | 14 | 15 | 16 | com.h2database 17 | h2 18 | 2.1.210 19 | 20 | 21 | junit 22 | junit 23 | 4.13.1 24 | test 25 | 26 | 27 | 28 | 29 | ${project.basedir}/src/main/java 30 | ${project.basedir}/src/test/java 31 | 32 | 33 | 34 | maven-assembly-plugin 35 | 36 | 37 | package 38 | 39 | single 40 | 41 | 42 | 43 | 44 | 45 | 46 | true 47 | com.github.derickfelix.bankapplication.BankApplication 48 | 49 | 50 | 51 | jar-with-dependencies 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | src/main/resources 60 | true 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/BankApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright 2019 Derick Felix. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication; 25 | 26 | import com.github.derickfelix.bankapplication.utilities.DBUtility; 27 | import com.github.derickfelix.bankapplication.utilities.MessageUtility; 28 | import com.github.derickfelix.bankapplication.views.LoginForm; 29 | import javax.swing.UnsupportedLookAndFeelException; 30 | 31 | public class BankApplication { 32 | 33 | /** 34 | * @param args the command line arguments 35 | */ 36 | public static void main(String args[]) 37 | { 38 | /* Set the System look and feel */ 39 | // 40 | try { 41 | String systemLookAndFeel = javax.swing.UIManager.getSystemLookAndFeelClassName(); 42 | javax.swing.UIManager.setLookAndFeel(systemLookAndFeel); 43 | } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | UnsupportedLookAndFeelException e) { 44 | MessageUtility.error(null, "Failed to use system look and feel", e); 45 | } 46 | // 47 | 48 | DBUtility.prepare(); 49 | 50 | /* Create and display the form */ 51 | java.awt.EventQueue.invokeLater(() -> { 52 | new LoginForm().setVisible(true); 53 | }); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/database/BankAppTemplate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2019 Derick Felix 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.database; 25 | 26 | import com.github.derickfelix.bankapplication.utilities.FileUtility; 27 | import com.github.derickfelix.bankapplication.utilities.MessageUtility; 28 | import java.sql.Connection; 29 | import java.sql.DriverManager; 30 | import java.sql.ResultSet; 31 | import java.sql.SQLException; 32 | import java.sql.Statement; 33 | import java.util.ArrayList; 34 | import java.util.List; 35 | import java.util.Map; 36 | import java.util.Optional; 37 | 38 | public class BankAppTemplate { 39 | public void update(String sql, Map params) 40 | { 41 | try (Connection c = getConnection()) { 42 | // Create statement 43 | if (params != null) { 44 | sql = createSql(params, sql); 45 | } 46 | 47 | try (Statement stmt = c.createStatement()) { 48 | stmt.execute(sql); 49 | } 50 | 51 | } catch (NullPointerException | ClassNotFoundException | SQLException e) { 52 | throw new RuntimeException(e); 53 | } 54 | } 55 | 56 | public Optional queryForObject(String sql, Map params, RowMapper rowMapper) 57 | { 58 | List query = query(sql, params, rowMapper); 59 | 60 | if (query == null || query.isEmpty()) { 61 | return Optional.empty(); 62 | } 63 | 64 | return Optional.of(query.get(0)); 65 | } 66 | 67 | public List queryForList(String sql, Map params, RowMapper rowMapper) 68 | { 69 | return query(sql, params, rowMapper); 70 | } 71 | 72 | private List query(String sql, Map params, RowMapper rowMapper) 73 | { 74 | try (Connection c = getConnection()) { 75 | // Create statement 76 | if (params != null) { 77 | sql = createSql(params, sql); 78 | } 79 | 80 | try (Statement stmt = c.createStatement()) { 81 | List list = new ArrayList(); 82 | try (ResultSet rs = stmt.executeQuery(sql)) { 83 | while (rs.next()) { 84 | list.add(rowMapper.mapRow(rs)); 85 | } 86 | } 87 | return list; 88 | } 89 | } catch (NullPointerException | ClassNotFoundException | SQLException e) { 90 | MessageUtility.error(null, e); 91 | } 92 | 93 | return null; 94 | } 95 | 96 | private String createSql(Map params, String sql) 97 | { 98 | StringBuilder builder = new StringBuilder(); 99 | StringBuilder keyBuilder = new StringBuilder(); 100 | 101 | char[] chars = sql.toCharArray(); 102 | for (int i = 0; i < chars.length; ++i) { 103 | if (chars[i] == ':') { 104 | i++; 105 | while (i < chars.length && (chars[i] != ',' && chars[i] != ' ' && chars[i] != ')')) { 106 | keyBuilder.append(chars[i]); 107 | i++; 108 | } 109 | builder.append("'").append(params.get(keyBuilder.toString())).append("'"); 110 | if (i < chars.length) { 111 | keyBuilder = new StringBuilder(); 112 | } else { 113 | break; 114 | } 115 | } 116 | builder.append(chars[i]); 117 | } 118 | 119 | return builder.toString(); 120 | } 121 | 122 | private Connection getConnection() throws ClassNotFoundException, SQLException 123 | { 124 | Class.forName("org.h2.Driver"); 125 | String username = "sa"; 126 | String password = ""; 127 | 128 | return DriverManager.getConnection("jdbc:h2:" + FileUtility.home() + "db;DB_CLOSE_ON_EXIT=FALSE;AUTO_RECONNECT=TRUE", username, password); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/database/RowMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2019 Derick Felix 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.database; 25 | 26 | import java.sql.ResultSet; 27 | import java.sql.SQLException; 28 | 29 | /** 30 | * An interface used by {@link BankAppTemplate BankAppTemplate} for mapping rows of a 31 | * ResultSet on a per-row bases. Implementations of this interface perform the 32 | * actual work of mapping each row to a result object, but don't need to worry 33 | * about exception handling. {@code SQLExceptions} will be caught and handled by 34 | * the calling {@code BankAppTemplate}. 35 | * 36 | * 37 | * @param the model of the row mapper 38 | */ 39 | public interface RowMapper { 40 | 41 | /** 42 | * Implementations must implement this method to map each row of data in the 43 | * ResultSet. This method should not call next() on the ResultSet; it is 44 | * only supposed to map values of the current row. 45 | * 46 | * @param rs the ResultSet to map (pre-initialized for the current row) 47 | * @return the result object for the current row (may be null) 48 | * @throws java.sql.SQLException if a SQLException is encountered getting 49 | * column values (that is, there's no need to catch SQLException) 50 | */ 51 | T mapRow(ResultSet rs) throws SQLException; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/models/Customer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright 2019 Derick Felix. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.models; 25 | 26 | public class Customer extends Entity { 27 | 28 | private String address; 29 | private String accountNumber; 30 | private String accountType; 31 | private String password; 32 | 33 | public String getAddress() 34 | { 35 | return address; 36 | } 37 | 38 | public void setAddress(String address) 39 | { 40 | this.address = address; 41 | } 42 | 43 | public String getAccountNumber() 44 | { 45 | return accountNumber; 46 | } 47 | 48 | public void setAccountNumber(String accountNumber) 49 | { 50 | this.accountNumber = accountNumber; 51 | } 52 | 53 | public String getAccountType() 54 | { 55 | return accountType; 56 | } 57 | 58 | public void setAccountType(String accountType) 59 | { 60 | this.accountType = accountType; 61 | } 62 | 63 | public String getPassword() 64 | { 65 | return password; 66 | } 67 | 68 | public void setPassword(String password) 69 | { 70 | this.password = password; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/models/Entity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2019 Derick Felix 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.models; 25 | 26 | import java.util.Objects; 27 | 28 | public class Entity { 29 | 30 | private Long id; 31 | 32 | private String name; 33 | 34 | public Long getId() 35 | { 36 | return id; 37 | } 38 | 39 | public void setId(Long id) 40 | { 41 | this.id = id; 42 | } 43 | 44 | @Override 45 | public int hashCode() 46 | { 47 | int hash = 7; 48 | hash = 67 * hash + Objects.hashCode(this.id); 49 | return hash; 50 | } 51 | 52 | @Override 53 | public boolean equals(Object obj) 54 | { 55 | if (this == obj) { 56 | return true; 57 | } 58 | 59 | if (obj == null) { 60 | return false; 61 | } 62 | 63 | if (getClass() != obj.getClass()) { 64 | return false; 65 | } 66 | 67 | final Entity other = (Entity) obj; 68 | 69 | return Objects.equals(this.id, other.id); 70 | } 71 | 72 | public String getName() 73 | { 74 | return name; 75 | } 76 | 77 | public void setName(String name) 78 | { 79 | this.name = name; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/models/Operation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2020 Derick Felix 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.models; 25 | 26 | import java.time.LocalDateTime; 27 | 28 | /** 29 | * 30 | * @author derickfelix 31 | */ 32 | public class Operation { 33 | 34 | private LocalDateTime createdAt; 35 | private String accountNumber; 36 | private double amount; 37 | private Type type; 38 | 39 | public LocalDateTime getCreatedAt() 40 | { 41 | return createdAt; 42 | } 43 | 44 | public void setCreatedAt(LocalDateTime createdAt) 45 | { 46 | this.createdAt = createdAt; 47 | } 48 | 49 | public String getAccountNumber() 50 | { 51 | return accountNumber; 52 | } 53 | 54 | public void setAccountNumber(String accountNumber) 55 | { 56 | this.accountNumber = accountNumber; 57 | } 58 | 59 | public double getAmount() 60 | { 61 | return amount; 62 | } 63 | 64 | public void setAmount(double amount) 65 | { 66 | this.amount = amount; 67 | } 68 | 69 | public Type getType() 70 | { 71 | return type; 72 | } 73 | 74 | public void setType(Type type) 75 | { 76 | this.type = type; 77 | } 78 | 79 | public static enum Type { 80 | WITHDRAW, DEPOSIT; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/models/User.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright 2019 Derick Felix. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.models; 25 | 26 | public class User extends Entity { 27 | 28 | private String username; 29 | private String password; 30 | private String role; 31 | 32 | public String getUsername() 33 | { 34 | return username; 35 | } 36 | 37 | public void setUsername(String username) 38 | { 39 | this.username = username; 40 | } 41 | 42 | public String getPassword() 43 | { 44 | return password; 45 | } 46 | 47 | public void setPassword(String password) 48 | { 49 | this.password = password; 50 | } 51 | 52 | public String getRole() 53 | { 54 | return role; 55 | } 56 | 57 | public void setRole(String role) 58 | { 59 | this.role = role; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/repositories/BaseRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2019 Derick Felix 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.repositories; 25 | 26 | import java.util.List; 27 | import java.util.Optional; 28 | 29 | /** 30 | * 31 | * @param the model the repository will represent 32 | * @param the type of the model identification 33 | */ 34 | public interface BaseRepository { 35 | /** 36 | * Retrieves all the entities of the database 37 | * 38 | * @return - A List of entites 39 | */ 40 | List findAll(); 41 | 42 | /** 43 | * Gets an entity in the database by specifying an id 44 | * 45 | * @param id the id of the entity 46 | * @return an optional of the found entity 47 | */ 48 | Optional find(ID id); 49 | 50 | /** 51 | * Save a specific entity in the database 52 | * 53 | * @param model the entity to update 54 | */ 55 | void save(T model); 56 | 57 | /** 58 | * Destroy a customer of the database 59 | * 60 | * @param id the id to be destroyed 61 | * @return an optional of the deleted entity 62 | */ 63 | Optional deleteById(ID id); 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/repositories/CustomerRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright 2019 Derick Felix. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.repositories; 25 | 26 | import com.github.derickfelix.bankapplication.models.Customer; 27 | import java.util.List; 28 | import java.util.Optional; 29 | 30 | public interface CustomerRepository extends BaseRepository { 31 | 32 | List search(String term); 33 | 34 | Optional findByAccountNumber(String accountNumber); 35 | 36 | Optional findByAccountNumberAndPassword(String accountNumber, String password); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/repositories/OperationRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright 2019 Derick Felix. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.repositories; 25 | 26 | import com.github.derickfelix.bankapplication.models.Operation; 27 | import java.util.List; 28 | import java.util.Optional; 29 | 30 | public interface OperationRepository { 31 | 32 | // List findAll(); 33 | 34 | List findAllDeposits(); 35 | 36 | 37 | 38 | List findAllByAccountNumber(String accountNumber); 39 | 40 | List findAllDepositsByAccountNumber(String accountNumber); 41 | 42 | 43 | 44 | void deposit(String accountNumber, double amount); 45 | 46 | 47 | 48 | Optional currentBalance(String accountNumber); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/repositories/UserRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright 2019 Derick Felix. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.repositories; 25 | 26 | import com.github.derickfelix.bankapplication.models.User; 27 | import java.util.List; 28 | import java.util.Optional; 29 | 30 | public interface UserRepository extends BaseRepository { 31 | 32 | List search(String term); 33 | 34 | Optional findByUsernameAndPassword(String username, String password); 35 | 36 | Optional findByUsername(String username); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/repositories/WithdrawRepository.java: -------------------------------------------------------------------------------- 1 | package com.github.derickfelix.bankapplication.repositories; 2 | 3 | import com.github.derickfelix.bankapplication.models.Operation; 4 | import java.util.List; 5 | import java.util.Optional; 6 | 7 | public interface WithdrawRepository{ 8 | List findAllWithdrawsByAccountNumber(String accountNumber); 9 | void withdraw(String accountNumber, double amount); 10 | List findAllWithdraws(); 11 | } -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/repositories/impl/CustomerRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright 2019 Derick Felix. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.repositories.impl; 25 | 26 | import com.github.derickfelix.bankapplication.database.BankAppTemplate; 27 | import com.github.derickfelix.bankapplication.database.RowMapper; 28 | import com.github.derickfelix.bankapplication.models.Customer; 29 | import java.sql.ResultSet; 30 | import java.sql.SQLException; 31 | import com.github.derickfelix.bankapplication.repositories.CustomerRepository; 32 | import java.util.HashMap; 33 | import java.util.List; 34 | import java.util.Map; 35 | import java.util.Optional; 36 | import org.h2.util.StringUtils; 37 | 38 | public class CustomerRepositoryImpl implements CustomerRepository { 39 | 40 | private final BankAppTemplate template; 41 | private static CustomerRepositoryImpl custRepoInstance = null; 42 | public CustomerRepositoryImpl() 43 | { 44 | this.template = new BankAppTemplate(); 45 | } 46 | 47 | @Override 48 | public List findAll() 49 | { 50 | String sql = "select * from customers"; 51 | 52 | return template.queryForList(sql, null, new CustomerMapper()); 53 | } 54 | 55 | @Override 56 | public Optional find(Long id) 57 | { 58 | String sql = "select * from customers where id = :id"; 59 | Map params = new HashMap<>(); 60 | params.put("id", id); 61 | 62 | return template.queryForObject(sql, params, new CustomerMapper()); 63 | } 64 | 65 | @Override 66 | public void save(Customer model) 67 | { 68 | String sql; 69 | Map params = new HashMap<>(); 70 | 71 | if (model.getId() == null) { 72 | sql = "insert into customers (name, address, account_number, account_type, password) " 73 | + "values (:name, :address, :account_number, :account_type, HASH('SHA256', :password))"; 74 | 75 | params.put("password", model.getPassword()); 76 | } else { 77 | sql = "update customers set name = :name, address = :address, " 78 | + "account_number = :account_number, account_type = :account_type " 79 | + "where id = :id"; 80 | 81 | params.put("id", model.getId()); 82 | } 83 | 84 | params.put("name", model.getName()); 85 | params.put("address", model.getAddress()); 86 | params.put("account_number", model.getAccountNumber()); 87 | params.put("account_type", model.getAccountType()); 88 | 89 | template.update(sql, params); 90 | } 91 | 92 | @Override 93 | public Optional deleteById(Long id) 94 | { 95 | Optional optional = find(id); 96 | 97 | optional.ifPresent(customer -> { 98 | String sql = "delete from customers where id = :id"; 99 | Map params = new HashMap<>(); 100 | params.put("id", customer.getId()); 101 | 102 | template.update(sql, params); 103 | }); 104 | 105 | return optional; 106 | } 107 | 108 | @Override 109 | public List search(String term) 110 | { 111 | String sql = "select * from customers where id = :code or (upper(name) like :term or upper(address) like :term or upper(account_number) like :term or upper(account_type) like :term)"; 112 | Map params = new HashMap<>(); 113 | params.put("code", StringUtils.isNumber(term) ? term : -1); 114 | params.put("term", "%" + term.toUpperCase() + "%"); 115 | 116 | return template.queryForList(sql, params, new CustomerMapper()); 117 | } 118 | 119 | @Override 120 | public Optional findByAccountNumber(String accountNumber) 121 | { 122 | String sql = "select * from customers where account_number = :account_number"; 123 | Map params = new HashMap<>(); 124 | params.put("account_number", accountNumber); 125 | 126 | return template.queryForObject(sql, params, new CustomerMapper()); 127 | } 128 | 129 | @Override 130 | public Optional findByAccountNumberAndPassword(String accountNumber, String password) 131 | { 132 | String sql = "select * from customers where account_number = :account_number and password = HASH('SHA256', :password)"; 133 | Map params = new HashMap<>(); 134 | params.put("account_number", accountNumber); 135 | params.put("password", password); 136 | 137 | return template.queryForObject(sql, params, new CustomerMapper()); 138 | } 139 | 140 | public class CustomerMapper implements RowMapper { 141 | 142 | @Override 143 | public Object mapRow(ResultSet rs) throws SQLException 144 | { 145 | Customer customer = new Customer(); 146 | customer.setId(rs.getLong("id")); 147 | customer.setName(rs.getString("name")); 148 | customer.setAddress(rs.getString("address")); 149 | customer.setAccountNumber(rs.getString("account_number")); 150 | customer.setAccountType(rs.getString("account_type")); 151 | customer.setPassword(rs.getString("password")); 152 | 153 | return customer; 154 | } 155 | 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/repositories/impl/OperationRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright 2019 Derick Felix. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.repositories.impl; 25 | 26 | import com.github.derickfelix.bankapplication.database.BankAppTemplate; 27 | import com.github.derickfelix.bankapplication.database.RowMapper; 28 | import com.github.derickfelix.bankapplication.models.Operation; 29 | import java.sql.ResultSet; 30 | import java.sql.SQLException; 31 | import com.github.derickfelix.bankapplication.repositories.OperationRepository; 32 | import java.time.LocalDateTime; 33 | import java.util.ArrayList; 34 | import java.util.Collections; 35 | import java.util.HashMap; 36 | import java.util.List; 37 | import java.util.Map; 38 | import java.util.Optional; 39 | 40 | public class OperationRepositoryImpl implements OperationRepository { 41 | 42 | private final BankAppTemplate template; 43 | private static OperationRepositoryImpl operationalRepoInstance = null; 44 | 45 | private OperationRepositoryImpl() 46 | { 47 | this.template = new BankAppTemplate(); 48 | } 49 | 50 | public static OperationRepositoryImpl getOPInstance() { 51 | if (operationalRepoInstance == null) { 52 | operationalRepoInstance = new OperationRepositoryImpl(); 53 | } 54 | return operationalRepoInstance; 55 | } 56 | 57 | @Override 58 | public List findAllDeposits() 59 | { 60 | String sql = "select * from deposits"; 61 | 62 | return template.queryForList(sql, null, new OperationMapper(Operation.Type.DEPOSIT)); 63 | } 64 | 65 | @Override 66 | public List findAllByAccountNumber(String accountNumber) 67 | { 68 | String withdrawSql = "select * from withdraws where account_number = :account_number"; 69 | String depositSql = "select * from deposits where account_number = :account_number"; 70 | Map params = new HashMap<>(); 71 | params.put("account_number", accountNumber); 72 | 73 | List withdraws = template.queryForList(withdrawSql, params, new OperationMapper(Operation.Type.WITHDRAW)); 74 | List deposits = template.queryForList(depositSql, params, new OperationMapper(Operation.Type.DEPOSIT)); 75 | 76 | List operations = new ArrayList<>(withdraws.size() + deposits.size()); 77 | operations.addAll(withdraws); 78 | operations.addAll(deposits); 79 | 80 | Collections.sort(operations, (a, b) -> { 81 | return a.getCreatedAt().compareTo(b.getCreatedAt()); 82 | }); 83 | 84 | return operations; 85 | } 86 | 87 | @Override 88 | public List findAllDepositsByAccountNumber(String accountNumber) 89 | { 90 | String sql = "select * from deposits where account_number = :account_number"; 91 | Map params = new HashMap<>(); 92 | params.put("account_number", accountNumber); 93 | 94 | return template.queryForList(sql, params, new OperationMapper(Operation.Type.DEPOSIT)); 95 | } 96 | 97 | 98 | 99 | 100 | @Override 101 | public void deposit(String accountNumber, double amount) 102 | { 103 | String sql = "insert into deposits (created_at, account_number, amount) values (:created_at, :account_number, :amount)"; 104 | Map params = new HashMap<>(); 105 | params.put("created_at", LocalDateTime.now()); 106 | params.put("account_number", accountNumber); 107 | params.put("amount", amount); 108 | 109 | template.update(sql, params); 110 | } 111 | 112 | 113 | 114 | 115 | @Override 116 | public Optional currentBalance(String accountNumber) 117 | { 118 | String sql = "select " 119 | + "IFNULL((select sum(amount) from deposits where account_number = :account_number), 0) " 120 | + " - " 121 | + "IFNULL((select sum(amount) from withdraws where account_number = :account_number), 0)" 122 | + "as balance"; 123 | 124 | Map params = new HashMap<>(); 125 | params.put("account_number", accountNumber); 126 | 127 | return template.queryForObject(sql, params, new BalanceMapper()); 128 | } 129 | 130 | public class OperationMapper implements RowMapper { 131 | 132 | private final Operation.Type type; 133 | 134 | public OperationMapper(Operation.Type type) 135 | { 136 | this.type = type; 137 | } 138 | 139 | @Override 140 | public Operation mapRow(ResultSet rs) throws SQLException 141 | { 142 | Operation operation = new Operation(); 143 | operation.setCreatedAt(rs.getTimestamp("created_at").toLocalDateTime()); 144 | operation.setAccountNumber(rs.getString("account_number")); 145 | operation.setAmount(type == Operation.Type.WITHDRAW ? -rs.getDouble("amount") : rs.getDouble("amount")); 146 | operation.setType(type); 147 | 148 | return operation; 149 | } 150 | 151 | } 152 | 153 | public class BalanceMapper implements RowMapper { 154 | 155 | @Override 156 | public Double mapRow(ResultSet rs) throws SQLException 157 | { 158 | return rs.getDouble("balance"); 159 | } 160 | 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/repositories/impl/RepositoryFactory.java: -------------------------------------------------------------------------------- 1 | package com.github.derickfelix.bankapplication.repositories.impl; 2 | 3 | import com.github.derickfelix.bankapplication.repositories.BaseRepository; 4 | 5 | public class RepositoryFactory { 6 | public BaseRepository getInstance(String repo) { 7 | if(repo.equalsIgnoreCase("user")) { 8 | return new UserRepositoryImpl(); 9 | } else if (repo.equalsIgnoreCase("customer")) { 10 | return new CustomerRepositoryImpl(); 11 | } 12 | return null; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/repositories/impl/UserRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright 2019 Derick Felix. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.repositories.impl; 25 | 26 | import com.github.derickfelix.bankapplication.database.BankAppTemplate; 27 | import com.github.derickfelix.bankapplication.database.RowMapper; 28 | import com.github.derickfelix.bankapplication.models.User; 29 | import com.github.derickfelix.bankapplication.repositories.UserRepository; 30 | import java.sql.ResultSet; 31 | import java.sql.SQLException; 32 | import java.util.HashMap; 33 | import java.util.List; 34 | import java.util.Map; 35 | import java.util.Optional; 36 | import org.h2.util.StringUtils; 37 | 38 | public class UserRepositoryImpl implements UserRepository { 39 | 40 | private final BankAppTemplate template; 41 | 42 | public UserRepositoryImpl() 43 | { 44 | this.template = new BankAppTemplate(); 45 | } 46 | 47 | @Override 48 | public List findAll() 49 | { 50 | String sql = "select * from users"; 51 | 52 | return template.queryForList(sql, null, new UserMapper()); 53 | } 54 | 55 | @Override 56 | public Optional find(Long id) 57 | { 58 | String sql = "select * from users where id = :id"; 59 | Map params = new HashMap<>(); 60 | params.put("id", id); 61 | 62 | return template.queryForObject(sql, params, new UserMapper()); 63 | } 64 | 65 | @Override 66 | public void save(User model) 67 | { 68 | String sql; 69 | Map params = new HashMap<>(); 70 | 71 | if (model.getId() == null) { 72 | sql = "insert into users (name, username, password, role) " 73 | + "values (:name, :username, HASH('SHA256', :password), :role)"; 74 | 75 | params.put("password", model.getPassword()); 76 | } else { 77 | sql = "update users set name = :name, username = :username, role = :role where id = :id"; 78 | 79 | params.put("id", model.getId()); 80 | } 81 | 82 | params.put("username", model.getUsername()); 83 | params.put("name", model.getName()); 84 | params.put("role", model.getRole()); 85 | 86 | template.update(sql, params); 87 | } 88 | 89 | @Override 90 | public Optional deleteById(Long id) 91 | { 92 | Optional optional = find(id); 93 | 94 | optional.ifPresent(user -> { 95 | String sql = "delete from users where id = :id"; 96 | Map params = new HashMap<>(); 97 | params.put("id", user.getId()); 98 | 99 | template.update(sql, params); 100 | }); 101 | 102 | return optional; 103 | } 104 | 105 | @Override 106 | public Optional findByUsername(String username) 107 | { 108 | String sql = "select * from users where username = :username"; 109 | Map params = new HashMap<>(); 110 | params.put("username", username); 111 | 112 | return template.queryForObject(sql, params, new UserMapper()); 113 | } 114 | 115 | @Override 116 | public Optional findByUsernameAndPassword(String username, String password) 117 | { 118 | String sql = "select * from users where username = :username and password = HASH('SHA256', :password)"; 119 | Map params = new HashMap<>(); 120 | params.put("username", username); 121 | params.put("password", password); 122 | 123 | return template.queryForObject(sql, params, new UserMapper()); 124 | } 125 | 126 | @Override 127 | public List search(String term) 128 | { 129 | String sql = "select * from users where id = :code or (upper(name) like :term or upper(username) like :term or upper(role) like :term)"; 130 | Map params = new HashMap<>(); 131 | params.put("code", StringUtils.isNumber(term) ? term : -1); 132 | params.put("term", "%" + term.toUpperCase() + "%"); 133 | 134 | return template.queryForList(sql, params, new UserMapper()); 135 | } 136 | 137 | public static class UserMapper implements RowMapper { 138 | 139 | @Override 140 | public Object mapRow(ResultSet rs) throws SQLException 141 | { 142 | User user = new User(); 143 | user.setId(rs.getLong("id")); 144 | user.setName(rs.getString("name")); 145 | user.setUsername(rs.getString("username")); 146 | user.setPassword(rs.getString("password")); 147 | user.setRole(rs.getString("role")); 148 | 149 | return user; 150 | } 151 | 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/repositories/impl/WithdrawRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.derickfelix.bankapplication.repositories.impl; 2 | 3 | import com.github.derickfelix.bankapplication.database.BankAppTemplate; 4 | import com.github.derickfelix.bankapplication.database.RowMapper; 5 | import com.github.derickfelix.bankapplication.models.Operation; 6 | import com.github.derickfelix.bankapplication.repositories.WithdrawRepository; 7 | 8 | import java.sql.ResultSet; 9 | import java.sql.SQLException; 10 | import java.time.LocalDateTime; 11 | import java.util.HashMap; 12 | import java.util.List; 13 | import java.util.Map; 14 | 15 | public class WithdrawRepositoryImpl implements WithdrawRepository { 16 | private final BankAppTemplate template; 17 | 18 | public WithdrawRepositoryImpl() { 19 | this.template = new BankAppTemplate(); 20 | } 21 | 22 | @Override 23 | public void withdraw(String accountNumber, double amount) 24 | { 25 | String sql = "insert into withdraws (created_at, account_number, amount) values (:created_at, :account_number, :amount)"; 26 | Map params = new HashMap<>(); 27 | params.put("created_at", LocalDateTime.now()); 28 | params.put("account_number", accountNumber); 29 | params.put("amount", amount); 30 | 31 | template.update(sql, params); 32 | } 33 | 34 | @Override 35 | public List findAllWithdrawsByAccountNumber(String accountNumber) 36 | { 37 | String sql = "select * from withdraws where account_number = :account_number"; 38 | Map params = new HashMap<>(); 39 | params.put("account_number", accountNumber); 40 | 41 | return template.queryForList(sql, params, new WithdrawRepositoryImpl.WithdrawMapper(Operation.Type.WITHDRAW)); 42 | } 43 | 44 | @Override 45 | public List findAllWithdraws() 46 | { 47 | String sql = "select * from withdraws"; 48 | 49 | return template.queryForList(sql, null, new WithdrawRepositoryImpl.WithdrawMapper(Operation.Type.WITHDRAW)); 50 | } 51 | 52 | public class WithdrawMapper implements RowMapper { 53 | 54 | private final Operation.Type type; 55 | 56 | public WithdrawMapper(Operation.Type type) 57 | { 58 | this.type = type; 59 | } 60 | 61 | @Override 62 | public Operation mapRow(ResultSet rs) throws SQLException 63 | { 64 | Operation operation = new Operation(); 65 | operation.setCreatedAt(rs.getTimestamp("created_at").toLocalDateTime()); 66 | operation.setAccountNumber(rs.getString("account_number")); 67 | operation.setAmount(type == Operation.Type.WITHDRAW ? -rs.getDouble("amount") : rs.getDouble("amount")); 68 | operation.setType(type); 69 | 70 | return operation; 71 | } 72 | 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/securities/AuthSecurity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2019 Derick Felix 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.securities; 25 | 26 | import com.github.derickfelix.bankapplication.models.Customer; 27 | import com.github.derickfelix.bankapplication.models.User; 28 | 29 | public class AuthSecurity { 30 | 31 | private static User userAuthenticated; 32 | private static Customer customerAuthenticated; 33 | 34 | private AuthSecurity() 35 | { 36 | } 37 | 38 | public static void login(User user) 39 | { 40 | userAuthenticated = user; 41 | } 42 | 43 | public static void login(Customer customer) 44 | { 45 | customerAuthenticated = customer; 46 | } 47 | 48 | public static void logout() 49 | { 50 | userAuthenticated = null; 51 | customerAuthenticated = null; 52 | } 53 | 54 | public static User getUser() 55 | { 56 | return userAuthenticated; 57 | } 58 | 59 | public static Customer getCustomer() 60 | { 61 | return customerAuthenticated; 62 | } 63 | 64 | public static boolean isUserAuthenticated() 65 | { 66 | return userAuthenticated != null; 67 | } 68 | 69 | public static boolean isCustomerAuthenticated() 70 | { 71 | return customerAuthenticated != null; 72 | } 73 | 74 | public static boolean isUserAdmin() 75 | { 76 | return userAuthenticated != null && userAuthenticated.getRole().equals("Administrator"); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/utilities/DBUtility.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2019 Derick Felix 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.utilities; 25 | 26 | import com.github.derickfelix.bankapplication.database.BankAppTemplate; 27 | import com.github.derickfelix.bankapplication.models.User; 28 | import com.github.derickfelix.bankapplication.repositories.impl.UserRepositoryImpl.UserMapper; 29 | import java.sql.ResultSet; 30 | import java.sql.SQLException; 31 | import java.util.Optional; 32 | import java.util.Random; 33 | import org.h2.tools.Server; 34 | 35 | public class DBUtility { 36 | 37 | private static BankAppTemplate template; 38 | 39 | private DBUtility() 40 | { 41 | } 42 | 43 | public static void prepare() 44 | { 45 | try { 46 | Server.createWebServer().start(); 47 | template = new BankAppTemplate(); 48 | checkDatabase(); 49 | } catch (SQLException e) { 50 | MessageUtility.error(null, e); 51 | } 52 | } 53 | 54 | private static void checkDatabase() 55 | { 56 | initialiseTable("customers", 57 | "id identity", "name varchar", "address varchar", "account_number varchar", "account_type varchar", "password varchar" 58 | ); 59 | 60 | initialiseTable("users", 61 | "id identity", "name varchar", "username varchar unique", 62 | "password varchar", "role varchar" 63 | ); 64 | 65 | initialiseTable("deposits", 66 | "id identity", "created_at timestamp", "account_number varchar", "amount decimal" 67 | ); 68 | 69 | initialiseTable("withdraws", 70 | "id identity", "created_at timestamp", "account_number varchar", "amount decimal" 71 | ); 72 | 73 | // Optional 74 | seedTables(); 75 | checkDefaultUser(); 76 | } 77 | 78 | private static void initialiseTable(String tableName, String... fields) 79 | { 80 | StringBuilder builder = new StringBuilder(); 81 | builder.append("create table if not exists "); 82 | builder.append(tableName); 83 | builder.append('('); 84 | 85 | for (int i = 0; i < fields.length - 1; ++i) { 86 | builder.append(fields[i]); 87 | builder.append(", "); 88 | } 89 | 90 | builder.append(fields[fields.length - 1]); 91 | builder.append(')'); 92 | 93 | template.update(builder.toString(), null); 94 | } 95 | 96 | private static void checkDefaultUser() 97 | { 98 | String sql = "select * from users where username = 'root'"; 99 | Optional optional = template.queryForObject(sql, null, new UserMapper()); 100 | 101 | if (!optional.isPresent()) { 102 | template.update("insert into users (name, username, password, role) values ('Admin User', 'root', HASH('SHA256', 'admin'), 'Administrator')", null); 103 | } 104 | } 105 | 106 | private static void seedTables() 107 | { 108 | if (!hasData("users")) { 109 | seedUsers(); 110 | } 111 | if (!hasData("customers")) { 112 | seedCustomers(); 113 | } 114 | } 115 | 116 | private static boolean hasData(String table) 117 | { 118 | String sql = "select count(*) as count from " + table; 119 | 120 | Integer count = template.queryForObject(sql, null, (ResultSet rs) -> rs.getInt("count")).orElse(0); 121 | 122 | return count > 0; 123 | } 124 | 125 | private static void seedUsers() 126 | { 127 | StringBuilder sql = new StringBuilder("insert into users (name, username, password, role) values\n"); 128 | 129 | int amount = 100; 130 | 131 | for (int i = 0; i < amount; i++) { 132 | sql.append('('); 133 | //Generating and appending fullname and username 134 | sql.append(generateNameAndUsername()); 135 | // password 136 | sql.append("', HASH('SHA256', '123456'), 'Standard')"); 137 | 138 | if ((i + 1) < amount) { 139 | sql.append(",\n"); 140 | } 141 | } 142 | 143 | template.update(sql.toString(), null); 144 | } 145 | 146 | private static StringBuilder generateNameAndUsername(){ 147 | Random random = new Random(); 148 | String[] maleNames = maleNames(); 149 | String[] femaleNames = femaleNames(); 150 | StringBuilder name = new StringBuilder(); 151 | boolean male = random.nextBoolean(); 152 | String firstName = male ? maleNames[random.nextInt(maleNames.length)] : femaleNames[random.nextInt(femaleNames.length)]; 153 | 154 | // Full name 155 | name.append("'"); 156 | name.append(firstName); 157 | name.append(' '); 158 | name.append(maleNames[random.nextInt(maleNames.length)]); 159 | name.append("', '"); 160 | // username 161 | name.append(firstName.toLowerCase()); 162 | name.append(random.nextInt(1000)); 163 | 164 | return name; 165 | } 166 | 167 | private static void seedCustomers() 168 | { 169 | StringBuilder sql = new StringBuilder("insert into customers (name, address, account_number, account_type, password) values\n"); 170 | Random random = new Random(); 171 | String[] maleNames = maleNames(); 172 | String[] femaleNames = femaleNames(); 173 | String[] states = states(); 174 | int amount = 1000; 175 | 176 | for (int i = 0; i < amount; i++) { 177 | sql.append('('); 178 | boolean male = random.nextBoolean(); 179 | 180 | // Full name 181 | sql.append("'"); 182 | sql.append(male ? maleNames[random.nextInt(maleNames.length)] : femaleNames[random.nextInt(femaleNames.length)]); 183 | sql.append(' '); 184 | sql.append(maleNames[random.nextInt(maleNames.length)]); 185 | 186 | sql.append("', '"); 187 | // address 188 | sql.append(random.nextInt(8066) + 1000); 189 | sql.append(" Example St, "); 190 | sql.append(states[random.nextInt(states.length)]); 191 | sql.append(' '); 192 | sql.append(random.nextInt(38208) + 1000); 193 | 194 | sql.append("', '"); 195 | // account number 196 | sql.append(random.nextInt(175665) + 100000); 197 | sql.append("-"); 198 | sql.append(random.nextInt(1000) + 100); 199 | sql.append("', '"); 200 | // account type 201 | sql.append(random.nextBoolean() ? "Current" : "Savings"); 202 | // password 203 | sql.append("', HASH('SHA256', '123456'))"); 204 | 205 | if ((i + 1) < amount) { 206 | sql.append(",\n"); 207 | } 208 | } 209 | 210 | template.update(sql.toString(), null); 211 | } 212 | 213 | private static String[] maleNames() 214 | { 215 | return new String[] { 216 | "Jeff", "Abel", "Daron", "Lenard", "Reinaldo", "Earnest", 217 | "Gilberto", "Thaddeus", "Rafael", "Leland", "Cristopher", 218 | "Nickolas", "Darrick", "Jon", "Houston", "Rashad", 219 | "Jason", "Archie", "Carmen", "Thurman", "Forest", "Dannie", 220 | "Dick", "David", "Nick", "Stefan", "Stephen", "Mauricio", 221 | "Sidney", "Pat", "Garry", "Dee", "Rosario", "Ellis", 222 | "Bob", "Julio", "Chung", "Raymond", "Timmy", "Xavier", 223 | "Clay", "Clark", "Kris", "Raleigh", "Neville", "Brendon", 224 | "Wilford", "Zachariah", "Ollie", "Silas", "Terry", "Bennett", 225 | "Asa", "Olen", "Everett", "Benjamin", "Bobbie", "Renaldo", 226 | "Murray", "Josue", "Jamison", "Boyce", "Carson", "Edgardo", 227 | "Kenton", "Ernesto", "Brain", "Jack", "Truman", "Les", "Antonia", 228 | "Thurman", "Robby", "Kris", "Raymon", "Adam", "Damon", "Bernardo", 229 | "Christoper", "Hank", "Man", "Ivory", "Markus", "Weston", 230 | "Kendall", "Edmond", "Royal", "Mervin", "Art", "Moshe", 231 | "Dorian", "Eugenio", "Noe", "Ronald", "Emerson", "Ambrose", 232 | "Avery", "Miquel", "Ruben", "Wyatt" 233 | }; 234 | } 235 | 236 | private static String[] femaleNames() 237 | { 238 | return new String[] { 239 | "Eladia", "Phylicia", "Karey", "Lissa", "Shela", "Maryetta", 240 | "Kimberely", "Estrella", "Bev", "Vallie", "Tonda", "Carline", 241 | "Agripina", "Tiffani", "Yan", "Dori", "Amberly", "Noreen", 242 | "Susan", "Josphine", "Garnet", "Cori", "Trina", "Lyla", "Felicia", 243 | "Nikole", "Katelynn", "Laveta", "Latasha", "Inell", "Teressa", 244 | "Temple", "Oma", "Marlen", "Larhonda", "Fae", "Carole", "Tess", 245 | "Zofia", "Noelia", "Lyndsay", "Odessa", "Yolanda", "Antonina", 246 | "Delorse", "Marry", "Misty", "Winnifred", "Alethia", "Marth" 247 | }; 248 | } 249 | 250 | private static String[] states() 251 | { 252 | return new String[] { 253 | "NY", "CA", "MS", "MD", "GA", "PA", "NJ", "WI", "IL", "MA", 254 | "CT", "SC", "NC", "VA", "TN", "FL" 255 | }; 256 | } 257 | } 258 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/utilities/FileUtility.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2019 Derick Felix 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.utilities; 25 | 26 | import java.io.IOException; 27 | import java.io.PrintWriter; 28 | import java.util.List; 29 | import java.util.stream.Collectors; 30 | 31 | public class FileUtility { 32 | private FileUtility() 33 | { 34 | } 35 | 36 | public static String home() 37 | { 38 | return System.getProperty("os.name").contains("Linux") ? "~/.zweibank/" : "C:\\zweibank\\"; 39 | } 40 | 41 | public static void write(List lines, String pathFile) 42 | { 43 | try (PrintWriter writer = new PrintWriter(pathFile)) { 44 | lines.forEach(line -> { 45 | writer.println(line); 46 | }); 47 | } catch (IOException e) { 48 | MessageUtility.error(null, e); 49 | } 50 | } 51 | 52 | /** 53 | * Exports a table data to a file, user informs which colunms they 54 | * want, and a file divided by ';' will be generated. 55 | * 56 | * @param rows each row (String[]) has many columns 57 | * @param columns only export columns with the true value 58 | * @param filePath the path where the content will be exported 59 | */ 60 | public static void exportTableDataToFile(List rows, boolean[] columns, String filePath) throws Exception 61 | { 62 | if (rows.isEmpty()) { 63 | throw new Exception("Could not export, there is no data"); 64 | } 65 | 66 | if (rows.get(0).length != columns.length) { 67 | throw new Exception("Could not export, the amount of columns is not the same of the columns of the data"); 68 | } 69 | 70 | List lines = rows.stream().map(row -> { 71 | 72 | String line = ""; 73 | 74 | for (int i = 0; i < row.length; ++i) { 75 | if (columns[i]) { 76 | line += row[i] + ";"; 77 | } 78 | } 79 | 80 | return line; 81 | }).collect(Collectors.toList()); 82 | 83 | write(lines, filePath); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/utilities/MessageUtility.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2019 Derick Felix 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.utilities; 25 | 26 | import com.github.derickfelix.bankapplication.views.dialogs.ExceptionDialog; 27 | import javax.swing.JOptionPane; 28 | 29 | public class MessageUtility { 30 | 31 | private MessageUtility() 32 | { 33 | } 34 | 35 | public static void info(String message) 36 | { 37 | info(null, message); 38 | } 39 | 40 | public static void info(java.awt.Frame parent, String message) 41 | { 42 | JOptionPane.showMessageDialog(parent, message, "Zwei Bank Application", JOptionPane.INFORMATION_MESSAGE); 43 | } 44 | 45 | public static void warning(String message) 46 | { 47 | warning(null, message); 48 | } 49 | public static void warning(java.awt.Frame parent, String message) 50 | { 51 | JOptionPane.showMessageDialog(parent, message, "Zwei Bank Application", JOptionPane.WARNING_MESSAGE); 52 | } 53 | 54 | public static int confirmWarning(java.awt.Frame parent, String message) 55 | { 56 | return JOptionPane.showConfirmDialog(null, message, "Zwei Bank Application", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); 57 | } 58 | 59 | /** 60 | * Show an exception dialog with two buttons, okay (closes the dialog) and 61 | * detail (shows another dialog detailing the exception). 62 | * 63 | * @param parent the calling frame of this dialog 64 | * @param e the exception which this dialog is showing 65 | */ 66 | public static void error(java.awt.Frame parent, Exception e) 67 | { 68 | error(parent, e.getMessage(), e); 69 | } 70 | 71 | public static void error(java.awt.Frame parent, String message, Exception e) 72 | { 73 | Object[] choices = {"Ok", "Details >>>"}; 74 | Object defaultChoice = choices[1]; 75 | 76 | if (JOptionPane.showOptionDialog(null, message, "Zwei Bank Application", JOptionPane.YES_NO_OPTION, 77 | JOptionPane.ERROR_MESSAGE, null, choices, defaultChoice) == 1) { 78 | new ExceptionDialog(parent, true, e).setVisible(true); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/utilities/ViewUtility.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2019 Derick Felix 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.utilities; 25 | 26 | import java.awt.Cursor; 27 | import java.util.List; 28 | import javax.swing.JTable; 29 | import javax.swing.table.DefaultTableModel; 30 | 31 | public class ViewUtility { 32 | 33 | public static final Cursor WAIT_CURSOR = new Cursor(Cursor.WAIT_CURSOR); 34 | public static final Cursor DEFAULT_CURSOR = new Cursor(Cursor.DEFAULT_CURSOR); 35 | 36 | private ViewUtility() 37 | { 38 | } 39 | 40 | public static void addIconTo(java.awt.Window frame) 41 | { 42 | try { 43 | java.net.URL url = frame.getClass().getResource("/images/logo.png"); 44 | java.awt.image.BufferedImage image = javax.imageio.ImageIO.read(url); 45 | frame.setIconImage(image); 46 | } catch (java.io.IOException ex) { 47 | MessageUtility.error(null, ex); 48 | } 49 | } 50 | 51 | public static void addRowsToTable(List rows, JTable table) 52 | { 53 | rows.forEach((row) -> { 54 | ((DefaultTableModel) table.getModel()).addRow(row); 55 | }); 56 | } 57 | 58 | public static void clearTable(javax.swing.JTable table) 59 | { 60 | DefaultTableModel dm = (DefaultTableModel) table.getModel(); 61 | dm.getDataVector().removeAllElements(); 62 | dm.fireTableDataChanged(); // notifies the JTable that the model has changed 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/views/AboutForm.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/views/AboutForm.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2019 Derick Felix 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.views; 25 | 26 | import com.github.derickfelix.bankapplication.utilities.ViewUtility; 27 | import java.awt.Color; 28 | import java.time.LocalDate; 29 | import java.time.format.DateTimeFormatter; 30 | import javax.swing.BorderFactory; 31 | 32 | public class AboutForm extends javax.swing.JFrame { 33 | 34 | public AboutForm() 35 | { 36 | initComponents(); 37 | customSettings(); 38 | } 39 | 40 | private void customSettings() 41 | { 42 | ViewUtility.addIconTo(this); 43 | lblDate.setText("Date: " + LocalDate.now().format(DateTimeFormatter.ofPattern("MM/dd/yyyy"))); 44 | getRootPane().setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.WHITE)); 45 | } 46 | 47 | /** 48 | * This method is called from within the constructor to initialize the form. 49 | * WARNING: Do NOT modify this code. The content of this method is always 50 | * regenerated by the Form Editor. 51 | */ 52 | @SuppressWarnings("unchecked") 53 | // //GEN-BEGIN:initComponents 54 | private void initComponents() 55 | { 56 | 57 | lblLogo = new javax.swing.JLabel(); 58 | lblTitle = new javax.swing.JLabel(); 59 | lblVersion = new javax.swing.JLabel(); 60 | lblDate = new javax.swing.JLabel(); 61 | lblLicense = new javax.swing.JLabel(); 62 | 63 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 64 | setTitle("Zwei Bank - Login"); 65 | addMouseListener(new java.awt.event.MouseAdapter() 66 | { 67 | public void mouseClicked(java.awt.event.MouseEvent evt) 68 | { 69 | formMouseClicked(evt); 70 | } 71 | }); 72 | 73 | lblLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/logo.png"))); // NOI18N 74 | 75 | lblTitle.setFont(new java.awt.Font("Noto Sans", 1, 18)); // NOI18N 76 | lblTitle.setText("Bank Application"); 77 | 78 | lblVersion.setText("Version 1.0.0"); 79 | 80 | lblDate.setText("Date: dd/MM/yyyy"); 81 | 82 | lblLicense.setText("MIT License"); 83 | 84 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 85 | getContentPane().setLayout(layout); 86 | layout.setHorizontalGroup( 87 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 88 | .addGroup(layout.createSequentialGroup() 89 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 90 | .addGroup(layout.createSequentialGroup() 91 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 92 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 93 | .addComponent(lblTitle, javax.swing.GroupLayout.Alignment.TRAILING) 94 | .addComponent(lblLicense, javax.swing.GroupLayout.Alignment.TRAILING))) 95 | .addGroup(layout.createSequentialGroup() 96 | .addContainerGap() 97 | .addComponent(lblLogo) 98 | .addGap(96, 96, 96) 99 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 100 | .addComponent(lblVersion, javax.swing.GroupLayout.Alignment.TRAILING) 101 | .addComponent(lblDate, javax.swing.GroupLayout.Alignment.TRAILING)))) 102 | .addContainerGap()) 103 | ); 104 | layout.setVerticalGroup( 105 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 106 | .addGroup(layout.createSequentialGroup() 107 | .addContainerGap() 108 | .addComponent(lblTitle) 109 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 110 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 111 | .addGroup(layout.createSequentialGroup() 112 | .addComponent(lblVersion) 113 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 114 | .addComponent(lblDate)) 115 | .addComponent(lblLogo, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)) 116 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE) 117 | .addComponent(lblLicense) 118 | .addContainerGap()) 119 | ); 120 | 121 | pack(); 122 | setLocationRelativeTo(null); 123 | }// //GEN-END:initComponents 124 | 125 | private void formMouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_formMouseClicked 126 | {//GEN-HEADEREND:event_formMouseClicked 127 | dispose(); 128 | }//GEN-LAST:event_formMouseClicked 129 | 130 | // Variables declaration - do not modify//GEN-BEGIN:variables 131 | private javax.swing.JLabel lblDate; 132 | private javax.swing.JLabel lblLicense; 133 | private javax.swing.JLabel lblLogo; 134 | private javax.swing.JLabel lblTitle; 135 | private javax.swing.JLabel lblVersion; 136 | // End of variables declaration//GEN-END:variables 137 | } 138 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/views/LoginForm.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/views/LoginForm.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2019 Derick Felix 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.views; 25 | 26 | import com.github.derickfelix.bankapplication.models.Customer; 27 | import com.github.derickfelix.bankapplication.repositories.impl.RepositoryFactory; 28 | import com.github.derickfelix.bankapplication.views.users.MainForm; 29 | import com.github.derickfelix.bankapplication.models.User; 30 | import com.github.derickfelix.bankapplication.repositories.CustomerRepository; 31 | import com.github.derickfelix.bankapplication.repositories.UserRepository; 32 | import com.github.derickfelix.bankapplication.securities.AuthSecurity; 33 | import com.github.derickfelix.bankapplication.utilities.ViewUtility; 34 | import com.github.derickfelix.bankapplication.views.customers.CustomerMainForm; 35 | import java.awt.Color; 36 | import java.util.Optional; 37 | import javax.swing.BorderFactory; 38 | import javax.swing.JOptionPane; 39 | 40 | public class LoginForm extends javax.swing.JFrame { 41 | 42 | private final UserRepository userRepository; 43 | private final CustomerRepository customerRepository; 44 | 45 | public LoginForm() 46 | { 47 | this.userRepository = (UserRepository) new RepositoryFactory().getInstance("user"); 48 | this.customerRepository = (CustomerRepository) new RepositoryFactory().getInstance("customer"); 49 | initComponents(); 50 | customSettings(); 51 | } 52 | 53 | private void customSettings() 54 | { 55 | ViewUtility.addIconTo(this); 56 | getRootPane().setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.BLACK)); 57 | } 58 | 59 | /** 60 | * This method is called from within the constructor to initialize the form. 61 | * WARNING: Do NOT modify this code. The content of this method is always 62 | * regenerated by the Form Editor. 63 | */ 64 | @SuppressWarnings("unchecked") 65 | // //GEN-BEGIN:initComponents 66 | private void initComponents() 67 | { 68 | 69 | btnExit = new javax.swing.JButton(); 70 | btnLogin = new javax.swing.JButton(); 71 | lblLogo = new javax.swing.JLabel(); 72 | txtUsernameOrAccountNumber = new javax.swing.JTextField(); 73 | lblUsernameOrAccountNumber = new javax.swing.JLabel(); 74 | lblPassword = new javax.swing.JLabel(); 75 | txtPassword = new javax.swing.JPasswordField(); 76 | 77 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 78 | setTitle("Zwei Bank - Login"); 79 | setUndecorated(true); 80 | 81 | btnExit.setFont(new java.awt.Font("Liberation Sans", 0, 12)); // NOI18N 82 | btnExit.setText("Exit"); 83 | btnExit.addActionListener(new java.awt.event.ActionListener() 84 | { 85 | public void actionPerformed(java.awt.event.ActionEvent evt) 86 | { 87 | btnExitActionPerformed(evt); 88 | } 89 | }); 90 | 91 | btnLogin.setFont(new java.awt.Font("Liberation Sans", 0, 12)); // NOI18N 92 | btnLogin.setText("Login"); 93 | btnLogin.addActionListener(new java.awt.event.ActionListener() 94 | { 95 | public void actionPerformed(java.awt.event.ActionEvent evt) 96 | { 97 | btnLoginActionPerformed(evt); 98 | } 99 | }); 100 | 101 | lblLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/logo.png"))); // NOI18N 102 | 103 | txtUsernameOrAccountNumber.setFont(new java.awt.Font("Liberation Sans", 0, 12)); // NOI18N 104 | 105 | lblUsernameOrAccountNumber.setFont(new java.awt.Font("Liberation Sans", 0, 12)); // NOI18N 106 | lblUsernameOrAccountNumber.setText("Username or Account Number"); 107 | 108 | lblPassword.setFont(new java.awt.Font("Liberation Sans", 0, 12)); // NOI18N 109 | lblPassword.setText("Password"); 110 | 111 | txtPassword.setFont(new java.awt.Font("Liberation Sans", 0, 12)); // NOI18N 112 | 113 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 114 | getContentPane().setLayout(layout); 115 | layout.setHorizontalGroup( 116 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 117 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 118 | .addContainerGap() 119 | .addComponent(lblLogo) 120 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, 37, Short.MAX_VALUE) 121 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) 122 | .addGroup(layout.createSequentialGroup() 123 | .addComponent(btnLogin, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE) 124 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 125 | .addComponent(btnExit, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)) 126 | .addComponent(txtPassword) 127 | .addComponent(lblPassword, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 128 | .addComponent(txtUsernameOrAccountNumber) 129 | .addComponent(lblUsernameOrAccountNumber, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 130 | .addGap(24, 24, 24)) 131 | ); 132 | layout.setVerticalGroup( 133 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 134 | .addGroup(layout.createSequentialGroup() 135 | .addGap(50, 50, 50) 136 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 137 | .addComponent(lblLogo, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE) 138 | .addGroup(layout.createSequentialGroup() 139 | .addGap(18, 18, 18) 140 | .addComponent(lblUsernameOrAccountNumber) 141 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 142 | .addComponent(txtUsernameOrAccountNumber, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) 143 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 144 | .addComponent(lblPassword) 145 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 146 | .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) 147 | .addGap(18, 18, 18) 148 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 149 | .addComponent(btnLogin) 150 | .addComponent(btnExit)))) 151 | .addGap(50, 50, 50)) 152 | ); 153 | 154 | pack(); 155 | setLocationRelativeTo(null); 156 | }// //GEN-END:initComponents 157 | 158 | private void btnExitActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnExitActionPerformed 159 | {//GEN-HEADEREND:event_btnExitActionPerformed 160 | System.exit(0); 161 | }//GEN-LAST:event_btnExitActionPerformed 162 | 163 | private void btnLoginActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnLoginActionPerformed 164 | {//GEN-HEADEREND:event_btnLoginActionPerformed 165 | String usernameOrAccountNumber = txtUsernameOrAccountNumber.getText(); 166 | String password = new String(txtPassword.getPassword()); 167 | Optional userOptional = userRepository.findByUsernameAndPassword(usernameOrAccountNumber, password); 168 | 169 | if (userOptional.isPresent()) { 170 | User user = userOptional.get(); 171 | AuthSecurity.login(user); 172 | new MainForm().setVisible(true); 173 | dispose(); 174 | return; 175 | } 176 | 177 | Optional customerOptional = customerRepository.findByAccountNumberAndPassword(usernameOrAccountNumber, password); 178 | 179 | if (customerOptional.isPresent()) { 180 | Customer customer = customerOptional.get(); 181 | AuthSecurity.login(customer); 182 | new CustomerMainForm().setVisible(true); 183 | dispose(); 184 | return; 185 | } 186 | 187 | JOptionPane.showMessageDialog(this, "Credentials provided doesn't match our records!", "Zwei Bank Application", JOptionPane.WARNING_MESSAGE); 188 | }//GEN-LAST:event_btnLoginActionPerformed 189 | 190 | // Variables declaration - do not modify//GEN-BEGIN:variables 191 | private javax.swing.JButton btnExit; 192 | private javax.swing.JButton btnLogin; 193 | private javax.swing.JLabel lblLogo; 194 | private javax.swing.JLabel lblPassword; 195 | private javax.swing.JLabel lblUsernameOrAccountNumber; 196 | private javax.swing.JPasswordField txtPassword; 197 | private javax.swing.JTextField txtUsernameOrAccountNumber; 198 | // End of variables declaration//GEN-END:variables 199 | } 200 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/views/custom/BackgroundDesktopPane.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2019 Derick Felix 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.views.custom; 25 | 26 | import java.awt.Graphics; 27 | import javax.swing.ImageIcon; 28 | import javax.swing.JDesktopPane; 29 | 30 | /** 31 | * 32 | * @author derickfelix 33 | */ 34 | public class BackgroundDesktopPane extends JDesktopPane { 35 | 36 | private final ImageIcon image; 37 | 38 | public BackgroundDesktopPane() 39 | { 40 | image = new ImageIcon(getClass().getResource("/images/desktop-background.png")); 41 | } 42 | 43 | @Override 44 | protected void paintComponent(Graphics g) 45 | { 46 | super.paintComponent(g); 47 | int x = (getWidth() - image.getIconWidth()) / 2; 48 | int y = (getHeight() - image.getIconHeight()) / 2; 49 | g.drawImage(image.getImage(), x, y, this); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/views/custom/StripedTableCellRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2020 Derick Felix 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.views.custom; 25 | 26 | import java.awt.Color; 27 | import java.awt.Component; 28 | import javax.swing.JTable; 29 | import javax.swing.table.DefaultTableCellRenderer; 30 | 31 | public class StripedTableCellRenderer extends DefaultTableCellRenderer { 32 | 33 | private final DefaultTableCellRenderer renderer; 34 | 35 | @SuppressWarnings("OverridableMethodCallInConstructor") 36 | public StripedTableCellRenderer(int alignment) 37 | { 38 | renderer = new DefaultTableCellRenderer(); 39 | renderer.setHorizontalAlignment(alignment); 40 | } 41 | 42 | @Override 43 | public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) 44 | { 45 | Component c = renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); 46 | 47 | if (isSelected) { 48 | c.setBackground(new Color(50, 120, 255)); 49 | String item = (String) value; 50 | if (item.startsWith("-") && Character.isDigit(item.charAt(1))) { 51 | c.setForeground(Color.CYAN); 52 | } else { 53 | c.setForeground(Color.WHITE); 54 | } 55 | } else { 56 | if (row % 2 == 0) { 57 | c.setBackground(Color.WHITE); 58 | } else { 59 | c.setBackground(new Color(230, 230, 230)); 60 | } 61 | 62 | String item = (String) value; 63 | if (item.startsWith("-") && Character.isDigit(item.charAt(1))) { 64 | c.setForeground(Color.RED); 65 | } else { 66 | c.setForeground(Color.DARK_GRAY); 67 | } 68 | } 69 | 70 | return c; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/views/customers/NewDepositFrame.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 |
168 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/views/customers/NewDepositFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2019 Derick Felix 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.views.customers; 25 | 26 | import com.github.derickfelix.bankapplication.models.Customer; 27 | import com.github.derickfelix.bankapplication.repositories.CustomerRepository; 28 | import com.github.derickfelix.bankapplication.repositories.OperationRepository; 29 | import com.github.derickfelix.bankapplication.repositories.impl.RepositoryFactory; 30 | import com.github.derickfelix.bankapplication.repositories.impl.OperationRepositoryImpl; 31 | import com.github.derickfelix.bankapplication.securities.AuthSecurity; 32 | import com.github.derickfelix.bankapplication.utilities.MessageUtility; 33 | import com.github.derickfelix.bankapplication.utilities.ViewUtility; 34 | import java.util.Optional; 35 | 36 | public class NewDepositFrame extends javax.swing.JInternalFrame { 37 | 38 | private final CustomerMainForm customerMainForm; 39 | private final CustomerRepository customerRepository; 40 | private final OperationRepository operationRepository; 41 | private final String accountNumber; 42 | 43 | public NewDepositFrame(CustomerMainForm customerMainForm) 44 | { 45 | this.customerMainForm = customerMainForm; 46 | this.customerRepository = (CustomerRepository) new RepositoryFactory().getInstance("customer"); 47 | this.operationRepository = OperationRepositoryImpl.getOPInstance(); 48 | this.accountNumber = AuthSecurity.getCustomer().getAccountNumber(); 49 | 50 | initComponents(); 51 | customSettings(); 52 | } 53 | 54 | private void customSettings() 55 | { 56 | defineCurrentBalance(); 57 | } 58 | 59 | /** 60 | * This method is called from within the constructor to initialize the form. 61 | * WARNING: Do NOT modify this code. The content of this method is always 62 | * regenerated by the Form Editor. 63 | */ 64 | @SuppressWarnings("unchecked") 65 | // //GEN-BEGIN:initComponents 66 | private void initComponents() 67 | { 68 | 69 | btnDeposit = new javax.swing.JButton(); 70 | btnClose = new javax.swing.JButton(); 71 | paneInputs = new javax.swing.JPanel(); 72 | lblCurrentBalance = new javax.swing.JLabel(); 73 | txtCurrentBalance = new javax.swing.JTextField(); 74 | txtDepositAmount = new javax.swing.JTextField(); 75 | lblDepositAmount = new javax.swing.JLabel(); 76 | txtPassword = new javax.swing.JPasswordField(); 77 | lblPassword = new javax.swing.JLabel(); 78 | 79 | setClosable(true); 80 | setMaximizable(true); 81 | setResizable(true); 82 | setTitle("Zwei Bank Application - Deposit Operation"); 83 | 84 | btnDeposit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/save.png"))); // NOI18N 85 | btnDeposit.setText("Deposit"); 86 | btnDeposit.addActionListener(new java.awt.event.ActionListener() 87 | { 88 | public void actionPerformed(java.awt.event.ActionEvent evt) 89 | { 90 | btnDepositActionPerformed(evt); 91 | } 92 | }); 93 | 94 | btnClose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/close.png"))); // NOI18N 95 | btnClose.setText("Close"); 96 | btnClose.addActionListener(new java.awt.event.ActionListener() 97 | { 98 | public void actionPerformed(java.awt.event.ActionEvent evt) 99 | { 100 | btnCloseActionPerformed(evt); 101 | } 102 | }); 103 | 104 | paneInputs.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 102))); 105 | 106 | lblCurrentBalance.setText("Your Balance"); 107 | 108 | txtCurrentBalance.setEnabled(false); 109 | 110 | lblDepositAmount.setText("Deposit Amount"); 111 | 112 | lblPassword.setText("Password"); 113 | 114 | javax.swing.GroupLayout paneInputsLayout = new javax.swing.GroupLayout(paneInputs); 115 | paneInputs.setLayout(paneInputsLayout); 116 | paneInputsLayout.setHorizontalGroup( 117 | paneInputsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 118 | .addGroup(paneInputsLayout.createSequentialGroup() 119 | .addContainerGap() 120 | .addGroup(paneInputsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 121 | .addComponent(txtDepositAmount) 122 | .addComponent(txtCurrentBalance) 123 | .addComponent(lblDepositAmount, javax.swing.GroupLayout.DEFAULT_SIZE, 408, Short.MAX_VALUE) 124 | .addComponent(lblCurrentBalance, javax.swing.GroupLayout.DEFAULT_SIZE, 408, Short.MAX_VALUE) 125 | .addComponent(txtPassword) 126 | .addComponent(lblPassword, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 127 | .addContainerGap()) 128 | ); 129 | paneInputsLayout.setVerticalGroup( 130 | paneInputsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 131 | .addGroup(paneInputsLayout.createSequentialGroup() 132 | .addGroup(paneInputsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 133 | .addGroup(paneInputsLayout.createSequentialGroup() 134 | .addGap(35, 35, 35) 135 | .addComponent(txtCurrentBalance, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) 136 | .addGroup(paneInputsLayout.createSequentialGroup() 137 | .addContainerGap() 138 | .addComponent(lblCurrentBalance))) 139 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 140 | .addComponent(lblDepositAmount) 141 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 142 | .addComponent(txtDepositAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) 143 | .addGap(15, 15, 15) 144 | .addComponent(lblPassword) 145 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 146 | .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) 147 | .addContainerGap(24, Short.MAX_VALUE)) 148 | ); 149 | 150 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 151 | getContentPane().setLayout(layout); 152 | layout.setHorizontalGroup( 153 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 154 | .addGroup(layout.createSequentialGroup() 155 | .addContainerGap() 156 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 157 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 158 | .addGap(0, 0, Short.MAX_VALUE) 159 | .addComponent(btnDeposit) 160 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 161 | .addComponent(btnClose)) 162 | .addComponent(paneInputs, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 163 | .addContainerGap()) 164 | ); 165 | layout.setVerticalGroup( 166 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 167 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 168 | .addContainerGap() 169 | .addComponent(paneInputs, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 170 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 171 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 172 | .addComponent(btnClose) 173 | .addComponent(btnDeposit)) 174 | .addGap(12, 12, 12)) 175 | ); 176 | 177 | setBounds(300, 100, 469, 302); 178 | }// //GEN-END:initComponents 179 | 180 | private void btnDepositActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnDepositActionPerformed 181 | {//GEN-HEADEREND:event_btnDepositActionPerformed 182 | deposit(); 183 | }//GEN-LAST:event_btnDepositActionPerformed 184 | 185 | private void btnCloseActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnCloseActionPerformed 186 | {//GEN-HEADEREND:event_btnCloseActionPerformed 187 | dispose(); 188 | }//GEN-LAST:event_btnCloseActionPerformed 189 | 190 | private void clearForm() 191 | { 192 | txtDepositAmount.setText(""); 193 | txtPassword.setText(""); 194 | defineCurrentBalance(); 195 | } 196 | 197 | private void defineCurrentBalance() 198 | { 199 | setCursor(ViewUtility.WAIT_CURSOR); 200 | txtCurrentBalance.setText(operationRepository.currentBalance(accountNumber).orElse(0.0).toString()); 201 | setCursor(ViewUtility.DEFAULT_CURSOR); 202 | } 203 | 204 | private void deposit() 205 | { 206 | try { 207 | double depositAmount = Double.parseDouble(txtDepositAmount.getText()); 208 | String password = new String(txtPassword.getPassword()); 209 | 210 | if (depositAmount <= 0 || password.isEmpty()) { 211 | MessageUtility.warning(customerMainForm, "There are invalid fields"); 212 | return; 213 | } 214 | 215 | Optional optional = customerRepository.findByAccountNumberAndPassword(accountNumber, password); 216 | 217 | if (!optional.isPresent()) { 218 | MessageUtility.warning(customerMainForm, "Could not peform operation invalid password!"); 219 | return; 220 | } 221 | 222 | operationRepository.deposit(accountNumber, depositAmount); 223 | 224 | MessageUtility.info(customerMainForm, "Money deposited successfully!"); 225 | clearForm(); 226 | } catch (NumberFormatException e) { 227 | MessageUtility.error(customerMainForm, "Invalid deposit vaule", e); 228 | } 229 | } 230 | 231 | // Variables declaration - do not modify//GEN-BEGIN:variables 232 | private javax.swing.JButton btnClose; 233 | private javax.swing.JButton btnDeposit; 234 | private javax.swing.JLabel lblCurrentBalance; 235 | private javax.swing.JLabel lblDepositAmount; 236 | private javax.swing.JLabel lblPassword; 237 | private javax.swing.JPanel paneInputs; 238 | private javax.swing.JTextField txtCurrentBalance; 239 | private javax.swing.JTextField txtDepositAmount; 240 | private javax.swing.JPasswordField txtPassword; 241 | // End of variables declaration//GEN-END:variables 242 | } 243 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/views/customers/NewWithdrawFrame.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 |
168 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/views/customers/NewWithdrawFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2019 Derick Felix 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.derickfelix.bankapplication.views.customers; 25 | 26 | import com.github.derickfelix.bankapplication.models.Customer; 27 | import com.github.derickfelix.bankapplication.repositories.CustomerRepository; 28 | import com.github.derickfelix.bankapplication.repositories.OperationRepository; 29 | import com.github.derickfelix.bankapplication.repositories.impl.RepositoryFactory; 30 | import com.github.derickfelix.bankapplication.repositories.WithdrawRepository; 31 | 32 | import com.github.derickfelix.bankapplication.repositories.impl.CustomerRepositoryImpl; 33 | import com.github.derickfelix.bankapplication.repositories.impl.OperationRepositoryImpl; 34 | 35 | import com.github.derickfelix.bankapplication.repositories.impl.WithdrawRepositoryImpl; 36 | import com.github.derickfelix.bankapplication.securities.AuthSecurity; 37 | import com.github.derickfelix.bankapplication.utilities.MessageUtility; 38 | import com.github.derickfelix.bankapplication.utilities.ViewUtility; 39 | import java.util.Optional; 40 | 41 | public class NewWithdrawFrame extends javax.swing.JInternalFrame { 42 | 43 | private final CustomerMainForm customerMainForm; 44 | private final CustomerRepository customerRepository; 45 | private final OperationRepository operationRepository; 46 | private final WithdrawRepository withdrawRepository; 47 | private final String accountNumber; 48 | 49 | public NewWithdrawFrame(CustomerMainForm customerMainForm) 50 | { 51 | this.customerMainForm = customerMainForm; 52 | this.customerRepository = (CustomerRepository) new RepositoryFactory().getInstance("customer"); 53 | this.operationRepository = OperationRepositoryImpl.getOPInstance(); 54 | this.withdrawRepository = new WithdrawRepositoryImpl(); 55 | this.accountNumber = AuthSecurity.getCustomer().getAccountNumber(); 56 | 57 | initComponents(); 58 | customSettings(); 59 | } 60 | 61 | private void customSettings() 62 | { 63 | defineCurrentBalance(); 64 | } 65 | 66 | /** 67 | * This method is called from within the constructor to initialize the form. 68 | * WARNING: Do NOT modify this code. The content of this method is always 69 | * regenerated by the Form Editor. 70 | */ 71 | @SuppressWarnings("unchecked") 72 | // //GEN-BEGIN:initComponents 73 | private void initComponents() 74 | { 75 | 76 | btnWithdraw = new javax.swing.JButton(); 77 | btnClose = new javax.swing.JButton(); 78 | paneInputs = new javax.swing.JPanel(); 79 | lblCurrentBalance = new javax.swing.JLabel(); 80 | txtCurrentBalance = new javax.swing.JTextField(); 81 | txtWithdrawAmount = new javax.swing.JTextField(); 82 | lblWithdrawAmount = new javax.swing.JLabel(); 83 | txtPassword = new javax.swing.JPasswordField(); 84 | lblPassword = new javax.swing.JLabel(); 85 | 86 | setClosable(true); 87 | setMaximizable(true); 88 | setResizable(true); 89 | setTitle("Zwei Bank Application - Withdraw Operation"); 90 | 91 | btnWithdraw.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/save.png"))); // NOI18N 92 | btnWithdraw.setText("Withdraw"); 93 | btnWithdraw.addActionListener(new java.awt.event.ActionListener() 94 | { 95 | public void actionPerformed(java.awt.event.ActionEvent evt) 96 | { 97 | btnWithdrawActionPerformed(evt); 98 | } 99 | }); 100 | 101 | btnClose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/close.png"))); // NOI18N 102 | btnClose.setText("Close"); 103 | btnClose.addActionListener(new java.awt.event.ActionListener() 104 | { 105 | public void actionPerformed(java.awt.event.ActionEvent evt) 106 | { 107 | btnCloseActionPerformed(evt); 108 | } 109 | }); 110 | 111 | paneInputs.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 102))); 112 | 113 | lblCurrentBalance.setText("Your Balance"); 114 | 115 | txtCurrentBalance.setEnabled(false); 116 | 117 | lblWithdrawAmount.setText("Withdraw Amount"); 118 | 119 | lblPassword.setText("Password"); 120 | 121 | javax.swing.GroupLayout paneInputsLayout = new javax.swing.GroupLayout(paneInputs); 122 | paneInputs.setLayout(paneInputsLayout); 123 | paneInputsLayout.setHorizontalGroup( 124 | paneInputsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 125 | .addGroup(paneInputsLayout.createSequentialGroup() 126 | .addContainerGap() 127 | .addGroup(paneInputsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 128 | .addComponent(txtWithdrawAmount) 129 | .addComponent(txtCurrentBalance) 130 | .addComponent(lblWithdrawAmount, javax.swing.GroupLayout.DEFAULT_SIZE, 408, Short.MAX_VALUE) 131 | .addComponent(lblCurrentBalance, javax.swing.GroupLayout.DEFAULT_SIZE, 408, Short.MAX_VALUE) 132 | .addComponent(txtPassword) 133 | .addComponent(lblPassword, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 134 | .addContainerGap()) 135 | ); 136 | paneInputsLayout.setVerticalGroup( 137 | paneInputsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 138 | .addGroup(paneInputsLayout.createSequentialGroup() 139 | .addGroup(paneInputsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 140 | .addGroup(paneInputsLayout.createSequentialGroup() 141 | .addGap(35, 35, 35) 142 | .addComponent(txtCurrentBalance, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) 143 | .addGroup(paneInputsLayout.createSequentialGroup() 144 | .addContainerGap() 145 | .addComponent(lblCurrentBalance))) 146 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 147 | .addComponent(lblWithdrawAmount) 148 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 149 | .addComponent(txtWithdrawAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) 150 | .addGap(15, 15, 15) 151 | .addComponent(lblPassword) 152 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 153 | .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) 154 | .addContainerGap(24, Short.MAX_VALUE)) 155 | ); 156 | 157 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 158 | getContentPane().setLayout(layout); 159 | layout.setHorizontalGroup( 160 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 161 | .addGroup(layout.createSequentialGroup() 162 | .addContainerGap() 163 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 164 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 165 | .addGap(0, 0, Short.MAX_VALUE) 166 | .addComponent(btnWithdraw) 167 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 168 | .addComponent(btnClose)) 169 | .addComponent(paneInputs, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 170 | .addContainerGap()) 171 | ); 172 | layout.setVerticalGroup( 173 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 174 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 175 | .addContainerGap() 176 | .addComponent(paneInputs, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 177 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 178 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 179 | .addComponent(btnClose) 180 | .addComponent(btnWithdraw)) 181 | .addGap(12, 12, 12)) 182 | ); 183 | 184 | setBounds(300, 100, 469, 302); 185 | }// //GEN-END:initComponents 186 | 187 | private void btnWithdrawActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnWithdrawActionPerformed 188 | {//GEN-HEADEREND:event_btnWithdrawActionPerformed 189 | withdraw(); 190 | }//GEN-LAST:event_btnWithdrawActionPerformed 191 | 192 | private void btnCloseActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnCloseActionPerformed 193 | {//GEN-HEADEREND:event_btnCloseActionPerformed 194 | dispose(); 195 | }//GEN-LAST:event_btnCloseActionPerformed 196 | 197 | private void clearForm() 198 | { 199 | txtWithdrawAmount.setText(""); 200 | txtPassword.setText(""); 201 | defineCurrentBalance(); 202 | } 203 | 204 | private void defineCurrentBalance() 205 | { 206 | setCursor(ViewUtility.WAIT_CURSOR); 207 | txtCurrentBalance.setText(operationRepository.currentBalance(accountNumber).orElse(0.0).toString()); 208 | setCursor(ViewUtility.DEFAULT_CURSOR); 209 | } 210 | 211 | private void withdraw() 212 | { 213 | try { 214 | double withdrawAmount = Double.parseDouble(txtWithdrawAmount.getText()); 215 | String password = new String(txtPassword.getPassword()); 216 | 217 | if (withdrawAmount <= 0 || password.isEmpty()) { 218 | MessageUtility.warning(customerMainForm, "There are invalid fields"); 219 | return; 220 | } 221 | 222 | double futureBalance = Double.parseDouble(txtCurrentBalance.getText()) - withdrawAmount; 223 | 224 | if (futureBalance < 0) { 225 | MessageUtility.warning(customerMainForm, "Could not perform this operation, not enough money!"); 226 | return; 227 | } 228 | 229 | Optional optional = customerRepository.findByAccountNumberAndPassword(accountNumber, password); 230 | 231 | if (!optional.isPresent()) { 232 | MessageUtility.warning(customerMainForm, "Could not peform this operation, invalid password!"); 233 | return; 234 | } 235 | 236 | withdrawRepository.withdraw(accountNumber, withdrawAmount); 237 | 238 | MessageUtility.info(customerMainForm, "Money withdrawn successfully!"); 239 | clearForm(); 240 | } catch (NumberFormatException e) { 241 | MessageUtility.error(customerMainForm, "Invalid withdraw value", e); 242 | } 243 | } 244 | 245 | // Variables declaration - do not modify//GEN-BEGIN:variables 246 | private javax.swing.JButton btnClose; 247 | private javax.swing.JButton btnWithdraw; 248 | private javax.swing.JLabel lblCurrentBalance; 249 | private javax.swing.JLabel lblPassword; 250 | private javax.swing.JLabel lblWithdrawAmount; 251 | private javax.swing.JPanel paneInputs; 252 | private javax.swing.JTextField txtCurrentBalance; 253 | private javax.swing.JPasswordField txtPassword; 254 | private javax.swing.JTextField txtWithdrawAmount; 255 | // End of variables declaration//GEN-END:variables 256 | } 257 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/views/dialogs/ExceptionDialog.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/views/dialogs/ExceptionDialog.java: -------------------------------------------------------------------------------- 1 | /* * Copyright (c) 2018 VR Fortaleza. All rights reserved. * */ 2 | package com.github.derickfelix.bankapplication.views.dialogs; 3 | 4 | public class ExceptionDialog extends javax.swing.JDialog { 5 | 6 | private final Exception exception; 7 | 8 | /** 9 | * Creates new form ExceptionDialog 10 | * 11 | * @param parent the parent of this dialog 12 | * @param modal if true the parent frame cannot be accessed until this 13 | * dialog is closed 14 | * @param exception the exception which this dialog is describing 15 | */ 16 | public ExceptionDialog(java.awt.Frame parent, boolean modal, Exception exception) 17 | { 18 | super(parent, modal); 19 | this.exception = exception; 20 | 21 | initComponents(); 22 | customComponents(); 23 | } 24 | 25 | private void customComponents() 26 | { 27 | StringBuilder builder = new StringBuilder(); 28 | builder.append(exception.getMessage()).append("\n\n"); 29 | StackTraceElement[] stes = exception.getStackTrace(); 30 | for (StackTraceElement ste : stes) { 31 | builder.append(ste).append("\n"); 32 | } 33 | txtMessage.setText(builder.toString()); 34 | } 35 | 36 | /** 37 | * This method is called from within the constructor to initialize the form. 38 | * WARNING: Do NOT modify this code. The content of this method is always 39 | * regenerated by the Form Editor. 40 | */ 41 | @SuppressWarnings("unchecked") 42 | // //GEN-BEGIN:initComponents 43 | private void initComponents() 44 | { 45 | 46 | scrollPane = new javax.swing.JScrollPane(); 47 | txtMessage = new javax.swing.JTextArea(); 48 | btnClose = new javax.swing.JButton(); 49 | 50 | setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 51 | setTitle("Detalhes"); 52 | 53 | txtMessage.setEditable(false); 54 | txtMessage.setBackground(new java.awt.Color(238, 238, 238)); 55 | txtMessage.setColumns(20); 56 | txtMessage.setFont(new java.awt.Font("Noto Sans", 0, 11)); // NOI18N 57 | txtMessage.setRows(5); 58 | scrollPane.setViewportView(txtMessage); 59 | 60 | btnClose.setFont(new java.awt.Font("Noto Sans", 0, 11)); // NOI18N 61 | btnClose.setText("Sair"); 62 | btnClose.addActionListener(new java.awt.event.ActionListener() 63 | { 64 | public void actionPerformed(java.awt.event.ActionEvent evt) 65 | { 66 | btnCloseActionPerformed(evt); 67 | } 68 | }); 69 | 70 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 71 | getContentPane().setLayout(layout); 72 | layout.setHorizontalGroup( 73 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 74 | .addGroup(layout.createSequentialGroup() 75 | .addContainerGap() 76 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 77 | .addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 551, Short.MAX_VALUE) 78 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 79 | .addGap(0, 0, Short.MAX_VALUE) 80 | .addComponent(btnClose, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))) 81 | .addContainerGap()) 82 | ); 83 | layout.setVerticalGroup( 84 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 85 | .addGroup(layout.createSequentialGroup() 86 | .addContainerGap() 87 | .addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE) 88 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 89 | .addComponent(btnClose) 90 | .addContainerGap()) 91 | ); 92 | 93 | pack(); 94 | setLocationRelativeTo(null); 95 | }// //GEN-END:initComponents 96 | 97 | private void btnCloseActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnCloseActionPerformed 98 | {//GEN-HEADEREND:event_btnCloseActionPerformed 99 | dispose(); 100 | }//GEN-LAST:event_btnCloseActionPerformed 101 | 102 | // Variables declaration - do not modify//GEN-BEGIN:variables 103 | private javax.swing.JButton btnClose; 104 | private javax.swing.JScrollPane scrollPane; 105 | private javax.swing.JTextArea txtMessage; 106 | // End of variables declaration//GEN-END:variables 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/views/dialogs/ExportDialog.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 |
161 |
162 | 163 | 164 | 165 | 166 | 167 | <Editor/> 168 | <Renderer/> 169 | </Column> 170 | <Column maxWidth="250" minWidth="200" prefWidth="200" resizable="true"> 171 | <Title/> 172 | <Editor/> 173 | <Renderer/> 174 | </Column> 175 | </TableColumnModel> 176 | </Property> 177 | <Property name="gridColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> 178 | <Color blue="ff" green="ff" red="ff" type="rgb"/> 179 | </Property> 180 | <Property name="selectionModel" type="javax.swing.ListSelectionModel" editor="org.netbeans.modules.form.editors2.JTableSelectionModelEditor"> 181 | <JTableSelectionModel selectionMode="0"/> 182 | </Property> 183 | <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> 184 | <TableHeader reorderingAllowed="false" resizingAllowed="true"/> 185 | </Property> 186 | </Properties> 187 | <Events> 188 | <EventHandler event="mouseReleased" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="mainTableMouseReleased"/> 189 | <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="mainTableMouseClicked"/> 190 | </Events> 191 | </Component> 192 | </SubComponents> 193 | </Container> 194 | <Component class="javax.swing.JCheckBox" name="cbSelectAll"> 195 | <Properties> 196 | <Property name="text" type="java.lang.String" value="Select All"/> 197 | </Properties> 198 | <Events> 199 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbSelectAllActionPerformed"/> 200 | </Events> 201 | </Component> 202 | </SubComponents> 203 | </Form> 204 | -------------------------------------------------------------------------------- /src/main/java/com/github/derickfelix/bankapplication/views/users/UsersFrameForm.form: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8" ?> 2 | 3 | <Form version="1.6" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo"> 4 | <Properties> 5 | <Property name="closable" type="boolean" value="true"/> 6 | <Property name="maximizable" type="boolean" value="true"/> 7 | <Property name="resizable" type="boolean" value="true"/> 8 | <Property name="title" type="java.lang.String" value="Zwei Bank Application - User Form"/> 9 | </Properties> 10 | <SyntheticProperties> 11 | <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,30,0,0,2,116"/> 12 | <SyntheticProperty name="formPosition" type="java.awt.Point" value="-84,-19,0,5,115,114,0,14,106,97,118,97,46,97,119,116,46,80,111,105,110,116,-74,-60,-118,114,52,126,-56,38,2,0,2,73,0,1,120,73,0,1,121,120,112,0,0,1,44,0,0,0,100"/> 13 | <SyntheticProperty name="formSizePolicy" type="int" value="0"/> 14 | <SyntheticProperty name="generatePosition" type="boolean" value="true"/> 15 | <SyntheticProperty name="generateSize" type="boolean" value="true"/> 16 | </SyntheticProperties> 17 | <AuxValues> 18 | <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> 19 | <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> 20 | <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> 21 | <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> 22 | <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> 23 | <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> 24 | <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> 25 | <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> 26 | <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> 27 | </AuxValues> 28 | 29 | <Layout> 30 | <DimensionLayout dim="0"> 31 | <Group type="103" groupAlignment="0" attributes="0"> 32 | <Group type="102" attributes="0"> 33 | <EmptySpace max="-2" attributes="0"/> 34 | <Group type="103" groupAlignment="0" attributes="0"> 35 | <Component id="paneInputs" max="32767" attributes="0"/> 36 | <Component id="toolbar" alignment="1" max="32767" attributes="0"/> 37 | <Group type="102" alignment="1" attributes="0"> 38 | <EmptySpace min="0" pref="0" max="32767" attributes="0"/> 39 | <Component id="btnSave" min="-2" max="-2" attributes="0"/> 40 | <EmptySpace max="-2" attributes="0"/> 41 | <Component id="btnClose" min="-2" max="-2" attributes="0"/> 42 | </Group> 43 | </Group> 44 | <EmptySpace max="-2" attributes="0"/> 45 | </Group> 46 | </Group> 47 | </DimensionLayout> 48 | <DimensionLayout dim="1"> 49 | <Group type="103" groupAlignment="0" attributes="0"> 50 | <Group type="102" alignment="1" attributes="0"> 51 | <Component id="toolbar" min="-2" pref="25" max="-2" attributes="0"/> 52 | <EmptySpace max="-2" attributes="0"/> 53 | <Component id="paneInputs" max="32767" attributes="0"/> 54 | <EmptySpace max="-2" attributes="0"/> 55 | <Group type="103" groupAlignment="3" attributes="0"> 56 | <Component id="btnClose" alignment="3" min="-2" max="-2" attributes="0"/> 57 | <Component id="btnSave" alignment="3" min="-2" max="-2" attributes="0"/> 58 | </Group> 59 | <EmptySpace min="-2" pref="12" max="-2" attributes="0"/> 60 | </Group> 61 | </Group> 62 | </DimensionLayout> 63 | </Layout> 64 | <SubComponents> 65 | <Container class="javax.swing.JToolBar" name="toolbar"> 66 | <Properties> 67 | <Property name="floatable" type="boolean" value="false"/> 68 | <Property name="rollover" type="boolean" value="true"/> 69 | </Properties> 70 | 71 | <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/> 72 | <SubComponents> 73 | <Component class="javax.swing.JButton" name="tbtnAdd"> 74 | <Properties> 75 | <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> 76 | <Image iconType="3" name="/images/add.png"/> 77 | </Property> 78 | <Property name="toolTipText" type="java.lang.String" value="Add New"/> 79 | <Property name="focusable" type="boolean" value="false"/> 80 | <Property name="horizontalTextPosition" type="int" value="0"/> 81 | <Property name="verticalTextPosition" type="int" value="3"/> 82 | </Properties> 83 | <Events> 84 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="tbtnAddActionPerformed"/> 85 | </Events> 86 | </Component> 87 | <Component class="javax.swing.JButton" name="tbtnSave"> 88 | <Properties> 89 | <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> 90 | <Image iconType="3" name="/images/save.png"/> 91 | </Property> 92 | <Property name="toolTipText" type="java.lang.String" value="Search"/> 93 | <Property name="focusable" type="boolean" value="false"/> 94 | <Property name="horizontalTextPosition" type="int" value="0"/> 95 | <Property name="verticalTextPosition" type="int" value="3"/> 96 | </Properties> 97 | <Events> 98 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="tbtnSaveActionPerformed"/> 99 | </Events> 100 | </Component> 101 | </SubComponents> 102 | </Container> 103 | <Component class="javax.swing.JButton" name="btnSave"> 104 | <Properties> 105 | <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> 106 | <Image iconType="3" name="/images/save.png"/> 107 | </Property> 108 | <Property name="text" type="java.lang.String" value="Save"/> 109 | </Properties> 110 | <Events> 111 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSaveActionPerformed"/> 112 | </Events> 113 | </Component> 114 | <Component class="javax.swing.JButton" name="btnClose"> 115 | <Properties> 116 | <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> 117 | <Image iconType="3" name="/images/close.png"/> 118 | </Property> 119 | <Property name="text" type="java.lang.String" value="Close"/> 120 | </Properties> 121 | <Events> 122 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCloseActionPerformed"/> 123 | </Events> 124 | </Component> 125 | <Container class="javax.swing.JPanel" name="paneInputs"> 126 | <Properties> 127 | <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> 128 | <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> 129 | <LineBorder> 130 | <Color PropertyName="color" blue="66" green="66" red="0" type="rgb"/> 131 | </LineBorder> 132 | </Border> 133 | </Property> 134 | </Properties> 135 | 136 | <Layout> 137 | <DimensionLayout dim="0"> 138 | <Group type="103" groupAlignment="0" attributes="0"> 139 | <Group type="102" attributes="0"> 140 | <EmptySpace min="-2" max="-2" attributes="0"/> 141 | <Group type="103" groupAlignment="0" attributes="0"> 142 | <Component id="lblName" max="32767" attributes="0"/> 143 | <Component id="lblRole" alignment="0" min="-2" pref="240" max="-2" attributes="0"/> 144 | <Component id="txtName" alignment="0" max="32767" attributes="0"/> 145 | <Component id="cmbRole" pref="270" max="32767" attributes="0"/> 146 | </Group> 147 | <EmptySpace min="-2" max="-2" attributes="0"/> 148 | <Group type="103" groupAlignment="0" attributes="0"> 149 | <Component id="txtUsername" max="32767" attributes="0"/> 150 | <Component id="txtPassword" max="32767" attributes="0"/> 151 | <Component id="lblPassword" max="32767" attributes="0"/> 152 | <Component id="lblUsername" pref="286" max="32767" attributes="0"/> 153 | </Group> 154 | <EmptySpace min="-2" max="-2" attributes="0"/> 155 | </Group> 156 | </Group> 157 | </DimensionLayout> 158 | <DimensionLayout dim="1"> 159 | <Group type="103" groupAlignment="0" attributes="0"> 160 | <Group type="102" alignment="0" attributes="0"> 161 | <EmptySpace min="-2" pref="6" max="-2" attributes="0"/> 162 | <Group type="103" groupAlignment="0" attributes="0"> 163 | <Group type="102" attributes="0"> 164 | <EmptySpace min="-2" pref="23" max="-2" attributes="0"/> 165 | <Group type="103" groupAlignment="3" attributes="0"> 166 | <Component id="txtName" alignment="3" min="-2" pref="26" max="-2" attributes="0"/> 167 | <Component id="txtUsername" alignment="3" min="-2" pref="26" max="-2" attributes="0"/> 168 | </Group> 169 | </Group> 170 | <Group type="103" groupAlignment="3" attributes="0"> 171 | <Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/> 172 | <Component id="lblUsername" alignment="3" min="-2" max="-2" attributes="0"/> 173 | </Group> 174 | </Group> 175 | <Group type="103" groupAlignment="0" attributes="0"> 176 | <Group type="102" alignment="0" attributes="0"> 177 | <EmptySpace min="-2" pref="20" max="-2" attributes="0"/> 178 | <Group type="103" groupAlignment="3" attributes="0"> 179 | <Component id="cmbRole" alignment="3" min="-2" max="-2" attributes="0"/> 180 | <Component id="txtPassword" alignment="3" min="-2" pref="26" max="-2" attributes="0"/> 181 | </Group> 182 | </Group> 183 | <Group type="103" groupAlignment="3" attributes="0"> 184 | <Component id="lblRole" alignment="3" min="-2" max="-2" attributes="0"/> 185 | <Component id="lblPassword" alignment="3" min="-2" max="-2" attributes="0"/> 186 | </Group> 187 | </Group> 188 | <EmptySpace pref="72" max="32767" attributes="0"/> 189 | </Group> 190 | </Group> 191 | </DimensionLayout> 192 | </Layout> 193 | <SubComponents> 194 | <Component class="javax.swing.JLabel" name="lblName"> 195 | <Properties> 196 | <Property name="text" type="java.lang.String" value="Name"/> 197 | </Properties> 198 | </Component> 199 | <Component class="javax.swing.JTextField" name="txtName"> 200 | </Component> 201 | <Component class="javax.swing.JLabel" name="lblUsername"> 202 | <Properties> 203 | <Property name="text" type="java.lang.String" value="Username"/> 204 | </Properties> 205 | </Component> 206 | <Component class="javax.swing.JTextField" name="txtUsername"> 207 | </Component> 208 | <Component class="javax.swing.JLabel" name="lblPassword"> 209 | <Properties> 210 | <Property name="text" type="java.lang.String" value="Password"/> 211 | </Properties> 212 | </Component> 213 | <Component class="javax.swing.JPasswordField" name="txtPassword"> 214 | </Component> 215 | <Component class="javax.swing.JComboBox" name="cmbRole"> 216 | <Properties> 217 | <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> 218 | <StringArray count="2"> 219 | <StringItem index="0" value="Standard"/> 220 | <StringItem index="1" value="Administrator"/> 221 | </StringArray> 222 | </Property> 223 | </Properties> 224 | <AuxValues> 225 | <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> 226 | </AuxValues> 227 | </Component> 228 | <Component class="javax.swing.JLabel" name="lblRole"> 229 | <Properties> 230 | <Property name="text" type="java.lang.String" value="Role"/> 231 | </Properties> 232 | </Component> 233 | </SubComponents> 234 | </Container> 235 | </SubComponents> 236 | </Form> 237 | -------------------------------------------------------------------------------- /src/main/resources/images/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thederickff/BankApplication/8aad797f5c6c80e42afb9a908e94e89410f124b5/src/main/resources/images/add.png -------------------------------------------------------------------------------- /src/main/resources/images/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thederickff/BankApplication/8aad797f5c6c80e42afb9a908e94e89410f124b5/src/main/resources/images/close.png -------------------------------------------------------------------------------- /src/main/resources/images/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thederickff/BankApplication/8aad797f5c6c80e42afb9a908e94e89410f124b5/src/main/resources/images/delete.png -------------------------------------------------------------------------------- /src/main/resources/images/demo.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thederickff/BankApplication/8aad797f5c6c80e42afb9a908e94e89410f124b5/src/main/resources/images/demo.jpeg -------------------------------------------------------------------------------- /src/main/resources/images/desktop-background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thederickff/BankApplication/8aad797f5c6c80e42afb9a908e94e89410f124b5/src/main/resources/images/desktop-background.png -------------------------------------------------------------------------------- /src/main/resources/images/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thederickff/BankApplication/8aad797f5c6c80e42afb9a908e94e89410f124b5/src/main/resources/images/edit.png -------------------------------------------------------------------------------- /src/main/resources/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thederickff/BankApplication/8aad797f5c6c80e42afb9a908e94e89410f124b5/src/main/resources/images/logo.png -------------------------------------------------------------------------------- /src/main/resources/images/logo.svg: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> 2 | <!-- Created with Inkscape (http://www.inkscape.org/) --> 3 | 4 | <svg 5 | xmlns:dc="http://purl.org/dc/elements/1.1/" 6 | xmlns:cc="http://creativecommons.org/ns#" 7 | xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 8 | xmlns:svg="http://www.w3.org/2000/svg" 9 | xmlns="http://www.w3.org/2000/svg" 10 | xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" 11 | xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" 12 | width="171.96855mm" 13 | height="111.39397mm" 14 | viewBox="0 0 171.96855 111.39398" 15 | version="1.1" 16 | id="svg8" 17 | inkscape:version="0.92.1 r15371" 18 | sodipodi:docname="logo.svg"> 19 | <defs 20 | id="defs2" /> 21 | <sodipodi:namedview 22 | id="base" 23 | pagecolor="#ffffff" 24 | bordercolor="#666666" 25 | borderopacity="1.0" 26 | inkscape:pageopacity="0.0" 27 | inkscape:pageshadow="2" 28 | inkscape:zoom="0.5" 29 | inkscape:cx="-78.861056" 30 | inkscape:cy="253.02258" 31 | inkscape:document-units="px" 32 | inkscape:current-layer="layer1" 33 | showgrid="false" 34 | showborder="false" 35 | inkscape:window-width="1366" 36 | inkscape:window-height="728" 37 | inkscape:window-x="0" 38 | inkscape:window-y="0" 39 | inkscape:window-maximized="1" /> 40 | <metadata 41 | id="metadata5"> 42 | <rdf:RDF> 43 | <cc:Work 44 | rdf:about=""> 45 | <dc:format>image/svg+xml</dc:format> 46 | <dc:type 47 | rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> 48 | <dc:title></dc:title> 49 | </cc:Work> 50 | </rdf:RDF> 51 | </metadata> 52 | <g 53 | inkscape:label="Ebene 1" 54 | inkscape:groupmode="layer" 55 | id="layer1" 56 | transform="translate(11.206197,-66.11857)"> 57 | <path 58 | style="opacity:1;fill:#000055;fill-opacity:1;stroke:#ffffff;stroke-width:2.11640215;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none" 59 | d="m 144.28236,140.73305 c 2.83089,31.78492 33.06686,34.25424 0.29566,34.25424 -34.33987,0 -63.188758,10.65393 -63.188758,-25.65786 0,-2.91395 0.18126,-5.78264 0.528773,-8.59638 z" 60 | id="path4720" 61 | inkscape:connector-curvature="0" /> 62 | <path 63 | style="opacity:1;fill:#000055;fill-opacity:1;stroke:#ffffff;stroke-width:2.11640215;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none" 64 | d="m 72.103105,140.73305 c 0.367468,2.81374 0.559656,5.68243 0.559656,8.59638 2e-6,36.31179 -30.505839,25.65786 -66.8176249,25.65786 -34.6530661,0 -2.680814,-2.46932 0.312642,-34.25424 z" 65 | id="path4718" 66 | inkscape:connector-curvature="0" /> 67 | <path 68 | style="opacity:1;fill:#000055;fill-opacity:1;stroke:#ffffff;stroke-width:2.11640215;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none" 69 | d="m 140.68587,67.176771 c 30.18737,0 10.55487,11.110687 3.07268,35.720769 H 82.180907 C 93.089467,81.68665 115.19257,67.176771 140.68587,67.176771 Z" 70 | id="path4716" 71 | inkscape:connector-curvature="0" /> 72 | <path 73 | style="opacity:1;fill:#000055;fill-opacity:1;stroke:#ffffff;stroke-width:2.11640215;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none" 74 | d="m 13.365987,67.176771 c 25.493162,0 47.59646,14.509871 58.504956,35.720769 H 10.293822 c -7.4821519,-24.6101 -27.1151,-35.720769 3.072165,-35.720769 z" 75 | id="path4577" 76 | inkscape:connector-curvature="0" /> 77 | <text 78 | xml:space="preserve" 79 | style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:25.20459557px;line-height:2.25;font-family:Kirsty;-inkscape-font-specification:'Kirsty, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;opacity:1;fill:#000055;fill-opacity:1;stroke:#ffffff;stroke-width:1.34937501;stroke-miterlimit:4;stroke-dasharray:none" 80 | x="10.689514" 81 | y="131.27039" 82 | id="text4589"><tspan 83 | sodipodi:role="line" 84 | x="10.689514" 85 | y="131.27039" 86 | style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:25.20459557px;line-height:2.25;font-family:Kirsty;-inkscape-font-specification:'Kirsty, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000055;stroke:#ffffff;stroke-width:1.34937501;stroke-miterlimit:4;stroke-dasharray:none" 87 | id="tspan4591">ZW<tspan 88 | style="line-height:22.85000038;fill:#000055;stroke:#ffffff;stroke-width:1.34937501" 89 | id="tspan4654">EI B</tspan>ANK</tspan></text> 90 | </g> 91 | </svg> 92 | -------------------------------------------------------------------------------- /src/main/resources/images/print.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thederickff/BankApplication/8aad797f5c6c80e42afb9a908e94e89410f124b5/src/main/resources/images/print.png -------------------------------------------------------------------------------- /src/main/resources/images/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thederickff/BankApplication/8aad797f5c6c80e42afb9a908e94e89410f124b5/src/main/resources/images/save.png -------------------------------------------------------------------------------- /src/main/resources/images/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thederickff/BankApplication/8aad797f5c6c80e42afb9a908e94e89410f124b5/src/main/resources/images/search.png --------------------------------------------------------------------------------