Skip to content

Commit

Permalink
Merge branch 'master' into feature/build-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Mar 2, 2020
2 parents 03ac26f + 6458413 commit 16e98a3
Show file tree
Hide file tree
Showing 603 changed files with 29,227 additions and 36,654 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Expand Up @@ -10,7 +10,7 @@ trim_trailing_whitespace = true
ij_continuation_indent_size = 8
ij_formatter_off_tag = @formatter:off
ij_formatter_on_tag = @formatter:on
ij_formatter_tags_enabled = false
ij_formatter_tags_enabled = true
ij_smart_tabs = false
ij_visual_guides = 100,130,150,180
ij_wrap_on_typing = false
Expand Down Expand Up @@ -156,7 +156,7 @@ ij_java_keep_first_column_comment = true
ij_java_keep_indents_on_empty_lines = false
ij_java_keep_line_breaks = true
ij_java_keep_multiple_expressions_in_one_line = false
ij_java_keep_simple_blocks_in_one_line = false
ij_java_keep_simple_blocks_in_one_line = true
ij_java_keep_simple_classes_in_one_line = false
ij_java_keep_simple_lambdas_in_one_line = false
ij_java_keep_simple_methods_in_one_line = false
Expand Down
6 changes: 5 additions & 1 deletion gui/admin-gui/pom.xml
Expand Up @@ -691,7 +691,6 @@
<dependency>
<groupId>com.evolveum.midpoint.infra</groupId>
<artifactId>test-util</artifactId>
<version>4.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -816,6 +815,11 @@
<version>4.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Expand Up @@ -217,5 +217,7 @@ public class GuiStyleConstants {
public static final String CLASS_ICON_CLAIM = "fa fa-paper-plane-o";
public static final String CLASS_ICON_TEXT = "fa fa-text-width";

public static final String CLASS_ICON_TRASH = "fa fa-trash-o";


}
Expand Up @@ -647,6 +647,48 @@ public static TaskType createSingleRecurrenceTask(String taskName, QName applica
return task;
}

public static boolean canSuspendTask(TaskType task, PageBase pageBase) {
return pageBase.isAuthorized(ModelAuthorizationAction.SUSPEND_TASK, task.asPrismObject())
&& (isRunnableTask(task) || isRunningTask(task))
&& !isWorkflowTask(task);
}

public static boolean canResumeTask(TaskType task, PageBase pageBase) {
return pageBase.isAuthorized(ModelAuthorizationAction.RESUME_TASK, task.asPrismObject())
&& (isSuspendedTask(task) || (isClosedTask(task) && isRecurringTask(task)))
&& !isWorkflowTask(task);
}

public static boolean canRunNowTask(TaskType task, PageBase pageBase) {
return pageBase.isAuthorized(ModelAuthorizationAction.RUN_TASK_IMMEDIATELY, task.asPrismObject())
&& (isRunnableTask(task) || (isClosedTask(task) && !isRecurringTask(task)))
&& !isWorkflowTask(task);
}

public static boolean isRunnableTask(TaskType task) {
return task != null && TaskExecutionStatusType.RUNNABLE == task.getExecutionStatus();
}

public static boolean isRunningTask(TaskType task) {
return task != null && task.getNodeAsObserved() != null;
}

public static boolean isSuspendedTask(TaskType task) {
return task != null && TaskExecutionStatusType.SUSPENDED == task.getExecutionStatus();
}

public static boolean isClosedTask(TaskType task) {
return task != null && TaskExecutionStatusType.CLOSED == task.getExecutionStatus();
}

public static boolean isRecurringTask(TaskType task) {
return task != null && TaskRecurrenceType.RECURRING == task.getRecurrence();
}

public static boolean isWorkflowTask(TaskType task) {
return task != null && TaskCategory.WORKFLOW.equals(task.getCategory());
}

public static void iterativeExecuteBulkAction(PageBase pageBase, ExecuteScriptType script, Task task, OperationResult result )
throws SchemaException, SecurityViolationException, ObjectNotFoundException, ExpressionEvaluationException,
CommunicationException, ConfigurationException{
Expand Down Expand Up @@ -1225,8 +1267,8 @@ public static <C extends Containerable> String getDisplayName(PrismContainerValu
if (name != null && !name.isEmpty()) {
displayName = name;
}
} else if (prismContainerValue.canRepresent(PropertyConstraintType.class)) {
PropertyConstraintType propertyConstraintType = (PropertyConstraintType) prismContainerValue.asContainerable();
} else if (prismContainerValue.canRepresent(ItemConstraintType.class)) {
ItemConstraintType propertyConstraintType = (ItemConstraintType) prismContainerValue.asContainerable();
String path = "";
if (propertyConstraintType.getPath() != null) {
path = propertyConstraintType.getPath().getItemPath().toString();
Expand Down
Expand Up @@ -455,7 +455,7 @@ public List<PrismContainerValueWrapper<C>> getPerformedSelectedItems(IModel<Pris
return performedItems;
}

//TODO generalize for properites
//TODO generalize for properties
public PrismContainerValueWrapper<C> createNewItemContainerValueWrapper(
PrismContainerValue<C> newItem,
PrismContainerWrapper<C> model, AjaxRequestTarget target) {
Expand Down
Expand Up @@ -11,14 +11,11 @@
import com.evolveum.midpoint.gui.impl.prism.PrismPropertyWrapper;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.web.component.AceEditor;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior;
import com.evolveum.midpoint.web.page.admin.reports.component.AceEditorPanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
import org.apache.wicket.markup.html.panel.Panel;
import org.springframework.stereotype.Component;

Expand All @@ -35,7 +32,12 @@ public void register() {

@Override
protected Panel getPanel(PrismPropertyPanelContext<ExpressionType> panelCtx) {
AceEditorPanel conditionPanel = new AceEditorPanel(panelCtx.getComponentId(), null, new ConditionExpressionModel(panelCtx.getRealValueModel(), panelCtx.getPageBase()), 200);
AceEditorPanel conditionPanel = new AceEditorPanel(panelCtx.getComponentId(), null, new ExpressionModel(panelCtx.getRealValueModel(), panelCtx.getPageBase()), 200){
@Override
protected boolean isResizeToMaxHeight() {
return false;
}
};
// conditionPanel.getEditor().add(new OnChangeAjaxBehavior() {
// @Override
// protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
Expand Down
@@ -1,99 +1,96 @@
/*
* 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.midpoint.web.util.ExpressionUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType;

import com.evolveum.prism.xml.ns._public.types_3.RawType;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType;

import javax.xml.bind.JAXBElement;
import java.util.List;

public class ConditionExpressionModel implements IModel<String> {

private static final Trace LOGGER = TraceManager.getTrace(ConditionExpressionModel.class);

private static final long serialVersionUID = 1L;

private IModel<ExpressionType> baseModel;
private PageBase pageBase;

public ConditionExpressionModel(IModel<ExpressionType> valueWrapper, PageBase pageBase) {
this.baseModel = valueWrapper;
this.pageBase = pageBase;
}

@Override
public void detach() {
// TODO Auto-generated method stub

}

@Override
public String getObject() {
try {
ExpressionType value = baseModel.getObject();
if (value == null) {
return null;
}

List<JAXBElement<?>> evaluatros = value.getExpressionEvaluator();
//should be one
if (CollectionUtils.isEmpty(evaluatros)) {
return null;
}
if (evaluatros.size() > 1) {
LOGGER.warn("More than one evaluator found. getting first of them");
}

JAXBElement<?> evaluator = evaluatros.get(0);
if (evaluator == null) {
return null;
}

return ExpressionUtil.serialize(evaluator, pageBase.getPrismContext());

} catch (SchemaException e) {
// TODO handle!!!!
LoggingUtils.logUnexpectedException(LOGGER, "Cannot serialize filter", e);
// getSession().error("Cannot serialize filter");
}
return null;
}

@Override
public void setObject(String object) {
if (StringUtils.isBlank(object)) {
baseModel.setObject(null);
return;
}

try {
ExpressionType condition = new ExpressionType();
ExpressionUtil.parseExpressionEvaluators(object, condition, pageBase.getPrismContext());
// ExpressionType condition = pageBase.getPrismContext().parserFor(object).parseRealValue();
baseModel.setObject(condition);
} catch (Exception e) {
// TODO handle!!!!
LoggingUtils.logUnexpectedException(LOGGER, "Cannot parse filter", e);
// getSession().error("Cannot parse filter");
}

}
}
/*
* 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.midpoint.web.util.ExpressionUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;

import javax.xml.bind.JAXBElement;
import java.util.List;

public class ExpressionModel implements IModel<String> {

private static final Trace LOGGER = TraceManager.getTrace(ExpressionModel.class);

private static final long serialVersionUID = 1L;

private IModel<ExpressionType> baseModel;
private PageBase pageBase;

public ExpressionModel(IModel<ExpressionType> valueWrapper, PageBase pageBase) {
this.baseModel = valueWrapper;
this.pageBase = pageBase;
}

@Override
public void detach() {
// TODO Auto-generated method stub

}

@Override
public String getObject() {
try {
ExpressionType value = baseModel.getObject();
if (value == null) {
return null;
}

List<JAXBElement<?>> evaluatros = value.getExpressionEvaluator();
//should be one
if (CollectionUtils.isEmpty(evaluatros)) {
return null;
}
if (evaluatros.size() > 1) {
LOGGER.warn("More than one evaluator found. getting first of them");
}

JAXBElement<?> evaluator = evaluatros.get(0);
if (evaluator == null) {
return null;
}

return ExpressionUtil.serialize(evaluator, pageBase.getPrismContext());

} catch (SchemaException e) {
// TODO handle!!!!
LoggingUtils.logUnexpectedException(LOGGER, "Cannot serialize filter", e);
// getSession().error("Cannot serialize filter");
}
return null;
}

@Override
public void setObject(String object) {
if (StringUtils.isBlank(object)) {
baseModel.setObject(null);
return;
}

try {
ExpressionType condition = new ExpressionType();
ExpressionUtil.parseExpressionEvaluators(object, condition, pageBase.getPrismContext());
// ExpressionType condition = pageBase.getPrismContext().parserFor(object).parseRealValue();
baseModel.setObject(condition);
} catch (Exception e) {
// TODO handle!!!!
LoggingUtils.logUnexpectedException(LOGGER, "Cannot parse filter", e);
// getSession().error("Cannot parse filter");
}

}
}
Expand Up @@ -450,7 +450,7 @@ ItemStatus getItemStatus() {
return status;
}


@NotNull
@Override
public ItemName getItemName() {
return getItemDefinition().getItemName();
Expand Down
Expand Up @@ -107,7 +107,8 @@ public boolean isVisible() {
return false;
}

if (!((PrismContainerWrapper) parent).isExpanded() && parent.isMultiValue()) {

if (!isShowOnTopLevel() && !((PrismContainerWrapper) parent).isExpanded() && parent.isMultiValue()) {
return false;
}
return true;
Expand Down
Expand Up @@ -25,6 +25,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingLevelType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType;
import org.jetbrains.annotations.NotNull;

/**
* @author skublik
Expand All @@ -38,6 +39,7 @@ public ProfilingClassLoggerContainerWrapperImpl(PrismContainerValueWrapper<?> pa
super(parent, item, status);
}

@NotNull
@Override
public ItemName getItemName() {
return ItemName.fromQName(ProfilingClassLoggerWrapperFactoryImpl.PROFILING_LOGGER_PATH);
Expand Down
Expand Up @@ -8,9 +8,9 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div class="col-md-2 col-xs-12 prism-property-label " wicket:id="header"/>
<div class="col-lg-2 col-md-4 col-xs-12 prism-property-label " wicket:id="header"/>
<div class="row">
<div class="col-md-12 col-xs-12 prism-property-value" wicket:id="values">
<div class="col-lg-10 col-md-8 col-xs-12 prism-property-value" wicket:id="values">
<div wicket:id="expressionPanel"/>
</div>
</div>
Expand Down

0 comments on commit 16e98a3

Please sign in to comment.