]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
Studies comparison functionality is implemented.
authormka <mka@opencascade.com>
Thu, 14 Mar 2013 11:20:23 +0000 (11:20 +0000)
committermka <mka@opencascade.com>
Thu, 14 Mar 2013 11:20:23 +0000 (11:20 +0000)
18 files changed:
Workspace/Siman-Common/src/org/splat/service/PublicationService.java
Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/StudyService.java
Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/dto/StudyFacadeDTO.java [new file with mode: 0644]
Workspace/Siman-Common/src/spring/businessServiceContext.xml
Workspace/Siman/WebContent/WEB-INF/tiles/tiles-defs.xml
Workspace/Siman/WebContent/conf/som.xml
Workspace/Siman/WebContent/jsp/toolbar.jsp
Workspace/Siman/WebContent/skin/tool.compare.png [new file with mode: 0644]
Workspace/Siman/WebContent/study/comparison.jsp [new file with mode: 0644]
Workspace/Siman/src/labels.properties
Workspace/Siman/src/labels_en.properties
Workspace/Siman/src/org/splat/simer/CompareStudyAction.java [new file with mode: 0644]
Workspace/Siman/src/som.properties
Workspace/Siman/src/som_en.properties
Workspace/Siman/src/spring/applicationContext.xml

index b3b4e4fbc1a156586dac7579a8f41809ca260ae8..6279f2db814907cb550432fd85104bc40c1c376f 100644 (file)
@@ -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;
 }
index 995b89a8ded5a564c41441c412b2b4cb86e48841..29986c00803b057082173e5007db544713ce847d 100644 (file)
@@ -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.
         * 
index 24d624d77b139b7d1fed080e7ce5adfbfd96485f..2d757e97769ed8bdcb07687c1d1939c8545a6604 100644 (file)
@@ -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;
index 277ea777f9d3bef4d643fa688fe3e64837dcf168..9b7af704e7c2f0bf208f0b106695c84571455538 100644 (file)
@@ -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<User> 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.
+        * <br><b> DocumentDto.id are actually filled in with Publication ids.</b>
+        * @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<StudyFacadeDTO> 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.
         */
index 2e3fc4538e3f9af18d1473a7f3099a09c8ec20c1..7fd574be5fa406b1c083190e87cf35f9bcc300c4 100644 (file)
@@ -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<User> contributor = getModifiableContributors(aStudy); // Initializes contributor
                for (Iterator<User> 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<User> 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<User> 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<DocToCompareDTO> docsList, final String userName) throws IncompatibleDataException {
+       public String compare (final List<DocToCompareDTO> 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<StudyFacadeDTO> getComparableStudies(final long userId) throws MismatchException {
+               //retrieve the number of the "Analyze the results" step 
+               List<Step> 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<Publication> publications = _publicationDAO.getFilteredList("mydoc",
+                               Restrictions.eq("step", Integer.valueOf(theAnalyzeStep.getNumber())));
+
+               //split retrieved publications into groups by studies and scenarios
+               Map<Study, List<ProjectElement>> studyMap = new HashMap<Study, List<ProjectElement>>();
+               Map<ProjectElement, List<Publication>> scenarioMap = 
+                               new HashMap<ProjectElement, List<Publication>>();
+               
+               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<ProjectElement>());
+                       }
+                       
+                       if(!studyMap.get(study).contains(scenario)) {
+                               studyMap.get(study).add(scenario);
+                       }
+
+                       if(!scenarioMap.containsKey(scenario)) {
+                               scenarioMap.put(scenario, new ArrayList<Publication>());
+                       }
+                       scenarioMap.get(scenario).add(publication);
+               }
+               
+               //Create the result DTOs
+               List<StudyFacadeDTO> result = new ArrayList<StudyFacadeDTO>();
+               for(Study study : studyMap.keySet()) {
+                       
+                       StudyFacadeDTO studyDTO = new StudyFacadeDTO();
+                       studyDTO.setName(study.getTitle());
+                       studyDTO.setScenarios(new ArrayList<StudyFacadeDTO.ScenarioDTO>());
+                       result.add(studyDTO);
+                       
+                       for(ProjectElement scenario : studyMap.get(study)) {
+                               
+                               StudyFacadeDTO.ScenarioDTO scenarioDTO = new StudyFacadeDTO.ScenarioDTO();
+                               scenarioDTO.setName(scenario.getTitle());
+                               scenarioDTO.setDocs(new ArrayList<DocumentDTO>());
+                               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 (file)
index 0000000..b1d1b7f
--- /dev/null
@@ -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 <DocumentDTO> _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<DocumentDTO> getDocs() {
+                       return _docs;
+               }
+
+               /**
+                * Set the docs.
+                * @param docs the docs to set
+                */
+               public void setDocs(final List<DocumentDTO> docs) {
+                       _docs = docs;
+               }
+       }
+
+       /**
+        * The name.
+        */
+       private String _name;
+       
+       /**
+        * The scenarios.
+        */
+       private List<ScenarioDTO> _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<ScenarioDTO> getScenarios() {
+               return _scenarios;
+       }
+       
+       /**
+        * Set the scenarios.
+        * @param scenarios the scenarios to set
+        */
+       public void setScenarios(final List<ScenarioDTO> scenarios) {
+               _scenarios = scenarios;
+       }
+}
\ No newline at end of file
index 65564d760b3543d050d05c382a5339cf633063ae..2e7fd929324afe94dc58b1bea55125529e69c0fe 100644 (file)
@@ -158,6 +158,7 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
                <property name="userService" ref="userService" />
                <property name="descriptionAttributeDAO" ref="descriptionAttributeDAO" />
         <property name="repositoryService" ref="repositoryService" />
+        <property name="publicationDAO" ref="publicationDAO" />
        </bean>
 
        <bean id="userRights" abstract="true" scope="session">
index 9d138421c1b12f080678cb34f4b3d5f10f8bb35d..c68d3f77bf7eacf88ccdf7056f9ab2edda0a737f 100644 (file)
@@ -62,6 +62,7 @@
        <put-attribute name="presentation_pane"   value="/study/searchKnowledge.jsp"/>
 </definition>
 
+
 <!-- BEGIN: Display Study -->
 <definition name="zone.stepcomments"  template="/jsp/readComment.jsp"/>
 
 </definition>
 
 <definition name="page.displaystudy" extends="baseLayout">
-        <put-attribute name="presentation_pane" value="zone.displaystudy"/>
+    <put-attribute name="presentation_pane" value="zone.displaystudy"/>
 </definition>
+
+
 <!-- RKV: BEGIN: Simulation contexts -->
 <definition name="page.newcontext" extends="baseLayout">
     <put-attribute name="presentation_pane"   value="/study/displayStudyStep.jsp?action=newContext"/>
 </definition>
 
 <definition name="page.comparestudy" extends="baseLayout">
-    <put-attribute name="left_menus"   value="/jsp/comparisonResult.jsp"/>
     <put-attribute name="presentation_pane"   value="/study/comparison.jsp"/>
+    <put-attribute name="left_menus"   value=""/>
 </definition>
 
 </tiles-definitions>
\ No newline at end of file
index 25613947d0e2acf3e4944b8a382799a970f4ca12..75eacbaf088070fed55e2d04cee14f44b7ab5398 100644 (file)
@@ -7,6 +7,7 @@
      -->
     <database>
         <repository disk="/home/siman/Repository" />
+        <!--repository disk="W:/Eclipse workspace/SIMAN/Repository" /-->
     </database>
 
 
@@ -72,6 +73,7 @@
         <article type="report"        uses="results"/>
         <article type="memorandum"/>
         <article type="minutes"/>
+        <article type="coparisonResult"/>
     </documents>
 
 
             <module name="CASTEM"/>
         </step>
         <step name="postprocessing">
-            <flow contents="memorandum,minutes"/>
+            <flow contents="memorandum,minutes,coparisonResult" result="coparisonResult"/>
             <storage path="6.Report"/>
         </step>
         <step name="capitalization">
             <mapping extension="med"    type="model"/>
             <mapping extension="py"     type="model"/>             <!-- SMESH Python script             -->
         </step>
+        <step number="6">
+            <mapping extension="srd"    type="coparisonResult"/>
+        </step>
     </default-doctypes>
     
 </project-structure>
\ No newline at end of file
index af5887a9865a1d1d6bc3a99a5fa94e2f1f924e97..bd5f0150e29f572e7e83bb5aa540c43047cfc3e2 100644 (file)
                                        <param name="refresh" value="<s:property value="%{refresh}"/>">
                                </applet>
                        </s:if></td>
+                       
+            <td width=30 align=right><s:a action="init-study-comparison">
+                <img src="<s:url value="/skin/tool.compare.png"/>" border="none"
+                    title="<s:text name="tooltip.compare"/>" style="background-color: transparent;"/>
+            </s:a></td>
+            <td align=right><img
+                src="<s:url value="/skin/image.vseparator.png"/>" border="none" />
+            
                        <td width=30 align=right><s:a href="%{#idea}">
                                <img src="<s:url value="/skin/icon.idea.png"/>" border="none"
                                        title="<s:text name="tooltip.search"/>" />
diff --git a/Workspace/Siman/WebContent/skin/tool.compare.png b/Workspace/Siman/WebContent/skin/tool.compare.png
new file mode 100644 (file)
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 (file)
index 0000000..db52150
--- /dev/null
@@ -0,0 +1,80 @@
+<%@page language="java" contentType="text/html; charset=ISO-8859-1"
+    pageEncoding="ISO-8859-1"%>
+<%@taglib prefix="s" uri="/struts-tags"%>
+
+
+<div id="article-box">
+  <div id="section"><s:text name="title.document"/></div>
+  <div id="article-body" class="text">
+       <form style="display:table">
+         <!--  Table header -->
+         <table border="0" cellpadding="0" cellspacing="0">
+           <tr>
+             <td width="180"><b>Study</b></td>
+             <td width="180"><b>Scenario</b></td>
+             <td width="180"><b>Result</b></td>
+             <td width="100"><b>Selection</b></td>
+           </tr>
+         </table>
+         
+         <!--  Table body -->
+         <table border="0" cellpadding="0" cellspacing="0">
+           <s:iterator var="currentStudy" value="studyList">
+        <tr height="1" bgcolor="#AAAAAA"><td colspan="2"></td></tr>
+           <tr valign="top">
+             <td width="180"><s:property value="#currentStudy.name"/></td>
+             <td>
+             
+             <table border="0" cellpadding="0" cellspacing="0">
+               <s:iterator var="currentScenario" value="%{#currentStudy.scenarios}">
+                 <tr valign="top">
+                 <td width="180"><s:property value="#currentScenario.name"/></td>
+                 <td>
+                 
+                 <table border="0" cellpadding="0" cellspacing="0">
+                   <s:iterator var="currentDoc" value="#currentScenario.docs">
+                     <tr>
+                       <td width="180"><s:property value="#currentDoc.title"/></td>
+                       <td width="100">
+                         <s:checkbox name="documentsToCompareIds" fieldValue="%{#currentDoc.id}" theme="simple"/>
+                       </td>   
+                     </tr>
+                   </s:iterator>
+                 </table>
+              
+                 </td>
+               </tr>
+               </s:iterator>
+             </table>
+             
+             </td>
+           </tr>
+           </s:iterator>
+         </table>
+         <br>
+         <br>
+         <s:submit value="%{'Compare'}" action="compare-studies"/>
+       
+       </form>
+  </div>
+</div>
+
+<s:if test="errorMessage">
+<div id="message"><p><s:text name="message.error.comparison"/></p></div>
+<script>
+    $(document).ready(function () {
+        $( "#message" ).dialog({
+            autoOpen: true,
+            width: 400,
+            buttons: [
+                {
+                    text: '<s:text name="button.ok"/>',
+                    click: function() {
+                        $( this ).dialog( "close" );
+                    }
+                }
+            ]
+        });
+    });
+</script>
+</s:if>
\ No newline at end of file
index 94833cd795dd3864ce91f8d9d0ddad5f2ccb623c..b2b1f95550b50a3d8624664d7b5c957151a03748 100644 (file)
@@ -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
index 60c95fdbc5ebde5d9064fa22d457f1789efaacd9..b7723fb97b7041f91bbb748584a06f0fc70f9cfd 100644 (file)
@@ -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 (file)
index 0000000..62934b3
--- /dev/null
@@ -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<StudyFacadeDTO> _studyList;
+       
+       /**
+        * Ids of files to compare.
+        */
+       private List<Long> _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<DocToCompareDTO> docsList = new ArrayList<DocToCompareDTO>();
+                               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<StudyFacadeDTO> getStudyList() {
+               return _studyList;
+       }
+
+       /**
+        * Set the studyList.
+        * @param studyList the studyList to set
+        */
+       public void setStudyList(final List<StudyFacadeDTO> studyList) {
+               _studyList = studyList;
+       }
+
+       /**
+        * Get the filesToCompareIds.
+        * @return the filesToCompareIds
+        */
+       public List<Long> getDocumentsToCompareIds() {
+               return _documentsToCompareIds;
+       }
+
+       /**
+        * Set the filesToCompareIds.
+        * @param filesToCompareIds the filesToCompareIds to set
+        */
+       public void setDocumentsToCompareIds(final List<Long> 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;
+       }
+}
index e9b05e29b57e354197566c3bdbf8ea204fd1b46f..af1c0d3a5b6d862550a2a978e4c56879b12827d4 100644 (file)
@@ -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
index 2d87e0a5abbe76accaa6012e0c77dc6cc0f30832..edd888bc3cbc0f30b6882a61867f8ff164a46c8a 100644 (file)
@@ -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
index 4e06cc98b6fc13d91afcf86220d88c38d9b4ee34..4ff995c9ab3c368dc4afaa7362569693d975c39f 100644 (file)
@@ -80,7 +80,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="projectSettings" ref="projectSettings" />
                <property name="knowledgeElementTypeService"
                        ref="knowledgeElementTypeService" />
-               <property name="publicationService" ref="publicationService" />
+        <property name="publicationService" ref="publicationService" />
        </bean>
 
        <bean id="openStudy" class="org.splat.simer.OpenStudy"
@@ -100,8 +100,8 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
        <bean id="invalidateAction"
                class="org.splat.simer.InvalidateAction" />
-
-       <bean id="baseAction" class="org.splat.simer.Action"
+    
+    <bean id="baseAction" class="org.splat.simer.Action"
                scope="prototype" abstract="true">
                <property name="applicationSettings" ref="applicationSettings" />
                <property name="openStudy" ref="openStudy" />
@@ -138,7 +138,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
        <bean id="importDocumentAction"
                class="org.splat.simer.ImportDocumentAction" scope="prototype"
                parent="baseAction">
-               <property name="studyService" ref="studyService" />
+        <property name="studyService" ref="studyService" />
                <property name="stepService" ref="stepService" />
                <property name="projectSettings" ref="projectSettings" />
                <property name="publicationService" ref="publicationService" />
@@ -156,8 +156,8 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
        <bean id="removeStudyAction"
                class="org.splat.simer.RemoveStudyAction" scope="prototype"
                parent="baseAction">
-               <property name="studyService" ref="studyService" />
-       </bean>
+        <property name="studyService" ref="studyService" />
+    </bean>
 
        <!--========= Inherited from displayStudyStepAction ========= -->
 
@@ -206,23 +206,22 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                        ref="knowledgeElementTypeService" />
                <property name="scenarioService" ref="scenarioService" />
        </bean>
-
-       <bean id="editStepCommentAction"
-               class="org.splat.simer.EditStepCommentAction" scope="prototype"
-               parent="displayStudyStepAction">
-               <property name="stepService" ref="stepService" />
-       </bean>
-
-       <bean id="editStudyDescriptionAction"
-               class="org.splat.simer.EditStudyDescriptionAction" scope="prototype"
+       
+    <bean id="editStepCommentAction"
+        class="org.splat.simer.EditStepCommentAction" scope="prototype"
+        parent="displayStudyStepAction">
+        <property name="stepService" ref="stepService" />
+    </bean>
+       
+    <bean id="editStudyDescriptionAction"
+        class="org.splat.simer.EditStudyDescriptionAction" scope="prototype"
                parent="displayStudyStepAction" />
-
-
-       <!-- bean id="CompareStudyAction"
-               class="org.splat.simer.CompareStudyAction" scope="prototype"
-               parent="displayStudyStepAction">
-               <property name="studyService" ref="studyService" />
-               </bean-->
+    
+    <bean id="CompareStudyAction"
+        class="org.splat.simer.CompareStudyAction" scope="prototype"
+        parent="displayStudyStepAction">
+        <property name="publicationService" ref="publicationService" />
+    </bean>
 
        <!-- End of Inherited from displayStudyStepAction -->
 
@@ -285,7 +284,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="projectSettings" ref="projectSettings" />
                <property name="publicationService" ref="publicationService" />
                <property name="stepService" ref="stepService" />
-               <property name="studyService" ref="studyService" />
+        <property name="studyService" ref="studyService" />
                <property name="repositoryService" ref="repositoryService" />
        </bean>