Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task page visibility improvements, new panel for ExecuteScriptType, f…
…ix for CleanupTaskHandler.getArchetypeOid()
- Loading branch information
Showing
10 changed files
with
545 additions
and
347 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/ExecuteScriptModel.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 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 ExecuteScriptModel implements IModel<String> { | ||
|
||
private static final transient Trace LOGGER = TraceManager.getTrace(ExecuteScriptModel.class); | ||
|
||
private IModel<ExecuteScriptType> baseModel; | ||
private ModelServiceLocator locator; | ||
|
||
public ExecuteScriptModel(IModel<ExecuteScriptType> model, ModelServiceLocator locator) { | ||
this.baseModel = model; | ||
this.locator = locator; | ||
} | ||
|
||
|
||
@Override | ||
public String getObject() { | ||
try { | ||
ExecuteScriptType value = baseModel.getObject(); | ||
if (value == null) { | ||
return null; | ||
} | ||
|
||
return locator.getPrismContext().xmlSerializer().serializeRealValue(value); | ||
} catch (Exception e) { | ||
// TODO handle!!!! | ||
LoggingUtils.logUnexpectedException(LOGGER, "Cannot serialize script", e); | ||
ThreadContext.getSession().error("Cannot serialize script: " + e.getMessage()); | ||
// getSession().error("Cannot serialize filter"); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setObject(String object) { | ||
if (StringUtils.isBlank(object)) { | ||
return; | ||
} | ||
|
||
try { | ||
ExecuteScriptType script = locator.getPrismContext().parserFor(object).parseRealValue(ExecuteScriptType.class); | ||
baseModel.setObject(script); | ||
} catch (Exception e) { | ||
// TODO handle!!!! | ||
LoggingUtils.logUnexpectedException(LOGGER, "Cannot parse script", e); | ||
ThreadContext.getSession().error("Cannot parse script: " + e.getMessage()); | ||
// getSession().error("Cannot parse filter"); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...gui/src/main/java/com/evolveum/midpoint/gui/impl/factory/ExecuteScriptWrapperFactory.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 org.apache.wicket.markup.html.panel.Panel; | ||
|
||
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.midpoint.web.component.input.TextAreaPanel; | ||
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptType; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
@Component | ||
public class ExecuteScriptWrapperFactory extends AbstractGuiComponentFactory<ExecuteScriptType> { | ||
|
||
@PostConstruct | ||
public void register() { | ||
getRegistry().addToRegistry(this); | ||
} | ||
|
||
@Override | ||
public <IW extends ItemWrapper> boolean match(IW wrapper) { | ||
return QNameUtil.match(ExecuteScriptType.COMPLEX_TYPE, wrapper.getTypeName()); | ||
} | ||
|
||
@Override | ||
public Integer getOrder() { | ||
return super.getOrder() - 1; | ||
} | ||
|
||
@Override | ||
protected Panel getPanel(PrismPropertyPanelContext<ExecuteScriptType> panelCtx) { | ||
return new TextAreaPanel<>(panelCtx.getComponentId(), new ExecuteScriptModel(panelCtx.getRealValueModel(), panelCtx.getPageBase()), 100); | ||
} | ||
} |
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
Oops, something went wrong.