Skip to content

Commit

Permalink
Add basic object type hierarchy features to XSD
Browse files Browse the repository at this point in the history
(Plus minor code cleanup.)
  • Loading branch information
mederly committed Apr 20, 2022
1 parent edca82e commit e0327df
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,11 @@ public class ObjectClassDetailsDto implements Serializable{
private boolean isDefault;

public ObjectClassDetailsDto(ResourceObjectTypeDefinition definition){
if(definition != null){
if (definition != null) {
displayName = definition.getDisplayName() != null ? definition.getDisplayName() : VALUE_NOT_SPECIFIED;
description = definition.getDescription() != null ? definition.getDescription() : VALUE_NOT_SPECIFIED;

if(definition.getKind() != null){
kind = definition.getKind().value();
} else

intent = definition.getIntent() != null ? definition.getIntent() : VALUE_NOT_SPECIFIED;
kind = definition.getKind().value();
intent = definition.getIntent();
String nativeObjectClassName = definition.getObjectClassDefinition().getNativeObjectClass();
this.nativeObjectClass = nativeObjectClassName != null ? nativeObjectClassName : VALUE_NOT_SPECIFIED;
isDefault = definition.isDefaultForKind();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.annotation.ItemDiagramSpecification;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceAttributeDefinitionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
Expand Down Expand Up @@ -156,26 +154,21 @@ public PrismObjectDefinition<ShadowType> computePrismObjectDefinition() {

@Override
public PrismObject<ShadowType> createBlankShadow(String resourceOid, String tag) {
PrismObject<ShadowType> accountShadow;
try {
accountShadow = getPrismContext().createObject(ShadowType.class);
} catch (SchemaException e) {
// This should not happen
throw new SystemException("Internal error instantiating account shadow: " + e.getMessage(), e);
}
ShadowType accountShadowType = accountShadow.asObjectable();
ShadowType shadow =
new ShadowType()
.tag(tag)
.objectClass(getObjectClassDefinition().getTypeName())
.resourceRef(resourceOid, ResourceType.COMPLEX_TYPE);

accountShadowType
.tag(tag)
.objectClass(getObjectClassDefinition().getTypeName())
.resourceRef(resourceOid, ResourceType.COMPLEX_TYPE);
PrismObject<ShadowType> shadowPrismObject = shadow.asPrismObject();

// Setup definition
PrismObjectDefinition<ShadowType> newDefinition = accountShadow.getDefinition().cloneWithReplacedDefinition(
ShadowType.F_ATTRIBUTES, toResourceAttributeContainerDefinition());
accountShadow.setDefinition(newDefinition);
shadowPrismObject.setDefinition(
shadowPrismObject.getDefinition()
.cloneWithReplacedDefinition(
ShadowType.F_ATTRIBUTES, toResourceAttributeContainerDefinition()));

return accountShadow;
return shadowPrismObject;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
import org.jetbrains.annotations.NotNull;

/**
* Used to represent combined definition of structural and auxiliary object classes.
* Represents ad-hoc combination of definitions of structural and auxiliary object classes.
*
* @author semancik
*
*/
public interface CompositeObjectDefinition extends ResourceObjectDefinition, LayeredDefinition {

Expand All @@ -31,7 +30,8 @@ public interface CompositeObjectDefinition extends ResourceObjectDefinition, Lay
@NotNull Collection<ResourceObjectDefinition> getAuxiliaryDefinitions();

/**
* The restriction to the structural definition is intentional.
* Returns the names of auxiliary object classes that are "statically" defined for the structural object type.
* (The restriction to the structural definition is intentional.)
*
* @see ResourceObjectDefinition#getConfiguredAuxiliaryObjectClassNames()
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.annotation.ItemDiagramSpecification;
Expand All @@ -32,7 +31,7 @@
import org.jetbrains.annotations.Nullable;

/**
* Used to represent combined definition of structural and auxiliary object classes.
* Represents ad-hoc combination of definitions of structural and auxiliary object classes.
*
* @author semancik
*/
Expand Down Expand Up @@ -103,11 +102,6 @@ public boolean isObjectMarker() {
return structuralDefinition.isObjectMarker();
}

@Override
public boolean isIgnored() {
return structuralDefinition.isIgnored();
}

@Override
public ItemProcessing getProcessing() {
return structuralDefinition.getProcessing();
Expand Down Expand Up @@ -197,7 +191,6 @@ public boolean isRuntimeSchema() {
return structuralDefinition.isRuntimeSchema();
}

@SuppressWarnings("unchecked") // temporary workaround
@NotNull
@Override
public Collection<? extends ResourceAttributeDefinition<?>> getPrimaryIdentifiers() {
Expand All @@ -209,7 +202,6 @@ public Collection<? extends ResourceAttributeDefinition<?>> getPrimaryIdentifier
return structuralDefinition.getPrimaryIdentifiersNames();
}

@SuppressWarnings("unchecked") // temporary workaround
@NotNull
@Override
public Collection<? extends ResourceAttributeDefinition<?>> getSecondaryIdentifiers() {
Expand Down Expand Up @@ -309,7 +301,6 @@ public <T extends CapabilityType> T getEffectiveCapability(Class<T> capabilityCl
return structuralDefinition.getEffectiveCapability(capabilityClass, resource);
}

@SuppressWarnings("unchecked") // temporary workaround
@NotNull
@Override
public List<? extends ResourceAttributeDefinition<?>> getAttributeDefinitions() {
Expand Down Expand Up @@ -375,11 +366,6 @@ public List<String> getIgnoredNamespaces() {
return structuralDefinition.getIgnoredNamespaces();
}

// @Override
// public LayerRefinedObjectDefinition forLayer(@NotNull LayerType layerType) {
// return LayerRefinedObjectDefinitionImpl.wrap(this, layerType);
// }

public Collection<ResourceAssociationDefinition> getEntitlementAssociationDefinitions() {
return getAssociationDefinitions(ShadowKindType.ENTITLEMENT);
}
Expand Down Expand Up @@ -421,23 +407,11 @@ public Class<?> getTypeClass() {
return ShadowAttributesType.class;
}

// TODO what is this for?
private Stream<ResourceObjectDefinition> getRefinedObjectClassDefinitionsStream() {
return Stream.concat(
Stream.of(structuralDefinition),
auxiliaryDefinitions.stream());
}

@Override
public PrismObject<ShadowType> createBlankShadow(String resourceOid, String tag) {
return structuralDefinition.createBlankShadow(resourceOid, tag);
}

// @Override
// public ResourceShadowDiscriminator getShadowDiscriminator() {
// return structuralObjectClassDefinition.getShadowDiscriminator();
// }

@Override
public ResourcePasswordDefinitionType getPasswordDefinition() {
return findInDefinitions(ResourceObjectDefinition::getPasswordDefinition);
Expand Down Expand Up @@ -508,9 +482,6 @@ public boolean equals(Object obj) {
if (this == obj) {
return true;
}
// if (!super.equals(obj)) {
// return false;
// }
if (getClass() != obj.getClass()) {
return false;
}
Expand All @@ -526,10 +497,6 @@ public boolean equals(Object obj) {

@Override
public String debugDump(int indent) {
return debugDump(indent, (LayerType) null);
}

protected String debugDump(int indent, LayerType layer) {
StringBuilder sb = new StringBuilder();
sb.append(INDENT_STRING.repeat(Math.max(0, indent)));
sb.append(getDebugDumpClassName()).append(getMutabilityFlag()).append(": ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PagedSearchCapabilityType;

/**
* Definition that describes either an object class (as fetched from the resource),
* A definition that describes either an object class (as fetched from the resource),
* or an object type (as defined in `schemaHandling` part of resource definition).
*
* It is used as a common interface to both "raw" and "refined" definitions.
* (E.g. in cases when there is no `schemaHandling` for given object class, or globally.)
* It is used as a common interface to both "raw" and "refined" definitions. (Raw definitions are used e.g. in cases
* when there is no `schemaHandling` for given object class, or for the resource as a whole.)
*
* Note: Before midPoint 4.5, this interface was known as ObjectClassComplexTypeDefinition.
* Note: Before midPoint 4.5, this interface was known as `ObjectClassComplexTypeDefinition`.
* So the hierarchy was:
*
* ComplexTypeDefinition
Expand All @@ -57,7 +57,7 @@
*
* This change eliminates e.g. the need to create "artificial" refined object class definitions just to allow
* model and provisioning modules to work with object classes not described in schema handling. (Confusion stemmed
* e.g. from the fact that RefinedObjectClassDefinition had to have kind/intent. This is now fixed.)
* e.g. from the fact that `RefinedObjectClassDefinition` had to have kind/intent. This is now fixed.)
*/
public interface ResourceObjectDefinition
extends
Expand All @@ -69,7 +69,7 @@ public interface ResourceObjectDefinition

/**
* Returns the object class definition. It is either this object itself,
* or the linked definition (for object type).
* or the linked object class definition (for object type).
*/
@NotNull ResourceObjectClassDefinition getObjectClassDefinition();

Expand All @@ -84,8 +84,6 @@ public interface ResourceObjectDefinition
*
* For dynamically composed definitions ({@link CompositeObjectDefinition} only the statically-defined ones
* (i.e. those from the structural definition) are returned.
*
* TODO
*/
@Experimental
Collection<QName> getConfiguredAuxiliaryObjectClassNames();
Expand Down Expand Up @@ -302,7 +300,7 @@ default ResourceBidirectionalMappingType getActivationBidirectionalMappingType(I
/**
* Returns the phases in which inbound mappings are evaluated by default.
*
* @see ResourceObjectTypeDefinitionType#getInboundMappingsEvaluation()
* @see ResourceObjectTypeDefinitionType#getMappingsEvaluation()
*/
@Nullable DefaultInboundMappingEvaluationPhasesType getDefaultInboundMappingEvaluationPhases();
//endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public ResourceActivationDefinitionType getActivationSchemaHandling() {
if (configuredCapabilities == null) {
return null;
}
CapabilitiesType capabilitiesType = new CapabilitiesType(getPrismContext());
CapabilitiesType capabilitiesType = new CapabilitiesType();
capabilitiesType.setConfigured(configuredCapabilities);
return capabilitiesType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3852,27 +3852,13 @@
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<!-- <xsd:element name="objectClass" type="tns:ResourceObjectTypeDefinitionType" minOccurs="0"
maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
The objectClass part of schema handling definition provides a mechanism to redefine schema
object classes. The object classes are tough of as being fairly abstract. This definition
may define default values to set for each instance of this object class. It may define
default mapping. But these definitions should be directly used in constructions in roles
and assignments. The objectType definitions below are supposed to be used for that purpose.
</xsd:documentation>
</xsd:annotation>
</xsd:element> -->
<xsd:element name="objectType" type="tns:ResourceObjectTypeDefinitionType" minOccurs="0"
maxOccurs="unbounded">
<xsd:element name="objectType" type="tns:ResourceObjectTypeDefinitionType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
The objectType part of schema handling definition provides a mechanism to define
concrete types of objects that this resource supports. There should be definitions
of account types, entitlement types, etc.
There are the definitions that should be used in constructions in roles, orgs,
assignments, etc.
of account types, entitlement types, etc. These are the definitions that should be
used in constructions in roles, orgs, assignments, etc.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
Expand Down Expand Up @@ -3909,17 +3895,31 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="intent" type="xsd:string" minOccurs="0">
<xsd:element name="intent" type="xsd:string" minOccurs="0" default="default">
<xsd:annotation>
<xsd:documentation>
Intent of objects covered by this type.
If not specified, then XXXXXXXXXXXX.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element ref="tns:displayName" minOccurs="0"/>
<xsd:element ref="tns:description" minOccurs="0"/>
<xsd:element ref="tns:documentation" minOccurs="0"/>
<xsd:element name="abstract" type="xsd:boolean" minOccurs="0" default="false">
<xsd:annotation>
<xsd:documentation>
Is this an abstract object type? Such a type cannot be referenced from a construction,
nor it can be used as a categorization result.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="parent" type="tns:ParentObjectTypeReferenceType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Parent (super) type of this resource object type.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="default" type="xsd:boolean" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -4172,6 +4172,35 @@
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:complexType name="ParentObjectTypeReferenceType">
<xsd:annotation>
<xsd:documentation>
References a parent object type.
</xsd:documentation>
<xsd:appinfo>
<a:container/>
<a:since>4.6</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="kind" type="tns:ShadowKindType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Kind of the parent type. If not specified, the kind of the child is used.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="intent" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Intent of the parent type. Should be specified.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:complexType name="ResourceMappingsEvaluationConfigurationType">
<xsd:annotation>
<xsd:documentation>
Expand Down

0 comments on commit e0327df

Please sign in to comment.