{
\"EmployeeId\": \"1\",
\"CompanyId\": \"1\",
\"FirstName\": \"SPENCER\",
\"LastName\": \"LIN\"
\"Status\": {
\"Code\": \"A\",
\"Description\": \"Active\"
},
\"BenefitClass\": null,
\"SupervisorId\": null,
\"SupervisorFirstName\": null,
\"SupervisorLastName\": null,
\"CostCenters\": [
{
\"Code\": \"01\",
\"Description\": \"Corporate\"
}
]
}
I was able to print the results of the value in DB, like below:
/*****************************************this is the employeeId returned from DB.**************************************/
def returntripDB = getEmployeeFromDB(db,jsonRes)
returned DB value[[Id:1], [Id:113], [Id:129], [Id:130], [Id:131], [Id:134], [Id:136], [Id:140], [Id:143]]
public def getEmployeeFromDB(def database,jsonRes)
{
def query = \"SELECT Id FROM [mydb].[mydb].[etable] order by etableid asc\"
// log.info \"QUERY for all employee id only \"+query
return database.rows(query)
}
I want to iterate through the reponse and compare the values to the DB. How can i do this?
","kudosSumWeight":0,"postTime":"2016-03-17T16:04:08.246-07:00","images":{"__typename":"AssociatedImageConnection","edges":[],"totalCount":0,"pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null}},"attachments":{"__typename":"AttachmentConnection","pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null},"edges":[]},"tags":{"__typename":"TagConnection","pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null},"edges":[]},"timeToRead":1,"currentRevision":{"__ref":"Revision:revision:116038_1"},"latestVersion":null,"metrics":{"__typename":"MessageMetrics","views":7636},"read":false,"visibilityScope":"PUBLIC","canonicalUrl":null,"seoTitle":null,"seoDescription":null,"isEscalated":null,"placeholder":false,"originalMessageForPlaceholder":null,"messagePolicies":{"__typename":"MessagePolicies","canModerateSpamMessage":{"__typename":"PolicyResult","failureReason":{"__typename":"FailureReason","message":"error.lithium.policies.feature.moderation_spam.action.moderate_entity.allowed.accessDenied","key":"error.lithium.policies.feature.moderation_spam.action.moderate_entity.allowed.accessDenied","args":[]}}},"archivalData":null,"customFields":[]},"Conversation:conversation:116038":{"__typename":"Conversation","id":"conversation:116038","solved":true,"topic":{"__ref":"ForumTopicMessage:message:116038"},"lastPostingActivityTime":"2016-03-22T07:51:06.563-07:00","lastPostTime":"2016-03-22T07:51:06.563-07:00","unreadReplyCount":14,"isSubscribed":false},"ModerationData:moderation_data:116038":{"__typename":"ModerationData","id":"moderation_data:116038","status":"APPROVED","rejectReason":null,"isReportedAbuse":false,"rejectUser":null,"rejectTime":null,"rejectActorType":null},"Revision:revision:116038_1":{"__typename":"Revision","id":"revision:116038_1","lastEditTime":"2016-03-17T16:04:08.246-07:00"},"AcceptedSolutionMessage:message:116194":{"__typename":"AcceptedSolutionMessage","id":"message:116194","conversation":{"__ref":"Conversation:conversation:116038"},"author":{"__ref":"User:user:21201"},"entityType":"FORUM_REPLY","eventPath":"category:ready_api_forums/community:nwkab66374board:readyapi-questions/message:116038/message:116194","revisionNum":1,"uid":116194,"depth":9,"hasGivenKudo":false,"subscribed":false,"board":{"__ref":"Forum:board:readyapi-questions"},"parent":{"__ref":"ForumReplyMessage:message:116167"},"subject":"Re: Compare response to table values","moderationData":{"__ref":"ModerationData:moderation_data:116194"},"body":"Looks like your case is similar except that data is in json instead of xmllets please stick to the original question... folks can you please help me on this its been 3 days and am hunting for the solution. This morning I have 2 issues my iterator of the reponse isnt printing results
1.my iterator is not printing result which it did earlier
jsonRes.Items.EmployeeId.each
{
//groovy iterator
def valueOfEmployee=it.value
log.info myResponsevalues
}
Issue 2 : how do i add the results of database return and the above to an arrays and compare the results. Hit a blank wall.please help
","body@stringLength":"584","rawBody":"lets please stick to the original question... folks can you please help me on this its been 3 days and am hunting for the solution. This morning I have 2 issues my iterator of the reponse isnt printing results
1.my iterator is not printing result which it did earlier
jsonRes.Items.EmployeeId.each
{
//groovy iterator
def valueOfEmployee=it.value
log.info myResponsevalues
}
Issue 2 : how do i add the results of database return and the above to an arrays and compare the results. Hit a blank wall.please help
","isEscalated":null,"postTime":"2016-03-21T06:14:00.000-07:00","solution":false,"customFields":[],"attachments":{"__typename":"AttachmentConnection","edges":[],"pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null}}},"ModerationData:moderation_data:116194":{"__typename":"ModerationData","id":"moderation_data:116194","status":"APPROVED","rejectReason":null,"isReportedAbuse":false,"rejectUser":null,"rejectTime":null,"rejectActorType":null},"Rank:rank:26":{"__typename":"Rank","id":"rank:26","position":9,"name":"Community Hero","color":"00537C","icon":null,"rankStyle":"OUTLINE"},"ModerationData:moderation_data:116167":{"__typename":"ModerationData","id":"moderation_data:116167","status":"APPROVED","rejectReason":null},"Revision:revision:116194_1":{"__typename":"Revision","id":"revision:116194_1","lastEditTime":"2016-03-21T10:34:03.537-07:00"},"QueryVariables:ReplyList:message:116194:1":{"__typename":"QueryVariables","id":"ReplyList:message:116194:1","value":{"id":"message:116194","sorts":{"kudosSumWeight":{"direction":"DESC","order":0},"postTime":{"direction":"ASC","order":1}},"useAvatar":true,"useAuthorLogin":true,"useAuthorRank":true,"useBody":true,"useKudosCount":true,"useTimeToRead":false,"useMedia":false,"useReadOnlyIcon":false,"useRepliesCount":false,"useSearchSnippet":false,"useAcceptedSolutionButton":true,"useSolvedBadge":false,"useAttachments":false,"attachmentsFirst":5,"useTags":false,"useNodeAncestors":false,"useUserHoverCard":false,"useNodeHoverCard":false,"useModerationStatus":true,"usePreviewSubjectModal":false,"useMessageStatus":true}},"CachedAsset:text:en_US-shared/client/components/users/UserAvatar-1749758931278":{"__typename":"CachedAsset","id":"text:en_US-shared/client/components/users/UserAvatar-1749758931278","value":{"altText":"{login}'s avatar","altTextGeneric":"User's avatar"},"localOverride":false},"CachedAsset:text:en_US-shared/client/components/ranks/UserRankLabel-1749758931278":{"__typename":"CachedAsset","id":"text:en_US-shared/client/components/ranks/UserRankLabel-1749758931278","value":{"altTitle":"Icon for {rankName} rank"},"localOverride":false},"CachedAsset:text:en_US-components/common/ExternalLinkWarningModal-1749758931278":{"__typename":"CachedAsset","id":"text:en_US-components/common/ExternalLinkWarningModal-1749758931278","value":{"title":"Leaving the Community","description":"You're about to leave this site and navigate to an external domain. Are you sure you want to continue?","action.submit":"Continue","action.cancel":"Go Back"},"localOverride":false},"CachedAsset:text:en_US-components/messages/AcceptedSolutionButton-1749758931278":{"__typename":"CachedAsset","id":"text:en_US-components/messages/AcceptedSolutionButton-1749758931278","value":{"accept":"Mark as Solution","accepted":"Marked as Solution","errorHeader":"Error!","errorAdd":"There was an error marking as solution.","errorRemove":"There was an error unmarking as solution.","solved":"Solved","topicAlreadySolvedErrorTitle":"Solution Already Exists","topicAlreadySolvedErrorDesc":"Refresh the browser to view the existing solution"},"localOverride":false},"CachedAsset:text:en_US-components/messages/LinearReplyList-1749758931278":{"__typename":"CachedAsset","id":"text:en_US-components/messages/LinearReplyList-1749758931278","value":{"title":"{count, plural, one{# Reply} other{# Replies}}","title@board:BLOG":"{count, plural, one{# Comment} other{# Comments}}","title@board:TKB":"{count, plural, one{# Comment} other{# Comments}}","title@board:IDEA":"{count, plural, one{# Comment} other{# Comments}}","title@board:OCCASION":"{count, plural, one{# Comment} other{# Comments}}","noRepliesTitle":"No Replies","noRepliesTitle@board:BLOG":"No Comments","noRepliesTitle@board:TKB":"No Comments","noRepliesTitle@board:IDEA":"No Comments","noRepliesTitle@board:OCCASION":"No Comments","noRepliesDescription":"Be the first to reply","noRepliesDescription@board:BLOG":"Be the first to comment","noRepliesDescription@board:TKB":"Be the first to comment","noRepliesDescription@board:OCCASION":"Be the first to comment","noRepliesDescription@board:IDEA":"Be the first to comment","messageReadOnlyAlert:BLOG":"Comments have been turned off for this post","messageReadOnlyAlert:TKB":"Comments have been turned off for this article","messageReadOnlyAlert:IDEA":"Comments have been turned off for this idea","messageReadOnlyAlert:FORUM":"Replies have been turned off for this discussion","messageReadOnlyAlert:OCCASION":"Comments have been turned off for this event"},"localOverride":false},"ModerationData:moderation_data:116200":{"__typename":"ModerationData","id":"moderation_data:116200","status":"APPROVED","rejectReason":null,"isReportedAbuse":false,"rejectUser":null,"rejectTime":null,"rejectActorType":null},"ForumReplyMessage:message:116200":{"__typename":"ForumReplyMessage","author":{"__ref":"User:user:69680"},"id":"message:116200","entityType":"FORUM_REPLY","eventPath":"category:ready_api_forums/community:nwkab66374board:readyapi-questions/message:116038/message:116200","revisionNum":1,"uid":116200,"depth":10,"hasGivenKudo":false,"subscribed":false,"board":{"__ref":"Forum:board:readyapi-questions"},"parent":{"__ref":"AcceptedSolutionMessage:message:116194"},"conversation":{"__ref":"Conversation:conversation:116038"},"subject":"Re: Compare response to table values","moderationData":{"__ref":"ModerationData:moderation_data:116200"},"body":"that was a helpful post thanks Rao.
this is what i have so far
/******* Create a Array and add all employeeIds from reponse*******/
def responseList = []
jsonRes.Items.EmployeeId.each {
responseList.add(it.value) //'it' is the name of the default iterator created by the .each()
//log.info \"all the employee ids in reponse in array\"+responseList
}
/******* Create a Array and add all employeeIds from Database*******/
def empIdFromDB = []
returntripDB.each {
empIdFromDB.add(it.value)
// log.info \"all the employee ids in reponse in array\"+empIdFromDB
}
//sorting the Data before checking for equality
def a = responseList.sort()
log.info \"all the employee ids in reponse in array\"+a
def b = empIdFromDB.sort()
log.info \"all the employee ids in DB in array\"+b
BUT the result am getting is not what i want: below is the result
all the employee ids in reponse in array[29, 2, 6, 1, 4, 3, 5]
all the employee ids in DB in array[ , ,, , ], 6, ,, ,, ,, 4, 9, 5, , , 2, [, , , ,, ,, 2, 3, 1]
Why is it not sorting the data.Also why is the DB results all screwed up?.
","body@stripHtml({\"removeProcessingText\":false,\"removeSpoilerMarkup\":false,\"removeTocMarkup\":false,\"truncateLength\":200})@stringLength":"223","kudosSumWeight":0,"postTime":"2016-03-21T12:52:56.932-07:00","lastPublishTime":"2016-03-21T12:52:56.932-07:00","metrics":{"__typename":"MessageMetrics","views":1664},"visibilityScope":"PUBLIC","placeholder":false,"showMoveIndicator":false,"originalMessageForPlaceholder":null,"isEscalated":null,"solution":false,"repliesCount":4,"readOnly":false,"attachments":{"__typename":"AttachmentConnection","edges":[],"pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null}},"customFields":[]},"ModerationData:moderation_data:116206":{"__typename":"ModerationData","id":"moderation_data:116206","status":"APPROVED","rejectReason":null,"isReportedAbuse":false,"rejectUser":null,"rejectTime":null,"rejectActorType":null},"ForumReplyMessage:message:116206":{"__typename":"ForumReplyMessage","author":{"__ref":"User:user:21201"},"id":"message:116206","entityType":"FORUM_REPLY","eventPath":"category:ready_api_forums/community:nwkab66374board:readyapi-questions/message:116038/message:116206","revisionNum":1,"uid":116206,"depth":11,"hasGivenKudo":false,"subscribed":false,"board":{"__ref":"Forum:board:readyapi-questions"},"parent":{"__ref":"ForumReplyMessage:message:116200"},"conversation":{"__ref":"Conversation:conversation:116038"},"subject":"Re: Compare response to table values","moderationData":{"__ref":"ModerationData:moderation_data:116206"},"body":"It appears that db is returning results as list some times. So it is adding list when you add, inside of a list. Please check it.","body@stripHtml({\"removeProcessingText\":false,\"removeSpoilerMarkup\":false,\"removeTocMarkup\":false,\"truncateLength\":200})@stringLength":"129","kudosSumWeight":0,"postTime":"2016-03-21T18:23:41.744-07:00","lastPublishTime":"2016-03-21T18:23:41.744-07:00","metrics":{"__typename":"MessageMetrics","views":1671},"visibilityScope":"PUBLIC","placeholder":false,"showMoveIndicator":false,"originalMessageForPlaceholder":null,"isEscalated":null,"solution":false,"repliesCount":3,"readOnly":false,"attachments":{"__typename":"AttachmentConnection","edges":[],"pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null}},"customFields":[]},"ModerationData:moderation_data:116246":{"__typename":"ModerationData","id":"moderation_data:116246","status":"APPROVED","rejectReason":null,"isReportedAbuse":false,"rejectUser":null,"rejectTime":null,"rejectActorType":null},"ForumReplyMessage:message:116246":{"__typename":"ForumReplyMessage","author":{"__ref":"User:user:69680"},"id":"message:116246","entityType":"FORUM_REPLY","eventPath":"category:ready_api_forums/community:nwkab66374board:readyapi-questions/message:116038/message:116246","revisionNum":1,"uid":116246,"depth":12,"hasGivenKudo":false,"subscribed":false,"board":{"__ref":"Forum:board:readyapi-questions"},"parent":{"__ref":"ForumReplyMessage:message:116206"},"conversation":{"__ref":"Conversation:conversation:116038"},"subject":"Re: Compare response to table values","moderationData":{"__ref":"ModerationData:moderation_data:116246"},"body":"
Iam sorry but iam seeking answer since am not a groovy expert. All i know is i am capturing results in a array.
please help.
","body@stripHtml({\"removeProcessingText\":false,\"removeSpoilerMarkup\":false,\"removeTocMarkup\":false,\"truncateLength\":200})@stringLength":"135","kudosSumWeight":0,"postTime":"2016-03-22T05:35:53.557-07:00","lastPublishTime":"2016-03-22T05:35:53.557-07:00","metrics":{"__typename":"MessageMetrics","views":1666},"visibilityScope":"PUBLIC","placeholder":false,"showMoveIndicator":false,"originalMessageForPlaceholder":null,"isEscalated":null,"solution":false,"repliesCount":2,"readOnly":false,"attachments":{"__typename":"AttachmentConnection","edges":[],"pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null}},"customFields":[]},"ModerationData:moderation_data:116256":{"__typename":"ModerationData","id":"moderation_data:116256","status":"APPROVED","rejectReason":null,"isReportedAbuse":false,"rejectUser":null,"rejectTime":null,"rejectActorType":null},"ForumReplyMessage:message:116256":{"__typename":"ForumReplyMessage","author":{"__ref":"User:user:21201"},"id":"message:116256","entityType":"FORUM_REPLY","eventPath":"category:ready_api_forums/community:nwkab66374board:readyapi-questions/message:116038/message:116256","revisionNum":1,"uid":116256,"depth":13,"hasGivenKudo":false,"subscribed":false,"board":{"__ref":"Forum:board:readyapi-questions"},"parent":{"__ref":"ForumReplyMessage:message:116246"},"conversation":{"__ref":"Conversation:conversation:116038"},"subject":"Re: Compare response to table values","moderationData":{"__ref":"ModerationData:moderation_data:116256"},"body":"With given details, it is difficult to provide exact solution that works with your data.what information do you need ?.
","body@stripHtml({\"removeProcessingText\":false,\"removeSpoilerMarkup\":false,\"removeTocMarkup\":false,\"truncateLength\":200})@stringLength":"33","kudosSumWeight":0,"postTime":"2016-03-22T07:51:06.563-07:00","lastPublishTime":"2016-03-22T07:51:06.563-07:00","metrics":{"__typename":"MessageMetrics","views":1661},"visibilityScope":"PUBLIC","placeholder":false,"showMoveIndicator":false,"originalMessageForPlaceholder":null,"isEscalated":null,"solution":false,"repliesCount":0,"attachments":{"__typename":"AttachmentConnection","edges":[],"pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null}},"customFields":[]}}}},"page":"/forums/ForumMessagePage/ForumMessagePage","query":{"boardId":"readyapi-questions","messageSubject":"compare-response-to-table-values","messageId":"116038","replyId":"116194"},"buildId":"3XH0qYWYCnEYycuN5W4S8","runtimeConfig":{"buildInformationVisible":false,"logLevelApp":"info","logLevelMetrics":"info","surveysEnabled":true,"openTelemetry":{"clientEnabled":false,"configName":"smartbear","serviceVersion":"25.4.0","universe":"prod","collector":"http://localhost:4318","logLevel":"error","routeChangeAllowedTime":"5000","headers":"","enableDiagnostic":"false","maxAttributeValueLength":"4095"},"apolloDevToolsEnabled":false,"quiltLazyLoadThreshold":"3"},"isFallback":false,"isExperimentalCompile":false,"dynamicIds":["components_seo_QAPageSchema","components_community_Navbar_NavbarWidget","components_community_Breadcrumb_BreadcrumbWidget","components_messages_TopicWithThreadedReplyListWidget","components_messages_MessageListForNodeByRecentActivityWidget","components_messages_RelatedContentWidget","components_customComponent_CustomComponent","components_messages_MessageView_MessageViewStandard","components_messages_EscalatedMessageBanner","shared_client_components_common_List_UnstyledList","components_messages_MessageView","components_messages_MessageView_MessageViewInline","shared_client_components_common_Pager_PagerLoadMore","components_customComponent_CustomComponentContent_TemplateContent"],"appGip":true,"scriptLoader":[]}