Reputation: 11
I am trying to loop through a complex list with Start and End DateTime properties and return a list of durations. Using a FEEL expression for t in Times return t.End - t.Start
it returns null.
To verify that I was pulling back the correct values I just returned t.End
and the expected DateTime returned.
Next, I tried the same thing but removed the list from the complex object Time.End - Time.Start
a duration object returns as expected.
{
"Times": [
{
"Start": "2024-06-05T11:35:02.534Z",
"End": "2024-06-05T11:40:02.534Z"
},
{
"Start": "2024-06-05T11:35:02.534Z",
"End": "2024-06-05T11:45:02.534Z"
}
],
"Time": {
"Start": "2024-06-05T11:35:02.534Z",
"End": "2024-06-05T11:40:02.534Z"
}
}
<?xml version="1.0" encoding="UTF-8"?>
<dmn:definitions xmlns:dmn="http://www.omg.org/spec/DMN/20180521/MODEL/" xmlns="https://kiegroup.org/dmn/_6B49457F-BD43-44B8-A8D1-C16C038AF388" xmlns:feel="http://www.omg.org/spec/DMN/20180521/FEEL/" xmlns:kie="http://www.drools.org/kie/dmn/1.2" xmlns:dmndi="http://www.omg.org/spec/DMN/20180521/DMNDI/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" id="_6D154B1D-07A7-45FB-8072-5CF69CB00FE5" name="Tester" typeLanguage="http://www.omg.org/spec/DMN/20180521/FEEL/" namespace="https://kiegroup.org/dmn/_6B49457F-BD43-44B8-A8D1-C16C038AF388">
<dmn:extensionElements/>
<dmn:itemDefinition id="_32787051-6A12-4E8B-9660-29D507705E74" name="tTimes" isCollection="true">
<dmn:itemComponent id="_05BFFE04-32F4-4C50-9D09-769769DDC843" name="Start" isCollection="false">
<dmn:typeRef>date and time</dmn:typeRef>
</dmn:itemComponent>
<dmn:itemComponent id="_434FDD08-E9E2-4A21-88F9-388812F5B8C9" name="End" isCollection="false">
<dmn:typeRef>date and time</dmn:typeRef>
</dmn:itemComponent>
</dmn:itemDefinition>
<dmn:itemDefinition id="_21E922DF-5B8D-475E-B623-E6F7A7EDD431" name="tTime" isCollection="false">
<dmn:itemComponent id="_8814111B-8DA8-47CD-80EC-EA1505D47BCB" name="Start" isCollection="false">
<dmn:typeRef>date and time</dmn:typeRef>
</dmn:itemComponent>
<dmn:itemComponent id="_847C3435-1A87-4480-B831-34535015CB99" name="End" isCollection="false">
<dmn:typeRef>date and time</dmn:typeRef>
</dmn:itemComponent>
</dmn:itemDefinition>
<dmn:inputData id="_D9E2AF83-1AED-4D85-81A2-6D59ACDBAC40" name="Times">
<dmn:extensionElements/>
<dmn:variable id="_539A4E07-D776-4FDB-846E-7D8B12D6F8D8" name="Times" typeRef="tTimes"/>
</dmn:inputData>
<dmn:decision id="_147DD60D-E174-4B3B-9C35-A429F0579CB9" name="Durations">
<dmn:extensionElements/>
<dmn:variable id="_2F30572C-E7C5-4B99-851A-1BADDDC9C30E" name="Durations" typeRef="Any"/>
<dmn:informationRequirement id="_ECE5C11A-757A-407D-9F5B-697E051D5A13">
<dmn:requiredInput href="#_D9E2AF83-1AED-4D85-81A2-6D59ACDBAC40"/>
</dmn:informationRequirement>
<dmn:literalExpression id="_20333D57-43F5-43E4-AC58-8AAE36BC85F2">
<dmn:text>for t in Times
return t.End - t.Start</dmn:text>
</dmn:literalExpression>
</dmn:decision>
<dmn:inputData id="_78ACBCC1-676A-4D7F-8EE4-9B133A3CE231" name="Time">
<dmn:extensionElements/>
<dmn:variable id="_3646CB83-CE3D-4806-913D-DBE43D72FD5E" name="Time" typeRef="tTime"/>
</dmn:inputData>
<dmn:decision id="_08F0D84D-4813-46E7-9A9D-E2745E1BDBF5" name="Duration">
<dmn:extensionElements/>
<dmn:variable id="_9C554CEE-F0C9-4CEE-B068-3741A4B68184" name="Duration" typeRef="days and time duration"/>
<dmn:informationRequirement id="_4B6DEFEF-89FA-4C48-8022-4D306A53074D">
<dmn:requiredInput href="#_78ACBCC1-676A-4D7F-8EE4-9B133A3CE231"/>
</dmn:informationRequirement>
<dmn:literalExpression id="_F9CB76A7-9D1D-49B0-9A79-5BC8D8E80D25">
<dmn:text>Time.End - Time.Start</dmn:text>
</dmn:literalExpression>
</dmn:decision>
<dmndi:DMNDI>
<dmndi:DMNDiagram id="_5858630C-D84E-4CF8-A9D0-A45135368536" name="DRG">
<di:extension>
<kie:ComponentsWidthsExtension>
<kie:ComponentWidths dmnElementRef="_20333D57-43F5-43E4-AC58-8AAE36BC85F2">
<kie:width>520</kie:width>
</kie:ComponentWidths>
<kie:ComponentWidths dmnElementRef="_F9CB76A7-9D1D-49B0-9A79-5BC8D8E80D25">
<kie:width>524</kie:width>
</kie:ComponentWidths>
</kie:ComponentsWidthsExtension>
</di:extension>
<dmndi:DMNShape id="dmnshape-drg-_D9E2AF83-1AED-4D85-81A2-6D59ACDBAC40" dmnElementRef="_D9E2AF83-1AED-4D85-81A2-6D59ACDBAC40" isCollapsed="false">
<dmndi:DMNStyle>
<dmndi:FillColor red="255" green="255" blue="255"/>
<dmndi:StrokeColor red="0" green="0" blue="0"/>
<dmndi:FontColor red="0" green="0" blue="0"/>
</dmndi:DMNStyle>
<dc:Bounds x="342" y="329" width="100" height="50"/>
<dmndi:DMNLabel/>
</dmndi:DMNShape>
<dmndi:DMNShape id="dmnshape-drg-_147DD60D-E174-4B3B-9C35-A429F0579CB9" dmnElementRef="_147DD60D-E174-4B3B-9C35-A429F0579CB9" isCollapsed="false">
<dmndi:DMNStyle>
<dmndi:FillColor red="255" green="255" blue="255"/>
<dmndi:StrokeColor red="0" green="0" blue="0"/>
<dmndi:FontColor red="0" green="0" blue="0"/>
</dmndi:DMNStyle>
<dc:Bounds x="343" y="229" width="100" height="50"/>
<dmndi:DMNLabel/>
</dmndi:DMNShape>
<dmndi:DMNShape id="dmnshape-drg-_78ACBCC1-676A-4D7F-8EE4-9B133A3CE231" dmnElementRef="_78ACBCC1-676A-4D7F-8EE4-9B133A3CE231" isCollapsed="false">
<dmndi:DMNStyle>
<dmndi:FillColor red="255" green="255" blue="255"/>
<dmndi:StrokeColor red="0" green="0" blue="0"/>
<dmndi:FontColor red="0" green="0" blue="0"/>
</dmndi:DMNStyle>
<dc:Bounds x="512" y="329" width="100" height="50"/>
<dmndi:DMNLabel/>
</dmndi:DMNShape>
<dmndi:DMNShape id="dmnshape-drg-_08F0D84D-4813-46E7-9A9D-E2745E1BDBF5" dmnElementRef="_08F0D84D-4813-46E7-9A9D-E2745E1BDBF5" isCollapsed="false">
<dmndi:DMNStyle>
<dmndi:FillColor red="255" green="255" blue="255"/>
<dmndi:StrokeColor red="0" green="0" blue="0"/>
<dmndi:FontColor red="0" green="0" blue="0"/>
</dmndi:DMNStyle>
<dc:Bounds x="513" y="229" width="100" height="50"/>
<dmndi:DMNLabel/>
</dmndi:DMNShape>
<dmndi:DMNEdge id="dmnedge-drg-_ECE5C11A-757A-407D-9F5B-697E051D5A13" dmnElementRef="_ECE5C11A-757A-407D-9F5B-697E051D5A13">
<di:waypoint x="392" y="354"/>
<di:waypoint x="393" y="279"/>
</dmndi:DMNEdge>
<dmndi:DMNEdge id="dmnedge-drg-_4B6DEFEF-89FA-4C48-8022-4D306A53074D" dmnElementRef="_4B6DEFEF-89FA-4C48-8022-4D306A53074D">
<di:waypoint x="562" y="354"/>
<di:waypoint x="563" y="279"/>
</dmndi:DMNEdge>
</dmndi:DMNDiagram>
</dmndi:DMNDI>
</dmn:definitions>
So, in summary, when I have a structured object with a Start Datetime and End Datetime I can return a duration with "Time.End - Time.Start", but I can't do the same for a complex list "for t in Times return t.End - t.Start. Given the above Times object how can I loop through the list and return the a list of durations?
Upvotes: 1
Views: 42
Reputation: 267
Hi it should be possible, I am sending picture with successful evaluation. Please notice I have used date and time function to be sure string is converted to date and time data type.
Upvotes: 0