You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by fm...@apache.org on 2017/12/13 09:24:28 UTC
syncope git commit: [SYNCOPE-1250] splits filtering (performed on
schema set) and sorting (performed on attributes)
Repository: syncope
Updated Branches:
refs/heads/2_0_X 1609e2022 -> 1c6aae6f5
[SYNCOPE-1250] splits filtering (performed on schema set) and sorting (performed on attributes)
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/1c6aae6f
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/1c6aae6f
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/1c6aae6f
Branch: refs/heads/2_0_X
Commit: 1c6aae6f572927d48b432b89014c810c37d55f03
Parents: 1609e20
Author: fmartelli <fa...@gmail.com>
Authored: Wed Dec 13 10:24:06 2017 +0100
Committer: fmartelli <fa...@gmail.com>
Committed: Wed Dec 13 10:24:06 2017 +0100
----------------------------------------------------------------------
.../console/wizards/any/AbstractAttrs.java | 36 +++++++-------------
1 file changed, 13 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/1c6aae6f/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AbstractAttrs.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AbstractAttrs.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AbstractAttrs.java
index 75ca867..00cc339 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AbstractAttrs.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AbstractAttrs.java
@@ -22,7 +22,6 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -167,28 +166,8 @@ public abstract class AbstractAttrs<S extends AbstractSchemaTO> extends WizardSt
return whichAttrs.contains(schemaTO.getKey());
}
});
-
- // 2. sort remainig attributes according to configuration, e.g. attrLayout
- final Map<String, Integer> attrLayoutMap = new HashMap<>(whichAttrs.size());
- for (int i = 0; i < whichAttrs.size(); i++) {
- attrLayoutMap.put(whichAttrs.get(i), i);
- }
- Collections.sort(allSchemas, new Comparator<S>() {
-
- @Override
- public int compare(final S schema1, final S schema2) {
- int value = 0;
-
- if (attrLayoutMap.get(schema1.getKey()) > attrLayoutMap.get(schema2.getKey())) {
- value = 1;
- } else if (attrLayoutMap.get(schema1.getKey()) < attrLayoutMap.get(schema2.getKey())) {
- value = -1;
- }
-
- return value;
- }
- });
}
+
for (S schemaTO : allSchemas) {
scs.put(schemaTO.getKey(), schemaTO);
}
@@ -235,7 +214,7 @@ public abstract class AbstractAttrs<S extends AbstractSchemaTO> extends WizardSt
return null;
}
- protected static class AttrComparator implements Comparator<AttrTO>, Serializable {
+ protected class AttrComparator implements Comparator<AttrTO>, Serializable {
/**
*
@@ -249,6 +228,17 @@ public abstract class AbstractAttrs<S extends AbstractSchemaTO> extends WizardSt
}
if (right == null || StringUtils.isEmpty(right.getSchema())) {
return 1;
+ } else if (AbstractAttrs.this.reoderSchemas()) {
+ int leftIndex = AbstractAttrs.this.whichAttrs.indexOf(left.getSchema());
+ int rightIndex = AbstractAttrs.this.whichAttrs.indexOf(right.getSchema());
+
+ if (leftIndex > rightIndex) {
+ return 1;
+ } else if (leftIndex < rightIndex) {
+ return -1;
+ } else {
+ return 0;
+ }
} else {
return left.getSchema().compareTo(right.getSchema());
}