[midPoint] Add complex type element to user type

Jason Everling jeverling at bshp.edu
Wed Mar 1 16:26:47 CET 2017


You shouldn't need to define another complex type, all your user extensions
could be under <xsd:complexType name="UserExtensionType">

<xsd:complexType name="UserTypeExtensionType">
        <xsd:annotation>
            <xsd:appinfo>
                <a:extension ref="c:UserType"/>
            </xsd:appinfo>
        </xsd:annotation>
        <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:element name="another1" type="xsd:string" minOccurs="0"
maxOccurs="1">
                <xsd:annotation>
                    <xsd:appinfo>
                        <a:indexed>true</a:indexed>
                        <a:displayName>Another 1</a:displayName>
                        <a:displayOrder>160</a:displayOrder>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="another2" type="xsd:string" minOccurs="0"
maxOccurs="1">
                <xsd:annotation>
                    <xsd:appinfo>
                        <a:indexed>true</a:indexed>
                        <a:displayName>Another 2</a:displayName>
                        <a:displayOrder>170</a:displayOrder>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>

If that is really what you are trying to do, you just need to add the
extension reference to usertype,

<xsd:complexType name="JobType">
        <xsd:annotation>
            <xsd:appinfo>
                <a:extension ref="c:UserType"/>
            </xsd:appinfo>
        </xsd:annotation>
<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>



JASON

On Wed, Mar 1, 2017 at 8:51 AM, Dmitriy Berezkin <berezkin.dmitriy at gmail.com
> wrote:

> Hi!
>
> Thank you for example!
>
> Yes, I checked this link https://github.com/Evolveum/mi
> dpoint/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</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>
> wrote:
>
>> Hi Dmitry,
>>
>> do you checked for example this sample?
>> https://github.com/Evolveum/midpoint/blob/master/samples/sch
>> ema/extension-samples.xsd
>>
>> best regards,
>>
>> Gustav
>>
>>
>>> 2017-02-22 18:49 GMT+01:00 Dmitriy Berezkin <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.PrismContext
>>>> 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
>>>> http://lists.evolveum.com/mailman/listinfo/midpoint
>>>>
>>>>
>>>
>>>
>>> --
>>> s pozdravom
>>>
>>> Gustáv Pálos
>>>
>>
>>
>>
>> --
>> Gustáv Pálos
>> Identity Engineer
>> evolveum.com
>>
>> _______________________________________________
>> 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
>
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> http://lists.evolveum.com/mailman/listinfo/midpoint
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170301/84419311/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Снимок экрана 2017-03-01 в 17.48.41.png
Type: image/png
Size: 28642 bytes
Desc: not available
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170301/84419311/attachment.png>


More information about the midPoint mailing list