Author: solomax
Date: Wed Oct 5 12:38:07 2016
New Revision: 1763442
URL: http://svn.apache.org/viewvc?rev=1763442&view=rev
Log:
[OPENMEETINGS-553] initial work on import/export
Added:
openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/backup/OmCalendarConverter.java
openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/backup/OmCalendarConverter.java
Modified:
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/calendar/OmCalendarDao.java
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/OmCalendar.java
openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupExport.java
openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupImport.java
openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/caldav/AppointmentManager.java
openmeetings/application/branches/3.2.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestOmCalendar.java
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/calendar/OmCalendarDao.java
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/OmCalendar.java
openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupExport.java
openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupImport.java
openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/caldav/AppointmentManager.java
openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestOmCalendar.java
Modified:
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/calendar/OmCalendarDao.java
URL:
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/calendar/OmCalendarDao.java?rev=1763442&r1=1763441&r2=1763442&view=diff
==============================================================================
---
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/calendar/OmCalendarDao.java
(original)
+++
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/calendar/OmCalendarDao.java
Wed Oct 5 12:38:07 2016
@@ -41,12 +41,30 @@ public class OmCalendarDao {
}
/**
+ * Returns the Calendar Specified by the Calendar ID.
+ *
+ * @param calId Calendar ID of the Calendar to return.
+ * @return Returns the Calendar if found, else returns null
+ */
+ public OmCalendar get(Long calId) {
+ TypedQuery<OmCalendar> query =
em.createNamedQuery("getCalendarbyId", OmCalendar.class)
+ .setParameter("calId", calId);
+ OmCalendar c = null;
+ try {
+ c = query.getSingleResult();
+ } catch (NoResultException e) {
+ //no-op
+ }
+ return c;
+ }
+
+ /**
* Return all the Calendars that belong to the User.
*
* @param userId User ID to whom the calendars belong.
* @return List of Calendars
*/
- public List<OmCalendar> get(Long userId) {
+ public List<OmCalendar> getByUser(Long userId) {
return em.createNamedQuery("getCalendarbyUser",
OmCalendar.class)
.setParameter("userId", userId)
.getResultList();
@@ -81,25 +99,6 @@ public class OmCalendarDao {
}
/**
- * Returns the Calendar Specified by the Calendar ID.
- *
- * @param calId Calendar ID of the Calendar to return.
- * @return Returns the Calendar if found, else returns null
- */
- public OmCalendar getCalendarbyId(Long calId) {
- TypedQuery<OmCalendar> query =
em.createNamedQuery("getCalendarbyId", OmCalendar.class)
- .setParameter("calId", calId);
- OmCalendar calendar = null;
- try {
- calendar = query.getSingleResult();
- } catch (NoResultException e) {
- //no-op
- }
-
- return calendar;
- }
-
- /**
* Deletes the Calendar on the Database, along with all the
Appointments associated with it.
*
* @param c Calendar to Delete
Modified:
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/OmCalendar.java
URL:
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/OmCalendar.java?rev=1763442&r1=1763441&r2=1763442&view=diff
==============================================================================
---
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/OmCalendar.java
(original)
+++
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/OmCalendar.java
Wed Oct 5 12:38:07 2016
@@ -29,74 +29,68 @@ import javax.persistence.*;
@Entity
@Table(name = "om_calendar")
@NamedQueries({
- @NamedQuery(name="getCalendars", query="SELECT c FROM
OmCalendar c WHERE c.deleted = false ORDER BY c.id")
- , @NamedQuery(name="getCalendarbyUser", query="SELECT c FROM
OmCalendar c" +
- " WHERE c.deleted = false AND c.owner.id = :userId AND
c.syncType <> OmCalendar$SyncType.GOOGLE_CALENDAR " +
- "ORDER BY c.id")
+ @NamedQuery(name = "getCalendars", query = "SELECT c FROM
OmCalendar c WHERE c.deleted = false ORDER BY c.id"),
+ @NamedQuery(name = "getCalendarbyUser", query = "SELECT c FROM
OmCalendar c"
+ + " WHERE c.deleted = false AND c.owner.id =
:userId AND c.syncType <> OmCalendar$SyncType.GOOGLE_CALENDAR "
+ + "ORDER BY c.id")
// OpenJPA has trouble with referencing Subclasses, thus java $
symbol is used
// Comes from the OpenJPA Mailing List.
- , @NamedQuery(name="getGoogleCalendars", query="SELECT c FROM
OmCalendar c WHERE c.deleted = false AND c.owner.id = :userId " +
- "AND c.syncType = OmCalendar$SyncType.GOOGLE_CALENDAR ORDER BY
c.id")
- , @NamedQuery(name="getAppointmentsbyCalendarinRange",
- query="SELECT a FROM Appointment a "
+ ,
+ @NamedQuery(name = "getGoogleCalendars", query = "SELECT c FROM
OmCalendar c WHERE c.deleted = false AND c.owner.id = :userId "
+ + "AND c.syncType =
OmCalendar$SyncType.GOOGLE_CALENDAR ORDER BY c.id"),
+ @NamedQuery(name = "getAppointmentsbyCalendarinRange", query =
"SELECT a FROM Appointment a "
+ "WHERE a.deleted = false "
+ " AND ( "
+ " (a.start BETWEEN :start AND
:end) "
+ " OR (a.end BETWEEN :start AND
:end) "
+ " OR (a.start < :start AND a.end
> :end) "
+ " )"
- + " AND a.owner.id = :userId AND
a.calendar.id = :calId ")
- , @NamedQuery(name="getCalendarbyId",
- query="SELECT c FROM OmCalendar c WHERE c.deleted = false AND
c.id = :calId")
-})
-@Root(name="om_calendar")
+ + " AND a.owner.id = :userId AND
a.calendar.id = :calId "),
+ @NamedQuery(name = "getCalendarbyId", query = "SELECT c FROM
OmCalendar c WHERE c.deleted = false AND c.id = :calId") })
+@Root(name = "calendar")
public class OmCalendar implements IDataProviderEntity {
private static final long serialVersionUID = 1L;
+ public enum SyncType {
+ NONE, ETAG, CTAG, WEBDAV_SYNC, GOOGLE_CALENDAR
+ }
+
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name="id")
- @Element(name="calendarId", data=true)
+ @Column(name = "id")
+ @Element(name = "id", data = true)
private Long id;
- @Column(name="title")
- @Element(name="calendarTitle", data=true, required=false)
+ @Column(name = "title")
+ @Element(name = "title", data = true, required = false)
private String title;
- //Can Also act as the Google Calendar ID for Google Calendars
- @Column(name="href")
- @Element(name="calendarHref", data=true)
+ // Can Also act as the Google Calendar ID for Google Calendars
+ @Column(name = "href")
+ @Element(name = "href", data = true)
private String href;
- //Can also act as the Google API Key for Google Calendars. Note, not
always needed.
- @Column(name="sync_token")
- @Element(name="calendarSyncToken", data=true, required=false)
+ // Can also act as the Google API Key for Google Calendars. Note, not
always needed.
+ @Column(name = "sync_token")
+ @Element(name = "token", data = true, required = false)
private String token;
- @Column(name="deleted")
- @Element(data=true)
+ @Column(name = "deleted")
+ @Element(name = "deleted", data = true)
private boolean deleted;
- public enum SyncType {
- NONE,
- ETAG,
- CTAG,
- WEBDAV_SYNC,
- GOOGLE_CALENDAR
- }
-
- @Column(name="sync_type")
+ @Column(name = "sync_type")
@Enumerated(EnumType.STRING)
- @Element(name="sync_type", data=true)
+ @Element(name = "syncType", data = true)
private SyncType syncType = SyncType.NONE;
@ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name="user_id", nullable=true)
- @ForeignKey(enabled=true)
- @Element(name="users_id", data=true, required=false)
+ @JoinColumn(name = "user_id", nullable = true)
+ @ForeignKey(enabled = true)
+ @Element(name = "ownerId", data = true, required = false)
private User owner;
- //Getters + Setters
+ // Getters + Setters
@Override
public Long getId() {
return id;
@@ -157,7 +151,7 @@ public class OmCalendar implements IData
@Override
public String toString() {
- return "Calendar [ id=" + id + ", title=" + title + ", token="
+ token + ", href="
- + href + ", SyncType=" + syncType + ",
deleted=" + deleted + ", owner=" + owner + " ]";
+ return "Calendar [ id=" + id + ", title=" + title + ", token="
+ token + ", href=" + href + ", SyncType="
+ + syncType + ", deleted=" + deleted + ",
owner=" + owner + " ]";
}
}
Modified:
openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupExport.java
URL:
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupExport.java?rev=1763442&r1=1763441&r2=1763442&view=diff
==============================================================================
---
openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupExport.java
(original)
+++
openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupExport.java
Wed Oct 5 12:38:07 2016
@@ -36,6 +36,7 @@ import org.apache.openmeetings.db.dao.ba
import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
import org.apache.openmeetings.db.dao.calendar.AppointmentDao;
import org.apache.openmeetings.db.dao.calendar.MeetingMemberDao;
+import org.apache.openmeetings.db.dao.calendar.OmCalendarDao;
import org.apache.openmeetings.db.dao.file.FileExplorerItemDao;
import org.apache.openmeetings.db.dao.record.RecordingDao;
import org.apache.openmeetings.db.dao.room.PollDao;
@@ -52,6 +53,7 @@ import org.apache.openmeetings.db.dao.us
import org.apache.openmeetings.db.entity.basic.ChatMessage;
import org.apache.openmeetings.db.entity.basic.Configuration;
import org.apache.openmeetings.db.entity.calendar.Appointment;
+import org.apache.openmeetings.db.entity.calendar.OmCalendar;
import org.apache.openmeetings.db.entity.file.FileExplorerItem;
import org.apache.openmeetings.db.entity.record.Recording;
import org.apache.openmeetings.db.entity.room.Room;
@@ -91,6 +93,8 @@ public class BackupExport {
@Autowired
private AppointmentDao appointmentDao;
@Autowired
+ private OmCalendarDao calendarDao;
+ @Autowired
private FileExplorerItemDao fileExplorerItemDao;
@Autowired
private RecordingDao recordingDao;
@@ -168,10 +172,23 @@ public class BackupExport {
registry.bind(Room.class, RoomConverter.class);
writeList(serializer, backup_dir,
"rooms_organisation.xml", "room_organisations", roomGroupDao.get());
- progressHolder.setProgress(20);
+ progressHolder.setProgress(17);
}
/*
+ * ##################### Backup Calendars
+ */
+ {
+ List<OmCalendar> list = calendarDao.get();
+ Registry registry = new Registry();
+ Strategy strategy = new RegistryStrategy(registry);
+ Serializer serializer = new Persister(strategy);
+ registry.bind(User.class, UserConverter.class);
+
+ writeList(serializer, backup_dir, "calendars.xml",
"calendars", list);
+ progressHolder.setProgress(22);
+ }
+ /*
* ##################### Backup Appointments
*/
{
Modified:
openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupImport.java
URL:
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupImport.java?rev=1763442&r1=1763441&r2=1763442&view=diff
==============================================================================
---
openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupImport.java
(original)
+++
openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupImport.java
Wed Oct 5 12:38:07 2016
@@ -68,6 +68,7 @@ import org.apache.openmeetings.db.dao.ba
import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
import org.apache.openmeetings.db.dao.calendar.AppointmentDao;
import org.apache.openmeetings.db.dao.calendar.MeetingMemberDao;
+import org.apache.openmeetings.db.dao.calendar.OmCalendarDao;
import org.apache.openmeetings.db.dao.file.FileExplorerItemDao;
import org.apache.openmeetings.db.dao.record.RecordingDao;
import org.apache.openmeetings.db.dao.room.PollDao;
@@ -85,6 +86,7 @@ import org.apache.openmeetings.db.entity
import org.apache.openmeetings.db.entity.basic.Configuration;
import org.apache.openmeetings.db.entity.calendar.Appointment;
import org.apache.openmeetings.db.entity.calendar.MeetingMember;
+import org.apache.openmeetings.db.entity.calendar.OmCalendar;
import org.apache.openmeetings.db.entity.file.FileExplorerItem;
import org.apache.openmeetings.db.entity.file.FileItem;
import org.apache.openmeetings.db.entity.record.Recording;
@@ -136,6 +138,8 @@ public class BackupImport {
@Autowired
private AppointmentDao appointmentDao;
@Autowired
+ private OmCalendarDao calendarDao;
+ @Autowired
private RoomDao roomDao;
@Autowired
private UserDao userDao;
@@ -170,12 +174,13 @@ public class BackupImport {
@Autowired
private RoomGroupDao roomGroupDao;
- private final Map<Long, Long> usersMap = new HashMap<>();
+ private final Map<Long, Long> userMap = new HashMap<>();
private final Map<Long, Long> groupMap = new HashMap<>();
- private final Map<Long, Long> appointmentsMap = new HashMap<>();
- private final Map<Long, Long> roomsMap = new HashMap<>();
- private final Map<Long, Long> messageFoldersMap = new HashMap<>();
- private final Map<Long, Long> userContactsMap = new HashMap<>();
+ private final Map<Long, Long> calendarMap = new HashMap<>();
+ private final Map<Long, Long> appointmentMap = new HashMap<>();
+ private final Map<Long, Long> roomMap = new HashMap<>();
+ private final Map<Long, Long> messageFolderMap = new HashMap<>();
+ private final Map<Long, Long> userContactMap = new HashMap<>();
private final Map<String, Integer> userEmailMap = new HashMap<>();
private final Map<String, String> fileMap = new HashMap<>();
@@ -224,17 +229,18 @@ public class BackupImport {
}
public void performImport(InputStream is) throws Exception {
- usersMap.clear();
+ userMap.clear();
groupMap.clear();
- appointmentsMap.clear();
- roomsMap.clear();
- messageFoldersMap.clear();
- userContactsMap.clear();
+ calendarMap.clear();
+ appointmentMap.clear();
+ roomMap.clear();
+ messageFolderMap.clear();
+ userContactMap.clear();
userEmailMap.clear();
fileMap.clear();
- messageFoldersMap.put(INBOX_FOLDER_ID, INBOX_FOLDER_ID);
- messageFoldersMap.put(SENT_FOLDER_ID, SENT_FOLDER_ID);
- messageFoldersMap.put(TRASH_FOLDER_ID, TRASH_FOLDER_ID);
+ messageFolderMap.put(INBOX_FOLDER_ID, INBOX_FOLDER_ID);
+ messageFolderMap.put(SENT_FOLDER_ID, SENT_FOLDER_ID);
+ messageFolderMap.put(TRASH_FOLDER_ID, TRASH_FOLDER_ID);
File f = unzip(is);
@@ -249,7 +255,7 @@ public class BackupImport {
matcher.bind(Long.class, LongTransform.class);
registry.bind(Date.class, DateConverter.class);
- registry.bind(User.class, new UserConverter(userDao,
usersMap));
+ registry.bind(User.class, new UserConverter(userDao,
userMap));
List<Configuration> list = readList(serializer, f,
"configs.xml", "configs", Configuration.class, true);
for (Configuration c : list) {
@@ -363,7 +369,7 @@ public class BackupImport {
u.setType(User.Type.external);
}
userDao.update(u, Long.valueOf(-1));
- usersMap.put(userId, u.getId());
+ userMap.put(userId, u.getId());
}
}
@@ -387,7 +393,7 @@ public class BackupImport {
}
}
r = roomDao.update(r, null);
- roomsMap.put(roomId, r.getId());
+ roomMap.put(roomId, r.getId());
}
}
@@ -401,7 +407,7 @@ public class BackupImport {
Serializer serializer = new Persister(strategy);
registry.bind(Group.class, new GroupConverter(groupDao,
groupMap));
- registry.bind(Room.class, new RoomConverter(roomDao,
roomsMap));
+ registry.bind(Room.class, new RoomConverter(roomDao,
roomMap));
List<RoomGroup> list = readList(serializer, f,
"rooms_organisation.xml", "room_organisations", RoomGroup.class);
for (RoomGroup ro : list) {
@@ -422,8 +428,8 @@ public class BackupImport {
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
- registry.bind(User.class, new UserConverter(userDao,
usersMap));
- registry.bind(Room.class, new RoomConverter(roomDao,
roomsMap));
+ registry.bind(User.class, new UserConverter(userDao,
userMap));
+ registry.bind(Room.class, new RoomConverter(roomDao,
roomMap));
registry.bind(Date.class, DateConverter.class);
List<ChatMessage> list = readList(serializer, f,
"chat_messages.xml", "chat_messages", ChatMessage.class, true);
@@ -435,8 +441,23 @@ public class BackupImport {
chatDao.update(m);
}
}
-
- log.info("Chat messages import complete, starting appointement
import");
+ log.info("Chat messages import complete, starting calendar
import");
+ /*
+ * ##################### Import Calendars
+ */
+ {
+ Registry registry = new Registry();
+ Strategy strategy = new RegistryStrategy(registry);
+ Serializer serializer = new Persister(strategy);
+ registry.bind(User.class, new UserConverter(userDao,
userMap));
+ //registry.bind(OmCalendar.SyncType.class,
OmCalendarSyncTypeConverter.class);
+ List<OmCalendar> list = readList(serializer, f,
"calendars.xml", "calendars", OmCalendar.class);
+ for (OmCalendar a : list) {
+
+ }
+ }
+
+ log.info("Calendar import complete, starting appointement
import");
/*
* ##################### Import Appointements
*/
@@ -445,10 +466,11 @@ public class BackupImport {
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
- registry.bind(User.class, new UserConverter(userDao,
usersMap));
+ registry.bind(User.class, new UserConverter(userDao,
userMap));
registry.bind(Appointment.Reminder.class,
AppointmentReminderTypeConverter.class);
- registry.bind(Room.class, new RoomConverter(roomDao,
roomsMap));
+ registry.bind(Room.class, new RoomConverter(roomDao,
roomMap));
registry.bind(Date.class, DateConverter.class);
+ registry.bind(OmCalendar.class, new
OmCalendarConverter(calendarDao, calendarMap));
List<Appointment> list = readList(serializer, f,
"appointements.xml", "appointments", Appointment.class);
for (Appointment a : list) {
@@ -468,7 +490,7 @@ public class BackupImport {
continue;
}
a = appointmentDao.update(a, null, false);
- appointmentsMap.put(appId, a.getId());
+ appointmentMap.put(appId, a.getId());
}
}
@@ -507,10 +529,10 @@ public class BackupImport {
for (Recording r : list) {
r.setId(null);
if (r.getRoomId() != null) {
-
r.setRoomId(roomsMap.get(r.getRoomId()));
+ r.setRoomId(roomMap.get(r.getRoomId()));
}
if (r.getOwnerId() != null) {
-
r.setOwnerId(usersMap.get(r.getOwnerId()));
+
r.setOwnerId(userMap.get(r.getOwnerId()));
}
if (r.getMetaData() != null) {
for (RecordingMetaData meta :
r.getMetaData()) {
@@ -544,7 +566,7 @@ public class BackupImport {
if (storedFolder == null) {
p.setId(null);
Long newFolderId =
privateMessageFolderDao.addPrivateMessageFolderObj(p);
- messageFoldersMap.put(folderId,
newFolderId);
+ messageFolderMap.put(folderId,
newFolderId);
}
}
}
@@ -558,7 +580,7 @@ public class BackupImport {
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
- registry.bind(User.class, new UserConverter(userDao,
usersMap));
+ registry.bind(User.class, new UserConverter(userDao,
userMap));
List<UserContact> list = readList(serializer, f,
"userContacts.xml", "usercontacts", UserContact.class, true);
for (UserContact uc : list) {
@@ -571,7 +593,7 @@ public class BackupImport {
uc.setOwner(null);
}
uc = userContactDao.update(uc);
- userContactsMap.put(ucId, uc.getId());
+ userContactMap.put(ucId, uc.getId());
}
}
}
@@ -585,8 +607,8 @@ public class BackupImport {
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
- registry.bind(User.class, new UserConverter(userDao,
usersMap));
- registry.bind(Room.class, new RoomConverter(roomDao,
roomsMap));
+ registry.bind(User.class, new UserConverter(userDao,
userMap));
+ registry.bind(Room.class, new RoomConverter(roomDao,
roomMap));
registry.bind(Date.class, DateConverter.class);
List<PrivateMessage> list = readList(serializer, f,
"privateMessages.xml", "privatemessages", PrivateMessage.class, true);
@@ -634,9 +656,9 @@ public class BackupImport {
// We need to reset this as openJPA reject to
store them otherwise
file.setId(null);
Long roomId = file.getRoomId();
- file.setRoomId(roomsMap.containsKey(roomId) ?
roomsMap.get(roomId) : null);
+ file.setRoomId(roomMap.containsKey(roomId) ?
roomMap.get(roomId) : null);
if (file.getOwnerId() != null) {
-
file.setOwnerId(usersMap.get(file.getOwnerId()));
+
file.setOwnerId(userMap.get(file.getOwnerId()));
}
if (file.getParentId() != null &&
file.getParentId().longValue() <= 0L) {
file.setParentId(null);
@@ -656,8 +678,8 @@ public class BackupImport {
Serializer serializer = new Persister(strategy,
matcher);
matcher.bind(Integer.class, IntegerTransform.class);
- registry.bind(User.class, new UserConverter(userDao,
usersMap));
- registry.bind(Room.class, new RoomConverter(roomDao,
roomsMap));
+ registry.bind(User.class, new UserConverter(userDao,
userMap));
+ registry.bind(Room.class, new RoomConverter(roomDao,
roomMap));
registry.bind(RoomPoll.Type.class,
PollTypeConverter.class);
registry.bind(Date.class, DateConverter.class);
@@ -873,8 +895,8 @@ public class BackupImport {
Strategy strategy = new RegistryStrategy(registry);
Serializer ser = new Persister(strategy);
- registry.bind(User.class, new UserConverter(userDao, usersMap));
- registry.bind(Appointment.class, new
AppointmentConverter(appointmentDao, appointmentsMap));
+ registry.bind(User.class, new UserConverter(userDao, userMap));
+ registry.bind(Appointment.class, new
AppointmentConverter(appointmentDao, appointmentMap));
File xml = new File(baseDir, filename);
if (!xml.exists()) {
@@ -1090,7 +1112,7 @@ public class BackupImport {
matcher.bind(Long.class, LongTransform.class);
matcher.bind(Integer.class, IntegerTransform.class);
- registry.bind(User.class, new UserConverter(userDao,
usersMap));
+ registry.bind(User.class, new UserConverter(userDao,
userMap));
registry.bind(Room.Type.class, RoomTypeConverter.class);
InputNode root = NodeBuilder.read(new
FileInputStream(xml));
@@ -1214,8 +1236,8 @@ public class BackupImport {
Long newId = null;
switch (map) {
case USERS:
- if (usersMap.containsKey(oldId)) {
- newId = usersMap.get(oldId);
+ if (userMap.containsKey(oldId)) {
+ newId = userMap.get(oldId);
}
break;
case ORGANISATIONS:
@@ -1224,23 +1246,23 @@ public class BackupImport {
}
break;
case APPOINTMENTS:
- if (appointmentsMap.containsKey(oldId)) {
- newId = appointmentsMap.get(oldId);
+ if (appointmentMap.containsKey(oldId)) {
+ newId = appointmentMap.get(oldId);
}
break;
case ROOMS:
- if (roomsMap.containsKey(oldId)) {
- newId = roomsMap.get(oldId);
+ if (roomMap.containsKey(oldId)) {
+ newId = roomMap.get(oldId);
}
break;
case MESSAGEFOLDERS:
- if (messageFoldersMap.containsKey(oldId)) {
- newId = messageFoldersMap.get(oldId);
+ if (messageFolderMap.containsKey(oldId)) {
+ newId = messageFolderMap.get(oldId);
}
break;
case USERCONTACTS:
- if (userContactsMap.containsKey(oldId)) {
- newId = userContactsMap.get(oldId);
+ if (userContactMap.containsKey(oldId)) {
+ newId = userContactMap.get(oldId);
}
break;
default:
Added:
openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/backup/OmCalendarConverter.java
URL:
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/backup/OmCalendarConverter.java?rev=1763442&view=auto
==============================================================================
---
openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/backup/OmCalendarConverter.java
(added)
+++
openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/backup/OmCalendarConverter.java
Wed Oct 5 12:38:07 2016
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") + you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.backup;
+
+import java.util.Map;
+
+import org.apache.openmeetings.db.dao.calendar.OmCalendarDao;
+import org.apache.openmeetings.db.entity.calendar.OmCalendar;
+import org.simpleframework.xml.stream.InputNode;
+import org.simpleframework.xml.stream.OutputNode;
+
+public class OmCalendarConverter extends OmConverter<OmCalendar> {
+ private OmCalendarDao calendarDao;
+ private Map<Long, Long> idMap;
+
+ public OmCalendarConverter() {
+ //default constructor is for export
+ }
+
+ public OmCalendarConverter(OmCalendarDao calendarDao, Map<Long, Long>
idMap) {
+ this.calendarDao = calendarDao;
+ this.idMap = idMap;
+ }
+
+ @Override
+ public OmCalendar read(InputNode node) throws Exception {
+ long oldId = getLong(node);
+ Long newId = idMap.containsKey(oldId) ? idMap.get(oldId) :
oldId;
+
+ OmCalendar c = calendarDao.get(newId);
+ return c == null ? new OmCalendar() : c;
+ }
+
+ @Override
+ public void write(OutputNode node, OmCalendar value) throws Exception {
+ node.setData(true);
+ node.setValue(value == null ? "0" : "" + value.getId());
+ }
+}
\ No newline at end of file
Modified:
openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/caldav/AppointmentManager.java
URL:
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/caldav/AppointmentManager.java?rev=1763442&r1=1763441&r2=1763442&view=diff
==============================================================================
---
openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/caldav/AppointmentManager.java
(original)
+++
openmeetings/application/branches/3.2.x/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/caldav/AppointmentManager.java
Wed Oct 5 12:38:07 2016
@@ -197,10 +197,10 @@ public class AppointmentManager {
}
/**
- * @see OmCalendarDao#get(Long)
+ * @see OmCalendarDao#getByUser(Long)
*/
public List<OmCalendar> getCalendars(Long userid) {
- return calendarDao.get(userid);
+ return calendarDao.getByUser(userid);
}
/**
Modified:
openmeetings/application/branches/3.2.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestOmCalendar.java
URL:
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestOmCalendar.java?rev=1763442&r1=1763441&r2=1763442&view=diff
==============================================================================
---
openmeetings/application/branches/3.2.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestOmCalendar.java
(original)
+++
openmeetings/application/branches/3.2.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestOmCalendar.java
Wed Oct 5 12:38:07 2016
@@ -52,7 +52,7 @@ public class TestOmCalendar extends Abst
assertTrue("Saved calendar should have valid id: " +
calendar.getId(),
calendar.getId() != null && calendar.getId() >
0);
- OmCalendar c = calendarDao.getCalendarbyId(calendar.getId());
+ OmCalendar c = calendarDao.get(calendar.getId());
assertNotNull("Failed to find Calendar by id", c);
}
}
Modified:
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/calendar/OmCalendarDao.java
URL:
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/calendar/OmCalendarDao.java?rev=1763442&r1=1763441&r2=1763442&view=diff
==============================================================================
---
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/calendar/OmCalendarDao.java
(original)
+++
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/calendar/OmCalendarDao.java
Wed Oct 5 12:38:07 2016
@@ -41,12 +41,30 @@ public class OmCalendarDao {
}
/**
+ * Returns the Calendar Specified by the Calendar ID.
+ *
+ * @param calId Calendar ID of the Calendar to return.
+ * @return Returns the Calendar if found, else returns null
+ */
+ public OmCalendar get(Long calId) {
+ TypedQuery<OmCalendar> query =
em.createNamedQuery("getCalendarbyId", OmCalendar.class)
+ .setParameter("calId", calId);
+ OmCalendar c = null;
+ try {
+ c = query.getSingleResult();
+ } catch (NoResultException e) {
+ //no-op
+ }
+ return c;
+ }
+
+ /**
* Return all the Calendars that belong to the User.
*
* @param userId User ID to whom the calendars belong.
* @return List of Calendars
*/
- public List<OmCalendar> get(Long userId) {
+ public List<OmCalendar> getByUser(Long userId) {
return em.createNamedQuery("getCalendarbyUser",
OmCalendar.class)
.setParameter("userId", userId)
.getResultList();
@@ -81,25 +99,6 @@ public class OmCalendarDao {
}
/**
- * Returns the Calendar Specified by the Calendar ID.
- *
- * @param calId Calendar ID of the Calendar to return.
- * @return Returns the Calendar if found, else returns null
- */
- public OmCalendar getCalendarbyId(Long calId) {
- TypedQuery<OmCalendar> query =
em.createNamedQuery("getCalendarbyId", OmCalendar.class)
- .setParameter("calId", calId);
- OmCalendar calendar = null;
- try {
- calendar = query.getSingleResult();
- } catch (NoResultException e) {
- //no-op
- }
-
- return calendar;
- }
-
- /**
* Deletes the Calendar on the Database, along with all the
Appointments associated with it.
*
* @param c Calendar to Delete
Modified:
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/OmCalendar.java
URL:
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/OmCalendar.java?rev=1763442&r1=1763441&r2=1763442&view=diff
==============================================================================
---
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/OmCalendar.java
(original)
+++
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/OmCalendar.java
Wed Oct 5 12:38:07 2016
@@ -29,74 +29,68 @@ import javax.persistence.*;
@Entity
@Table(name = "om_calendar")
@NamedQueries({
- @NamedQuery(name="getCalendars", query="SELECT c FROM
OmCalendar c WHERE c.deleted = false ORDER BY c.id")
- , @NamedQuery(name="getCalendarbyUser", query="SELECT c FROM
OmCalendar c" +
- " WHERE c.deleted = false AND c.owner.id = :userId AND
c.syncType <> OmCalendar$SyncType.GOOGLE_CALENDAR " +
- "ORDER BY c.id")
+ @NamedQuery(name = "getCalendars", query = "SELECT c FROM
OmCalendar c WHERE c.deleted = false ORDER BY c.id"),
+ @NamedQuery(name = "getCalendarbyUser", query = "SELECT c FROM
OmCalendar c"
+ + " WHERE c.deleted = false AND c.owner.id =
:userId AND c.syncType <> OmCalendar$SyncType.GOOGLE_CALENDAR "
+ + "ORDER BY c.id")
// OpenJPA has trouble with referencing Subclasses, thus java $
symbol is used
// Comes from the OpenJPA Mailing List.
- , @NamedQuery(name="getGoogleCalendars", query="SELECT c FROM
OmCalendar c WHERE c.deleted = false AND c.owner.id = :userId " +
- "AND c.syncType = OmCalendar$SyncType.GOOGLE_CALENDAR ORDER BY
c.id")
- , @NamedQuery(name="getAppointmentsbyCalendarinRange",
- query="SELECT a FROM Appointment a "
+ ,
+ @NamedQuery(name = "getGoogleCalendars", query = "SELECT c FROM
OmCalendar c WHERE c.deleted = false AND c.owner.id = :userId "
+ + "AND c.syncType =
OmCalendar$SyncType.GOOGLE_CALENDAR ORDER BY c.id"),
+ @NamedQuery(name = "getAppointmentsbyCalendarinRange", query =
"SELECT a FROM Appointment a "
+ "WHERE a.deleted = false "
+ " AND ( "
+ " (a.start BETWEEN :start AND
:end) "
+ " OR (a.end BETWEEN :start AND
:end) "
+ " OR (a.start < :start AND a.end
> :end) "
+ " )"
- + " AND a.owner.id = :userId AND
a.calendar.id = :calId ")
- , @NamedQuery(name="getCalendarbyId",
- query="SELECT c FROM OmCalendar c WHERE c.deleted = false AND
c.id = :calId")
-})
-@Root(name="om_calendar")
+ + " AND a.owner.id = :userId AND
a.calendar.id = :calId "),
+ @NamedQuery(name = "getCalendarbyId", query = "SELECT c FROM
OmCalendar c WHERE c.deleted = false AND c.id = :calId") })
+@Root(name = "calendar")
public class OmCalendar implements IDataProviderEntity {
private static final long serialVersionUID = 1L;
+ public enum SyncType {
+ NONE, ETAG, CTAG, WEBDAV_SYNC, GOOGLE_CALENDAR
+ }
+
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name="id")
- @Element(name="calendarId", data=true)
+ @Column(name = "id")
+ @Element(name = "id", data = true)
private Long id;
- @Column(name="title")
- @Element(name="calendarTitle", data=true, required=false)
+ @Column(name = "title")
+ @Element(name = "title", data = true, required = false)
private String title;
- //Can Also act as the Google Calendar ID for Google Calendars
- @Column(name="href")
- @Element(name="calendarHref", data=true)
+ // Can Also act as the Google Calendar ID for Google Calendars
+ @Column(name = "href")
+ @Element(name = "href", data = true)
private String href;
- //Can also act as the Google API Key for Google Calendars. Note, not
always needed.
- @Column(name="sync_token")
- @Element(name="calendarSyncToken", data=true, required=false)
+ // Can also act as the Google API Key for Google Calendars. Note, not
always needed.
+ @Column(name = "sync_token")
+ @Element(name = "token", data = true, required = false)
private String token;
- @Column(name="deleted")
- @Element(data=true)
+ @Column(name = "deleted")
+ @Element(name = "deleted", data = true)
private boolean deleted;
- public enum SyncType {
- NONE,
- ETAG,
- CTAG,
- WEBDAV_SYNC,
- GOOGLE_CALENDAR
- }
-
- @Column(name="sync_type")
+ @Column(name = "sync_type")
@Enumerated(EnumType.STRING)
- @Element(name="sync_type", data=true)
+ @Element(name = "syncType", data = true)
private SyncType syncType = SyncType.NONE;
@ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name="user_id", nullable=true)
- @ForeignKey(enabled=true)
- @Element(name="users_id", data=true, required=false)
+ @JoinColumn(name = "user_id", nullable = true)
+ @ForeignKey(enabled = true)
+ @Element(name = "ownerId", data = true, required = false)
private User owner;
- //Getters + Setters
+ // Getters + Setters
@Override
public Long getId() {
return id;
@@ -157,7 +151,7 @@ public class OmCalendar implements IData
@Override
public String toString() {
- return "Calendar [ id=" + id + ", title=" + title + ", token="
+ token + ", href="
- + href + ", SyncType=" + syncType + ",
deleted=" + deleted + ", owner=" + owner + " ]";
+ return "Calendar [ id=" + id + ", title=" + title + ", token="
+ token + ", href=" + href + ", SyncType="
+ + syncType + ", deleted=" + deleted + ",
owner=" + owner + " ]";
}
}
Modified:
openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupExport.java
URL:
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupExport.java?rev=1763442&r1=1763441&r2=1763442&view=diff
==============================================================================
---
openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupExport.java
(original)
+++
openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupExport.java
Wed Oct 5 12:38:07 2016
@@ -36,6 +36,7 @@ import org.apache.openmeetings.db.dao.ba
import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
import org.apache.openmeetings.db.dao.calendar.AppointmentDao;
import org.apache.openmeetings.db.dao.calendar.MeetingMemberDao;
+import org.apache.openmeetings.db.dao.calendar.OmCalendarDao;
import org.apache.openmeetings.db.dao.file.FileExplorerItemDao;
import org.apache.openmeetings.db.dao.record.RecordingDao;
import org.apache.openmeetings.db.dao.room.PollDao;
@@ -52,6 +53,7 @@ import org.apache.openmeetings.db.dao.us
import org.apache.openmeetings.db.entity.basic.ChatMessage;
import org.apache.openmeetings.db.entity.basic.Configuration;
import org.apache.openmeetings.db.entity.calendar.Appointment;
+import org.apache.openmeetings.db.entity.calendar.OmCalendar;
import org.apache.openmeetings.db.entity.file.FileExplorerItem;
import org.apache.openmeetings.db.entity.record.Recording;
import org.apache.openmeetings.db.entity.room.Room;
@@ -91,6 +93,8 @@ public class BackupExport {
@Autowired
private AppointmentDao appointmentDao;
@Autowired
+ private OmCalendarDao calendarDao;
+ @Autowired
private FileExplorerItemDao fileExplorerItemDao;
@Autowired
private RecordingDao recordingDao;
@@ -168,10 +172,23 @@ public class BackupExport {
registry.bind(Room.class, RoomConverter.class);
writeList(serializer, backup_dir,
"rooms_organisation.xml", "room_organisations", roomGroupDao.get());
- progressHolder.setProgress(20);
+ progressHolder.setProgress(17);
}
/*
+ * ##################### Backup Calendars
+ */
+ {
+ List<OmCalendar> list = calendarDao.get();
+ Registry registry = new Registry();
+ Strategy strategy = new RegistryStrategy(registry);
+ Serializer serializer = new Persister(strategy);
+ registry.bind(User.class, UserConverter.class);
+
+ writeList(serializer, backup_dir, "calendars.xml",
"calendars", list);
+ progressHolder.setProgress(22);
+ }
+ /*
* ##################### Backup Appointments
*/
{
Modified:
openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupImport.java
URL:
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupImport.java?rev=1763442&r1=1763441&r2=1763442&view=diff
==============================================================================
---
openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupImport.java
(original)
+++
openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/backup/BackupImport.java
Wed Oct 5 12:38:07 2016
@@ -68,6 +68,7 @@ import org.apache.openmeetings.db.dao.ba
import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
import org.apache.openmeetings.db.dao.calendar.AppointmentDao;
import org.apache.openmeetings.db.dao.calendar.MeetingMemberDao;
+import org.apache.openmeetings.db.dao.calendar.OmCalendarDao;
import org.apache.openmeetings.db.dao.file.FileExplorerItemDao;
import org.apache.openmeetings.db.dao.record.RecordingDao;
import org.apache.openmeetings.db.dao.room.PollDao;
@@ -85,6 +86,7 @@ import org.apache.openmeetings.db.entity
import org.apache.openmeetings.db.entity.basic.Configuration;
import org.apache.openmeetings.db.entity.calendar.Appointment;
import org.apache.openmeetings.db.entity.calendar.MeetingMember;
+import org.apache.openmeetings.db.entity.calendar.OmCalendar;
import org.apache.openmeetings.db.entity.file.FileExplorerItem;
import org.apache.openmeetings.db.entity.file.FileItem;
import org.apache.openmeetings.db.entity.record.Recording;
@@ -136,6 +138,8 @@ public class BackupImport {
@Autowired
private AppointmentDao appointmentDao;
@Autowired
+ private OmCalendarDao calendarDao;
+ @Autowired
private RoomDao roomDao;
@Autowired
private UserDao userDao;
@@ -170,12 +174,13 @@ public class BackupImport {
@Autowired
private RoomGroupDao roomGroupDao;
- private final Map<Long, Long> usersMap = new HashMap<>();
+ private final Map<Long, Long> userMap = new HashMap<>();
private final Map<Long, Long> groupMap = new HashMap<>();
- private final Map<Long, Long> appointmentsMap = new HashMap<>();
- private final Map<Long, Long> roomsMap = new HashMap<>();
- private final Map<Long, Long> messageFoldersMap = new HashMap<>();
- private final Map<Long, Long> userContactsMap = new HashMap<>();
+ private final Map<Long, Long> calendarMap = new HashMap<>();
+ private final Map<Long, Long> appointmentMap = new HashMap<>();
+ private final Map<Long, Long> roomMap = new HashMap<>();
+ private final Map<Long, Long> messageFolderMap = new HashMap<>();
+ private final Map<Long, Long> userContactMap = new HashMap<>();
private final Map<String, Integer> userEmailMap = new HashMap<>();
private final Map<String, String> fileMap = new HashMap<>();
@@ -224,17 +229,18 @@ public class BackupImport {
}
public void performImport(InputStream is) throws Exception {
- usersMap.clear();
+ userMap.clear();
groupMap.clear();
- appointmentsMap.clear();
- roomsMap.clear();
- messageFoldersMap.clear();
- userContactsMap.clear();
+ calendarMap.clear();
+ appointmentMap.clear();
+ roomMap.clear();
+ messageFolderMap.clear();
+ userContactMap.clear();
userEmailMap.clear();
fileMap.clear();
- messageFoldersMap.put(INBOX_FOLDER_ID, INBOX_FOLDER_ID);
- messageFoldersMap.put(SENT_FOLDER_ID, SENT_FOLDER_ID);
- messageFoldersMap.put(TRASH_FOLDER_ID, TRASH_FOLDER_ID);
+ messageFolderMap.put(INBOX_FOLDER_ID, INBOX_FOLDER_ID);
+ messageFolderMap.put(SENT_FOLDER_ID, SENT_FOLDER_ID);
+ messageFolderMap.put(TRASH_FOLDER_ID, TRASH_FOLDER_ID);
File f = unzip(is);
@@ -249,7 +255,7 @@ public class BackupImport {
matcher.bind(Long.class, LongTransform.class);
registry.bind(Date.class, DateConverter.class);
- registry.bind(User.class, new UserConverter(userDao,
usersMap));
+ registry.bind(User.class, new UserConverter(userDao,
userMap));
List<Configuration> list = readList(serializer, f,
"configs.xml", "configs", Configuration.class, true);
for (Configuration c : list) {
@@ -363,7 +369,7 @@ public class BackupImport {
u.setType(User.Type.external);
}
userDao.update(u, Long.valueOf(-1));
- usersMap.put(userId, u.getId());
+ userMap.put(userId, u.getId());
}
}
@@ -387,7 +393,7 @@ public class BackupImport {
}
}
r = roomDao.update(r, null);
- roomsMap.put(roomId, r.getId());
+ roomMap.put(roomId, r.getId());
}
}
@@ -401,7 +407,7 @@ public class BackupImport {
Serializer serializer = new Persister(strategy);
registry.bind(Group.class, new GroupConverter(groupDao,
groupMap));
- registry.bind(Room.class, new RoomConverter(roomDao,
roomsMap));
+ registry.bind(Room.class, new RoomConverter(roomDao,
roomMap));
List<RoomGroup> list = readList(serializer, f,
"rooms_organisation.xml", "room_organisations", RoomGroup.class);
for (RoomGroup ro : list) {
@@ -422,8 +428,8 @@ public class BackupImport {
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
- registry.bind(User.class, new UserConverter(userDao,
usersMap));
- registry.bind(Room.class, new RoomConverter(roomDao,
roomsMap));
+ registry.bind(User.class, new UserConverter(userDao,
userMap));
+ registry.bind(Room.class, new RoomConverter(roomDao,
roomMap));
registry.bind(Date.class, DateConverter.class);
List<ChatMessage> list = readList(serializer, f,
"chat_messages.xml", "chat_messages", ChatMessage.class, true);
@@ -435,8 +441,23 @@ public class BackupImport {
chatDao.update(m);
}
}
-
- log.info("Chat messages import complete, starting appointement
import");
+ log.info("Chat messages import complete, starting calendar
import");
+ /*
+ * ##################### Import Calendars
+ */
+ {
+ Registry registry = new Registry();
+ Strategy strategy = new RegistryStrategy(registry);
+ Serializer serializer = new Persister(strategy);
+ registry.bind(User.class, new UserConverter(userDao,
userMap));
+ //registry.bind(OmCalendar.SyncType.class,
OmCalendarSyncTypeConverter.class);
+ List<OmCalendar> list = readList(serializer, f,
"calendars.xml", "calendars", OmCalendar.class);
+ for (OmCalendar a : list) {
+
+ }
+ }
+
+ log.info("Calendar import complete, starting appointement
import");
/*
* ##################### Import Appointements
*/
@@ -445,10 +466,11 @@ public class BackupImport {
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
- registry.bind(User.class, new UserConverter(userDao,
usersMap));
+ registry.bind(User.class, new UserConverter(userDao,
userMap));
registry.bind(Appointment.Reminder.class,
AppointmentReminderTypeConverter.class);
- registry.bind(Room.class, new RoomConverter(roomDao,
roomsMap));
+ registry.bind(Room.class, new RoomConverter(roomDao,
roomMap));
registry.bind(Date.class, DateConverter.class);
+ registry.bind(OmCalendar.class, new
OmCalendarConverter(calendarDao, calendarMap));
List<Appointment> list = readList(serializer, f,
"appointements.xml", "appointments", Appointment.class);
for (Appointment a : list) {
@@ -468,7 +490,7 @@ public class BackupImport {
continue;
}
a = appointmentDao.update(a, null, false);
- appointmentsMap.put(appId, a.getId());
+ appointmentMap.put(appId, a.getId());
}
}
@@ -507,10 +529,10 @@ public class BackupImport {
for (Recording r : list) {
r.setId(null);
if (r.getRoomId() != null) {
-
r.setRoomId(roomsMap.get(r.getRoomId()));
+ r.setRoomId(roomMap.get(r.getRoomId()));
}
if (r.getOwnerId() != null) {
-
r.setOwnerId(usersMap.get(r.getOwnerId()));
+
r.setOwnerId(userMap.get(r.getOwnerId()));
}
if (r.getMetaData() != null) {
for (RecordingMetaData meta :
r.getMetaData()) {
@@ -544,7 +566,7 @@ public class BackupImport {
if (storedFolder == null) {
p.setId(null);
Long newFolderId =
privateMessageFolderDao.addPrivateMessageFolderObj(p);
- messageFoldersMap.put(folderId,
newFolderId);
+ messageFolderMap.put(folderId,
newFolderId);
}
}
}
@@ -558,7 +580,7 @@ public class BackupImport {
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
- registry.bind(User.class, new UserConverter(userDao,
usersMap));
+ registry.bind(User.class, new UserConverter(userDao,
userMap));
List<UserContact> list = readList(serializer, f,
"userContacts.xml", "usercontacts", UserContact.class, true);
for (UserContact uc : list) {
@@ -571,7 +593,7 @@ public class BackupImport {
uc.setOwner(null);
}
uc = userContactDao.update(uc);
- userContactsMap.put(ucId, uc.getId());
+ userContactMap.put(ucId, uc.getId());
}
}
}
@@ -585,8 +607,8 @@ public class BackupImport {
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
- registry.bind(User.class, new UserConverter(userDao,
usersMap));
- registry.bind(Room.class, new RoomConverter(roomDao,
roomsMap));
+ registry.bind(User.class, new UserConverter(userDao,
userMap));
+ registry.bind(Room.class, new RoomConverter(roomDao,
roomMap));
registry.bind(Date.class, DateConverter.class);
List<PrivateMessage> list = readList(serializer, f,
"privateMessages.xml", "privatemessages", PrivateMessage.class, true);
@@ -634,9 +656,9 @@ public class BackupImport {
// We need to reset this as openJPA reject to
store them otherwise
file.setId(null);
Long roomId = file.getRoomId();
- file.setRoomId(roomsMap.containsKey(roomId) ?
roomsMap.get(roomId) : null);
+ file.setRoomId(roomMap.containsKey(roomId) ?
roomMap.get(roomId) : null);
if (file.getOwnerId() != null) {
-
file.setOwnerId(usersMap.get(file.getOwnerId()));
+
file.setOwnerId(userMap.get(file.getOwnerId()));
}
if (file.getParentId() != null &&
file.getParentId().longValue() <= 0L) {
file.setParentId(null);
@@ -656,8 +678,8 @@ public class BackupImport {
Serializer serializer = new Persister(strategy,
matcher);
matcher.bind(Integer.class, IntegerTransform.class);
- registry.bind(User.class, new UserConverter(userDao,
usersMap));
- registry.bind(Room.class, new RoomConverter(roomDao,
roomsMap));
+ registry.bind(User.class, new UserConverter(userDao,
userMap));
+ registry.bind(Room.class, new RoomConverter(roomDao,
roomMap));
registry.bind(RoomPoll.Type.class,
PollTypeConverter.class);
registry.bind(Date.class, DateConverter.class);
@@ -873,8 +895,8 @@ public class BackupImport {
Strategy strategy = new RegistryStrategy(registry);
Serializer ser = new Persister(strategy);
- registry.bind(User.class, new UserConverter(userDao, usersMap));
- registry.bind(Appointment.class, new
AppointmentConverter(appointmentDao, appointmentsMap));
+ registry.bind(User.class, new UserConverter(userDao, userMap));
+ registry.bind(Appointment.class, new
AppointmentConverter(appointmentDao, appointmentMap));
File xml = new File(baseDir, filename);
if (!xml.exists()) {
@@ -1090,7 +1112,7 @@ public class BackupImport {
matcher.bind(Long.class, LongTransform.class);
matcher.bind(Integer.class, IntegerTransform.class);
- registry.bind(User.class, new UserConverter(userDao,
usersMap));
+ registry.bind(User.class, new UserConverter(userDao,
userMap));
registry.bind(Room.Type.class, RoomTypeConverter.class);
InputNode root = NodeBuilder.read(new
FileInputStream(xml));
@@ -1214,8 +1236,8 @@ public class BackupImport {
Long newId = null;
switch (map) {
case USERS:
- if (usersMap.containsKey(oldId)) {
- newId = usersMap.get(oldId);
+ if (userMap.containsKey(oldId)) {
+ newId = userMap.get(oldId);
}
break;
case ORGANISATIONS:
@@ -1224,23 +1246,23 @@ public class BackupImport {
}
break;
case APPOINTMENTS:
- if (appointmentsMap.containsKey(oldId)) {
- newId = appointmentsMap.get(oldId);
+ if (appointmentMap.containsKey(oldId)) {
+ newId = appointmentMap.get(oldId);
}
break;
case ROOMS:
- if (roomsMap.containsKey(oldId)) {
- newId = roomsMap.get(oldId);
+ if (roomMap.containsKey(oldId)) {
+ newId = roomMap.get(oldId);
}
break;
case MESSAGEFOLDERS:
- if (messageFoldersMap.containsKey(oldId)) {
- newId = messageFoldersMap.get(oldId);
+ if (messageFolderMap.containsKey(oldId)) {
+ newId = messageFolderMap.get(oldId);
}
break;
case USERCONTACTS:
- if (userContactsMap.containsKey(oldId)) {
- newId = userContactsMap.get(oldId);
+ if (userContactMap.containsKey(oldId)) {
+ newId = userContactMap.get(oldId);
}
break;
default:
Added:
openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/backup/OmCalendarConverter.java
URL:
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/backup/OmCalendarConverter.java?rev=1763442&view=auto
==============================================================================
---
openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/backup/OmCalendarConverter.java
(added)
+++
openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/backup/OmCalendarConverter.java
Wed Oct 5 12:38:07 2016
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") + you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.backup;
+
+import java.util.Map;
+
+import org.apache.openmeetings.db.dao.calendar.OmCalendarDao;
+import org.apache.openmeetings.db.entity.calendar.OmCalendar;
+import org.simpleframework.xml.stream.InputNode;
+import org.simpleframework.xml.stream.OutputNode;
+
+public class OmCalendarConverter extends OmConverter<OmCalendar> {
+ private OmCalendarDao calendarDao;
+ private Map<Long, Long> idMap;
+
+ public OmCalendarConverter() {
+ //default constructor is for export
+ }
+
+ public OmCalendarConverter(OmCalendarDao calendarDao, Map<Long, Long>
idMap) {
+ this.calendarDao = calendarDao;
+ this.idMap = idMap;
+ }
+
+ @Override
+ public OmCalendar read(InputNode node) throws Exception {
+ long oldId = getLong(node);
+ Long newId = idMap.containsKey(oldId) ? idMap.get(oldId) :
oldId;
+
+ OmCalendar c = calendarDao.get(newId);
+ return c == null ? new OmCalendar() : c;
+ }
+
+ @Override
+ public void write(OutputNode node, OmCalendar value) throws Exception {
+ node.setData(true);
+ node.setValue(value == null ? "0" : "" + value.getId());
+ }
+}
\ No newline at end of file
Modified:
openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/caldav/AppointmentManager.java
URL:
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/caldav/AppointmentManager.java?rev=1763442&r1=1763441&r2=1763442&view=diff
==============================================================================
---
openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/caldav/AppointmentManager.java
(original)
+++
openmeetings/application/trunk/openmeetings-service/src/main/java/org/apache/openmeetings/service/calendar/caldav/AppointmentManager.java
Wed Oct 5 12:38:07 2016
@@ -197,10 +197,10 @@ public class AppointmentManager {
}
/**
- * @see OmCalendarDao#get(Long)
+ * @see OmCalendarDao#getByUser(Long)
*/
public List<OmCalendar> getCalendars(Long userid) {
- return calendarDao.get(userid);
+ return calendarDao.getByUser(userid);
}
/**
Modified:
openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestOmCalendar.java
URL:
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestOmCalendar.java?rev=1763442&r1=1763441&r2=1763442&view=diff
==============================================================================
---
openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestOmCalendar.java
(original)
+++
openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestOmCalendar.java
Wed Oct 5 12:38:07 2016
@@ -52,7 +52,7 @@ public class TestOmCalendar extends Abst
assertTrue("Saved calendar should have valid id: " +
calendar.getId(),
calendar.getId() != null && calendar.getId() >
0);
- OmCalendar c = calendarDao.getCalendarbyId(calendar.getId());
+ OmCalendar c = calendarDao.get(calendar.getId());
assertNotNull("Failed to find Calendar by id", c);
}
}