Announcement

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

    Improvement: FieldType.CREATOR + IDACall extends + RPCManager.setUserId()

    Hi Isomorphic,

    I played around with extending the IDACall servlet as described in http://www.smartclient.com/smartgwte...l#requiresRole.

    I found that this might be missing/not optimal:

    My usecase:
    I log in using Tomcat Realm Security with a username. As 1st call in my LoginServlet I get the ID to the username and store it in the session (In the DB all entries belong (foreign key) to a user, identified by its id, not its username.

    Until now I boilerplate-copied this to every .ds.xml
    Code:
    	<operationBindings>
    		<operationBinding operationType="add">
    			<values fieldName="CREATED_BY" value="$session.authenticatedUserID" />
    			<values fieldName="CREATED_AT" value="$currentDate" />
    			<values fieldName="MODIFIED_BY" value="$session.authenticatedUserID" />
    			<values fieldName="MODIFIED_AT" value="$currentDate" />
    			<values fieldName="TENANT_ID" value="$session.authenticatedUserTenantID" />
    		</operationBinding>
    		<operationBinding operationType="update">
    			<values fieldName="MODIFIED_BY" value="$session.authenticatedUserID" />
    			<values fieldName="MODIFIED_AT" value="$currentDate" />
    			<values fieldName="TENANT_ID" value="$session.authenticatedUserTenantID" />
    		</operationBinding>
    	</operationBindings>
    But with extending LoginServlet and reading about CREATOR, CREATORTIMESTAMP, MODIFIER and MODIFIERTIMESTAMP in http://www.smartclient.com/smartgwte...FieldType.html today, I might be able to get rid of all the boilerplate code.

    I already started and saw then that it seems that CREATOR and MODIFIER are of type "TEXT" implicitly. Also com.isomorphic.rpc.RPCManager.setUserId(String) takes only a String and does not have an Integer overload. It might be a good idea to add this, as the generated SQL will be correct then with respect to data type of the DB column. For Oracle the value is converted automatically if the types do not match, but this might not be the case everywhere and might also lead to suboptimal execution plans when the DataSource fields are used in a criteria (e.g. WHERE id ='123' (with the '' )).

    Best regards,
    Blama
Working...
X