Skip to content
Permalink
Newer
Older
100644 92 lines (81 sloc) 4.34 KB
1
<?xml version="1.0"?>
2
<!--
3
~ Copyright (c) 2019 Evolveum and contributors
4
~
5
~ This work is dual-licensed under the Apache License 2.0
6
~ and European Union Public License. See LICENSE file for details.
7
-->
8
9
<objectTemplate xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3" oid="8098b124-c20c-4965-8adf-e528abedf7a4">
10
<name>template-user</name>
11
<mapping>
12
<strength>strong</strength>
13
<source>
14
<path>name</path>
15
</source>
16
<expression>
17
<script>
18
<code>
19
import com.evolveum.midpoint.xml.ns._public.common.common_3.*
20
import com.evolveum.midpoint.schema.constants.*
21
import com.evolveum.midpoint.schema.*
22
import javax.xml.namespace.*
23
import com.evolveum.midpoint.util.*
24
import com.evolveum.midpoint.prism.path.*
25
26
GROUPER_RESOURCE_OID = '1eff65de-5bb6-483d-9edf-8cc2c2ee0233'
27
MEMBER_NAME = new QName(MidPointConstants.NS_RI, 'member')
28
29
memberDef = prismContext.definitionFactory().createPropertyDefinition(MEMBER_NAME, DOMUtil.XSD_STRING)
30
memberDef.setMaxOccurs(-1)
31
32
shadowQuery = prismContext.queryFor(ShadowType.class)
33
.item(ShadowType.F_RESOURCE_REF).ref(GROUPER_RESOURCE_OID)
34
.and().item(ShadowType.F_SYNCHRONIZATION_SITUATION).eq(SynchronizationSituationType.LINKED)
35
.and().item(ShadowType.F_KIND).eq(ShadowKindType.ENTITLEMENT)
36
.and().item(ShadowType.F_INTENT).eq('group')
37
.and().block().item(ShadowType.F_DEAD).isNull().or().item(ShadowType.F_DEAD).eq(false).endBlock()
38
.and().item(ItemPath.create(ShadowType.F_ATTRIBUTES, MEMBER_NAME), memberDef).eq(basic.stringify(name))
39
.build()
40
41
//log.info('shadowQuery = {}\n{}', shadowQuery, shadowQuery.debugDump())
42
options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch())
43
shadows = midpoint.searchObjects(ShadowType.class, shadowQuery, options)
44
//log.info('shadows found for {}: {}', name, shadows)
45
46
orgNames = shadows.collect { basic.stringify(it.name) } // todo - use attributes
47
log.info('org names = {}', orgNames)
48
49
if (!orgNames.isEmpty()) {
50
orgQueryBuilder = prismContext.queryFor(OrgType.class)
51
52
first = true
53
for (orgName in orgNames) {
54
if (first) {
55
first = false
56
} else {
57
orgQueryBuilder = orgQueryBuilder.or()
58
}
59
orgQueryBuilder = orgQueryBuilder.item(ItemPath.create(OrgType.F_EXTENSION, 'grouperName')).eq(orgName)
60
}
61
62
orgQuery = orgQueryBuilder.build()
63
//log.info('org query:\n', orgQuery.debugDump())
64
65
orgs = midpoint.searchObjects(OrgType.class, orgQuery, null)
66
log.info('orgs found: {}', orgs)
67
68
orgs.collect {
69
new AssignmentType(prismContext)
70
.subtype('grouper-group')
71
.targetRef(it.oid, OrgType.COMPLEX_TYPE)
72
}
73
} else {
74
null
75
}
76
</code>
77
</script>
78
</expression>
79
<target>
80
<path>assignment</path>
81
<set>
82
<condition>
83
<script>
84
<code>
85
assignment?.subtype.contains('grouper-group')
86
</code>
87
</script>
88
</condition>
89
</set>
90
</target>
91
</mapping>
92
</objectTemplate>
You can’t perform that action at this time.