/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File Id:
* Creation date 02.10.2012
package org.splat.service;
+import java.util.List;
+
import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.DocumentType;
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.ValidationCycle;
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.UserDTO;
+import org.splat.service.dto.StudyFacadeDTO.ScenarioDTO;
/**
* This class defines all methods for creation, modification the study.
/**
* Increment total number of study documents including versions (docount) and update it in the study.
- * @param aStudy the study
+ *
+ * @param aStudy
+ * the study
* @return incremented docount value
*/
- public int generateLocalIndex(Study aStudy);
+ int generateLocalIndex(Study aStudy);
/**
* Get study by its id.
* the study id
* @return found study or null
*/
- public Study selectStudy(long index);
+ Study selectStudy(long index);
+
+ /**
+ * Delete the study.
+ *
+ * @param index
+ * the study id
+ */
+ void removeStudy(final Long index);
/**
* Create a new study.
* @throws MissedPropertyException
* if a mandatory property is missed
* @throws InvalidPropertyException
- * if some property doesn't exist
+ * if an invalid value is passed to a property
* @throws MultiplyDefinedException
* if some property is defined several times
*/
- public Study createStudy(Study.Properties sprop)
- throws MissedPropertyException, InvalidPropertyException,
- MultiplyDefinedException;
+ Study createStudy(Study.Properties sprop) throws MissedPropertyException,
+ InvalidPropertyException, MultiplyDefinedException;
/**
* Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
* @throws MissedPropertyException
* if a mandatory property is missed
* @throws InvalidPropertyException
- * if some property doesn't exist
+ * if an invalid value is passed to a property
* @throws MultiplyDefinedException
* if some property occurs several times
*/
- public SimulationContext addProjectContext(Study aStudy,
+ SimulationContext addProjectContext(Study aStudy,
SimulationContext.Properties cprop) throws MissedPropertyException,
InvalidPropertyException, MultiplyDefinedException;
* the simulation context to add
* @return the added simulation context
*/
- public SimulationContext addProjectContext(Study aStudy,
- SimulationContext context);
+ SimulationContext addProjectContext(Study aStudy, SimulationContext context);
/**
- * Add a new scenario to the study.
+ * Remove a simulation context from a study.
*
* @param aStudy
* the study
- * @param sprop
- * scenario properties
- * @return the added scenario
- * @throws MissedPropertyException
- * if a mandatory property is missed
- * @throws InvalidPropertyException
- * if some property doesn't exist
- * @throws MultiplyDefinedException
- * if some property occurs several times
- */
- public Scenario addScenario(Study aStudy, Scenario.Properties sprop)
- throws MissedPropertyException, InvalidPropertyException,
- MultiplyDefinedException;
-
- /**
- * Remove a simulation context from a study.
- * @param aStudy the study
- * @param context the simulation context to remove
+ * @param context
+ * the simulation context to remove
* @return true if removing succeeded
*/
- public boolean removeProjectContext(Study aStudy, SimulationContext context);
+ boolean removeProjectContext(Study aStudy, SimulationContext context);
/**
* Demotes this study from In-Check to In-Draft then In-Work states. This function is called internally when demoting the final result
* the study to demote
* @return true if the demotion succeeded.
*/
- public boolean demote(Study aStudy);
+ boolean demote(Study aStudy);
/**
* Promotes this study from In-Work to In-Draft then In-Check and APPROVED states. This function is called internally when promoting the
* the study to promote
* @return true if the promotion succeeded.
*/
- public boolean promote(Study aStudy);
+ boolean promote(Study aStudy);
/**
* Add a contributor to the study.
* the contributor
* @return true if addition succeeded
*/
- public boolean addContributor(Study aStudy, User user);
+ boolean addContributor(Study aStudy, User user);
/**
* Remove contributors from the study.
* contributor(s)
* @return true if removing succeeded
*/
- public boolean removeContributor(Study aStudy, User... users);
+ boolean removeContributor(Study aStudy, User... users);
/**
* Set a validation cycle for documents of the given type in the given study.
* @param vprop
* validation cycle properties
*/
- public void setValidationCycle(Study aStudy, DocumentType type,
+ void setValidationCycle(Study aStudy, DocumentType type,
ValidationCycle.Properties vprop);
/**
* @return true if the move succeeded.
* @see #isPublic()
*/
- public boolean moveToPublic(Study aStudy);
+ boolean moveToPublic(Study aStudy);
+
+ /**
+ * Moves this study from the Public to the Private area of the repository.
+ *
+ * @param aStudy
+ * the study to move
+ * @return true if the move succeeded.
+ */
+ boolean moveToPrivate(Study aStudy);
/**
* Moves this study from the Public to the Reference area of the repository. For being moved to the Reference area, the study must
* @see #isPublic()
* @see Publication#approve(Date)
*/
- public boolean moveToReference(Study aStudy);
+ boolean moveToReference(Study aStudy);
/**
* Update a study.
* new properties of the study
* @return true if the study has been updated successfully
* @throws InvalidPropertyException
- * if some property doesn't exist
+ * if an invalid value is passed to a property
*/
- public boolean update(Study aStudy, Properties sprop)
+ boolean update(Study aStudy, Properties sprop)
throws InvalidPropertyException;
+
+ /**
+ * Initialize shortcuts of the study as its transient collections.
+ *
+ * @param aStudy
+ * the study
+ */
+ void loadWorkflow(Study aStudy);
+
+ /**
+ * Returns the validation cycle of the given document type.
+ *
+ * @param aStudy
+ * the study
+ * @param type
+ * the document type being subject of validation
+ * @return the validation cycle of the document, or null if not defined.
+ */
+ ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type);
+
+ /**
+ * Checks if the given user participates to this study. The Study staff includes the author and contributors.
+ *
+ * @param aStudy
+ * the study
+ * @param user
+ * the user to look for
+ * @return true if the given user is actor of this study.
+ * @see #getContributors()
+ */
+ boolean isStaffedBy(Study aStudy, User user);
+
+ /**
+ * Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
+ *
+ * @param aStudy
+ * the study
+ * @param user
+ * the user to look for
+ * @return true if the given user is actor of this study.
+ * @see #getActors()
+ */
+ boolean hasActor(Study aStudy, User user);
+
+ /**
+ * Returns unmodifiable initialized transient list of contributors of this study.
+ *
+ * @param aStudy
+ * the study
+ * @return the unmodifiable not null transient list of contributors of this study
+ */
+ List<User> getContributors(Study aStudy);
+
+ /**
+ * Mark study as reference.
+ *
+ * @param aStudy -
+ * the Study
+ */
+ void markStudyAsReference(Study aStudy);
+
+ /**
+ * Remove study as reference. This operation is inverse one to Mark as reference.
+ *
+ * @param aStudy -
+ * 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).
+ *
+ * @param studyId
+ * the study id
+ * @return the description attribute value (null if does not exist)
+ * @throws InvalidParameterException
+ * 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
+ * @param descriptionText
+ * the description text
+ * @throws InvalidParameterException
+ * if some parameters are invalid.
+ */
+ void setDescription(Long studyId, String descriptionText)
+ throws InvalidParameterException;
+
+ /**
+ * Remove a description attached to a study.
+ *
+ * @param studyId
+ * the study id
+ * @throws InvalidParameterException
+ * 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)
+ throws InvalidParameterException;
+
+ /**
+ * Compare the studies and generate the file that contains the result chart.
+ *
+ * @param docsList
+ * the list of dtos each contains information: StudyTitle, ScenarioTitle, PathToFile in vault.
+ * @param userName
+ * the name of the user who compare the results.
+ * @throws IncompatibleDataException
+ * if data is incompatible for "Compare the studies" functionality.
+ *
+ * @return path to result file in the vault.
+ */
+ String compare(List<DocToCompareDTO> docsList, final String userName)
+ throws IncompatibleDataException;
+
+ /**
+ * Get readers of a given study.
+ * @param studyId the study id.
+ * @return list of user DTO corresponding to the study readers.
+ * @throws InvalidParameterException if no study with such id has been found in the database.
+ */
+ List<UserDTO> getReaders(final long studyId) throws InvalidParameterException;
+
+ /**
+ * Add reader to a given study.
+ * @param studyId the study id.
+ * @param userId the user id.
+ * @return true if the user has been added as a reader
+ * @throws InvalidParameterException if no study or user with such id has been found in the database.
+ */
+ boolean addReader(final long studyId, final long userId) throws InvalidParameterException;
+
+ /**
+ * Remove reader from a given study.
+ * @param studyId the study id.
+ * @param userId the user id.
+ * @return true if the relation has been found and removed
+ * @throws InvalidParameterException if no study or user with such id has been found in the database.
+ */
+ boolean removeReader(final long studyId, final long userId) throws InvalidParameterException;
}