import java.io.IOException;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.hibernate.criterion.Restrictions;
import org.splat.util.BeanHelper;
import org.springframework.transaction.annotation.Transactional;
-
/**
* Step service implementation.
*
* Injected user DAO.
*/
private UserDAO _userDAO;
-
-
+
/**
* {@inheritDoc}
*
} else {
scenarii = aStep.getOwnerStudy().getScenarii();
}
-// try {
- for (int i = 0; i < scenarii.length; i++) {
- Scenario scene = scenarii[i];
- List<KnowledgeElement> knelm = scene.getAllKnowledgeElements();
- for (Iterator<KnowledgeElement> j = knelm.iterator(); j
- .hasNext();) {
- KnowledgeElement kelm = j.next();
-// getIndexService().update(kelm);
- }
- updateScenarioIndex(scene);
- }
-// } catch (Exception error) {
-// LOG.error("Unable to re-index Knowledge Elements, reason:", error);
-// }
+ for (int i = 0; i < scenarii.length; i++) {
+ Scenario scene = scenarii[i];
+ updateScenarioIndex(scene);
+ }
}
/**
*
* @param scene
* the scenario
- * @throws IOException
- * if can't update lucene index
*/
- private void updateScenarioIndex(final Scenario scene) /*throws IOException*/ {
+ private void updateScenarioIndex(final Scenario scene) {
if (scene.getUcase() == null) {
- for (Iterator<KnowledgeElement> i = scene.getKnowledgeElements()
- .iterator(); i.hasNext();) {
- KnowledgeElement kelm = i.next();
- if (!kelm.getType().equals("usecase")) {
- continue;
+ for (KnowledgeElement kelm : scene.getKnowledgeElements()) {
+ if (kelm.getType().equals("usecase")) {
+ scene.setUcase(kelm);
+ break;
}
- scene.setUcase(kelm);
- break;
}
}
-// getIndexService().update(scene.getUcase());
}
/**
}
if (newFormat != null
- /*&& previous.getType().equals(
- getProjectSettings().getDefaultDocumentType(
- aStep.getStep(), newFormat))*/) {
+ /*
+ * && previous.getType().equals( getProjectSettings().getDefaultDocumentType( aStep.getStep(), newFormat))
+ */) {
dprop.setFormat(newFormat);
}
}
return res;
}
-
+
/**
* {@inheritDoc}
- *
+ *
* @see org.splat.service.StepService#addComment(org.splat.som.Step, org.splat.dal.bo.som.CommentAttribute)
*/
@Override
@Transactional
- public void addStepComment(final StepCommentDTO comment) throws InvalidParameterException {
+ public void addStepComment(final StepCommentDTO comment)
+ throws InvalidParameterException {
- if(comment.getId()!= null) {
- throw new InvalidParameterException("id", String.valueOf(comment.getId()));
+ if (comment.getId() != null) {
+ throw new InvalidParameterException("id", String.valueOf(comment
+ .getId()));
}
User user = getUserDAO().get(comment.getUserId());
if (user == null) {
- throw new InvalidParameterException("userId", String.valueOf(comment.getUserId()));
+ throw new InvalidParameterException("userId", String
+ .valueOf(comment.getUserId()));
}
- ProjectElement projectElement = getProjectElementDAO().get(comment.getProjectElementId());
- if (projectElement==null) {
- throw new InvalidParameterException("projectElementId", comment.getProjectElementId().toString());
+ ProjectElement projectElement = getProjectElementDAO().get(
+ comment.getProjectElementId());
+ if (projectElement == null) {
+ throw new InvalidParameterException("projectElementId", comment
+ .getProjectElementId().toString());
}
- if(comment.getStep() == null || comment.getStep()<0) {
- throw new InvalidParameterException("step", String.valueOf(comment.getStep()));
+ if (comment.getStep() == null || comment.getStep() < 0) {
+ throw new InvalidParameterException("step", String.valueOf(comment
+ .getStep()));
}
- if(comment.getDate() == null) {
- throw new InvalidParameterException("date", String.valueOf(comment.getDate()));
+ if (comment.getDate() == null) {
+ throw new InvalidParameterException("date", String.valueOf(comment
+ .getDate()));
}
- if(comment.getTitle() == null) {
- throw new InvalidParameterException("title", String.valueOf(comment.getTitle()));
+ if (comment.getTitle() == null) {
+ throw new InvalidParameterException("title", String.valueOf(comment
+ .getTitle()));
}
StepCommentAttribute newComment = new StepCommentAttribute(
- projectElement,
- comment.getText(),
- comment.getDate(),
- comment.getStep(),
- user,
- comment.getTitle()
- );
-
- Long resultKey=getStepCommentAttributeDAO().create(newComment);
+ projectElement, comment.getText(), comment.getDate(), comment
+ .getStep(), user, comment.getTitle());
+
+ Long resultKey = getStepCommentAttributeDAO().create(newComment);
comment.setId(resultKey);
}
/**
* {@inheritDoc}
+ *
* @see org.splat.service.StepService#getStepComments(org.splat.som.Step)
*/
@Override
@Transactional(readOnly = true)
- public List<StepCommentDTO> getStepComments(final Step step) throws InvalidParameterException {
+ public List<StepCommentDTO> getStepComments(final Step step)
+ throws InvalidParameterException {
ProjectElement owner = _projectElementDAO.get(step.getOwner().getRid());
- if(owner == null) {
- throw new InvalidParameterException("step owner id",
- Long.valueOf(step.getOwner().getRid()).toString());
+ if (owner == null) {
+ throw new InvalidParameterException("step owner id", Long.valueOf(
+ step.getOwner().getRid()).toString());
}
- List<StepCommentAttribute> comments = _stepCommentAttributeDAO.getFilteredList(
- Restrictions.and(
- Restrictions.eq("step", Integer.valueOf(step.getNumber())),
- Restrictions.eq("owner", owner)));
+ List<StepCommentAttribute> comments = _stepCommentAttributeDAO
+ .getFilteredList(Restrictions.and(Restrictions.eq("step",
+ Integer.valueOf(step.getNumber())), Restrictions.eq(
+ "owner", owner)));
List<StepCommentDTO> commentDTOs = new ArrayList<StepCommentDTO>();
- for(StepCommentAttribute comment : comments) {
- StepCommentDTO stepCommentDTO = BeanHelper.copyBean(comment, StepCommentDTO.class);
- stepCommentDTO.setText(comment.getValue());
- stepCommentDTO.setId(Long.valueOf(comment.getRid()));
- commentDTOs.add(stepCommentDTO);
+ for (StepCommentAttribute comment : comments) {
+ StepCommentDTO stepCommentDTO = BeanHelper.copyBean(comment,
+ StepCommentDTO.class);
+ stepCommentDTO.setText(comment.getValue());
+ stepCommentDTO.setId(Long.valueOf(comment.getRid()));
+ commentDTOs.add(stepCommentDTO);
}
return commentDTOs;
}
/**
* {@inheritDoc}
+ *
* @see org.splat.service.StepService#removeStepComment(long)
*/
@Override
@Transactional
- public void removeStepComment(final long commentId) throws InvalidParameterException {
- StepCommentAttribute stepComment = _stepCommentAttributeDAO.get(Long.valueOf(commentId));
- if(stepComment == null) {
- throw new InvalidParameterException("commentId",String.valueOf(commentId));
+ public void removeStepComment(final long commentId)
+ throws InvalidParameterException {
+ StepCommentAttribute stepComment = _stepCommentAttributeDAO.get(Long
+ .valueOf(commentId));
+ if (stepComment == null) {
+ throw new InvalidParameterException("commentId", String
+ .valueOf(commentId));
}
_stepCommentAttributeDAO.delete(stepComment);
}
- /**
+ /**
* {@inheritDoc}
+ *
* @see org.splat.service.StepService#editStepComment(long, java.lang.String, java.lang.String)
*/
@Override
@Transactional
- public void editStepComment(final long commentId, final String newValue, final String newTitle)
- throws InvalidParameterException {
- StepCommentAttribute comment = _stepCommentAttributeDAO.get(Long.valueOf(commentId));
- if(comment == null) {
- throw new InvalidParameterException("commentId",String.valueOf(commentId));
+ public void editStepComment(final long commentId, final String newValue,
+ final String newTitle) throws InvalidParameterException {
+ StepCommentAttribute comment = _stepCommentAttributeDAO.get(Long
+ .valueOf(commentId));
+ if (comment == null) {
+ throw new InvalidParameterException("commentId", String
+ .valueOf(commentId));
}
- if(newTitle != null) {
+ if (newTitle != null) {
comment.setTitle(newTitle);
}
- if(newValue != null) {
+ if (newValue != null) {
comment.setValue(newValue);
}
_stepCommentAttributeDAO.update(comment);
}
- /**
+ /**
* {@inheritDoc}
+ *
* @see org.splat.service.StepService#isCommentMadeByUser(long, long)
*/
@Override
@Transactional(readOnly = true)
public boolean isCommentMadeByUser(final long commentId, final long userId)
throws InvalidParameterException {
- StepCommentAttribute comment = _stepCommentAttributeDAO.get(Long.valueOf(commentId));
- if(comment == null) {
- throw new InvalidParameterException("commentId", String.valueOf(commentId));
+ StepCommentAttribute comment = _stepCommentAttributeDAO.get(Long
+ .valueOf(commentId));
+ if (comment == null) {
+ throw new InvalidParameterException("commentId", String
+ .valueOf(commentId));
}
return comment.getUser().getIndex() == userId;
}
-
+
/**
* Get the documentService.
*
private ProjectSettingsService getProjectSettings() {
return _projectSettings;
}
-
+
/**
* Set project settings service.
*
final ProjectSettingsService projectSettingsService) {
_projectSettings = projectSettingsService;
}
-
+
/**
* Get the stepCommentAttributeDAO.
+ *
* @return the stepCommentAttributeDAO
*/
public StepCommentAttributeDAO getStepCommentAttributeDAO() {
/**
* Set the stepCommentAttributeDAO.
- * @param commentAttributeDAO the stepCommentAttributeDAO to set
+ *
+ * @param commentAttributeDAO
+ * the stepCommentAttributeDAO to set
*/
public void setStepCommentAttributeDAO(
final StepCommentAttributeDAO commentAttributeDAO) {
/**
* Get the userDAO.
+ *
* @return the userDAO
*/
public UserDAO getUserDAO() {
return _userDAO;
}
+
/**
* Set the userDAO.
- * @param userDAO the userDAO to set
+ *
+ * @param userDAO
+ * the userDAO to set
*/
public void setUserDAO(final UserDAO userDAO) {
_userDAO = userDAO;