1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.hack23.cia.service.data.impl;
20
21 import java.util.Date;
22
23 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.stereotype.Service;
25 import org.springframework.transaction.annotation.Propagation;
26 import org.springframework.transaction.annotation.Transactional;
27
28 import com.hack23.cia.model.internal.application.system.impl.LanguageContentData;
29 import com.hack23.cia.model.internal.application.system.impl.LanguageContentType;
30 import com.hack23.cia.service.data.api.LanguageContentDataDAO;
31 import com.hack23.cia.service.data.api.LanguageContentService;
32
33
34
35
36 @Service
37 @Transactional(propagation=Propagation.REQUIRES_NEW)
38 final class LanguageContentServiceImpl implements LanguageContentService {
39
40
41
42 @Autowired
43 private LanguageContentDataDAO languageContentDataDAO;
44
45
46
47
48 public LanguageContentServiceImpl() {
49 super();
50 }
51
52 @Override
53 public String getLanguageResource(String key, String keyGroup,String language, String defaultEnglishValue) {
54 final LanguageContentData findTranslation = languageContentDataDAO.findTranslation(key, language, language);
55
56 if (findTranslation != null) {
57 return findTranslation.getLanguageValue();
58 } else {
59 final LanguageContentData newDefaultValue = new LanguageContentData().withCreatedDate(new Date()).withFromLanguage("en").withToLanguage("en").withLanguageContentType(LanguageContentType.HUMAN_TRANSLATION).withLanguageValue(defaultEnglishValue).withRefKey(key);
60 languageContentDataDAO.persist(newDefaultValue);
61 return newDefaultValue.getLanguageValue();
62 }
63 }
64
65 }