Announcement

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

  • Blama
    replied
    Hi Isomorphic,

    this thread is about <values> and <criteria> DSRequestModifier in .ds.xml operationBinding only being applied to client initiated requests.

    While this is OK the way it is, it would be great if the docs somehow mentioned it. I couldn't find this in any docs recently in order to explain observed behavior.
    I think it's only in this thread.
    I would be great if the docs above or criteria and values get an update saying something like:
    • Normal clientside requests get the additional criteria from <criteria>.
    • New serverside DSRequests picking up the RPCManager from the clientside request get the additional criteria from <criteria>.
    • New serverside DSRequests without a RPCManager don't get the additional criteria.
    • Use <whereClause>field = 'N' AND ($defaultWhereClause)</whereClause> if you want restrictions to be always applied.
    Perhaps this should also be linked from serverside BaseRequest.isClientRequest().

    Best regards
    Blama

    Leave a comment:


  • Blama
    replied
    Great, I just saw them.

    Thank you
    Blama

    Leave a comment:


  • Isomorphic
    replied
    We've added some samples of Criteria declaration in ds.xml to DSRequestModifier javadocs.

    Leave a comment:


  • Blama
    replied
    Hi Isomorphic,

    please note the .ds.xml-AdvancedCriteria docs and .ds.xml-Criterion seem to be text-copies of their respective com.smartgwt.client.data-classes.

    How to include a Criteria in .ds.xml is only shown in the QuickStartGuide (chapter "Server-Assigned Criteria/Values"). For AdvancedCriteria/Criterion this is shown nowhere. It would be good to have information in the ds.xml docs, most likely instead of the current docs.

    Best regards
    Blama

    Leave a comment:


  • Blama
    replied
    Hi all,

    this .ds.xml is obviously wrong as it misses the <operationBinding>-tag. I just retested with:
    Code:
    <DataSource ID="animals" serverType="sql" tableName="animals" testFileName="animals.data.xml">
        <fields>
            <field name="commonName" title="Animal" type="text" />
            <field name="scientificName" title="Scientific Name" type="text" primaryKey="true" required="true" />
            <field name="lifeSpan" title="Life Span" type="integer" />
            <field name="status" title="Endangered Status" type="text">
                <valueMap>
                    <value>Threatened</value>
                    <value>Endangered</value>
                    <value>Not Endangered</value>
                    <value>Not currently listed</value>
                    <value>May become threatened</value>
                    <value>Protected</value>
                </valueMap>
            </field>
            <field name="diet" title="Diet" type="text" />
            <field name="information" title="Interesting Facts" type="text" length="1000" />
            <field name="picture" title="Picture" type="image" detail="true" imageURLPrefix="/isomorphic/system/reference/inlineExamples/tiles/images/" />
        </fields>
    
        <operationBindings>
            [B]<operationBinding operationType="fetch">[/B]
                <criteria _constructor="AdvancedCriteria" operator="and">
                    <criterion fieldName="lifeSpan" operator="greaterThan" value="10" />
                    <criterion fieldName="scientificName" operator="iContains" value="ana" />
                </criteria>
            [B]</operationBinding>[/B]
        </operationBindings>
    </DataSource>
    which is working as expected.

    Best regards
    Blama

    Leave a comment:


  • Blama
    replied
    Hi Isomorphic,

    could you please revisit this:

    Originally posted by Isomorphic View Post
    We've done some testing and this feature is working for us.

    We've been testing against the shipped "animals" data source.

    For simple criteria you can use this approach (for example):
    Code:
        <operationBindings>
            <operationBinding operationType="fetch">
                <criteria fieldName="lifeSpan" value="20"/>
                <criteria fieldName="scientificName" value="Ateles panicus"/>
            </operationBinding>
        </operationBindings>
    This works for me like for you.


    Originally posted by Isomorphic View Post
    For AdvancedCriteria, you can set the "_constructor" attribute, like this:
    Code:
    <operationBindings>
            <operationBinding operationType="fetch"  >
    
                <criteria _constructor="AdvancedCriteria" operator="and">
                    <criterion fieldName="lifeSpan" operator="greaterThan" value="10" />
                    <criterion fieldName="scientificName" operator="iContains" value="ana" />
                </criteria>
    
            </operationBinding>
        </operationBindings>
    which behaves as expected, generating output like this:
    === 2014-08-29 19:51:28,316 [l0-0] INFO SQLDataSource - [builtinApplication.animals_fetch] Performing fetch operation with
    criteria: {criteria:[{value:"10",fieldName:"lifeSpan",operator:"greaterThan"},{value:"ana",fieldName:"scientificName",operator:"iContains"}],operator:"and",_constructor:"AdvancedCriteria"} values: {criteria:[{value:"10",fieldName:"lifeSpan",operator:"greaterThan"},{value:"ana",fieldName:"scientificName",operator:"iContains"}],operator:"and",_constructor:"AdvancedCriteria"}
    === 2014-08-29 19:51:28,331 [l0-0] INFO SQLDataSource - [builtinApplication.animals_fetch] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause
    === 2014-08-29 19:51:28,341 [l0-0] DEBUG SQLDataSource - [builtinApplication.animals_fetch] Executing row count query: SELECT COUNT(*) FROM $defaultTableClause WHERE $defaultWhereClause
    === 2014-08-29 19:51:28,342 [l0-0] DEBUG SQLDataSource - [builtinApplication.animals_fetch] Eval'd row count query: SELECT COUNT(*) FROM animals WHERE ((animals.lifeSpan > 10 AND animals.lifeSpan IS NOT NULL) AND (animals.scientificName LIKE '%ana%' AND animals.scientificName IS NOT NULL))
    This does not work for me. Using v10.0p_2015-05-19/PowerEdition Deployment (built 2015-05-19) I get this log (see bold lines for SQLs):
    Code:
    === 2015-05-19 17:14:27,280 [9-47] INFO  RequestContext - URL: '/builtinds/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0': Moz (Gecko) with Accept-Encoding header
    === 2015-05-19 17:14:27,280 [9-47] DEBUG IDACall - Header Name:Value pair: Cookie:isc_cState=ready; JSESSIONID=s4rqhlhyotnt1ttl3vtqoh5e1; GLog=%7B%0D%20%20%20%20trackRPC%3Atrue%2C%20%0D%20%20%20%20pageGUID%3A%2221815023-43EB-4995-8A08-E47132200934%22%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20sgwtInternal%3A1%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A3%2C%20%0D%20%20%20%20left%3A0%2C%20%0D%20%20%20%20top%3A0%2C%20%0D%20%20%20%20width%3A525%2C%20%0D%20%20%20%20height%3A966%0D%7D
    === 2015-05-19 17:14:27,281 [9-47] DEBUG IDACall - Header Name:Value pair: DNT:1
    === 2015-05-19 17:14:27,281 [9-47] DEBUG IDACall - Header Name:Value pair: Host:127.0.0.1:8888
    === 2015-05-19 17:14:27,281 [9-47] DEBUG IDACall - Header Name:Value pair: Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    === 2015-05-19 17:14:27,281 [9-47] DEBUG IDACall - Header Name:Value pair: Content-Length:1044
    === 2015-05-19 17:14:27,281 [9-47] DEBUG IDACall - Header Name:Value pair: Content-Type:application/x-www-form-urlencoded; charset=UTF-8
    === 2015-05-19 17:14:27,281 [9-47] DEBUG IDACall - Header Name:Value pair: Accept-Language:de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
    === 2015-05-19 17:14:27,281 [9-47] DEBUG IDACall - Header Name:Value pair: Pragma:no-cache
    === 2015-05-19 17:14:27,281 [9-47] DEBUG IDACall - Header Name:Value pair: Connection:keep-alive
    === 2015-05-19 17:14:27,281 [9-47] DEBUG IDACall - Header Name:Value pair: Referer:http://127.0.0.1:8888/BuiltInDS.html?gwt.codesvr=127.0.0.1:9997
    === 2015-05-19 17:14:27,281 [9-47] DEBUG IDACall - Header Name:Value pair: User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0
    === 2015-05-19 17:14:27,282 [9-47] DEBUG IDACall - Header Name:Value pair: Cache-Control:no-cache
    === 2015-05-19 17:14:27,282 [9-47] DEBUG IDACall - Header Name:Value pair: Accept-Encoding:gzip, deflate
    === 2015-05-19 17:14:27,282 [9-47] DEBUG IDACall - session exists: s4rqhlhyotnt1ttl3vtqoh5e1
    === 2015-05-19 17:14:27,282 [9-47] DEBUG IDACall - remote user: null
    === 2015-05-19 17:14:27,295 [9-47] DEBUG XML - Parsed XML from (in memory stream): 8ms
    === 2015-05-19 17:14:27,296 [9-47] DEBUG ISCKeyedObjectPool - Borrowing object for 'transaction'
    === 2015-05-19 17:14:27,296 [9-47] DEBUG PoolableDataSourceFactory - Created DataSource null of type 'transaction' in the pooling flow
    === 2015-05-19 17:14:27,297 [9-47] DEBUG ISCKeyedObjectPool - Borrowing object for 'Object'
    === 2015-05-19 17:14:27,297 [9-47] DEBUG PoolableDataSourceFactory - Created DataSource 48 of type 'Object' and assigned it to thread qtp1473125779-47
    === 2015-05-19 17:14:27,298 [9-47] DEBUG PoolableDataSourceFactory - Created DataSource 48 of type 'Object' in the pooling flow
    === 2015-05-19 17:14:27,298 [9-47] DEBUG PoolableDataSourceFactory - Activated DataSource 48 of type 'Object'
    === 2015-05-19 17:14:27,299 [9-47] DEBUG ISCKeyedObjectPool - Borrowing object for 'List'
    === 2015-05-19 17:14:27,300 [9-47] DEBUG PoolableDataSourceFactory - Created DataSource 49 of type 'List' and assigned it to thread qtp1473125779-47
    === 2015-05-19 17:14:27,300 [9-47] DEBUG PoolableDataSourceFactory - Created DataSource 49 of type 'List' in the pooling flow
    === 2015-05-19 17:14:27,300 [9-47] DEBUG PoolableDataSourceFactory - Activated DataSource 49 of type 'List'
    === 2015-05-19 17:14:27,301 [9-47] DEBUG ISCKeyedObjectPool - Borrowing object for 'elem'
    === 2015-05-19 17:14:27,302 [9-47] DEBUG PoolableDataSourceFactory - Created DataSource null of type 'elem' in the pooling flow
    === 2015-05-19 17:14:27,304 [9-47] DEBUG RPCManager - Processing 1 requests.
    === 2015-05-19 17:14:27,304 [9-47] DEBUG ISCKeyedObjectPool - Borrowing object for 'animals'
    === 2015-05-19 17:14:27,304 [9-47] DEBUG PoolableDataSourceFactory - Activated DataSource 32 of type 'animals'
    === 2015-05-19 17:14:27,305 [9-47] DEBUG DSRequest - Caching instance 32 of DS 'animals' from DSRequest.getDataSource()
    === 2015-05-19 17:14:27,305 [9-47] DEBUG DSRequest - Caching instance 32 of DS animals
    === 2015-05-19 17:14:27,306 [9-47] DEBUG RPCManager - Request #1 (DSRequest) payload: {
        criteria:{
        },
        operationConfig:{
            dataSource:"animals",
            repo:null,
            operationType:"fetch",
            textMatchStyle:"exact"
        },
        startRow:0,
        endRow:75,
        componentId:"isc_ListGrid_1",
        appID:"builtinApplication",
        operation:"animals_fetch",
        oldValues:{
        }
    }
    === 2015-05-19 17:14:27,307 [9-47] INFO  IDACall - Performing 1 operation(s)
    === 2015-05-19 17:14:27,307 [9-47] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
    === 2015-05-19 17:14:27,307 [9-47] DEBUG DeclarativeSecurity - DataSource animals is not in the pre-checked list, processing...
    === 2015-05-19 17:14:27,307 [9-47] DEBUG AppBase - [builtinApplication.animals_fetch] No userTypes defined, allowing anyone access to all operations for this application
    === 2015-05-19 17:14:27,308 [9-47] DEBUG AppBase - [builtinApplication.animals_fetch] No public zero-argument method named '_animals_fetch' found, performing generic datasource operation
    === 2015-05-19 17:14:27,309 [9-47] INFO  SQLDataSource - [builtinApplication.animals_fetch] Performing fetch operation with
    	criteria: {}	values: {}
    === 2015-05-19 17:14:27,309 [9-47] INFO  SQLWhereClause - [builtinApplication.animals_fetch] empty condition
    === 2015-05-19 17:14:27,310 [9-47] INFO  SQLDataSource - [builtinApplication.animals_fetch] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause
    === 2015-05-19 17:14:27,311 [9-47] DEBUG SQLDataSource - [builtinApplication.animals_fetch] Executing row count query: SELECT COUNT(*) FROM $defaultTableClause WHERE $defaultWhereClause
    [B]=== 2015-05-19 17:14:27,312 [9-47] DEBUG SQLDataSource - [builtinApplication.animals_fetch] Eval'd row count query: SELECT COUNT(*) FROM animals WHERE ('1'='1')[/B]
    === 2015-05-19 17:14:27,312 [9-47] DEBUG PoolableSQLConnectionFactory - [builtinApplication.animals_fetch] DriverManager fetching connection for HSQLDB via jdbc url jdbc:hsqldb:hsql://localhost/isomorphic
    === 2015-05-19 17:14:27,312 [9-47] DEBUG PoolableSQLConnectionFactory - [builtinApplication.animals_fetch] Passing JDBC URL only to getConnection
    === 2015-05-19 17:14:27,415 [9-47] DEBUG PoolableSQLConnectionFactory - [builtinApplication.animals_fetch] makeObject() created an unpooled Connection '788586398'
    === 2015-05-19 17:14:27,415 [9-47] DEBUG SQLConnectionManager - [builtinApplication.animals_fetch] Borrowed connection '788586398'
    === 2015-05-19 17:14:27,416 [9-47] DEBUG SQLDriver - [builtinApplication.animals_fetch] About to execute SQL query in 'HSQLDB' using connection '788586398'
    [B]=== 2015-05-19 17:14:27,416 [9-47] INFO  SQLDriver - [builtinApplication.animals_fetch] Executing SQL query on 'HSQLDB': SELECT COUNT(*) FROM animals WHERE ('1'='1')
    === 2015-05-19 17:14:27,420 [9-47] DEBUG SQLDataSource - [builtinApplication.animals_fetch] Using SQL Limit query
    === 2015-05-19 17:14:27,421 [9-47] DEBUG SQLDataSource - [builtinApplication.animals_fetch] SQL windowed select rows 0->75, result size 75. Query: SELECT LIMIT 0 75  animals.commonName, animals.scientificName, animals.lifeSpan, animals.status, animals.diet, animals.information, animals.picture FROM animals WHERE ('1'='1')
    === 2015-05-19 17:14:27,421 [9-47] DEBUG SQLDataSource - [builtinApplication.animals_fetch] SQL windowed select rows 0->75, result size 75. Query: SELECT LIMIT 0 75  animals.commonName, animals.scientificName, animals.lifeSpan, animals.status, animals.diet, animals.information, animals.picture FROM animals WHERE ('1'='1')[/B]
    === 2015-05-19 17:14:27,429 [9-47] INFO  DSResponse - [builtinApplication.animals_fetch] DSResponse: List with 29 items
    === 2015-05-19 17:14:27,429 [9-47] DEBUG DSRequest - About to free up resources for request of type fetch on DataSource animals
    === 2015-05-19 17:14:27,430 [9-47] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
    === 2015-05-19 17:14:27,430 [9-47] DEBUG RPCManager - non-DMI response, dropExtraFields: false
    === 2015-05-19 17:14:27,440 [9-47] DEBUG SQLDriver - Freeing SQLDriver dbConnection 788586398
    === 2015-05-19 17:14:27,441 [9-47] DEBUG SQLConnectionManager - About to close JDBCConnection with hashcode "788586398"
    === 2015-05-19 17:14:27,442 [9-47] DEBUG PoolableDataSourceFactory - Cleared and passivated DataSource 32 of type 'animals'
    === 2015-05-19 17:14:27,443 [9-47] INFO  Compression - /builtinds/sc/IDACall: 10585 -> 4153 bytes
    My only change to the sample is this animals.ds.xml:
    Code:
    <DataSource ID="animals" serverType="sql" tableName="animals" testFileName="animals.data.xml">
    	<fields>
    		<field name="commonName" title="Animal" type="text" />
    		<field name="scientificName" title="Scientific Name" type="text" primaryKey="true" required="true" />
    		<field name="lifeSpan" title="Life Span" type="integer" />
    		<field name="status" title="Endangered Status" type="text">
    			<valueMap>
    				<value>Threatened</value>
    				<value>Endangered</value>
    				<value>Not Endangered</value>
    				<value>Not currently listed</value>
    				<value>May become threatened</value>
    				<value>Protected</value>
    			</valueMap>
    		</field>
    		<field name="diet" title="Diet" type="text" />
    		<field name="information" title="Interesting Facts" type="text" length="1000" />
    		<field name="picture" title="Picture" type="image" detail="true" imageURLPrefix="/isomorphic/system/reference/inlineExamples/tiles/images/" />
    	</fields>
    
    	<operationBindings>
    		<criteria _constructor="AdvancedCriteria" operator="and">
    			<criterion fieldName="lifeSpan" operator="greaterThan" value="10" />
    			<criterion fieldName="scientificName" operator="iContains" value="ana" />
    		</criteria>
    	</operationBindings>
    </DataSource>
    I should definitely see what you are seeing, but I'm not.
    I'm using v10.0p_2015-05-19/PowerEdition, GWT 2.7.0 DevMode using built-in Jetty, Eclipse Luna SR2, FF26+GWT Plugin, Win8.1.
    I can change log settings in log4j.isc.config.xml if that would help.

    Best regards
    Blama

    Leave a comment:


  • Isomorphic
    replied
    The "flag" you are looking for is simply to call setRPCManager(). Blama can't do this because of a very unusual use case, but this applies for any normal use case.

    Leave a comment:


  • Isomorphic
    replied
    We were already using SmartGWT.

    Sorry, we can't go and repeat all this same work chasing an issue we've already confirmed as not reproducible. You are the one who has an environment where the issue occurs, so it's up to you to figure out how your environment differs from the standard environment, and not the other way around.

    Leave a comment:


  • Blama
    replied
    Hi Isomorphic,

    Regarding #5:
    Originally posted by Isomorphic View Post
    Regarding #5, see post #4 - this already shows minimal changes made to an Eval build to verify that the feature is working as expected.
    That's why I asked for the file. Of course I can copy&paste and I did that - but I did not get the result you got and we both expected.
    I started with a clean built-in-ds directory directly from the eval-zip and copy/pasted the contents (Win8.1, Eclipse Luna, FF 26 Dev Mode).

    Important: I posted a download link for SmartClient, but actually I used SmartGWT (builds/SmartGWT/4.1p/EnterpriseEval/2014-09-01).
    Could you retry with SmartGWT and post the .ds.xml as forum-attachment nevertheless? It seems useless but I don't know where the difference should come from, so I try to rule everything out. This is the only file changed, correct?

    Thank you & Best regards (& sorry for being stubborn),
    Blama

    Leave a comment:


  • claudiobosticco
    replied
    Originally posted by Blama View Post
    Problem: I also send mails from three other operationBinding with <mail>-tag. These operationBinding is server-only and hit by a servlet called on a regular basis. So the <criteria> are not applied (because it is a server DSRequest where I can't assign a RPCManager).
    Of course I could solve it with <whereClause> and that's what I will do now. But it would be nice (as low priority enhancement at some time in the future) to be able to do it with <criteria> as well.
    +1

    I understand why the default behaviour is that the criteria are not applied without a rpcManager, but it would be nice to have a flag to change that for a specific operationBinding

    Leave a comment:


  • Isomorphic
    replied
    Regarding #5, see post #4 - this already shows minimal changes made to an Eval build to verify that the feature is working as expected.

    Leave a comment:


  • Blama
    replied
    Hi Isomorphic,

    thanks for the fast answer.

    Perhaps I need to explain my use-case:
    I have view that offers many records with different status, OPEN, CLOSED, INPROCESS.
    I have different client side layouts, displaying these records, each one of a status.
    So far, I'm doing this with different <operationBinding>s with <whereClause>s. This works, but I think the <criteria>-way would be more declarative (see last post).
    So far, no problem here.
    Problem: I also send mails from three other operationBinding with <mail>-tag. These operationBindings are server-only and hit by a servlet called on a regular basis. So the <criteria> are not applied (because it is a server DSRequest where I can't assign a RPCManager).
    Of course I could solve it with <whereClause> and that's what I will do now. But it would be nice (as low priority enhancement at some time in the future) to be able to do it with <criteria> as well.


    Regarding #5:
    Could you start with a fresh BuiltInDS-sample from http://www.smartclient.com/builds/SmartClient/9.1p/Eval and attach all changed files (either attachment or as forum-CODE-tag)? It should be animals.ds.xml only, shouldn't it? I agree the difference has to be minor, so to rule everything else out, this might be worth a try. Normally I'd say that I'm able to copy&paste your <operationBindings>...</operationBindings>-tag into my file, but let's be 100% sure.

    Best regards,
    Blama
    Last edited by Blama; 2 Sep 2014, 00:00. Reason: typos removed

    Leave a comment:


  • Isomorphic
    replied
    The existing behavior of <criteria> is exactly what you want for business rules. What you're expecting is analogous to being able to configure Oracle so that you could never do a normal query against the table again, even if you were a DBA with appropriate credentials.

    We're not sure what more we can do on #5 - we already tested that scenario and showed you our logs of it behaving as expected. Most likely, the project where you are testing differs from the SDK in some subtle way.

    Leave a comment:


  • Blama
    replied
    Hi Isomorphic,

    OK, I did not know that. This is not clear at all from the docs under client/docs/serverds/*.
    I thought it could be used to express business rules as well (one operationBinding with some criteria, another operationBinding with different criteria).

    So for business rules I'll have to use the <whereClause>-tag, correct?
    If so it would be a nice enhancement to define per <criteria> whether it is used a security constraint or business rule, because this is better with respect to fieldNames and tableNames when it comes to joins. It is also more declarative than using SQL IMHO.

    Could you also look into the problem of the more AdvancedCriteria being ignored/not picked up (post #5 in this thread?)

    Thank you & Best regards,
    Blama

    Leave a comment:


  • Isomorphic
    replied
    That's expected behavior. DSRequests which don't come from the client (don't have an RPCManager) are not subject to security settings like <criteria> on an operationBinding.

    If this were not the case, you would be unable to bypass those <criteria> at all, no matter what you did, so you would have fundamentally limited the capability of your DataSource, which is obviously not desirable.

    Leave a comment:

Working...
X