Skip to content

Commit

Permalink
Merge branch 'feature/plugin-support'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Sep 6, 2016
2 parents 6a7f7a5 + 0f12185 commit bef8408
Show file tree
Hide file tree
Showing 8 changed files with 448 additions and 2 deletions.
Expand Up @@ -19,6 +19,7 @@
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;
import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.NotNull;

import javax.xml.namespace.QName;
import java.io.Serializable;
Expand Down Expand Up @@ -434,6 +435,17 @@ public ItemPath append(ItemPath childPath) {
return new ItemPath(this, childPath);
}

@NotNull
public static List<ItemPath> fromStringList(List<String> pathsAsStrings) {
List<ItemPath> rv = new ArrayList<>();
if (pathsAsStrings != null) {
for (String pathAsString : pathsAsStrings) {
rv.add(new ItemPathType(pathAsString).getItemPath());
}
}
return rv;
}

public enum CompareResult {
EQUIVALENT,
SUPERPATH,
Expand Down
Expand Up @@ -16,13 +16,15 @@
package com.evolveum.midpoint.schema;

import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.GetOperationOptionsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

import javax.xml.namespace.QName;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
* @author semancik
Expand Down Expand Up @@ -485,4 +487,26 @@ private void appendVal(StringBuilder sb, String name, Object val) {
}
}

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

GetOperationOptions rv = new GetOperationOptions();
for (String option : options) {
if (GetOperationOptionsType.F_RAW.getLocalPart().equals(option)) {
rv.setRaw(true);
}
if (GetOperationOptionsType.F_NO_FETCH.getLocalPart().equals(option)) {
rv.setNoFetch(true);
}
if (GetOperationOptionsType.F_NO_DISCOVERY.getLocalPart().equals(option)) {
rv.setDoNotDiscovery(true);
}
}

return rv;
}


}
Expand Up @@ -451,5 +451,45 @@
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="CompareResultType">
<xsd:annotation>
<xsd:documentation>
EXPERIMENTAL. TODO.
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="currentToProvided" type="t:ObjectDeltaType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Delta that would change the current object (in midPoint) into the client-provided one.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="providedToCurrent" type="t:ObjectDeltaType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Delta that would change the client-provided object to the current object (in midPoint).
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="normalizedObject" type="c:ObjectType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
"Normalized version" of provided object (i.e. the one that is created by parsing and re-serializing the object.)
Items to be ignored are left out from it.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="currentObject" type="c:ObjectType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Current version of object, as stored in midPoint.
Items to be ignored are left out from it.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

</xsd:schema>

Expand Up @@ -10776,7 +10776,46 @@
</xsd:sequence>
</xsd:complexType>

<xsd:simpleType name="SynchronizationIntentType">
<xsd:complexType name="ModelCompareOptionsType">
<xsd:annotation>
<xsd:documentation>
EXPERIMENTAL.
TODO
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="computeCurrentToProvided" type="xsd:boolean" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Computes current-to-provided delta. ("Current" means the object that is currently available in the midPoint.)
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="computeProvidedToCurrent" type="xsd:boolean" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Computes provided-to-current delta.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="returnNormalized" type="xsd:boolean" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Returns the normalized version of provided object.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="returnCurrent" type="xsd:boolean" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Returns the current version of provided object.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

<xsd:simpleType name="SynchronizationIntentType">
<xsd:annotation>
<xsd:documentation>
TODO
Expand Down
@@ -0,0 +1,177 @@
/*
* Copyright (c) 2010-2016 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.model.api;

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

import java.io.Serializable;
import java.util.List;

/**
* Options to be used for compareObject calls.
*
* EXPERIMENTAL
*
* @author mederly
*
*/
public class ModelCompareOptions implements Serializable, Cloneable {

/**
* Computes current-to-provided delta. ("Current" means the object that is currently available in the midPoint.)
*/
Boolean computeCurrentToProvided;

/**
* Computes provided-to-current delta.
*/
Boolean computeProvidedToCurrent;

/**
* Returns the normalized version of provided object.
*/
Boolean returnNormalized;

/**
* Returns the current version of provided object.
*/
Boolean returnCurrent;

public Boolean getComputeCurrentToProvided() {
return computeCurrentToProvided;
}

public void setComputeCurrentToProvided(Boolean computeCurrentToProvided) {
this.computeCurrentToProvided = computeCurrentToProvided;
}

public static boolean isComputeCurrentToProvided(ModelCompareOptions options) {
return options != null && options.computeCurrentToProvided != null && options.computeCurrentToProvided;
}

public Boolean getComputeProvidedToCurrent() {
return computeProvidedToCurrent;
}

public void setComputeProvidedToCurrent(Boolean computeProvidedToCurrent) {
this.computeProvidedToCurrent = computeProvidedToCurrent;
}

public static boolean isComputeProvidedToCurrent(ModelCompareOptions options) {
return options != null && options.computeProvidedToCurrent != null && options.computeProvidedToCurrent;
}

public Boolean getReturnNormalized() {
return returnNormalized;
}

public void setReturnNormalized(Boolean returnNormalized) {
this.returnNormalized = returnNormalized;
}

public static boolean isReturnNormalized(ModelCompareOptions options) {
return options != null && options.returnNormalized != null && options.returnNormalized;
}

public Boolean getReturnCurrent() {
return returnCurrent;
}

public void setReturnCurrent(Boolean returnCurrent) {
this.returnCurrent = returnCurrent;
}

public static boolean isReturnCurrent(ModelCompareOptions options) {
return options != null && options.returnCurrent != null && options.returnCurrent;
}

public ModelCompareOptionsType toModelCompareOptionsType() {
ModelCompareOptionsType retval = new ModelCompareOptionsType();
retval.setComputeCurrentToProvided(computeCurrentToProvided);
retval.setComputeProvidedToCurrent(computeProvidedToCurrent);
retval.setReturnNormalized(returnNormalized);
retval.setReturnCurrent(returnCurrent);
return retval;
}

public static ModelCompareOptions fromModelCompareOptionsType(ModelCompareOptionsType type) {
if (type == null) {
return null;
}
ModelCompareOptions retval = new ModelCompareOptions();
retval.setComputeProvidedToCurrent(type.isComputeProvidedToCurrent());
retval.setComputeCurrentToProvided(type.isComputeCurrentToProvided());
retval.setReturnNormalized(type.isReturnNormalized());
retval.setReturnCurrent(type.isReturnCurrent());
return retval;
}

public static ModelCompareOptions fromRestOptions(List<String> options){
if (options == null || options.isEmpty()){
return null;
}

ModelCompareOptions rv = new ModelCompareOptions();
for (String option : options){
if (ModelCompareOptionsType.F_COMPUTE_CURRENT_TO_PROVIDED.getLocalPart().equals(option)){
rv.setComputeCurrentToProvided(true);
}
if (ModelCompareOptionsType.F_COMPUTE_PROVIDED_TO_CURRENT.getLocalPart().equals(option)){
rv.setComputeProvidedToCurrent(true);
}
if (ModelCompareOptionsType.F_RETURN_NORMALIZED.getLocalPart().equals(option)){
rv.setReturnNormalized(true);
}
if (ModelCompareOptionsType.F_RETURN_CURRENT.getLocalPart().equals(option)){
rv.setReturnCurrent(true);
}
}
return rv;
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder("ModelCompareOptions(");
appendFlag(sb, "computeCurrentToProvided", computeCurrentToProvided);
appendFlag(sb, "computeProvidedToCurrent", computeProvidedToCurrent);
appendFlag(sb, "returnNormalized", returnNormalized);
appendFlag(sb, "returnCurrent", returnCurrent);
if (sb.charAt(sb.length() - 1) == ',') {
sb.deleteCharAt(sb.length() - 1);
}
sb.append(")");
return sb.toString();
}

private void appendFlag(StringBuilder sb, String name, Boolean val) {
if (val == null) {
return;
} else if (val) {
sb.append(name);
sb.append(",");
} else {
sb.append(name);
sb.append("=false,");
}
}

public ModelCompareOptions clone() {
// not much efficient, but...
ModelCompareOptions clone = fromModelCompareOptionsType(toModelCompareOptionsType());
return clone;
}

}

0 comments on commit bef8408

Please sign in to comment.