@Test public void fetchForEveryoneWithSearch() { ((JSONObject) request.get("query")).put("keywords", "eureka"); sut.fetch(request, 0L); context.assertIsSatisfied(); }
public List<Long> fetch(final JSONObject request, final Long userEntityId) { boolean unHandled = false; List<List<Long>> returnedDataSets = new ArrayList<List<Long>>(); JSONObject jsonQuery = request.getJSONObject("query"); if (jsonQuery.size() == 0 || (jsonQuery.size() == 1 && jsonQuery.containsKey("sortBy") && jsonQuery.getString("sortBy").equals( "date"))) { returnedDataSets.add(everyoneMapper.execute(null)); } else { for (Object objParam : jsonQuery.keySet()) { DomainMapper<Object, List<?>> mapper = mappers.get(objParam); if (mapper != null) { List<?> data = null; if (transformers.containsKey(objParam) && transformers.get(objParam) != null) { data = mapper.execute(transformers.get(objParam).transform(jsonQuery, userEntityId)); } else { data = mapper.execute(jsonQuery); } if (data.size() > 0) { if (data.get(0) instanceof List) { List<List<Long>> dataList = (List<List<Long>>) data; for (List<Long> subList : dataList) { returnedDataSets.add(subList); } } else { returnedDataSets.add((List<Long>) data); } } } else { unHandled = true; } } if (returnedDataSets.size() == 0) { return null; } } List<Long> returned = new ArrayList<Long>(); for (List<Long> dataSet : returnedDataSets) { Integer maxCount = request.getInt("count"); if (unHandled) { maxCount = MAXITEMS; } returned = orCollider.collide(dataSet, returned, maxCount); } return returned; }
PersistenceDataSource implements DescendingOrderDataSource { public List<Long> fetch(final JSONObject request, final Long userEntityId) { boolean unHandled = false; List<List<Long>> returnedDataSets = new ArrayList<List<Long>>(); JSONObject jsonQuery = request.getJSONObject("query"); if (jsonQuery.size() == 0 || (jsonQuery.size() == 1 && jsonQuery.containsKey("sortBy") && jsonQuery.getString("sortBy").equals( "date"))) { returnedDataSets.add(everyoneMapper.execute(null)); } else { for (Object objParam : jsonQuery.keySet()) { DomainMapper<Object, List<?>> mapper = mappers.get(objParam); if (mapper != null) { List<?> data = null; if (transformers.containsKey(objParam) && transformers.get(objParam) != null) { data = mapper.execute(transformers.get(objParam).transform(jsonQuery, userEntityId)); } else { data = mapper.execute(jsonQuery); } if (data.size() > 0) { if (data.get(0) instanceof List) { List<List<Long>> dataList = (List<List<Long>>) data; for (List<Long> subList : dataList) { returnedDataSets.add(subList); } } else { returnedDataSets.add((List<Long>) data); } } } else { unHandled = true; } } if (returnedDataSets.size() == 0) { return null; } } List<Long> returned = new ArrayList<Long>(); for (List<Long> dataSet : returnedDataSets) { Integer maxCount = request.getInt("count"); if (unHandled) { maxCount = MAXITEMS; } returned = orCollider.collide(dataSet, returned, maxCount); } return returned; } }
PersistenceDataSource implements DescendingOrderDataSource { public List<Long> fetch(final JSONObject request, final Long userEntityId) { boolean unHandled = false; List<List<Long>> returnedDataSets = new ArrayList<List<Long>>(); JSONObject jsonQuery = request.getJSONObject("query"); if (jsonQuery.size() == 0 || (jsonQuery.size() == 1 && jsonQuery.containsKey("sortBy") && jsonQuery.getString("sortBy").equals( "date"))) { returnedDataSets.add(everyoneMapper.execute(null)); } else { for (Object objParam : jsonQuery.keySet()) { DomainMapper<Object, List<?>> mapper = mappers.get(objParam); if (mapper != null) { List<?> data = null; if (transformers.containsKey(objParam) && transformers.get(objParam) != null) { data = mapper.execute(transformers.get(objParam).transform(jsonQuery, userEntityId)); } else { data = mapper.execute(jsonQuery); } if (data.size() > 0) { if (data.get(0) instanceof List) { List<List<Long>> dataList = (List<List<Long>>) data; for (List<Long> subList : dataList) { returnedDataSets.add(subList); } } else { returnedDataSets.add((List<Long>) data); } } } else { unHandled = true; } } if (returnedDataSets.size() == 0) { return null; } } List<Long> returned = new ArrayList<Long>(); for (List<Long> dataSet : returnedDataSets) { Integer maxCount = request.getInt("count"); if (unHandled) { maxCount = MAXITEMS; } returned = orCollider.collide(dataSet, returned, maxCount); } return returned; } PersistenceDataSource(final DomainMapper<Object, List<Long>> inEveryoneMapper,
            final HashMap<String, DomainMapper<Object, List<?>>> inMappers,
            final HashMap<String, PersistenceDataSourceRequestTransformer> inTransformers,
            final ListCollider inOrCollider); }
PersistenceDataSource implements DescendingOrderDataSource { public List<Long> fetch(final JSONObject request, final Long userEntityId) { boolean unHandled = false; List<List<Long>> returnedDataSets = new ArrayList<List<Long>>(); JSONObject jsonQuery = request.getJSONObject("query"); if (jsonQuery.size() == 0 || (jsonQuery.size() == 1 && jsonQuery.containsKey("sortBy") && jsonQuery.getString("sortBy").equals( "date"))) { returnedDataSets.add(everyoneMapper.execute(null)); } else { for (Object objParam : jsonQuery.keySet()) { DomainMapper<Object, List<?>> mapper = mappers.get(objParam); if (mapper != null) { List<?> data = null; if (transformers.containsKey(objParam) && transformers.get(objParam) != null) { data = mapper.execute(transformers.get(objParam).transform(jsonQuery, userEntityId)); } else { data = mapper.execute(jsonQuery); } if (data.size() > 0) { if (data.get(0) instanceof List) { List<List<Long>> dataList = (List<List<Long>>) data; for (List<Long> subList : dataList) { returnedDataSets.add(subList); } } else { returnedDataSets.add((List<Long>) data); } } } else { unHandled = true; } } if (returnedDataSets.size() == 0) { return null; } } List<Long> returned = new ArrayList<Long>(); for (List<Long> dataSet : returnedDataSets) { Integer maxCount = request.getInt("count"); if (unHandled) { maxCount = MAXITEMS; } returned = orCollider.collide(dataSet, returned, maxCount); } return returned; } PersistenceDataSource(final DomainMapper<Object, List<Long>> inEveryoneMapper,
            final HashMap<String, DomainMapper<Object, List<?>>> inMappers,
            final HashMap<String, PersistenceDataSourceRequestTransformer> inTransformers,
            final ListCollider inOrCollider); List<Long> fetch(final JSONObject request, final Long userEntityId); }
PersistenceDataSource implements DescendingOrderDataSource { public List<Long> fetch(final JSONObject request, final Long userEntityId) { boolean unHandled = false; List<List<Long>> returnedDataSets = new ArrayList<List<Long>>(); JSONObject jsonQuery = request.getJSONObject("query"); if (jsonQuery.size() == 0 || (jsonQuery.size() == 1 && jsonQuery.containsKey("sortBy") && jsonQuery.getString("sortBy").equals( "date"))) { returnedDataSets.add(everyoneMapper.execute(null)); } else { for (Object objParam : jsonQuery.keySet()) { DomainMapper<Object, List<?>> mapper = mappers.get(objParam); if (mapper != null) { List<?> data = null; if (transformers.containsKey(objParam) && transformers.get(objParam) != null) { data = mapper.execute(transformers.get(objParam).transform(jsonQuery, userEntityId)); } else { data = mapper.execute(jsonQuery); } if (data.size() > 0) { if (data.get(0) instanceof List) { List<List<Long>> dataList = (List<List<Long>>) data; for (List<Long> subList : dataList) { returnedDataSets.add(subList); } } else { returnedDataSets.add((List<Long>) data); } } } else { unHandled = true; } } if (returnedDataSets.size() == 0) { return null; } } List<Long> returned = new ArrayList<Long>(); for (List<Long> dataSet : returnedDataSets) { Integer maxCount = request.getInt("count"); if (unHandled) { maxCount = MAXITEMS; } returned = orCollider.collide(dataSet, returned, maxCount); } return returned; } PersistenceDataSource(final DomainMapper<Object, List<Long>> inEveryoneMapper,
            final HashMap<String, DomainMapper<Object, List<?>>> inMappers,
            final HashMap<String, PersistenceDataSourceRequestTransformer> inTransformers,
            final ListCollider inOrCollider); List<Long> fetch(final JSONObject request, final Long userEntityId);  }