Project

General

Profile

« Previous | Next » 

Revision 47408

moved to dnet45

View differences:

modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/ISVocabularyLoader.java
3 3
import eu.dnetlib.domain.enabling.VocabularySearchCriteria;
4 4
import gr.uoa.di.driver.enabling.ISLookUp;
5 5
import gr.uoa.di.driver.enabling.ISLookUpException;
6
import gr.uoa.di.driver.enabling.resultset.ResultSet;
7
import gr.uoa.di.driver.enabling.resultset.ResultSetFactory;
8
import gr.uoa.di.driver.xml.VocabularyXmlConverter;
9 6
import org.apache.log4j.Logger;
10 7

  
11
import javax.xml.bind.JAXBException;
8
import java.util.List;
12 9
import java.util.Locale;
13 10

  
14 11
public class ISVocabularyLoader extends VocabularyLoader {
15 12

  
16
	private ResultSetFactory rsFactory = null;
17 13
	private ISLookUp<eu.dnetlib.domain.enabling.Vocabulary> lookup = null;
18 14

  
19 15
	private static Logger logger = Logger.getLogger(ISVocabularyLoader.class);
......
27 23
		VocabularySearchCriteria criteria = new VocabularySearchCriteria();
28 24
		criteria.setName(localizedResourceName);
29 25

  
30
		ResultSet<String> rs = null;
31
		String xml = null;
26
		List<eu.dnetlib.domain.enabling.Vocabulary> list;
32 27

  
28

  
33 29
		try {
34
			rs = rsFactory.createResultSet(lookup.search(criteria));
30
			list = lookup.fetch(criteria);
35 31

  
36
			if (rs.size() > 0) {
37
				xml = rs.getElements(1, 1).get(0);
32
			if (list.size() > 0) {
33
				return list.get(0);
38 34

  
39 35
			} else {
40 36
				logger.debug("The " + localizedResourceName + " does not exist in IS. Loading default vocabulary instead.");
41 37
				criteria.setName(((ISVocabulary)vocabulary).getResourceName());
42
				rs = rsFactory.createResultSet(lookup.search(criteria));
38
				list = lookup.fetch(criteria);
43 39

  
44
				if (rs.size() > 0) {
45
					xml = rs.getElements(1, 1).get(0);
40
				if (list.size() > 0) {
41
					return list.get(0);
46 42
				}
47 43
			}
48 44

  
......
50 46
			logger.warn("Problem loading " + vocabulary.getName() + " from IS.", ise);
51 47
		}
52 48

  
53
		if (xml != null && !xml.trim().isEmpty()) {
54
			VocabularyXmlConverter converter = null;
55
			try {
56
				converter = new VocabularyXmlConverter();
57
				rs.close();
58
				return converter.XmlToObject(xml);
59

  
60
			} catch (JAXBException jaxbe) {
61
				logger.error("Unable to load vocabulary " + vocabulary.getName(), jaxbe);
62
			}
63
		}
64

  
65
		//rs.close();
66 49
		return null;
67 50
	}
68 51

  
......
73 56
	public void setLookup(ISLookUp<eu.dnetlib.domain.enabling.Vocabulary> lookup) {
74 57
		this.lookup = lookup;
75 58
	}
76

  
77
	public ResultSetFactory getRsFactory() {
78
		return rsFactory;
79
	}
80

  
81
	public void setRsFactory(ResultSetFactory rsFactory) {
82
		this.rsFactory = rsFactory;
83
	}
84 59
}
modules/uoa-search/trunk/src/main/resources/eu/dnetlib/data/search/springContext-searchService.xml
45 45

  
46 46

  
47 47
    <bean id="blackboardHandler" class="eu.dnetlib.enabling.tools.blackboard.BlackboardHandlerImpl">
48
        <property name="registryLocator" ref="cnr.registryLocator"/>
48
		<property name="serviceLocator" ref="cnr.uniqueServiceLocator" />
49 49
        <property name="messageFactory">
50 50
            <bean class="eu.dnetlib.miscutils.jaxb.JaxbFactory">
51 51
                <constructor-arg value="eu.dnetlib.enabling.tools.blackboard.BlackboardMessageImpl" />
modules/uoa-search/trunk/src/main/resources/eu/dnetlib/data/search/springContext-transformation.xml
40 40
	
41 41
	<bean id="isVocabularyLoader" class="eu.dnetlib.data.search.utils.vocabulary.ISVocabularyLoader">
42 42
		<property name="lookup" ref="vocabularyLookUp"></property>
43
		<property name="rsFactory" ref="resultSetFactory"/>
44 43
	</bean>
45 44
	
46 45
	<bean id="localVocabularyLoader" class="eu.dnetlib.data.search.utils.vocabulary.LocalVocabularyLoader"/>

Also available in: Unified diff