List of usage examples for org.springframework.data.domain Sort toString
@Override
public String toString()
From source file:com.epam.ta.reportportal.core.widget.content.CasesTrendContentLoader.java
/** * Calculation of differences in one group or in overall array of items * //from w ww .jav a 2s. co m * @param initial * @param sorting * @return */ private Map<String, List<ChartObject>> calculateDiffs(List<ChartObject> initial, Sort sorting) { if (initial.isEmpty()) return new HashMap<>(); if (sorting.toString().contains(Sort.Direction.DESC.name())) { Integer previous = Integer .valueOf(initial.get(initial.size() - 1).getValues().get(getTotalFieldName())); for (int i = initial.size() - 1; i >= 0; i--) { Integer current = Integer.valueOf(initial.get(i).getValues().get(getTotalFieldName())); initial.get(i).getValues().put(DELTA, String.valueOf(current - previous)); previous = current; } } else { Integer previous = Integer.valueOf(initial.get(0).getValues().get(getTotalFieldName())); for (ChartObject anInitial : initial) { Integer current = Integer.valueOf(anInitial.getValues().get(getTotalFieldName())); anInitial.getValues().put(DELTA, String.valueOf(current - previous)); previous = current; } } Map<String, List<ChartObject>> result = new HashMap<>(); result.put(RESULT, initial); return result; }
From source file:com.epam.ta.reportportal.core.widget.content.CasesTrendContentLoader.java
/** * Calculation of group differences between TOTAL parameter of items * /* w w w . j a v a 2s. c o m*/ * @param initial * @param sorting * @return */ private Map<String, List<ChartObject>> calculateGroupedDiffs(Map<String, List<ChartObject>> initial, Sort sorting) { if (initial.keySet().isEmpty()) return new HashMap<>(); if (sorting.toString().contains(Sort.Direction.ASC.name())) { ArrayList<String> keys = new ArrayList<>(initial.keySet()); /* Last element in map */ Integer previous = Integer .valueOf(initial.get(keys.get(keys.size() - 1)).get(0).getValues().get(getTotalFieldName())); /* Iteration in reverse order */ for (int i = keys.size() - 1; i >= 0; i--) { Integer current = Integer .valueOf(initial.get(keys.get(i)).get(0).getValues().get(getTotalFieldName())); initial.get(keys.get(i)).get(0).getValues().put(DELTA, String.valueOf(current - previous)); previous = current; } } else { Integer previous = Integer.valueOf( initial.get(initial.keySet().iterator().next()).get(0).getValues().get(getTotalFieldName())); for (Map.Entry<String, List<ChartObject>> entry : initial.entrySet()) { Integer current = Integer.valueOf(entry.getValue().get(0).getValues().get(getTotalFieldName())); entry.getValue().get(0).getValues().put(DELTA, String.valueOf(current - previous)); previous = current; } } return initial; }
From source file:cn.guoyukun.spring.jpa.repository.RepositoryHelper.java
/** * ?//from w w w. jav a 2s .com * * @param sort * @return */ public String prepareOrder(Sort sort) { if (sort == null || !sort.iterator().hasNext()) { return ""; } StringBuilder orderBy = new StringBuilder(""); orderBy.append(" order by "); orderBy.append(sort.toString().replace(":", " ")); return orderBy.toString(); }