01: package com.mvnforum.jaxb.dao;
02:
03: import java.util.Collection;
04: import java.util.Iterator;
05: import java.util.List;
06:
07: import javax.xml.bind.JAXBException;
08:
09: import com.mvnforum.jaxb.db.Mvnforum;
10: import com.mvnforum.jaxb.db.MvnforumType;
11: import com.mvnforum.jaxb.db.ObjectFactory;
12: import com.mvnforum.jaxb.db.RankType;
13: import com.mvnforum.jaxb.db.MvnforumType.RankListType;
14: import com.mvnforum.jaxb.util.XMLUtil;
15:
16: public class RankListDAO {
17:
18: public RankListType getRankListType(Collection rankTypes)
19: throws JAXBException {
20: ObjectFactory objectFactory = XMLUtil.getObjectFactory();
21: MvnforumType.RankListType rankListType = objectFactory
22: .createMvnforumTypeRankListType();
23: for (Iterator iter = rankTypes.iterator(); iter.hasNext();) {
24: rankListType.getRank().add(iter.next());
25: }
26: return rankListType;
27: }
28:
29: public RankType getRankType(int rankMinPosts, int rankLevel,
30: String rankTitle, String rankImage, int rankType,
31: int rankOption) throws JAXBException {
32: ObjectFactory objectFactory = XMLUtil.getObjectFactory();
33: RankType rank = objectFactory.createRankType();
34: rank.setRankMinPosts(rankMinPosts);
35: rank.setRankLevel(rankLevel);
36: rank.setRankTitle(rankTitle);
37: rank.setRankImage(rankImage);
38: rank.setRankType(rankType);
39: rank.setRankOption(rankOption);
40: return rank;
41: }
42:
43: public List importRankType() throws JAXBException {
44: Mvnforum mvnforum = XMLUtil.getMvnforum();
45: RankListType rankListType = mvnforum.getRankList();
46: return rankListType.getRank();
47: }
48:
49: }
|