Skip to content

Commit

Permalink
Merge branch 'post-3.7-fixes' of github.com:Evolveum/midpoint into po…
Browse files Browse the repository at this point in the history
…st-3.7-fixes
  • Loading branch information
semancik committed Jan 10, 2018
2 parents d939a53 + 98da921 commit e2abddc
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 5 deletions.
Expand Up @@ -16,6 +16,8 @@

package com.evolveum.midpoint.schema;

import com.evolveum.midpoint.xml.ns._public.common.common_3.DefinitionProcessingOptionType;

/**
* How should be definitions processed when object is to be retrieved. Currently applies at the model level;
* but in the future it might be used also elsewhere.
Expand All @@ -42,6 +44,35 @@ public enum DefinitionProcessingOption {
*
* NOT IMPLEMENTED YET
*/
NONE
NONE;


public static DefinitionProcessingOption toDefinitionProcessingOption(DefinitionProcessingOptionType definitionProcessingOptionType) {
if (definitionProcessingOptionType == null) {
return null;
}

switch (definitionProcessingOptionType) {
case FULL: return DefinitionProcessingOption.FULL;
case ONLY_IF_EXISTS: return DefinitionProcessingOption.ONLY_IF_EXISTS;
case NONE : return DefinitionProcessingOption.NONE;
default:
throw new IllegalStateException("Unknown definition processing option: " + definitionProcessingOptionType);
}
}

public static DefinitionProcessingOptionType toDefinitionProcessingOptionType(DefinitionProcessingOption definitionProcessingOption) {
if (definitionProcessingOption == null) {
return null;
}

switch (definitionProcessingOption) {
case FULL : return DefinitionProcessingOptionType.FULL;
case ONLY_IF_EXISTS : return DefinitionProcessingOptionType.ONLY_IF_EXISTS;
case NONE : return DefinitionProcessingOptionType.NONE;
default:
throw new IllegalStateException("Unknown definition processing option: " + definitionProcessingOption);
}

}
}
Expand Up @@ -771,7 +771,7 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects
.hash(retrieve, resolve, resolveNames, noFetch, raw, tolerateRawData, doNotDiscovery, relationalValueSearchQuery,
allowNotFound, readOnly, staleness, distinct);
allowNotFound, readOnly, staleness, distinct, definitionProcessing);
}

public GetOperationOptions clone() {
Expand All @@ -790,6 +790,7 @@ public GetOperationOptions clone() {
if (this.relationalValueSearchQuery != null) {
clone.relationalValueSearchQuery = this.relationalValueSearchQuery.clone();
}
clone.definitionProcessing = this.definitionProcessing;
return clone;
}

Expand All @@ -808,18 +809,22 @@ public String toString() {
appendVal(sb, "staleness", staleness);
appendVal(sb, "distinct", distinct);
appendVal(sb, "relationalValueSearchQuery", relationalValueSearchQuery);
appendVal(sb, "definitionProcessing", definitionProcessing);
removeLastComma(sb);
sb.append(")");
return sb.toString();
}


public static Collection<SelectorOptions<GetOperationOptions>> fromRestOptions(List<String> options, List<String> include, List<String> exclude) {
public static Collection<SelectorOptions<GetOperationOptions>> fromRestOptions(List<String> options, List<String> include, List<String> exclude, DefinitionProcessingOption definitionProcessing) {
if (CollectionUtils.isEmpty(options) && CollectionUtils.isEmpty(include) && CollectionUtils.isEmpty(exclude)) {
if (definitionProcessing != null) {
return SelectorOptions.createCollection(GetOperationOptions.createDefinitionProcessing(definitionProcessing));
}
return null;
}
Collection<SelectorOptions<GetOperationOptions>> rv = new ArrayList<>();
GetOperationOptions rootOptions = fromRestOptions(options);
GetOperationOptions rootOptions = fromRestOptions(options, definitionProcessing);
if (rootOptions != null) {
rv.add(SelectorOptions.create(rootOptions));
}
Expand All @@ -832,8 +837,11 @@ public static Collection<SelectorOptions<GetOperationOptions>> fromRestOptions(L
return rv;
}

public static GetOperationOptions fromRestOptions(List<String> options) {
public static GetOperationOptions fromRestOptions(List<String> options, DefinitionProcessingOption definitionProcessing) {
if (options == null || options.isEmpty()){
if (definitionProcessing != null) {
return GetOperationOptions.createDefinitionProcessing(definitionProcessing);
}
return null;
}

Expand All @@ -852,6 +860,8 @@ public static GetOperationOptions fromRestOptions(List<String> options) {
rv.setResolveNames(true);
}
}

rv.setDefinitionProcessing(definitionProcessing);

return rv;
}
Expand Down
Expand Up @@ -179,6 +179,7 @@ private static GetOperationOptionsType getOptionsToGetOptionsType(GetOperationOp
// TODO relational value search query (but it might become obsolete)
optionsType.setAllowNotFound(options.getAllowNotFound());
optionsType.setPointInTimeType(PointInTimeType.toPointInTimeTypeType(options.getPointInTimeType()));
optionsType.setDefinitionProcessing(DefinitionProcessingOption.toDefinitionProcessingOptionType(options.getDefinitionProcessing()));
optionsType.setStaleness(options.getStaleness());
optionsType.setDistinct(options.getDistinct());
return optionsType;
Expand Down Expand Up @@ -213,6 +214,7 @@ private static GetOperationOptions getOptionsTypeToGetOptions(GetOperationOption
// TODO relational value search query (but it might become obsolete)
options.setAllowNotFound(optionsType.isAllowNotFound());
options.setPointInTimeType(PointInTimeType.toPointInTimeType(optionsType.getPointInTimeType()));
options.setDefinitionProcessing(DefinitionProcessingOption.toDefinitionProcessingOption(optionsType.getDefinitionProcessing()));
options.setStaleness(optionsType.getStaleness());
options.setDistinct(optionsType.isDistinct());
return options;
Expand Down
Expand Up @@ -15526,6 +15526,7 @@ ConstructionType.kind.help=Kind of resource object that should be created on the
<xsd:element name="pointInTimeType" type="tns:PointInTimeTypeType" minOccurs="0"/>
<xsd:element name="staleness" type="xsd:long" minOccurs="0"/>
<xsd:element name="distinct" type="xsd:boolean" minOccurs="0"/>
<xsd:element name="definitionProcessing" type="tns:DefinitionProcessingOptionType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>

Expand Down Expand Up @@ -15596,6 +15597,58 @@ ConstructionType.kind.help=Kind of resource object that should be created on the
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="DefinitionProcessingOptionType">
<xsd:annotation>
<xsd:documentation>
How should be definitions processed when object is to be retrieved. Currently applies at the model level;
but in the future it might be used also elsewhere.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumClass/>
<a:since>3.7.1</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="full">
<xsd:annotation>
<xsd:documentation>
Full definition processing for the specified item(s) is to be done.
This applies recursively also to sub-items.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="FULL"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="onlyIfExists">
<xsd:annotation>
<xsd:documentation>
Full definition processing for the specified item(s) is to be done, but only if the item(s) exist.
This applies recursively also to sub-items.

Currently supported on root level only.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="ONLY_IF_EXISTS"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="none">
<xsd:annotation>
<xsd:documentation>
Definition for the specified item(s) is to be excluded from the resulting object, even if the item(s) do exist.

NOT IMPLEMENTED YET
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="NONE"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>


<xsd:simpleType name="IterationMethodType">
<xsd:annotation>
Expand Down

0 comments on commit e2abddc

Please sign in to comment.