Skip to content

Commit

Permalink
MID-4459 sorting in object tables now configurable. By default enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Feb 20, 2018
1 parent 3a83dfe commit 16631bb
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
Expand Up @@ -34,6 +34,8 @@
import com.evolveum.midpoint.web.security.MidPointApplication;
import com.evolveum.midpoint.wf.api.WorkflowManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AdminGuiConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.GuiObjectListType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.GuiObjectListsType;
import org.apache.commons.lang.Validate;
import org.apache.wicket.Component;
import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder;
Expand Down Expand Up @@ -187,9 +189,38 @@ public Boolean getObject() {
};
}

protected ObjectPaging createPaging(long offset, long pageSize) {
return ObjectPaging.createPaging(safeLongToInteger(offset), safeLongToInteger(pageSize), createObjectOrderings(getSort()));
}
protected boolean checkOrderingSettings() {
return false;
}

protected boolean isOrderingDisabled() {
PageBase page = (PageBase) component.getPage();
AdminGuiConfigurationType config = page.getPrincipal().getAdminGuiConfiguration();
if (config == null) {
return false;
}
GuiObjectListsType lists = config.getObjectLists();
if (lists == null) {
return false;
}

GuiObjectListType def = lists.getDefault();
if (def == null) {
return false;
}

return def.isDisableSorting();
}

protected ObjectPaging createPaging(long offset, long pageSize) {
Integer o = safeLongToInteger(offset);
Integer size = safeLongToInteger(pageSize);
List<ObjectOrdering> orderings = null;
if (!checkOrderingSettings() || !isOrderingDisabled()) {
orderings = createObjectOrderings(getSort());
}
return ObjectPaging.createPaging(o, size, orderings);
}

/**
* Could be overridden in subclasses.
Expand Down
Expand Up @@ -144,6 +144,11 @@ public Iterator<W> internalIterator(long first, long count) {
return getAvailableData().iterator();
}

@Override
protected boolean checkOrderingSettings() {
return true;
}

protected void handleNotSuccessOrHandledErrorInIterator(OperationResult result){
getPage().showResult(result);
throw new RestartResponseException(PageError.class);
Expand Down
Expand Up @@ -101,6 +101,11 @@ public Iterator<DebugObjectItem> internalIterator(long first, long count) {
return getAvailableData().iterator();
}

@Override
protected boolean checkOrderingSettings() {
return true;
}

private DebugObjectItem createItem(PrismObject<? extends ObjectType> object, OperationResult result) {
DebugObjectItem item = DebugObjectItem.createDebugObjectItem(object);
if (ShadowType.class.isAssignableFrom(object.getCompileTimeClass())) {
Expand Down
Expand Up @@ -127,7 +127,11 @@ private void preprocessSelectedDataInternal() {
}
}
}


@Override
protected boolean checkOrderingSettings() {
return true;
}

@Override
public Iterator<SelectableBean<O>> internalIterator(long offset, long pageSize) {
Expand Down
Expand Up @@ -17159,6 +17159,7 @@
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="default" type="tns:GuiObjectListType" minOccurs="0"/>
<xsd:element name="objectList" type="tns:GuiObjectListType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="includeDefaultLists" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="true">
<xsd:annotation>
Expand Down Expand Up @@ -17192,6 +17193,7 @@
<xsd:element name="column" type="tns:GuiObjectColumnType" minOccurs="0" maxOccurs="unbounded"/>
<!-- TODO: number of results per page (MID-1931) -->
<!-- TODO: later: export settings (GuiExportSettingsType) -->
<xsd:element name="disableSorting" type="xsd:boolean" default="false" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>

Expand Down

0 comments on commit 16631bb

Please sign in to comment.