Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Sep 18, 2019
2 parents 35e8453 + c87b5e9 commit bcc950d
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 48 deletions.
Expand Up @@ -424,12 +424,12 @@ protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam

@Override
public boolean isOrderingDisabled() {
GuiObjectListPanelConfigurationType additionalPanelConfig = getAdditionalPanelConfig();
if (additionalPanelConfig != null && additionalPanelConfig.isDisableSorting() != null) {
return additionalPanelConfig.isDisableSorting();
} else {
return super.isOrderingDisabled();
}
return ObjectListPanel.this.isOrderingDisabled();
}

@Override
public boolean isUseObjectCounting(){
return isCountingEnabled();
}
};
if (options == null){
Expand Down Expand Up @@ -469,6 +469,42 @@ protected GuiObjectListPanelConfigurationType getAdditionalPanelConfig(){
return null;
}

protected boolean isOrderingDisabled(){
CompiledObjectCollectionView guiObjectListViewType = getGuiObjectListViewType();
if (isAdditionalPanel()){
if (guiObjectListViewType != null && guiObjectListViewType.getAdditionalPanels() != null &&
guiObjectListViewType.getAdditionalPanels().getMemberPanel() != null &&
guiObjectListViewType.getAdditionalPanels().getMemberPanel().isDisableSorting() != null){
return guiObjectListViewType.getAdditionalPanels().getMemberPanel().isDisableSorting();
}
} else {
if (guiObjectListViewType != null && guiObjectListViewType.isDisableSorting() != null){
return guiObjectListViewType.isDisableSorting();
}
}
return true;
}

protected boolean isCountingEnabled(){
CompiledObjectCollectionView guiObjectListViewType = getGuiObjectListViewType();
if (isAdditionalPanel()){
if (guiObjectListViewType != null && guiObjectListViewType.getAdditionalPanels() != null &&
guiObjectListViewType.getAdditionalPanels().getMemberPanel() != null &&
guiObjectListViewType.getAdditionalPanels().getMemberPanel().isDisableCounting() != null){
return guiObjectListViewType.getAdditionalPanels().getMemberPanel().isDisableCounting();
}
} else {
if (guiObjectListViewType != null && guiObjectListViewType.isDisableCounting() != null){
return !guiObjectListViewType.isDisableCounting();
}
}
return true;
}

protected boolean isAdditionalPanel(){
return false;
}

private SearchFormPanel initSearch(String headerId) {
SearchFormPanel searchPanel = new SearchFormPanel(headerId, searchModel) {

Expand Down
Expand Up @@ -248,6 +248,14 @@ public String getObject() {
protected void onPageChanged(AjaxRequestTarget target, long page) {
target.add(count);
}

@Override
protected boolean isCountingDisabled(){
if (dataTable.getDataProvider() instanceof SelectableBeanObjectDataProvider){
return !((SelectableBeanObjectDataProvider)dataTable.getDataProvider()).isUseObjectCounting();
}
return super.isCountingDisabled();
}
};
footerContainer.add(nb2);

Expand Down
Expand Up @@ -267,7 +267,7 @@ public void setType(Class<O> type) {
clearCache();
}

public boolean isUseObjectCounting(){
protected boolean isUseObjectCounting(){
return useObjectCounting;
}

Expand Down
Expand Up @@ -273,7 +273,7 @@ public void onClick(AjaxRequestTarget target) {

@Override
public boolean isEnabled() {
return BooleanUtils.isTrue(showPageListingModel.getObject()) && isLastEnabled();
return !isCountingDisabled() && BooleanUtils.isTrue(showPageListingModel.getObject()) && isLastEnabled();
}
});
last.add(lastLink);
Expand Down Expand Up @@ -330,4 +330,8 @@ private void pageLinkPerformed(AjaxRequestTarget target, long page) {

protected void onPageChanged(AjaxRequestTarget target, long page) {
}

protected boolean isCountingDisabled(){
return false;
}
}
Expand Up @@ -344,6 +344,11 @@ protected ObjectQuery createContentQuery() {
protected GuiObjectListPanelConfigurationType getAdditionalPanelConfig(){
return AbstractRoleMemberPanel.this.getAdditionalPanelConfig();
}

@Override
protected boolean isAdditionalPanel(){
return true;
}
};
childrenListPanel.setOutputMarkupId(true);
memberContainer.add(childrenListPanel);
Expand Down
Expand Up @@ -154,12 +154,4 @@ protected MemberPanelStorage getMemberPanelStorage(){
return (MemberPanelStorage) storage;
}

@Override
protected GuiObjectListPanelConfigurationType getAdditionalPanelConfig(){
CompiledObjectCollectionView orgViewType = getPageBase().getCompiledUserProfile().findObjectCollectionView(OrgType.COMPLEX_TYPE, null);
if (orgViewType == null || orgViewType.getAdditionalPanels() == null){
return null;
}
return orgViewType.getAdditionalPanels().getMemberPanel();
}
}
Expand Up @@ -24204,6 +24204,16 @@
<a:displayName>GuiObjectListViewType.disableSorting</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="disableCounting" type="xsd:boolean" default="false" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Configures the possibility of the objects counting while object list loading
</xsd:documentation>
<xsd:appinfo>
<a:displayName>GuiObjectListViewType.disableCounting</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<!-- TODO: number of results per page (MID-1931) -->
<!-- TODO: later: export settings (GuiExportSettingsType) -->
Expand Down
71 changes: 40 additions & 31 deletions infra/util/src/main/java/com/evolveum/midpoint/util/DOMUtil.java
Expand Up @@ -7,45 +7,36 @@

package com.evolveum.midpoint.util;

import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.apache.xerces.util.XMLChar;
import org.jetbrains.annotations.NotNull;
import org.w3c.dom.*;
import org.xml.sax.SAXException;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.util.*;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.*;
import javax.xml.transform.Transformer;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.util.*;
import java.util.Map.Entry;
import java.util.regex.Pattern;

import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.apache.xerces.util.XMLChar;
import org.jetbrains.annotations.NotNull;
import org.w3c.dom.Attr;
import org.w3c.dom.Comment;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
import org.xml.sax.SAXException;

import com.evolveum.midpoint.util.exception.SystemException;
import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;

/**
* @author Igor Farinic
Expand Down Expand Up @@ -182,8 +173,26 @@ public class DOMUtil {
try {
//setTransformerFactoryIfPresent("com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"); // too many whitespaces in Java11
//setTransformerFactoryIfPresent("org.apache.xalan.xsltc.trax.TransformerFactoryImpl"); // too few whitespaces
setTransformerFactoryIfPresent("org.apache.xalan.processor.TransformerFactoryImpl"); // a bit slower
TransformerFactory transformerFactory = TransformerFactory.newInstance();

String className = "org.apache.xalan.processor.TransformerFactoryImpl";
setTransformerFactoryIfPresent(className); // a bit slower

ClassLoader cl = null;
try {
Class clazz = Class.forName(className);
if (clazz != null) {
cl = clazz.getClassLoader();
}
} catch (Exception ex) {
}

TransformerFactory transformerFactory;
if (cl != null) {
transformerFactory = TransformerFactory.newInstance(className, cl);
} else {
transformerFactory = TransformerFactory.newInstance();
}

//System.out.println("TF = " + transformerFactory.getClass().getName());
Transformer trans = transformerFactory.newTransformer();
trans.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); // XALAN-specific
Expand Down
Expand Up @@ -47,6 +47,7 @@ public class CompiledObjectCollectionView implements DebugDumpable, Serializable
private GuiObjectListViewAdditionalPanelsType additionalPanels;
private DistinctSearchOptionType distinct;
private Boolean disableSorting;
private Boolean disableCounting;
private SearchBoxConfigurationType searchBoxConfiguration;
private ObjectFilter filter;
private ObjectFilter domainFilter;
Expand Down Expand Up @@ -140,7 +141,15 @@ public Boolean getDisableSorting() {
public void setDisableSorting(Boolean disableSorting) {
this.disableSorting = disableSorting;
}


public Boolean isDisableCounting() {
return disableCounting;
}

public void setDisableCounting(Boolean disableCounting) {
this.disableCounting = disableCounting;
}

public SearchBoxConfigurationType getSearchBoxConfiguration() {
return searchBoxConfiguration;
}
Expand Down Expand Up @@ -211,6 +220,7 @@ public String debugDump(int indent) {
DebugUtil.debugDumpWithLabelToStringLn(sb, "additionalPanels", additionalPanels, indent + 1);
DebugUtil.debugDumpWithLabelToStringLn(sb, "distinct", distinct, indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "disableSorting", disableSorting, indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "disableCounting", disableCounting, indent + 1);
DebugUtil.debugDumpWithLabelToStringLn(sb, "searchBoxConfiguration", searchBoxConfiguration, indent + 1);
DebugUtil.debugDumpWithLabelLn(sb, "filter", filter, indent + 1);
DebugUtil.debugDumpWithLabel(sb, "domainFilter", domainFilter, indent + 1);
Expand Down
Expand Up @@ -342,6 +342,7 @@ private void compileView(CompiledObjectCollectionView existingView, GuiObjectLis
compileDisplay(existingView, objectListViewType);
compileDistinct(existingView, objectListViewType);
compileSorting(existingView, objectListViewType);
compileCounting(existingView, objectListViewType);
compileDisplayOrder(existingView, objectListViewType);
compileSearchBox(existingView, objectListViewType);
compileCollection(existingView, objectListViewType, task, result);
Expand Down Expand Up @@ -437,6 +438,13 @@ private void compileSorting(CompiledObjectCollectionView existingView, GuiObject
}
}

private void compileCounting(CompiledObjectCollectionView existingView, GuiObjectListViewType objectListViewType) {
Boolean newDisableCounting = objectListViewType.isDisableCounting();
if (newDisableCounting != null) {
existingView.setDisableCounting(newDisableCounting);
}
}

private void compileDisplayOrder(CompiledObjectCollectionView existingView, GuiObjectListViewType objectListViewType){
Integer newDisplayOrder = objectListViewType.getDisplayOrder();
if (newDisplayOrder != null){
Expand Down

0 comments on commit bcc950d

Please sign in to comment.