Skip to content

Commit

Permalink
Fix ReportConfigurationPanel lambda serialization
Browse files Browse the repository at this point in the history
A filter in ReportConfigurationPanel was not serializable;
fixed by replacing lambda with resulting objects.
  • Loading branch information
mederly committed Jan 23, 2018
1 parent 161fdaf commit 856b7d7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2010-2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.evolveum.midpoint.gui.api.model;

import org.apache.wicket.model.AbstractReadOnlyModel;
import org.jetbrains.annotations.NotNull;

/**
* EXPERIMENTAL
* TODO better name
*
* @author mederly
*/
public class ReadOnlyValueModel<T> extends AbstractReadOnlyModel<T> {

@NotNull private final T object;

public ReadOnlyValueModel(@NotNull T object) {
this.object = object;
}

@Override
public T getObject() {
return object;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.api.SubscriptionType;
import com.evolveum.midpoint.gui.api.model.ReadOnlyModel;
import com.evolveum.midpoint.gui.api.model.ReadOnlyValueModel;
import com.evolveum.midpoint.model.api.ModelExecuteOptions;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.SelectorOptions;
Expand Down Expand Up @@ -701,9 +701,10 @@ public List<T> getObject() {
};
}

// use for small enums only
@NotNull
public static <T extends Enum> IModel<List<T>> createReadonlyModelFromEnum(@NotNull Class<T> type, @NotNull Predicate<T> filter) {
return new ReadOnlyModel<>(() ->
public static <T extends Enum> IModel<List<T>> createReadonlyValueModelFromEnum(@NotNull Class<T> type, @NotNull Predicate<T> filter) {
return new ReadOnlyValueModel<>(
Arrays.stream(type.getEnumConstants())
.filter(filter)
.collect(Collectors.toList()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected void initLayout() {
createStringResource("ObjectType.description"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
add(description);

IModel choices = WebComponentUtil.createReadonlyModelFromEnum(ExportType.class, e -> e != ExportType.JXL);
IModel choices = WebComponentUtil.createReadonlyValueModelFromEnum(ExportType.class, e -> e != ExportType.JXL);
IChoiceRenderer renderer = new EnumChoiceRenderer();
DropDownFormGroup exportType = new DropDownFormGroup(ID_EXPORT_TYPE, new PropertyModel<ExportType>(getModel(), ReportDto.F_EXPORT_TYPE), choices, renderer,
createStringResource("ReportType.export"), ID_LABEL_SIZE, ID_INPUT_SIZE, true);
Expand Down

0 comments on commit 856b7d7

Please sign in to comment.