use of org.apache.openmeetings.db.entity.room.RoomPollAnswer in project openmeetings by apache.
the class VoteDialog method updateModel.
public void updateModel(IPartialPageRequestHandler target, RoomPoll rp) {
RoomPollAnswer a = new RoomPollAnswer();
a.setRoomPoll(rp);
User u = userDao.get(getUserId());
a.setVotedUser(u);
user.setObject(getName(this, a.getRoomPoll().getCreator()));
form.setModelObject(a);
boolean typeNum = a.getRoomPoll() != null && RoomPoll.Type.numeric == a.getRoomPoll().getType();
form.typeBool.setVisible(!typeNum);
form.typeInt.setVisible(typeNum);
target.add(form);
}
use of org.apache.openmeetings.db.entity.room.RoomPollAnswer in project openmeetings by apache.
the class BackupImport method importPolls.
/*
* ##################### Import Room Polls
*/
private void importPolls(File f) throws Exception {
log.info("File explorer item import complete, starting room poll import");
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
RegistryMatcher matcher = new RegistryMatcher();
Serializer serializer = new Persister(strategy, matcher);
matcher.bind(Integer.class, IntegerTransform.class);
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);
List<RoomPoll> list = readList(serializer, f, "roompolls.xml", "roompolls", RoomPoll.class);
for (RoomPoll rp : list) {
rp.setId(null);
if (rp.getRoom() == null || rp.getRoom().getId() == null) {
// room was deleted
continue;
}
if (rp.getCreator() == null || rp.getCreator().getId() == null) {
rp.setCreator(null);
}
for (RoomPollAnswer rpa : rp.getAnswers()) {
if (rpa.getVotedUser() == null || rpa.getVotedUser().getId() == null) {
rpa.setVotedUser(null);
}
}
pollDao.update(rp);
}
}
use of org.apache.openmeetings.db.entity.room.RoomPollAnswer in project openmeetings by apache.
the class VoteDialog method onInitialize.
@Override
protected void onInitialize() {
getTitle().setObject(getString("18"));
add(form = new PollAnswerForm("form", new CompoundPropertyModel<>(new RoomPollAnswer())));
vote = new DialogButton("vote", getString("32"));
cancel = new DialogButton("cancel", getString("lbl.cancel"));
super.onInitialize();
}
use of org.apache.openmeetings.db.entity.room.RoomPollAnswer in project openmeetings by apache.
the class VoteDialog method onSubmit.
/* (non-Javadoc)
* @see com.googlecode.wicket.jquery.ui.widget.dialog.AbstractFormDialog#onSubmit(org.apache.wicket.ajax.AjaxRequestTarget)
*/
@Override
protected void onSubmit(AjaxRequestTarget target) {
RoomPollAnswer a = form.getModelObject();
Long roomId = a.getRoomPoll().getRoom().getId();
if (!pollDao.hasVoted(roomId, getUserId())) {
a.setVoteDate(new Date());
a.getRoomPoll().getAnswers().add(a);
pollDao.update(a.getRoomPoll());
}
sendRoom(new RoomMessage(roomId, findParent(MainPanel.class).getClient(), RoomMessage.Type.pollUpdated));
}
Aggregations