View Javadoc
1   /*
2    * Copyright 2010 James Pether Sörling
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   *	$Id$
17   *  $HeadURL$
18  */
19  package com.hack23.cia.service.component.agent.impl.worldbank.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.worldbank.countries.impl.CountryElement;
29  import com.hack23.cia.model.external.worldbank.data.impl.WorldBankData;
30  import com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorElement;
31  import com.hack23.cia.service.data.api.CountryElementDAO;
32  import com.hack23.cia.service.data.api.DataDAO;
33  import com.hack23.cia.service.data.api.IndicatorElementDAO;
34  
35  /**
36   * The Class WorldbankUpdateServiceImpl.
37   */
38  @Component("WorldbankUpdateService")
39  @Transactional(propagation = Propagation.MANDATORY)
40  final class WorldbankUpdateServiceImpl implements WorldbankUpdateService {
41  
42  	/** The country element dao. */
43  	@Autowired
44  	private CountryElementDAO countryElementDAO;
45  
46  	/** The data dao. */
47  	@Autowired
48  	private DataDAO dataDAO;
49  
50  	/** The indicator element dao. */
51  	@Autowired
52  	private IndicatorElementDAO indicatorElementDAO;
53  
54  	/**
55  	 * Instantiates a new worldbank import service impl.
56  	 */
57  	public WorldbankUpdateServiceImpl() {
58  		super();
59  	}
60  
61  	@Override
62  	public void updateCountryElement(final CountryElement country) {
63  		if (country != null) {
64  			countryElementDAO.persist(country);
65  		}
66  	}
67  
68  	@Override
69  	public void updateData(final List<WorldBankData> data) {
70  		if (data != null && !data.isEmpty()) {
71  			dataDAO.persist(data);
72  		}
73  	}
74  
75  	@Override
76  	public void updateIndicatorElement(final IndicatorElement object) {
77  		if (object != null) {
78  			indicatorElementDAO.persist(object);
79  		}
80  	}
81  
82  }