-
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.
Support development-mode resources in model
This commit makes sure that activation, projection, and delta execution are skipped for non-production projections when running in "production configuration" mode. Work in progress.
- Loading branch information
Showing
18 changed files
with
730 additions
and
476 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
infra/schema/src/main/java/com/evolveum/midpoint/schema/util/SimulationUtil.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) 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.schema.util; | ||
|
||
import com.evolveum.midpoint.schema.constants.SchemaConstants; | ||
import com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition; | ||
import com.evolveum.midpoint.schema.processor.ResourceObjectDefinition; | ||
import com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition; | ||
import com.evolveum.midpoint.util.annotation.Experimental; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Temporary | ||
*/ | ||
public class SimulationUtil { | ||
|
||
/** | ||
* Returns true if the specified configuration item (e.g. resource, object class, object type, item, mapping, ...) | ||
* is in "production" lifecycle state. | ||
* | ||
* The idea is that configuration items in `active` and `deprecated` states will have a different behavior | ||
* than the ones in `proposed` state. (The behavior of other states is going to be determined later.) | ||
* | ||
* TODO Preliminary code. | ||
*/ | ||
@Experimental | ||
private static boolean isInProduction(String lifecycleState) { | ||
return lifecycleState == null | ||
|| SchemaConstants.LIFECYCLE_ACTIVE.equals(lifecycleState) | ||
|| SchemaConstants.LIFECYCLE_DEPRECATED.equals(lifecycleState); | ||
} | ||
|
||
@SuppressWarnings("BooleanMethodIsAlwaysInverted") | ||
public static boolean isInProduction(@NotNull ResourceType resource) { | ||
return isInProduction(resource.getLifecycleState()); | ||
} | ||
|
||
public static boolean isInProduction(@NotNull ResourceObjectDefinition objectDefinition) { | ||
// Object class | ||
ResourceObjectClassDefinition classDefinition = objectDefinition.getObjectClassDefinition(); | ||
if (!SimulationUtil.isInProduction(classDefinition.getLifecycleState())) { | ||
return false; | ||
} | ||
// Object type (if there's any) | ||
ResourceObjectTypeDefinition typeDefinition = objectDefinition.getTypeDefinition(); | ||
return typeDefinition == null || SimulationUtil.isInProduction(typeDefinition.getLifecycleState()); | ||
} | ||
|
||
/** TODO description */ | ||
public static boolean isInProduction(@NotNull ResourceType resource, @Nullable ResourceObjectDefinition objectDefinition) { | ||
if (!isInProduction(resource)) { | ||
// The whole resource is in development mode. We ignore any object class/type level settings in this case. | ||
return false; | ||
} else { | ||
// If there is an object class, it must be in production | ||
return objectDefinition == null || isInProduction(objectDefinition); | ||
} | ||
} | ||
} |
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
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.