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/18 19:21:50 UTC
syncope git commit: [SYNCOPE-1252] fix the search feature + improve
autocompletion for property field
Repository: syncope
Updated Branches:
refs/heads/2_0_X 062b482a6 -> 17fd3a998
[SYNCOPE-1252] fix the search feature + improve autocompletion for property field
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/17fd3a99
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/17fd3a99
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/17fd3a99
Branch: refs/heads/2_0_X
Commit: 17fd3a998c3da838af7b358536fcc35b7082143a
Parents: 062b482
Author: fmartelli <fa...@gmail.com>
Authored: Mon Dec 18 20:21:37 2017 +0100
Committer: fmartelli <fa...@gmail.com>
Committed: Mon Dec 18 20:21:37 2017 +0100
----------------------------------------------------------------------
.../panels/search/SearchClausePanel.java | 98 ++++++++++----------
.../console/panels/search/SearchUtils.java | 33 +++++--
2 files changed, 76 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/17fd3a99/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchClausePanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchClausePanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchClausePanel.java
index 98ff33c..80c0452 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchClausePanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchClausePanel.java
@@ -391,52 +391,43 @@ public class SearchClausePanel extends FieldPanel<SearchClause> {
}
if (field.getModel().getObject().getType() == Type.GROUP_MEMBERSHIP) {
- target.focusComponent(null);
- property.getField().inputChanged();
- property.getField().validate();
- if (property.getField().isValid()) {
- property.getField().valid();
- property.getField().updateModel();
- String[] inputAsArray = property.getField().getInputAsArray();
-
- if (StringUtils.isBlank(property.getField().getInput())
- || inputAsArray.length == 0) {
- property.setChoices(properties.getObject());
- } else {
- String inputValue = (inputAsArray.length > 1 && inputAsArray[1] != null)
- ? inputAsArray[1]
- : property.getField().getInput();
- inputValue = (inputValue.startsWith("*") && !inputValue.endsWith("*"))
- ? inputValue + "*"
- : (!inputValue.startsWith("*") && inputValue.endsWith("*"))
- ? "*" + inputValue
- : (inputValue.startsWith("*") && inputValue.endsWith("*")
- ? inputValue : "*" + inputValue + "*");
-
- if (groupInfo.getRight() > AnyObjectSearchPanel.MAX_GROUP_LIST_CARDINALITY) {
- List<GroupTO> filteredGroups =
- groupRestClient.search("/",
- SyncopeClient.getGroupSearchConditionBuilder().
- is("name").equalToIgnoreCase(inputValue).
- query(),
- 1,
- AnyObjectSearchPanel.MAX_GROUP_LIST_CARDINALITY,
- new SortParam<>("name", true),
- null);
- Collection<String> newList =
- CollectionUtils.collect(filteredGroups,
- new Transformer<GroupTO, String>() {
-
- @Override
- public String transform(final GroupTO input) {
- return input.getName();
- }
- });
-
- final List<String> names = new ArrayList<>(newList);
- Collections.sort(names);
- property.setChoices(names);
- }
+ String[] inputAsArray = property.getField().getInputAsArray();
+
+ if (StringUtils.isBlank(property.getField().getInput())
+ || inputAsArray.length == 0) {
+ property.setChoices(properties.getObject());
+ } else {
+ String inputValue = (inputAsArray.length > 1 && inputAsArray[1] != null)
+ ? inputAsArray[1]
+ : property.getField().getInput();
+ inputValue = (inputValue.startsWith("*") && !inputValue.endsWith("*"))
+ ? inputValue + "*"
+ : (!inputValue.startsWith("*") && inputValue.endsWith("*"))
+ ? "*" + inputValue
+ : (inputValue.startsWith("*") && inputValue.endsWith("*")
+ ? inputValue : "*" + inputValue + "*");
+
+ if (groupInfo.getRight() > AnyObjectSearchPanel.MAX_GROUP_LIST_CARDINALITY) {
+ List<GroupTO> filteredGroups = groupRestClient.search("/",
+ SyncopeClient.getGroupSearchConditionBuilder().
+ is("name").equalToIgnoreCase(inputValue).
+ query(),
+ 1,
+ AnyObjectSearchPanel.MAX_GROUP_LIST_CARDINALITY,
+ new SortParam<>("name", true),
+ null);
+ Collection<String> newList = CollectionUtils.collect(filteredGroups,
+ new Transformer<GroupTO, String>() {
+
+ @Override
+ public String transform(final GroupTO input) {
+ return input.getName();
+ }
+ });
+
+ final List<String> names = new ArrayList<>(newList);
+ Collections.sort(names);
+ property.setChoices(names);
}
}
}
@@ -445,9 +436,16 @@ public class SearchClausePanel extends FieldPanel<SearchClause> {
@Override
protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
-
attributes.getAjaxCallListeners().clear();
}
+ }, new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+
+ }
});
final AjaxDropDownChoicePanel<SearchClause.Comparator> comparator = new AjaxDropDownChoicePanel<>(
@@ -515,7 +513,11 @@ public class SearchClausePanel extends FieldPanel<SearchClause> {
SearchClausePanel.this.clause.setObject(searchClause);
setFieldAccess(searchClause.getType(), property, comparator, value);
+
+ // reset property value in case and just in case of change of type
+ property.setModelObject(StringUtils.EMPTY);
target.add(property);
+
target.add(comparator);
target.add(value);
}
@@ -608,7 +610,7 @@ public class SearchClausePanel extends FieldPanel<SearchClause> {
case GROUP_MEMBER:
value.setEnabled(true);
property.setEnabled(false);
- property.setModelObject(null);
+ property.setModelObject(StringUtils.EMPTY);
break;
case RESOURCE:
http://git-wip-us.apache.org/repos/asf/syncope/blob/17fd3a99/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java
index 68ac17f..80fa692 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java
@@ -259,9 +259,14 @@ public final class SearchUtils implements Serializable {
case ATTRIBUTE:
if (StringUtils.isNotBlank(clause.getProperty())) {
- boolean isLong = availableSchemaTypes.get(clause.getProperty()) != null
- && availableSchemaTypes.get(clause.getProperty()).getType()
- == AttrSchemaType.Long;
+ boolean isLong = false;
+ boolean isDouble = false;
+ if (availableSchemaTypes.get(clause.getProperty()) != null) {
+ isLong = availableSchemaTypes.get(clause.getProperty()).getType()
+ == AttrSchemaType.Long;
+ isDouble = availableSchemaTypes.get(clause.getProperty()).getType()
+ == AttrSchemaType.Double;
+ }
SyncopeProperty property = builder.is(clause.getProperty());
switch (clause.getComparator()) {
@@ -276,25 +281,33 @@ public final class SearchUtils implements Serializable {
case LESS_THAN:
condition = isLong
? property.lessThan(NumberUtils.toLong(value))
- : property.lexicalBefore(value);
+ : isDouble
+ ? property.lessThan(NumberUtils.toDouble(value))
+ : property.lexicalBefore(value);
break;
case LESS_OR_EQUALS:
condition = isLong
? property.lessOrEqualTo(NumberUtils.toLong(value))
- : property.lexicalNotAfter(value);
+ : isDouble
+ ? property.lessOrEqualTo(NumberUtils.toDouble(value))
+ : property.lexicalNotAfter(value);
break;
case GREATER_THAN:
condition = isLong
? property.greaterThan(NumberUtils.toLong(value))
- : property.lexicalAfter(value);
+ : isDouble
+ ? property.greaterThan(NumberUtils.toDouble(value))
+ : property.lexicalAfter(value);
break;
case GREATER_OR_EQUALS:
condition = isLong
? property.greaterOrEqualTo(NumberUtils.toLong(value))
- : property.lexicalNotBefore(value);
+ : isDouble
+ ? property.greaterOrEqualTo(NumberUtils.toDouble(value))
+ : property.lexicalNotBefore(value);
break;
case NOT_EQUALS:
@@ -302,6 +315,12 @@ public final class SearchUtils implements Serializable {
break;
case EQUALS:
+ condition = isLong
+ ? property.equalTo(NumberUtils.toLong(value))
+ : isDouble
+ ? property.equalTo(NumberUtils.toDouble(value))
+ : property.equalToIgnoreCase(value);
+ break;
default:
condition = property.equalToIgnoreCase(value);
break;