@Override protected void addStagedModels() throws Exception { PollsQuestion question = PollsTestUtil.addQuestion(stagingGroup.getGroupId()); PollsChoice choice = PollsTestUtil.addChoice(stagingGroup.getGroupId(), question.getQuestionId()); PollsTestUtil.addVote( stagingGroup.getGroupId(), question.getQuestionId(), choice.getChoiceId()); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } PollsChoice pollsChoice = null; try { pollsChoice = (PollsChoice) obj; } catch (ClassCastException cce) { return false; } long primaryKey = pollsChoice.getPrimaryKey(); if (getPrimaryKey() == primaryKey) { return true; } else { return false; } }
public int compareTo(PollsChoice pollsChoice) { int value = 0; if (getPollsQuestionId() < pollsChoice.getPollsQuestionId()) { value = -1; } else if (getPollsQuestionId() > pollsChoice.getPollsQuestionId()) { value = 1; } else { value = 0; } if (value != 0) { return value; } value = getName().compareTo(pollsChoice.getName()); if (value != 0) { return value; } return 0; }
@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; }
/** * 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 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; }