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;
* @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;
}
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;
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;
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.
*
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;
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;
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.
* @see #isPublic()
*/
boolean moveToPublic(Study aStudy);
-
+
/**
* Moves this study from the Public to the Private area of the repository.
*
* @return the unmodifiable not null transient list of contributors of this study
*/
List<User> getContributors(Study aStudy);
-
+
/**
* Mark study as reference.
*
* the Study
*/
void markStudyAsReference(Study aStudy);
-
+
/**
* Remove study as reference. This operation is inverse one to Mark as reference.
*
* 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).
*
* 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.
*
* @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)
* @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.
*/
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;
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;
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;
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;
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.PdfWriter;
-
/**
* This class defines all methods for creation, modification the study.
*
* Injected user service.
*/
private UserService _userService;
-
+
/**
* Injected publication DAO.
*/
*
* @see org.splat.service.StudyService#selectStudy(long)
*/
+ @Override
@Transactional
public Study selectStudy(final long index) {
Study result = getStudyDAO().get(index);
getStudyDAO().delete(study);
}
}
-
+
/**
* Get study by its reference.
*
*
* @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,
*
* @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)
*
* @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) {
*
* @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();) {
* @see #isPublic()
* @see Publication#approve(Date)
*/
+ @Override
public boolean moveToReference(final Study aStudy) {
if (aStudy.getProgressState() != ProgressState.APPROVED) {
return false;
*
* @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) {
*
* @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;
*
* @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(
* @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) {
* 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);
*
* @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);
* a study to promote
* @return true if the demotion succeeded.
*/
+ @Override
@Transactional
public boolean promote(final Study aStudy) {
if (aStudy.getProgressState() == ProgressState.inWORK) {
* @return true if the move succeeded.
* @see #isPublic()
*/
+ @Override
@Transactional
public boolean moveToPublic(final Study aStudy) {
boolean isOk = false;
* a study to move
* @return true if the move succeeded.
*/
+ @Override
@Transactional
public boolean moveToPrivate(final Study aStudy) {
boolean isOk = false;
*/
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()));
* 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);
* 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()) {
* @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;
* @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;
* @param aStudy
* the study
*/
+ @Override
public void loadWorkflow(final Study aStudy) {
setShortCuts(aStudy);
}
getStudyDAO().merge(aStudy);
}
+
/**
* {@inheritDoc}
* @see org.splat.service.StudyService#getDescription(java.lang.Long)
}
study.setAttribute(new DescriptionAttribute(study, descriptionText));
}
-
- /**
+
+ /**
* {@inheritDoc}
* @see org.splat.service.StudyService#removeStudyDescription(java.lang.Long)
*/
}
return study.removeAttribute(study.getAttribute(DescriptionAttribute.class));
}
+
/**
*
* @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 = "";
//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());
return resultPath;
}
-
+
/**
* Get project settings.
*
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
final DescriptionAttributeDAO descriptionAttributeDAO) {
_descriptionAttributeDAO = descriptionAttributeDAO;
}
-
}
--- /dev/null
+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
<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">
<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
-->
<database>
<repository disk="/home/siman/Repository" />
+ <!--repository disk="W:/Eclipse workspace/SIMAN/Repository" /-->
</database>
<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
<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"/>" />
--- /dev/null
+<%@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
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
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
--- /dev/null
+/*****************************************************************************
+ * 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;
+ }
+}
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
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
<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"
<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" />
<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" />
<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 ========= -->
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 -->
<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>