Skip to content

Commit

Permalink
사용자 모델 생성에 필요한 기본 사전 데이터 추가 로직 변경 related #14
Browse files Browse the repository at this point in the history
  • Loading branch information
9bow committed Sep 7, 2019
1 parent bc0398d commit eba79f7
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package kr.co.shineware.nlp.komoran.admin.config;

import kr.co.shineware.nlp.komoran.admin.repository.DicWordRepository;
import kr.co.shineware.nlp.komoran.admin.repository.GrammarInRepository;
import kr.co.shineware.nlp.komoran.admin.service.DicWordService;
import kr.co.shineware.nlp.komoran.admin.service.GrammarInService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -40,6 +42,12 @@ public class SetupDefaultData implements ApplicationRunner {
@Autowired
private DicWordService dicWordService;

@Autowired
private GrammarInRepository grammarInRepository;

@Autowired
private GrammarInService grammarInService;


private Path getDefaultFilePath(String type) {
String filePathStr;
Expand Down Expand Up @@ -71,14 +79,22 @@ private Path getDefaultFilePath(String type) {
return pathForDefaultFile;
}


@Override
public void run(ApplicationArguments args) throws Exception {
logger.debug("DicWord : " + dicWordRepository.count());
logger.debug("GrammarIn : " + grammarInRepository.count());

// Initialize DicWord
if (dicWordRepository.count() <= 0 && getDefaultFilePath("dicword") != null) {
logger.debug("Importing DicWord from file named "+ filenameDicWord);
dicWordService.importFromFile(getDefaultFilePath("dicword"));
}

// Initialize GrammarIn
if (grammarInRepository.count() <= 0 && getDefaultFilePath("grammarrin") != null) {
logger.debug("Importing GrammarIn from file named "+ filenameGrammarIn);
grammarInService.importFromFile(getDefaultFilePath("grammarin"));
}
}
}

0 comments on commit eba79f7

Please sign in to comment.