This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!

james frain

Ranch Hand
+ Follow
since Apr 06, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by james frain



I have a Question class that contains a list of Answer objects. In my POJOs I represent this in my Question class as

and in my Answer class this relationship is declared as

I had expected that ORMlite would throw an exception if I tried to persist an Answer which referenced a Question that had not yet been persisted to the database. However, this does not appear to happen. I can persist Answer objects as I please without saving the referenced Question objects. I verified the Answers are being saved with no questions being saved by looking in my database using SQLliteBrowser. This breaks my data integrity as when I restart my program the db now contains Answers that reference non existing questions. Is there any way to enforce this? With my experience in Hibernate it will not allow you to save the Child object without first saving the referenced "Parent" object.
7 years ago


This is my server side class



the two fields have getters and setters. On my JSP side I have a var declared as


My Struts Action has a getter called getDefinitions which gets called and returns a list of DefinitionT objects.
In my JS I have the following code


Firstly I was trying to figure out how to get the number of objects in the list but g_definitions.size is "Undefined" If I try to access g_definitions[0].value it is also undefined. How do I handle this list properly?
We have an android app which allows a user to download data from a GAE back end and also send data changes/user input back to the GAE. All data from the server is also copied to the local DB on the android client. What we are trying to figure out is the best practice for tracking and sending changes the user makes when a connection to the GAE is not available. Our plan is to have the client make the updates to the local DB and if the server is unavailable to send these changes over to it then they are marked as Out of Date on the client. When the server connection becomes available again the changes will then be sent over asynchronously. Can anyone see any problems with this approach or know of a better way to do it?
8 years ago
Hey Kevin,
We got around the initial problem. It was to do with the method signatures on the server side. We had a @POST handler which we couldn't figure out why it was not being called but the problem was our method signature didn't take a "Representation" object !!
Anyways we have ditiched out REST solution for the time being and going with an RPC solution first. Very easy to implement in comparison but we defo indend to plug in a REST solution later on this year when we get some proof of concepts ironed out.
8 years ago
I have been trying to get my head around the IO session listed below. http://bradabrams.com/2011/05/google-io-session-overview-android-app-engine-a-developers-dream-combination/

Everything seems straight forward till I tried to create my own custom method in the auto generated CloudTasksService class. eg I want to add a method like

Problem is how do I get this method to be callable from the client? On the client side the Auto generated code, when you ask the Google plugin to create the RPC service, works fine for me but now I want to add a new method manually on the server side, which I have done, but how do I modify the TaskRequest class to allow my client to call this method? The problem I see is the TaskRequest is created by the factory. Do I have to implement all the plumbing code myself which the Google plugin does automatically for the other methods. I just don't want to have to be implementing code myself which can be done automatically.

EDIT .... Just found this thread but still can't get the client to call my new method on the server side. See http://code.google.com/eclipse/docs/appeng_android_tuning.html

Rgds
8 years ago
I posted on Stack Over flow too about this.
activity.setRequestedOrientation( 1 ) in your create method ( or indeed in a unit test )
does diddly squat, the orientation will always be 0, ie landscape, it seems the only way to get the orientation to change is to run it on a physical device.
8 years ago
I too have the same question. I don't see why any of the views in the xml file should disappear just because you change the screen orientation. If it is just a very simple answer then a one liner will do Views having IDs assigned to them just means that the values they contain will be restored when the screen redraws in the new orientation? it doesn not explain why the screen is blank if you change orientation
8 years ago
Thanks for reply.
The project is modularized and well sturctured. The reason there are so many unit tests is that every concievable permutation of input for every method is tested. Even if a method has a public contract that requires a non null value we still test it with a null value and verify the correct exceptions are thrown.
So with 20 classes with around 10 public methods each and most methods having an average of 10 - 15 tests that is where we get the number of tests that we have.
I would say that there is only maybe 1 - 2 of these tests that really need to be run each time but as in OP we don't want to remove any of the others.
I did come across a means by where the TestCaseRunner is extended and a filter mechanism added but this is a bit hackish for my liking
8 years ago
I want to split all my JUnits up between "must run" and "nice to run" tests.
The reason being that with over 3000 tests our build process is now taking way too long and sometimes it is a pain to even run them. Now getting very selective about what new code gets tested at all.
Solution would be, when ime allows run all tests ( Eg nightly with no developers around ) and when I want to smoke test the code base during the day I could run more corse grained tests.
So is it possible for JUnit to be setup in such a away as to run diff tests at different times?
If not is there any programatic way to achieve this?
Bottom line is we're in the real world and don't have time to be running Unit tests against setters and getters that will almost never change but I don't want a single method in our code base that goes untested, so rock, hard place comes to mind.

Thanks ... J
8 years ago
Still at design stage and trying to investigate most aspects of Android before I decide how to proceed.
Basically the app will provide data to the user by retrieving it from the local SQL Lite db. Any changes the user makes will be saved to the database. Here's the tricky part. I want the user to be able to share their updates with other users and also to be able to pull fresh data into their own app from other users. So this brings us into the domain of a client / server style architecture.
The server is already up and running on the Google App engine. This app hosts a database containing the "Master copy" of all the data. The data will be exposed to the Android clients via REST services which is already up and running and hence I have to integrate to this.

So when a user wants to get fresh updates from the server they will execute a "Synchronize" routine. Any updates they have made locally will be uploaded and any new/updates other users have made will be downloaded.
Here is where I need help. How best can I keep users local DB synchronized with the server? I would prefer if the user did not have to explicitally do a synchronization as this could hit the app responsiveness. ( Even if it is threaded off ) Could the server calls be wrapped up in a Content Provider type object?
Any one got any examples of this problem or got any best practices I should follow.
I could easily just have a client get its data directly from the server and upload any changes directly to the server but this would not be desirable as the app would not work without network. An absolute requirement is the app must work without n/w coverage. Obviously synchronization would not work without coverage.
Thanks
8 years ago
yes, I am hitting the restlet web service in both cases, with and without GAE support. With GAE support enabled the Representation entity is blank when I call getText on it in my Restlet POST method.
I have made sure I am using the GAE version of Restlet API
8 years ago
GWT
I have a REST webservice which works fine handling a JSON string I send it and sending back a response ( I don't thing that it being a rest service is significant but I thought I should mention it )
I can run my app in hosted mode in Eclipse or as a standalone and both work fine. However, when I add Google App Engine support and rerun my web app, the JSON data being sent from the client is blank when I run entity.getText on the Restlet side. Nothing changed in code, just checked the GAE support properties box.
I'm guessing it's some JSON library I am using that does not work with GAE but I cannot tell for sure. Any one got any idea what else I could check for?

Thanks ..
8 years ago
GWT
I have a GWT app which works fine and presents a GUI i developed with GWT on a static html page. url = /app/LoginPage.html
Now, I want to have some REST services available, I have edited the web.ml as follows

Very basic login REST service which I want to call from the JavaScript running on LoginPage.html

However, nothing is happening at the backend, my Resource never gets created, indeed MainRestletRouter
never gets instantiated.
Any idea what I might be doing wrong. I have seen this in a few plces on the net but no one has ever given a full explanation as to how they fixed it if they did.

I run my app inside eclipse, in development mode on the Jetty server supplied with GWT plugin
8 years ago
About to implement a solution which allows a user to login/register from a JSP page OR from an Android client. We will be using REST exclusively.
What I plan on doing is as follows.
User Registers, causing a user token (name/pwd) to be POSTED to my REST service. This will be persisted and an Auth token created for this user and the username,pwd and Auth token will all be persisted.
The Auth token is then returned to the user and sent back with any further REST calls.
The token will expire after say 2 weeks.
On further logins a user/pwd will be sent to the REST service and checked against the persisted version.
Is this a good way to go about authentication ? Is there any frameworks that handle this sort of functionality as it is common to almost all client server apps?
Thanks ..
8 years ago
This is last chance saloon for me, spent days trying to get to the bottom of this
here is the problem. If I include anything other than a "" blank string ( eg entity = new StringRequestEntity("abc", "text/plain", "UTF-8"); )in the entity then the request fails with the error message "Unsupported Media Type"
I have tried multiple different content types but can never seem to get past this
With just a blank string the POST gets to the resource handler.
Looking at the documentation it is the server that is throwing this error back because it does not have any resource that can handle plain text, so how do I set up my resource to do this?

My resource

8 years ago