Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IntegrationProducerApps
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Raghunath Josula
IntegrationProducerApps
Commits
16ee4e93
Commit
16ee4e93
authored
Feb 20, 2020
by
rjosula
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Committing Active MQ Producer application
parents
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
869 additions
and
0 deletions
+869
-0
pom.xml
VoterProducerApi/pom.xml
+126
-0
VoterProducerApiApplication.java
...a/com/voter/verification/VoterProducerApiApplication.java
+17
-0
ActiveMQConfig.java
...in/java/com/voter/verification/config/ActiveMQConfig.java
+52
-0
MongoConfig.java
.../main/java/com/voter/verification/config/MongoConfig.java
+32
-0
VoterVerificationController.java
.../verification/controller/VoterVerificationController.java
+51
-0
VoterDAO.java
...pi/src/main/java/com/voter/verification/dao/VoterDAO.java
+15
-0
VoterDAOImpl.java
...rc/main/java/com/voter/verification/dao/VoterDAOImpl.java
+55
-0
VoterInformationGateway.java
...m/voter/verification/gateway/VoterInformationGateway.java
+15
-0
Voter.java
...Api/src/main/java/com/voter/verification/model/Voter.java
+86
-0
VoterInformation.java
...n/java/com/voter/verification/model/VoterInformation.java
+97
-0
VotersStatus.java
.../main/java/com/voter/verification/model/VotersStatus.java
+55
-0
DummyActivator.java
...n/java/com/voter/verification/service/DummyActivator.java
+12
-0
VoterServiceActivator.java
...com/voter/verification/service/VoterServiceActivator.java
+90
-0
VoterInformation.xsd
VoterProducerApi/src/main/resources/VoterInformation.xsd
+61
-0
application.properties
VoterProducerApi/src/main/resources/application.properties
+7
-0
voter-app-configuration.xml
...roducerApi/src/main/resources/voter-app-configuration.xml
+85
-0
VoterProducerApiApplicationTests.java
.../voter/verification/VoterProducerApiApplicationTests.java
+13
-0
No files found.
VoterProducerApi/pom.xml
0 → 100644
View file @
16ee4e93
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.2.4.RELEASE
</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>
com.voter.verification
</groupId>
<artifactId>
VoterProducerApi
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<name>
VoterProducerApi
</name>
<description>
Voter Producer App
</description>
<properties>
<java.version>
1.8
</java.version>
</properties>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-activemq
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-integration
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.integration
</groupId>
<artifactId>
spring-integration-mongodb
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.integration
</groupId>
<artifactId>
spring-integration-mongodb
</artifactId>
<scope>
compile
</scope>
<exclusions>
<exclusion>
<artifactId>
jackson-module-kotlin
</artifactId>
<groupId>
com.fasterxml.jackson.module
</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<scope>
runtime
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
<exclusions>
<exclusion>
<groupId>
org.junit.vintage
</groupId>
<artifactId>
junit-vintage-engine
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-jms
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.integration
</groupId>
<artifactId>
spring-integration-jms
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.integration
</groupId>
<artifactId>
spring-integration-core
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.integration
</groupId>
<artifactId>
spring-integration-xml
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.activemq
</groupId>
<artifactId>
activemq-broker
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.integration
</groupId>
<artifactId>
spring-integration-test
</artifactId>
<scope>
test
</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-oxm -->
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-oxm
</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml/jackson-xml-databind -->
<dependency>
<groupId>
com.fasterxml
</groupId>
<artifactId>
jackson-xml-databind
</artifactId>
<version>
0.6.2
</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
VoterProducerApi/src/main/java/com/voter/verification/VoterProducerApiApplication.java
0 → 100644
View file @
16ee4e93
package
com
.
voter
.
verification
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.annotation.ImportResource
;
import
org.springframework.integration.config.EnableIntegration
;
@SpringBootApplication
@EnableIntegration
@ImportResource
({
"classpath*:/voter-app-configuration.xml"
})
public
class
VoterProducerApiApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
VoterProducerApiApplication
.
class
,
args
);
}
}
VoterProducerApi/src/main/java/com/voter/verification/config/ActiveMQConfig.java
0 → 100644
View file @
16ee4e93
package
com
.
voter
.
verification
.
config
;
import
javax.jms.Queue
;
import
org.apache.activemq.command.ActiveMQQueue
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.integration.support.json.Jackson2JsonObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
/**
* Active MQ configuration file to register the Input and Output Queues to this application.
* @author rjosula
*
*/
@Configuration
public
class
ActiveMQConfig
{
private
final
String
VOTER_VEIFN_JSON_MESSAGE_QUEUE_NAME
=
"VoterJsonMessageQueue"
;
private
final
String
VOTER_VEIFN_XML_MESSAGE_QUEUE_NAME
=
"VoterXMLMessageQueue"
;
/**
* Voter Input Queue to read the messages
* @return
*/
@Bean
public
Queue
voterMessageQueue
()
{
return
new
ActiveMQQueue
(
VOTER_VEIFN_JSON_MESSAGE_QUEUE_NAME
);
}
/**
* Voter Input Queue to write the messages
* @return
*/
@Bean
public
Queue
voterOutputQueue
()
{
return
new
ActiveMQQueue
(
VOTER_VEIFN_XML_MESSAGE_QUEUE_NAME
);
}
/**
* Object mapper to convert JSON to Object (Java Object / XML Object/ any custom object)
* @return
*/
@Bean
public
static
Jackson2JsonObjectMapper
getMapper
()
{
ObjectMapper
mapper
=
new
ObjectMapper
();
return
new
Jackson2JsonObjectMapper
(
mapper
);
}
}
VoterProducerApi/src/main/java/com/voter/verification/config/MongoConfig.java
0 → 100644
View file @
16ee4e93
package
com
.
voter
.
verification
.
config
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.env.Environment
;
import
org.springframework.data.mongodb.MongoDbFactory
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.SimpleMongoDbFactory
;
import
com.mongodb.MongoClientURI
;
@Configuration
public
class
MongoConfig
{
@Autowired
private
Environment
env
;
@Bean
public
MongoDbFactory
mongoDbFactory
()
{
return
new
SimpleMongoDbFactory
(
new
MongoClientURI
(
env
.
getProperty
(
"spring.data.mongodb.uri"
)));
}
@Bean
public
MongoTemplate
mongoTemplate
()
{
MongoTemplate
mongoTemplate
=
new
MongoTemplate
(
mongoDbFactory
());
return
mongoTemplate
;
}
}
VoterProducerApi/src/main/java/com/voter/verification/controller/VoterVerificationController.java
0 → 100644
View file @
16ee4e93
package
com
.
voter
.
verification
.
controller
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.messaging.Message
;
import
org.springframework.messaging.MessageHeaders
;
import
org.springframework.messaging.support.MessageBuilder
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.voter.verification.gateway.VoterInformationGateway
;
/**
* Handler class to handle the person object to prepare the voter information
* based on the persons age list of voters shall be decided.
*
* @author rjosula
*
*/
@RestController
@RequestMapping
(
"/voter/verificationapp"
)
public
class
VoterVerificationController
{
@Autowired
private
VoterInformationGateway
voterInputGateway
;
/**
* Controller method recieves employee information json string which will be processed
* to verify whether the employee is eligible for voting or not.
* @return
*/
@RequestMapping
(
value
=
"/sendVoterInfo"
,
method
=
RequestMethod
.
POST
,
produces
=
{
"application/xml"
})
public
ResponseEntity
<?>
publishVoterInfo
(
@RequestBody
String
personString
)
{
Map
<
String
,
Object
>
headers
=
new
HashMap
<>();
headers
.
put
(
"content-type"
,
"application/json"
);
MessageHeaders
header
=
new
MessageHeaders
(
headers
);
Message
<
String
>
msg
=
MessageBuilder
.
createMessage
(
personString
,
header
);
voterInputGateway
.
sendToInputQ
(
msg
);
return
new
ResponseEntity
<
String
>(
"Published successfully"
,
HttpStatus
.
ACCEPTED
);
}
}
VoterProducerApi/src/main/java/com/voter/verification/dao/VoterDAO.java
0 → 100644
View file @
16ee4e93
package
com
.
voter
.
verification
.
dao
;
import
java.util.List
;
import
com.voter.verification.model.Voter
;
/**
* VoterDAO is an interface provides save or update of the Voter Information
* @author rjosula
*
*/
public
interface
VoterDAO
{
public
Voter
saveOrUpdateVoterInfo
(
Voter
voterObj
);
public
List
<
Voter
>
getListOfVoterInfo
(
Integer
id
);
}
VoterProducerApi/src/main/java/com/voter/verification/dao/VoterDAOImpl.java
0 → 100644
View file @
16ee4e93
package
com
.
voter
.
verification
.
dao
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.stereotype.Repository
;
import
com.voter.verification.model.Voter
;
/**
* Voter Repository Implementation class to operate the CRUD operations.
* @author rjosula
*
*/
@Repository
public
class
VoterDAOImpl
implements
VoterDAO
{
@Autowired
private
MongoTemplate
mongoTemplate
;
@Override
public
Voter
saveOrUpdateVoterInfo
(
Voter
voterObj
)
{
Voter
voterSavedObj
=
null
;
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"personId"
).
is
(
Integer
.
valueOf
(
voterObj
.
getpersonId
())));
try
{
Update
update
=
new
Update
();
update
.
set
(
"personId"
,
voterObj
.
getpersonId
());
update
.
set
(
"personAge"
,
voterObj
.
getpersonAge
());
update
.
set
(
"personName"
,
voterObj
.
getpersonName
());
update
.
set
(
"personAddress"
,
voterObj
.
getpersonAddress
());
update
.
set
(
"state"
,
voterObj
.
getState
());
voterSavedObj
=
mongoTemplate
.
findAndModify
(
query
,
update
,
Voter
.
class
);
if
(
voterSavedObj
==
null
)
{
voterSavedObj
=
mongoTemplate
.
save
(
voterObj
);
}
System
.
out
.
println
(
"Updated the information ... "
+
voterSavedObj
.
toString
());
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
return
voterSavedObj
;
}
@Override
public
List
<
Voter
>
getListOfVoterInfo
(
Integer
id
)
{
return
mongoTemplate
.
find
(
new
Query
().
addCriteria
(
Criteria
.
where
(
"personId"
).
is
(
id
)),
Voter
.
class
);
}
}
VoterProducerApi/src/main/java/com/voter/verification/gateway/VoterInformationGateway.java
0 → 100644
View file @
16ee4e93
package
com
.
voter
.
verification
.
gateway
;
import
org.springframework.messaging.Message
;
import
org.springframework.stereotype.Component
;
/**
* Gateway interface to accept the Voter Information Message
* @author rjosula
*
*/
@Component
public
interface
VoterInformationGateway
{
public
void
sendToInputQ
(
Message
<
String
>
voterJson
);
}
VoterProducerApi/src/main/java/com/voter/verification/model/Voter.java
0 → 100644
View file @
16ee4e93
package
com
.
voter
.
verification
.
model
;
import
java.io.Serializable
;
import
org.springframework.data.mongodb.core.mapping.Document
;
@Document
(
collection
=
"voterinformation"
)
public
class
Voter
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
private
int
personId
;
private
String
personName
;
private
int
personAge
;
private
String
personAddress
;
private
String
state
;
private
String
emailId
;
private
String
referenceId
;
public
int
getpersonId
()
{
return
personId
;
}
public
void
setpersonId
(
int
personId
)
{
this
.
personId
=
personId
;
}
public
String
getpersonName
()
{
return
personName
;
}
public
void
setpersonName
(
String
personName
)
{
this
.
personName
=
personName
;
}
public
int
getpersonAge
()
{
return
personAge
;
}
public
void
setpersonAge
(
int
personAge
)
{
this
.
personAge
=
personAge
;
}
public
String
getpersonAddress
()
{
return
personAddress
;
}
public
void
setpersonAddress
(
String
personAddress
)
{
this
.
personAddress
=
personAddress
;
}
public
String
getState
()
{
return
state
;
}
public
void
setState
(
String
state
)
{
this
.
state
=
state
;
}
public
Voter
()
{
}
public
String
getEmailId
()
{
return
emailId
;
}
public
void
setEmailId
(
String
emailId
)
{
this
.
emailId
=
emailId
;
}
public
String
getReferenceId
()
{
return
referenceId
;
}
public
void
setReferenceId
(
String
referenceId
)
{
this
.
referenceId
=
referenceId
;
}
public
Voter
(
int
personId
,
String
personName
,
int
personAge
,
String
personAddress
,
String
state
,
String
emailId
,
String
referenceId
)
{
super
();
this
.
personId
=
personId
;
this
.
personName
=
personName
;
this
.
personAge
=
personAge
;
this
.
personAddress
=
personAddress
;
this
.
state
=
state
;
this
.
emailId
=
emailId
;
this
.
referenceId
=
referenceId
;
}
@Override
public
String
toString
()
{
return
"Voter [personId="
+
personId
+
", personName="
+
personName
+
", personAge="
+
personAge
+
", personAddress="
+
personAddress
+
", state="
+
state
+
", emailId="
+
emailId
+
", referenceId="
+
referenceId
+
"]"
;
}
}
VoterProducerApi/src/main/java/com/voter/verification/model/VoterInformation.java
0 → 100644
View file @
16ee4e93
package
com
.
voter
.
verification
.
model
;
import
java.io.Serializable
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlRootElement
;
@XmlRootElement
(
name
=
"voterinformation"
)
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
VoterInformation
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
@XmlElement
(
name
=
"voterId"
)
private
int
voterId
;
@XmlElement
(
name
=
"voterName"
)
private
String
voterName
;
@XmlElement
(
name
=
"voterAddress"
)
private
String
voterAddress
;
@XmlElement
(
name
=
"voterProvince"
)
private
String
voterProvince
;
@XmlElement
(
name
=
"isEligible"
)
private
boolean
isEligible
;
@XmlElement
(
name
=
"voterage"
)
private
int
voterAge
;
@XmlElement
(
name
=
"referenceId"
)
private
String
referenceId
;
@XmlElement
(
name
=
"emailId"
)
private
String
emailId
;
public
void
setVoterId
(
int
voterId
)
{
this
.
voterId
=
voterId
;
}
public
void
setVoterName
(
String
voterName
)
{
this
.
voterName
=
voterName
;
}
public
void
setVoterAddress
(
String
voterAddress
)
{
this
.
voterAddress
=
voterAddress
;
}
public
void
setVoterProvince
(
String
voterProvince
)
{
this
.
voterProvince
=
voterProvince
;
}
public
void
setEligible
(
boolean
isEligible
)
{
this
.
isEligible
=
isEligible
;
}
public
int
getVoterAge
()
{
return
voterAge
;
}
public
void
setVoterAge
(
int
voterAge
)
{
this
.
voterAge
=
voterAge
;
}
public
String
getReferenceId
()
{
return
referenceId
;
}
public
void
setReferenceId
(
String
referenceId
)
{
this
.
referenceId
=
referenceId
;
}
public
String
getEmailId
()
{
return
emailId
;
}
public
void
setEmailId
(
String
emailId
)
{
this
.
emailId
=
emailId
;
}
//
// public int getVoterId() {
// return voterId;
// }
// public String getVoterName() {
// return voterName;
// }
//
// public String getVoterAddress() {
// return voterAddress;
// }
/*
* public String getVoterProvince() { return voterProvince; }
*/
/*
* public boolean isEligible() { return isEligible; }
*/
}
VoterProducerApi/src/main/java/com/voter/verification/model/VotersStatus.java
0 → 100644
View file @
16ee4e93
package
com
.
voter
.
verification
.
model
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* Statistics class which will store the eligible & ineligible voters.
* @author rjosula
*
*/
public
class
VotersStatus
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
private
int
noOfVotersEligible
;
private
int
noOfVotersInEligible
;
private
List
<
VoterInformation
>
eligibleVoters
;
private
List
<
VoterInformation
>
inEligibleVoters
;
public
int
getNoOfVotersEligible
()
{
return
noOfVotersEligible
;
}
public
void
setNoOfVotersEligible
(
int
noOfVotersEligible
)
{
this
.
noOfVotersEligible
=
noOfVotersEligible
;
}
public
int
getNoOfVotersInEligible
()
{
return
noOfVotersInEligible
;
}
public
void
setNoOfVotersInEligible
(
int
noOfVotersInEligible
)
{
this
.
noOfVotersInEligible
=
noOfVotersInEligible
;
}
public
List
<
VoterInformation
>
getEligibleVoters
()
{
return
eligibleVoters
;
}
public
void
setEligibleVoters
(
List
<
VoterInformation
>
eligibleVoters
)
{
this
.
eligibleVoters
=
eligibleVoters
;
}
public
List
<
VoterInformation
>
getInEligibleVoters
()
{
return
inEligibleVoters
;
}
public
void
setInEligibleVoters
(
List
<
VoterInformation
>
inEligibleVoters
)
{
this
.
inEligibleVoters
=
inEligibleVoters
;
}
@Override
public
String
toString
()
{
return
"VotersStatus [noOfVotersEligible="
+
noOfVotersEligible
+
", noOfVotersInEligible="
+
noOfVotersInEligible
+
", eligibleVoters="
+
eligibleVoters
.
size
()
+
", inEligibleVoters="
+
inEligibleVoters
.
size
()
+
"]"
;
}
}
VoterProducerApi/src/main/java/com/voter/verification/service/DummyActivator.java
0 → 100644
View file @
16ee4e93
package
com
.
voter
.
verification
.
service
;
import
org.springframework.messaging.Message
;
import
org.springframework.stereotype.Component
;
@Component
public
class
DummyActivator
{
public
Message
<
String
>
executeVoterCmd
(
Message
<
String
>
input
){
return
input
;
}
}
VoterProducerApi/src/main/java/com/voter/verification/service/VoterServiceActivator.java
0 → 100644
View file @
16ee4e93
package
com
.
voter
.
verification
.
service
;
import
java.io.StringWriter
;
import
javax.xml.transform.Source
;
import
javax.xml.transform.Transformer
;
import
javax.xml.transform.TransformerException
;
import
javax.xml.transform.TransformerFactory
;
import
javax.xml.transform.TransformerFactoryConfigurationError
;
import
javax.xml.transform.dom.DOMResult
;
import
javax.xml.transform.dom.DOMSource
;
import
javax.xml.transform.stream.StreamResult
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.messaging.Message
;
import
org.springframework.messaging.support.MessageBuilder
;
import
org.springframework.stereotype.Component
;
import
com.voter.verification.dao.VoterDAO
;
import
com.voter.verification.model.Voter
;
import
com.voter.verification.model.VoterInformation
;
/**
* Service activator to consume & apply business logic to transform from JSON to
* XML
*
* @author rjosula
*
*/
@Component
public
class
VoterServiceActivator
{
@Autowired
private
VoterDAO
voterDAO
;
/**
* Service activator method to receive the input message
*
* @param inputMesg
* @return
*/
public
Message
<
VoterInformation
>
mapPersonToVoter
(
Message
<
Voter
>
personMsg
)
{
System
.
out
.
println
(
"Inside service activator... "
+
personMsg
.
getPayload
());
Voter
voterInput
=
personMsg
.
getPayload
();
Voter
voterObjSaved
=
null
;
boolean
isPersonEligible
=
false
;
if
(
voterInput
.
getpersonAge
()
>=
18
)
{
isPersonEligible
=
true
;
}
/** Saving the information using DAO Layer*/
voterObjSaved
=
voterDAO
.
saveOrUpdateVoterInfo
(
voterInput
);
System
.
out
.
println
(
"Voter information has been successfully saved or updated!...."
+
voterObjSaved
.
toString
());
VoterInformation
voterInfo
=
new
VoterInformation
();
voterInfo
.
setVoterId
(
voterInput
.
getpersonId
());
voterInfo
.
setVoterName
(
voterInput
.
getpersonName
());
voterInfo
.
setVoterAddress
(
voterInput
.
getpersonAddress
());
voterInfo
.
setVoterProvince
(
voterInput
.
getState
());
voterInfo
.
setEligible
(
isPersonEligible
);
voterInfo
.
setVoterAge
(
voterInput
.
getpersonAge
());
voterInfo
.
setReferenceId
(
voterInput
.
getReferenceId
());
voterInfo
.
setEmailId
(
voterInput
.
getEmailId
());
return
MessageBuilder
.
withPayload
(
voterInfo
).
build
();
}
/**
* Takes input as DomResult XML and converts to XML String.
*
* @param inputJson
* @return
*/
public
String
voterXMLInput
(
Message
<
DOMResult
>
inputJson
)
{
DOMResult
payload
=
inputJson
.
getPayload
();
Transformer
transformer
;
Message
<
String
>
msgOutput
=
null
;
try
{
transformer
=
TransformerFactory
.
newInstance
().
newTransformer
();
StringWriter
writer
=
new
StringWriter
();
StreamResult
result
=
new
StreamResult
(
writer
);
Source
input
=
new
DOMSource
(
payload
.
getNode
());
transformer
.
transform
(
input
,
result
);
msgOutput
=
MessageBuilder
.
createMessage
(
result
.
getWriter
().
toString
(),
inputJson
.
getHeaders
());
}
catch
(
TransformerFactoryConfigurationError
|
TransformerException
e
)
{
e
.
printStackTrace
();
}
return
msgOutput
.
getPayload
();
}
}
VoterProducerApi/src/main/resources/VoterInformation.xsd
0 → 100644
View file @
16ee4e93
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema
xmlns:xs=
"http://www.w3.org/2001/XMLSchema"
>
<xs:element
name=
"voterinformation"
>
<xs:complexType>
<xs:sequence>
<xs:element
name=
"voterId"
maxOccurs=
"1"
minOccurs=
"1"
nillable=
"false"
>
<xs:simpleType>
<xs:restriction
base=
"xs:int"
/>
</xs:simpleType>
</xs:element>
<xs:element
name=
"voterName"
maxOccurs=
"1"
minOccurs=
"1"
nillable=
"false"
>
<xs:simpleType>
<xs:restriction
base=
"xs:string"
/>
</xs:simpleType>
</xs:element>
<xs:element
name=
"voterAddress"
maxOccurs=
"1"
minOccurs=
"1"
nillable=
"false"
>
<xs:simpleType>
<xs:restriction
base=
"xs:string"
/>
</xs:simpleType>
</xs:element>
<xs:element
name=
"voterProvince"
maxOccurs=
"1"
minOccurs=
"1"
nillable=
"false"
>
<xs:simpleType>
<xs:restriction
base=
"xs:string"
/>
</xs:simpleType>
</xs:element>
<xs:element
name=
"isEligible"
maxOccurs=
"1"
minOccurs=
"1"
nillable=
"false"
>
<xs:simpleType>
<xs:restriction
base=
"xs:boolean"
/>
</xs:simpleType>
</xs:element>
<xs:element
name=
"voterage"
maxOccurs=
"1"
minOccurs=
"1"
nillable=
"false"
>
<xs:simpleType>
<xs:restriction
base=
"xs:int"
/>
</xs:simpleType>
</xs:element>
<xs:element
name=
"referenceId"
maxOccurs=
"1"
minOccurs=
"1"
nillable=
"false"
>
<xs:simpleType>
<xs:restriction
base=
"xs:string"
/>
</xs:simpleType>
</xs:element>
<xs:element
name=
"emailId"
maxOccurs=
"1"
minOccurs=
"1"
nillable=
"false"
>
<xs:simpleType>
<xs:restriction
base=
"xs:string"
/>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
\ No newline at end of file
VoterProducerApi/src/main/resources/application.properties
0 → 100644
View file @
16ee4e93
spring.activemq.in-memory
=
true
spring.activemq.pool.enabled
=
false
spring.activemq.user
=
admin
spring.activemq.password
=
admin
spring.data.mongodb.uri
=
mongodb://voter:admin@localhost:27017/admin
VoterProducerApi/src/main/resources/voter-app-configuration.xml
0 → 100644
View file @
16ee4e93
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:jms=
"http://www.springframework.org/schema/integration/jms"
xmlns:integration=
"http://www.springframework.org/schema/integration"
xmlns:int-mongodb=
"http://www.springframework.org/schema/integration/mongodb"
xmlns:int=
"http://www.springframework.org/schema/integration"
xmlns:int-jdbc=
"http://www.springframework.org/schema/integration/jdbc"
xmlns:jdbc=
"http://www.springframework.org/schema/jdbc"
xmlns:int-xml=
"http://www.springframework.org/schema/integration/xml"
xmlns:p=
"http://www.springframework.org/schema/p"
xmlns:int-jms=
"http://www.springframework.org/schema/integration/jms"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
https://www.springframework.org/schema/integration/spring-integration.xsd
https://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-4.2.xsd
http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
http://www.springframework.org/schema/integration/mail http://www.springframework.org/schema/integration/mail/spring-integration-mail-4.2.xsd
http://www.springframework.org/schema/integration/xml http://www.springframework.org/schema/integration/xml/spring-integration-xml-4.2.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd
http://www.springframework.org/schema/integration/mongodb https://www.springframework.org/schema/integration/mongodb/spring-integration-mongodb.xsd
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream-4.2.xsd"
>
<int:channel
id=
"requestChannel"
/>
<int:channel
id=
"replyChannel"
/>
<int:channel
id=
"person.mapper.voting.out"
/>
<int:channel
id=
"person.mapper.voting.in"
/>
<!-- Bean declarations starts -->
<bean
id=
"jmsConnectionFactory"
class=
"org.apache.activemq.ActiveMQConnectionFactory"
p:brokerURL=
"tcp://localhost:61616"
p:trustAllPackages=
"true"
/>
<bean
id=
"jaxb2Marshaller"
class=
"org.springframework.oxm.jaxb.Jaxb2Marshaller"
>
<property
name=
"schema"
value=
"classpath:/VoterInformation.xsd"
/>
<property
name=
"packagesToScan"
>
<list>
<value>
com.voter.verification.model
</value>
</list>
</property>
</bean>
<bean
id =
"destRouter"
class=
"com.voter.verification.service.DummyActivator"
/>
<!-- Bean declarations ends -->
<!-- Gateway declarations starts -->
<int:gateway
id=
"gateway.id"
service-interface=
"com.voter.verification.gateway.VoterInformationGateway"
default-request-channel=
"requestChannel"
default-reply-channel=
"replyChannel"
/>
<int:json-to-object-transformer
id=
"jsonStringToPersonTrnsfrmer.eligible.person.id"
object-mapper=
"getMapper"
type=
"com.voter.verification.model.Voter"
input-channel=
"requestChannel"
output-channel=
"person.mapper.voting.out"
/>
<int:service-activator
id=
"service.activator.input.id"
input-channel=
"person.mapper.voting.out"
output-channel=
"person.mapper.voting.in"
ref=
"voterServiceActivator"
method=
"mapPersonToVoter"
/>
<int:chain
input-channel=
"person.mapper.voting.in"
output-channel=
"replyChannel"
>
<int-xml:marshalling-transformer
id=
"obj-to-xml-transformer"
marshaller=
"jaxb2Marshaller"
/>
<int:service-activator
id=
"service.activator.input.id.2"
ref=
"voterServiceActivator"
method=
"voterXMLInput"
/>
</int:chain>
<jms:outbound-channel-adapter
id=
"xmlQueue.id"
channel=
"replyChannel"
connection-factory=
"jmsConnectionFactory"
destination=
"voterOutputQueue"
/>
<!-- Bean definitions to be used for the integrations -->
</beans>
\ No newline at end of file
VoterProducerApi/src/test/java/com/voter/verification/VoterProducerApiApplicationTests.java
0 → 100644
View file @
16ee4e93
package
com
.
voter
.
verification
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
@SpringBootTest
class
VoterProducerApiApplicationTests
{
@Test
void
contextLoads
()
{
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment