Statistics
| Branch: | Revision:

m2u-upass-admin / test / Test.java @ 41:48535d43fbf7

History | View | Annotate | Download (2.54 KB)

1 0:ea666cc7880e hadi
import java.util.Date;
2
3
import com.ib.ibss.hibernate.tables.DAOFactory;
4
5
import net.penril.ibss.core.AdminUserProfileDAO;
6
import net.penril.ibss.core.hibernate.AdminPermission;
7
import net.penril.ibss.core.hibernate.AdminPermissionId;
8
import net.penril.ibss.core.hibernate.AdminSecurity;
9
import net.penril.ibss.core.hibernate.AdminUserProfile;
10
import net.penril.ibss.core.hibernate.IbUser;
11
12
/**
13
 * Copyright (c) 2010 Penril Datability (M) Sdn Bhd All rights reserved.
14
 *
15
 * This software is copyrighted. Under the copyright laws, this software
16
 * may not be copied, in whole or in part, without prior written consent
17
 * of Penril Datability (SEA) Sdn Bhd or its assignees. This software is
18
 * provided under the terms of a license between Penril Datability (SEA)
19
 * Sdn Bhd and the recipient, and its use is subject to the terms of that
20
 * license.
21
 */
22
23
/**
24
 * <pre>
25
 * PROGRAMMER: Khairul Anwar
26
 * CHANGE-NO:
27
 * TASK-NO:
28
 * DATE CREATED: Oct 31, 2012
29
 * TAG AS:
30
 * REASON(S):
31
 * MODIFICATION:
32
 * </pre>
33
 */
34
35
/**
36
 * <Class description>
37
 */
38
public class Test {
39
40
        public static void main(String[] args) throws Exception
41
        {
42
                DAOFactory daofact = DAOFactory.instance(DAOFactory.HIBERNATE);
43
                AdminUserProfileDAO dao = daofact.getAdminUserProfileDAO();
44
                long seq = dao.getNextSequenceNumber ("SEQ_USER_ID");
45
                IbUser mainProfile = new IbUser();
46
47
                AdminUserProfile profile = new AdminUserProfile();
48
                mainProfile.setCreationDate (new Date());
49
                mainProfile.setPassword ("");
50
                mainProfile.setModifTime (new Date());
51
                mainProfile.setUserState (0);
52
                mainProfile.setUserAlias ("testacct2");
53
                mainProfile.setAccountId (seq);
54
55
                profile.setCreatedBy (0);
56
                profile.setUpdatedBy (0);
57
                profile.setUpdatedDate (new Date());
58
                profile.setForceReset (0);
59
                profile.setGroupId (1);
60
                profile.setRoleId (1);
61
                profile.setUserDob ("30021987");
62
                profile.setUserEmail ("mail@main.com");
63
                profile.setUserMobileNumber ("0128888888");
64
                profile.setUserName ("Tester number 1");
65
                profile.setUserGender ("M");
66
                profile.setUserRace ("");
67
                profile.setUserOfficeNumber ("0312345678");
68
                profile.setMainProfile (mainProfile);
69
70
                AdminSecurity security = new AdminSecurity();
71
                security.setMainProfile(mainProfile);
72
                profile.setAdminSecurity(security);
73
74
                AdminPermission permission = new AdminPermission();
75
                permission.setAdminUserProfile(profile);
76
                permission.setAdminAuthPermissionId(new AdminPermissionId(profile.getUserId(), 10L));
77
78
                profile.getAdminPermissions().add(permission);
79
80
                dao.createNewUser (profile);
81
        }
82
}