Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    SQLDataSource auditing and autoCreateAuditTable

    SmartClient Version: v10.0p_2015-03-31/Enterprise Development Only (built 2015-03-31)

    I'm just trying the audit feature, and I see in the sample the attribute DataSource.autoCreateAuditTable

    but I don't see it in the docs. Is it supported or not?

    #2
    I'm having problems in using the audit feature.
    I'm using a manually created Audit DataSource.

    The problem is that after the insert in the audit table, to synch the cache it uses a fetch which is that of the audited datasource, which fails because it has pretty complex custom sql.

    But why that? I was expecting to see the fetch operation of the audit dataSource.

    In the logs, it seems that it finds the AUDIT_JPC_CONTRATTI datasource I created, but then it creates a new datasource ('Generating DataSource AUDIT_JPC_CONTRATTI from xml' which inherits from the audited dataSource:

    Code:
    2015-04-07 17:55:10,838 DEBUG AuditDSGenerator [builtinApplication.JPC_CONTRATTI_update] AUDIT_JPC_CONTRATTI is an audit DataSource, processing 
    2015-04-07 17:55:10,838 DEBUG BasicDataSource [builtinApplication.JPC_CONTRATTI_update] Looking up superDS of DataSource JPC_CONTRATTI: 'JPC_CONTRATTI_BASE' 
    2015-04-07 17:55:10,839 DEBUG PoolableDataSourceFactory [builtinApplication.JPC_CONTRATTI_update] Created DataSource 6969 of type 'JPC_CONTRATTI_BASE' and assigned it to thread http-bio-8444-exec-11 
    2015-04-07 17:55:10,839 DEBUG PoolableDataSourceFactory [builtinApplication.JPC_CONTRATTI_update] Created DataSource 6968 of type 'JPC_CONTRATTI' and assigned it to thread http-bio-8444-exec-11 
    2015-04-07 17:55:10,839 DEBUG AuditDSGenerator [builtinApplication.JPC_CONTRATTI_update] getAuditRevisionFieldName returns audit_revision 
    2015-04-07 17:55:10,839 DEBUG AuditDSGenerator [builtinApplication.JPC_CONTRATTI_update] getAuditTypeFieldName returns audit_operationType 
    2015-04-07 17:55:10,839 DEBUG AuditDSGenerator [builtinApplication.JPC_CONTRATTI_update] getAuditTimestampFieldName returns audit_changeTime 
    2015-04-07 17:55:10,839 DEBUG AuditDSGenerator [builtinApplication.JPC_CONTRATTI_update] getAuditUserFieldName returns audit_modifier 
    2015-04-07 17:55:10,839 DEBUG AuditDSGenerator [builtinApplication.JPC_CONTRATTI_update] Found 88 fields in the inherited datasource! 
    2015-04-07 17:55:10,839 DEBUG AuditDSGenerator [builtinApplication.JPC_CONTRATTI_update] getAuditRevisionFieldName returns audit_revision 
    2015-04-07 17:55:10,839 DEBUG AuditDSGenerator [builtinApplication.JPC_CONTRATTI_update] Setting primaryKey to false on field ID_REC 
    2015-04-07 17:55:10,839 DEBUG AuditDSGenerator [builtinApplication.JPC_CONTRATTI_update] Changing field ID_REC type from sequence to integer. 
    2015-04-07 17:55:10,839 WARN  AuditDSGenerator [builtinApplication.JPC_CONTRATTI_update] Field ID_REC has overriden attributes. Saving it to inheriting DataSource. 
    2015-04-07 17:55:10,840 DEBUG AuditDSGenerator [builtinApplication.JPC_CONTRATTI_update] Generating DataSource AUDIT_JPC_CONTRATTI from xml: 
    2015-04-07 17:55:10,840 DEBUG AuditDSGenerator [builtinApplication.JPC_CONTRATTI_update] <DataSource serverType="sql" ID="AUDIT_JPC_CONTRATTI" inheritsFrom="JPC_CONTRATTI" xmlFromConfig="true">
    <fields>
    <field name="audit_revision"    type="sequence" primaryKey="true"/>
    <field name="audit_operationType"    type="enum">
    <valueMap>
    	<value>add</value>	<value>remove</value>	<value>update</value></valueMap>
    </field>
    <field name="audit_changeTime"    type="creatorTimestamp" hidden="false"/>
    <field name="audit_modifier"    type="creator" hidden="false"/>
    <field typeExplicitlyDeclared="true" sequenceName="SEQUENCE_ID_REC" sqlType="decimal" hidden="true" name="ID_REC" primaryKey="false" type="integer"  />
    </fields>
    </DataSource>
    So it seems that it's ignoring the audit dataSource that I've created.

    Comment


      #3
      We're clarifying the docs around autoCreateAuditTable.

      As far as your issue, it does seem to be ignoring your manually created audit DataSource, but you haven't shown the part of the configuration that would cause your DataSource to be used, so there's not much to analyze for possible errors..

      Comment


        #4
        SmartClient Version: v10.0p_2015-04-03/Enterprise Deployment (built 2015-04-03)

        Chrome on OSX

        In the audited dataSource I've added:

        Code:
        <DataSource xmlns:fmt="urn:jsptld:/WEB-INF/fmt.tld" xmlns="http://www.smartclient.com/schema"
                    ID="JPC_CONTRATTI"
                    tableName="JPC_CONTRATTI"
                    schema="DBSALES"
                    dbName="dbJpcEP"
                    serverType="sql"
                    dropExtraFields="false"
                    requiresAuthentication="false"
                    inheritsFrom="JPC_CONTRATTI_BASE"
                    audit="true"
                    auditDataSourceID="AUDIT_JPC_CONTRATTI"
                >
            <fields>
        ...
        The audit dataSource is:

        Code:
        <!-- Auto-generated from database table AUDIT_JPC_CONTRATTI -->
        
        <DataSource 
        	schema="DBSALES"
        	dbName="dbJpcEP"
        	tableName="AUDIT_JPC_CONTRATTI"
        	ID="AUDIT_JPC_CONTRATTI"
        	dataSourceVersion="1"
        	generatedBy="v10.0p_2015-04-07/Enterprise Deployment 2015-04-07"
        	serverType="sql"
        >
        	<fields>
        		<field sqlType="decimal" sqlLength="38" name="ID_REC" type="integer"></field>
        		<field sqlType="decimal" sqlLength="38" name="ID_STAGIONI_FK" type="integer"></field>
        		<field sqlType="decimal" sqlLength="38" name="CONTRATTO_NUM" type="integer"></field>
        		<field sqlType="decimal" sqlLength="38" name="ID_ANAGRAFICA_CLIENTI_FK" type="integer"></field>
        		<field sqlType="varchar" sqlLength="60" name="ACCOUNT" length="60" type="text"></field>
        		<field sqlType="decimal" sqlLength="0" name="VALORE_CONTRATTO" type="float"></field>
        		<field sqlType="decimal" sqlLength="0" name="SUM_SCONTO_RIGHE" type="float"></field>
        		<field sqlType="timestamp" sqlLength="7" name="DATE_MOD" type="datetime"></field>
        		<field sqlType="timestamp" sqlLength="7" name="DATE_CREATOR" type="datetime"></field>
        		<field sqlType="varchar" sqlLength="60" name="ACCOUNT_MOD" length="60" type="text"></field>
        		<field sqlType="varchar" sqlLength="60" name="CREATOR" length="60" type="text"></field>
        		<field sqlType="float" sqlLength="126" name="SCONTO_INCONDIZIONATO_VALORE" type="float"></field>
        		<field sqlType="timestamp" sqlLength="7" name="DATA_FIRMA" type="datetime"></field>
        		<field sqlType="varchar" sqlLength="4000" name="NOTE" length="4000" type="text"></field>
        		<field sqlType="decimal" sqlLength="0" name="VALORE_CONTRATTO_SCONTATO" type="float"></field>
        		<field sqlType="decimal" sqlLength="38" name="ID_STATO_CONTRATTO_FK" type="integer"></field>
        		<field sqlType="decimal" sqlLength="38" name="ID_CONTRATTO_SPLIT_FK" type="integer"></field>
        		<field sqlType="decimal" sqlLength="38" name="ID_CONTRATTO_PRECEDENTE_FK" type="integer"></field>
        		<field sqlType="decimal" sqlLength="38" name="ID_NOTE_INTERNE_FK" type="integer"></field>
        		<field sqlType="blob" sqlLength="4000" name="FILE_TEMP" type="binary"></field>
        		<field sqlType="timestamp" sqlLength="11" name="FILE_TEMP_DATE_CREATED" type="datetime"></field>
        		<field sqlType="decimal" sqlLength="0" name="FILE_TEMP_FILESIZE" type="float"></field>
        		<field sqlType="varchar" sqlLength="255" name="FILE_TEMP_FILENAME" length="255" type="text"></field>
        		<field sqlType="varchar" sqlLength="1" name="FL_REQUISITI_FIRMA" length="1" type="text"></field>
        		<field sqlType="varchar" sqlLength="1" name="FL_ACC_COND_GEN_CONTR" length="1" type="text"></field>
        		<field sqlType="varchar" sqlLength="1" name="FL_PRESA_VIS_CLAUS_VESS" length="1" type="text"></field>
        		<field sqlType="varchar" sqlLength="1" name="FL_CONS_TRATT_DATI_PERS" length="1" type="text"></field>
        		<field sqlType="varchar" sqlLength="1" name="FL_CONS_COM_DATI_TERZI" length="1" type="text"></field>
        		<field sqlType="varchar" sqlLength="1" name="FL_CONS_TRAT_DATI_PROFILO" length="1" type="text"></field>
        		<field sqlType="varchar" sqlLength="1" name="FL_CONS_TRAT_DATI_ALT_SOC" length="1" type="text"></field>
        		<field sqlType="varchar" sqlLength="1" name="FL_NOTIFICA_A_CLIENTE" length="1" type="text"></field>
        		<field sqlType="timestamp" sqlLength="7" name="DATA_SOTTOSC_CLIENTE" type="datetime"></field>
        		<field sqlType="varchar" sqlLength="1" name="IS_ANNULLATO" length="1" type="text"></field>
        		<field sqlType="varchar" sqlLength="1" name="ARCHIVIATO_PER_STATS" length="1" type="text"></field>
        		<field sqlType="varchar" sqlLength="1" name="UPGRADE_WIP" length="1" type="text"></field>
        		<field sqlType="varchar" sqlLength="4000" name="NOTE_CLIENTE" length="4000" type="text"></field>
        		<field sqlType="decimal" sqlLength="38" name="ID_REC_ORIG" type="integer"></field>
        		<field sqlType="varchar" sqlLength="3" name="TIPO" length="3" type="text"></field>
        		<field sqlType="varchar" sqlLength="1" name="FATT_DA_COMPENSARE" length="1" type="text"></field>
        		<field sqlType="decimal" sqlLength="38" name="CONTRATTO_NUM_1213" type="integer"></field>
        		<field sqlType="decimal" sqlLength="38" name="ID_B2B" type="integer"></field>
        		<field sqlType="varchar" sqlLength="255" name="FL_B2B" length="255" type="text"></field>
        		<field sqlType="timestamp" sqlLength="7" name="FL_B2B_TS" type="datetime"></field>
        		<field sqlType="varchar" sqlLength="60" name="ACCOUNT_ASSEGNATO" length="60" type="text"></field>
        		<field sqlType="decimal" primaryKey="true" sqlLength="38" name="AUDIT_REVISION" type="sequence"></field>
        		<field sqlType="varchar" sqlLength="255" name="AUDIT_OPERATIONTYPE" length="255" type="text"></field>
        		<field sqlType="timestamp" sqlLength="7" name="AUDIT_CHANGETIME" type="datetime"></field>
        		<field sqlType="varchar" sqlLength="255" name="AUDIT_MODIFIER" length="255" type="text"></field>
        	</fields>
        	<operationBindings>
        	    <operationBinding operationType="fetch" operationId="defaultFetch">
        	        <selectClause>$defaultSelectClause</selectClause>
        	        <tableClause>$defaultTableClause</tableClause>
        	        <whereClause>$defaultWhereClause</whereClause>
        	        <orderClause>$defaultOrderClause</orderClause>
        	    </operationBinding>
        		<operationBinding operationType="add" cacheSyncOperation="defaultFetch">
        			<valuesClause>$defaultValuesClause</valuesClause>
        		</operationBinding>
        	</operationBindings>
        </DataSource>
        (the operationBindings are a test I've done before realizing that it was ignoring that dataSource)

        In my index.jsp I load the audit dataSource:
        Code:
        <jsp:include page="/shared/ds/audit/AUDIT_JPC_CONTRATTI.ds.xml"/>
        Note: AUDIT_JPC_CONTRATTI is loaded after the audited dataSource (JPC_CONTRATTI)

        Comment


          #5
          In the audit dataSource there aren't all the fields of the audited dataSource, could it be a problem?

          Comment


            #6
            We don't see anything immediately wrong with your declarations, at the same time, we have a whole suite of tests for manually specified audit DataSources, all passing.

            We'd need a minimal runnable test case to look further.

            Comment


              #7
              sorry for not updating this thread: it was a dummy error on my side, actually I put the audit dataSource in a different folder which wasn't in the server.properties (project.datasources property)

              Comment

              Working...
              X