@Override public PollsChoice addChoice( long userId, long questionId, String name, String description, ServiceContext serviceContext) throws PortalException { validate(name, description); User user = userPersistence.findByPrimaryKey(userId); Date now = new Date(); long choiceId = counterLocalService.increment(); PollsChoice choice = pollsChoicePersistence.create(choiceId); choice.setUuid(serviceContext.getUuid()); choice.setGroupId(serviceContext.getScopeGroupId()); choice.setCompanyId(user.getCompanyId()); choice.setUserId(user.getUserId()); choice.setUserName(user.getFullName()); choice.setCreateDate(serviceContext.getCreateDate(now)); choice.setModifiedDate(serviceContext.getModifiedDate(now)); choice.setQuestionId(questionId); choice.setName(name); choice.setDescription(description); pollsChoicePersistence.update(choice); return choice; }
/** * Converts the soap model instance into a normal model instance. * * @param soapModel the soap model instance to convert * @return the normal model instance */ public static PollsChoice toModel(PollsChoiceSoap soapModel) { if (soapModel == null) { return null; } PollsChoice model = new PollsChoiceImpl(); model.setUuid(soapModel.getUuid()); model.setPollsChoiceId(soapModel.getPollsChoiceId()); model.setPollsQuestionId(soapModel.getPollsQuestionId()); model.setName(soapModel.getName()); model.setDescription(soapModel.getDescription()); return model; }
@Override public PollsChoice updateChoice( long choiceId, long questionId, String name, String description, ServiceContext serviceContext) throws PortalException { validate(name, description); pollsQuestionPersistence.findByPrimaryKey(questionId); PollsChoice choice = pollsChoicePersistence.findByPrimaryKey(choiceId); choice.setModifiedDate(serviceContext.getModifiedDate(null)); choice.setQuestionId(questionId); choice.setName(name); choice.setDescription(description); pollsChoicePersistence.update(choice); return choice; }