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.GlobalPermissionList;
10: import com.mvnforum.jaxb.db.GroupMemberList;
11: import com.mvnforum.jaxb.db.GroupMemberType;
12: import com.mvnforum.jaxb.db.GroupType;
13: import com.mvnforum.jaxb.db.Mvnforum;
14: import com.mvnforum.jaxb.db.MvnforumType;
15: import com.mvnforum.jaxb.db.ObjectFactory;
16: import com.mvnforum.jaxb.db.MvnforumType.GroupListType;
17: import com.mvnforum.jaxb.util.XMLUtil;
18:
19: public class GroupListDAO {
20:
21: public GroupListType getGroupListType(Collection groups)
22: throws JAXBException {
23: ObjectFactory objectFactory = XMLUtil.getObjectFactory();
24: MvnforumType.GroupListType groupListType = objectFactory
25: .createMvnforumTypeGroupListType();
26: for (Iterator iter = groups.iterator(); iter.hasNext();) {
27: groupListType.getGroup().add(iter.next());
28: }
29: return groupListType;
30: }
31:
32: public GroupType getGroupType(String groupName, String groupDesc,
33: int groupOption, String groupOwnerName,
34: String groupCreationDate, String groupModifiedDate,
35: GlobalPermissionList globalPermissionList,
36: GroupMemberList groupMemberList) throws JAXBException {
37: ObjectFactory objectFactory = XMLUtil.getObjectFactory();
38: GroupType group = objectFactory.createGroupType();
39: group.setGroupName(groupName);
40: group.setGroupDesc(groupDesc);
41: group.setGroupOption(groupOption);
42: group.setGroupOwnerName(groupOwnerName);
43: group.setGroupCreationDate(groupCreationDate);
44: group.setGroupModifiedDate(groupModifiedDate);
45: group.setGlobalPermissionList(globalPermissionList);
46: group.setGroupMemberList(groupMemberList);
47:
48: return group;
49: }
50:
51: public GlobalPermissionList getGlobalPermissionList(
52: Collection globalPermissions) throws JAXBException {
53: ObjectFactory objectFactory = XMLUtil.getObjectFactory();
54: GlobalPermissionList globalPermissionList = objectFactory
55: .createGlobalPermissionList();
56: for (Iterator iter = globalPermissions.iterator(); iter
57: .hasNext();) {
58: globalPermissionList.getGlobalPermission().add(iter.next());
59: }
60: return globalPermissionList;
61: }
62:
63: public GroupMemberList getGroupMemberList(
64: Collection groupMemberTypes) throws JAXBException {
65: ObjectFactory objectFactory = XMLUtil.getObjectFactory();
66: GroupMemberList groupMemberList = objectFactory
67: .createGroupMemberList();
68: for (Iterator iter = groupMemberTypes.iterator(); iter
69: .hasNext();) {
70: groupMemberList.getGroupMember().add(iter.next());
71: }
72: return groupMemberList;
73: }
74:
75: public GroupMemberType getGroupMemberType(String memberName,
76: int privilege, String creationDate, String modifiedDate)
77: throws JAXBException {
78: ObjectFactory objectFactory = XMLUtil.getObjectFactory();
79: GroupMemberType groupMemberType = objectFactory
80: .createGroupMemberType();
81:
82: groupMemberType.setMemberName(memberName);
83: groupMemberType.setPrivilege(privilege);
84: groupMemberType.setCreationDate(creationDate);
85: groupMemberType.setModifiedDate(modifiedDate);
86: return groupMemberType;
87: }
88:
89: public List importGroupTypes() throws JAXBException {
90:
91: Mvnforum mvnforum = XMLUtil.getMvnforum();
92: GroupListType groupListType = mvnforum.getGroupList();
93: System.out.println(groupListType);
94:
95: return groupListType.getGroup();
96:
97: }
98:
99: }
|