The below code validates some bunch of variables/fields from a schema object, so here the requirement is I have two different schema objects which has common Fields/variables, Is it possible to validate these variables in more generic way. In below code there is two events FI & Profile (Note: Future can be more events like these) these are two different schema objects but has same fields/variables of same Object "Types", here is my code. Thank you!
How to validate common Validating variables/fields from multiple objects in more generic way?a schema object
How to validate common variables/fields from multiple objects in more generic way?
The below code validates some bunch of variables/fields from a schema object, so here the requirement is I have two different schema objects which has common Fields/variables, Is it possible to validate these variables in more generic way. In below code there is two events FI & Profile (Note: Future can be more events like these) these are two different schema objects but has same fields/variables of same Object "Types", here is my code. Thank you!
Validating variables/fields from a schema object
The below code validates some bunch of variables/fields from a schema object, so here the requirement is I have two different schema objects which has common Fields/variables, Is it possible to validate these variables in more generic way. In below code there is two events FI & Profile (Note: Future can be more events like these) these are two different schema objects but has same fields/variables of same Object "Types".
public class RequestValidation {
public class RequestValidation {
public void validateRequest(EventRequest eventRequest) {
//FI Event
FIEventProcessorImpl fiEventProcessor = new FIEventProcessorImpl();
FIEventSchema fiEvent = fiEventProcessor.getFiEventSchema(eventRequest);
//Party data Validation
String partyFName = null;
String partyLName = null;
String partyEmail = null;
String partyId = null;
if (null != fiEvent.getParty()) {
partyId = fiEvent.getParty().getPartyId();
if (null != fiEvent.getParty().getPartyName()
&& null != fiEvent.getParty().getPartyName().getName()) {
partyFName = fiEvent.getParty().getPartyName().getName().getGivenName();
partyLName = fiEvent.getParty().getPartyName().getName().getSurname();
if (null == partyFName && null == partyLName) {
Map<String, Object> nameMap = fiEvent.getParty().getPartyName().getName()
.getAdditionalProperties();
if (!nameMap.isEmpty()) {
partyFName = getAdditionalProperty(nameMap, "first_name");
partyLName = getAdditionalProperty(nameMap, "last_name");
}
}
}
if (null != fiEvent.getParty().getPartyEmail()) {
partyEmail = fiEvent.getParty().getPartyEmail().getEmailAddress();
if(null == partyEmail || partyEmail.isEmpty()){
//Logging missing field value logic
}
}
}
if (null !=== fiEventpartyFName || partyFName.getPartyisEmpty() || null == partyLName || partyLName.getPartyEmailisEmpty()
|| null == partyId || partyId.isEmpty()) {
partyEmail//Logging missing field value logic
}
//Application Context data Validation
String score = null;
String clientId = null;
if(null != fiEvent.getPartygetApplicationContext() && null != fiEvent.getPartyEmailgetApplicationContext().getEmailAddressgetContextItems()){
List<ContextItem> contextItems = fiEvent.getApplicationContext().getContextItems();
if(null ==!= partyEmailcontextItems ||&& partyEmail!contextItems.isEmpty()){
//LoggingsocialScore missing= fieldgetContextValue(contextItems, value"SCORE");
logic clientFp = getContextValue(contextItems, "CLIENT_ID");
}
}
}
if (null == partyFNamescore || partyFNamescore.isEmpty() || null == partyLNameclientId || partyLNameclientId.isEmpty()
|| null) =={
partyId || partyId.isEmpty()) {
//Logging missing field value logic
}
//Application Context data Validation
String score = null;
String clientId = null;
if(null != fiEvent.getApplicationContext() && null != fiEvent.getApplicationContext().getContextItems()){
List<ContextItem> contextItems = fiEvent.getApplicationContext().getContextItems();
if(null != contextItems && !contextItems.isEmpty()){
socialScore = getContextValue(contextItems, "SCORE");
clientFp = getContextValue(contextItems, "CLIENT_ID");
}
}
if
(null == score || score.isEmpty() || null == clientId || clientId.isEmpty()) {
//Logging missing field value logic
}
ProfileChange Event
//ProfileChange Event
ProfileProcessorImpl eventProcessor = new ProfileProcessorImpl();
ProfileEventSchema profileevent = eventProcessor.getProfileEventSchema(eventRequest);
//Party data Validation
if (null != profileevent.getParty()) {
partyId = profileevent.getParty().getPartyId();
if (null != profileevent.getParty().getPartyName()
&& null != profileevent.getParty().getPartyName().getName()) {
partyFName = profileevent.getParty().getPartyName().getName().getGivenName();
partyLName = profileevent.getParty().getPartyName().getName().getSurname();
if (null == partyFName && null == partyLName) {
Map<String, Object> nameMap = profileevent.getParty().getPartyName().getName()
.getAdditionalProperties();
if (!nameMap.isEmpty()) {
partyFName = getAdditionalProperty(nameMap, "first_name");
partyLName = getAdditionalProperty(nameMap, "last_name");
}
}
}
if (null != profileevent.getParty().getPartyEmail()) {
partyEmail = profileevent.getParty().getPartyEmail().getEmailAddress();
if(null == partyEmail || partyEmail.isEmpty()){
//Logging missing field value logic
}
}
}
if (null !=== profileevent.getParty()partyFName || partyFName.getPartyEmailisEmpty()) {
|| null == partyLName || partyLName.isEmpty()
partyEmail = profileevent.getParty().getPartyEmail().getEmailAddress();
|| if(null == partyEmailpartyId || partyEmailpartyId.isEmpty()) {
//Logging missing field value logic
}
//Application Context data Validation
if(null != profileevent.getApplicationContext() && null != profileevent.getApplicationContext().getContextItems()){
List<ContextItem> contextItems = profileevent.getApplicationContext().getContextItems();
if(null != contextItems && !contextItems.isEmpty()){
socialScore = getContextValue(contextItems, "SCORE");
clientFp = getContextValue(contextItems, "CLIENT_ID");
}
}
}
if (null == partyFNamescore || partyFNamescore.isEmpty() || null == partyLNameclientId || partyLNameclientId.isEmpty()
||) null{
== partyId || partyId.isEmpty()) {
//Logging missing field value logic
}
//Application Context data Validation
if(null != profileevent.getApplicationContext() && null != profileevent.getApplicationContext().getContextItems()){
List<ContextItem> contextItems = profileevent.getApplicationContext().getContextItems();
if(null != contextItems && !contextItems.isEmpty()){
socialScore = getContextValue(contextItems, "SCORE");
clientFp = getContextValue(contextItems, "CLIENT_ID");
}
}
if (null == score || score.isEmpty() || null == clientId || clientId.isEmpty()) {
//Logging missing field value logic}
}
}
private String getContextValue(List<ContextItem> contextItems, String key) {
String value = null;
for(ContextItem contextItem : contextItems){
if(contextItem.getKey().equalsIgnoreCase(key)){
value = contextItem.getValue();
}
}
return value.toString();
}
return value.toString();
}
private String getAdditionalProperty(Map<String, ?> map, String key) {
Object value = map.get(key);
return value == null ? null : value.toString();
}
}
}
public class RequestValidation {
public void validateRequest(EventRequest eventRequest) {
//FI Event
FIEventProcessorImpl fiEventProcessor = new FIEventProcessorImpl();
FIEventSchema fiEvent = fiEventProcessor.getFiEventSchema(eventRequest);
//Party data Validation
String partyFName = null;
String partyLName = null;
String partyEmail = null;
String partyId = null;
if (null != fiEvent.getParty()) {
partyId = fiEvent.getParty().getPartyId();
if (null != fiEvent.getParty().getPartyName()
&& null != fiEvent.getParty().getPartyName().getName()) {
partyFName = fiEvent.getParty().getPartyName().getName().getGivenName();
partyLName = fiEvent.getParty().getPartyName().getName().getSurname();
if (null == partyFName && null == partyLName) {
Map<String, Object> nameMap = fiEvent.getParty().getPartyName().getName()
.getAdditionalProperties();
if (!nameMap.isEmpty()) {
partyFName = getAdditionalProperty(nameMap, "first_name");
partyLName = getAdditionalProperty(nameMap, "last_name");
}
}
}
if (null != fiEvent.getParty().getPartyEmail()) {
partyEmail = fiEvent.getParty().getPartyEmail().getEmailAddress();
if(null == partyEmail || partyEmail.isEmpty()){
//Logging missing field value logic
}
}
}
if (null == partyFName || partyFName.isEmpty() || null == partyLName || partyLName.isEmpty()
|| null == partyId || partyId.isEmpty()) {
//Logging missing field value logic
}
//Application Context data Validation
String score = null;
String clientId = null;
if(null != fiEvent.getApplicationContext() && null != fiEvent.getApplicationContext().getContextItems()){
List<ContextItem> contextItems = fiEvent.getApplicationContext().getContextItems();
if(null != contextItems && !contextItems.isEmpty()){
socialScore = getContextValue(contextItems, "SCORE");
clientFp = getContextValue(contextItems, "CLIENT_ID");
}
}
if (null == score || score.isEmpty() || null == clientId || clientId.isEmpty()) {
//Logging missing field value logic
}
//ProfileChange Event
ProfileProcessorImpl eventProcessor = new ProfileProcessorImpl();
ProfileEventSchema profileevent = eventProcessor.getProfileEventSchema(eventRequest);
//Party data Validation
if (null != profileevent.getParty()) {
partyId = profileevent.getParty().getPartyId();
if (null != profileevent.getParty().getPartyName()
&& null != profileevent.getParty().getPartyName().getName()) {
partyFName = profileevent.getParty().getPartyName().getName().getGivenName();
partyLName = profileevent.getParty().getPartyName().getName().getSurname();
if (null == partyFName && null == partyLName) {
Map<String, Object> nameMap = profileevent.getParty().getPartyName().getName()
.getAdditionalProperties();
if (!nameMap.isEmpty()) {
partyFName = getAdditionalProperty(nameMap, "first_name");
partyLName = getAdditionalProperty(nameMap, "last_name");
}
}
}
if (null != profileevent.getParty().getPartyEmail()) {
partyEmail = profileevent.getParty().getPartyEmail().getEmailAddress();
if(null == partyEmail || partyEmail.isEmpty()){
//Logging missing field value logic
}
}
}
if (null == partyFName || partyFName.isEmpty() || null == partyLName || partyLName.isEmpty()
|| null == partyId || partyId.isEmpty()) {
//Logging missing field value logic
}
//Application Context data Validation
if(null != profileevent.getApplicationContext() && null != profileevent.getApplicationContext().getContextItems()){
List<ContextItem> contextItems = profileevent.getApplicationContext().getContextItems();
if(null != contextItems && !contextItems.isEmpty()){
socialScore = getContextValue(contextItems, "SCORE");
clientFp = getContextValue(contextItems, "CLIENT_ID");
}
}
if (null == score || score.isEmpty() || null == clientId || clientId.isEmpty()) {
//Logging missing field value logic
}
}
private String getContextValue(List<ContextItem> contextItems, String key) {
String value = null;
for(ContextItem contextItem : contextItems){
if(contextItem.getKey().equalsIgnoreCase(key)){
value = contextItem.getValue();
}
}
return value.toString();
}
private String getAdditionalProperty(Map<String, ?> map, String key) {
Object value = map.get(key);
return value == null ? null : value.toString();
}
}
public class RequestValidation {
public void validateRequest(EventRequest eventRequest) {
//FI Event
FIEventProcessorImpl fiEventProcessor = new FIEventProcessorImpl();
FIEventSchema fiEvent = fiEventProcessor.getFiEventSchema(eventRequest);
//Party data Validation
String partyFName = null;
String partyLName = null;
String partyEmail = null;
String partyId = null;
if (null != fiEvent.getParty()) {
partyId = fiEvent.getParty().getPartyId();
if (null != fiEvent.getParty().getPartyName()
&& null != fiEvent.getParty().getPartyName().getName()) {
partyFName = fiEvent.getParty().getPartyName().getName().getGivenName();
partyLName = fiEvent.getParty().getPartyName().getName().getSurname();
if (null == partyFName && null == partyLName) {
Map<String, Object> nameMap = fiEvent.getParty().getPartyName().getName()
.getAdditionalProperties();
if (!nameMap.isEmpty()) {
partyFName = getAdditionalProperty(nameMap, "first_name");
partyLName = getAdditionalProperty(nameMap, "last_name");
}
}
}
if (null != fiEvent.getParty().getPartyEmail()) {
partyEmail = fiEvent.getParty().getPartyEmail().getEmailAddress();
if(null == partyEmail || partyEmail.isEmpty()){
//Logging missing field value logic
}
}
}
if (null == partyFName || partyFName.isEmpty() || null == partyLName || partyLName.isEmpty()
|| null == partyId || partyId.isEmpty()) {
//Logging missing field value logic
}
//Application Context data Validation
String score = null;
String clientId = null;
if(null != fiEvent.getApplicationContext() && null != fiEvent.getApplicationContext().getContextItems()){
List<ContextItem> contextItems = fiEvent.getApplicationContext().getContextItems();
if(null != contextItems && !contextItems.isEmpty()){
socialScore = getContextValue(contextItems, "SCORE");
clientFp = getContextValue(contextItems, "CLIENT_ID");
}
}
if (null == score || score.isEmpty() || null == clientId || clientId.isEmpty()) {
//Logging missing field value logic
}
//ProfileChange Event
ProfileProcessorImpl eventProcessor = new ProfileProcessorImpl();
ProfileEventSchema profileevent = eventProcessor.getProfileEventSchema(eventRequest);
//Party data Validation
if (null != profileevent.getParty()) {
partyId = profileevent.getParty().getPartyId();
if (null != profileevent.getParty().getPartyName()
&& null != profileevent.getParty().getPartyName().getName()) {
partyFName = profileevent.getParty().getPartyName().getName().getGivenName();
partyLName = profileevent.getParty().getPartyName().getName().getSurname();
if (null == partyFName && null == partyLName) {
Map<String, Object> nameMap = profileevent.getParty().getPartyName().getName()
.getAdditionalProperties();
if (!nameMap.isEmpty()) {
partyFName = getAdditionalProperty(nameMap, "first_name");
partyLName = getAdditionalProperty(nameMap, "last_name");
}
}
}
if (null != profileevent.getParty().getPartyEmail()) {
partyEmail = profileevent.getParty().getPartyEmail().getEmailAddress();
if(null == partyEmail || partyEmail.isEmpty()){
//Logging missing field value logic
}
}
}
if (null == partyFName || partyFName.isEmpty() || null == partyLName || partyLName.isEmpty()
|| null == partyId || partyId.isEmpty()) {
//Logging missing field value logic
}
//Application Context data Validation
if(null != profileevent.getApplicationContext() && null != profileevent.getApplicationContext().getContextItems()){
List<ContextItem> contextItems = profileevent.getApplicationContext().getContextItems();
if(null != contextItems && !contextItems.isEmpty()){
socialScore = getContextValue(contextItems, "SCORE");
clientFp = getContextValue(contextItems, "CLIENT_ID");
}
}
if (null == score || score.isEmpty() || null == clientId || clientId.isEmpty()) {
//Logging missing field value logic
}
}
private String getContextValue(List<ContextItem> contextItems, String key) {
String value = null;
for(ContextItem contextItem : contextItems){
if(contextItem.getKey().equalsIgnoreCase(key)){
value = contextItem.getValue();
}
}
return value.toString();
}
private String getAdditionalProperty(Map<String, ?> map, String key) {
Object value = map.get(key);
return value == null ? null : value.toString();
}
}
The below code validates some bunch of variables/fields from a schema object, so here the requirement is I have two different schema objects which has common Fields/variables, Is it possible to validate these variables in more generic way. In below code there is two events FI & Profile (Note: Future can be more events like these) these are two different schema objects but has same fields/variables of same Object "Types", here is my code. Thank you!
public void validateRequest(EventRequest eventRequest) {
//FI Event
FIEventProcessorImpl fiEventProcessor = new FIEventProcessorImpl();
FIEventSchema fiEvent = fiEventProcessor.getFiEventSchema(eventRequest);
//Party data Validation
String partyFName = null;
String partyLName = null;
String partyEmail = null;
String partyId = null;
if (null != fiEvent.getParty()) {
partyId = fiEvent.getParty().getPartyId();
if (null != fiEvent.getParty().getPartyName()
&& null != fiEvent.getParty().getPartyName().getName()) {
partyFName = fiEvent.getParty().getPartyName().getName().getGivenName();
partyLName = fiEvent.getParty().getPartyName().getName().getSurname();
if (null == partyFName && null == partyLName) {
Map<String, Object> nameMap = fiEvent.getParty().getPartyName().getName()
.getAdditionalProperties();
if (!nameMap.isEmpty()) {
partyFName = getAdditionalProperty(nameMap, "first_name");
partyLName = getAdditionalProperty(nameMap, "last_name");
}
}
}
if (null != fiEvent.getParty().getPartyEmail()) {
partyEmail = fiEvent.getParty().getPartyEmail().getEmailAddress();
if(null == partyEmail || partyEmail.isEmpty()){
//Logging missing field value logic
}
}
}
if (null == partyFName || partyFName.isEmpty() || null == partyLName || partyLName.isEmpty()
|| null == partyId || partyId.isEmpty()) {
//Logging missing field value logic
}
//Application Context data Validation
String socialScorescore = null;
String clientFpclientId = null;
if(null != fiEvent.getApplicationContext() && null != fiEvent.getApplicationContext().getContextItems()){
List<ContextItem> contextItems = fiEvent.getApplicationContext().getContextItems();
if(null != contextItems && !contextItems.isEmpty()){
socialScore = getContextValue(contextItems, "SCORE");
clientFp = getContextValue(contextItems, "CLIENT_ID");
}
}
if (null == socialScorescore || socialScorescore.isEmpty() || null == clientFpclientId || clientFpclientId.isEmpty()) {
//Logging missing field value logic
}
//ProfileProfileChange Event
ProfileProcessorImpl eventProcessor = new ProfileProcessorImpl();
ProfileEventSchema profileevent = eventProcessor.getProfileEventSchema(eventRequest);
//Party data Validation
if (null != profileevent.getParty()) {
partyId = profileevent.getParty().getPartyId();
if (null != profileevent.getParty().getPartyName()
&& null != profileevent.getParty().getPartyName().getName()) {
partyFName = profileevent.getParty().getPartyName().getName().getGivenName();
partyLName = profileevent.getParty().getPartyName().getName().getSurname();
if (null == partyFName && null == partyLName) {
Map<String, Object> nameMap = profileevent.getParty().getPartyName().getName()
.getAdditionalProperties();
if (!nameMap.isEmpty()) {
partyFName = getAdditionalProperty(nameMap, "first_name");
partyLName = getAdditionalProperty(nameMap, "last_name");
}
}
}
if (null != profileevent.getParty().getPartyEmail()) {
partyEmail = profileevent.getParty().getPartyEmail().getEmailAddress();
if(null == partyEmail || partyEmail.isEmpty()){
//Logging missing field value logic
}
}
}
if (null == partyFName || partyFName.isEmpty() || null == partyLName || partyLName.isEmpty()
|| null == partyId || partyId.isEmpty()) {
//Logging missing field value logic
}
//Application Context data Validation
if(null != profileevent.getApplicationContext() && null != profileevent.getApplicationContext().getContextItems()){
List<ContextItem> contextItems = profileevent.getApplicationContext().getContextItems();
if(null != contextItems && !contextItems.isEmpty()){
socialScore = getContextValue(contextItems, "SCORE");
clientFp = getContextValue(contextItems, "CLIENT_ID");
}
}
if (null == socialScorescore || socialScorescore.isEmpty() || null == clientFpclientId || clientFpclientId.isEmpty()) {
//Logging missing field value logic
}
}
private String getContextValue(List<ContextItem> contextItems, String key) {
String value = null;
for(ContextItem contextItem : contextItems){
if(contextItem.getKey().equalsIgnoreCase(key)){
value = contextItem.getValue();
}
}
return value.toString();
}
private String getAdditionalProperty(Map<String, ?> map, String key) {
Object value = map.get(key);
return value == null ? null : value.toString();
}
The below code validates some bunch of variables/fields from a schema object, so here the requirement is I have two different schema objects which has common Fields/variables, Is it possible to validate these variables in more generic way, here is my code. Thank you!
public void validateRequest(EventRequest eventRequest) {
//FI Event
FIEventProcessorImpl fiEventProcessor = new FIEventProcessorImpl();
FIEventSchema fiEvent = fiEventProcessor.getFiEventSchema(eventRequest);
//Party data Validation
String partyFName = null;
String partyLName = null;
String partyEmail = null;
String partyId = null;
if (null != fiEvent.getParty()) {
partyId = fiEvent.getParty().getPartyId();
if (null != fiEvent.getParty().getPartyName()
&& null != fiEvent.getParty().getPartyName().getName()) {
partyFName = fiEvent.getParty().getPartyName().getName().getGivenName();
partyLName = fiEvent.getParty().getPartyName().getName().getSurname();
if (null == partyFName && null == partyLName) {
Map<String, Object> nameMap = fiEvent.getParty().getPartyName().getName()
.getAdditionalProperties();
if (!nameMap.isEmpty()) {
partyFName = getAdditionalProperty(nameMap, "first_name");
partyLName = getAdditionalProperty(nameMap, "last_name");
}
}
}
if (null != fiEvent.getParty().getPartyEmail()) {
partyEmail = fiEvent.getParty().getPartyEmail().getEmailAddress();
if(null == partyEmail || partyEmail.isEmpty()){
//Logging missing field value logic
}
}
}
if (null == partyFName || partyFName.isEmpty() || null == partyLName || partyLName.isEmpty()
|| null == partyId || partyId.isEmpty()) {
//Logging missing field value logic
}
//Application Context data Validation
String socialScore = null;
String clientFp = null;
if(null != fiEvent.getApplicationContext() && null != fiEvent.getApplicationContext().getContextItems()){
List<ContextItem> contextItems = fiEvent.getApplicationContext().getContextItems();
if(null != contextItems && !contextItems.isEmpty()){
socialScore = getContextValue(contextItems, "SCORE");
clientFp = getContextValue(contextItems, "CLIENT_ID");
}
}
if (null == socialScore || socialScore.isEmpty() || null == clientFp || clientFp.isEmpty()) {
//Logging missing field value logic
}
//Profile Event
ProfileProcessorImpl eventProcessor = new ProfileProcessorImpl();
ProfileEventSchema profileevent = eventProcessor.getProfileEventSchema(eventRequest);
//Party data Validation
if (null != profileevent.getParty()) {
partyId = profileevent.getParty().getPartyId();
if (null != profileevent.getParty().getPartyName()
&& null != profileevent.getParty().getPartyName().getName()) {
partyFName = profileevent.getParty().getPartyName().getName().getGivenName();
partyLName = profileevent.getParty().getPartyName().getName().getSurname();
if (null == partyFName && null == partyLName) {
Map<String, Object> nameMap = profileevent.getParty().getPartyName().getName()
.getAdditionalProperties();
if (!nameMap.isEmpty()) {
partyFName = getAdditionalProperty(nameMap, "first_name");
partyLName = getAdditionalProperty(nameMap, "last_name");
}
}
}
if (null != profileevent.getParty().getPartyEmail()) {
partyEmail = profileevent.getParty().getPartyEmail().getEmailAddress();
if(null == partyEmail || partyEmail.isEmpty()){
//Logging missing field value logic
}
}
}
if (null == partyFName || partyFName.isEmpty() || null == partyLName || partyLName.isEmpty()
|| null == partyId || partyId.isEmpty()) {
//Logging missing field value logic
}
//Application Context data Validation
if(null != profileevent.getApplicationContext() && null != profileevent.getApplicationContext().getContextItems()){
List<ContextItem> contextItems = profileevent.getApplicationContext().getContextItems();
if(null != contextItems && !contextItems.isEmpty()){
socialScore = getContextValue(contextItems, "SCORE");
clientFp = getContextValue(contextItems, "CLIENT_ID");
}
}
if (null == socialScore || socialScore.isEmpty() || null == clientFp || clientFp.isEmpty()) {
//Logging missing field value logic
}
}
private String getContextValue(List<ContextItem> contextItems, String key) {
String value = null;
for(ContextItem contextItem : contextItems){
if(contextItem.getKey().equalsIgnoreCase(key)){
value = contextItem.getValue();
}
}
return value.toString();
}
private String getAdditionalProperty(Map<String, ?> map, String key) {
Object value = map.get(key);
return value == null ? null : value.toString();
}
The below code validates some bunch of variables/fields from a schema object, so here the requirement is I have two different schema objects which has common Fields/variables, Is it possible to validate these variables in more generic way. In below code there is two events FI & Profile (Note: Future can be more events like these) these are two different schema objects but has same fields/variables of same Object "Types", here is my code. Thank you!
public void validateRequest(EventRequest eventRequest) {
//FI Event
FIEventProcessorImpl fiEventProcessor = new FIEventProcessorImpl();
FIEventSchema fiEvent = fiEventProcessor.getFiEventSchema(eventRequest);
//Party data Validation
String partyFName = null;
String partyLName = null;
String partyEmail = null;
String partyId = null;
if (null != fiEvent.getParty()) {
partyId = fiEvent.getParty().getPartyId();
if (null != fiEvent.getParty().getPartyName()
&& null != fiEvent.getParty().getPartyName().getName()) {
partyFName = fiEvent.getParty().getPartyName().getName().getGivenName();
partyLName = fiEvent.getParty().getPartyName().getName().getSurname();
if (null == partyFName && null == partyLName) {
Map<String, Object> nameMap = fiEvent.getParty().getPartyName().getName()
.getAdditionalProperties();
if (!nameMap.isEmpty()) {
partyFName = getAdditionalProperty(nameMap, "first_name");
partyLName = getAdditionalProperty(nameMap, "last_name");
}
}
}
if (null != fiEvent.getParty().getPartyEmail()) {
partyEmail = fiEvent.getParty().getPartyEmail().getEmailAddress();
if(null == partyEmail || partyEmail.isEmpty()){
//Logging missing field value logic
}
}
}
if (null == partyFName || partyFName.isEmpty() || null == partyLName || partyLName.isEmpty()
|| null == partyId || partyId.isEmpty()) {
//Logging missing field value logic
}
//Application Context data Validation
String score = null;
String clientId = null;
if(null != fiEvent.getApplicationContext() && null != fiEvent.getApplicationContext().getContextItems()){
List<ContextItem> contextItems = fiEvent.getApplicationContext().getContextItems();
if(null != contextItems && !contextItems.isEmpty()){
socialScore = getContextValue(contextItems, "SCORE");
clientFp = getContextValue(contextItems, "CLIENT_ID");
}
}
if (null == score || score.isEmpty() || null == clientId || clientId.isEmpty()) {
//Logging missing field value logic
}
//ProfileChange Event
ProfileProcessorImpl eventProcessor = new ProfileProcessorImpl();
ProfileEventSchema profileevent = eventProcessor.getProfileEventSchema(eventRequest);
//Party data Validation
if (null != profileevent.getParty()) {
partyId = profileevent.getParty().getPartyId();
if (null != profileevent.getParty().getPartyName()
&& null != profileevent.getParty().getPartyName().getName()) {
partyFName = profileevent.getParty().getPartyName().getName().getGivenName();
partyLName = profileevent.getParty().getPartyName().getName().getSurname();
if (null == partyFName && null == partyLName) {
Map<String, Object> nameMap = profileevent.getParty().getPartyName().getName()
.getAdditionalProperties();
if (!nameMap.isEmpty()) {
partyFName = getAdditionalProperty(nameMap, "first_name");
partyLName = getAdditionalProperty(nameMap, "last_name");
}
}
}
if (null != profileevent.getParty().getPartyEmail()) {
partyEmail = profileevent.getParty().getPartyEmail().getEmailAddress();
if(null == partyEmail || partyEmail.isEmpty()){
//Logging missing field value logic
}
}
}
if (null == partyFName || partyFName.isEmpty() || null == partyLName || partyLName.isEmpty()
|| null == partyId || partyId.isEmpty()) {
//Logging missing field value logic
}
//Application Context data Validation
if(null != profileevent.getApplicationContext() && null != profileevent.getApplicationContext().getContextItems()){
List<ContextItem> contextItems = profileevent.getApplicationContext().getContextItems();
if(null != contextItems && !contextItems.isEmpty()){
socialScore = getContextValue(contextItems, "SCORE");
clientFp = getContextValue(contextItems, "CLIENT_ID");
}
}
if (null == score || score.isEmpty() || null == clientId || clientId.isEmpty()) {
//Logging missing field value logic
}
}
private String getContextValue(List<ContextItem> contextItems, String key) {
String value = null;
for(ContextItem contextItem : contextItems){
if(contextItem.getKey().equalsIgnoreCase(key)){
value = contextItem.getValue();
}
}
return value.toString();
}
private String getAdditionalProperty(Map<String, ?> map, String key) {
Object value = map.get(key);
return value == null ? null : value.toString();
}