##### Coverage Report - jp.co.y_net.amm.service.DataInitializer

Classes in this File | Line Coverage | Branch Coverage | Complexity

DataInitializer

0% | 0/13

0% | 0/4

0.0;0

1

     package jp.co.y_net.amm.service;

2

3

     import jp.co.y_net.amm.common.CalcHash;

4

     import jp.co.y_net.amm.dao.OrgDao;

5

     import jp.co.y_net.amm.dao.Usr;

6

     import jp.co.y_net.amm.dao.UsrDao;

7

8

     import org.springframework.beans.factory.annotation.Autowired;

9

     import org.springframework.beans.factory.annotation.Qualifier;

10

     import org.springframework.stereotype.Component;

11

12

     @Component("dataInitializer")

13

0

     public class DataInitializer {

14

15

0

         public static boolean DONE = false;

16

17

         @Autowired(required = true)

18

         @Qualifier("usrDao")

19

         private UsrDao usrDao;

20

21

         @Autowired(required = true)

22

         @Qualifier("orgDao")

23

         private OrgDao orgDao;

24

         /**

25

          * アプリケーションに必要最低限のレコードを作成する

26

          */

27

         public void initializeData() {

28

29

0

             if(DONE) return;

30

0

             DONE = true;

31

32

             /* アプリケーションに運営管理者が1人もいなければレコードを作成する */

33

0

             Usr sysAdminCond = new Usr();

34

0

             sysAdminCond.setKind(Usr.KIND_運営管理者);

35

0

             if(usrDao.get(sysAdminCond).size() == 0) {

36

0

                 Usr usrRoot = new Usr();

37

0

                 usrRoot.setLoginid("root");

38

0

                 usrRoot.setKind(Usr.KIND_運営管理者);

39

0

                 String pwhash = CalcHash.passowrdHash("manager", usrRoot.getLoginid());

40

0

                 usrRoot.setPwhash(pwhash);

41

             }

42

43

44

45

46

47

0

         }

48

     }