[midPoint] Add complex type element to user type

Ivan Noris ivan.noris at evolveum.com
Wed Mar 1 17:18:22 CET 2017


Hi Dmitriy,

not sure what are you trying to achieve, but the most complicated thing
I ever needed in schema extension was enumeration (which could be
replaced by lookup tables now...)

This is an example from my schema extension for roles.

...

    <xsd:simpleType name="XServiceIntegrationType">
        <xsd:annotation>
            <xsd:documentation>Enum for X
IntegrationType</xsd:documentation>
                    <xsd:appinfo>
                        <a:displayName>X Integration Type</a:displayName>
                        <a:displayOrder>150</a:displayOrder>
                    </xsd:appinfo>
        </xsd:annotation>
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="LEVEL0">
                <xsd:annotation>
                    <xsd:appinfo>
                        <a:label>LEVEL0</a:label>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:enumeration>
            <xsd:enumeration value="LEVEL0A">
                <xsd:annotation>
                    <xsd:appinfo>
                        <a:label>LEVEL0A</a:label>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:enumeration>
            <xsd:enumeration value="LEVEL0M">
                <xsd:annotation>
                    <xsd:appinfo>
                        <a:label>LEVEL0M</a:label>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:enumeration>
            <xsd:enumeration value="LEVEL1">
                <xsd:annotation>
                    <xsd:appinfo>
                        <a:label>LEVEL1</a:label>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:enumeration>
            <xsd:enumeration value="LEVEL2">
                <xsd:annotation>
                    <xsd:appinfo>
                        <a:label>LEVEL2</a:label>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:enumeration>
            <xsd:enumeration value="LEVEL3">
                <xsd:annotation>
                    <xsd:appinfo>
                        <a:label>LEVEL3</a:label>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:enumeration>
        </xsd:restriction>
    </xsd:simpleType>
...

  <xsd:complexType name="RoleTypeExtensionType">
    <xsd:annotation>
      <xsd:appinfo>
        <a:extension ref="c:RoleType"/>
      </xsd:appinfo>
    </xsd:annotation>
    <xsd:sequence>
  <xsd:element name="*xxxServiceIntegrationType*"
type="*tns:XServiceIntegrationType*" minOccurs="0">
    <xsd:annotation>
          <xsd:appinfo>
            <a:indexed>true</a:indexed>
              <a:displayName>X Service Integration Type</a:displayName>
              <a:displayOrder>150</a:displayOrder>
            </xsd:appinfo>
    </xsd:annotation>
  </xsd:element>
...
    </xsd:sequence>
  </xsd:complexType>
...

Regards,
Ivan

On 03/01/2017 03:51 PM, Dmitriy Berezkin wrote:
> Hi!
>
> Thank you for example!
>
> Yes, I checked this link
> https://github.com/Evolveum/midpoint/blob/master/samples/schema/extension-samples.xsd
> and didnt found how complex element used in UserExtensionType.
>
> I added my custom object “JobType” to UserExtensionType like this:
> <xsd:element name="jobs" type="tns:JobType" minOccurs="0"
> maxOccurs="unbounded”/>
>
> Here is xsd part for “JobType":
> <xsd:complexType name="JobType">
> <xsd:sequence>
> <xsd:element name="jobTitle" type="xsd:string" minOccurs="0"
> maxOccurs="1">
> <xsd:annotation>
> <xsd:appinfo>
> <a:indexed>true</a:indexed>
> <a:displayName>job title</a:displayName>
> <a:displayOrder>310</a:displayOrder>
> </xsd:appinfo>
> </xsd:annotation>
> </xsd:element>
> </xsd:sequence>
> </xsd:complexType>
>
> And now I can see custom fields in midpoint:
>
>
> But it gives me an error of I try to save them:
> Caused by: java.lang.IllegalStateException: Cannot parse as
> {http://example.com/xml/ns/mySchema}JobType: parser ValueParser(DOMe,
> {http://example.com/xml/ns/mySchema}jobs: 1)
>
> ---
> Dmitry
>
> On 22 февр. 2017 г., 21:31 +0300, Jason Everling <jeverling at bshp.edu>,
> wrote:
>> can you post what have so far? Here is ours, trimmed down of course
>> as we have many types from orgs, roles, and user types
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>>
>> <xsd:schema elementFormDefault="qualified"
>>             targetNamespace="http://midpoint.bshp.edu/bshp"
>> xmlns:tns="http://midpoint.bshp.edu/bshp"
>>            
>> xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
>>            
>> xmlns:a="http://prism.evolveum.com/xml/ns/public/annotation-3"
>>             xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>>
>> <!-- Enumerated Objects -->
>> <xsd:simpleType name="bshpAffiliation">
>> <xsd:annotation>
>> <xsd:documentation>Choices for Affiliation</xsd:documentation>
>> </xsd:annotation>
>> <xsd:restriction base="xsd:string">
>>             <xsd:enumeration value="faculty">
>>                 <xsd:annotation>
>>                     <xsd:appinfo>
>>                         <a:label>faculty</a:label>
>>                     </xsd:appinfo>
>>                 </xsd:annotation>
>>             </xsd:enumeration>
>>             <xsd:enumeration value="staff">
>>                 <xsd:annotation>
>>                     <xsd:appinfo>
>>                         <a:label>staff</a:label>
>>                     </xsd:appinfo>
>>                 </xsd:annotation>
>>             </xsd:enumeration>
>>             <xsd:enumeration value="student">
>>                 <xsd:annotation>
>>                     <xsd:appinfo>
>>                         <a:label>student</a:label>
>>                     </xsd:appinfo>
>>                 </xsd:annotation>
>>             </xsd:enumeration>
>>             <xsd:enumeration value="alumni">
>>                 <xsd:annotation>
>>                     <xsd:appinfo>
>>                         <a:label>alumni</a:label>
>>                     </xsd:appinfo>
>>                 </xsd:annotation>
>>             </xsd:enumeration>
>>             <xsd:enumeration value="external">
>>                 <xsd:annotation>
>>                     <xsd:appinfo>
>>                         <a:label>external</a:label>
>>                     </xsd:appinfo>
>>                 </xsd:annotation>
>>             </xsd:enumeration>
>>         </xsd:restriction>
>>     </xsd:simpleType>
>>
>>     <!-- User Extension -->
>>
>>     <xsd:complexType name="UserTypeExtensionType">
>>         <xsd:annotation>
>>             <xsd:appinfo>
>>                 <a:extension ref="c:UserType"/>
>>             </xsd:appinfo>
>>         </xsd:annotation>
>>         <xsd:sequence>
>>             <xsd:element name="otherMailbox" type="xsd:string"
>> minOccurs="0" maxOccurs="unbounded">
>>                 <xsd:annotation>
>>                     <xsd:appinfo>
>>                         <a:indexed>true</a:indexed>
>>                         <a:displayName>Other Mailbox</a:displayName>
>>                         <a:displayOrder>120</a:displayOrder>
>>                         <a:help>someone at example.com
>> <mailto:someone at example.com></a:help>
>>                     </xsd:appinfo>
>>                 </xsd:annotation>
>>             </xsd:element>
>>             <xsd:element name="campus" type="xsd:string"
>> minOccurs="0" maxOccurs="1">
>>                 <xsd:annotation>
>>                     <xsd:appinfo>
>>                         <a:indexed>true</a:indexed>
>>                         <a:displayName>Campus</a:displayName>
>>                         <a:displayOrder>160</a:displayOrder>
>>                     </xsd:appinfo>
>>                 </xsd:annotation>
>>             </xsd:element>
>> <xsd:element name="bshpAffiliation" type="tns:bshpAffiliation"
>> minOccurs="0" maxOccurs="1">
>> <xsd:annotation>
>> <xsd:appinfo>
>> <a:indexed>true</a:indexed>
>> <a:displayName>Affiliation</a:displayName>
>> <a:displayOrder>170</a:displayOrder>
>> </xsd:appinfo>
>> </xsd:annotation>
>> </xsd:element>
>>         </xsd:sequence>
>>     </xsd:complexType>
>> </xsd:schema>
>>
>> JASON
>>
>>
>> On Wed, Feb 22, 2017 at 12:24 PM, Pálos Gustáv
>> <gustav.palos at evolveum.com <mailto:gustav.palos at evolveum.com>> wrote:
>>
>>     Hi Dmitry,
>>
>>     do you checked for example this sample?
>>     https://github.com/Evolveum/midpoint/blob/master/samples/schema/extension-samples.xsd
>>     <https://github.com/Evolveum/midpoint/blob/master/samples/schema/extension-samples.xsd>
>>
>>     best regards,
>>
>>     Gustav
>>      
>>
>>         2017-02-22 18:49 GMT+01:00 Dmitriy Berezkin
>>         <berezkin.dmitriy at gmail.com <mailto:berezkin.dmitriy at gmail.com>>:
>>
>>             Hi!
>>
>>             Could you tell me how I can extend UserType with
>>             complexType object?
>>
>>             I tried to add <xsd:complexType> under <xsd:sequence> of
>>             my custom xsd but got error:
>>>             org.springframework.beans.factory.BeanCreationException:
>>>             Error creating bean with name 'repositoryFactory':
>>>             Injection of autowired dependencies failed; nested
>>>             exception is
>>>             org.springframework.beans.factory.BeanCreationException:
>>>             Could not autowire field: private
>>>             com.evolveum.midpoint.prism.Pr
>>>             <http://com.evolveum.midpoint.prism.Pr>ismContext
>>>             com.evolveum.midpoint.init.RepositoryFactory.prismContext;
>>>             nested exception is
>>>             org.springframework.beans.factory.BeanCreationException:
>>>             Error creating bean with name 'prismContext' defined in
>>>             class path resource [ctx-configuration.xml]: Bean
>>>             instantiation via factory method failed; nested
>>>             exception is
>>>             org.springframework.beans.BeanInstantiationException:
>>>             Failed to instantiate
>>>             [com.evolveum.midpoint.prism.PrismContext]: Factory
>>>             method 'createInitializedPrismContext' threw exception;
>>>             nested exception is
>>>             com.evolveum.midpoint.util.exception.SchemaException:
>>>             XML error during XSD schema parsing: *Unexpected
>>>             <xsd:complexType> appears at line 65 column 42(embedded
>>>             exception null)* in file C:\midpoint\schema\test1.xsd
>>
>>             Do you have any example of using complexType attribute
>>             with UserExtensionType?
>>
>>             ---
>>             Dmitry
>>
>>             _______________________________________________
>>             midPoint mailing list
>>             midPoint at lists.evolveum.com
>>             <mailto:midPoint at lists.evolveum.com>
>>             http://lists.evolveum.com/mailman/listinfo/midpoint
>>             <http://lists.evolveum.com/mailman/listinfo/midpoint>
>>
>>
>>
>>
>>         --
>>         s pozdravom
>>
>>         Gustáv Pálos
>>
>>
>>
>>
>>     --
>>     Gustáv Pálos
>>     Identity Engineer
>>     evolveum.com <http://evolveum.com/>
>>
>>     _______________________________________________
>>     midPoint mailing list
>>     midPoint at lists.evolveum.com <mailto:midPoint at lists.evolveum.com>
>>     http://lists.evolveum.com/mailman/listinfo/midpoint
>>     <http://lists.evolveum.com/mailman/listinfo/midpoint>
>>
>>
>> _______________________________________________
>> midPoint mailing list
>> midPoint at lists.evolveum.com
>> http://lists.evolveum.com/mailman/listinfo/midpoint
>
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> http://lists.evolveum.com/mailman/listinfo/midpoint

-- 
Ivan Noris
Senior Identity Engineer
evolveum.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170301/fb4171d2/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 28642 bytes
Desc: not available
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170301/fb4171d2/attachment.png>


More information about the midPoint mailing list