-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/master'
- Loading branch information
Showing
8 changed files
with
113 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
...int/gui/impl/page/admin/systemconfiguration/component/MessageTransportContainerModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright (c) 2022 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.gui.impl.page.admin.systemconfiguration.component; | ||
|
||
import javax.xml.namespace.QName; | ||
|
||
import org.apache.wicket.model.IModel; | ||
|
||
import com.evolveum.midpoint.gui.api.component.BasePanel; | ||
import com.evolveum.midpoint.gui.api.factory.wrapper.PrismContainerWrapperFactory; | ||
import com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext; | ||
import com.evolveum.midpoint.gui.api.model.LoadableModel; | ||
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper; | ||
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper; | ||
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper; | ||
import com.evolveum.midpoint.prism.Containerable; | ||
import com.evolveum.midpoint.prism.PrismContainerDefinition; | ||
import com.evolveum.midpoint.prism.path.ItemPath; | ||
import com.evolveum.midpoint.task.api.Task; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
import com.evolveum.midpoint.web.model.PrismContainerWrapperModel; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; | ||
|
||
/** | ||
* @deprecated | ||
* | ||
* This helper model was created because currently there's no simple way of creating PrismContainerWrapper automatically if ItemPath | ||
* has more than one item. PrismObjectWrapper creates containers only up to first level. In our case for SystemConfigurationType it creates | ||
* PrismContainerWrapper for messageTransportConfiguration container but if there's no existing configuration, this container contains zero items. | ||
* | ||
* This should be fixed somewhere in PrismContainerWrapperModel or ItemWrapperModel, but it was not an easy fix - it's a mess | ||
* there (between model, wrapper and real prism items). To complicate the change even further, we also don't want to create | ||
* recursively all container wrappers for all non-existing containers at all times. | ||
* | ||
* Created by Viliam Repan (lazyman). | ||
*/ | ||
@Deprecated | ||
public class MessageTransportContainerModel<T extends Containerable> implements IModel<PrismContainerWrapper<T>> { | ||
|
||
private BasePanel panel; | ||
|
||
private LoadableModel<PrismObjectWrapper<SystemConfigurationType>> model; | ||
|
||
private QName containerName; | ||
|
||
public MessageTransportContainerModel(BasePanel panel, LoadableModel<PrismObjectWrapper<SystemConfigurationType>> model, QName containerName) { | ||
|
||
this.panel = panel; | ||
this.model = model; | ||
this.containerName = containerName; | ||
} | ||
|
||
@Override | ||
public PrismContainerWrapper<T> getObject() { | ||
PrismContainerWrapper container = PrismContainerWrapperModel.fromContainerWrapper(model, ItemPath.create( | ||
SystemConfigurationType.F_MESSAGE_TRANSPORT_CONFIGURATION, containerName)).getObject(); | ||
|
||
if (container != null) { | ||
return container; | ||
} | ||
|
||
container = PrismContainerWrapperModel.fromContainerWrapper(model, ItemPath.create( | ||
SystemConfigurationType.F_MESSAGE_TRANSPORT_CONFIGURATION)).getObject(); | ||
|
||
try { | ||
PrismContainerValueWrapper value = (PrismContainerValueWrapper) container.getValue(); | ||
|
||
PrismContainerDefinition def = container.findContainerDefinition(ItemPath.create(containerName)); | ||
PrismContainerWrapperFactory factory = panel.getPageBase().getRegistry().findContainerWrapperFactory(def); | ||
|
||
Task task = panel.getPageBase().createSimpleTask("Create child containers"); | ||
WrapperContext ctx = new WrapperContext(task, task.getResult()); | ||
ctx.setCreateIfEmpty(true); | ||
|
||
PrismContainerWrapper child = (PrismContainerWrapper) factory.createWrapper(value, def, ctx); | ||
value.addItem(child); | ||
|
||
return child; | ||
} catch (SchemaException ex) { | ||
// todo handle | ||
ex.printStackTrace(); | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters