-
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.
MID-8842 ninja - search object type processor + test
(cherry picked from commit 2dd10c8)
- Loading branch information
Showing
4 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
...ain/java/com/evolveum/midpoint/schema/validator/processor/DefaultObjectTypeProcessor.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,63 @@ | ||
/* | ||
* Copyright (C) 2010-2023 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.schema.validator.processor; | ||
|
||
import com.evolveum.midpoint.prism.PrismObject; | ||
import com.evolveum.midpoint.prism.path.ItemPath; | ||
import com.evolveum.midpoint.schema.validator.UpgradeObjectProcessor; | ||
import com.evolveum.midpoint.schema.validator.UpgradePhase; | ||
import com.evolveum.midpoint.schema.validator.UpgradePriority; | ||
import com.evolveum.midpoint.schema.validator.UpgradeType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTypeSearchItemConfigurationType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.SearchBoxConfigurationType; | ||
|
||
import javax.xml.namespace.QName; | ||
|
||
@SuppressWarnings("unused") | ||
public class DefaultObjectTypeProcessor implements UpgradeObjectProcessor<ObjectType> { | ||
|
||
@Override | ||
public UpgradePhase getPhase() { | ||
return UpgradePhase.BEFORE; | ||
} | ||
|
||
@Override | ||
public UpgradePriority getPriority() { | ||
return UpgradePriority.NECESSARY; | ||
} | ||
|
||
@Override | ||
public UpgradeType getType() { | ||
return UpgradeType.SEAMLESS; | ||
} | ||
|
||
@Override | ||
public boolean isApplicable(PrismObject<?> object, ItemPath path) { | ||
return matchParentTypeAndItemName(object, path, SearchBoxConfigurationType.class, SearchBoxConfigurationType.F_DEFAULT_OBJECT_TYPE); | ||
} | ||
|
||
@Override | ||
public boolean process(PrismObject<ObjectType> object, ItemPath path) throws Exception { | ||
SearchBoxConfigurationType config = getItemParent(object, path); | ||
QName type = config.getDefaultObjectType(); | ||
|
||
ObjectTypeSearchItemConfigurationType typeConfig = config.getObjectTypeConfiguration(); | ||
if (typeConfig == null) { | ||
typeConfig = new ObjectTypeSearchItemConfigurationType(); | ||
config.setObjectTypeConfiguration(typeConfig); | ||
} | ||
|
||
if (typeConfig.getDefaultValue() == null) { | ||
typeConfig.setDefaultValue(type); | ||
} | ||
config.setDefaultObjectType(null); | ||
|
||
return true; | ||
} | ||
} |
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