core/src/main/java/com/capitalone/dashboard/repository/CustomRepositoryQueryImpl.java
//TODO: This needs to be re-thought out.
This needs to be re-thought out.
This needs to be re - thought out .
public List<CollectorItem> findCollectorItemsBySubsetOptionsWithNullCheck(ObjectId id, Map<String, Object> allOptions, Map<String, Object> selectOptions) {
        Criteria c = Criteria.where("collectorId").is(id);
        for (Map.Entry<String, Object> e : allOptions.entrySet()) {
            if (selectOptions.containsKey(e.getKey())) {
                c = c.and("options." + e.getKey()).is(selectOptions.get(e.getKey()));
            } else {
                switch (e.getValue().getClass().getSimpleName()) {
                    case "String":
                        c = c.and("options." + e.getKey()).is(null);
                        break;
                    case "Integer":
                        c = c.and("options." + e.getKey()).is(null);
                        break;
                    case "Long":
                        c = c.and("options." + e.getKey()).is(null);
                        break;
                    case "Double":
                        c = c.and("options." + e.getKey()).is(null);
                        break;
                    case "Boolean":
                        c = c.and("options." + e.getKey()).is(null);
                        break;
                    default:
                        c = c.and("options." + e.getKey()).is(null);
                        break;
                }
            }
        }
        return template.find(new Query(c), CollectorItem.class);
    }
public List < CollectorItem > findCollectorItemsBySubsetOptionsWithNullCheck ( ObjectId id , Map < String , Object > allOptions , Map < String , Object > selectOptions ) { Criteria c = Criteria . where ( "collectorId" ) . is ( id ) ; for ( Map . Entry < String , Object > e : allOptions . entrySet ( ) ) { if ( selectOptions . containsKey ( e . getKey ( ) ) ) { c = c . and ( "options." + e . getKey ( ) ) . is ( selectOptions . get ( e . getKey ( ) ) ) ; } else { switch ( e . getValue ( ) . getClass ( ) . getSimpleName ( ) ) { case "String" : c = c . and ( "options." + e . getKey ( ) ) . is ( null ) ; break ; case "Integer" : c = c . and ( "options." + e . getKey ( ) ) . is ( null ) ; break ; case "Long" : c = c . and ( "options." + e . getKey ( ) ) . is ( null ) ; break ; case "Double" : c = c . and ( "options." + e . getKey ( ) ) . is ( null ) ; break ; case "Boolean" : c = c . and ( "options." + e . getKey ( ) ) . is ( null ) ; break ; default : c = c . and ( "options." + e . getKey ( ) ) . is ( null ) ; break ; } } } return template . find ( new Query ( c ) , CollectorItem . class ) ; }
TODO: This needs to be re-thought out.
TODO : This needs to be re - thought out .