1818
1919import java .util .Map ;
2020
21+ import org .energyos .espi .common .domain .IntervalBlock ;
2122import org .energyos .espi .common .models .atom .DateTimeType ;
2223import org .energyos .espi .common .models .atom .EntryType ;
2324
@@ -41,15 +42,61 @@ public boolean matches(EntryType entry) {
4142 }
4243 }
4344
45+ if (hasParam ("published-max" ) && hasParam ("published-min" )) {
46+ // check if this is an IntervalBlock
47+ if (entry .getContent ().getIntervalBlocks ()!=null && !entry .getContent ().getIntervalBlocks ().isEmpty ()){
48+ IntervalBlock ib1 = entry .getContent ().getIntervalBlocks ().get (0 );
49+ IntervalBlock ibn = entry .getContent ().getIntervalBlocks ().get (entry .getContent ().getIntervalBlocks ().size ()-1 );
50+
51+ long lStart = ib1 .getInterval ().getStart ();
52+ long lEnd = ibn .getInterval ().getStart () + ibn .getInterval ().getDuration ();
53+
54+ long lPubMin = toTime ("published-min" )/1000 ;
55+ long lPubMax = toTime ("published-max" )/1000 ;
56+
57+ if ((lStart >= lPubMin ) && (lEnd <= lPubMax )){
58+ emittedCounter ++;
59+ return true ; // cannot fall-through to the final return statement... must return here to bypass additional pub min,max checks
60+ } else {
61+ return false ;
62+ }
63+ } else {
64+ if ( (toTime ("published-max" ) < toTime (entry .getPublished ())) && (toTime ("published-min" ) > toTime (entry .getPublished ()))) {
65+ return false ;
66+ }
67+ }
68+ }
69+
4470 if (hasParam ("published-max" )) {
45- if (toTime ("published-max" ) < toTime (entry .getPublished ())) {
46- return false ;
71+ // check if this is an IntervalBlock
72+ if (entry .getContent ().getIntervalBlocks ()!=null && !entry .getContent ().getIntervalBlocks ().isEmpty ()){
73+ IntervalBlock ibn = entry .getContent ().getIntervalBlocks ().get (entry .getContent ().getIntervalBlocks ().size ()-1 );
74+
75+ long lEnd = ibn .getInterval ().getStart () + ibn .getInterval ().getDuration ();
76+
77+ if (toTime ("published-max" )/1000 < lEnd ){
78+ return false ;
79+ }
80+ } else {
81+ if (toTime ("published-max" ) < toTime (entry .getPublished ())) {
82+ return false ;
83+ }
4784 }
4885 }
4986
5087 if (hasParam ("published-min" )) {
51- if (toTime ("published-min" ) > toTime (entry .getPublished ())) {
52- return false ;
88+ // check if this is an IntervalBlock
89+ if (entry .getContent ().getIntervalBlocks ()!=null && !entry .getContent ().getIntervalBlocks ().isEmpty ()){
90+ IntervalBlock ib1 = entry .getContent ().getIntervalBlocks ().get (0 );
91+ long lStart = ib1 .getInterval ().getStart ();
92+
93+ if (toTime ("published-min" )/1000 > lStart ){
94+ return false ;
95+ }
96+ } else {
97+ if (toTime ("published-min" ) > toTime (entry .getPublished ())) {
98+ return false ;
99+ }
53100 }
54101 }
55102
0 commit comments