Changeset 26 for trunk


Ignore:
Timestamp:
Jan 2, 2011, 8:51:21 PM (14 years ago)
Author:
fmguler
Message:

Refs #3 - Ven.save() is transferred to the new package. Save use case is completed. Convert.toDB() converts camel case object names to database names with underscores. Unchecked VenException is thrown by Ven methods. Liquibase changelog (test-db-changelog.xml) is changed to include only a simple object to test save operation. It creates a sample database table and inserts a sample row. On rollback it removes sample data. Using liquibase, Sample.java builds database, tests save operation and rolls back.

QueryGenerator generates insert and update queries for save and generates sequence query to assign ids to new objects. Ven calls query generator and runs the query using spring jdbc template.

Old codebase updated to run at Java 1.4

Location:
trunk/fmgVen
Files:
3 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/fmgVen/etc/test-db/test-db-changelog.xml

    r24 r26  
    44    </changeSet> 
    55    <changeSet author="fmguler" id="0"> 
    6         <tagDatabase tag="0"/> 
     6        <tagDatabase tag="tag-init"/> 
    77    </changeSet> 
    88    <!-- TEST SCHEMA >> --> 
    99    <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"/> 
    1313            </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"/> 
    2417        </createTable> 
    2518    </changeSet> 
    2619    <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"/> 
    3621    </changeSet> 
    3722    <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> 
    4831    </changeSet> 
    4932    <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"/> 
    6134    </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 --> 
    47836</databaseChangeLog> 
  • trunk/fmgVen/nbproject/build-impl.xml

    r19 r26  
    8080    </target> 
    8181    <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=&lt;path_to_property_file&gt; jar (where you put the property "platforms.${platform.active}.home" in a .properties file) 
     117  or ant -Dplatforms.${platform.active}.home=&lt;path_to_JDK_home&gt; jar (where no properties file is used)  
     118  </fail> 
    82119        <available file="${manifest.file}" property="manifest.available"/> 
    83120        <available file="${application.splash}" property="splashscreen.available"/> 
     
    199236            <length length="0" string="${endorsed.classpath}" when="greater"/> 
    200237        </condition> 
    201         <property name="javac.fork" value="false"/> 
    202238        <property name="jar.index" value="false"/> 
    203239        <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/> 
     
    245281                <mkdir dir="${empty.dir}"/> 
    246282                <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}"> 
    248284                    <src> 
    249285                        <dirset dir="@{gensrcdir}" erroronmissingdir="false"> 
     
    284320                <property location="${build.dir}/empty" name="empty.dir"/> 
    285321                <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}"> 
    287323                    <src> 
    288324                        <dirset dir="@{gensrcdir}" erroronmissingdir="false"> 
     
    335371            <attribute default="**" name="testincludes"/> 
    336372            <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}"> 
    338374                    <batchtest todir="${build.test.results.dir}"> 
    339375                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}"> 
     
    366402                        <path path="@{classpath}"/> 
    367403                    </classpath> 
     404                    <bootclasspath> 
     405                        <path path="${platform.bootcp}"/> 
     406                    </bootclasspath> 
    368407                </nbjpdastart> 
    369408            </sequential> 
     
    381420    </target> 
    382421    <target name="-init-debug-args"> 
    383         <property name="version-output" value="java version &quot;${ant.java.version}"/> 
     422        <exec executable="${platform.java}" outputproperty="version-output"> 
     423            <arg value="-version"/> 
     424        </exec> 
    384425        <condition property="have-jdk-older-than-1.4"> 
    385426            <or> 
     
    406447            <element name="customize" optional="true"/> 
    407448            <sequential> 
    408                 <java classname="@{classname}" dir="${work.dir}" fork="true"> 
     449                <java classname="@{classname}" dir="${work.dir}" fork="true" jvm="${platform.java}"> 
    409450                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> 
    410451                    <jvmarg line="${debug-args-line}"/> 
     
    431472            <element name="customize" optional="true"/> 
    432473            <sequential> 
    433                 <java classname="@{classname}" dir="${work.dir}" fork="true"> 
     474                <java classname="@{classname}" dir="${work.dir}" fork="true" jvm="${platform.java}"> 
    434475                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> 
    435476                    <jvmarg value="-Dfile.encoding=${runtime.encoding}"/> 
     
    613654            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/> 
    614655        </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> 
    616657    </target> 
    617658    <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"> 
     
    627668        <echo>To run this application from the command line without Ant, try:</echo> 
    628669        <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> 
    630671    </target> 
    631672    <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"> 
     
    637678        <echo>To run this application from the command line without Ant, try:</echo> 
    638679        <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> 
    640681    </target> 
    641682    <target name="-post-jar"> 
     
    715756    <target depends="init" if="have.sources" name="-javadoc-build"> 
    716757        <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}"> 
    718759            <classpath> 
    719760                <path path="${javac.classpath}"/> 
  • trunk/fmgVen/nbproject/genfiles.properties

    r23 r26  
    1 build.xml.data.CRC32=6b84a8b1 
     1build.xml.data.CRC32=31e5c25b 
    22build.xml.script.CRC32=a9b2e5a3 
    33build.xml.stylesheet.CRC32=28e38971@1.38.1.45 
    44# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 
    55# 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=6b84a8b1 
    7 nbproject/build-impl.xml.script.CRC32=494c2ca4 
     6nbproject/build-impl.xml.data.CRC32=31e5c25b 
     7nbproject/build-impl.xml.script.CRC32=68c11675 
    88nbproject/build-impl.xml.stylesheet.CRC32=78c6a6ee@1.38.1.45 
  • trunk/fmgVen/nbproject/project.properties

    r24 r26  
    3030    ${libs.Ven.classpath} 
    3131# Space-separated list of extra javac options 
    32 javac.compilerargs=-Xlint:deprecation 
     32javac.compilerargs= 
    3333javac.deprecation=false 
    3434javac.processorpath=\ 
     
    5353javadoc.windowtitle= 
    5454meta.inf.dir=${src.dir}/META-INF 
    55 platform.active=default_platform 
     55platform.active=JDK_1.4 
    5656run.classpath=\ 
    5757    ${javac.classpath}:\ 
  • trunk/fmgVen/nbproject/project.xml

    r23 r26  
    66            <name>fmgVen</name> 
    77            <minimum-ant-version>1.6.5</minimum-ant-version> 
     8            <explicit-platform explicit-source-supported="true"/> 
    89            <source-roots> 
    910                <root id="src.dir"/> 
  • trunk/fmgVen/src/com/fmguler/ven/QueryGenerator.java

    r23 r26  
    1818package com.fmguler.ven; 
    1919 
     20import com.fmguler.ven.util.Convert; 
     21import java.beans.PropertyDescriptor; 
     22import java.util.Date; 
    2023import java.util.HashSet; 
    2124import java.util.Set; 
     25import org.springframework.beans.BeanWrapper; 
     26import org.springframework.beans.BeanWrapperImpl; 
    2227 
    2328/** 
     
    2732public class QueryGenerator { 
    2833    private Set domainPackages; 
     34    private Set dbClasses; 
    2935 
    3036    public QueryGenerator() { 
    3137        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); 
    3245    } 
    3346 
     
    4053    } 
    4154 
    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(); 
    4489    } 
    4590 
    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 
    47128    public void addDomainPackage(String domainPackage) { 
    48129        domainPackages.add(domainPackage); 
  • trunk/fmgVen/src/com/fmguler/ven/Ven.java

    r25 r26  
    1818package com.fmguler.ven; 
    1919 
     20import java.util.HashMap; 
    2021import java.util.List; 
    2122import javax.sql.DataSource; 
     23import org.springframework.beans.BeanWrapper; 
     24import org.springframework.beans.BeanWrapperImpl; 
     25import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource; 
    2226import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; 
     27import org.springframework.jdbc.core.namedparam.SqlParameterSource; 
    2328 
    2429/** 
     
    4449    } 
    4550 
    46     public Object get(int no, Class objectClass) { 
     51    public Object get(int id, Class objectClass) { 
    4752        return null; 
    4853    } 
    4954 
     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     */ 
    5064    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); 
    5178    } 
    5279 
    53     public void delete(int no, Class objectClass) { 
     80    public void delete(int id, Class objectClass) { 
    5481    } 
    5582 
    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 
    57103    public void setDataSource(DataSource dataSource) { 
    58104        if (dataSource == null) throw new RuntimeException("fmgVen - DataSource cannot be null"); 
  • trunk/fmgVen/src/net/fmg/ven/Olcut.java

    r22 r26  
    77 * Ven - Ayar Yerine Gelenek veritabanı erişim nesnesi 
    88 */ 
    9  
    109package net.fmg.ven; 
    1110 
     
    2524    private Map parametreler; 
    2625    private Set baglaclar; 
    27      
     26 
    2827    /**  
    2928     * Yeni ölçüt 
     
    3231        this.metin = ""; 
    3332        this.parametreler = new HashMap(); 
    34         this.baglaclar =  new HashSet(); 
     33        this.baglaclar = new HashSet(); 
    3534        //{"and", "or", "=", "<>", "<", ">"} 
    3635    } 
    37      
     36 
    3837    /** 
    3938     * YAPILMADI 
    4039     */ 
    41     public Olcut ekle(Olcut olcut){         
     40    public Olcut ekle(Olcut olcut) { 
    4241        return null; 
    4342    } 
    44      
     43 
    4544    /** 
    4645     * YAPILMADI 
    4746     */ 
    48     public Olcut ekle(List olcutler){         
     47    public Olcut ekle(List olcutler) { 
    4948        return null; 
    5049    } 
    51      
     50 
    5251    /** 
    5352     * YAPILMADI 
    5453     */ 
    55     public Olcut ve(){ 
     54    public Olcut ve() { 
    5655        return null; 
    5756    } 
    58      
     57 
    5958    /** 
    6059     * koşul ekle 
    6160     */ 
    62     public Olcut ekle(String kosul){ 
    63         this.metin +=" "+kosul; 
     61    public Olcut ekle(String kosul) { 
     62        this.metin += " " + kosul; 
    6463        return this; 
    6564    } 
    66      
     65 
    6766    /** 
    6867     * koşullarda kullanılan parametreleri ekle 
    6968     */ 
    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); 
    7271        return this; 
    7372    } 
    74      
     73 
    7574    /** 
    7675     * koşullarda kullanılan parametreleri tümden ekle 
    7776     */ 
    78     public Olcut ekle(Map parametreler){ 
     77    public Olcut ekle(Map parametreler) { 
    7978        this.parametreler.putAll(parametreler); 
    8079        return this; 
    8180    } 
    82      
    83     public String olcutleriAl(){ 
     81 
     82    public String olcutleriAl() { 
    8483        //((1=1) and ((1=1) and (musteri_numuneler_numune_sahibi.rapor_tarihi is null) and (musteri.no = 4))) 
    8584        //Musteri.numuneler.deneyler.deneyTip.ad like :p1 
    8685        String sonuc = ""; 
    87         metin = metin.replace("(","( "); 
    88         metin = metin.replace(")"," )"); 
     86        metin = metin.replaceAll("\\(", "\\( "); 
     87        metin = metin.replaceAll("\\)", " \\)"); 
    8988        String[] parcalar = metin.split(" "); 
    9089        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('.'); 
    9392                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]; 
    9998            } 
    10099        } 
    101100        return sonuc; 
    102101    } 
    103      
    104     public Map parametreler(){ 
     102 
     103    public Map parametreler() { 
    105104        return this.parametreler; 
    106105    } 
    107106 
    108107    public String toString() { 
    109         return olcutleriAl()+" "+this.parametreler; 
     108        return olcutleriAl() + " " + this.parametreler; 
    110109    } 
    111      
    112110} 
  • trunk/fmgVen/src/net/fmg/ven/SorguEslestirici.java

    r23 r26  
    5757        long t1 = System.currentTimeMillis(); 
    5858        final List sonuclar = new LinkedList(); 
    59         final String tabloAdi = Cevir.vt(nesneSinifi.getSimpleName()); 
     59        final String tabloAdi = Cevir.vt(Cevir.isim(nesneSinifi.getName())); 
    6060        final Set sutunlar = new HashSet(); 
    6161         
  • trunk/fmgVen/src/net/fmg/ven/SorguUretici.java

    r22 r26  
    5959            if (alanSinifi.getPackage()!=null && nesnePaketleri.contains(alanSinifi.getPackage().getName()) && baglarKapsar(baglar,nesneYolu+"."+alanAdi)){ //domain nesnesi 1-1 join 
    6060                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ğ tablosu 
     61                String bagTablosu = Cevir.vt(Cevir.isim(alanSinifi.getName()));//gerçek bağ tablosu 
    6262                fromCumlesi.append(" left join "+bagTablosu+" "+bagTablosuDigerAd); 
    6363                fromCumlesi.append(" on "+bagTablosuDigerAd+".no = "+tabloAdi+"."+sutunAdi+"_no"); 
     
    6767                Class cokluAlandakiNesneSinifi = (Class)wr.getPropertyValue(alanAdi+".nesneSinifi"); 
    6868                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ğ tablosu 
     69                String bagTablosu = Cevir.vt(Cevir.isim(cokluAlandakiNesneSinifi.getName()));//gerçek bağ tablosu 
    7070                String bagAlani = Cevir.vt((String)wr.getPropertyValue(alanAdi+".bagAlani")); //YAP: bunu vermeden de varsayılan birşey yapsın 
    7171                fromCumlesi.append(" left join "+bagTablosu+" "+bagTablosuDigerAd); 
     
    9393    public String secmeSorgusuUret(Set baglar, Class nesneSinifi){ 
    9494        //long t1 = System.currentTimeMillis(); 
    95         String nesneAdi = nesneSinifi.getSimpleName(); 
     95        String nesneAdi = Cevir.isim(nesneSinifi.getName()); 
    9696        String tabloAdi = Cevir.vt(nesneAdi); 
    9797        StringBuffer selectCumlesi = new StringBuffer("select "); 
     
    108108    public String saymaSorgusuUret(Set baglar, Class nesneSinifi){ 
    109109        //long t1 = System.currentTimeMillis(); 
    110         String nesneAdi = nesneSinifi.getSimpleName(); 
     110        String nesneAdi = Cevir.isim(nesneSinifi.getName()); 
    111111        String tabloAdi = Cevir.vt(nesneAdi); 
    112112        StringBuffer selectCumlesi = new StringBuffer(); 
     
    123123    public String guncellemeSorgusuUret(Object nesne){ 
    124124        BeanWrapper wr = new BeanWrapperImpl(nesne); 
    125         String nesneAdi = nesne.getClass().getSimpleName(); 
     125        String nesneAdi = Cevir.isim(nesne.getClass().getName()); 
    126126        String tabloAdi = Cevir.vt(nesneAdi); 
    127127        StringBuffer sorgu; 
  • trunk/fmgVen/src/net/fmg/ven/Ven.java

    r22 r26  
    4848        Set baglar = new HashSet(); 
    4949        kullanimlar.put(kullanimNo,baglar); 
    50         baglar.add(nesneSinifi.getSimpleName()); 
     50        baglar.add(Cevir.isim(nesneSinifi.getName())); 
    5151         
    5252        String sorgu = uretici.secmeSorgusuUret(baglar, nesneSinifi); 
     
    111111    public Object nesneAl(Class nesneSinifi, Integer no, Set baglar){ 
    112112        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); 
    114114        sorgu += " where 1=1"+olcut.olcutleriAl(); 
    115115        if(hataAyiklama) System.out.println("SQL: "+sorgu); 
     
    127127    public Object nesneAl(Class nesneSinifi, Integer no, Set baglar, Olcut olcut){ 
    128128        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çin 
     129        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 
    130130        olcut.ekle("___no",no); 
    131131        if(hataAyiklama) System.out.println("SQL: "+sorgu); 
     
    145145        BeanWrapper wr = new BeanWrapperImpl(nesne); 
    146146        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()))); 
    148148        } 
    149149    } 
    150150     
    151151    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 ;"; 
    153153        Map parametreler = new HashMap(2); 
    154154        parametreler.put("no",no); 
  • trunk/fmgVen/src/net/fmg/ven/arac/Cevir.java

    r22 r26  
    3535        return sonuc.toString(); 
    3636    } 
     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    } 
    3743     
    3844} 
  • trunk/fmgVen/test/com/fmguler/ven/sample/Sample.java

    r25 r26  
    4040    public static void main(String[] args) { 
    4141        buildDatabase(); 
    42         testGet(); 
    43         //rollbackDatabase(); 
     42        testSave(); 
     43        rollbackDatabase(); 
    4444    } 
    4545 
     
    139139            Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(getDataSource().getConnection()); 
    140140            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", ""); 
    143142            Locale.setDefault(currLocale); 
    144143        } catch (SQLException ex) { 
  • trunk/fmgVen/test/com/fmguler/ven/sample/domain/SomeDomainObject.java

    r23 r26  
    2525 */ 
    2626public class SomeDomainObject { 
    27     private int no; 
     27    private Integer id; 
    2828    private String name; 
    2929    private String description; 
     
    3131 
    3232    /** 
    33      * @return the no 
     33     * @return the id 
    3434     */ 
    35     public int getNo() { 
    36         return no; 
     35    public Integer getId() { 
     36        return id; 
    3737    } 
    3838 
    3939    /** 
    40      * @param no the no to set 
     40     * @param id the id to set 
    4141     */ 
    42     public void setNo(int no) { 
    43         this.no = no; 
     42    public void setId(Integer id) { 
     43        this.id = id; 
    4444    } 
    4545 
     
    8787 
    8888    public String toString() { 
    89         return no + " " + name + " " + description + " " + date; 
     89        return id + " " + name + " " + description + " " + date; 
    9090    } 
    9191} 
Note: See TracChangeset for help on using the changeset viewer.