3535import org .efaps .admin .datamodel .SQLTable ;
3636import org .efaps .admin .datamodel .Status ;
3737import org .efaps .admin .datamodel .Type ;
38+ import org .efaps .admin .datamodel .attributetype .CreatedType ;
3839import org .efaps .admin .datamodel .attributetype .IAttributeType ;
3940import org .efaps .admin .datamodel .attributetype .LinkType ;
4041import org .efaps .admin .datamodel .attributetype .LongType ;
42+ import org .efaps .admin .datamodel .attributetype .ModifiedType ;
4143import org .efaps .admin .datamodel .attributetype .StatusType ;
4244import org .efaps .db .Instance ;
4345import org .efaps .db .stmt .selection .elements .LinktoElement ;
6163import org .efaps .eql2 .IWhereGroupTerm ;
6264import org .efaps .eql2 .IWhereSelect ;
6365import org .efaps .eql2 .IWhereTerm ;
66+ import org .efaps .util .DateTimeUtil ;
6467import org .efaps .util .EFapsException ;
6568import org .efaps .util .UUIDUtil ;
6669import org .efaps .util .cache .CacheReloadException ;
6770import org .slf4j .Logger ;
6871import org .slf4j .LoggerFactory ;
6972
73+ import com .ctc .wstx .shaded .msv_core .datatype .xsd .DateTimeType ;
74+
7075/**
7176 * The Class Filter.
7277 */
@@ -289,6 +294,7 @@ protected Section attribute(final SQLSelect _sqlSelect,
289294 protected Section status (final SQLSelect _sqlSelect ,
290295 final Connection connection ,
291296 final IWhereElement _element )
297+ throws EFapsException
292298 {
293299
294300 Section ret = null ;
@@ -342,6 +348,7 @@ protected Section attribute(final SQLSelect _sqlSelect,
342348 final Attribute _attr ,
343349 final Connection connection ,
344350 final IWhereElement _element )
351+ throws EFapsException
345352 {
346353 Section ret = null ;
347354 if (_attr != null ) {
@@ -354,9 +361,10 @@ protected Section attribute(final SQLSelect _sqlSelect,
354361 protected Section attribute (final SQLSelect _sqlSelect ,
355362 final Attribute _attr ,
356363 final Connection connection ,
357- final IWhereElement _element ,
364+ final IWhereElement element ,
358365 final TableIdx _tableIdx ,
359366 final boolean _nullable )
367+ throws EFapsException
360368 {
361369 Section ret = null ;
362370 if (_attr != null ) {
@@ -365,27 +373,32 @@ protected Section attribute(final SQLSelect _sqlSelect,
365373 final boolean noEscape ;
366374 final List <String > values ;
367375 if (attrType instanceof StatusType ) {
368- values = _element .getValuesList ().stream ()
376+ values = element .getValuesList ().stream ()
369377 .flatMap (val -> convertStatusValue (_attr , val ).stream ())
370378 .collect (Collectors .toList ());
371379 noEscape = true ;
372380 } else if (attrType instanceof LinkType ) {
373381 noEscape = true ;
374- values = _element .getValuesList ().stream ()
382+ values = element .getValuesList ().stream ()
375383 .map (this ::convertLinkValue )
376384 .collect (Collectors .toList ());
385+ } else if (attrType instanceof CreatedType || attrType instanceof ModifiedType
386+ || attrType .getClass ().equals (DateTimeType .class )) {
387+ final var dateTime = DateTimeUtil .toDBDateTime (element .getValues (0 ));
388+ values = Arrays .asList (dateTime .toString ());
389+ noEscape = false ;
377390 } else {
378391 noEscape = attrType instanceof LongType ;
379- values = Arrays .asList (_element .getValues ());
392+ values = Arrays .asList (element .getValues ());
380393 }
381394
382- if (_nullable && !Comparison .NULL .equals (_element .getComparison ())
383- && !Comparison .NOTNULL .equals (_element .getComparison ())) {
395+ if (_nullable && !Comparison .NULL .equals (element .getComparison ())
396+ && !Comparison .NOTNULL .equals (element .getComparison ())) {
384397 final Group group = new Group ().setConnection (Connection .AND );
385398 group .add (new Criteria ()
386399 .tableIndex (_tableIdx .getIdx ())
387400 .colName (_attr .getSqlColNames ().get (0 ))
388- .comparison (_element .getComparison ())
401+ .comparison (element .getComparison ())
389402 .values (new LinkedHashSet <>(values ))
390403 .escape (!noEscape )
391404 .connection (Connection .OR ));
@@ -399,7 +412,7 @@ protected Section attribute(final SQLSelect _sqlSelect,
399412 ret = new Criteria ()
400413 .tableIndex (_tableIdx .getIdx ())
401414 .colNames (_attr .getSqlColNames ())
402- .comparison (_element .getComparison ())
415+ .comparison (element .getComparison ())
403416 .values (new LinkedHashSet <>(values ))
404417 .escape (!noEscape )
405418 .connection (connection )
0 commit comments