1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.hack23.cia.service.component.agent.impl.riksdagen.workers.data;
20
21 import java.util.List;
22
23 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.stereotype.Component;
25 import org.springframework.transaction.annotation.Propagation;
26 import org.springframework.transaction.annotation.Transactional;
27
28 import com.hack23.cia.model.external.riksdagen.documentcontent.impl.DocumentContentData;
29 import com.hack23.cia.model.external.riksdagen.documentcontent.impl.DocumentContentData_;
30 import com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement;
31 import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentStatusContainer;
32 import com.hack23.cia.model.external.riksdagen.person.impl.PersonData;
33 import com.hack23.cia.model.external.riksdagen.utskottsforslag.impl.CommitteeProposalComponentData;
34 import com.hack23.cia.model.external.riksdagen.utskottsforslag.impl.CommitteeProposalComponentData_;
35 import com.hack23.cia.model.external.riksdagen.votering.impl.VoteData;
36 import com.hack23.cia.service.data.api.CommitteeProposalComponentDataDAO;
37 import com.hack23.cia.service.data.api.DocumentContentDataDAO;
38 import com.hack23.cia.service.data.api.DocumentElementDAO;
39 import com.hack23.cia.service.data.api.DocumentStatusContainerDAO;
40 import com.hack23.cia.service.data.api.PersonDataDAO;
41 import com.hack23.cia.service.data.api.VoteDataDAO;
42
43
44
45
46 @Component("RiksdagenUpdateService")
47 @Transactional(propagation = Propagation.MANDATORY)
48 final class RiksdagenUpdateServiceImpl implements RiksdagenUpdateService {
49
50
51 @Autowired
52 private CommitteeProposalComponentDataDAO committeeProposalComponentDataDAO;
53
54
55 @Autowired
56 private DocumentContentDataDAO documentContentDataDAO;
57
58
59 @Autowired
60 private DocumentElementDAO documentElementDAO;
61
62
63 @Autowired
64 private DocumentStatusContainerDAO documentStatusContainerDAO;
65
66
67 @Autowired
68 private PersonDataDAO personDataDAO;
69
70
71 @Autowired
72 private VoteDataDAO voteDataDAO;
73
74
75
76
77 public RiksdagenUpdateServiceImpl() {
78 super();
79 }
80
81 @Override
82 public void update(final PersonData personData) {
83 if (personDataDAO.load(personData.getId()) != null) {
84
85 } else {
86 personDataDAO.persist(personData);
87 }
88 }
89
90 @Override
91 public void updateCommitteeProposalComponentData(final CommitteeProposalComponentData committeeProposal) {
92 if (committeeProposalComponentDataDAO.findFirstByProperty(CommitteeProposalComponentData_.document,
93 committeeProposal.getDocument()) != null) {
94
95 } else {
96 committeeProposalComponentDataDAO.persist(committeeProposal);
97 }
98 }
99
100 @Override
101 public void updateDocumentContentData(final DocumentContentData documentData) {
102 if (documentContentDataDAO.findFirstByProperty(DocumentContentData_.id, documentData.getId()) != null) {
103
104 } else {
105 documentContentDataDAO.persist(documentData);
106 }
107 }
108
109 @Override
110 public void updateDocumentData(final DocumentStatusContainer documentData) {
111 documentStatusContainerDAO.persist(documentData);
112 }
113
114 @Override
115 public void updateDocumentElement(final DocumentElement documentData) {
116 if (documentElementDAO.checkDocumentElement(documentData.getId())) {
117
118 } else {
119 documentElementDAO.persist(documentData);
120 }
121
122 }
123
124 @Override
125 public void updateVoteDataData(final List<VoteData> list) {
126 if (list != null && !list.isEmpty()) {
127 voteDataDAO.persist(list);
128 }
129 }
130
131 }