- Timestamp:
- Jan 2, 2011, 8:51:21 PM (14 years ago)
- Location:
- trunk/fmgVen
- Files:
-
- 3 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/fmgVen/etc/test-db/test-db-changelog.xml
r24 r26 4 4 </changeSet> 5 5 <changeSet author="fmguler" id="0"> 6 <tagDatabase tag=" 0"/>6 <tagDatabase tag="tag-init"/> 7 7 </changeSet> 8 8 <!-- TEST SCHEMA >> --> 9 9 <changeSet author="fmguler" id="1"> 10 <createTable schemaName="public" tableName=" aa_authorization_parameter">11 <column autoIncrement="true" name=" no" type="serial">12 <constraints nullable="false" primaryKey="true" primaryKeyName=" aa_authorization_parameter_pkey"/>10 <createTable schemaName="public" tableName="some_domain_object"> 11 <column autoIncrement="true" name="id" type="serial"> 12 <constraints nullable="false" primaryKey="true" primaryKeyName="some_domain_object_pkey"/> 13 13 </column> 14 <column name="param_no" type="int4"> 15 <constraints nullable="false"/> 16 </column> 17 <column name="attribute" type="VARCHAR(100)"/> 18 <column name="operator" type="VARCHAR(100)"/> 19 <column name="value" type="TEXT(2147483647)"/> 20 <column name="connective" type="VARCHAR(10)"/> 21 <column name="order" type="int4"> 22 <constraints nullable="false"/> 23 </column> 14 <column name="name" type="VARCHAR(100)"/> 15 <column name="description" type="TEXT(2147483647)"/> 16 <column name="date" type="TIMESTAMP WITHOUT TIME ZONE"/> 24 17 </createTable> 25 18 </changeSet> 26 19 <changeSet author="fmguler" id="2"> 27 <createTable schemaName="public" tableName="aa_group"> 28 <column autoIncrement="true" name="no" type="serial"> 29 <constraints nullable="false" primaryKey="true" primaryKeyName="aa_group_pkey"/> 30 </column> 31 <column name="name" type="VARCHAR(100)"> 32 <constraints nullable="false"/> 33 </column> 34 <column name="description" type="VARCHAR(1000)"/> 35 </createTable> 20 <tagDatabase tag="tag-single-table"/> 36 21 </changeSet> 37 22 <changeSet author="fmguler" id="3"> 38 <createTable schemaName="public" tableName="aa_group_authorization"> 39 <column name="auth_name" type="VARCHAR(100)"> 40 <constraints nullable="false"/> 41 </column> 42 <column name="group_no" type="int4"> 43 <constraints nullable="false"/> 44 </column> 45 <column name="param_no" type="int4"/> 46 <column name="rule" type="int4"/> 47 </createTable> 23 <insert schemaName="public" tableName="some_domain_object"> 24 <column name="name" value="name1"/> 25 <column name="description" value="desc1"/> 26 <column name="date" value="2010-10-13"/> 27 </insert> 28 <rollback> 29 delete from some_domain_object; 30 </rollback> 48 31 </changeSet> 49 32 <changeSet author="fmguler" id="4"> 50 <createTable schemaName="public" tableName="aa_user_group"> 51 <column name="username" type="VARCHAR(100)"> 52 <constraints nullable="false"/> 53 </column> 54 <column name="group_no" type="int4"> 55 <constraints nullable="false"/> 56 </column> 57 <column name="order" type="int4"> 58 <constraints nullable="false"/> 59 </column> 60 </createTable> 33 <tagDatabase tag="tag-single-table-data"/> 61 34 </changeSet> 62 <changeSet author="fmguler" id="5"> 63 <createTable schemaName="public" tableName="user_attribute"> 64 <column autoIncrement="true" name="no" type="serial"> 65 <constraints nullable="false" primaryKey="true" primaryKeyName="user_attribute_pkey"/> 66 </column> 67 <column autoIncrement="true" name="user_no" type="serial"> 68 <constraints nullable="false"/> 69 </column> 70 <column name="attribute" type="VARCHAR(100)"/> 71 <column name="value" type="TEXT(2147483647)"/> 72 <column name="type" type="VARCHAR(100)"/> 73 <column defaultValueNumeric="0" name="priority" type="int4"/> 74 </createTable> 75 </changeSet> 76 <changeSet author="fmguler" id="6"> 77 <createTable schemaName="public" tableName="user_authentication"> 78 <column name="username" type="VARCHAR(150)"> 79 <constraints nullable="false" primaryKey="true" primaryKeyName="user_authentication_pkey"/> 80 </column> 81 <column name="password" type="VARCHAR(150)"> 82 <constraints nullable="false"/> 83 </column> 84 </createTable> 85 </changeSet> 86 <changeSet author="fmguler" id="7"> 87 <createTable schemaName="public" tableName="user_operation"> 88 <column autoIncrement="true" name="no" type="serial"> 89 <constraints nullable="false" primaryKey="true" primaryKeyName="user_operation_pkey"/> 90 </column> 91 <column name="username" type="VARCHAR(100)"> 92 <constraints nullable="false"/> 93 </column> 94 <column name="module" type="VARCHAR(100)"> 95 <constraints nullable="false"/> 96 </column> 97 <column name="operation" type="VARCHAR(100)"> 98 <constraints nullable="false"/> 99 </column> 100 <column defaultValueDate="now()" name="date" type="TIMESTAMP WITHOUT TIME ZONE"> 101 <constraints nullable="false"/> 102 </column> 103 <column name="parameter" type="TEXT(2147483647)"/> 104 </createTable> 105 </changeSet> 106 <changeSet author="fmguler" id="8"> 107 <addPrimaryKey columnNames="auth_name, group_no" constraintName="aa_group_authorization_pkey" schemaName="public" tableName="aa_group_authorization"/> 108 </changeSet> 109 <changeSet author="fmguler" id="9"> 110 <addPrimaryKey columnNames="username, group_no" constraintName="aa_user_group_pkey" schemaName="public" tableName="aa_user_group"/> 111 </changeSet> 112 <changeSet author="fmguler" id="10"> 113 <addUniqueConstraint columnNames="user_no, attribute" constraintName="user_attribute_user_no_key" schemaName="public" tableName="user_attribute"/> 114 </changeSet> 115 <changeSet author="fmguler" id="11"> 116 <createIndex indexName="aa_param_index" schemaName="public" tableName="aa_authorization_parameter" unique="false"> 117 <column name="param_no"/> 118 </createIndex> 119 </changeSet> 120 <changeSet author="fmguler" id="12"> 121 <createIndex indexName="aa_param_index2" schemaName="public" tableName="aa_group_authorization" unique="false"> 122 <column name="param_no"/> 123 </createIndex> 124 </changeSet> 125 <changeSet author="fmguler" id="13"> 126 <createIndex indexName="aa_auth_name_index" schemaName="public" tableName="aa_group_authorization" unique="false"> 127 <column name="auth_name"/> 128 </createIndex> 129 </changeSet> 130 <changeSet author="fmguler" id="14"> 131 <createIndex indexName="aa_user_group_index" schemaName="public" tableName="aa_user_group" unique="false"> 132 <column name="username"/> 133 <column name="group_no"/> 134 </createIndex> 135 </changeSet> 136 <changeSet author="fmguler" id="15"> 137 <createIndex indexName="user_operation_index" schemaName="public" tableName="user_operation" unique="false"> 138 <column name="username"/> 139 <column name="module"/> 140 <column name="operation"/> 141 <column name="date"/> 142 </createIndex> 143 </changeSet> 144 <changeSet author="fmguler" id="16"> 145 <addForeignKeyConstraint baseColumnNames="group_no" baseTableName="aa_group_authorization" baseTableSchemaName="public" constraintName="aa_group_authorization_group_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="RESTRICT" referencedColumnNames="no" referencedTableName="aa_group" referencedTableSchemaName="public"/> 146 </changeSet> 147 <changeSet author="fmguler" id="17"> 148 <createView schemaName="public" viewName="user_view"> 149 <![CDATA[SELECT ua.user_no, u1.value AS username, u2.value AS full_name, u3.value AS receipt_signing_type, u4.value AS mobile_signature_phone_number, u5.value AS mobile_signature_credit FROM ((((((SELECT DISTINCT user_attribute.user_no FROM user_attribute ORDER BY user_attribute.user_no) ua LEFT JOIN (SELECT user_attribute.user_no, user_attribute.value FROM user_attribute WHERE ((user_attribute.attribute)::text = 'username'::text)) u1 ON ((ua.user_no = u1.user_no))) LEFT JOIN (SELECT user_attribute.user_no, user_attribute.value FROM user_attribute WHERE ((user_attribute.attribute)::text = 'fullName'::text)) u2 ON ((ua.user_no = u2.user_no))) LEFT JOIN (SELECT user_attribute.user_no, user_attribute.value FROM user_attribute WHERE ((user_attribute.attribute)::text = 'receiptSigningType'::text)) u3 ON ((ua.user_no = u3.user_no))) LEFT JOIN (SELECT user_attribute.user_no, user_attribute.value FROM user_attribute WHERE ((user_attribute.attribute)::text = 'mobileSignaturePhoneNumber'::text)) u4 ON ((ua.user_no = u4.user_no))) LEFT JOIN (SELECT user_attribute.user_no, user_attribute.value FROM user_attribute WHERE ((user_attribute.attribute)::text = 'mobileSignatureCredit'::text)) u5 ON ((ua.user_no = u5.user_no))) ORDER BY ua.user_no;]]> 150 </createView> 151 </changeSet> 152 <changeSet author="fmguler" id="18"> 153 <comment>SERIAL'ler serilerin sonuna _seq ekliyor, ama kodda oldugu gibi cagirabiliyoruz</comment> 154 <sql> 155 ALTER TABLE aa_authorization_parameter_no_seq RENAME TO aa_authorization_parameter_no; 156 ALTER TABLE aa_group_no_seq RENAME TO aa_group_no; 157 ALTER TABLE user_attribute_no_seq RENAME TO user_attribute_no; 158 ALTER TABLE user_attribute_user_no_seq RENAME TO user_no; 159 ALTER TABLE user_operation_no_seq RENAME TO user_operation_no; 160 </sql> 161 <rollback/> 162 </changeSet> 163 <changeSet author="fmguler" id="19"> 164 <comment>Default Data</comment> 165 <sql> 166 INSERT INTO aa_group ("no", name, description) VALUES (1, 'Signomat Base Users', 'Signomat Base Users, have basic usage rights'); 167 INSERT INTO aa_group ("no", name, description) VALUES (2, 'SignArt Client Users', 'SignArt Client Users, have access to CSP mobile signing facilities'); 168 INSERT INTO aa_group ("no", name, description) VALUES (3, 'Workspace Users', 'Workspace Users, have access to /workspace web pages'); 169 INSERT INTO aa_group ("no", name, description) VALUES (4, 'Dox Users', 'Dox Users, have access to /dox web pages'); 170 INSERT INTO aa_group ("no", name, description) VALUES (5, 'Admin Users', 'Admin Users have access to /admin web pages'); 171 INSERT INTO aa_group ("no", name, description) VALUES (6, 'Demo Users', 'Demo Users have limited access, no access to DoX, and no timestamp facilities in signing portal'); 172 173 174 INSERT INTO aa_group_authorization (auth_name, group_no, param_no, "rule") VALUES ('PageAccessAuth', 1, NULL, 1); 175 INSERT INTO aa_group_authorization (auth_name, group_no, param_no, "rule") VALUES ('PageAccessAuth', 2, NULL, 2); 176 INSERT INTO aa_group_authorization (auth_name, group_no, param_no, "rule") VALUES ('PageAccessAuth', 3, NULL, 3); 177 INSERT INTO aa_group_authorization (auth_name, group_no, param_no, "rule") VALUES ('PageAccessAuth', 4, NULL, 4); 178 INSERT INTO aa_group_authorization (auth_name, group_no, param_no, "rule") VALUES ('PageAccessAuth', 5, NULL, 5); 179 INSERT INTO aa_group_authorization (auth_name, group_no, param_no, "rule") VALUES ('PageAccessAuth', 6, NULL, 3); 180 INSERT INTO aa_group_authorization (auth_name, group_no, param_no, "rule") VALUES ('SignAuth', 3, NULL, 1); 181 INSERT INTO aa_group_authorization (auth_name, group_no, param_no, "rule") VALUES ('SignAuth', 6, NULL, 2); 182 183 184 INSERT INTO user_attribute (attribute, value, "type", priority) VALUES ('username', 'admin', '00_id', 0); 185 INSERT INTO user_attribute (user_no, attribute, value, "type", priority) VALUES ((select user_no from user_attribute where attribute = 'username' and value='admin'), 'citizenshipNumber', '12345', '00_id', 0); 186 INSERT INTO user_authentication (username, "password") VALUES ('12345', '21232f297a57a5a743894a0e4a801fc3'); 187 188 189 INSERT INTO aa_user_group (username, group_no, "order") VALUES ((select user_no from user_attribute where attribute = 'username' and value='admin'), 1, 1); 190 INSERT INTO aa_user_group (username, group_no, "order") VALUES ((select user_no from user_attribute where attribute = 'username' and value='admin'), 3, 2); 191 INSERT INTO aa_user_group (username, group_no, "order") VALUES ((select user_no from user_attribute where attribute = 'username' and value='admin'), 4, 3); 192 INSERT INTO aa_user_group (username, group_no, "order") VALUES ((select user_no from user_attribute where attribute = 'username' and value='admin'), 5, 4); 193 </sql> 194 <rollback/> 195 </changeSet> 196 <changeSet author="fmguler" id="20" runOnChange="true"> 197 <comment>Function to delete all data from all tables. Can be updated later (runAlways is set)</comment> 198 <createProcedure><![CDATA[ 199 --DROP FUNCTION db_delete_all_data(); 200 CREATE OR REPLACE FUNCTION db_delete_all_data() RETURNS character varying 201 LANGUAGE plpgsql 202 AS 'DECLARE 203 table_list VARCHAR(100000); 204 mtable RECORD; 205 BEGIN 206 207 table_list := ''''; 208 -- public semasinda bulunan tum tablolar, bizim tablolarimiz 209 210 FOR mtable IN select * from pg_tables where schemaname = ''public'' LOOP 211 IF position(''databasechangelog'' in mtable.tablename)>0 THEN CONTINUE; END IF; 212 table_list := table_list || quote_ident(mtable.tablename) || '', ''; 213 END LOOP; 214 215 table_list := substring(table_list from 0 for length(table_list)-1); 216 217 EXECUTE ''TRUNCATE TABLE '' || table_list; 218 219 RETURN table_list; 220 END;'; 221 ]]> 222 </createProcedure> 223 <rollback/> 224 </changeSet> 225 <!-- << INFRASTRUCTURE SCHEMA --> 226 <!-- WORKSPACE SCHEMA >> --> 227 <changeSet author="fmguler" id="21"> 228 <createTable schemaName="public" tableName="workspace_file"> 229 <column autoIncrement="true" name="no" type="serial"> 230 <constraints nullable="false" primaryKey="true" primaryKeyName="workspace_file_pkey"/> 231 </column> 232 <column name="user_no" type="int4"/> 233 <column name="file_path" type="VARCHAR(10000)"/> 234 <column name="file_summary" type="TEXT(2147483647)"/> 235 <column name="status" type="int4"/> 236 <column name="creation_date" type="TIMESTAMP WITHOUT TIME ZONE"/> 237 <column name="file_extension" type="VARCHAR(1024)"/> 238 <column defaultValueBoolean="false" name="temporary" type="bool"> 239 <constraints nullable="false"/> 240 </column> 241 </createTable> 242 </changeSet> 243 <!-- << WORKSPACE SCHEMA --> 244 <changeSet author="fmguler" id="22"> 245 <tagDatabase tag="21"/> 246 </changeSet> 247 <!-- DOX SCHEMA >> --> 248 <changeSet author="fmguler" id="23"> 249 <createTable schemaName="public" tableName="dox_message"> 250 <column autoIncrement="true" name="no" type="serial"> 251 <constraints nullable="false" primaryKey="true" primaryKeyName="dox_message_pkey"/> 252 </column> 253 <column name="type" type="int4"/> 254 <column name="subject" type="VARCHAR(10000)"> 255 <constraints nullable="false"/> 256 </column> 257 <column name="content" type="TEXT(2147483647)"> 258 <constraints nullable="false"/> 259 </column> 260 <column name="sender" type="VARCHAR(1024)"> 261 <constraints nullable="false"/> 262 </column> 263 <column name="date" type="TIMESTAMP WITHOUT TIME ZONE"/> 264 <column defaultValueNumeric="0" name="options" type="int4"> 265 <constraints nullable="false"/> 266 </column> 267 <column defaultValueNumeric="0" name="status" type="int4"> 268 <constraints nullable="false"/> 269 </column> 270 </createTable> 271 </changeSet> 272 <changeSet author="fmguler" id="24"> 273 <createTable schemaName="public" tableName="dox_message_attribute"> 274 <column autoIncrement="true" name="no" type="serial"> 275 <constraints nullable="false" primaryKey="true" primaryKeyName="dox_message_attribute_pkey"/> 276 </column> 277 <column name="message_no" type="int4"> 278 <constraints nullable="false"/> 279 </column> 280 <column name="type" type="VARCHAR(1024)"> 281 <constraints nullable="false"/> 282 </column> 283 <column name="attribute" type="VARCHAR(1024)"> 284 <constraints nullable="false"/> 285 </column> 286 <column name="value" type="TEXT(2147483647)"> 287 <constraints nullable="false"/> 288 </column> 289 <column defaultValueNumeric="0" name="order" type="int4"> 290 <constraints nullable="false"/> 291 </column> 292 </createTable> 293 </changeSet> 294 <changeSet author="fmguler" id="25"> 295 <createTable schemaName="public" tableName="dox_message_attachment"> 296 <column autoIncrement="true" name="no" type="serial"> 297 <constraints nullable="false" primaryKey="true" primaryKeyName="dox_message_attachment_pkey"/> 298 </column> 299 <column name="message_no" type="int4"> 300 <constraints nullable="false"/> 301 </column> 302 <column name="content_no" type="int4"> 303 <constraints nullable="false"/> 304 </column> 305 <column name="content_type" type="VARCHAR(1000)"> 306 <constraints nullable="false"/> 307 </column> 308 <column name="name" type="VARCHAR(10000)"> 309 <constraints nullable="false"/> 310 </column> 311 <column name="reference" type="VARCHAR(1000)"> 312 <constraints nullable="false"/> 313 </column> 314 <column defaultValueNumeric="0" name="flags" type="int4"> 315 <constraints nullable="false"/> 316 </column> 317 </createTable> 318 </changeSet> 319 <changeSet author="fmguler" id="26"> 320 <createTable schemaName="public" tableName="dox_content"> 321 <column autoIncrement="true" name="no" type="serial"> 322 <constraints nullable="false" primaryKey="true" primaryKeyName="dox_attachment_content_pkey"/> 323 </column> 324 <column name="path" type="VARCHAR(10000)"> 325 <constraints nullable="false"/> 326 </column> 327 <column name="hash" type="VARCHAR(1024)"/> 328 </createTable> 329 </changeSet> 330 <changeSet author="fmguler" id="27"> 331 <addForeignKeyConstraint baseColumnNames="message_no" baseTableName="dox_message_attribute" baseTableSchemaName="public" constraintName="dox_message_attribute_message_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_message" referencedTableSchemaName="public"/> 332 </changeSet> 333 <changeSet author="fmguler" id="28"> 334 <addForeignKeyConstraint baseColumnNames="message_no" baseTableName="dox_message_attachment" baseTableSchemaName="public" constraintName="dox_message_attachment_message_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_message" referencedTableSchemaName="public"/> 335 </changeSet> 336 <changeSet author="fmguler" id="29"> 337 <addForeignKeyConstraint baseColumnNames="content_no" baseTableName="dox_message_attachment" baseTableSchemaName="public" constraintName="dox_message_attachment_content_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_content" referencedTableSchemaName="public"/> 338 </changeSet> 339 <changeSet author="fmguler" id="30"> 340 <tagDatabase tag="29"/> 341 </changeSet> 342 <!-- DOX SCHEMA (TRANSACTION) >> --> 343 <changeSet author="fmguler" id="31"> 344 <createTable schemaName="public" tableName="dox_domain"> 345 <column autoIncrement="true" name="no" type="serial"> 346 <constraints nullable="false" primaryKey="true" primaryKeyName="dox_domain_pkey"/> 347 </column> 348 <column name="domain" type="VARCHAR(1024)"/> 349 <column name="address" type="VARCHAR(2048)"/> 350 <column name="client_certificate" type="TEXT(2147483647)"/> 351 <column name="server_certificate" type="TEXT(2147483647)"/> 352 <column defaultValueBoolean="false" name="can_relay" type="bool"> 353 <constraints nullable="false"/> 354 </column> 355 <column defaultValueNumeric="0" name="protocol" type="int4"> 356 <constraints nullable="false"/> 357 </column> 358 </createTable> 359 </changeSet> 360 <changeSet author="fmguler" id="32"> 361 <createTable schemaName="public" tableName="dox_transaction_log"> 362 <column autoIncrement="true" name="no" type="serial"> 363 <constraints nullable="false" primaryKey="true" primaryKeyName="dox_transaction_log_pkey"/> 364 </column> 365 <column name="message_no" type="int4"/> 366 <column name="sender" type="VARCHAR(1024)"> 367 <constraints nullable="false"/> 368 </column> 369 <column name="recipient" type="VARCHAR(1024)"> 370 <constraints nullable="false"/> 371 </column> 372 <column defaultValueNumeric="0" name="sender_domain_no" type="int4"> 373 <constraints nullable="false"/> 374 </column> 375 <column defaultValueNumeric="0" name="recipient_domain_no" type="int4"> 376 <constraints nullable="false"/> 377 </column> 378 <column defaultValueBoolean="false" name="relay" type="bool"> 379 <constraints nullable="false"/> 380 </column> 381 <column defaultValueDate="now()" name="date" type="TIMESTAMP WITHOUT TIME ZONE"> 382 <constraints nullable="false"/> 383 </column> 384 <column defaultValueNumeric="0" name="protocol" type="int4"> 385 <constraints nullable="false"/> 386 </column> 387 <column defaultValueNumeric="0" name="status" type="int4"> 388 <constraints nullable="false"/> 389 </column> 390 <column name="details" type="TEXT(2147483647)"/> 391 </createTable> 392 </changeSet> 393 <changeSet author="fmguler" id="33"> 394 <createTable schemaName="public" tableName="dox_user_message"> 395 <column autoIncrement="true" name="no" type="serial"> 396 <constraints nullable="false" primaryKey="true" primaryKeyName="dox_user_message_pkey"/> 397 </column> 398 <column name="user_no" type="int4"> 399 <constraints nullable="false"/> 400 </column> 401 <column name="message_no" type="int4"> 402 <constraints nullable="false"/> 403 </column> 404 <column defaultValueNumeric="0" name="folder" type="int4"> 405 <constraints nullable="false"/> 406 </column> 407 <column name="transaction_log_no" type="int4"/> 408 </createTable> 409 </changeSet> 410 <changeSet author="fmguler" id="34"> 411 <addForeignKeyConstraint baseColumnNames="sender_domain_no" baseTableName="dox_transaction_log" baseTableSchemaName="public" constraintName="dox_transaction_log_sender_domain_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_domain" referencedTableSchemaName="public"/> 412 </changeSet> 413 <changeSet author="fmguler" id="35"> 414 <addForeignKeyConstraint baseColumnNames="recipient_domain_no" baseTableName="dox_transaction_log" baseTableSchemaName="public" constraintName="dox_transaction_log_recipient_domain_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_domain" referencedTableSchemaName="public"/> 415 </changeSet> 416 <changeSet author="fmguler" id="36"> 417 <addForeignKeyConstraint baseColumnNames="message_no" baseTableName="dox_transaction_log" baseTableSchemaName="public" constraintName="dox_transaction_log_message_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_message" referencedTableSchemaName="public"/> 418 </changeSet> 419 <changeSet author="fmguler" id="37"> 420 <addForeignKeyConstraint baseColumnNames="message_no" baseTableName="dox_user_message" baseTableSchemaName="public" constraintName="dox_user_message_message_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_message" referencedTableSchemaName="public"/> 421 </changeSet> 422 <changeSet author="fmguler" id="38"> 423 <addForeignKeyConstraint baseColumnNames="transaction_log_no" baseTableName="dox_user_message" baseTableSchemaName="public" constraintName="dox_user_message_transaction_log_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="SET NULL" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_transaction_log" referencedTableSchemaName="public"/> 424 </changeSet> 425 <changeSet author="fmguler" id="39"> 426 <tagDatabase tag="38"/> 427 </changeSet> 428 <!-- DOX SCHEMA (UPDATE 1) --> 429 <changeSet author="fmguler" id="40"> 430 <addColumn tableName="dox_message_attachment" schemaName="public"> 431 <column name="content_length" type="int4" defaultValueNumeric="0"/> 432 </addColumn> 433 <comment>to keep track of attachment size, and tell to the browser while downloading</comment> 434 </changeSet> 435 <changeSet author="fmguler" id="41"> 436 <comment> 437 change on delete cascade to on delete restrict of some foreign key constraints, since referencing tables does not belong to referenced tables 438 e.g. Msg. attachment does not belong to content, if a msg attch. exists, referenced content cannot be deleted. 439 </comment> 440 <dropForeignKeyConstraint baseTableName="dox_message_attachment" baseTableSchemaName="public" constraintName="dox_message_attachment_content_no_fkey"/> 441 <rollback changeSetId="29" changeSetAuthor="fmguler" /> 442 </changeSet> 443 <changeSet author="fmguler" id="42"> 444 <addForeignKeyConstraint baseTableName="dox_message_attachment" baseTableSchemaName="public" baseColumnNames="content_no" constraintName="dox_message_attachment_content_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_content" referencedTableSchemaName="public"/> 445 </changeSet> 446 <changeSet author="fmguler" id="43"> 447 <dropForeignKeyConstraint baseTableName="dox_transaction_log" baseTableSchemaName="public" constraintName="dox_transaction_log_recipient_domain_no_fkey"/> 448 <rollback changeSetId="35" changeSetAuthor="fmguler" /> 449 </changeSet> 450 <changeSet author="fmguler" id="44"> 451 <addForeignKeyConstraint baseColumnNames="recipient_domain_no" baseTableName="dox_transaction_log" baseTableSchemaName="public" constraintName="dox_transaction_log_recipient_domain_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_domain" referencedTableSchemaName="public"/> 452 </changeSet> 453 <changeSet author="fmguler" id="45"> 454 <dropForeignKeyConstraint baseTableName="dox_transaction_log" baseTableSchemaName="public" constraintName="dox_transaction_log_sender_domain_no_fkey"/> 455 <rollback changeSetId="34" changeSetAuthor="fmguler" /> 456 </changeSet> 457 <changeSet author="fmguler" id="46"> 458 <addForeignKeyConstraint baseColumnNames="sender_domain_no" baseTableName="dox_transaction_log" baseTableSchemaName="public" constraintName="dox_transaction_log_sender_domain_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_domain" referencedTableSchemaName="public"/> 459 </changeSet> 460 <changeSet author="fmguler" id="47"> 461 <dropForeignKeyConstraint baseTableName="dox_user_message" baseTableSchemaName="public" constraintName="dox_user_message_transaction_log_no_fkey"/> 462 <rollback changeSetId="38" changeSetAuthor="fmguler" /> 463 </changeSet> 464 <changeSet author="fmguler" id="48"> 465 <addForeignKeyConstraint baseColumnNames="transaction_log_no" baseTableName="dox_user_message" baseTableSchemaName="public" constraintName="dox_user_message_transaction_log_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_transaction_log" referencedTableSchemaName="public"/> 466 </changeSet> 467 <changeSet author="fmguler" id="49"> 468 <dropForeignKeyConstraint baseTableName="dox_user_message" baseTableSchemaName="public" constraintName="dox_user_message_message_no_fkey"/> 469 <rollback changeSetId="37" changeSetAuthor="fmguler" /> 470 </changeSet> 471 <changeSet author="fmguler" id="50"> 472 <addForeignKeyConstraint baseColumnNames="message_no" baseTableName="dox_user_message" baseTableSchemaName="public" constraintName="dox_user_message_message_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_message" referencedTableSchemaName="public"/> 473 </changeSet> 474 <changeSet author="fmguler" id="51"> 475 <tagDatabase tag="50"/> 476 </changeSet> 477 <!-- << DOX SCHEMA --> 35 <!-- << TEST SCHEMA --> 478 36 </databaseChangeLog> -
trunk/fmgVen/nbproject/build-impl.xml
r19 r26 80 80 </target> 81 81 <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-init-macrodef-property" name="-do-init"> 82 <j2seproject1:property name="platform.home" value="platforms.${platform.active}.home"/> 83 <j2seproject1:property name="platform.bootcp" value="platforms.${platform.active}.bootclasspath"/> 84 <j2seproject1:property name="platform.compiler" value="platforms.${platform.active}.compile"/> 85 <j2seproject1:property name="platform.javac.tmp" value="platforms.${platform.active}.javac"/> 86 <condition property="platform.javac" value="${platform.home}/bin/javac"> 87 <equals arg1="${platform.javac.tmp}" arg2="$${platforms.${platform.active}.javac}"/> 88 </condition> 89 <property name="platform.javac" value="${platform.javac.tmp}"/> 90 <j2seproject1:property name="platform.java.tmp" value="platforms.${platform.active}.java"/> 91 <condition property="platform.java" value="${platform.home}/bin/java"> 92 <equals arg1="${platform.java.tmp}" arg2="$${platforms.${platform.active}.java}"/> 93 </condition> 94 <property name="platform.java" value="${platform.java.tmp}"/> 95 <j2seproject1:property name="platform.javadoc.tmp" value="platforms.${platform.active}.javadoc"/> 96 <condition property="platform.javadoc" value="${platform.home}/bin/javadoc"> 97 <equals arg1="${platform.javadoc.tmp}" arg2="$${platforms.${platform.active}.javadoc}"/> 98 </condition> 99 <property name="platform.javadoc" value="${platform.javadoc.tmp}"/> 100 <condition property="platform.invalid" value="true"> 101 <or> 102 <contains string="${platform.javac}" substring="$${platforms."/> 103 <contains string="${platform.java}" substring="$${platforms."/> 104 <contains string="${platform.javadoc}" substring="$${platforms."/> 105 </or> 106 </condition> 107 <fail unless="platform.home">Must set platform.home</fail> 108 <fail unless="platform.bootcp">Must set platform.bootcp</fail> 109 <fail unless="platform.java">Must set platform.java</fail> 110 <fail unless="platform.javac">Must set platform.javac</fail> 111 <fail if="platform.invalid"> 112 The J2SE Platform is not correctly set up. 113 Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. 114 Either open the project in the IDE and setup the Platform with the same name or add it manually. 115 For example like this: 116 ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file) 117 or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used) 118 </fail> 82 119 <available file="${manifest.file}" property="manifest.available"/> 83 120 <available file="${application.splash}" property="splashscreen.available"/> … … 199 236 <length length="0" string="${endorsed.classpath}" when="greater"/> 200 237 </condition> 201 <property name="javac.fork" value="false"/>202 238 <property name="jar.index" value="false"/> 203 239 <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/> … … 245 281 <mkdir dir="${empty.dir}"/> 246 282 <mkdir dir="@{apgeneratedsrcdir}"/> 247 <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">283 <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" executable="${platform.javac}" fork="yes" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}"> 248 284 <src> 249 285 <dirset dir="@{gensrcdir}" erroronmissingdir="false"> … … 284 320 <property location="${build.dir}/empty" name="empty.dir"/> 285 321 <mkdir dir="${empty.dir}"/> 286 <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">322 <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" executable="${platform.javac}" fork="yes" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}"> 287 323 <src> 288 324 <dirset dir="@{gensrcdir}" erroronmissingdir="false"> … … 335 371 <attribute default="**" name="testincludes"/> 336 372 <sequential> 337 <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}">373 <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" jvm="${platform.java}" showoutput="true" tempdir="${build.dir}"> 338 374 <batchtest todir="${build.test.results.dir}"> 339 375 <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}"> … … 366 402 <path path="@{classpath}"/> 367 403 </classpath> 404 <bootclasspath> 405 <path path="${platform.bootcp}"/> 406 </bootclasspath> 368 407 </nbjpdastart> 369 408 </sequential> … … 381 420 </target> 382 421 <target name="-init-debug-args"> 383 <property name="version-output" value="java version "${ant.java.version}"/> 422 <exec executable="${platform.java}" outputproperty="version-output"> 423 <arg value="-version"/> 424 </exec> 384 425 <condition property="have-jdk-older-than-1.4"> 385 426 <or> … … 406 447 <element name="customize" optional="true"/> 407 448 <sequential> 408 <java classname="@{classname}" dir="${work.dir}" fork="true" >449 <java classname="@{classname}" dir="${work.dir}" fork="true" jvm="${platform.java}"> 409 450 <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> 410 451 <jvmarg line="${debug-args-line}"/> … … 431 472 <element name="customize" optional="true"/> 432 473 <sequential> 433 <java classname="@{classname}" dir="${work.dir}" fork="true" >474 <java classname="@{classname}" dir="${work.dir}" fork="true" jvm="${platform.java}"> 434 475 <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> 435 476 <jvmarg value="-Dfile.encoding=${runtime.encoding}"/> … … 613 654 <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/> 614 655 </pathconvert> 615 <echo> java-cp "${run.classpath.with.dist.jar}" ${main.class}</echo>656 <echo>${platform.java} -cp "${run.classpath.with.dist.jar}" ${main.class}</echo> 616 657 </target> 617 658 <target depends="init,compile,-pre-pre-jar,-pre-jar,-init-macrodef-copylibs" if="do.archive+manifest.available+main.class+mkdist.available+splashscreen.available" name="-do-jar-with-libraries-and-splashscreen"> … … 627 668 <echo>To run this application from the command line without Ant, try:</echo> 628 669 <property location="${dist.jar}" name="dist.jar.resolved"/> 629 <echo> java-jar "${dist.jar.resolved}"</echo>670 <echo>${platform.java} -jar "${dist.jar.resolved}"</echo> 630 671 </target> 631 672 <target depends="init,compile,-pre-pre-jar,-pre-jar,-init-macrodef-copylibs" if="do.archive+manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries" unless="splashscreen.available"> … … 637 678 <echo>To run this application from the command line without Ant, try:</echo> 638 679 <property location="${dist.jar}" name="dist.jar.resolved"/> 639 <echo> java-jar "${dist.jar.resolved}"</echo>680 <echo>${platform.java} -jar "${dist.jar.resolved}"</echo> 640 681 </target> 641 682 <target name="-post-jar"> … … 715 756 <target depends="init" if="have.sources" name="-javadoc-build"> 716 757 <mkdir dir="${dist.javadoc.dir}"/> 717 <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">758 <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" executable="${platform.javadoc}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}"> 718 759 <classpath> 719 760 <path path="${javac.classpath}"/> -
trunk/fmgVen/nbproject/genfiles.properties
r23 r26 1 build.xml.data.CRC32= 6b84a8b11 build.xml.data.CRC32=31e5c25b 2 2 build.xml.script.CRC32=a9b2e5a3 3 3 build.xml.stylesheet.CRC32=28e38971@1.38.1.45 4 4 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 5 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 nbproject/build-impl.xml.data.CRC32= 6b84a8b17 nbproject/build-impl.xml.script.CRC32= 494c2ca46 nbproject/build-impl.xml.data.CRC32=31e5c25b 7 nbproject/build-impl.xml.script.CRC32=68c11675 8 8 nbproject/build-impl.xml.stylesheet.CRC32=78c6a6ee@1.38.1.45 -
trunk/fmgVen/nbproject/project.properties
r24 r26 30 30 ${libs.Ven.classpath} 31 31 # Space-separated list of extra javac options 32 javac.compilerargs= -Xlint:deprecation32 javac.compilerargs= 33 33 javac.deprecation=false 34 34 javac.processorpath=\ … … 53 53 javadoc.windowtitle= 54 54 meta.inf.dir=${src.dir}/META-INF 55 platform.active= default_platform55 platform.active=JDK_1.4 56 56 run.classpath=\ 57 57 ${javac.classpath}:\ -
trunk/fmgVen/nbproject/project.xml
r23 r26 6 6 <name>fmgVen</name> 7 7 <minimum-ant-version>1.6.5</minimum-ant-version> 8 <explicit-platform explicit-source-supported="true"/> 8 9 <source-roots> 9 10 <root id="src.dir"/> -
trunk/fmgVen/src/com/fmguler/ven/QueryGenerator.java
r23 r26 18 18 package com.fmguler.ven; 19 19 20 import com.fmguler.ven.util.Convert; 21 import java.beans.PropertyDescriptor; 22 import java.util.Date; 20 23 import java.util.HashSet; 21 24 import java.util.Set; 25 import org.springframework.beans.BeanWrapper; 26 import org.springframework.beans.BeanWrapperImpl; 22 27 23 28 /** … … 27 32 public class QueryGenerator { 28 33 private Set domainPackages; 34 private Set dbClasses; 29 35 30 36 public QueryGenerator() { 31 37 domainPackages = new HashSet(); 38 dbClasses = new HashSet(); 39 //the predefined database classes; 40 this.dbClasses.add(Integer.class); 41 this.dbClasses.add(String.class); 42 this.dbClasses.add(Date.class); 43 this.dbClasses.add(Double.class); 44 this.dbClasses.add(Boolean.class); 32 45 } 33 46 … … 40 53 } 41 54 42 public String generateUpdateQuery() { 43 return null; 55 public String generateInsertQuery(Object object) throws VenException { 56 BeanWrapper wr = new BeanWrapperImpl(object); 57 String objectName = Convert.toSimpleName(object.getClass().getName()); 58 String tableName = Convert.toDB(objectName); 59 PropertyDescriptor[] pdArr = wr.getPropertyDescriptors(); 60 61 //generate insert query 62 StringBuffer query = new StringBuffer("insert into " + tableName + "("); 63 StringBuffer values = new StringBuffer(" values("); 64 for (int i = 0; i < pdArr.length; i++) { 65 Class fieldClass = pdArr[i].getPropertyType(); //field class 66 String columnName = Convert.toDB(pdArr[i].getName()); //column name 67 String fieldName = pdArr[i].getName(); //field name 68 //if (fieldName.equals("id")) continue; //remove if it does not break the sequence 69 if (dbClasses.contains(fieldClass)) { //direct database field (Integer,String,Date, etc) 70 query.append(columnName); 71 query.append(","); 72 values.append(":").append(fieldName); 73 values.append(","); 74 } 75 if (fieldClass.getPackage() != null && domainPackages.contains(fieldClass.getPackage().getName())) { //object 76 query.append(Convert.toDB(fieldName)).append("_id"); 77 query.append(","); 78 values.append(":").append(fieldName).append(".id"); 79 values.append(","); 80 } 81 } 82 query.deleteCharAt(query.length() - 1); 83 query.append(")"); 84 values.deleteCharAt(values.length() - 1); 85 values.append(");"); 86 query.append(values); 87 88 return query.toString(); 44 89 } 45 90 46 //SETTERS------------------------------------------------------------------- 91 /** 92 * Generates insert/update query 93 * @return the insert update SQL query 94 */ 95 public String generateUpdateQuery(Object object) throws VenException { 96 BeanWrapper wr = new BeanWrapperImpl(object); 97 String objectName = Convert.toSimpleName(object.getClass().getName()); 98 String tableName = Convert.toDB(objectName); 99 PropertyDescriptor[] pdArr = wr.getPropertyDescriptors(); 100 101 StringBuffer query = new StringBuffer("update " + tableName + " set "); 102 for (int i = 0; i < pdArr.length; i++) { 103 Class fieldClass = pdArr[i].getPropertyType(); //field class 104 String columnName = Convert.toDB(pdArr[i].getName()); //column name 105 String fieldName = pdArr[i].getName(); //field name 106 if (dbClasses.contains(fieldClass)) { //direct database field (Integer,String,Date, etc) 107 query.append(columnName).append("=:").append(fieldName); 108 query.append(","); 109 } 110 if (fieldClass.getPackage() != null && domainPackages.contains(fieldClass.getPackage().getName())) { //object 111 query.append(columnName).append("_id=:").append(fieldName).append(".id"); 112 query.append(","); 113 } 114 } 115 query.deleteCharAt(query.length() - 1); 116 query.append(" where id = :id ;"); //TODO: remove the last comma 117 return query.toString(); 118 } 119 120 public String generateSequenceQuery(Object object) throws VenException { 121 String objectName = Convert.toSimpleName(object.getClass().getName()); 122 String tableName = Convert.toDB(objectName); 123 return "select nextval('" + tableName + "_id_seq');"; 124 } 125 126 //-------------------------------------------------------------------------- 127 //SETTERS 47 128 public void addDomainPackage(String domainPackage) { 48 129 domainPackages.add(domainPackage); -
trunk/fmgVen/src/com/fmguler/ven/Ven.java
r25 r26 18 18 package com.fmguler.ven; 19 19 20 import java.util.HashMap; 20 21 import java.util.List; 21 22 import javax.sql.DataSource; 23 import org.springframework.beans.BeanWrapper; 24 import org.springframework.beans.BeanWrapperImpl; 25 import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource; 22 26 import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; 27 import org.springframework.jdbc.core.namedparam.SqlParameterSource; 23 28 24 29 /** … … 44 49 } 45 50 46 public Object get(int no, Class objectClass) {51 public Object get(int id, Class objectClass) { 47 52 return null; 48 53 } 49 54 55 /** 56 * Save the object. If it has a "id" property it will be updated. 57 * It will be inserted otherwise. 58 * <p> 59 * The object will be saved to a table with the same name as the object, 60 * The fields of object will be mapped to the table fields. 61 * 62 * @param object the object to be saved 63 */ 50 64 public void save(Object object) { 65 String query = null; 66 67 if (isObjectNew(object)) { 68 //if this is a new object assign a new id first 69 generateId(object); 70 query = generator.generateInsertQuery(object); 71 } else { 72 query = generator.generateUpdateQuery(object); 73 } 74 75 //execute the insert/update query 76 SqlParameterSource parameterSource = new BeanPropertySqlParameterSource(object); 77 template.update(query, parameterSource); 51 78 } 52 79 53 public void delete(int no, Class objectClass) {80 public void delete(int id, Class objectClass) { 54 81 } 55 82 56 //SETTERS------------------------------------------------------------------- 83 //-------------------------------------------------------------------------- 84 //PRIVATE METHODS 85 //return true if the object id is zero or null false otherwise 86 private boolean isObjectNew(Object object) throws VenException { 87 BeanWrapper beanWrapper = new BeanWrapperImpl(object); 88 Object objectId = beanWrapper.getPropertyValue("id"); 89 if (objectId == null) return true; 90 if (!(objectId instanceof Integer)) throw new VenException(VenException.EC_GENERATOR_OBJECT_ID_TYPE_INVALID); 91 return ((Integer)objectId).intValue() == 0; 92 } 93 94 //set new object id 95 private void generateId(Object object) { 96 Integer newObjectId = new Integer(template.queryForInt(generator.generateSequenceQuery(object), new HashMap())); 97 BeanWrapper beanWrapper = new BeanWrapperImpl(object); 98 beanWrapper.setPropertyValue("id", newObjectId); 99 } 100 101 //-------------------------------------------------------------------------- 102 //SETTERS 57 103 public void setDataSource(DataSource dataSource) { 58 104 if (dataSource == null) throw new RuntimeException("fmgVen - DataSource cannot be null"); -
trunk/fmgVen/src/net/fmg/ven/Olcut.java
r22 r26 7 7 * Ven - Ayar Yerine Gelenek veritabanı erişim nesnesi 8 8 */ 9 10 9 package net.fmg.ven; 11 10 … … 25 24 private Map parametreler; 26 25 private Set baglaclar; 27 26 28 27 /** 29 28 * Yeni ölçüt … … 32 31 this.metin = ""; 33 32 this.parametreler = new HashMap(); 34 this.baglaclar = 33 this.baglaclar = new HashSet(); 35 34 //{"and", "or", "=", "<>", "<", ">"} 36 35 } 37 36 38 37 /** 39 38 * YAPILMADI 40 39 */ 41 public Olcut ekle(Olcut olcut) {40 public Olcut ekle(Olcut olcut) { 42 41 return null; 43 42 } 44 43 45 44 /** 46 45 * YAPILMADI 47 46 */ 48 public Olcut ekle(List olcutler) {47 public Olcut ekle(List olcutler) { 49 48 return null; 50 49 } 51 50 52 51 /** 53 52 * YAPILMADI 54 53 */ 55 public Olcut ve() {54 public Olcut ve() { 56 55 return null; 57 56 } 58 57 59 58 /** 60 59 * koşul ekle 61 60 */ 62 public Olcut ekle(String kosul) {63 this.metin += " "+kosul;61 public Olcut ekle(String kosul) { 62 this.metin += " " + kosul; 64 63 return this; 65 64 } 66 65 67 66 /** 68 67 * koşullarda kullanılan parametreleri ekle 69 68 */ 70 public Olcut ekle(String parametre, Object nesne) {71 this.parametreler.put(parametre, nesne);69 public Olcut ekle(String parametre, Object nesne) { 70 this.parametreler.put(parametre, nesne); 72 71 return this; 73 72 } 74 73 75 74 /** 76 75 * koşullarda kullanılan parametreleri tümden ekle 77 76 */ 78 public Olcut ekle(Map parametreler) {77 public Olcut ekle(Map parametreler) { 79 78 this.parametreler.putAll(parametreler); 80 79 return this; 81 80 } 82 83 public String olcutleriAl() {81 82 public String olcutleriAl() { 84 83 //((1=1) and ((1=1) and (musteri_numuneler_numune_sahibi.rapor_tarihi is null) and (musteri.no = 4))) 85 84 //Musteri.numuneler.deneyler.deneyTip.ad like :p1 86 85 String sonuc = ""; 87 metin = metin.replace ("(","( ");88 metin = metin.replace (")",")");86 metin = metin.replaceAll("\\(", "\\( "); 87 metin = metin.replaceAll("\\)", " \\)"); 89 88 String[] parcalar = metin.split(" "); 90 89 for (int i = 0; i < parcalar.length; i++) { 91 if (!parcalar[i].startsWith(":") && parcalar[i]. contains(".")){92 int sonNokta = parcalar[i].lastIndexOf('.'); 90 if (!parcalar[i].startsWith(":") && parcalar[i].indexOf(".") >= 0) { 91 int sonNokta = parcalar[i].lastIndexOf('.'); 93 92 sonuc += " "; 94 int u = parcalar[i].length(); 95 sonuc += Cevir.vt(parcalar[i].substring(0,sonNokta).replace('.','_'));96 sonuc += Cevir.vt(parcalar[i].substring(sonNokta,u));97 } else{98 sonuc += " " +parcalar[i];93 int u = parcalar[i].length(); 94 sonuc += Cevir.vt(parcalar[i].substring(0, sonNokta).replace('.', '_')); 95 sonuc += Cevir.vt(parcalar[i].substring(sonNokta, u)); 96 } else { 97 sonuc += " " + parcalar[i]; 99 98 } 100 99 } 101 100 return sonuc; 102 101 } 103 104 public Map parametreler() {102 103 public Map parametreler() { 105 104 return this.parametreler; 106 105 } 107 106 108 107 public String toString() { 109 return olcutleriAl() +" "+this.parametreler;108 return olcutleriAl() + " " + this.parametreler; 110 109 } 111 112 110 } -
trunk/fmgVen/src/net/fmg/ven/SorguEslestirici.java
r23 r26 57 57 long t1 = System.currentTimeMillis(); 58 58 final List sonuclar = new LinkedList(); 59 final String tabloAdi = Cevir.vt( nesneSinifi.getSimpleName());59 final String tabloAdi = Cevir.vt(Cevir.isim(nesneSinifi.getName())); 60 60 final Set sutunlar = new HashSet(); 61 61 -
trunk/fmgVen/src/net/fmg/ven/SorguUretici.java
r22 r26 59 59 if (alanSinifi.getPackage()!=null && nesnePaketleri.contains(alanSinifi.getPackage().getName()) && baglarKapsar(baglar,nesneYolu+"."+alanAdi)){ //domain nesnesi 1-1 join 60 60 String bagTablosuDigerAd = tabloAdi+"_"+sutunAdi; // bağ tablosu için diğer ad, çünkü aynı isimde birden fazla bağ olabilir, karışmasın 61 String bagTablosu = Cevir.vt( alanSinifi.getSimpleName());//gerçek bağ tablosu61 String bagTablosu = Cevir.vt(Cevir.isim(alanSinifi.getName()));//gerçek bağ tablosu 62 62 fromCumlesi.append(" left join "+bagTablosu+" "+bagTablosuDigerAd); 63 63 fromCumlesi.append(" on "+bagTablosuDigerAd+".no = "+tabloAdi+"."+sutunAdi+"_no"); … … 67 67 Class cokluAlandakiNesneSinifi = (Class)wr.getPropertyValue(alanAdi+".nesneSinifi"); 68 68 String bagTablosuDigerAd = tabloAdi+"_"+sutunAdi; // bağ tablosu için diğer ad, çünkü aynı isimde birden fazla bağ olabilir, karışmasın 69 String bagTablosu = Cevir.vt( cokluAlandakiNesneSinifi.getSimpleName());//gerçek bağ tablosu69 String bagTablosu = Cevir.vt(Cevir.isim(cokluAlandakiNesneSinifi.getName()));//gerçek bağ tablosu 70 70 String bagAlani = Cevir.vt((String)wr.getPropertyValue(alanAdi+".bagAlani")); //YAP: bunu vermeden de varsayılan birşey yapsın 71 71 fromCumlesi.append(" left join "+bagTablosu+" "+bagTablosuDigerAd); … … 93 93 public String secmeSorgusuUret(Set baglar, Class nesneSinifi){ 94 94 //long t1 = System.currentTimeMillis(); 95 String nesneAdi = nesneSinifi.getSimpleName();95 String nesneAdi = Cevir.isim(nesneSinifi.getName()); 96 96 String tabloAdi = Cevir.vt(nesneAdi); 97 97 StringBuffer selectCumlesi = new StringBuffer("select "); … … 108 108 public String saymaSorgusuUret(Set baglar, Class nesneSinifi){ 109 109 //long t1 = System.currentTimeMillis(); 110 String nesneAdi = nesneSinifi.getSimpleName();110 String nesneAdi = Cevir.isim(nesneSinifi.getName()); 111 111 String tabloAdi = Cevir.vt(nesneAdi); 112 112 StringBuffer selectCumlesi = new StringBuffer(); … … 123 123 public String guncellemeSorgusuUret(Object nesne){ 124 124 BeanWrapper wr = new BeanWrapperImpl(nesne); 125 String nesneAdi = nesne.getClass().getSimpleName();125 String nesneAdi = Cevir.isim(nesne.getClass().getName()); 126 126 String tabloAdi = Cevir.vt(nesneAdi); 127 127 StringBuffer sorgu; -
trunk/fmgVen/src/net/fmg/ven/Ven.java
r22 r26 48 48 Set baglar = new HashSet(); 49 49 kullanimlar.put(kullanimNo,baglar); 50 baglar.add( nesneSinifi.getSimpleName());50 baglar.add(Cevir.isim(nesneSinifi.getName())); 51 51 52 52 String sorgu = uretici.secmeSorgusuUret(baglar, nesneSinifi); … … 111 111 public Object nesneAl(Class nesneSinifi, Integer no, Set baglar){ 112 112 String sorgu = uretici.secmeSorgusuUret(baglar, nesneSinifi); 113 Olcut olcut = new Olcut().ekle("and "+Cevir.vt( nesneSinifi.getSimpleName())+".no = :___no").ekle("___no",no);113 Olcut olcut = new Olcut().ekle("and "+Cevir.vt(Cevir.isim(nesneSinifi.getName()))+".no = :___no").ekle("___no",no); 114 114 sorgu += " where 1=1"+olcut.olcutleriAl(); 115 115 if(hataAyiklama) System.out.println("SQL: "+sorgu); … … 127 127 public Object nesneAl(Class nesneSinifi, Integer no, Set baglar, Olcut olcut){ 128 128 String sorgu = uretici.secmeSorgusuUret(baglar, nesneSinifi); 129 sorgu += " where 1=1 and "+Cevir.vt( nesneSinifi.getSimpleName())+".no = :___no "+olcut.olcutleriAl(); //No diğer ölçütlerden önce gelmeli order-limit için129 sorgu += " where 1=1 and "+Cevir.vt(Cevir.isim(nesneSinifi.getName()))+".no = :___no "+olcut.olcutleriAl(); //No diğer ölçütlerden önce gelmeli order-limit için 130 130 olcut.ekle("___no",no); 131 131 if(hataAyiklama) System.out.println("SQL: "+sorgu); … … 145 145 BeanWrapper wr = new BeanWrapperImpl(nesne); 146 146 if(wr.getPropertyValue("no")==null){ 147 wr.setPropertyValue("no",new Integer(sablon.queryForInt("select currval('"+Cevir.vt( nesne.getClass().getSimpleName())+"_no')", new HashMap())));147 wr.setPropertyValue("no",new Integer(sablon.queryForInt("select currval('"+Cevir.vt(Cevir.isim(nesne.getClass().getName()))+"_no')", new HashMap()))); 148 148 } 149 149 } 150 150 151 151 public void nesneSil(Integer no, Class nesneSinifi){ 152 String sorgu = "delete from "+Cevir.vt( nesneSinifi.getSimpleName())+" where no = :no ;";152 String sorgu = "delete from "+Cevir.vt(Cevir.isim(nesneSinifi.getName()))+" where no = :no ;"; 153 153 Map parametreler = new HashMap(2); 154 154 parametreler.put("no",no); -
trunk/fmgVen/src/net/fmg/ven/arac/Cevir.java
r22 r26 35 35 return sonuc.toString(); 36 36 } 37 38 public static String isim(String isim) { 39 int i = isim.lastIndexOf("."); 40 if (i < 0) return isim; 41 return isim.substring(i + 1); 42 } 37 43 38 44 } -
trunk/fmgVen/test/com/fmguler/ven/sample/Sample.java
r25 r26 40 40 public static void main(String[] args) { 41 41 buildDatabase(); 42 test Get();43 //rollbackDatabase();42 testSave(); 43 rollbackDatabase(); 44 44 } 45 45 … … 139 139 Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(getDataSource().getConnection()); 140 140 Liquibase liquibase = new Liquibase("etc/test-db/test-db-changelog.xml", new FileSystemFileOpener(), database); 141 //liquibase.rollback(51, ""); 142 liquibase.rollback("0", ""); 141 liquibase.rollback("tag-single-table", ""); 143 142 Locale.setDefault(currLocale); 144 143 } catch (SQLException ex) { -
trunk/fmgVen/test/com/fmguler/ven/sample/domain/SomeDomainObject.java
r23 r26 25 25 */ 26 26 public class SomeDomainObject { 27 private int no;27 private Integer id; 28 28 private String name; 29 29 private String description; … … 31 31 32 32 /** 33 * @return the no33 * @return the id 34 34 */ 35 public int getNo() {36 return no;35 public Integer getId() { 36 return id; 37 37 } 38 38 39 39 /** 40 * @param no the noto set40 * @param id the id to set 41 41 */ 42 public void set No(int no) {43 this. no = no;42 public void setId(Integer id) { 43 this.id = id; 44 44 } 45 45 … … 87 87 88 88 public String toString() { 89 return no+ " " + name + " " + description + " " + date;89 return id + " " + name + " " + description + " " + date; 90 90 } 91 91 }
Note: See TracChangeset
for help on using the changeset viewer.