use of com.blazebit.persistence.view.Sorter in project blaze-persistence by Blazebit.
the class SorterTest method testAscendingNullFirst.
@Test
public void testAscendingNullFirst() {
Sorter sorter = Sorters.sorter(true, true);
verifySorter(sorter).orderBy(expression, true, true);
}
use of com.blazebit.persistence.view.Sorter in project blaze-persistence by Blazebit.
the class EntityViewSettingHelper method applyAttributeSorters.
private static <T, Q extends FullQueryBuilder<T, Q>> void applyAttributeSorters(EntityViewSetting<?, ?> setting, Q cb, String viewRoot, Set<String> fetches, ManagedViewTypeImplementor<?> entityViewRoot) {
String name = entityViewRoot.getJavaType().getSimpleName();
StringBuilder sb = null;
for (Map.Entry<String, Sorter> attributeSorterEntry : setting.getAttributeSorters().entrySet()) {
String attributeName = attributeSorterEntry.getKey();
NavigableMap<String, AbstractMethodAttribute<?, ?>> recursiveAttributes = (NavigableMap<String, AbstractMethodAttribute<?, ?>>) entityViewRoot.getRecursiveAttributes();
Map.Entry<String, AbstractMethodAttribute<?, ?>> entry = recursiveAttributes.floorEntry(attributeName);
if (entry == null || !attributeName.startsWith(entry.getKey())) {
throw new IllegalArgumentException("The attribute with the name '" + attributeName + "' couldn't be found on the view type '" + name + "'");
}
if (attributeName.length() != entry.getKey().length()) {
throw new UnsupportedOperationException("No support yet for entity attribute filtering!");
// // If we get here, the attribute type is a managed type and we can copy the rest of the parts
// for (; i < parts.length; i++) {
// type = jpaMetamodel.managedType(maybeUnmanagedType);
// newSb.append('.');
// newSb.append(parts[i]);
// jpaAttribute = type.getAttribute(parts[i]);
// maybeUnmanagedType = jpaAttribute.getJavaType();
// }
}
Sorter sorter = attributeSorterEntry.getValue();
if (sb == null) {
sb = new StringBuilder(name.length() + attributeName.length() + 1);
} else {
sb.setLength(0);
}
String attributeExpression;
if (fetches.isEmpty() || fetches.contains(attributeName)) {
attributeExpression = buildAlias(sb, name, attributeName);
} else {
attributeExpression = buildMapping(sb, cb, viewRoot, recursiveAttributes, attributeName);
}
sorter.apply(cb, attributeExpression);
}
}
use of com.blazebit.persistence.view.Sorter in project blaze-persistence by Blazebit.
the class SorterTest method testDescendingNullFirst.
@Test
public void testDescendingNullFirst() {
Sorter sorter = Sorters.sorter(false, true);
verifySorter(sorter).orderBy(expression, false, true);
}
use of com.blazebit.persistence.view.Sorter in project blaze-persistence by Blazebit.
the class SorterTest method testDescendingNullLast.
@Test
public void testDescendingNullLast() {
Sorter sorter = Sorters.sorter(false, false);
verifySorter(sorter).orderBy(expression, false, false);
}
use of com.blazebit.persistence.view.Sorter in project blaze-persistence by Blazebit.
the class SorterTest method testAscendingNullLast.
@Test
public void testAscendingNullLast() {
Sorter sorter = Sorters.sorter(true, false);
verifySorter(sorter).orderBy(expression, true, false);
}
Aggregations