Search in sources :

Example 1 with RoomPollAnswer

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);
}
Also used : User(org.apache.openmeetings.db.entity.user.User) RoomPollAnswer(org.apache.openmeetings.db.entity.room.RoomPollAnswer)

Example 2 with RoomPollAnswer

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);
    }
}
Also used : UserConverter(org.apache.openmeetings.backup.converter.UserConverter) RoomConverter(org.apache.openmeetings.backup.converter.RoomConverter) RoomPollAnswer(org.apache.openmeetings.db.entity.room.RoomPollAnswer) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) RegistryMatcher(org.simpleframework.xml.transform.RegistryMatcher) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) RoomPoll(org.apache.openmeetings.db.entity.room.RoomPoll) Serializer(org.simpleframework.xml.Serializer)

Example 3 with RoomPollAnswer

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();
}
Also used : DialogButton(com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton) RoomPollAnswer(org.apache.openmeetings.db.entity.room.RoomPollAnswer)

Example 4 with RoomPollAnswer

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));
}
Also used : MainPanel(org.apache.openmeetings.web.common.MainPanel) RoomMessage(org.apache.openmeetings.db.util.ws.RoomMessage) RoomPollAnswer(org.apache.openmeetings.db.entity.room.RoomPollAnswer) Date(java.util.Date)

Aggregations

RoomPollAnswer (org.apache.openmeetings.db.entity.room.RoomPollAnswer)4 DialogButton (com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton)1 Date (java.util.Date)1 RoomConverter (org.apache.openmeetings.backup.converter.RoomConverter)1 UserConverter (org.apache.openmeetings.backup.converter.UserConverter)1 RoomPoll (org.apache.openmeetings.db.entity.room.RoomPoll)1 User (org.apache.openmeetings.db.entity.user.User)1 RoomMessage (org.apache.openmeetings.db.util.ws.RoomMessage)1 MainPanel (org.apache.openmeetings.web.common.MainPanel)1 Serializer (org.simpleframework.xml.Serializer)1 Registry (org.simpleframework.xml.convert.Registry)1 RegistryStrategy (org.simpleframework.xml.convert.RegistryStrategy)1 Persister (org.simpleframework.xml.core.Persister)1 Strategy (org.simpleframework.xml.strategy.Strategy)1 RegistryMatcher (org.simpleframework.xml.transform.RegistryMatcher)1