Skip to content

Commit

Permalink
Aligning mapping source/target schema, schema for mapping domain (MID…
Browse files Browse the repository at this point in the history
…-3692)
  • Loading branch information
semancik committed Jan 23, 2017
1 parent 769fdc2 commit ea5f880
Show file tree
Hide file tree
Showing 12 changed files with 108 additions and 65 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -627,7 +627,7 @@ private String formatItemInfo(ResourceItemDefinitionType item, ItemPathType ref,
if (outbound != null) {
sb.append(" | ").append(getString("SchemaHandlingStep.out")).append(": ");
boolean first = true;
for (MappingSourceDeclarationType source : outbound.getSource()) {
for (VariableBindingDefinitionType source : outbound.getSource()) {
if (source != null) {
if (first) first = false; else sb.append(", ");
sb.append(formatPath(source.getPath()));
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -117,7 +117,7 @@ private void prepareActivationObject(ResourceActivationDefinitionType activation
} else {
for(MappingType mapping: activation.getExistence().getInbound()){
if(mapping.equals(new MappingType())){
MappingSourceDeclarationType source = new MappingSourceDeclarationType();
VariableBindingDefinitionType source = new VariableBindingDefinitionType();
source.setPath(new ItemPathType(EXISTENCE_DEFAULT_SOURCE));
mapping.getSource().add(source);
}
Expand All @@ -129,23 +129,23 @@ private void prepareActivationObject(ResourceActivationDefinitionType activation
} else {
for(MappingType outbound: activation.getAdministrativeStatus().getOutbound()){
if(outbound.equals(new MappingType())){
MappingSourceDeclarationType source = new MappingSourceDeclarationType();
VariableBindingDefinitionType source = new VariableBindingDefinitionType();
source.setPath(new ItemPathType(ADM_STATUS_OUT_SOURCE_DEFAULT));
outbound.getSource().add(source);

MappingTargetDeclarationType target = new MappingTargetDeclarationType();
VariableBindingDefinitionType target = new VariableBindingDefinitionType();
target.setPath(new ItemPathType(ADM_STATUS_OUT_TARGET_DEFAULT));
outbound.setTarget(target);
}
}

for(MappingType inbound: activation.getAdministrativeStatus().getInbound()){
if(inbound.equals(new MappingType())){
MappingSourceDeclarationType source = new MappingSourceDeclarationType();
VariableBindingDefinitionType source = new VariableBindingDefinitionType();
source.setPath(new ItemPathType(ADM_STATUS_IN_SOURCE_DEFAULT));
inbound.getSource().add(source);

MappingTargetDeclarationType target = new MappingTargetDeclarationType();
VariableBindingDefinitionType target = new VariableBindingDefinitionType();
target.setPath(new ItemPathType(ADM_STATUS_IN_TARGET_DEFAULT));
inbound.setTarget(target);
}
Expand All @@ -157,23 +157,23 @@ private void prepareActivationObject(ResourceActivationDefinitionType activation
} else {
for(MappingType outbound: activation.getValidFrom().getOutbound()){
if(outbound.equals(new MappingType())){
MappingSourceDeclarationType source = new MappingSourceDeclarationType();
VariableBindingDefinitionType source = new VariableBindingDefinitionType();
source.setPath(new ItemPathType(VALID_FROM_OUT_SOURCE_DEFAULT));
outbound.getSource().add(source);

MappingTargetDeclarationType target = new MappingTargetDeclarationType();
VariableBindingDefinitionType target = new VariableBindingDefinitionType();
target.setPath(new ItemPathType(VALID_FROM_OUT_TARGET_DEFAULT));
outbound.setTarget(target);
}
}

for(MappingType inbound: activation.getValidFrom().getInbound()){
if(inbound.equals(new MappingType())){
MappingSourceDeclarationType source = new MappingSourceDeclarationType();
VariableBindingDefinitionType source = new VariableBindingDefinitionType();
source.setPath(new ItemPathType(VALID_FROM_IN_SOURCE_DEFAULT));
inbound.getSource().add(source);

MappingTargetDeclarationType target = new MappingTargetDeclarationType();
VariableBindingDefinitionType target = new VariableBindingDefinitionType();
target.setPath(new ItemPathType(VALID_FROM_IN_TARGET_DEFAULT));
inbound.setTarget(target);
}
Expand All @@ -185,23 +185,23 @@ private void prepareActivationObject(ResourceActivationDefinitionType activation
} else {
for(MappingType outbound: activation.getValidTo().getOutbound()){
if(outbound.equals(new MappingType())){
MappingSourceDeclarationType source = new MappingSourceDeclarationType();
VariableBindingDefinitionType source = new VariableBindingDefinitionType();
source.setPath(new ItemPathType(VALID_TO_OUT_SOURCE_DEFAULT));
outbound.getSource().add(source);

MappingTargetDeclarationType target = new MappingTargetDeclarationType();
VariableBindingDefinitionType target = new VariableBindingDefinitionType();
target.setPath(new ItemPathType(VALID_TO_OUT_TARGET_DEFAULT));
outbound.setTarget(target);
}
}

for(MappingType inbound: activation.getValidTo().getInbound()){
if(inbound.equals(new MappingType())){
MappingSourceDeclarationType source = new MappingSourceDeclarationType();
VariableBindingDefinitionType source = new VariableBindingDefinitionType();
source.setPath(new ItemPathType(VALID_TO_IN_SOURCE_DEFAULT));
inbound.getSource().add(source);

MappingTargetDeclarationType target = new MappingTargetDeclarationType();
VariableBindingDefinitionType target = new VariableBindingDefinitionType();
target.setPath(new ItemPathType(VALID_TO_IN_TARGET_DEFAULT));
inbound.setTarget(target);
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -83,7 +83,7 @@ public MappingTypeDto(MappingType mapping, PrismContext prismContext){

oldMappingObject = mappingObject.clone();

for(MappingSourceDeclarationType mappingSource: mappingObject.getSource()){
for(VariableBindingDefinitionType mappingSource: mappingObject.getSource()){
if(mappingSource.getPath() != null && mappingSource.getPath().getItemPath() != null){
source.add(mappingSource.getPath().getItemPath().toString());
}
Expand Down Expand Up @@ -139,21 +139,21 @@ public MappingType prepareDtoToSave(PrismContext prismContext) throws SchemaExce
}

if(target != null){
MappingTargetDeclarationType mappingTarget = new MappingTargetDeclarationType();
VariableBindingDefinitionType mappingTarget = new VariableBindingDefinitionType();
mappingTarget.setPath(new ItemPathType(target));
mappingObject.setTarget(mappingTarget);
} else {
mappingObject.setTarget(null);
}

mappingObject.getSource().clear();
List<MappingSourceDeclarationType> mappingSourceList = new ArrayList<>();
List<VariableBindingDefinitionType> mappingSourceList = new ArrayList<>();
for(String s: source){
if(s == null){
continue;
}

MappingSourceDeclarationType mappingSource = new MappingSourceDeclarationType();
VariableBindingDefinitionType mappingSource = new VariableBindingDefinitionType();
mappingSource.setPath(new ItemPathType(s));
mappingSourceList.add(mappingSource);
}
Expand Down Expand Up @@ -346,7 +346,7 @@ public static String createMappingLabel(MappingType mapping, Trace LOGGER, Prism
}

if(!mapping.getSource().isEmpty()){
for(MappingSourceDeclarationType source: mapping.getSource()){
for(VariableBindingDefinitionType source: mapping.getSource()){
if(source.getPath() != null && source.getPath().getItemPath() != null
&& source.getPath().getItemPath().getSegments() != null){

Expand All @@ -367,7 +367,7 @@ public static String createMappingLabel(MappingType mapping, Trace LOGGER, Prism
sb.append("->");

if (mapping.getTarget() != null) {
MappingTargetDeclarationType target = mapping.getTarget();
VariableBindingDefinitionType target = mapping.getTarget();
if (target.getPath() != null && !ItemPath.isNullOrEmpty(target.getPath().getItemPath())) {
List<ItemPathSegment> segments = target.getPath().getItemPath().getSegments();
sb.append(segments.get(segments.size() - 1));
Expand Down
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright (c) 2010-2016 Evolveum
~ Copyright (c) 2010-2017 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -46,7 +46,7 @@
<a href="https://wiki.evolveum.com/display/midPoint/Data+Model">https://wiki.evolveum.com/display/midPoint/Data+Model</a>
for more details.

<p>Version: 3.5</p>
<p>Version: 3.6-SNAPSHOT</p>

<p>Recommended namespace prefix: (default), c</p>
</xsd:documentation>
Expand Down
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright (c) 2010-2016 Evolveum
~ Copyright (c) 2010-2017 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -5861,9 +5861,9 @@
</xsd:element>
<xsd:element name="timeFrom" type="tns:MappingTimeDeclarationType" minOccurs="0"/>
<xsd:element name="timeTo" type="tns:MappingTimeDeclarationType" minOccurs="0"/>
<xsd:element name="source" type="tns:MappingSourceDeclarationType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="source" type="tns:VariableBindingDefinitionType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="expression" type="tns:ExpressionType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="target" type="tns:MappingTargetDeclarationType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="target" type="tns:VariableBindingDefinitionType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="condition" type="tns:ExpressionType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="inputFilter" type="tns:ValueFilterType" minOccurs="0"/>
<xsd:element name="outputFilter" type="tns:ValueFilterType" minOccurs="0"/>
Expand Down Expand Up @@ -5949,36 +5949,64 @@
</xsd:annotation>
<xsd:sequence>
<xsd:element ref="tns:description" minOccurs="0" maxOccurs="1"/>
<xsd:element name="referenceTime" type="tns:MappingSourceDeclarationType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="referenceTime" type="tns:VariableBindingDefinitionType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="offset" type="xsd:duration" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="MappingSourceDeclarationType">
<xsd:complexType name="VariableBindingDefinitionType">
<xsd:annotation>
<xsd:documentation>
TODO
Definition of variable wich is bound to the property. This is used
for mapping sources and targets or similar definitions that can work
on properties of objects. It is designed to handle relativistic behavior.
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="name" type="xsd:QName" minOccurs="0" maxOccurs="1"/>
<xsd:element ref="tns:description" minOccurs="0" maxOccurs="1"/>
<xsd:element name="path" type="t:ItemPathType"/>
<xsd:element name="set" type="tns:ValueSetDefinitionType">
<xsd:annotation>
<xsd:documentation>
Definition of the set of values for this variable. The variable
definition will be valid only for those variable. The evaluation
of the set depends on the context that the definition is used.
E.g. if the set is used in mapping source then it defines the
domain of the expression. If it used in the mapping target
definition then it defines range of the expression. Etc.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="MappingTargetDeclarationType">
<xsd:complexType name="ValueSetDefinitionType">
<xsd:annotation>
<xsd:documentation>
TODO
Definition of value set. It can define a set of values by several
methods. E.g. it can define set by a condition, enumaration of the values
and so on.
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element ref="tns:description" minOccurs="0" maxOccurs="1"/>
<xsd:element name="path" type="t:ItemPathType"/>
<xsd:element name="condition" type="c:ExpressionType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
<p>
Expression that is evaluated to check whether the value belongs to the set.
If the condition returns true then the value belongs to the set. Otherwise
it does not.
</p>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<!-- TODO: other set definition types:
* reference to lookup table
* reference to schema enumeration -->
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="ValueFilterType">
<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -6689,7 +6717,7 @@
</xsd:annotation>
<xsd:sequence>
<xsd:element ref="tns:expression"/>
<xsd:element name="target" type="tns:MappingTargetDeclarationType"/>
<xsd:element name="target" type="tns:VariableBindingDefinitionType"/>
</xsd:sequence>
</xsd:complexType>

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2016 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -395,7 +395,7 @@ private void assertResourceJaxb(ResourceType resourceType, boolean isSimple) thr
} else if ("departmentNumber".equals(ItemPathUtil.getOnlySegmentQName(attributeDefinitionType.getRef()).getLocalPart())) {
foundDepartmentNumber = true;
MappingType outbound = attributeDefinitionType.getOutbound();
MappingSourceDeclarationType source = outbound.getSource().get(0);
VariableBindingDefinitionType source = outbound.getSource().get(0);
System.out.println("source for departmentNumber = " + source);
assertNotNull("no source for outbound mapping for departmentNumber", source);
//<path xmlns:z="http://z/">$user/extension/z:dept</path>
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2016 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -73,7 +73,7 @@
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MappingTargetDeclarationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.VariableBindingDefinitionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSearchStrategyType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PopulateItemType;
Expand Down Expand Up @@ -433,7 +433,7 @@ private <IV extends PrismValue, ID extends ItemDefinition, C extends Containerab
return null;
}

MappingTargetDeclarationType targetType = populateItem.getTarget();
VariableBindingDefinitionType targetType = populateItem.getTarget();
if (targetType == null) {
LOGGER.warn("No target in populateObject in assignment expression in {}, "
+ "skipping. Subsequent operations will most likely fail", contextDescription);
Expand Down

0 comments on commit ea5f880

Please sign in to comment.