From: rkv Date: Tue, 19 Mar 2013 08:57:33 +0000 (+0000) Subject: Satisfy some PMD requirements. X-Git-Tag: Root_Delivery2_2013_04_22~88 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=377f67d3435d24df005c2b6610517f632d911c53;p=tools%2Fsiman.git Satisfy some PMD requirements. --- diff --git a/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java index eccbccc..2d2a2db 100644 --- a/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java @@ -72,6 +72,10 @@ public class SearchServiceImpl implements SearchService { */ public final static Logger LOG = Logger .getLogger(org.splat.service.SearchServiceImpl.class); + /** + * "title" property name. + */ + private final static String PROP_TITLE = "title"; /** * Injected repository service. @@ -185,7 +189,7 @@ public class SearchServiceImpl implements SearchService { // Group by study query.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); // Creation of the sort criteria - query.addOrder(Order.asc("title")); + query.addOrder(Order.asc(PROP_TITLE)); if (LOG.isInfoEnabled()) { LOG.info("Searching knowledge elements: \"" + query.toString()); @@ -226,7 +230,7 @@ public class SearchServiceImpl implements SearchService { String[] word = title.split(" "); for (int j = 0; j < word.length; j++) { - critext.add(Restrictions.like("title", "%" + word[j] + "%")); + critext.add(Restrictions.like(PROP_TITLE, "%" + word[j] + "%")); } topJunction.add(critext); } @@ -272,7 +276,7 @@ public class SearchServiceImpl implements SearchService { // Group by study query.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); // Creation of the sort criteria - query.addOrder(Order.asc("title")); + query.addOrder(Order.asc(PROP_TITLE)); if (LOG.isInfoEnabled()) { LOG.info("Searching studies: \"" + query.toString()); @@ -578,7 +582,7 @@ public class SearchServiceImpl implements SearchService { filter.add(new FilterClause(select, BooleanClause.Occur.SHOULD)); // Creation of the sort criteria - Sort sort = new Sort(new SortField("title", SortField.STRING)); + Sort sort = new Sort(new SortField(PROP_TITLE, SortField.STRING)); // Search TopFieldDocs found = searcher.search(fulquery, filter, hitsize, diff --git a/Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java index aed2ea4..9d933d2 100644 --- a/Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java @@ -11,7 +11,6 @@ package org.splat.service; import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.hibernate.criterion.Restrictions; @@ -55,7 +54,6 @@ import org.splat.som.Step; import org.splat.util.BeanHelper; import org.springframework.transaction.annotation.Transactional; - /** * Step service implementation. * @@ -126,8 +124,7 @@ public class StepServiceImpl implements StepService { * Injected user DAO. */ private UserDAO _userDAO; - - + /** * {@inheritDoc} * @@ -190,20 +187,10 @@ public class StepServiceImpl implements StepService { } else { scenarii = aStep.getOwnerStudy().getScenarii(); } -// try { - for (int i = 0; i < scenarii.length; i++) { - Scenario scene = scenarii[i]; - List knelm = scene.getAllKnowledgeElements(); - for (Iterator 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); + } } /** @@ -211,22 +198,16 @@ public class StepServiceImpl implements StepService { * * @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 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()); } /** @@ -407,9 +388,9 @@ public class StepServiceImpl implements StepService { } if (newFormat != null - /*&& previous.getType().equals( - getProjectSettings().getDefaultDocumentType( - aStep.getStep(), newFormat))*/) { + /* + * && previous.getType().equals( getProjectSettings().getDefaultDocumentType( aStep.getStep(), newFormat)) + */) { dprop.setFormat(newFormat); } @@ -558,126 +539,142 @@ public class StepServiceImpl implements StepService { } 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 getStepComments(final Step step) throws InvalidParameterException { + public List 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 comments = _stepCommentAttributeDAO.getFilteredList( - Restrictions.and( - Restrictions.eq("step", Integer.valueOf(step.getNumber())), - Restrictions.eq("owner", owner))); + List comments = _stepCommentAttributeDAO + .getFilteredList(Restrictions.and(Restrictions.eq("step", + Integer.valueOf(step.getNumber())), Restrictions.eq( + "owner", owner))); List commentDTOs = new ArrayList(); - 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. * @@ -861,7 +858,7 @@ public class StepServiceImpl implements StepService { private ProjectSettingsService getProjectSettings() { return _projectSettings; } - + /** * Set project settings service. * @@ -872,9 +869,10 @@ public class StepServiceImpl implements StepService { final ProjectSettingsService projectSettingsService) { _projectSettings = projectSettingsService; } - + /** * Get the stepCommentAttributeDAO. + * * @return the stepCommentAttributeDAO */ public StepCommentAttributeDAO getStepCommentAttributeDAO() { @@ -883,7 +881,9 @@ public class StepServiceImpl implements StepService { /** * Set the stepCommentAttributeDAO. - * @param commentAttributeDAO the stepCommentAttributeDAO to set + * + * @param commentAttributeDAO + * the stepCommentAttributeDAO to set */ public void setStepCommentAttributeDAO( final StepCommentAttributeDAO commentAttributeDAO) { @@ -892,14 +892,18 @@ public class StepServiceImpl implements StepService { /** * 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; diff --git a/Workspace/Siman-Common/src/org/splat/service/StudyService.java b/Workspace/Siman-Common/src/org/splat/service/StudyService.java index 347a0db..3e644a7 100644 --- a/Workspace/Siman-Common/src/org/splat/service/StudyService.java +++ b/Workspace/Siman-Common/src/org/splat/service/StudyService.java @@ -9,7 +9,6 @@ package org.splat.service; -import java.util.Date; import java.util.List; import org.splat.dal.bo.kernel.User; diff --git a/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java index fa31d39..5cd8631 100644 --- a/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java @@ -107,6 +107,10 @@ public class StudyServiceImpl implements StudyService { */ public final static AppLogger LOG = AppLogger .getLogger(StudyServiceImpl.class); + /** + * "studyId" parameter name. + */ + public final static String PARAM_STUDY_ID = "studyId"; /** * Injected index service. @@ -1168,11 +1172,11 @@ public class StudyServiceImpl implements StudyService { public String getDescription(final Long studyId) throws InvalidParameterException { if (studyId == null) { - throw new InvalidParameterException("studyId", "null"); + throw new InvalidParameterException(PARAM_STUDY_ID, "null"); } Study study = _studyDAO.get(studyId); if (study == null) { - throw new InvalidParameterException("studyId", studyId.toString()); + throw new InvalidParameterException(PARAM_STUDY_ID, studyId.toString()); } return study.getDescription(); } @@ -1187,11 +1191,11 @@ public class StudyServiceImpl implements StudyService { public void setDescription(final Long studyId, final String descriptionText) throws InvalidParameterException { if (studyId == null) { - throw new InvalidParameterException("studyId", "null"); + throw new InvalidParameterException(PARAM_STUDY_ID, "null"); } Study study = _studyDAO.get(studyId); if (study == null) { - throw new InvalidParameterException("studyId", studyId.toString()); + throw new InvalidParameterException(PARAM_STUDY_ID, studyId.toString()); } study.setAttribute(new DescriptionAttribute(study, descriptionText)); } @@ -1206,12 +1210,12 @@ public class StudyServiceImpl implements StudyService { public boolean removeDescription(final Long studyId) throws InvalidParameterException { if (studyId == null) { - throw new InvalidParameterException("studyId", String + throw new InvalidParameterException(PARAM_STUDY_ID, String .valueOf(studyId)); } Study study = _studyDAO.get(studyId); if (study == null) { - throw new InvalidParameterException("studyId", String + throw new InvalidParameterException(PARAM_STUDY_ID, String .valueOf(studyId)); } return study.removeAttribute(study