Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
tutorial:complete_query [2015/02/14 18:17]
yarpheuil
tutorial:complete_query [2015/10/05 17:52] (current)
Line 1: Line 1:
-Adichatz generates brute queries to fetch data from Application server ​(or database), one query per entity.\\+Adichatz generates brute queries to fetch data from Application server or database ​(by default, one query per entity).\\
 For example, the query for a <wrap adicode>​Customer</​wrap>​ class is described by an XML file called <wrap adicode>​$projectDirectory/​resources/​xml/​model/​customer/​CustomerQUERYGENERATED.axml</​wrap>:​ For example, the query for a <wrap adicode>​Customer</​wrap>​ class is described by an XML file called <wrap adicode>​$projectDirectory/​resources/​xml/​model/​customer/​CustomerQUERYGENERATED.axml</​wrap>:​
 +\\
 <sxh xml; first-line: 10; title: excerpt from '​CustomerQUERYGENERATED.axml'​ file.> <sxh xml; first-line: 10; title: excerpt from '​CustomerQUERYGENERATED.axml'​ file.>
 <?xml version="​1.0"​ encoding="​UTF-8"​ standalone="​yes"?>​ <?xml version="​1.0"​ encoding="​UTF-8"​ standalone="​yes"?>​
Line 6: Line 7:
     <​jointure fieldName="​address"​ jointureType="​join fetch " suffix="​a"/>​     <​jointure fieldName="​address"​ jointureType="​join fetch " suffix="​a"/>​
     <​jointure fieldName="​store"​ jointureType="​join fetch " suffix="​s"/>​     <​jointure fieldName="​store"​ jointureType="​join fetch " suffix="​s"/>​
-    <​queryPreference>​+    <​queryPreference ​orderByClause="​c.customerId"​>
         <​parameter id="​active"​ property="​active"​ style="​SWT.RIGHT"​ suffix="​c"/>​         <​parameter id="​active"​ property="​active"​ style="​SWT.RIGHT"​ suffix="​c"/>​
         <​parameter id="​address"​ property="​address"​ suffix="​c"/>​         <​parameter id="​address"​ property="​address"​ suffix="​c"/>​
Line 18: Line 19:
     </​queryPreference>​     </​queryPreference>​
 </​queryTree>​ </​queryTree>​
-</​sxh><​WRAP INDIC><​wrap adititle>​Remark</​wrap>:​\\+</​sxh><​WRAP INDIC><​wrap adititle>​Remarks</​wrap>:​\\
 The query description contains 2 parts:\\ The query description contains 2 parts:\\
   * <wrap adicode>​Jointures</​wrap>​ part describes other entities linked to each rows fetched by the query. ​   * <wrap adicode>​Jointures</​wrap>​ part describes other entities linked to each rows fetched by the query. ​
-  * The <wrap adicode>​QueryPreference</​wrap>​ part describes the default attributes managed in the outline panel of a Query Editor. Here, only optional query parameter ​are listed. ​+  * The <wrap adicode>​QueryPreference</​wrap>​ part describes the default attributes managed in the outline panel of a Query Editor. Here, only optional query parameters ​are listed. ​
 </​WRAP>​ </​WRAP>​
 \\ \\ \\ \\
-**Complete query by changing XML elements**\\ +<​html><​strong id="​changed_query">​Complete query by changing XML elements</​strong></​html>:​\\ 
-Now, we want to create a query for customers from USA (<wrap adicode>​countryId=103</​wrap>​). In this query we want to fetch the staff of the store and the address with the city and the country of the store.+Now, we want to complete the query in two ways: 
 +  - Add jointures ​to fetch the staff of the store and the address with the city and the country of the store. 
 +  - Add a preference to select only Customers from USA (<wrap adicode>​countryId=103</​wrap>​) a new pagination, a new column orders and two filters.\\
 Queries could be easily changed as shown below: Queries could be easily changed as shown below:
-<sxh xml; first-line: 1; highlight: [4,​5,​9,​10,​11,​12,​16,17,18,27,28,29,30]; title: excerpt from 'CustomerFromUSAQUERY.axml' file (new version)>​+<sxh xml; first-line: 1; highlight: [4,​5,​9,​10,​11,​12,​25,26,27,28,29,32,​33,​34,​36,​37]; title: excerpt from 'CustomerQUERY.axml' file (new version)>​
 <?xml version="​1.0"​ encoding="​UTF-8"​ standalone="​yes"?>​ <?xml version="​1.0"​ encoding="​UTF-8"​ standalone="​yes"?>​
 <​queryTree xmlns:​xsi="​http://​www.w3.org/​2001/​XMLSchema-instance"​ queryType="​JQL"​ entityURI="​adi://​myproject/​model.customer/​CustomerMM"​ suffix="​c"​ xsi:​noNamespaceSchemaLocation="​http://​www.adichatz.org/​xsd/​v0.8.7/​generator/​queryTree.xsd">​ <​queryTree xmlns:​xsi="​http://​www.w3.org/​2001/​XMLSchema-instance"​ queryType="​JQL"​ entityURI="​adi://​myproject/​model.customer/​CustomerMM"​ suffix="​c"​ xsi:​noNamespaceSchemaLocation="​http://​www.adichatz.org/​xsd/​v0.8.7/​generator/​queryTree.xsd">​
Line 43: Line 46:
         </​jointure>​         </​jointure>​
     </​jointure>​     </​jointure>​
-    <​whereClause>​co.countryId = 103</​whereClause>​ +    ​<​queryPreference ​orderByClause="c.customerId">
-    <​queryPreference ​columnOrder="0, 3, 4, 5, 2, 1, 6, 7, 8" statusBarKey="​Scale"​ id="​Preference">​ +
-        <​pagination firstResult="​0"​ maxResults="​50"/>+
         <​parameter id="​address"​ suffix="​c"/>​         <​parameter id="​address"​ suffix="​c"/>​
         <​parameter id="​customerId"​ style="​SWT.RIGHT"​ suffix="​c"/>​         <​parameter id="​customerId"​ style="​SWT.RIGHT"​ suffix="​c"/>​
Line 54: Line 55:
         <​parameter id="​lastUpdate"​ style="​SWT.CENTER"​ suffix="​c"/>​         <​parameter id="​lastUpdate"​ style="​SWT.CENTER"​ suffix="​c"/>​
         <​parameter id="​active"​ suffix="​c"/>​         <​parameter id="​active"​ suffix="​c"/>​
-        <​parameter id="​store_city"​ prompt="​Store city" property="​city" entityURI="​adi://​sakilaModel/​model.city/​CityMM" suffix="​sci"/>​ +        <​parameter id="​store_city"​ prompt="​Store city" property="​city"​ suffix="​a"/>​ 
-        <​parameter id="​store_country"​ prompt="​Store country"​ property="​country" entityURI="​adi://​sakilaModel/​model.country/​CountryMM" suffix="​sco"/>​ +        <​parameter id="​store_country"​ prompt="​Store country"​ property="​country"​ suffix="​sci"/>​ 
-        <​parameter id="​customer_city"​ prompt="​Customer city" property="​city" entityURI="​adi://​sakilaModel/​model.city/​CityMM" suffix="​ci"/>​ +        <​parameter id="​customer_city"​ prompt="​Customer city" property="​city"​ suffix="​a"/>​ 
-        <​parameter id="​customer_country"​ prompt="​Customer country"​ property="​country" ​entityURI="adi://​sakilaModel/​model.country/​CountryMM" suffix="​ci" />+        <​parameter id="​customer_country"​ prompt="​Customer country"​ property="​country" ​suffix="ci"/
 +        <​parameter id="​staff_name"​ prompt="​Staff name" property="​lastName" suffix="​st"/>
     </​queryPreference>​     </​queryPreference>​
 +    <​permanentPreferences>​
 +        <​queryPreference id="​usa"​ statusBarKey="​Navigation"​ columnOrder="​0,​ 3, 4, 5, 2, 1, 6, 7, 8">
 +            <​pagination firstResult="​0"​ maxResults="​50"​ paginated="​true"/>​
 +            <​parameter id="​customer_country"​ prompt="​Customer country"​ property="​country"​ permanent="​true"​ entityURI="​adi://​myproject/​model.country/​CountryMM"​ suffix="​co"​ valid="​true"​ columnText="​United States"​ expression="​103"​ operator="​="/>​
 +            <​filters>​
 +                <​filter enabled="​true"​ text="​Value in column '​active'​ is false."​ searchString="​true"​ column="​activeTC"/>​
 +                <​filter enabled="​false"​ text="​Value in column '​store'​ contains string '​Australia'​."​ column="​storeTC"​ searchString="​Australia"​ exactString="​false"​ caseInsensitive="​false"/>​
 +            </​filters>​
 +        </​queryPreference>​
 +    </​permanentPreferences>​
 </​queryTree>​ </​queryTree>​
 </​sxh>​ </​sxh>​
Line 66: Line 78:
   * Line <wrap adicode>​9</​wrap>:​ fetch the staff of the customer. ​   * Line <wrap adicode>​9</​wrap>:​ fetch the staff of the customer. ​
   * Lines <wrap adicode>​10</​wrap>,​ <wrap adicode>​11</​wrap>​ and <wrap adicode>​12</​wrap>:​ Fetch address, city and country of the store of the customer. ​   * Lines <wrap adicode>​10</​wrap>,​ <wrap adicode>​11</​wrap>​ and <wrap adicode>​12</​wrap>:​ Fetch address, city and country of the store of the customer. ​
-  * Line <wrap adicode>16</​wrap>: ​select only customer from USA.  +  * Lines <wrap adicode>25</​wrap>​ to <wrap adicode>​28</​wrap>: ​Add parameters allowing the user to extend the selection to specified fields
-  * Line <wrap adicode>17</​wrap>: ​Column ​order is changed and chosen ​status ​bar is <wrap adicode>​Scale</​wrap>​.  +  * Line <wrap adicode>32</​wrap>: ​Define e new preference, identified by <wrap adicode>​usa</​wrap>​ string, column ​order is changed and chosen ​<wrap adicode>​Navigation</​wrap> ​bar is <wrap adicode>​Scale</​wrap>​: User can navigates thru pages using a scale control.  
-  * Line <wrap adicode>18</​wrap>:​ Pagination start to first element (position 0) and fetch 50 rows per page.  +  * Line <wrap adicode>33</​wrap>:​ Pagination start to first element (position 0) and fetch 50 rows per page.  
-  * Lines <wrap adicode>27</​wrap> ​to <wrap adicode>30</​wrap>:​ Add parameters allowing the user to extend ​the selection ​to specified fields.  +  * Line <wrap adicode>​34</​wrap>:​ select only customer from USA.  
-T</​WRAP>​ +  * Lines <wrap adicode>36</​wrap> ​and <wrap adicode>37</​wrap>:​ Add 2 filters: first on column <wrap adicode>​Active</​wrap>,​ second on column <wrap adicode>​Store</​wrap>​. Only first filter is enabled. 
 +\\ \\ 
 +Open [[tutorial:​add_navigator_item|Add navigator item]] ​to see how to create a new item in navigator to call the query with defined preference.\\ 
 +Open [[tutorial:​change_table|Change table include]] ​to see how to display data from new jointures in table control
 +</​WRAP> ​ 
tutorial/complete_query.1423934274.txt.gz · Last modified: 2015/09/30 16:46 (external edit)