Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Oct 17, 2019
2 parents 57e19a8 + 9376c1d commit d5262bd
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 39 deletions.
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2019 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.api;

import org.apache.wicket.markup.html.form.FormComponent;

import java.io.Serializable;

public interface Validatable extends Serializable {

FormComponent getValidatableComponent();
}
Expand Up @@ -393,7 +393,7 @@ OtherPrivilegesLimitationType.F_APPROVAL_WORK_ITEMS, getRelationRegistry())
.isNull()
.build();
return getModelService().countContainers(CaseWorkItemType.class, query, null, task, task.getResult());
} catch (SchemaException | SecurityViolationException | ExpressionEvaluationException | ObjectNotFoundException | CommunicationException | ConfigurationException e) {
} catch (Exception e) {
LoggingUtils.logExceptionAsWarning(LOGGER, "Couldn't load work item count", e);
return null;
}
Expand All @@ -409,8 +409,7 @@ protected Integer load() {
Task task = createSimpleTask(OPERATION_LOAD_CERT_WORK_ITEM_COUNT);
OperationResult result = task.getResult();
return acs.countOpenWorkItems(getPrismContext().queryFactory().createQuery(), true, null, task, result);
} catch (SchemaException | SecurityViolationException | ObjectNotFoundException
| ConfigurationException | CommunicationException | ExpressionEvaluationException e) {
} catch (Exception e) {
LoggingUtils.logExceptionAsWarning(LOGGER, "Couldn't load certification work item count", e);
return null;
}
Expand Down
Expand Up @@ -7,12 +7,14 @@

package com.evolveum.midpoint.gui.impl.prism;

import com.evolveum.midpoint.gui.api.Validatable;
import com.evolveum.midpoint.gui.api.factory.GuiComponentFactory;
import com.evolveum.midpoint.gui.api.prism.PrismObjectWrapper;
import com.evolveum.midpoint.gui.impl.error.ErrorPanel;
import com.evolveum.midpoint.gui.impl.factory.PrismPropertyPanelContext;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
Expand Down Expand Up @@ -127,8 +129,8 @@ private WebMarkupContainer createInputPanel(ListItem<PrismPropertyValueWrapper<T
}
}

if (component instanceof InputPanel) {
InputPanel inputPanel = (InputPanel) component;
if (component instanceof Validatable) {
Validatable inputPanel = (Validatable) component;
// adding valid from/to date range validator, if necessary
ExpressionValidator<T> expressionValidator = new ExpressionValidator<T>(
LambdaModel.of(modelObject::getFormComponentValidator), getPageBase()) {
Expand All @@ -140,8 +142,29 @@ protected <O extends ObjectType> O getObjectType() {
return getObject();
}
};
inputPanel.getBaseFormComponent().add(expressionValidator);
// form.add(expressionValidator);
inputPanel.getValidatableComponent().add(expressionValidator);

inputPanel.getValidatableComponent().add(new AjaxFormComponentUpdatingBehavior("change") {

private static final long serialVersionUID = 1L;

@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(getPageBase().getFeedbackPanel());
target.add(feedback);
}

@Override
protected void onError(AjaxRequestTarget target, RuntimeException e) {
target.add(getPageBase().getFeedbackPanel());
target.add(feedback);
}

});
}

if (component instanceof InputPanel) {
InputPanel inputPanel = (InputPanel) component;

final List<FormComponent> formComponents = inputPanel.getFormComponents();
for (FormComponent<T> formComponent : formComponents) {
Expand Down
Expand Up @@ -6,6 +6,7 @@
*/
package com.evolveum.midpoint.gui.impl.prism.component;

import com.evolveum.midpoint.gui.api.Validatable;
import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
Expand All @@ -28,6 +29,7 @@
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
Expand All @@ -38,7 +40,7 @@
/**
* Created by honchar
*/
public class PolyStringEditorPanel extends BasePanel<PolyString>{
public class PolyStringEditorPanel extends BasePanel<PolyString> implements Validatable {
private static final long serialVersionUID = 1L;

private static final String ID_LOCALIZED_VALUE_CONTAINER = "localizedValueContainer";
Expand Down Expand Up @@ -404,17 +406,7 @@ protected String load() {
}

private TextPanel<PolyString> getOrigValuePanel(){
return (TextPanel<PolyString>) get(createComponentPath(ID_ORIGIN_VALUE_CONTAINER, ID_ORIG_VALUE));
}

private void onValueUpdated(){
PolyString panelModelObject = PolyStringEditorPanel.this.getModelObject();
if (panelModelObject == null){
panelModelObject = new PolyString(getOrigValuePanel().getBaseFormComponent().getValue());
}
PolyString updatedPolyStringValue = new PolyString(getOrigValuePanel().getBaseFormComponent().getValue(),
null, panelModelObject.getTranslation(), panelModelObject.getLang());
PolyStringEditorPanel.this.getModel().setObject(updatedPolyStringValue);
return (TextPanel<PolyString>) get(getPageBase().createComponentPath(ID_ORIGIN_VALUE_CONTAINER, ID_ORIG_VALUE_WITH_BUTTON, ID_ORIG_VALUE));
}

//todo refactor with PolyStringWrapper
Expand Down Expand Up @@ -467,4 +459,10 @@ private DropDownChoicePanel<String> getLanguagesChoicePanel(){
private void clearSelectedLanguageValue(){
currentlySelectedLang.delete(0, currentlySelectedLang.length());
}

@Override
public FormComponent getValidatableComponent() {
return getOrigValuePanel().getBaseFormComponent();
}

}
Expand Up @@ -7,6 +7,7 @@

package com.evolveum.midpoint.web.component.prism;

import com.evolveum.midpoint.gui.api.Validatable;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.markup.html.panel.Panel;

Expand All @@ -16,7 +17,7 @@
/**
* @author lazyman
*/
public abstract class InputPanel extends Panel {
public abstract class InputPanel extends Panel implements Validatable {

private static final long serialVersionUID = 1L;

Expand All @@ -29,4 +30,9 @@ public List<FormComponent> getFormComponents() {
}

public abstract FormComponent getBaseFormComponent();

@Override
public FormComponent getValidatableComponent() {
return getBaseFormComponent();
}
}
Expand Up @@ -235,12 +235,13 @@ private void handlePhoto(Object bean, ItemDelta delta) throws SchemaException {
RFocus<?> focus = (RFocus<?>) bean;
Set<RFocusPhoto> photos = focus.getJpegPhoto();

if (delta.isDelete()) {
if (isDelete(delta)) {
photos.clear();
return;
}

MapperContext context = new MapperContext();

context.setRepositoryContext(new RepositoryContext(repositoryService, prismContext, relationRegistry, extItemDictionary,
baseHelper.getConfiguration()));
context.setDelta(delta);
Expand Down Expand Up @@ -269,6 +270,19 @@ private void handlePhoto(Object bean, ItemDelta delta) throws SchemaException {
oldPhoto.setPhoto(photo.getPhoto());
}

private boolean isDelete(ItemDelta delta) {
if (delta.isDelete()) {
return true;
}

if (delta.isReplace()) {
if (delta.getAnyValue() == null) {
return true;
}
}

return false;
}
@SuppressWarnings("Duplicates")
private void handleWholeMetadata(Metadata<?> bean, ItemDelta delta) {
PrismValue value = null;
Expand Down
Expand Up @@ -265,19 +265,19 @@

<reaction>
<situation>linked</situation>
<action ref="http://midpoint.evolveum.com/xml/ns/public/model/action-3#modifyUser"/>
<action><handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#modifyUser</handlerUri></action>
</reaction>
<reaction>
<situation>deleted</situation>
<action ref="http://midpoint.evolveum.com/xml/ns/public/model/action-3#unlinkAccount"/>
<action><handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#unlinkAccount</handlerUri></action>
</reaction>
<reaction>
<situation>unlinked</situation>
<action ref="http://midpoint.evolveum.com/xml/ns/public/model/action-3#linkAccount"/>
<action><handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#linkAccount</handlerUri></action>
</reaction>
<reaction>
<situation>unmatched</situation>
<action ref="http://midpoint.evolveum.com/xml/ns/public/model/action-3#addUser"/>
<action><handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#addUser</handlerUri></action>
</reaction>

</objectSynchronization>
Expand Down
Expand Up @@ -300,19 +300,19 @@

<reaction>
<situation>linked</situation>
<action ref="http://midpoint.evolveum.com/xml/ns/public/model/action-3#modifyUser"/>
<action><handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#modifyUser</handlerUri></action>
</reaction>
<reaction>
<situation>deleted</situation>
<action ref="http://midpoint.evolveum.com/xml/ns/public/model/action-3#unlinkAccount"/>
<action><handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#unlinkAccount</handlerUri></action>
</reaction>
<reaction>
<situation>unlinked</situation>
<action ref="http://midpoint.evolveum.com/xml/ns/public/model/action-3#linkAccount"/>
<action><handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#linkAccount</handlerUri></action>
</reaction>
<reaction>
<situation>unmatched</situation>
<action ref="http://midpoint.evolveum.com/xml/ns/public/model/action-3#addUser"/>
<action><handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#addUser</handlerUri></action>
</reaction>

</objectSynchronization>
Expand Down
Expand Up @@ -388,19 +388,19 @@

<reaction>
<situation>linked</situation>
<action ref="http://midpoint.evolveum.com/xml/ns/public/model/action-3#modifyUser"/>
<action><handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#modifyUser</handlerUri></action>
</reaction>
<reaction>
<situation>deleted</situation>
<action ref="http://midpoint.evolveum.com/xml/ns/public/model/action-3#unlinkAccount"/>
<action><handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#unlinkAccount</handlerUri></action>
</reaction>
<reaction>
<situation>unlinked</situation>
<action ref="http://midpoint.evolveum.com/xml/ns/public/model/action-3#linkAccount"/>
<action><handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#linkAccount</handlerUri></action>
</reaction>
<reaction>
<situation>unmatched</situation>
<action ref="http://midpoint.evolveum.com/xml/ns/public/model/action-3#addUser"/>
<action><handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#addUser</handlerUri></action>
<objectTemplateRef oid="c0c010c0-d34d-b33f-f00d-777111111111"/>
</reaction>

Expand Down
Expand Up @@ -35,7 +35,7 @@
<q:value>captains</q:value>
</q:equal>
</filter>
<searchOnResource>true</searchOnResource>
<searchStrategy>onResource</searchStrategy>
</associationTargetSearch>
</expression>
</outbound>
Expand Down
Expand Up @@ -28,7 +28,7 @@
<q:value>judges</q:value>
</q:equal>
</filter>
<searchOnResource>true</searchOnResource>
<searchStrategy>onResource</searchStrategy>
</associationTargetSearch>
</expression>
</outbound>
Expand Down
Expand Up @@ -36,7 +36,7 @@
<q:value>pirates</q:value>
</q:equal>
</filter>
<searchOnResource>true</searchOnResource>
<searchStrategy>onResource</searchStrategy>
</associationTargetSearch>
</expression>
</outbound>
Expand Down
Expand Up @@ -28,7 +28,7 @@
<q:value>sailors</q:value>
</q:equal>
</filter>
<searchOnResource>true</searchOnResource>
<searchStrategy>onResource</searchStrategy>
</associationTargetSearch>
</expression>
</outbound>
Expand Down
4 changes: 2 additions & 2 deletions testing/longtest/src/test/resources/ldap/role-pirate.xml
@@ -1,5 +1,5 @@
<!--
~ Copyright (c) 2010-2017 Evolveum and contributors
~ Copyright (c) 2010-2019 Evolveum and contributors
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -36,7 +36,7 @@
<q:value>pirates</q:value>
</q:equal>
</filter>
<searchOnResource>true</searchOnResource>
<searchStrategy>onResource</searchStrategy>
</associationTargetSearch>
</expression>
</outbound>
Expand Down

0 comments on commit d5262bd

Please sign in to comment.