Package com.Bfcmain

Source Code of com.Bfcmain.BFCCompanyServlet

package com.Bfcmain;

import java.io.IOException;

import Controllers.UserMgt.Reg.*;

import javax.servlet.ServletException;
import javax.servlet.http.*;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.FetchOptions;
import com.google.appengine.api.datastore.PreparedQuery;
import com.google.appengine.api.datastore.Query;
import com.google.appengine.api.datastore.Query.*;
import com.google.appengine.api.datastore.Transaction;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Query.SortDirection;
import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

@SuppressWarnings("serial")
public class BFCCompanyServlet extends HttpServlet {
 
 
 
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException, ServletException {
    resp.setContentType("text/html");
    String firstname = req.getParameter("firstname");
    String lastname = req.getParameter("lastname");
    String mobilenumber = req.getParameter("mobilenumber");
    String email = req.getParameter("email");
    String gender = req.getParameter("gender");
    String city = req.getParameter("city");
    String state = req.getParameter("state");
   
   
    //UserRegestationServelet reg = new UserRegestationServelet();
    //reg.dopost(req, resp);
   
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
   
     
     
     
      Transaction txn = datastore.beginTransaction();
     
      Entity function1= new Entity("memberDetail");
     
      function1.setProperty("mem_id", "Create Member");
     
      function1.setProperty("FirstName", firstname);
     
      function1.setProperty("LastName", lastname);
     
      function1.setProperty("MobileNumber", mobilenumber);
     
      function1.setProperty("EmailAdd", email);
     
      function1.setProperty("EmailAdd", gender);
     
      function1.setProperty("EmailAdd", city);
     
      function1.setProperty("EmailAdd", state);
     
     
     
    /*  Entity function2= new Entity("Function");
     
      function2.setProperty("FunctionName", "Read Member");
     
      function2.setProperty("ModuleName", "User Management");
     
      function2.setProperty("Url", "ReadMember");
     
     
      Entity function3= new Entity("Function");
     
      function3.setProperty("FunctionName", "Update Member");
     
      function3.setProperty("ModuleName", "User Management");
     
      function3.setProperty("Url", "UpdateMember");
     
     
      Entity function4 = new Entity("Function");
     
      function4.setProperty("FunctionName", "Delete Member");
     
      function4.setProperty("ModuleName", "User Management");
     
      function4.setProperty("Url", "DeleteMember");
     
     
      Entity function5= new Entity("Function");
     
      function5.setProperty("FunctionName", "Create Role");
     
      function5.setProperty("ModuleName", "User Management");
     
      function5.setProperty("Url", "CreateRole");
     
     
      Entity function6= new Entity("Function");
     
      function6.setProperty("FunctionName", "Add Item");
     
      function6.setProperty("ModuleName", "Inventory Management");
     
      function6.setProperty("Url", "AddItem");*/
     
     
      //datastore.put(function5);
      txn.commit();
    /*Transaction txn2 = datastore.beginTransaction();datastore.put(function4);txn2.commit();
    Transaction txn3 = datastore.beginTransaction();datastore.put(function3);txn3.commit();
      Transaction txn4 = datastore.beginTransaction();datastore.put(function2);txn4.commit();*/
      Transaction txn5 = datastore.beginTransaction();datastore.put(function1);txn5.commit();
      //Transaction txn6 = datastore.beginTransaction();datastore.put(function6);txn6.commit();
     
      //txn.commit();
     
     
     
      /*datastore.put(function3);
      datastore.put(function4);
      datastore.put(function5);---*/
     
      /*Query gaeQuery = new Query("RoleFunction");
     
      PreparedQuery pq = datastore.prepare(gaeQuery);
     
      List<Entity> functionList = pq.asList(FetchOptions.Builder.withDefaults());
      */
     
    /*Transaction txn = datastore.beginTransaction();
     
      Entity user1=new Entity("SysUser");
     
      user1.setProperty("FirstName", "Akila");
      user1.setProperty("Active",false );
      user1.setProperty("LastName", "Kanishka");
     
      user1.setProperty("UserId", 001);
     
      user1.setProperty("Password", "xxxxxxx");
     
     
     
      user1.setProperty("Email", "gak@gmail.com");
     
      datastore.put(user1);
     
    txn.commit();  */
     
     
   
      UserService userService = UserServiceFactory.getUserService();
     
          User user = userService.getCurrentUser();

          if (user != null) {
            //HttpSession session=req.getSession();
            //session.setAttribute("username", user.getNickname());
              resp.setContentType("text/html");
              resp.getWriter().println("Hello,"+ user.getNickname() );
              //req.getRequestDispatcher("index.html").forward(req, resp);
             
          } else {
           
              resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
          }
       

     
     
    }
 

   
 

  }
TOP

Related Classes of com.Bfcmain.BFCCompanyServlet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.