From 966a9b2ff5d9fae89a89cc7d3b2a10cee003392a Mon Sep 17 00:00:00 2001 From: gargh Date: Fri, 10 Apr 2020 12:09:40 -0700 Subject: [PATCH] Final Commit usingHibernate for DB. --- AccountHibernate/.classpath | 49 ++++++ AccountHibernate/.project | 23 +++ .../org.eclipse.core.resources.prefs | 4 + .../.settings/org.eclipse.jdt.core.prefs | 8 + .../.settings/org.eclipse.m2e.core.prefs | 4 + AccountHibernate/pom.xml | 88 ++++++++++ .../AccountHibernate/AccountResource.java | 29 ++++ .../AccountHibernate/dao/PersonalInfoDAO.java | 17 ++ .../dao/PersonalInfoDAOImpl.java | 103 ++++++++++++ .../interfaces/ErrorMsgCodes.java | 43 +++++ .../AccountHibernate/util/HibernateUtil.java | 37 +++++ .../validation/AccountValidation.java | 150 ++++++++++++++++++ .../AccountValidationException.java | 32 ++++ .../AccountHibernate/vo/PersonalInfo.java | 69 ++++++++ .../src/main/java/hibernate.cfg.xml | 13 ++ .../rest/AccountHibernate/AppTest.java | 20 +++ .../target/classes/META-INF/MANIFEST.MF | 5 + .../AccountHibernate/pom.properties | 7 + .../AccountHibernate/pom.xml | 88 ++++++++++ .../AccountHibernate/AccountResource.class | Bin 0 -> 1573 bytes .../dao/PersonalInfoDAO.class | Bin 0 -> 586 bytes .../dao/PersonalInfoDAOImpl.class | Bin 0 -> 4411 bytes .../interfaces/ErrorMsgCodes.class | Bin 0 -> 1910 bytes .../AccountHibernate/util/HibernateUtil.class | Bin 0 -> 1602 bytes .../validation/AccountValidation.class | Bin 0 -> 3976 bytes .../AccountValidationException.class | Bin 0 -> 761 bytes .../AccountHibernate/vo/PersonalInfo.class | Bin 0 -> 2213 bytes .../target/classes/hibernate.cfg.xml | 13 ++ .../rest/AccountHibernate/AppTest.class | Bin 0 -> 517 bytes 29 files changed, 802 insertions(+) create mode 100644 AccountHibernate/.classpath create mode 100644 AccountHibernate/.project create mode 100644 AccountHibernate/.settings/org.eclipse.core.resources.prefs create mode 100644 AccountHibernate/.settings/org.eclipse.jdt.core.prefs create mode 100644 AccountHibernate/.settings/org.eclipse.m2e.core.prefs create mode 100644 AccountHibernate/pom.xml create mode 100644 AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/AccountResource.java create mode 100644 AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/dao/PersonalInfoDAO.java create mode 100644 AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/dao/PersonalInfoDAOImpl.java create mode 100644 AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/interfaces/ErrorMsgCodes.java create mode 100644 AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/util/HibernateUtil.java create mode 100644 AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/validation/AccountValidation.java create mode 100644 AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/validation/AccountValidationException.java create mode 100644 AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/vo/PersonalInfo.java create mode 100644 AccountHibernate/src/main/java/hibernate.cfg.xml create mode 100644 AccountHibernate/src/test/java/com/hibernate/rest/AccountHibernate/AppTest.java create mode 100644 AccountHibernate/target/classes/META-INF/MANIFEST.MF create mode 100644 AccountHibernate/target/classes/META-INF/maven/com.hibernate.rest/AccountHibernate/pom.properties create mode 100644 AccountHibernate/target/classes/META-INF/maven/com.hibernate.rest/AccountHibernate/pom.xml create mode 100644 AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/AccountResource.class create mode 100644 AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/dao/PersonalInfoDAO.class create mode 100644 AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/dao/PersonalInfoDAOImpl.class create mode 100644 AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/interfaces/ErrorMsgCodes.class create mode 100644 AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/util/HibernateUtil.class create mode 100644 AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/validation/AccountValidation.class create mode 100644 AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/validation/AccountValidationException.class create mode 100644 AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/vo/PersonalInfo.class create mode 100644 AccountHibernate/target/classes/hibernate.cfg.xml create mode 100644 AccountHibernate/target/test-classes/com/hibernate/rest/AccountHibernate/AppTest.class diff --git a/AccountHibernate/.classpath b/AccountHibernate/.classpath new file mode 100644 index 0000000..f8c90ba --- /dev/null +++ b/AccountHibernate/.classpath @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AccountHibernate/.project b/AccountHibernate/.project new file mode 100644 index 0000000..b589896 --- /dev/null +++ b/AccountHibernate/.project @@ -0,0 +1,23 @@ + + + AccountHibernate + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/AccountHibernate/.settings/org.eclipse.core.resources.prefs b/AccountHibernate/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..4c28b1a --- /dev/null +++ b/AccountHibernate/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/test/java=UTF-8 +encoding/=UTF-8 diff --git a/AccountHibernate/.settings/org.eclipse.jdt.core.prefs b/AccountHibernate/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..fbcdb7f --- /dev/null +++ b/AccountHibernate/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/AccountHibernate/.settings/org.eclipse.m2e.core.prefs b/AccountHibernate/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..14b697b --- /dev/null +++ b/AccountHibernate/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/AccountHibernate/pom.xml b/AccountHibernate/pom.xml new file mode 100644 index 0000000..0163520 --- /dev/null +++ b/AccountHibernate/pom.xml @@ -0,0 +1,88 @@ + + + + 4.0.0 + + com.hibernate.rest + AccountHibernate + 0.0.1-SNAPSHOT + + AccountHibernate + + http://www.example.com + + + UTF-8 + 1.7 + 1.7 + + + + + junit + junit + 4.11 + test + + + org.hibernate + hibernate-core + 4.1.1.Final + + + + mysql + mysql-connector-java + 5.1.34 + + + + + + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + + diff --git a/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/AccountResource.java b/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/AccountResource.java new file mode 100644 index 0000000..e37bc63 --- /dev/null +++ b/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/AccountResource.java @@ -0,0 +1,29 @@ +package com.hibernate.rest.AccountHibernate; + +import com.hibernate.rest.AccountHibernate.dao.PersonalInfoDAO; +import com.hibernate.rest.AccountHibernate.dao.PersonalInfoDAOImpl; +import com.hibernate.rest.AccountHibernate.validation.AccountValidationException; +import com.hibernate.rest.AccountHibernate.vo.PersonalInfo; + +/** + * Hello world! + * + */ +public class AccountResource +{ + + static PersonalInfoDAO personalDAO = new PersonalInfoDAOImpl(); + static PersonalInfo personalVO = new PersonalInfo(); + + public static void main( String[] args ) throws AccountValidationException, Exception + { + System.out.println( "Hello World!" ); + + personalDAO.addPersonalInfo(personalVO); + personalDAO.viewPersonalInfo(personalVO.getFirstName()); + personalDAO.modifyPersonalInfo(personalVO); + personalDAO.deletePersonalInfo(personalVO.getFirstName()); + + } + +} diff --git a/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/dao/PersonalInfoDAO.java b/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/dao/PersonalInfoDAO.java new file mode 100644 index 0000000..c740bab --- /dev/null +++ b/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/dao/PersonalInfoDAO.java @@ -0,0 +1,17 @@ +package com.hibernate.rest.AccountHibernate.dao; + + +import com.hibernate.rest.AccountHibernate.validation.AccountValidationException; +import com.hibernate.rest.AccountHibernate.vo.PersonalInfo; + +public interface PersonalInfoDAO { + + void addPersonalInfo(PersonalInfo personalVOO) throws AccountValidationException, Exception; + + PersonalInfo viewPersonalInfo(String firstName) throws AccountValidationException, Exception; + + void modifyPersonalInfo(PersonalInfo personalVOO) throws AccountValidationException, Exception; + + void deletePersonalInfo(String firstName) throws AccountValidationException, Exception; + +} \ No newline at end of file diff --git a/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/dao/PersonalInfoDAOImpl.java b/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/dao/PersonalInfoDAOImpl.java new file mode 100644 index 0000000..b1c6136 --- /dev/null +++ b/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/dao/PersonalInfoDAOImpl.java @@ -0,0 +1,103 @@ +package com.hibernate.rest.AccountHibernate.dao; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.springframework.stereotype.Repository; + +import com.hibernate.rest.AccountHibernate.util.HibernateUtil; +import com.hibernate.rest.AccountHibernate.validation.AccountValidation; +import com.hibernate.rest.AccountHibernate.validation.AccountValidationException; +import com.hibernate.rest.AccountHibernate.vo.PersonalInfo; + +@Repository +public class PersonalInfoDAOImpl implements PersonalInfoDAO { + + public PersonalInfoDAOImpl() { + super(); + } + + public void addPersonalInfo(PersonalInfo personalVOO) throws AccountValidationException, Exception { + + System.out.println("PersonalInfoDAOImpl : addPersonalInfo() : Start"); + Session session = HibernateUtil.getSessionFactory().openSession(); + StringBuffer allMessages = new StringBuffer(); + AccountValidation accValidate = new AccountValidation(); + System.out.println("Inside addPersonalInfoDAO : " + personalVOO.getFirstName()); + allMessages.append(accValidate.validatePersonalDetails(personalVOO.getFirstName(), personalVOO.getMiddleName(), + personalVOO.getLastName(), personalVOO.getGender())); + System.out.println("DAO Messages :" + allMessages.toString()); + if (allMessages.length() == 0) { + System.out.println("In DAO : " + personalVOO.getFirstName()); + Transaction tx = session.getTransaction(); + tx.begin(); + session.save(personalVOO); + System.out.println("PersonalInfoDAOImpl : addPersonalInfo() : End"); + tx.commit(); + session.close(); + } else { + throw new AccountValidationException(allMessages.toString()); + } + } + + public PersonalInfo viewPersonalInfo(String firstName) throws AccountValidationException, Exception { + + Session session = HibernateUtil.getSessionFactory().openSession(); + StringBuffer allMessages = new StringBuffer(); + AccountValidation accValidate = new AccountValidation(); + PersonalInfo personalVO = null; + System.out.println("Inside AccountDAO : " + firstName); + allMessages.append(accValidate.validateFirstName(firstName)); + System.out.println("DAO Messages :" + allMessages.toString()); + if (allMessages.length() == 0) { + System.out.println("In DAO : " + firstName); + personalVO = (PersonalInfo) session.load(PersonalInfo.class, firstName); + System.out.println(personalVO); + session.close(); + } else { + throw new AccountValidationException(allMessages.toString()); + } + return personalVO; + } + + public void modifyPersonalInfo(PersonalInfo personalVOO) throws AccountValidationException, Exception { + + Session session = HibernateUtil.getSessionFactory().openSession(); + StringBuffer allMessages = new StringBuffer(); + AccountValidation accValidate = new AccountValidation(); + System.out.println("Inside AccountDAO : " + personalVOO.getFirstName()); + allMessages.append(accValidate.validateFirstName(personalVOO.getFirstName())); + System.out.println("DAO Messages :" + allMessages.toString()); + if (allMessages.length() == 0) { + System.out.println("In DAO : " + personalVOO.getFirstName()); + Transaction tx = session.getTransaction(); + tx.begin(); + session.update(personalVOO); + tx.commit(); + session.close(); + } else { + throw new AccountValidationException(allMessages.toString()); + } + } + + public void deletePersonalInfo(String firstName) throws AccountValidationException, Exception { + + Session session = HibernateUtil.getSessionFactory().openSession(); + StringBuffer allMessages = new StringBuffer(); + AccountValidation accValidate = new AccountValidation(); + System.out.println("Inside AccountDAO : " + firstName); + allMessages.append(accValidate.validateFirstName(firstName)); + System.out.println("DAO Messages :" + allMessages.toString()); + if (allMessages.length() == 0) { + System.out.println("In DAO : " + firstName); + PersonalInfo personalVO = viewPersonalInfo(firstName); + Transaction tx = session.getTransaction(); + tx.begin(); + session.delete(personalVO); + tx.commit(); + session.close(); + } else { + throw new AccountValidationException(allMessages.toString()); + } + } + +} diff --git a/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/interfaces/ErrorMsgCodes.java b/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/interfaces/ErrorMsgCodes.java new file mode 100644 index 0000000..9a59bc4 --- /dev/null +++ b/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/interfaces/ErrorMsgCodes.java @@ -0,0 +1,43 @@ +package com.hibernate.rest.AccountHibernate.interfaces; + +/* + * + * Error Message Codes + * + * */ +public interface ErrorMsgCodes { + + // Login Error Codes + String USER_ID_NULL = "UserName Required
"; + String PASSWORD_NULL = "Password Required
"; + public static final String USER_ID_INVALID = "Invalid UserName. for eg: Ab_2-1
"; + public static final String PWD_INVALID = "Invalid Password. for eg: He_34-llo@123
"; + + // Personal details Error Codes + public static final String FIRST_NAME_IS_BLANK = "First Name is blank
"; + public static final String FIRST_NAME_INVALID = "First Name must start with a letter. " + + "It can contain only letters, numbers, spaces, hyphens(-) and underscores(_).
"; + public static final String MIDDLE_NAME_IS_BLANK = "Middle Name is blank
"; + public static final String MIDDLE_NAME_INVALID = "Middle Name must start with a letter. " + + "It can contain only letters, numbers, spaces, hyphens(-) and underscores(_).
"; + public static final String LAST_NAME_IS_BLANK = "Last Name is blank
"; + public static final String LAST_NAME_INVALID = "Last Name must start with a letter. " + + "It can contain only letters, numbers, spaces, hyphens(-) and underscores(_).
"; + + // Contact details Error Codes + public static final String ADDRESS_IS_BLANK = "Address is blank
"; + public static final String CITY_IS_BLANK = "City is blank
"; + public static final String STATE_IS_BLANK = "State is blank
"; + public static final String COUNTRY_IS_BLANK = "Country is blank
"; + public static final String PHONE_IS_BLANK = "Phone Number is blank
"; + public static final String PERSON_ID_IS_BLANK = "First Name is blank
"; + public static final String PHONE_INVALID = "Please specify the phone number in the format (000-000-0000).
"; + + //Bank Details Error Codes + public static final String BANK_NAME_IS_BLANK = "Bank Name is blank
"; + public static final String ACCOUNT_NUMBER_IS_BLANK = "Account Number is blank
"; + public static final String SSN_IS_BLANK = "SSN is blank
"; + public static final String SSN_INVALID = "SSN should be in the format (000-00-0000).
"; + + public static final String HOME_PAGE = "/jsp/home.jsp"; +} diff --git a/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/util/HibernateUtil.java b/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/util/HibernateUtil.java new file mode 100644 index 0000000..7d886d8 --- /dev/null +++ b/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/util/HibernateUtil.java @@ -0,0 +1,37 @@ +package com.hibernate.rest.AccountHibernate.util; + +import org.hibernate.SessionFactory; +import org.hibernate.cfg.Configuration; +import org.hibernate.service.ServiceRegistryBuilder; + +import com.hibernate.rest.AccountHibernate.vo.PersonalInfo; + +public class HibernateUtil { + + private static SessionFactory sessionFactory; + + private static Configuration config; + + // Create the initial SessionFactory from the default configuration files + static { + try { + config = new Configuration().configure().addAnnotatedClass(PersonalInfo.class); + /* + * .addAnnotatedClass(AccountVOO.class).addAnnotatedClass(ContactInfoVOO.class) + * .addAnnotatedClass(BankInfoVOO.class); + */ + + org.hibernate.service.ServiceRegistry serviceReg = new ServiceRegistryBuilder() + .applySettings(config.getProperties()).buildServiceRegistry(); + + sessionFactory = config.buildSessionFactory(serviceReg); + } catch (Throwable ex) { + throw new ExceptionInInitializerError(ex); + } + } + + public static SessionFactory getSessionFactory() { + return sessionFactory; + } + +} diff --git a/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/validation/AccountValidation.java b/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/validation/AccountValidation.java new file mode 100644 index 0000000..ea206c1 --- /dev/null +++ b/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/validation/AccountValidation.java @@ -0,0 +1,150 @@ +package com.hibernate.rest.AccountHibernate.validation; + +import com.hibernate.rest.AccountHibernate.interfaces.ErrorMsgCodes; + +public class AccountValidation { + + public AccountValidation() { + super(); + } + + /* + * + * Login Validations + * + */ + public String validateUserName(String userName) { + System.out.println("Inside Account Validation UserName: " + userName); + if (userName.equals("")) { + return ErrorMsgCodes.USER_ID_NULL; + } else if (userName.trim().length() < 2) { + return ErrorMsgCodes.USER_ID_INVALID; + } else if (!(userName.matches("[a-zA-Z0-9@_ -]+"))) { + return ErrorMsgCodes.USER_ID_INVALID; + } + return ""; + } + + public String validatePassword(String passwd) { + System.out.println("Inside Account Validation Password: " + passwd); + if (passwd.equals("")) { + return ErrorMsgCodes.PASSWORD_NULL; + } else if (passwd.trim().length() < 2) { + return ErrorMsgCodes.USER_ID_INVALID; + } else if (!(passwd.matches("[a-zA-Z0-9@_ -]+"))) { + return ErrorMsgCodes.USER_ID_INVALID; + } + return ""; + } + + + public String validateFirstName(String firstName) { + System.out.println("Inside Account Validation FirstName: " + firstName); + if (firstName == null || firstName.trim().length() == 0) { + return ErrorMsgCodes.FIRST_NAME_IS_BLANK; + } else if (firstName.trim().length() < 2) { + return ErrorMsgCodes.FIRST_NAME_INVALID; + } else if (!(firstName.matches("^[A-Za-z][a-zA-Z0-9_ -]+"))) { + return ErrorMsgCodes.FIRST_NAME_INVALID; + } + return ""; + } + + /* + * + * Personal Details Validation + * + */ + + public String validatePersonalDetails(String firstName, String middleName, String lastName, String gender) { + System.out.println("Inside Account Validation Personal details : "); + if (firstName == null || firstName.trim().length() == 0) { + return ErrorMsgCodes.FIRST_NAME_IS_BLANK; + } else if (firstName.trim().length() < 2) { + return ErrorMsgCodes.FIRST_NAME_INVALID; + } else if (!(firstName.matches("^[A-Za-z][a-zA-Z0-9_ -]+"))) { + return ErrorMsgCodes.FIRST_NAME_INVALID; + } + + if (middleName == null || middleName.trim().length() == 0) { + return ErrorMsgCodes.MIDDLE_NAME_IS_BLANK; + } else if (!(middleName.matches("[a-zA-Z0-9_ -]+"))) { + return ErrorMsgCodes.MIDDLE_NAME_INVALID; + } + + if (lastName == null || lastName.trim().length() == 0) { + return ErrorMsgCodes.LAST_NAME_IS_BLANK; + } else if (lastName.trim().length() < 2) { + return ErrorMsgCodes.LAST_NAME_INVALID; + } else if (!(lastName.matches("^[A-Za-z][a-zA-Z0-9_ -]+"))) { + return ErrorMsgCodes.LAST_NAME_INVALID; + } + return ""; + } + + /* + * + * Contact Details Validation + * + * + */ + + public String validateContactDetails(String address, String city, String state, String country, String phone, + String personId) { + if (address == null || address.trim().length() == 0) { + return ErrorMsgCodes.ADDRESS_IS_BLANK; + } + + if (city == null || city.trim().length() == 0) { + return ErrorMsgCodes.CITY_IS_BLANK; + } + + if (state == null || state.trim().length() == 0) { + return ErrorMsgCodes.STATE_IS_BLANK; + } + + if (country == null || country.trim().length() == 0) { + return ErrorMsgCodes.COUNTRY_IS_BLANK; + } + + if (phone == null || phone.trim().length() == 0) { + return ErrorMsgCodes.PHONE_IS_BLANK; + } else if (phone.trim().length() < 10) { + return ErrorMsgCodes.PHONE_INVALID; + } else if (!(phone.matches("[0-9]{3}[-][0-9]{3}[-][0-9]{4}+"))) { + return ErrorMsgCodes.PHONE_INVALID; + } + + return ""; + } + + /* + * + * Bank Details Validation + * + * + */ + + public String validateBankDetails(String bank, String accNo, String ssn, String personId) { + if (bank == null || bank.trim().length() == 0) { + return ErrorMsgCodes.BANK_NAME_IS_BLANK; + } + + if (accNo == null || accNo.trim().length() == 0) { + return ErrorMsgCodes.ACCOUNT_NUMBER_IS_BLANK; + } + + if (personId == null || personId.trim().length() == 0) { + return ErrorMsgCodes.PERSON_ID_IS_BLANK; + } + + if (ssn == null || ssn.trim().length() == 0) { + return ErrorMsgCodes.SSN_IS_BLANK; + } else if (!(ssn.matches("[0-9]{3}[-][0-9]{2}[-][0-9]{4}+"))) { + return ErrorMsgCodes.SSN_INVALID; + } + + return ""; + } + +} diff --git a/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/validation/AccountValidationException.java b/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/validation/AccountValidationException.java new file mode 100644 index 0000000..7836dc7 --- /dev/null +++ b/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/validation/AccountValidationException.java @@ -0,0 +1,32 @@ +package com.hibernate.rest.AccountHibernate.validation; + +/* + * + * User Defined Account Exception + * + * + */ + +public class AccountValidationException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + private String errorMessage; + + public AccountValidationException(String errorMessage) { + this.errorMessage = errorMessage; + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + + +} diff --git a/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/vo/PersonalInfo.java b/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/vo/PersonalInfo.java new file mode 100644 index 0000000..17393db --- /dev/null +++ b/AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/vo/PersonalInfo.java @@ -0,0 +1,69 @@ +package com.hibernate.rest.AccountHibernate.vo; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.xml.bind.annotation.XmlRootElement; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@XmlRootElement +@Entity +@Table(name="personaldetails") +@JsonIgnoreProperties({"hibernateLazyInitializer","handler"}) +public class PersonalInfo { + + @Id + @Column(name="firstname") + private String firstName; + @Column(name="middlename") + private String middleName; + @Column(name="lastname") + private String lastName; + @Column(name="gender") + private String gender; + + public PersonalInfo(){ + super(); + } + + public PersonalInfo(String firstName, String middleName, String lastName, String gender) { + this.firstName = firstName; + this.middleName = middleName; + this.lastName = lastName; + this.gender = gender; + } + + public String getFirstName() { + return firstName; + } + public void setFirstName(String firstName) { + this.firstName = firstName; + } + public String getMiddleName() { + return middleName; + } + public void setMiddleName(String middleName) { + this.middleName = middleName; + } + public String getLastName() { + return lastName; + } + public void setLastName(String lastName) { + this.lastName = lastName; + } + public String getGender() { + return gender; + } + public void setGender(String gender) { + this.gender = gender; + } + + @Override + public String toString() { + return "PersonalInfoVOO [firstName=" + firstName + ", middleName=" + middleName + ", lastName=" + lastName + + ", gender=" + gender + "]"; + } + +} diff --git a/AccountHibernate/src/main/java/hibernate.cfg.xml b/AccountHibernate/src/main/java/hibernate.cfg.xml new file mode 100644 index 0000000..32e0c04 --- /dev/null +++ b/AccountHibernate/src/main/java/hibernate.cfg.xml @@ -0,0 +1,13 @@ + + + + + com.mysql.jdbc.Driver + password + jdbc:mysql://localhost:3306/test + root + org.hibernate.dialect.MySQLDialect + + diff --git a/AccountHibernate/src/test/java/com/hibernate/rest/AccountHibernate/AppTest.java b/AccountHibernate/src/test/java/com/hibernate/rest/AccountHibernate/AppTest.java new file mode 100644 index 0000000..b477950 --- /dev/null +++ b/AccountHibernate/src/test/java/com/hibernate/rest/AccountHibernate/AppTest.java @@ -0,0 +1,20 @@ +package com.hibernate.rest.AccountHibernate; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Unit test for simple App. + */ +public class AppTest +{ + /** + * Rigorous Test :-) + */ + @Test + public void shouldAnswerWithTrue() + { + assertTrue( true ); + } +} diff --git a/AccountHibernate/target/classes/META-INF/MANIFEST.MF b/AccountHibernate/target/classes/META-INF/MANIFEST.MF new file mode 100644 index 0000000..771ca48 --- /dev/null +++ b/AccountHibernate/target/classes/META-INF/MANIFEST.MF @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Built-By: gargh +Build-Jdk: 1.8.0_231 +Created-By: Maven Integration for Eclipse + diff --git a/AccountHibernate/target/classes/META-INF/maven/com.hibernate.rest/AccountHibernate/pom.properties b/AccountHibernate/target/classes/META-INF/maven/com.hibernate.rest/AccountHibernate/pom.properties new file mode 100644 index 0000000..195859d --- /dev/null +++ b/AccountHibernate/target/classes/META-INF/maven/com.hibernate.rest/AccountHibernate/pom.properties @@ -0,0 +1,7 @@ +#Generated by Maven Integration for Eclipse +#Fri Apr 10 12:02:49 PDT 2020 +version=0.0.1-SNAPSHOT +groupId=com.hibernate.rest +m2e.projectName=AccountHibernate +m2e.projectLocation=C\:\\Users\\gargh\\eclipse-workspace-new-temp\\AccountHibernate +artifactId=AccountHibernate diff --git a/AccountHibernate/target/classes/META-INF/maven/com.hibernate.rest/AccountHibernate/pom.xml b/AccountHibernate/target/classes/META-INF/maven/com.hibernate.rest/AccountHibernate/pom.xml new file mode 100644 index 0000000..0163520 --- /dev/null +++ b/AccountHibernate/target/classes/META-INF/maven/com.hibernate.rest/AccountHibernate/pom.xml @@ -0,0 +1,88 @@ + + + + 4.0.0 + + com.hibernate.rest + AccountHibernate + 0.0.1-SNAPSHOT + + AccountHibernate + + http://www.example.com + + + UTF-8 + 1.7 + 1.7 + + + + + junit + junit + 4.11 + test + + + org.hibernate + hibernate-core + 4.1.1.Final + + + + mysql + mysql-connector-java + 5.1.34 + + + + + + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + + diff --git a/AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/AccountResource.class b/AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/AccountResource.class new file mode 100644 index 0000000000000000000000000000000000000000..f376cae9df50a993f2da8dc4cbb29bd8f263198a GIT binary patch literal 1573 zcmbVMSx*yD6#i}topu;4bYpP?*A|sg5dm8lWRaQ%jF=MR(=c->LuP5F(<=TeA%P%? zKfoVlJa?ci#XdC5!`yq%x#v6EckZ9RzkUOl#s>)@hH2fk)g5z-dyeLF)#Ei^UC?#6 z?)a-M>6zdYueo(k=MwrD26wfFrdpa)QP;P2x$ZLzRJm7k9nD%=SZA0o^#W~ZuKMxJ ztmtgJWSVD?n@D8>n&}Cs(TPJK(SmN7j_JQ<2xoI;hQ3ADpy01Cur*M4= znrn7GiiZr!Dz_|meAD$TV?xGbs1l}{-Z~8wJi${2sVXomDn&Zmtr7z?H8T>PGtBl< zfiBcm@B*{cTg@=elb&HNdnuCV%7QoZ3SNTxs8qPWVtO@yO|ywFsci25EJO~k6uib8 zDs98$-#X(cc1!$Hp$SI|3f_r)6SixZ+k59-3H6eKWl{Hp!7c9d^J*fc=2eK($u68E zMs5TT(TXYNB6We$Q-V*JpjisjLl;6+3?}WOVz6ip(?158^aFI7ryJr+pFsI?gsTS_ zIzf_l=>uebk|Kl=`pdz!IIV*i4Wu9ddIZj3R9YFy`zMbu);5a-LM1R!PA}jZuG7UB zZr~)0aVz>-NfV}9_?djADLr33*mHoh`D1FLfC9--gamfLumUS l3o=hp#u*~YF!>mvNfAAHat)b`LIW z3n^Ed;+*ZCqlq*EA5iM=qY7JIN}-Qjt``?E90IjR0+$UDa)-9X<}yf zelUvAU}!HyA$TgxoR6jpl8&Jzl-i~;+;xZhcocPues99ie0Z1i>a;a^gky$eFCmd? zCCa7WAd?EI^dg)vbT;Q#4?a|(>8&0i=?*v4vCFiX_j~_J#Sky8(zA8lAXb!;qdIuC z%eDNKv0Y`79(76#m)kqOm+SJ-kb&XAw+u9VO@|2m9Qi3kfFm?Lc8aq<*!d1#3++13 KPZwS(K>P#tU#Cm} literal 0 HcmV?d00001 diff --git a/AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/dao/PersonalInfoDAOImpl.class b/AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/dao/PersonalInfoDAOImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..60e5518e9f1590a216e95bb0f70eaea5cc3eb8e4 GIT binary patch literal 4411 zcmbW4`*Rc57018VwzRgqJZv6D1QLgm)PRlRU|tq+u?@yfWSe5JV<04JX>Ar(yJB}` zZ2C&mSCY1QH%(~LKuDWrrZ8=$BT76&`*Zp~rTt#*O4f^v%6L}0d-p!h{haSP=lbh! zzPb-!AHGn~AP`U5>DWbMPIoNL(_@bAda=P|(#~4mXt6b=*|C$lZ)tX z#d2bCxtGZCrKFzm4BK)QY!n!)$F@byG*X%zRPf7mv86blg3SUORy|St(1I=4svuhC zr>SMv)6*&*!8T&Hv!1}FM1HVAs~yAgraVX2((z_IDp1Swo&B8^V7hj(ZOYReFM>|& zQ1E!cpz=9Yd^eHEuehmHF`swG znlZ=Ck6E3*9$JyYyaM`eQ_X--u>g)-OIoKL&2kxO3^;-9Rl!j5nPGMbtRa^fH086F zbW)L)Nk25FFBq0I!&Z^O71jk;Tcka^OF8)UCmwKM-kH)_6HMcptP7+-2lW(OR#L_u zkj#!-DQRI=#iBGJO#P<~Puj4gVj0(HRnoLw8qrY@w0p&j4cnH*D#-m)kQ;D>;>rZ2 zb9!=8VE;pv4`xi)Ph(uJcJ^YmYSm1$;9`L-RXPjwAUh_LK^dX_L-m-g-|ZZPfymgp(#CoL`OG7nKtt^}G z$?EvKiketZH4{(E{Aw0$uktPlM^>e#;Cgw{&zDx7meO|0m|rf%E_d>=ia*Mw!`Tc^ z8x%!*N;h?{nBru-L?Cce#jo(H9C1s0QB5Bb}YKivvGv32)dME=f)2B`dv@D8j;6WXwbPpaPuYq5@R#Krao zwDUR4`vz>1lZjXP7G~RjzC=g+_8cDjC!V;6Jp$t^=$*ZbeG@C_nB3E`IPYiKH=)8)7~ZE;KPLS@vFB|n_8-`Z6+D6aJhXj{ zt~}ZSA6bBw@bE+Yh=|+p6@HAL5N{M;;${4lcI?0xcm+SBTi)j^KgTcV&0o^0b!hko z_Z6fR^eX6U<#1}RhKFW3RC?&vgFPeqLj{tr`6SCc^XocXakwx+;EG^^?)Cwqf3p$) z#z20NXeftwYjcl={#GPEkQZGyCDubKd&xOQ#!vA-vtFJ+p2iHHF7VXhVL#~{!0S9A zy^TY74~KDs{*eOqDc>qmzD0t+C#Du$4=A_coq+OIycSU2PP!k^8$RW2X!tKD4J!}| zJ}lB!I5{NpKhzA0a{=-@4@O?V74WVKh8*glK3tflo&flWvZ_z_LkxD{C`k=+e?z1{ zOy0-%b{uD^d<`dX4WlGBMsCmIEj&lE2`0&L++o;7+$nnCPN4G^Mu)HSHpYst z^R2|}>--f)RE5rO7RgKKpD?7VGtostS7`R_x}pEyA|I{59ZayB8S6%WD9AbCXxPs= z685KL&eu9}%?L>Yr^);bpQg!thI)UVTApR=S)AkF6`aQsULdgx4E7iCCSIbZH8Px| z>XY~@^gQ=bA4HM+?V|EOD{}v+$o<`b`x5huul$!8YtjSZ)l74v!~+d5;zx{{xJGlhgnJ literal 0 HcmV?d00001 diff --git a/AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/interfaces/ErrorMsgCodes.class b/AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/interfaces/ErrorMsgCodes.class new file mode 100644 index 0000000000000000000000000000000000000000..2a53a4014e77cd50568d3763b0dfcb964cbeca4c GIT binary patch literal 1910 zcmchYSyS6c5XXCR;RFa^5(qgbyV(R1Y#GSz<{*cB5UbW#SthAGsm9WPMdT6DjG*{x z`;ZTi50y&GMrLsQoCjCwCw2GCzb}9P@&7jf*aB+`E)dvu!@kk;yF3z1aUu+(Bw9*2=PGNnV?x%6nO@zJbV*cjJ}wuNYP_o^(dnOS6GicwG?%kpl&D>^92n> zaB})hu2T{Bv8ebU50k>J)85Hpj|;h)Tcb>PG!`Cyc0;WAsy#HS^a}JjA}KvB{NK&>T_)j|jwP_P_Q1^Jcl+ zuGqHLNKddjrsrY3Bt73nvn8wZS+jgfV4>uzlQFaFcE{}Kt(n8ov=xs1nBjb>x!dTp z^^gTTyp$}3=$ELiYO|q7-6F8k>V*PZWzd3S!LzMO+io_J?T`*hGU3A@Y3BbWP;3R9 zNsjHyU4QR{svf6@gRsNSrr7bxI~?RbQ*^aZDCACmg;6_ai#UVh&HM`6pok+lsg;+_ z(m*_Ju6i-qVWT;IL*UNoVw@~&##B?CK{I^#ed8ojX3^Y}pEnjOZG%Xj>MV|mZ5>wL0?uMi+`5&r>} zU&-(Q{+E1{uB8x zjUOYgYP^R0OyhOryv7FdhQ^!7&oxf&`?tpbAivP~CGu;Hw~^m!{0`aFxQJZVxPnQBCn)13eS literal 0 HcmV?d00001 diff --git a/AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/util/HibernateUtil.class b/AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/util/HibernateUtil.class new file mode 100644 index 0000000000000000000000000000000000000000..c0c3310e6f5406b4853e9f2c284aea3871af9bb3 GIT binary patch literal 1602 zcma)6ZBG+H5Pr5GN9!R{ML|?v^!sc^VhfU0LJmeLX6>_7ru8k#X6UPtGFY1q?|d= z3rm4|dZaBW;X6m-YmzK9GMsO6Jc z3D{`0aUKcEIca&L7CWT8^gHCaB*EDtwGO_uA}LMm=w&$EgQGtFkGkv zt8UXLsT#&l3RTNRO+RZQ?$|hkCJW;X1IJV@e)M=zxA8Llgc7bVK5@AyWk?K+;jV7Y zd%DpmTG($2Qdal3bN}=V7GEun` z@y{@H%KI|J_(z8JzoH`AbISGJ5x*u!0u5-TN2xXiwZK&NG|!`cw$M9oqZX{LEJIHn z-PI?^Es+aL(&J0Q)Szl$-PV;uFVWLL(=UdE=7@F){b*=yp#L~Y3};FDOfsW&<^cAa zeVi+!E!keiG5WQ}x6k;- LNXxKjY)iiZi_o&D literal 0 HcmV?d00001 diff --git a/AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/validation/AccountValidation.class b/AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/validation/AccountValidation.class new file mode 100644 index 0000000000000000000000000000000000000000..0610a0d3d3cdf9565241c202b4d9fae9629f0826 GIT binary patch literal 3976 zcmchaYf~Fl9LArefh;u8np!H}dWx-uLI}3?Rw^x*)}oYR5wt~$o6SPD-R!2j8)~e@ zdcRhk@s+-E`~=Y#IHNPZ^o5_oPvZET-ObX3;CLG+5YC=Gm*@XG&;OjmufPBJGk{~b zlSGSx)4Eg47R;RC+L~`Qq^BKS zvlcYhl+RIR!Y`Pfg7N8pt8;`Zqd1It&v0k7BIkUxZ+cVuobQ_U>PY|As&?FiJxQeN zBAu&vzEMo!UhHL*PMJaP4ZE67c9ui=9MI5;BT4L2u&;5R@v>><4Oc~vf`e1GXXXtN zkr$hIMNR7o(SdF}An85GiJIwNkS!igVLt@A<7tOX9GCJwb5wVW-e9l_pD)gk`H3P=F3(kWFH!9%R5hg<(8K-NyB@ zW^u{uLJVCs(tlaSF}|un5f|CobdCJUoI5JVemsRIr1S)bEXsnp6+nJ>Rav~;?!BL)r$)5yRyiY;(9G@E?Tf=3ffm{(Ncen zz$}MxY|WZ9s6yKAl_u%3b=Ce#O_PjKafu1JJ?5Gkkq_kviF=Vzoj3D&%V@@XiCbwy zs4A8f+_<~T|GEkqEjX=l*_*gSS5V%3_dm)~&`}H+hWoy1QD9hXTje%sxD;LU#Duh@ z?#Gt6{hwLlAKT_Cx8SjSo_6;d^37s8PndqCq1xto%6-LeOwSSrnvkcv+t`BydS(lb zO_v49*DxSYxA9ra&^&`VY3SxkMfe3nl!6{%x(cSTtm8JyO;Pj>4-aRe-{Ck%*A(nu zIIE+EX2MV&Xt5W=g-#5b@ZdHCW0*qj$TAjuN1 zSo}@~7d?d~p!LWPP`_iLg@>>_h+FurB7t`7WGNLk;@?g_Dd@tkXn?QTMz%fmJ$C5b9h6^@ZwIs7EMv00%LM!<2dyLwFonj8gI#pX54+P$y%klbDaiwjpt_C7`;1 zm%`Oo4s#J&*>9a{(=W^Q{_FY%*>o_pgbd|!buj%(B>qY@!sVna5m>MjJG)7%vxPqav{e)$XanpfbFb0> z%d9paxz>oGSnWytg07y#CK;#N(<-Z4H><9*Dty}AA#=^+bGjU%_3C(y(sv+%E-W+U zav4HDp_4+N?ju@8w(_J2_?R{4ihdse%APro;eo=6Emvd1}Vr*r9ze=qYBF* zqY7RR7|FLcS(5Il;0>1A0&ZPMb+r&#%P#qm`_8SJ+wfcDw)qBd>y6-UZ{>8Mk>%So z(Yq0p_v@ex1!28KC~p(WdxY{np?t&?`IrfFhfqEvl+S6EFKCl5?=s4K3}GH0G9(FM ho;^bd^Xwl&m=6LDjj|K%GT>eOl{?la?9zfy{{U*u+RXp} literal 0 HcmV?d00001 diff --git a/AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/validation/AccountValidationException.class b/AccountHibernate/target/classes/com/hibernate/rest/AccountHibernate/validation/AccountValidationException.class new file mode 100644 index 0000000000000000000000000000000000000000..8365689419a8ed893c9840df93a2e3afd3f0244f GIT binary patch literal 761 zcmb`EPfrv<5XE2ZpII3O7M4X(AcouSk}wC47!rdJ(bWsO_h#rUZI&L>(@XeRnqW*k z@B#Qx#y7(-AaHaJ(_OEsU;nE5>d)^>0I#s#LQQaxq^I$TInvH5uVbe(AHPYGbZY&( zNl&XVhe*UB<#M2X6)PUNE5=zWtDzbxPCk@wijhlUL{T<274c!4GYMy(=xLWNV{zD_N| z9RKr-_NmvnhJ#;d4>o_I^P{Nm@;_fVbhZ6ZbXnaCtke2kckR-!T*t3(*=QIa;0Y^5+DTs28(VY*T{XBsxD z7>r6mlML!(M(k%5yk^h}-C~q_okv(S=Q6>n1>rJ;hmp)rj$G|a#NDvukK12B8sFb8L-GiC7qEO-df5Uf+> zk96gC2op4qe+nzn4ZzCLHAsd&MAvBnnsSg09sG)uQ`pNY2jx3wv{%EM~`859A12_SC5=dB>heeEfX0-s??l%(=kn6g2_s$|(9!x(Vf#C@HP ziB+fb2QB`FLpmK*2%;||Q~82!hnKf-T7`%QX$)ZNVw3^qPT*l)pX$SmhcFo;L;=Z- z0$GU!Qi=wW8wGL~;qF}kM6-m^awL%aD3G;CAmwNv`B5Mb0c8CGAexm76^p7!aTLf# zB#=rpkRe9t)@%Yu^#UMz3h=h|fjAgAMThENwE9!#?nnBn46=Nn`pw}aVU0{y>(zJqTUKrr7==^2Fj MTbl6bxkoSl1Bw2p-~a#s literal 0 HcmV?d00001 diff --git a/AccountHibernate/target/classes/hibernate.cfg.xml b/AccountHibernate/target/classes/hibernate.cfg.xml new file mode 100644 index 0000000..32e0c04 --- /dev/null +++ b/AccountHibernate/target/classes/hibernate.cfg.xml @@ -0,0 +1,13 @@ + + + + + com.mysql.jdbc.Driver + password + jdbc:mysql://localhost:3306/test + root + org.hibernate.dialect.MySQLDialect + + diff --git a/AccountHibernate/target/test-classes/com/hibernate/rest/AccountHibernate/AppTest.class b/AccountHibernate/target/test-classes/com/hibernate/rest/AccountHibernate/AppTest.class new file mode 100644 index 0000000000000000000000000000000000000000..e7d429a945c211a353eed90077de216ca16b321a GIT binary patch literal 517 zcmb7AO;5r=6r3%EYOR8R9~`}*M)$xGW73!y4~-^DF!8pO4P8=pNxRkG9E48p%uxD|se!%fmP}g|;`pzu|m7Ai#sm z(3py6!Be3p{BAUrv1O=TD6Q-zL#2B>WN@#{So)}7Ge8wJhI*v5ye(!VG7zIwGBhI- zi*zV5RnDtV*Cr}wIE(&qQlFunC#Fcpq0V1q_NZ(!$O@9^+>-@0lS7p&(g?LSR#;^; zNi-spP588+t9fax@1u#fhZaF=B+PS}*#LXkXYj>hT5`MHr_!kZV2Ui3*Q&G>tU@|3 z^T81)4T>3X=tU_|^=RVM8TIPP8#Z1Suurvw0UujbgXIGCZJHQ%2z5|jZ8fNuL_I