I have a custom operation that is called when a user closes a Window. It is meant to clean up after a user by marking several items in the database that belong to them for deletion with a soft-delete flag.
The way the call works, is that when a user closes a window, a custom operation on a datasource is called and in the DSRequest is passed an IP Address.
Once the request makes it to the server, all records for a certain table are looked up via a fetch:
Once the List of records matching the IP Address criteria are fetched, they are looped over and new maps are created with the proper values set, so that a setValues(newVals) call can be made on the DSRequest.
Once all the maps are created and values set, the call to setValues is made and the a call to the execute method is made on the DataSource
note: the allowMultiUpdate property is set in the ds.xml for this data source, and reading the documentation it seemed like that was the flag to set for allowing multiple updates.
The problem is that when this request is executed, only one record is updated, and the following is seen in the logs, notice: WARN DSRequest - getValues() called on dsRequest containing multiple sets of values, returning first in list.....
12:51:13,367 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,367 [80-4] INFO IDACall - Performing 1 operation(s)
12:51:13,369 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,369 [80-4] DEBUG ServerObject - Couldn't find a public method named: fetch on class: com.sncorp.gs2.ui.server.dmi.VideoStreamDestinationDMI
12:51:13,370 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,370 [80-4] DEBUG DataSourceDMI - DataSourceDMI: no public method name: fetch available on class: com.sncorp.gs2.ui.server.dmi.VideoStreamDestinationDMI - defaulting to builtin operations.
12:51:13,371 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,371 [80-4] DEBUG AppBase - [builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application
12:51:13,371 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,371 [80-4] DEBUG AppBase - [builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation
12:51:13,372 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,372 [80-4] DEBUG JPADataSource - [builtinApplication.null] Creating EntityManager and starting transaction.
12:51:13,378 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,378 [80-4] DEBUG JPADataSource - [builtinApplication.null] Executing fetch.
12:51:13,378 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,378 [80-4] DEBUG JPADataSource - [builtinApplication.null] Query string: select _VideoStreamDestination from VideoStreamDestination _VideoStreamDestination where (lower(_VideoStreamDestination.ipAddress) = lower(:p0))
12:51:13,380 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,380 [80-4] DEBUG JPADataSource - [builtinApplication.null] Parameter p0: 127.0.0.1
12:51:13,391 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,391 [80-4] INFO DSResponse - [builtinApplication.null] DSResponse: List with 3 items
12:51:13,391 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,391 [80-4] DEBUG JPADataSource - [builtinApplication.null] Committing current transaction.
12:51:13,397 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,397 [80-4] DEBUG JPADataSource - [builtinApplication.null] Releasing entity manager.
12:51:13,398 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,398 [80-4] DEBUG JPADataSource - Releasing entity manager.
12:51:13,399 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,399 [80-4] DEBUG JPADataSource - Auto-joining transactions.
12:51:13,399 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,399 [80-4] DEBUG JPADataSource - Creating EntityManager, starting transaction and setting it to RPCManager.
12:51:13,405 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,405 [80-4] DEBUG DSRequest - Clobbering existing FreeResourcesHandler of type 'com.sncorp.gs2.ui.server.datasource.RTMDataSource' with a 'com.sncorp.gs2.ui.server.datasource.RTMDataSource'
12:51:13,406 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,406 [80-4] DEBUG JPADataSource - Executing update.
12:51:13,406 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,406 [80-4] WARN DSRequest - getValues() called on dsRequest containing multiple sets of values, returning first in list.
12:51:13,416 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,416 [80-4] WARN DSRequest - getValues() called on dsRequest containing multiple sets of values, returning first in list.
12:51:13,419 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,419 [80-4] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
12:51:13,419 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,419 [80-4] DEBUG JPADataSource - Committing transaction for 1 queued operation(s).
12:51:13,424 INFO [stdout] (pool-12-thread-1) === 2012-06-09 12:51:13,424 [ad-1] DEBUG ISCMessageDispatcher - sending message to channel: DATASOURCE_CHANNEL
12:51:13,425 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,425 [80-4] DEBUG RPCManager - DMI response, dropExtraFields: false
12:51:13,427 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,427 [80-4] DEBUG JPADataSource - Releasing entity manager.
What can I do to have all of the updates take place?
The way the call works, is that when a user closes a window, a custom operation on a datasource is called and in the DSRequest is passed an IP Address.
Code:
<operationBinding operationType="custom" allowMultiUpdate="true" operationId="deleteUserDestinationsByIPAddress" serverMethod="deleteUserDestinationsByIPAddress"/>
Code:
DataSource vsd = DataSourceManager.get("videoStreamDestination"); List<VideoStreamDestination> records = vsd.fetch("ipAddress",dsRequest.getFieldValue("ipAddress").toString());
Code:
ArrayList<Map<String,Object>> updatedDestinations = new ArrayList<Map<String, Object>>(); //iterate the entity list and make maps out of the objects for(VideoStreamDestination destination : records) { destination.setDeletedFlag(true); Map<String, Object> destinationMap = new HashMap<String, Object>(); destinationMap.put("id",destination.getId()); destinationMap.put("ipAddress",destination.getIpAddress()); destinationMap.put("portNumber",destination.getPortNumber()); destinationMap.put("creator",destination.getCreatorName()); destinationMap.put("deletedFlag",true); updatedDestinations.add(destinationMap); }
Code:
dsRequest.setValues(updatedDestinations); dsRequest.setOperationType(DSOperationType.UPDATE.toString().toLowerCase()); //dsRequest.setAllowMultiUpdate(true); vsd.execute(dsRequest);
The problem is that when this request is executed, only one record is updated, and the following is seen in the logs, notice: WARN DSRequest - getValues() called on dsRequest containing multiple sets of values, returning first in list.....
12:51:13,367 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,367 [80-4] INFO IDACall - Performing 1 operation(s)
12:51:13,369 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,369 [80-4] DEBUG ServerObject - Couldn't find a public method named: fetch on class: com.sncorp.gs2.ui.server.dmi.VideoStreamDestinationDMI
12:51:13,370 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,370 [80-4] DEBUG DataSourceDMI - DataSourceDMI: no public method name: fetch available on class: com.sncorp.gs2.ui.server.dmi.VideoStreamDestinationDMI - defaulting to builtin operations.
12:51:13,371 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,371 [80-4] DEBUG AppBase - [builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application
12:51:13,371 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,371 [80-4] DEBUG AppBase - [builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation
12:51:13,372 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,372 [80-4] DEBUG JPADataSource - [builtinApplication.null] Creating EntityManager and starting transaction.
12:51:13,378 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,378 [80-4] DEBUG JPADataSource - [builtinApplication.null] Executing fetch.
12:51:13,378 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,378 [80-4] DEBUG JPADataSource - [builtinApplication.null] Query string: select _VideoStreamDestination from VideoStreamDestination _VideoStreamDestination where (lower(_VideoStreamDestination.ipAddress) = lower(:p0))
12:51:13,380 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,380 [80-4] DEBUG JPADataSource - [builtinApplication.null] Parameter p0: 127.0.0.1
12:51:13,391 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,391 [80-4] INFO DSResponse - [builtinApplication.null] DSResponse: List with 3 items
12:51:13,391 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,391 [80-4] DEBUG JPADataSource - [builtinApplication.null] Committing current transaction.
12:51:13,397 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,397 [80-4] DEBUG JPADataSource - [builtinApplication.null] Releasing entity manager.
12:51:13,398 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,398 [80-4] DEBUG JPADataSource - Releasing entity manager.
12:51:13,399 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,399 [80-4] DEBUG JPADataSource - Auto-joining transactions.
12:51:13,399 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,399 [80-4] DEBUG JPADataSource - Creating EntityManager, starting transaction and setting it to RPCManager.
12:51:13,405 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,405 [80-4] DEBUG DSRequest - Clobbering existing FreeResourcesHandler of type 'com.sncorp.gs2.ui.server.datasource.RTMDataSource' with a 'com.sncorp.gs2.ui.server.datasource.RTMDataSource'
12:51:13,406 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,406 [80-4] DEBUG JPADataSource - Executing update.
12:51:13,406 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,406 [80-4] WARN DSRequest - getValues() called on dsRequest containing multiple sets of values, returning first in list.
12:51:13,416 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,416 [80-4] WARN DSRequest - getValues() called on dsRequest containing multiple sets of values, returning first in list.
12:51:13,419 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,419 [80-4] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
12:51:13,419 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,419 [80-4] DEBUG JPADataSource - Committing transaction for 1 queued operation(s).
12:51:13,424 INFO [stdout] (pool-12-thread-1) === 2012-06-09 12:51:13,424 [ad-1] DEBUG ISCMessageDispatcher - sending message to channel: DATASOURCE_CHANNEL
12:51:13,425 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,425 [80-4] DEBUG RPCManager - DMI response, dropExtraFields: false
12:51:13,427 INFO [stdout] (http-0.0.0.0-0.0.0.0-8080-4) === 2012-06-09 12:51:13,427 [80-4] DEBUG JPADataSource - Releasing entity manager.
What can I do to have all of the updates take place?
Comment