<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2008-2016 Haulmont.
  ~
  ~ 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.
  ~
  -->

<xs:schema
        targetNamespace="http://schemas.haulmont.com/cuba/view.xsd"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns="http://schemas.haulmont.com/cuba/view.xsd"
        elementFormDefault="qualified"
        attributeFormDefault="unqualified"
        >

    <xs:element name="views">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="include" type="includeType" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element name="view" type="viewType" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:complexType name="viewType">
        <xs:sequence minOccurs="0" maxOccurs="unbounded">
            <xs:element name="property" type="propertyType"/>
        </xs:sequence>
        <xs:attribute name="class"/>
        <xs:attribute name="entity"/>
        <xs:attribute name="name"/>
        <xs:attribute name="extends"/>
        <xs:attribute name="overwrite" type="xs:boolean"/>
        <xs:attribute name="systemProperties" type="xs:boolean"/>
    </xs:complexType>

    <xs:complexType name="propertyType">
        <xs:sequence minOccurs="0" maxOccurs="unbounded">
            <xs:element name="property" type="propertyType"/>
        </xs:sequence>
        <xs:attribute name="name"/>
        <xs:attribute name="view"/>
        <xs:attribute name="fetch" type="fetchModeType"/>
    </xs:complexType>

    <xs:complexType name="includeType">
        <xs:attribute name="file" type="xs:string"/>
    </xs:complexType>

    <xs:simpleType name="fetchModeType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="AUTO"/>
            <xs:enumeration value="UNDEFINED"/>
            <xs:enumeration value="JOIN"/>
            <xs:enumeration value="BATCH"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>
