You are on page 1of 18

Experiment-1

Aim: Develop a Hello World application using Google App Engine.

Theory:
App Engine (GAE) is a platform-as-a-service product that provides web app developersand
enterprises with access to Google's scalable hosting and tier 1 internet service.

GAE requires that applications be written in Java or Python, store data in Google Bigtable and
use the Google query language. Noncompliant applications require modification to use GAE.

GAE provides more infrastructure than other scalable hosting services, such as Amazon Elastic
Compute Cloud (EC2). GAE also eliminates some system administration and development
tasks to make writing scalable applications easier.

Google provides GAE free up to a certain amount of use for the following resources:

● processor (CPU)
● storage
● application programming interface (API) calls
● concurrent requests

Users exceeding the per-day or per-minute rates can pay for more of these resources.

Code:
1. Install Google Plugin for Eclipse
Read this guide – how to install Google Plugin for Eclipse. If you install the Google App
Engine Java SDK together with “Google Plugin for Eclipse“, then go to step 2, Otherwise,
fget the Google App Engine Java SDK and extract it.

2. Create New Web Application Project


In Eclipse toolbar, click on the Google icon, and select “New Web Application Project…”

Figure – New Web Application Project


Figure – Deselect the “Google Web ToolKit“, and link your GAE Java SDK via the
“configure SDK” link.
Click finished, Google Plugin for Eclipse will generate a sample project automatically.

3. Hello World
Review the generated project directory.
Nothing special, a standard Java web project structure.

HelloWorld/
src/
...Java source code...
META-INF/
...other configuration...
war/
...JSPs, images, data files...
WEB-INF/
...app configuration...
lib/
...JARs for libraries...
classes/
...compiled classes...
The extra is this file “appengine-web.xml“, Google App Engine need this to run and
deploy the application.

File : appengine-web.xml

<?xml version="1.0" encoding="utf-8"?>


<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application></application>
<version>1</version>

<!-- Configure java.util.logging -->


<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>

</appengine-web-app>

4. Run it local
Right click on the project and run as “Web Application“.

Eclipse console :

//...
INFO: The server is running at http://localhost:8888/
30 Mac 2012 11:13:01 PM com.google.appengine.tools.development.DevAppServerImpl start
INFO: The admin console is running at http://localhost:8888/_ah/admin

Access URL http://localhost:8888/, see output


and also the hello world servlet – http://localhost:8888/helloworld

5. Deploy to Google App Engine


Register an account on https://appengine.google.com/, and create an application ID for
your web application.

In this demonstration, I created an application ID, named “mkyong123”, and put it in


appengine-web.xml.

File : appengine-web.xml
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>mkyong123</application>
<version>1</version>

<!-- Configure java.util.logging -->


<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>

</appengine-web-app>

To deploy, see following steps:

Figure 1.1 – Click on GAE deploy button on the toolbar.

Figure 1.2 – Sign in with your Google account and click on the Deploy button.
Figure 1.3 – If everything is fine, the hello world web application will be deployed to this
URL – http://mkyong123.appspot.com/
Output:

Experiment-3
Aim:Creating an application in SalesForce.com using Apex Programming Language.

Theory:
Salesforce provides software and services aimed at creating relevant customer
experiences. Businesses can use Salesforce services to better connect with partners,
customers, and potential. Companies can track customer activity, market to customers,
and perform many other tasks using Salesforce CRM customers.

Code:
Sign up to the Salesforce using the following link:

https://developer.salesforce.com/signup

After signing up go to Setup and click on Developer Console.

Now, in Developer Console click on File -> New -> Apex Class and Name it as Demo1

Note: If your Apex Class is disabled then signup through the given link:
https://developer.salesforce.com/signup
1. Write the code to create an account.

Do not forget to save it.


Click on Debug -> Open Execute Anonymous Window and write the code and then
Execute it.

You can see the record has been successfully added.

Similarly, you can add number of records. To retrieve the records go to Query Editor
and type the query language and Execute it.

You can see the records added.


2. Write the code to update the account.

Follow the same steps: File -> New -> Apex Class and name it as Demo2.

Again click on Debug -> Open Execute Anonymous Window and write the code.
To view the records in Salesforce

3. Write the code to delete the records.

Follow the above steps: File -> New -> Apex Class and name it as Demo3.

Again click on Debug -> Open Execute Anonymous Window and write the code.
To view the records in Salesforce go to Setup and search for Accounts and click on it.
Output:

Experiment-2
Aim: The aim of this simplified example is to create a basic inventory tracking system using
Salesforce, allowing you to add and subtract quantities of products in a warehouse.
Theory:
In Salesforce, you can create custom objects to represent entities. In this case, you'd create a
custom object called "Product" and another called "Inventory." The Product object will store
details about each product, and the Inventory object will track the quantity of each product in the
warehouse.

Code:
Product Object:

● Fields: Name (Text), Product_Code (Text), Description (Text)


Inventory Object:

● Fields: Product (Lookup to Product object), Quantity_On_Hand (Number)


Here's an example of an Apex trigger that updates the Inventory object when a shipment
is received.

Here's an Apex trigger that updates the Inventory object when a shipment is received.

trigger ShipmentReceived on Shipment__c (after insert) {


List<Inventory__c> inventoryToUpdate = new List<Inventory__c>();

for(Shipment__c shipment : Trigger.new) {


for(Shipment_Line__c line : shipment.Shipment_Lines__r) {
// Find the corresponding Inventory record
Inventory__c inventory = [SELECT Id, Quantity_On_Hand__c FROM Inventory__c
WHERE Product__c = :line.Product__c LIMIT 1];

if(inventory != null) {
// Update the quantity on hand
inventory.Quantity_On_Hand__c += line.Quantity__c;
inventoryToUpdate.add(inventory);
}
}
}

if(!inventoryToUpdate.isEmpty()) {
update inventoryToUpdate;
}
}

Output:
We have the following data:

Product__c (Product ID): P1


Shipment__c (Shipment ID): S1
Shipment_Line__c (Shipment Line ID): SL1
Product__c (Lookup to Product): P1
Quantity__c (Quantity Shipped): 10

When a new shipment with the above details is created, the trigger will update the
corresponding Inventory record. If the initial quantity on hand for product P1 was 50, it would
now be updated to 60, reflecting the addition of the 10 units from the shipment.

You might also like