package iDSS.beans;

import java.util.*;
import java.rmi.RemoteException;
import java.sql.*;

import iDSS.utils.*;



public class TestUser {

    public static void main(String[] args) {


        iDSS.beans.UserJBean userBean = new iDSS.beans.UserJBean();

        Timestamp t1 = new Timestamp(System.currentTimeMillis());
        Timestamp t2 = new Timestamp(System.currentTimeMillis()*10);

        long l1 = 100;
        long l2 = 200;

        boolean success;

        success = userBean.create("Sayeed","sayeed.ahmed@strath.ac.uk",t1,l1);

        if(success)
            System.out.println("User " + userBean.getName() + " created");
        else
            System.out.println("Failed to create user");

        success = userBean.create("Sayeed2","sayeed.ahmed2@strath.ac.uk",t2,l2);

        if(success)
            System.out.println("User " + userBean.getName() + " created");
        else
            System.out.println("Failed to create user");



/**

        success = userBean.findByPrimaryKey("sayeed.ahmed@strath.ac.uk");

        if(success) {

            userBean.setName("Sayeed Ahmed");
            userBean.setLastVisited(Timestamp.valueOf("1789-12-31 23:59:59"));
            long l = 100;
            userBean.setTotalTimeSpent(l);

            System.out.println("user name        : " + userBean.getName());
            System.out.println("Email            : " + userBean.getEmail());
            System.out.println("Last visited     : " + userBean.getLastVisited().toString());
            System.out.println("Total time spent : " + userBean.getTotalTimeSpent());

        } //

        else {

            System.out.println("User not found for sayeed.ahmed@strath.ac.uk");

        } //



        Vector users = userBean.findAll();

        System.out.println("findAll()");

        for(int i=0;i<users.size();i++) {

            UserJBean uBean = (UserJBean)users.elementAt(i);

            System.out.println("user name        : " + uBean.getName());
            System.out.println("Email            : " + uBean.getEmail());
            System.out.println("Last visited     : " + uBean.getLastVisited().toString());
            System.out.println("Total time spent : " + uBean.getTotalTimeSpent());

            uBean.remove();

        } //for(int i=0;i<stations.size();i++)
**/

    } //public static void main(String[] args)



} //public class TestUser
