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
17 changed files
with
1,088 additions
and
921 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
67 changes: 67 additions & 0 deletions
67
gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ObjectDeltaModel.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,67 @@ | ||
/* | ||
* Copyright (c) 2020 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.factory; | ||
|
||
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.wicket.ThreadContext; | ||
import org.apache.wicket.model.IModel; | ||
|
||
import com.evolveum.midpoint.gui.api.util.ModelServiceLocator; | ||
import com.evolveum.midpoint.util.logging.LoggingUtils; | ||
import com.evolveum.midpoint.util.logging.Trace; | ||
import com.evolveum.midpoint.util.logging.TraceManager; | ||
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptType; | ||
|
||
public class ObjectDeltaModel implements IModel<String> { | ||
|
||
private static final transient Trace LOGGER = TraceManager.getTrace(ObjectDeltaModel.class); | ||
|
||
private IModel<ObjectDeltaType> baseModel; | ||
private ModelServiceLocator locator; | ||
|
||
public ObjectDeltaModel(IModel<ObjectDeltaType> model, ModelServiceLocator locator) { | ||
this.baseModel = model; | ||
this.locator = locator; | ||
} | ||
|
||
|
||
@Override | ||
public String getObject() { | ||
try { | ||
ObjectDeltaType value = baseModel.getObject(); | ||
if (value == null) { | ||
return null; | ||
} | ||
|
||
return locator.getPrismContext().xmlSerializer().serializeRealValue(value); | ||
} catch (Exception e) { | ||
// TODO handle!!!! | ||
LoggingUtils.logUnexpectedException(LOGGER, "Cannot serialize delta", e); | ||
ThreadContext.getSession().error("Cannot serialize delta: " + e.getMessage()); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setObject(String object) { | ||
if (StringUtils.isBlank(object)) { | ||
return; | ||
} | ||
|
||
try { | ||
ObjectDeltaType script = locator.getPrismContext().parserFor(object).parseRealValue(ObjectDeltaType.class); | ||
baseModel.setObject(script); | ||
} catch (Exception e) { | ||
// TODO handle!!!! | ||
LoggingUtils.logUnexpectedException(LOGGER, "Cannot parse delta", e); | ||
ThreadContext.getSession().error("Cannot parse delta: " + e.getMessage()); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...min-gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ObjectDeltaPanelFactory.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,44 @@ | ||
/* | ||
* Copyright (c) 2020 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.factory; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
import com.evolveum.midpoint.web.component.input.TextAreaPanel; | ||
|
||
import org.apache.wicket.markup.html.panel.Panel; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.evolveum.midpoint.gui.api.factory.AbstractGuiComponentFactory; | ||
import com.evolveum.midpoint.gui.api.prism.ItemWrapper; | ||
import com.evolveum.midpoint.util.QNameUtil; | ||
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType; | ||
|
||
@Component | ||
public class ObjectDeltaPanelFactory extends AbstractGuiComponentFactory<ObjectDeltaType> { | ||
|
||
@PostConstruct | ||
public void register() { | ||
getRegistry().addToRegistry(this); | ||
} | ||
|
||
@Override | ||
public Integer getOrder() { | ||
return super.getOrder() - 100; | ||
} | ||
|
||
@Override | ||
protected Panel getPanel(PrismPropertyPanelContext<ObjectDeltaType> panelCtx) { | ||
return new TextAreaPanel<>(panelCtx.getComponentId(), new ObjectDeltaModel(panelCtx.getRealValueModel(), panelCtx.getPageBase()), 20); | ||
} | ||
|
||
@Override | ||
public <IW extends ItemWrapper> boolean match(IW wrapper) { | ||
return QNameUtil.match(ObjectDeltaType.COMPLEX_TYPE, wrapper.getTypeName()); | ||
} | ||
} |
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
Oops, something went wrong.