Friday, January 11, 2013

Cloud Computing Presentations



1- Note to Share in Cloud

Developed by:
  • Sophat Nouv
  • Zhaoliang Meng


2- JiTT(Just in Time Translation) Chat

Developed by:
  • Hosain Fathelbab
  • Sundus Yousuf



3- Cost Management System

Developed by:
  • Zhe Shi
  • Yan Chen



4- Hotel Reservation System

Developed by:
  • AbdelRahman Elbakry
  • Mohhamad Qafaf


5- Dummy FourSquare

Developed by:
  • Ahmed Hagag
  • Izzeddin Alkouz


6- Smart Tast

Developed by:
  • Abd ElHamid
  • Blaine Lapiton



7- Mini CRM

Developed by:
  • Daniel Tadesse
  • Nand Raj Joshi


8- Course Registration and Assignment Management System

Developed by:
  • Hussein Al-Betar
  • Kamran Younus



9- Easy Task

Developed by:
  • Minh Nguyen
  • Surojit Das
http://sharplines14.appspot.com/



10- Go Together, Go Dutch

Developed by:
  • Homayoon Taheri
  • Huanjle Wang

Wednesday, January 9, 2013

Using Smart GWT

* What is Smart GWT?



          Smart GWT is a GWT-based framework that allows you to not only utilize its comprehensive widget library for your application UI, but also tie these widgets in with your server-side for data management. For a quick conceptual overview of Smart GWT.
         Smart GWT is based on the powerful and mature SmartClient library. In addition to Smart GWT LGPL, Pro & Enterprise editions of Smart GWT are available with additional features & tools, as well as commercial support.


* To integrate smartgwt framework, do the following:

1. Add smartgwt.jar and smartgwt-skins.jar to project's classpath.
2. Modify the .gwt.xml and inherit the smartgwt module.

    <inherits name="com.smartgwt.SmartGwt"/>

 3.   In the HTML, be sure to include this:
   <script>var isomorphicDir="smartgwtintroproject/sc/";</script>

* To view some UI components implemented in smartgwt, access the link below:
  http://www.smartclient.com/smartgwt/showcase/






Resources:

http://code.google.com/p/smartgwt/
http://code.google.com/p/smartgwt/
http://www.jroller.com/sjivan/entry/smartgwt_1_0_released

Tuesday, January 8, 2013

Local Unit Testing for DataStore

To do unit test for persistence layer (datastore), you need the following libraries in the classpath:


  • ${SDK_ROOT}/lib/impl/appengine-api.jar
  • ${SDK_ROOT}/lib/impl/appengine-api-labs.jar
  • ${SDK_ROOT}/lib/impl/appengine-api-stubs.jar
  • ${SDK_ROOT}/lib/testing/appengine-testing.jar
Once done, run the example below:

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import static com.google.appengine.api.datastore.FetchOptions.Builder.withLimit;
import com.google.appengine.api.datastore.Query;
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class LocalDatastoreTest {

    private final LocalServiceTestHelper helper =
        new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());

    @Before
    public void setUp() {
        helper.setUp();
    }

    @After
    public void tearDown() {
        helper.tearDown();
    }

    // run this test twice to prove we're not leaking any state across tests
    private void doTest() {
        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        assertEquals(0, ds.prepare(new Query("yam")).countEntities(withLimit(10)));
        ds.put(new Entity("yam"));
        ds.put(new Entity("yam"));
        assertEquals(2, ds.prepare(new Query("yam")).countEntities(withLimit(10)));
    }

    @Test
    public void testInsert1() {
        doTest();
    }

    @Test
    public void testInsert2() {
        doTest();
    }
}



For more details, you may read the source.

https://developers.google.com/appengine/docs/java/tools/localunittesting

Monday, January 7, 2013

make your code on the cloud

Not to have problems during merging your work with your team members, it is better to work with Source Control tool like SVN, and you can upload your code on the cloud so you will not be worry about losing the code and you can work from anywhere.

It is easy to install and easy to manage,

just follow this link to install SVN plugin with eclipse,
http://www.eclipse.org/subversive/index.php

and watch this video to know how to use google code to put your code on the cloud


Friday, January 4, 2013

common problem and solution on using datastore

problems and suitable solutions :

1- the import "com.google.appengine.api.datastore.key" cannot be resolved
this error is appeared during the runtime even Everything compiled just fine in the IDE.
Missing source files is a common stumbling block. What we've run into here is that the GWT compiler cannot find the source code for the com.google.appengine.Keyclass  
the first solution : is to create a Key class your self as described in this post
 http://fredsa.allen-sauer.com/2009/04/1st-look-at-app-engine-using-jdo.html.
the second solution: is to simply make the key field of "Long" type.

2- your data class (ChatMessage) is not default instantiable
Solution: make your data classes default instantiable(it must have a zero-argument constructor or no constructors at all), if your data class already has constructor with parameters so you just need to add another empty constructor.

3- ChatMessage has no custom serializer
so you can not serialize this object (send from client to server and vice versa)
solution: make your class implements Serializable  (java.io.Serializable)

4- List isn't serializable
more details about why it isn't serializable is in this post http://127.0.0.1:8888/MyFirstApp.html?gwt.codesvr=127.0.0.1:9997
Solution: so don't make the server's methods return List object, instead make it return ArrayList or vector or..
For this Problem where List isn't Serializable, you can find the answer on this link: http://stackoverflow.com/questions/4927227/why-doesnt-java-util-list-implement-serializable


last important notes: 

  • make sure that all fields in your data class is serializable.
  • some-times when you see a run-time error that doesn't make sense. Try cleaning your project and re-building it, if that doesn't solve it then try closing eclipse and open it back again, most of the time you will be good with this, but some-times you might even have to restart your computer. If all this attempts do not fix the problem then now for sure there is something wrong in your code. "ALL THIS IS ECLIPSE'S PROBLEM"
  • Sometimes an existing data might give you a problem when fetching from your datastore. To fix this remove your datastore(db) file. The Location is ../war/WEB-INF/appengine-generated/local_db.bin delete the local_db.bin file. 



Thanks to Sundus for providing his project, all these problems are solved in it,
you can download and import it from here
https://docs.google.com/open?id=0B1q8wbwjqNOwU2hGd2Vlc0tGVFE

Google App Engine and Java


Summary of GWT Reading

GWT let us write client program as Java program. Client is written in Java which is almost like a traditional GUI application such as having layout managers, attaching event handlers, and so on. In GWT, GUI code is translated into HTML and JavaScript. So, instead of compiling Java UI code to Java bytecodes, it compiles Java to JavaScript source code.

GWT application consists of a set of modules. A module is a GWT package consisting of Java code, JavaScript, HTML files, images, data definitions, and whatever else you need in a web application.

A typical GWT App has the following directory structure:
  • GWT libraries
  • a source directory named src
Ø       a module declaration (.gwt.xml)
Ø       a package for the client-side Java code
Ø       a package for the server-side Java code.
  • a target directory named war. war stands for “web archive”: the deployable package


GWT Module
 - a fundamental unit of code in GWT
- consists of a collection of things: Java code; resources like CSS, HTML, or image files; and GWT customizations, like Java to JavaScript compiler extensions.
- Modules can inherit things from other modules. (including css unlike in Java where it’s basically the code)
- GWT application starts with an entry point. An entry point is, pretty much, the GWT GUI equivalent of a main function. In the module file (.gwt.xml), you declare entry points. The Java class must extend the EntryPoint interface defined in GWT. The onLoadModule() is the entryPoint method. This is where you assemble the components in the UI.

Setting Up the UI
- In setting up, we need interface frame and the Entry Point class.
- The user interface frame is defined by an HTML file. The HTML file isn’t considered source code, so it should not be in the src directory. Instead, it should be placed in the war folder.
- In the html file, you may define the structure of the UI. For example, creating an empty box in the UI. The <td> tag creates a box in the HTML layout, but it’s empty—there’s nothing inside of the tag. In the Java code, we’ll insert something by referencing it using its id= tag.
- In onModuleLoad of the entry point class, we can create there the UI widgets like creating a button and a text box like what we do in AWT or SWING.
- The main panel of GWT is RootPanel.  Components can be arranged using layout managers for example VerticalPanel. 

RPC in GWT
- An RPC is something that looks almost like a normal method call, but under the covers, it’s translated by the system into a request sent from the client to the server. The return value of the RPC is the response
sent from the server back to the client.

Two ways to issue RPC:
1.       Java Native RPC Layer
-          problem with this approach: communication is slow.
2.       Google-style RPC
-          asynchronous or continuation passing style for remote calls. The call itself returns nothing. Instead, it takes an extra parameter, which is a function to invoke on the result of the RPC whenever it’s received.

Two parts of RPC in GWT
1.      Client-Side RPC in GWT
Ø    Synchronous interface for the service methods.
-  In the hello-world application, it’s called the greeting service. The greeting service interface is written in the client package because it is the client who is going to be the user of the interface.
                                    - can be annotated with information about how they’ll fit into the URL structure      
                                   of the application.
                                    - The service interface declaration must extend he GWT interface
                                   com.google.gwt.user.client.rpc.RemoteService.
                - Any parameters to a service method must extend either java.lang.Serializable or 
               the GWT specific variant com.google.gwt.user.client.rpc.IsSerializable.
Ø   Asynchronous interface counterpart of the synchronous interface
- It must have methods with exactly the same name as the methods in the synchronous interface; each method must have return type void; and each method adds a parameter at the end, which is an AsyncCallback and whose type parameter is the return type of the synchronous method.
- It’s really only used by the client—the actual plumbing to map between the asynchronous and synchronous interfaces is generated by GWT. The only purpose of the asynchronous interface is to provide the call interface that the client will use.
2.      Server-Side RPC in GWT
Ø Implement the asynchronous client interface using a class that extends RemoteServiceServlet.
Ø It is here where the data sent by the client will be processed.