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.riksdagen.workgenerator;
20  
21  import java.util.List;
22  import java.util.Map;
23  
24  import javax.jms.Destination;
25  import javax.jms.JMSException;
26  
27  import org.slf4j.Logger;
28  import org.slf4j.LoggerFactory;
29  import org.springframework.beans.factory.annotation.Autowired;
30  import org.springframework.beans.factory.annotation.Qualifier;
31  import org.springframework.stereotype.Service;
32  
33  import com.hack23.cia.model.internal.application.data.impl.RiksdagenDataSources;
34  
35  /**
36   * The Class RiksdagenDocumentContentWorkGeneratorImpl.
37   */
38  @Service("RiksdagenDocumentContentWorkGeneratorImpl")
39  final class RiksdagenDocumentContentWorkGeneratorImpl extends AbstractRiksdagenDataSourcesWorkGenerator {
40  
41  	/** The Constant LOGGER. */
42  	private static final Logger LOGGER = LoggerFactory.getLogger(RiksdagenDocumentContentWorkGeneratorImpl.class);
43  
44  	/** The document content workdestination. */
45  	@Autowired
46  	@Qualifier("com.hack23.cia.model.external.riksdagen.documentcontent.impl.DocumentContentData")
47  	private Destination documentContentWorkdestination;
48  
49  
50  	/**
51  	 * Instantiates a new riksdagen document content work generator impl.
52  	 */
53  	public RiksdagenDocumentContentWorkGeneratorImpl() {
54  		super(RiksdagenDataSources.DOCUMENT_CONTENT);
55  	}
56  
57  	@Override
58  	public void generateWorkOrders() {
59  		try {
60  			final Map<String, String> documentStatusContainerMap = getImportService()
61  					.getDocumentContentMap();
62  
63  			final List<String> avaibleDocumentStatus = getImportService()
64  					.getAvaibleDocumentContent();
65  
66  			for (final String id : avaibleDocumentStatus) {
67  				if (!documentStatusContainerMap.containsKey(id)) {
68  					getJmsSender().send(documentContentWorkdestination,
69  							id);
70  				}
71  			}
72  
73  		} catch (final JMSException e) {
74  			LOGGER.warn("error loading document content", e);
75  		}
76  	}
77  
78  }