Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Sep 18, 2023
2 parents 90627d8 + b4bfb84 commit bfeda00
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ public IModel<String> getDataModel(IModel<SelectableBean<ObjectReferenceType>> i
String creator = null;
String approvers = null;
String approverComments = null;

Channel channel = Channel.findChannel(chanel);
if (channel == null) {
return "N/A";
}

switch (channel) {
case SELF_SERVICE:
case USER:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,8 @@ protected IConverter<?> createConverter(Class<?> type) {
IModel<String> unitModel = new LoadableModel<>(false) {
@Override
protected String load() {
if (model.getObject() == null) {
return DurationWithOneElementPanel.this.choices.get(0).name;
}

List<DatatypeConstants.Field> choices = getChoicesAsField();

Optional<DatatypeConstants.Field> unit =
choices.stream().filter(choice -> model.getObject().isSet(choice)).findFirst();
if (unit.isPresent()) {
return unit.get().toString();
}
return DurationWithOneElementPanel.this.choices.get(0).name;
DatatypeConstants.Field actualUnit = parseUnitFiled(model);
return actualUnit.toString();
}
};

Expand All @@ -109,10 +99,36 @@ protected String load() {
StringChoiceRenderer.prefixed("DurationWithOneElementPanel.unit."));
unit.setNullValid(false);
unit.setOutputMarkupId(true);
unit.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
unit.add(new EmptyOnChangeAjaxFormUpdatingBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
DurationConverter converter = new DurationConverter();
Duration duration = converter.convertToObject(
converter.convertToString(
model.getObject(),
parseUnitFiled(model)),
getPageBase().getLocale());
model.setObject(duration);
}
});
add(unit);
}

private DatatypeConstants.Field parseUnitFiled(IModel<Duration> model) {
if (model.getObject() == null) {
return getChoicesAsField().get(0);
}

List<DatatypeConstants.Field> choices = getChoicesAsField();

Optional<DatatypeConstants.Field> unit =
choices.stream().filter(choice -> model.getObject().isSet(choice)).findFirst();
if (unit.isPresent()) {
return unit.get();
}
return getChoicesAsField().get(0);
}

private List<DatatypeConstants.Field> getChoicesAsField() {
return List.of(
DatatypeConstants.YEARS,
Expand Down Expand Up @@ -188,5 +204,15 @@ public String convertToString(Duration duration, Locale locale) {
.findFirst();
return String.valueOf(duration.getField(field.get()).intValue());
}

private String convertToString(Duration duration, DatatypeConstants.Field unit) {
List<DatatypeConstants.Field> choices = getChoicesAsField();

Optional<DatatypeConstants.Field> field = choices
.stream()
.filter(choice -> choice.equals(unit))
.findFirst();
return String.valueOf(duration.getField(field.get()).intValue());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
<xsd:appinfo>
<a:since>4.5</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
Expand Down Expand Up @@ -78,7 +77,8 @@
<xsd:appinfo>
<a:since>4.6</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
<a:deprecated>true</a:deprecated>
<a:deprecatedSince>4.8</a:deprecatedSince>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
Expand Down Expand Up @@ -108,7 +108,8 @@
<xsd:appinfo>
<a:since>4.5</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
<a:deprecated>true</a:deprecated>
<a:deprecatedSince>4.8</a:deprecatedSince>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
Expand All @@ -129,13 +130,11 @@
<xsd:complexType name="CompositeCorrelatorType">
<xsd:annotation>
<xsd:documentation>
TODO
User-friendly way of defining a correlator or correlators.
</xsd:documentation>
<xsd:appinfo>
<a:since>4.5</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
<a:elaborate>true</a:elaborate>
</xsd:appinfo>
</xsd:annotation>
Expand Down Expand Up @@ -267,7 +266,6 @@
<xsd:appinfo>
<a:since>4.5</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
Expand Down Expand Up @@ -376,7 +374,6 @@
<xsd:appinfo>
<a:since>4.6</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
Expand Down Expand Up @@ -445,13 +442,10 @@
<xsd:annotation>
<xsd:documentation>
"No-op" correlation that always returns "certainly no owner" result.

TODO NoneCorrelatorType?
</xsd:documentation>
<xsd:appinfo>
<a:since>4.5</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
Expand All @@ -471,7 +465,6 @@
<xsd:appinfo>
<a:since>4.5</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
Expand All @@ -498,7 +491,6 @@
<xsd:appinfo>
<a:since>4.5</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
Expand Down Expand Up @@ -541,7 +533,6 @@
<xsd:appinfo>
<a:since>4.5</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
Expand Down Expand Up @@ -797,7 +788,6 @@
<xsd:appinfo>
<a:since>4.6</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
Expand All @@ -817,7 +807,6 @@
<xsd:appinfo>
<a:since>4.6</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
Expand Down Expand Up @@ -877,7 +866,6 @@
<xsd:appinfo>
<a:since>4.6</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
Expand All @@ -900,7 +888,6 @@
<xsd:appinfo>
<a:since>4.5</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
Expand Down Expand Up @@ -1004,7 +991,6 @@
<xsd:appinfo>
<a:since>4.5</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
Expand All @@ -1028,7 +1014,6 @@
</xsd:documentation>
<xsd:appinfo>
<a:since>4.5</a:since>
<a:experimental>true</a:experimental>
<a:container>true</a:container>
</xsd:appinfo>
</xsd:annotation>
Expand Down Expand Up @@ -1184,7 +1169,6 @@
<xsd:appinfo>
<a:since>4.6</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
Expand Down Expand Up @@ -1266,7 +1250,6 @@
<xsd:appinfo>
<a:since>4.6</a:since>
<a:container>true</a:container>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
Expand All @@ -1275,6 +1258,9 @@
<xsd:documentation>
How to search for the item values?
</xsd:documentation>
<xsd:appinfo>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="focusItem" type="t:ItemPathType" minOccurs="0">
Expand Down Expand Up @@ -1542,7 +1528,6 @@
</xsd:documentation>
<xsd:appinfo>
<a:since>4.6</a:since>
<a:experimental>true</a:experimental>
<a:container>true</a:container>
</xsd:appinfo>
</xsd:annotation>
Expand Down

0 comments on commit bfeda00

Please sign in to comment.