HCI XmlSlurper Groovy在同一日期找不到job_information记录

问题描述 投票:0回答:1

我需要在job_information中找到事件Hire的记录。

def Message processData(Message message) {

//Get body from message 
def body = message.getBody(java.lang.String)
//Parse body
def queryCompoundEmployeeResponse = new XmlSlurper().parseText(body)

queryCompoundEmployeeResponse.CompoundEmployee.each{
  it.person.employment_information.each{
    def startDate = it.job_information.find{
      j->(j.event.text() == 'H') 
    }.start_date.text()
  }
}

但是,对于该员工,同一天有2条记录。并且find函数不返回任何内容。

有谁知道如何解决这个问题?

2 records at the same date image

groovy hana-cloud-platform sap-successfactors
1个回答
0
投票

不幸的是,我认为较少的人知道你在说什么,而且我没有任何来自员工组合的信息,这就是为什么我模拟了你的信息,并试图展示如何获得每个事件类型H,无论它是什么日期具有。

这应该搜索事件H并返回每个人 - 节点,无论日期是否彼此相等。

def stringXML = 
'<personDatabase>'+
        '  <person><firstName>John</firstName><lastName>Doe</lastName><created>2016-05-23T09:41:39.000Z</created><event>H</event></person>'+
        '  <person><firstName>Jane</firstName><lastName>Smith</lastName><created>2018-05-10T09:41:39.000Z</created><event>G</event></person>'+
        '  <person><firstName>Robert</firstName><lastName>Doe</lastName><created>2016-05-23T09:41:39.000Z</created><event>H</event></person>'+
'</personDatabase>'

def people = new XmlSlurper().parseText(stringXML)
people.person.findAll { p ->
    p.event.toString().equals('H')
}.each { p ->
    println p.created
}

这导致:

largeResult shortResult

根据您的需求进行调整。

直播:https://groovy-playground.appspot.com/?_sm_au_=iVVR2FSD4MsqWj30

© www.soinside.com 2019 - 2024. All rights reserved.