-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gargh
committed
Apr 10, 2020
1 parent
f3917f4
commit 966a9b2
Showing
29 changed files
with
802 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="test" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="lib" path="C:/Users/gargh/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.7.0/jackson-annotations-2.7.0.jar" sourcepath="C:/Users/gargh/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.7.0/jackson-annotations-2.7.0-sources.jar"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="org.eclipse.jst.component.archivename" value="jackson-annotations-2.7.0.jar"/> | ||
<attribute name="javadoc_location" value="jar:file:/C:/Users/gargh/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.7.0/jackson-annotations-2.7.0-javadoc.jar!/"/> | ||
<attribute name="maven.groupId" value="com.fasterxml.jackson.core"/> | ||
<attribute name="maven.artifactId" value="jackson-annotations"/> | ||
<attribute name="maven.version" value="2.7.0"/> | ||
<attribute name="maven.scope" value="compile"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="lib" path="C:/Users/gargh/.m2/repository/org/springframework/spring-context/4.1.1.RELEASE/spring-context-4.1.1.RELEASE.jar" sourcepath="C:/Users/gargh/.m2/repository/org/springframework/spring-context/4.1.1.RELEASE/spring-context-4.1.1.RELEASE-sources.jar"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="org.eclipse.jst.component.archivename" value="spring-context-4.1.1.RELEASE.jar"/> | ||
<attribute name="javadoc_location" value="jar:file:/C:/Users/gargh/.m2/repository/org/springframework/spring-context/4.1.1.RELEASE/spring-context-4.1.1.RELEASE-javadoc.jar!/"/> | ||
<attribute name="maven.groupId" value="org.springframework"/> | ||
<attribute name="maven.artifactId" value="spring-context"/> | ||
<attribute name="maven.version" value="4.1.1.RELEASE"/> | ||
<attribute name="maven.scope" value="compile"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>AccountHibernate</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
eclipse.preferences.version=1 | ||
encoding//src/main/java=UTF-8 | ||
encoding//src/test/java=UTF-8 | ||
encoding/<project>=UTF-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
resolveWorkspaceProjects=true | ||
version=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.hibernate.rest</groupId> | ||
<artifactId>AccountHibernate</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<name>AccountHibernate</name> | ||
<!-- FIXME change it to the project's website --> | ||
<url>http://www.example.com</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.7</maven.compiler.source> | ||
<maven.compiler.target>1.7</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.11</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hibernate</groupId> | ||
<artifactId>hibernate-core</artifactId> | ||
<version>4.1.1.Final</version> | ||
</dependency> | ||
<!-- http://mvnrepository.com/artifact/mysql/mysql-connector-java --> | ||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<version>5.1.34</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement><!-- lock down plugins versions to avoid using Maven | ||
defaults (may be moved to parent pom) --> | ||
<plugins> | ||
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> | ||
<plugin> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>3.1.0</version> | ||
</plugin> | ||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> | ||
<plugin> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>3.0.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.0</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.22.1</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.0.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-install-plugin</artifactId> | ||
<version>2.5.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<version>2.8.2</version> | ||
</plugin> | ||
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> | ||
<plugin> | ||
<artifactId>maven-site-plugin</artifactId> | ||
<version>3.7.1</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-project-info-reports-plugin</artifactId> | ||
<version>3.0.0</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> |
29 changes: 29 additions & 0 deletions
29
AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/AccountResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
|
||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
AccountHibernate/src/main/java/com/hibernate/rest/AccountHibernate/dao/PersonalInfoDAO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
} |
103 changes: 103 additions & 0 deletions
103
...tHibernate/src/main/java/com/hibernate/rest/AccountHibernate/dao/PersonalInfoDAOImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
...Hibernate/src/main/java/com/hibernate/rest/AccountHibernate/interfaces/ErrorMsgCodes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<br>"; | ||
String PASSWORD_NULL = "Password Required <br>"; | ||
public static final String USER_ID_INVALID = "Invalid UserName. for eg: Ab_2-1<br>"; | ||
public static final String PWD_INVALID = "Invalid Password. for eg: He_34-llo@123<br>"; | ||
|
||
// Personal details Error Codes | ||
public static final String FIRST_NAME_IS_BLANK = "First Name is blank<br>"; | ||
public static final String FIRST_NAME_INVALID = "First Name must start with a letter. " | ||
+ "It can contain only letters, numbers, spaces, hyphens(-) and underscores(_).<br/>"; | ||
public static final String MIDDLE_NAME_IS_BLANK = "Middle Name is blank<br>"; | ||
public static final String MIDDLE_NAME_INVALID = "Middle Name must start with a letter. " | ||
+ "It can contain only letters, numbers, spaces, hyphens(-) and underscores(_).<br/>"; | ||
public static final String LAST_NAME_IS_BLANK = "Last Name is blank<br>"; | ||
public static final String LAST_NAME_INVALID = "Last Name must start with a letter. " | ||
+ "It can contain only letters, numbers, spaces, hyphens(-) and underscores(_).<br/>"; | ||
|
||
// Contact details Error Codes | ||
public static final String ADDRESS_IS_BLANK = "Address is blank<br>"; | ||
public static final String CITY_IS_BLANK = "City is blank<br>"; | ||
public static final String STATE_IS_BLANK = "State is blank<br>"; | ||
public static final String COUNTRY_IS_BLANK = "Country is blank<br>"; | ||
public static final String PHONE_IS_BLANK = "Phone Number is blank<br>"; | ||
public static final String PERSON_ID_IS_BLANK = "First Name is blank<br>"; | ||
public static final String PHONE_INVALID = "Please specify the phone number in the format (000-000-0000).<br/>"; | ||
|
||
//Bank Details Error Codes | ||
public static final String BANK_NAME_IS_BLANK = "Bank Name is blank<br>"; | ||
public static final String ACCOUNT_NUMBER_IS_BLANK = "Account Number is blank<br>"; | ||
public static final String SSN_IS_BLANK = "SSN is blank<br>"; | ||
public static final String SSN_INVALID = "SSN should be in the format (000-00-0000).<br/>"; | ||
|
||
public static final String HOME_PAGE = "/jsp/home.jsp"; | ||
} |
Oops, something went wrong.