From: mka Date: Thu, 14 Mar 2013 11:20:23 +0000 (+0000) Subject: Studies comparison functionality is implemented. X-Git-Tag: Root_Delivery2_2013_04_22~100 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1ba46da65ce8b7823a8d01870d3c0db1c7ed85ab;p=tools%2Fsiman.git Studies comparison functionality is implemented. --- diff --git a/Workspace/Siman-Common/src/org/splat/service/PublicationService.java b/Workspace/Siman-Common/src/org/splat/service/PublicationService.java index b3b4e4f..6279f2d 100644 --- a/Workspace/Siman-Common/src/org/splat/service/PublicationService.java +++ b/Workspace/Siman-Common/src/org/splat/service/PublicationService.java @@ -23,11 +23,13 @@ import org.splat.dal.bo.som.ProjectElement; import org.splat.dal.bo.som.Publication; import org.splat.dal.bo.som.Study; import org.splat.dal.bo.som.Timestamp; +import org.splat.exception.InvalidParameterException; import org.splat.kernel.InvalidPropertyException; import org.splat.kernel.MismatchException; import org.splat.kernel.MissedPropertyException; import org.splat.kernel.MultiplyDefinedException; import org.splat.kernel.NotApplicableException; +import org.splat.service.dto.DocToCompareDTO; import org.splat.som.DocumentRights; import org.splat.som.Revision; import org.splat.som.Step; @@ -295,4 +297,13 @@ public interface PublicationService { * @see #actualize() */ void outdate(Publication aPublication); + + + /** + * Get DocToCompareDTO by publication id. + * @param publicationId publication id + * @return DocToCompareDTO + * @throws InvalidParameterException if there is no document with such id. + */ + DocToCompareDTO getDocToCompareDTO(long publicationId) throws InvalidParameterException; } diff --git a/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java index 995b89a..29986c0 100644 --- a/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java @@ -38,6 +38,7 @@ import org.splat.dal.bo.som.ValidationStep; import org.splat.dal.dao.som.ProjectElementDAO; import org.splat.dal.dao.som.PublicationDAO; import org.splat.dal.dao.som.TimestampDAO; +import org.splat.exception.InvalidParameterException; import org.splat.kernel.InvalidPropertyException; import org.splat.kernel.MismatchException; import org.splat.kernel.MissedPropertyException; @@ -45,6 +46,7 @@ import org.splat.kernel.MultiplyDefinedException; import org.splat.kernel.NotApplicableException; import org.splat.manox.Reader; import org.splat.manox.Toolbox; +import org.splat.service.dto.DocToCompareDTO; import org.splat.service.technical.RepositoryService; import org.splat.som.DocumentRights; import org.splat.som.Revision; @@ -742,6 +744,25 @@ public class PublicationServiceImpl implements PublicationService { getDocumentService().rename(aPublication.value(), title); } + /** + * {@inheritDoc} + * @see org.splat.service.PublicationService#getDocToCompareDTO(long) + */ + @Transactional(readOnly = true) + @Override + public DocToCompareDTO getDocToCompareDTO(final long publicationId) throws InvalidParameterException { + DocToCompareDTO res = new DocToCompareDTO(); + Publication pub = _publicationDAO.get(Long.valueOf(publicationId)); + if(pub == null) { + throw new InvalidParameterException("id", String.valueOf(publicationId)); + } + //res.setPathToFile(_documentService.getSaveDirectory(pub.value()).getAbsolutePath()); + res.setPathToFile(pub.value().getFile().asFile().getAbsolutePath()); + res.setScenarioTitle(pub.getOwner().getTitle()); //!!!!! + res.setStudyTitle(pub.getOwnerStudy().getTitle()); + return res; + } + /** * Get the projectElementService. * diff --git a/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java index 24d624d..2d757e9 100644 --- a/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java @@ -27,6 +27,7 @@ import org.splat.dal.bo.kernel.Role; import org.splat.dal.bo.kernel.User; import org.splat.dal.bo.som.ConvertsRelation; import org.splat.dal.bo.som.Document; +import org.splat.dal.bo.som.Document.Properties; import org.splat.dal.bo.som.DocumentType; import org.splat.dal.bo.som.File; import org.splat.dal.bo.som.KnowledgeElement; @@ -39,7 +40,6 @@ import org.splat.dal.bo.som.SimulationContextType; import org.splat.dal.bo.som.Study; import org.splat.dal.bo.som.UsedByRelation; import org.splat.dal.bo.som.UsesRelation; -import org.splat.dal.bo.som.Document.Properties; import org.splat.dal.dao.kernel.RoleDAO; import org.splat.dal.dao.kernel.UserDAO; import org.splat.dal.dao.som.KnowledgeElementDAO; diff --git a/Workspace/Siman-Common/src/org/splat/service/StudyService.java b/Workspace/Siman-Common/src/org/splat/service/StudyService.java index 277ea77..9b7af70 100644 --- a/Workspace/Siman-Common/src/org/splat/service/StudyService.java +++ b/Workspace/Siman-Common/src/org/splat/service/StudyService.java @@ -22,9 +22,13 @@ import org.splat.dal.bo.som.Study.Properties; import org.splat.exception.IncompatibleDataException; import org.splat.exception.InvalidParameterException; import org.splat.kernel.InvalidPropertyException; +import org.splat.kernel.MismatchException; import org.splat.kernel.MissedPropertyException; import org.splat.kernel.MultiplyDefinedException; import org.splat.service.dto.DocToCompareDTO; +import org.splat.service.dto.DocumentDTO; +import org.splat.service.dto.StudyFacadeDTO; +import org.splat.service.dto.StudyFacadeDTO.ScenarioDTO; /** * This class defines all methods for creation, modification the study. @@ -181,7 +185,7 @@ public interface StudyService { * @see #isPublic() */ boolean moveToPublic(Study aStudy); - + /** * Moves this study from the Public to the Private area of the repository. * @@ -269,7 +273,7 @@ public interface StudyService { * @return the unmodifiable not null transient list of contributors of this study */ List getContributors(Study aStudy); - + /** * Mark study as reference. * @@ -277,7 +281,7 @@ public interface StudyService { * the Study */ void markStudyAsReference(Study aStudy); - + /** * Remove study as reference. This operation is inverse one to Mark as reference. * @@ -285,7 +289,18 @@ public interface StudyService { * the Study */ void removeStudyAsReference(Study aStudy); - + + /** + * Get studies, scenarios and publications available for comparison. + *
DocumentDto.id are actually filled in with Publication ids. + * @param userId id of the user to to whom visible studies will be returned. + * @return list of {@link StudyFacadeDTO} containing lists of {@link ScenarioDTO} containing list of + * {@link DocumentDTO}, corresponding to to the publications available for comparison, + * with ids and titles filled in. + * @throws MismatchException if some configurations considering postprocessing step are invalid. + */ + List getComparableStudies(final long userId) throws MismatchException; + /** * Get the description attribute related to the study (there supposed to be the only one such attribute in the database). * @@ -296,7 +311,7 @@ public interface StudyService { * if a study with such id does not exist in the database. */ String getDescription(Long studyId) throws InvalidParameterException; - + /** * Set the description attribute related to the study. * @@ -316,7 +331,7 @@ public interface StudyService { * @param studyId * the study id * @throws InvalidParameterException - * if no study with such Id has been found in the database. + * if no study with such Id has been found in the database. * @return true if succeeded, false if study doesn't have a description. */ boolean removeDescription(final Long studyId) @@ -330,7 +345,7 @@ public interface StudyService { * @param userName * the name of the user who compare the results. * @throws IncompatibleDataException - * if data is incompatible for "Compare the studies" functionality. + * if data is incompatible for "Compare the studies" functionality. * * @return path to result file in the vault. */ diff --git a/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java index 2e3fc45..7fd574b 100644 --- a/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java @@ -16,9 +16,11 @@ import java.io.FileOutputStream; import java.io.IOException; import java.text.DecimalFormat; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Date; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -27,7 +29,9 @@ import java.util.Set; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.store.FSDirectory; +import org.hibernate.Hibernate; import org.hibernate.criterion.Restrictions; +import org.hibernate.proxy.HibernateProxy; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PlotOrientation; @@ -42,15 +46,17 @@ import org.splat.dal.bo.som.DescriptionAttribute; import org.splat.dal.bo.som.DocumentType; import org.splat.dal.bo.som.IDBuilder; import org.splat.dal.bo.som.ProgressState; +import org.splat.dal.bo.som.ProjectElement; import org.splat.dal.bo.som.Publication; +import org.splat.dal.bo.som.Scenario; import org.splat.dal.bo.som.SimulationContext; import org.splat.dal.bo.som.Study; -import org.splat.dal.bo.som.Study.Properties; import org.splat.dal.bo.som.ValidationCycle; -import org.splat.dal.bo.som.ValidationCycle.Actor; import org.splat.dal.bo.som.ValidationCycleRelation; import org.splat.dal.bo.som.ValidationStep; import org.splat.dal.bo.som.Visibility; +import org.splat.dal.bo.som.Study.Properties; +import org.splat.dal.bo.som.ValidationCycle.Actor; import org.splat.dal.dao.som.DescriptionAttributeDAO; import org.splat.dal.dao.som.DocumentDAO; import org.splat.dal.dao.som.IDBuilderDAO; @@ -61,14 +67,18 @@ import org.splat.dal.dao.som.ValidationCycleDAO; import org.splat.exception.IncompatibleDataException; import org.splat.exception.InvalidParameterException; import org.splat.kernel.InvalidPropertyException; +import org.splat.kernel.MismatchException; import org.splat.kernel.MissedPropertyException; import org.splat.kernel.MultiplyDefinedException; import org.splat.log.AppLogger; import org.splat.service.dto.DocToCompareDTO; +import org.splat.service.dto.DocumentDTO; +import org.splat.service.dto.StudyFacadeDTO; import org.splat.service.technical.IndexService; import org.splat.service.technical.ProjectSettingsService; import org.splat.service.technical.ProjectSettingsServiceImpl; import org.splat.service.technical.RepositoryService; +import org.splat.service.technical.ProjectSettingsService.Step; import org.splat.som.Revision; import org.springframework.transaction.annotation.Transactional; @@ -80,7 +90,6 @@ import com.lowagie.text.pdf.PdfContentByte; import com.lowagie.text.pdf.PdfTemplate; import com.lowagie.text.pdf.PdfWriter; - /** * This class defines all methods for creation, modification the study. * @@ -144,7 +153,7 @@ public class StudyServiceImpl implements StudyService { * Injected user service. */ private UserService _userService; - + /** * Injected publication DAO. */ @@ -170,6 +179,7 @@ public class StudyServiceImpl implements StudyService { * * @see org.splat.service.StudyService#selectStudy(long) */ + @Override @Transactional public Study selectStudy(final long index) { Study result = getStudyDAO().get(index); @@ -188,7 +198,7 @@ public class StudyServiceImpl implements StudyService { getStudyDAO().delete(study); } } - + /** * Get study by its reference. * @@ -209,6 +219,7 @@ public class StudyServiceImpl implements StudyService { * * @see org.splat.service.StudyService#createStudy(org.splat.dal.bo.som.Study.Properties) */ + @Override @Transactional public Study createStudy(final Study.Properties sprop) throws MissedPropertyException, InvalidPropertyException, @@ -234,6 +245,7 @@ public class StudyServiceImpl implements StudyService { * * @see org.splat.service.StudyService#addProjectContext(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.SimulationContext.Properties) */ + @Override @Transactional public SimulationContext addProjectContext(final Study aStudy, final SimulationContext.Properties cprop) @@ -250,6 +262,7 @@ public class StudyServiceImpl implements StudyService { * * @see org.splat.service.StudyService#addProjectContext(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.SimulationContext) */ + @Override @Transactional public SimulationContext addProjectContext(final Study aStudy, final SimulationContext context) { @@ -264,6 +277,7 @@ public class StudyServiceImpl implements StudyService { * * @see org.splat.service.StudyService#addContributor(org.splat.dal.bo.som.Study, org.splat.dal.bo.kernel.User) */ + @Override public boolean addContributor(final Study aStudy, final User user) { List contributor = getModifiableContributors(aStudy); // Initializes contributor for (Iterator i = contributor.iterator(); i.hasNext();) { @@ -293,6 +307,7 @@ public class StudyServiceImpl implements StudyService { * @see #isPublic() * @see Publication#approve(Date) */ + @Override public boolean moveToReference(final Study aStudy) { if (aStudy.getProgressState() != ProgressState.APPROVED) { return false; @@ -313,6 +328,7 @@ public class StudyServiceImpl implements StudyService { * * @see org.splat.service.StudyService#update(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.Study.Properties) */ + @Override public boolean update(final Study aStudy, final Properties sprop) throws InvalidPropertyException { if (sprop.getTitle() != null) { @@ -352,6 +368,7 @@ public class StudyServiceImpl implements StudyService { * * @see org.splat.service.StudyService#removeContributor(org.splat.dal.bo.som.Study, org.splat.dal.bo.kernel.User[]) */ + @Override public boolean removeContributor(final Study aStudy, final User... users) { List contributor = getModifiableContributors(aStudy); // Initializes contributor Boolean done = false; @@ -380,6 +397,7 @@ public class StudyServiceImpl implements StudyService { * * @see org.splat.service.StudyService#removeProjectContext(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.SimulationContext) */ + @Override public boolean removeProjectContext(final Study aStudy, final SimulationContext context) { boolean done = getStepService().removeSimulationContext( @@ -394,6 +412,7 @@ public class StudyServiceImpl implements StudyService { * @see org.splat.service.StudyService#setValidationCycle(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.DocumentType, * org.splat.dal.bo.som.ValidationCycle.Properties) */ + @Override @Transactional public void setValidationCycle(final Study aStudyDTO, final DocumentType type, final ValidationCycle.Properties vprop) { @@ -438,6 +457,7 @@ public class StudyServiceImpl implements StudyService { * a study to demote * @return true if the demotion succeeded. */ + @Override public boolean demote(final Study aStudy) { if (aStudy.getProgressState() == ProgressState.inCHECK) { aStudy.setProgressState(ProgressState.inDRAFT); @@ -454,6 +474,7 @@ public class StudyServiceImpl implements StudyService { * * @see org.splat.service.StudyService#generateLocalIndex(org.splat.dal.bo.som.Study) */ + @Override @Transactional public int generateLocalIndex(final Study aStudy) { aStudy.setLastLocalIndex(aStudy.getLastLocalIndex() + 1); @@ -468,6 +489,7 @@ public class StudyServiceImpl implements StudyService { * a study to promote * @return true if the demotion succeeded. */ + @Override @Transactional public boolean promote(final Study aStudy) { if (aStudy.getProgressState() == ProgressState.inWORK) { @@ -496,6 +518,7 @@ public class StudyServiceImpl implements StudyService { * @return true if the move succeeded. * @see #isPublic() */ + @Override @Transactional public boolean moveToPublic(final Study aStudy) { boolean isOk = false; @@ -515,6 +538,7 @@ public class StudyServiceImpl implements StudyService { * a study to move * @return true if the move succeeded. */ + @Override @Transactional public boolean moveToPrivate(final Study aStudy) { boolean isOk = false; @@ -719,7 +743,7 @@ public class StudyServiceImpl implements StudyService { */ private IndexService getIndex() throws IOException { IndexService lucin = getIndexService(); - if (IndexWriter.isLocked(FSDirectory.open(getRepositoryService() + if (IndexWriter.isLocked(FSDirectory.open(getRepositoryService() .getRepositoryIndexDirectory()))) { IndexWriter.unlock(FSDirectory.open(getRepositoryService() .getRepositoryIndexDirectory())); @@ -896,6 +920,7 @@ public class StudyServiceImpl implements StudyService { * the study * @return the unmodifiable not null transient list of contributors of this study */ + @Override public List getContributors(final Study aStudy) { if (aStudy.getContributor() == null) { setShortCuts(aStudy); @@ -926,6 +951,7 @@ public class StudyServiceImpl implements StudyService { * the document type being subject of validation * @return the validation cycle of the document, or null if not defined. */ + @Override public ValidationCycle getValidationCycleOf(final Study aStudy, final DocumentType type) { if (aStudy.getValidationCycles() == null || aStudy.getValidationCycles().isEmpty()) { @@ -954,6 +980,7 @@ public class StudyServiceImpl implements StudyService { * @return true if the given user is actor of this study. * @see #getActors() */ + @Override public boolean hasActor(final Study aStudy, final User user) { if (user == null) { return false; @@ -977,6 +1004,7 @@ public class StudyServiceImpl implements StudyService { * @return true if the given user is actor of this study. * @see #getContributors() */ + @Override public boolean isStaffedBy(final Study aStudy, final User user) { if (user == null) { return false; @@ -1004,6 +1032,7 @@ public class StudyServiceImpl implements StudyService { * @param aStudy * the study */ + @Override public void loadWorkflow(final Study aStudy) { setShortCuts(aStudy); } @@ -1093,6 +1122,7 @@ public class StudyServiceImpl implements StudyService { getStudyDAO().merge(aStudy); } + /** * {@inheritDoc} * @see org.splat.service.StudyService#getDescription(java.lang.Long) @@ -1128,8 +1158,8 @@ public class StudyServiceImpl implements StudyService { } study.setAttribute(new DescriptionAttribute(study, descriptionText)); } - - /** + + /** * {@inheritDoc} * @see org.splat.service.StudyService#removeStudyDescription(java.lang.Long) */ @@ -1145,6 +1175,7 @@ public class StudyServiceImpl implements StudyService { } return study.removeAttribute(study.getAttribute(DescriptionAttribute.class)); } + /** * @@ -1152,7 +1183,7 @@ public class StudyServiceImpl implements StudyService { * @see org.splat.service.StudyService#compare(java.util.List) */ @Override - public String compare (final List docsList, final String userName) throws IncompatibleDataException { + public String compare (final List docsList, final String userName) throws IncompatibleDataException{ String axis1Name = ""; String axis2Name = ""; @@ -1179,7 +1210,7 @@ public class StudyServiceImpl implements StudyService { //get the name of the axis. if (input.hasNext()) { String[] tokens = input.nextLine().split(","); - + if (tokens.length < 2) throw new IncompatibleDataException(MessageKeyEnum.IDT_000001.toString()); @@ -1264,7 +1295,7 @@ public class StudyServiceImpl implements StudyService { return resultPath; } - + /** * Get project settings. * @@ -1458,7 +1489,105 @@ public class StudyServiceImpl implements StudyService { public void setUserService(final UserService userService) { _userService = userService; } + + /** + * {@inheritDoc} + * + * @see org.splat.service.StudyService#getComparableStudies() + */ + @Transactional(readOnly = true) + public List getComparableStudies(final long userId) throws MismatchException { + //retrieve the number of the "Analyze the results" step + List allSteps = _projectSettings.getAllSteps(); + Step theAnalyzeStep = null; + for(Step step : allSteps) { + if(step.getKey().equals("postprocessing")) { + theAnalyzeStep = step; + } + } + if(theAnalyzeStep == null) { //TODO: throw some other exception + throw new MismatchException("no step with key 'postprocessing' found." + + "Probably, customization settings have been changed."); + } + + List publications = _publicationDAO.getFilteredList("mydoc", + Restrictions.eq("step", Integer.valueOf(theAnalyzeStep.getNumber()))); + + //split retrieved publications into groups by studies and scenarios + Map> studyMap = new HashMap>(); + Map> scenarioMap = + new HashMap>(); + + for(Publication publication : publications) { + //filter out publications corresponding to a document of given step which is not a _result_ document + if(!publication.value().getType().isResultOf(theAnalyzeStep) + || !"srd".equals(publication.getSourceFile().getFormat())) { + continue; + } + + //check the study visibility to the user + if(!isStaffedBy(publication.getOwnerStudy(), _userService.selectUser(userId)) + && Visibility.PUBLIC.equals(publication.getOwnerStudy().getVisibility())) { + continue; + } + + Study study = publication.getOwnerStudy(); + ProjectElement scenario = publication.getOwner(); + + Hibernate.initialize(scenario); + if (scenario instanceof HibernateProxy) { + scenario = (ProjectElement) ((HibernateProxy) scenario).getHibernateLazyInitializer() + .getImplementation(); + } + + if(!(scenario instanceof Scenario)) { + throw new MismatchException( + "publications from postprocessing step are supposed to have owner scenario"); + } + if(!studyMap.containsKey(study)) { + studyMap.put(study, new ArrayList()); + } + + if(!studyMap.get(study).contains(scenario)) { + studyMap.get(study).add(scenario); + } + + if(!scenarioMap.containsKey(scenario)) { + scenarioMap.put(scenario, new ArrayList()); + } + scenarioMap.get(scenario).add(publication); + } + + //Create the result DTOs + List result = new ArrayList(); + for(Study study : studyMap.keySet()) { + + StudyFacadeDTO studyDTO = new StudyFacadeDTO(); + studyDTO.setName(study.getTitle()); + studyDTO.setScenarios(new ArrayList()); + result.add(studyDTO); + + for(ProjectElement scenario : studyMap.get(study)) { + + StudyFacadeDTO.ScenarioDTO scenarioDTO = new StudyFacadeDTO.ScenarioDTO(); + scenarioDTO.setName(scenario.getTitle()); + scenarioDTO.setDocs(new ArrayList()); + studyDTO.getScenarios().add(scenarioDTO); + + for(Publication publication : scenarioMap.get(scenario)) { + + DocumentDTO documentDTO = new DocumentDTO(); + documentDTO.setId(publication.getIndex()); + documentDTO.setTitle(publication.value().getTitle()); + + scenarioDTO.getDocs().add(documentDTO); + } + } + } + return result; + } + /** * Get the publicationDAO. * @return the publicationDAO @@ -1523,5 +1652,4 @@ public class StudyServiceImpl implements StudyService { final DescriptionAttributeDAO descriptionAttributeDAO) { _descriptionAttributeDAO = descriptionAttributeDAO; } - } diff --git a/Workspace/Siman-Common/src/org/splat/service/dto/StudyFacadeDTO.java b/Workspace/Siman-Common/src/org/splat/service/dto/StudyFacadeDTO.java new file mode 100644 index 0000000..b1d1b7f --- /dev/null +++ b/Workspace/Siman-Common/src/org/splat/service/dto/StudyFacadeDTO.java @@ -0,0 +1,99 @@ +package org.splat.service.dto; + +import java.util.List; + +/** + * The study DTO. + */ +public class StudyFacadeDTO { + + /** + * The scenario DTO. + */ + public static class ScenarioDTO { + + /** + * The name. + */ + private String _name; + + /** + * List of file DTOs. + */ + private List _docs; + + /** + * Get the name. + * @return the name + */ + public String getName() { + return _name; + } + + /** + * Set the name. + * @param name the name to set + */ + public void setName(final String name) { + _name = name; + } + + /** + * Get the docs. + * @return the docs + */ + public List getDocs() { + return _docs; + } + + /** + * Set the docs. + * @param docs the docs to set + */ + public void setDocs(final List docs) { + _docs = docs; + } + } + + /** + * The name. + */ + private String _name; + + /** + * The scenarios. + */ + private List _scenarios; + + /** + * Get the name. + * @return the name + */ + public String getName() { + return _name; + } + + /** + * Set the name. + * @param name the name to set + */ + public void setName(final String name) { + _name = name; + } + + /** + * Get the scenarios. + * @return the scenarios + */ + public List getScenarios() { + return _scenarios; + } + + /** + * Set the scenarios. + * @param scenarios the scenarios to set + */ + public void setScenarios(final List scenarios) { + _scenarios = scenarios; + } +} \ No newline at end of file diff --git a/Workspace/Siman-Common/src/spring/businessServiceContext.xml b/Workspace/Siman-Common/src/spring/businessServiceContext.xml index 65564d7..2e7fd92 100644 --- a/Workspace/Siman-Common/src/spring/businessServiceContext.xml +++ b/Workspace/Siman-Common/src/spring/businessServiceContext.xml @@ -158,6 +158,7 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> + diff --git a/Workspace/Siman/WebContent/WEB-INF/tiles/tiles-defs.xml b/Workspace/Siman/WebContent/WEB-INF/tiles/tiles-defs.xml index 9d13842..c68d3f7 100644 --- a/Workspace/Siman/WebContent/WEB-INF/tiles/tiles-defs.xml +++ b/Workspace/Siman/WebContent/WEB-INF/tiles/tiles-defs.xml @@ -62,6 +62,7 @@ + @@ -79,8 +80,10 @@ - + + + @@ -145,8 +148,8 @@ - + \ No newline at end of file diff --git a/Workspace/Siman/WebContent/conf/som.xml b/Workspace/Siman/WebContent/conf/som.xml index 2561394..75eacba 100644 --- a/Workspace/Siman/WebContent/conf/som.xml +++ b/Workspace/Siman/WebContent/conf/som.xml @@ -7,6 +7,7 @@ --> + @@ -72,6 +73,7 @@
+
@@ -160,7 +162,7 @@ - + @@ -241,6 +243,9 @@ + + + \ No newline at end of file diff --git a/Workspace/Siman/WebContent/jsp/toolbar.jsp b/Workspace/Siman/WebContent/jsp/toolbar.jsp index af5887a..bd5f015 100644 --- a/Workspace/Siman/WebContent/jsp/toolbar.jsp +++ b/Workspace/Siman/WebContent/jsp/toolbar.jsp @@ -84,6 +84,14 @@ "> + + + " border="none" + title="" style="background-color: transparent;"/> + + " border="none" /> + " border="none" title="" /> diff --git a/Workspace/Siman/WebContent/skin/tool.compare.png b/Workspace/Siman/WebContent/skin/tool.compare.png new file mode 100644 index 0000000..a341231 Binary files /dev/null and b/Workspace/Siman/WebContent/skin/tool.compare.png differ diff --git a/Workspace/Siman/WebContent/study/comparison.jsp b/Workspace/Siman/WebContent/study/comparison.jsp new file mode 100644 index 0000000..db52150 --- /dev/null +++ b/Workspace/Siman/WebContent/study/comparison.jsp @@ -0,0 +1,80 @@ +<%@page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> +<%@taglib prefix="s" uri="/struts-tags"%> + + +
+
+
+
+ + + + + + + + +
StudyScenarioResultSelection
+ + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+ +
+ +
+ +
+
+
+ + + +
+
+ + +

+ +
\ No newline at end of file diff --git a/Workspace/Siman/src/labels.properties b/Workspace/Siman/src/labels.properties index 94833cd..b2b1f95 100644 --- a/Workspace/Siman/src/labels.properties +++ b/Workspace/Siman/src/labels.properties @@ -321,6 +321,7 @@ message.error.reference.mismatch = Ce document porte une r message.error.format.version = Ce document porte un numéro de version illicite. message.error.format.date = Ce document porte une date illicite ou définie dans un format non supporté. message.error.version.mismatch = Ce document porte un numéro de version illicite ou incorrect. +message.error.comparison = Invalid comparison input data. Select at least one document; all selected documents should have compatible format. #Validation errors message.error.noenteredvalue=The field ''{0}'' must be filled \ No newline at end of file diff --git a/Workspace/Siman/src/labels_en.properties b/Workspace/Siman/src/labels_en.properties index 60c95fd..b7723fb 100644 --- a/Workspace/Siman/src/labels_en.properties +++ b/Workspace/Siman/src/labels_en.properties @@ -322,6 +322,7 @@ message.error.reference.mismatch = The reference of this document does not matc message.error.format.version = The revision number of this document is illicit. message.error.format.date = The date of this document is illicit or is defined in an unsupported format. message.error.version.mismatch = The revision number of this document is illicit or incorrect. +message.error.comparison = Invalid comparison input data. Select at least one document; all selected documents should have compatible format. #Validation errors message.error.noenteredvalue=The field ''{0}'' must be filled \ No newline at end of file diff --git a/Workspace/Siman/src/org/splat/simer/CompareStudyAction.java b/Workspace/Siman/src/org/splat/simer/CompareStudyAction.java new file mode 100644 index 0000000..62934b3 --- /dev/null +++ b/Workspace/Siman/src/org/splat/simer/CompareStudyAction.java @@ -0,0 +1,224 @@ +/***************************************************************************** + * Company EURIWARE + * Application SIMAN + * File $Id$ + * Creation date Dec 11, 2012 + * @author $Author$ + * @version $Revision$ + *****************************************************************************/ + +package org.splat.simer; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import org.splat.exception.IncompatibleDataException; +import org.splat.exception.InvalidParameterException; +import org.splat.kernel.MismatchException; +import org.splat.service.PublicationService; +import org.splat.service.dto.DocToCompareDTO; +import org.splat.service.dto.StudyFacadeDTO; +import org.splat.wapp.Constants; + +/** + * Performs comparison of studies. + * @author isr + * + */ +public class CompareStudyAction extends DisplayStudyStepAction { + + /** + * Serial version ID. + */ + private static final long serialVersionUID = 6467920934724352021L; + + /** + * List of StudyDTO containing ScenarioDTO containing publications available for comparison. + */ + private List _studyList; + + /** + * Ids of files to compare. + */ + private List _documentsToCompareIds; + + /** + * Comparison result file name. + */ + private String _resultName = null; + + /** + * The result URL. + */ + private String _resultUrl; + + /** + * The result Input Stream. + */ + private InputStream _resultInputStream; + + /** + * Injected publication service. + */ + private PublicationService _publicationService; + + /** + * If true, "incompatible data" message will be displayed.. + */ + private Boolean _errorMessage = false; + + /** + * Initialize comparison screen. + * @return result + * @throws MismatchException if some configurations considering postprocessing step are invalid. + */ + public String doInitComparison() throws MismatchException { + initializationScreenContext(Constants.STUDY_MENU, Constants.BACK); + getTitleBarSettings().setEditDisabledProperty(Constants.TRUE); + String res = SUCCESS; + _studyList = getStudyService().getComparableStudies(getOpenStudy().getUser().getIndex()); + return res; + } + + /** + * Compare studies. + * @throws InvalidParameterException if no publication with given id is found + * @throws FileNotFoundException if no file with retrieved filename is found + * @return result + */ + public String doCompare() throws InvalidParameterException, FileNotFoundException { + String res = ERROR; + + if(_documentsToCompareIds != null && _documentsToCompareIds.size()>0) { + try { + List docsList = new ArrayList(); + for(Long id : _documentsToCompareIds) { + docsList.add(_publicationService.getDocToCompareDTO(id.longValue())); + } + String resultPath = getStudyService().compare(docsList, getConnectedUser().getUsername()); + File file = new File(resultPath); + _resultInputStream = new FileInputStream(file); + res = SUCCESS; + } catch(IncompatibleDataException e) { + LOG.debug("Error while trying to compare study results: " + e.getMessage()); + } + } + return res; + } + + /** + * Get the studyList. + * @return the studyList + */ + public List getStudyList() { + return _studyList; + } + + /** + * Set the studyList. + * @param studyList the studyList to set + */ + public void setStudyList(final List studyList) { + _studyList = studyList; + } + + /** + * Get the filesToCompareIds. + * @return the filesToCompareIds + */ + public List getDocumentsToCompareIds() { + return _documentsToCompareIds; + } + + /** + * Set the filesToCompareIds. + * @param filesToCompareIds the filesToCompareIds to set + */ + public void setDocumentsToCompareIds(final List filesToCompareIds) { + _documentsToCompareIds = filesToCompareIds; + } + + /** + * Get the resultName. + * @return the resultName + */ + public String getResultName() { + return _resultName; + } + + /** + * Set the resultName. + * @param resultName the resultName to set + */ + public void setResultName(final String resultName) { + _resultName = resultName; + } + + /** + * Get the resultUrl. + * @return the resultUrl + */ + public String getResultUrl() { + return _resultUrl; + } + + /** + * Set the resultUrl. + * @param resultUrl the resultUrl to set + */ + public void setResultUrl(final String resultUrl) { + _resultUrl = resultUrl; + } + + /** + * Get the publicationService. + * @return the publicationService + */ + public PublicationService getPublicationService() { + return _publicationService; + } + + /** + * Set the publicationService. + * @param publicationService the publicationService to set + */ + public void setPublicationService(PublicationService publicationService) { + _publicationService = publicationService; + } + + /** + * Get the resultInputStream. + * @return the resultInputStream + */ + public InputStream getResultInputStream() { + return _resultInputStream; + } + + /** + * Set the resultInputStream. + * @param resultInputStream the resultInputStream to set + */ + public void setResultInputStream(InputStream resultInputStream) { + _resultInputStream = resultInputStream; + } + + /** + * Get the errorMessage. + * @return the errorMessage + */ + public Boolean getErrorMessage() { + return _errorMessage; + } + + /** + * Set the errorMessage. + * @param errorMessage the errorMessage to set + */ + public void setErrorMessage(final Boolean errorMessage) { + _errorMessage = errorMessage; + } +} diff --git a/Workspace/Siman/src/som.properties b/Workspace/Siman/src/som.properties index e9b05e2..af1c0d3 100644 --- a/Workspace/Siman/src/som.properties +++ b/Workspace/Siman/src/som.properties @@ -36,6 +36,7 @@ type.document.results = R type.document.report = Rapport final type.document.memorandum = Note technique type.document.minutes = Compte rendu +type.document.coparisonResult= Study comparison result type.context.customer = Client type.context.product = Produit diff --git a/Workspace/Siman/src/som_en.properties b/Workspace/Siman/src/som_en.properties index 2d87e0a..edd888b 100644 --- a/Workspace/Siman/src/som_en.properties +++ b/Workspace/Siman/src/som_en.properties @@ -36,6 +36,7 @@ type.document.results = Calculation results type.document.report = Final report type.document.memorandum = Technical report type.document.minutes = Minute meeting +type.document.coparisonResult= Study comparison result type.context.customer = Customer type.context.product = Product diff --git a/Workspace/Siman/src/spring/applicationContext.xml b/Workspace/Siman/src/spring/applicationContext.xml index 4e06cc9..4ff995c 100644 --- a/Workspace/Siman/src/spring/applicationContext.xml +++ b/Workspace/Siman/src/spring/applicationContext.xml @@ -80,7 +80,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - + - - @@ -138,7 +138,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - + @@ -156,8 +156,8 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - - + + @@ -206,23 +206,22 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> ref="knowledgeElementTypeService" /> - - - - - - + + + + - - - + + + + @@ -285,7 +284,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - +