Changes between Version 22 and Version 23 of MolgenisAddressBookExample
- Timestamp:
- 2009-08-23T19:05:29+02:00 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
MolgenisAddressBookExample
v22 v23 2 2 3 3 = Generating MOLGENIS from scratch, step-by-step = 4 5 = 1. Create the data model XML[[BR]] = 4 == 1. Create the data model in `addressbook_db.xml` == 6 5 Create a new xml file ‘addressbook_db.xml’ in the root of you application. This file will contain the MOLGENIS model. Use the following template: 7 6 … … 14 13 </molgenis> 15 14 }}} 16 17 == Create a “Contact” data type == 15 === Create a “Contact” data type === 18 16 {{{ 19 17 #!xml … … 24 22 </molgenis> 25 23 }}} 26 27 == Add properties to “Contact” == 28 * A unique, automatic numeric identifier field that MOLGENIS will use to refer contacts. 24 === Add properties to “Contact” === 25 * A unique, automatic numeric identifier field that MOLGENIS will use to refer contacts. 29 26 {{{ 30 27 #!xml … … 49 46 }}} 50 47 51 == Create a “Address” data type==48 === Create a “Address” data type === 52 49 * Create the entity again 53 50 {{{ … … 55 52 <entity name="Address"> 56 53 }}} 57 * A unique, automatic numeric identifier field that MOLGENIS will use to refer addresses. 54 * A unique, automatic numeric identifier field that MOLGENIS will use to refer addresses. 58 55 {{{ 59 56 !xml … … 71 68 }}} 72 69 73 == Link Addresses to Contact.==70 === Link Addresses to Contact. === 74 71 * In the Address entity create a [http://en.wikipedia.org/wiki/Foreign_key ForeignKey] reference to Contact 75 72 {{{ … … 80 77 </entity> 81 78 }}} 82 Note that the xref_field refers to unique field ‘contact_id’ in entity ‘Contact’. The xref_label attribute indicates that we want to view references to Contact by ‘displayname’ name instead of the numeric id. 79 80 Note that the xref_field refers to unique field ‘contact_id’ in entity ‘Contact’. The xref_label attribute indicates that we want to view references to Contact by ‘displayname’ name instead of the numeric id. 83 81 84 82 Use of a meaningless numeric ‘id’ next to a meaningful ‘label’ enables us to change the ‘displayname’ name on Contact without the problem of also having to change this on each Address that refers to this contact. 85 83 84 == 2. Model the user interface in `addressbook_ui.xml` == 85 * Create a new xml file ‘addressbook_ui.xml’ in the root of you application by copy-pasting the db.xml file. This file will contain the MOLGENIS user interface model. 86 87 * We want to show the list of Addresses nested per Contact; for MOLGENIS you simply express this by nesting form elements. If suitable ‘xrefs’ exists these will be used to tie container and nested form together: 88 89 {{{ 90 #!xml 91 <?xml version="1.0" encoding="UTF-8"?> 92 <!DOCTYPE molgenis PUBLIC "MOLGENIS 1.0" "http://molgenis.sourceforge.net/dtd/molgenis_v_1_0.dtd"> 93 <molgenis name="addressbook"> 94 <form entity="Contact" name="Contacts"> 95 <form entity="Address" name="Addresses" view="list"/> 96 </form> 97 </molgenis> 98 }}} 99 == Generate the application == 100 === Configure the `molgenis.properties` file. === 101 The `model_database` and `model_userinterface` options point to the XML files where a data model and user interface is specified. Change to point to our newly created `addressbook_db.xml ` and `addressbook_ui.xml` files 102 103 {{{ 104 ############################################################### 105 # 1. FILES DESCRIBING YOUR DESIGN USING MOLGENIS XML LANGUAGE 106 # can be multiple files ',' separated 107 ############################################################### 108 109 # xml file with data model in terms of 'entity' descriptions 110 model_database = addressbook_db.xml 111 112 # xml file with user screen descriptions in terms of 'form', 'menu',.. 113 model_userinterface = addressbook_ui.xml 114 }}} 115 116 === Create an addressbook mysql instance === 117 CreateMysqlDatabase and then edit 'molgenis.properties' file to connect to this database. For example: 118 {{{ 119 ############################################################### 120 # 2. DATABASE SETTINGS 121 ############################################################### 122 123 # MySQL: 124 # jdbc compatible connection parameters to a database (see doc of database supplier) 125 db_driver = com.mysql.jdbc.Driver 126 db_user = molgenis 127 db_password = molgenis 128 db_uri= jdbc:mysql://localhost/addressbook 129 }}} 130 === Generate and compile your database === 131 See MolgenisGettingStarted 132 86 133 == Result == 87 134 [[Image(address-book-screenshot.JPG)]]