-
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.
- Loading branch information
Kateryna Honchar
committed
Aug 24, 2022
1 parent
829458d
commit 7fc3acd
Showing
3 changed files
with
90 additions
and
5 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
47 changes: 47 additions & 0 deletions
47
...i/src/main/java/com/evolveum/midpoint/gui/impl/factory/wrapper/BooleanWrapperFactory.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,47 @@ | ||
/* | ||
* Copyright (C) 2010-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.factory.wrapper; | ||
|
||
import com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext; | ||
import com.evolveum.midpoint.gui.api.prism.ItemStatus; | ||
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper; | ||
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismPropertyWrapper; | ||
import com.evolveum.midpoint.gui.impl.prism.wrapper.BooleanWrapperImpl; | ||
import com.evolveum.midpoint.prism.ItemDefinition; | ||
import com.evolveum.midpoint.prism.PrismProperty; | ||
import com.evolveum.midpoint.util.DOMUtil; | ||
import com.evolveum.midpoint.util.QNameUtil; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
@Component | ||
public class BooleanWrapperFactory extends PrismPropertyWrapperFactoryImpl<Boolean>{ | ||
|
||
@Override | ||
public boolean match(ItemDefinition<?> def) { | ||
return QNameUtil.match(DOMUtil.XSD_BOOLEAN, def.getTypeName()) ; | ||
} | ||
|
||
@PostConstruct | ||
@Override | ||
public void register() { | ||
getRegistry().addToRegistry(this); | ||
} | ||
|
||
@Override | ||
public int getOrder() { | ||
return 1110; | ||
} | ||
|
||
@Override | ||
protected PrismPropertyWrapper<Boolean> createWrapperInternal(PrismContainerValueWrapper<?> parent, PrismProperty<Boolean> item, | ||
ItemStatus status, WrapperContext ctx) { | ||
return new BooleanWrapperImpl(parent, item, status); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...in-gui/src/main/java/com/evolveum/midpoint/gui/impl/prism/wrapper/BooleanWrapperImpl.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,40 @@ | ||
/* | ||
* Copyright (C) 2010-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.prism.wrapper; | ||
|
||
import com.evolveum.midpoint.gui.api.prism.ItemStatus; | ||
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper; | ||
import com.evolveum.midpoint.prism.PrismProperty; | ||
import com.evolveum.midpoint.prism.delta.ItemDelta; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
import com.evolveum.midpoint.web.component.prism.ValueStatus; | ||
|
||
import java.util.Collection; | ||
|
||
public class BooleanWrapperImpl extends PrismPropertyWrapperImpl<Boolean> { | ||
private static final long serialVersionUID = 1L; | ||
|
||
public BooleanWrapperImpl(PrismContainerValueWrapper<?> parent, PrismProperty<Boolean> item, ItemStatus status) { | ||
super(parent, item, status); | ||
} | ||
|
||
@Override | ||
public <D extends ItemDelta<?, ?>> Collection<D> getDelta() throws SchemaException { | ||
PrismPropertyValueWrapper<Boolean> valueWrapper = getValue(); | ||
if (noChangesToApply(valueWrapper)){ | ||
valueWrapper.setStatus(ValueStatus.DELETED); | ||
} | ||
return super.getDelta(); | ||
} | ||
|
||
private boolean noChangesToApply(PrismPropertyValueWrapper<Boolean> valueWrapper) { | ||
return valueWrapper != null && valueWrapper.getOldValue() != null && valueWrapper.getOldValue().getValue() == null | ||
&& valueWrapper.getNewValue() != null && valueWrapper.getRealValue() != null && valueWrapper.getRealValue().equals(defaultValue()); | ||
} | ||
|
||
|
||
} |