// - Public services
+ @Override
public void clear() {
super.clear();
type = null;
// - Property setters
- public Properties setAuthor(User user) {
+ public Properties setAuthor(final User user) {
this.author = user;
return this;
}
- public Properties setDate(Date date) {
+ public Properties setDate(final Date date) {
this.date = date;
return this;
}
return date;
}
- public Properties setDescription(String summary)
+ public Properties setDescription(final String summary)
throws InvalidPropertyException {
- if (summary.length() == 0)
+ if (summary.length() == 0) {
throw new InvalidPropertyException("description");
+ }
this.summary = summary;
return this;
}
- public Properties setDocument(Document base) {
+ public Properties setDocument(final Document base, final ProjectSettingsService.Step aStep) {
type = base.type;
- step = ProjectSettingsServiceImpl.getStep(base.step);
+ step = aStep;
name = base.name;
format = base.getFormat();
state = ProgressState.inWORK; // For incrementing the version number at save time
return this;
}
- public Properties setExternReference(String ref)
+ public Properties setExternReference(final String ref)
throws InvalidPropertyException {
- if (ref.length() == 0)
+ if (ref.length() == 0) {
throw new InvalidPropertyException("reference");
- if (ref.equals(new Revision().toString()))
+ }
+ if (ref.equals(new Revision().toString())) {
throw new InvalidPropertyException("reference"); // Internal version number
+ }
this.version = ref;
return this;
}
- public Properties setFormat(String format)
+ public Properties setFormat(final String format)
throws InvalidPropertyException {
- if (format.length() == 0)
+ if (format.length() == 0) {
throw new InvalidPropertyException("format");
+ }
this.format = format;
return this;
}
// Required only for passing search arguments
- public Properties setLocalPath(String path)
+ public Properties setLocalPath(final String path)
throws InvalidPropertyException {
- if (path.length() == 0)
+ if (path.length() == 0) {
throw new InvalidPropertyException("path");
+ }
this.path = path;
return this;
}
- public Properties setName(String name) throws InvalidPropertyException {
- if (name.length() == 0)
+ public Properties setName(final String name) throws InvalidPropertyException {
+ if (name.length() == 0) {
throw new InvalidPropertyException("name");
+ }
this.name = name;
return this;
}
return this.name;
}
- public Properties setOwner(ProjectElement owner) {
+ public Properties setOwner(final ProjectElement owner) {
this.owner = owner;
return this;
}
return this.owner;
}
// Required only for passing search arguments
- public Properties setReference(String did)
+ public Properties setReference(final String did)
throws InvalidPropertyException {
- if (did.length() == 0)
+ if (did.length() == 0) {
throw new InvalidPropertyException("reference");
+ }
this.did = did;
return this;
}
- public Properties setState(ProgressState state)
+ public Properties setState(final ProgressState state)
throws InvalidPropertyException {
if (state == ProgressState.inPROGRESS
- || state == ProgressState.TEMPLATE)
+ || state == ProgressState.TEMPLATE) {
throw new InvalidPropertyException("state"); // Non document states
+ }
this.state = state;
return this;
}
- public Properties setStep(ProjectSettingsService.Step step) {
+ public Properties setStep(final ProjectSettingsService.Step step) {
this.step = step;
return this;
}
- public Properties setType(DocumentType type) {
+ public Properties setType(final DocumentType type) {
this.type = type;
return this;
}
public void checkValidity() throws MissedPropertyException,
InvalidPropertyException, MultiplyDefinedException {
- if (type == null)
+ if (type == null) {
throw new MissedPropertyException("type");
- if (owner == null)
+ }
+ if (owner == null) {
throw new MissedPropertyException("owner");
- if (step == null)
+ }
+ if (step == null) {
throw new MissedPropertyException("step");
- if (author == null)
+ }
+ if (author == null) {
throw new MissedPropertyException("author");
- if (format == null)
+ }
+ if (format == null) {
throw new MissedPropertyException("format");
- if (owner instanceof Study && !step.appliesTo(Study.class))
+ }
+ if (owner instanceof Study && !step.appliesTo(Study.class)) {
throw new InvalidPropertyException("step");
- if (!type.isContentInto(step))
+ }
+ if (!type.isContentInto(step)) {
throw new InvalidPropertyException("step");
+ }
if (state != null && state != ProgressState.EXTERN) {
// inDRAFT, inCHECK or APPROVED + version = imposed version (future use)
// inWORK + version = base version incremented at save time (used for versioning)
- if (version == null)
+ if (version == null) {
throw new InvalidPropertyException("state");
+ }
}
if (version != null) {
- if (state == null)
+ if (state == null) {
state = ProgressState.EXTERN;
+ }
}
}
}
}
// Internal constructor
- public Document(Properties dprop) throws MissedPropertyException,
+ public Document(final Properties dprop) throws MissedPropertyException,
InvalidPropertyException, MultiplyDefinedException {
// -------------------------------------
super(dprop); // Throws one of the above exception if not valid
// Public member functions
// ==============================================================================================================================
- public File getAttachedFile(String format) {
+ public File getAttachedFile(final String format) {
// -------------------------------------------
List<Relation> exports = getRelations(ConvertsRelation.class);
for (Iterator<Relation> i = exports.iterator(); i.hasNext();) {
File export = (File) i.next().getTo();
- if (export.getFormat().equals(format))
+ if (export.getFormat().equals(format)) {
return export;
+ }
}
return null;
}
return lasdate;
}
- public void setLastModificationDate(Date aDate) {
+ public void setLastModificationDate(final Date aDate) {
lasdate = aDate;
}
public Document getPreviousVersion() {
// -------------------------------------
Relation previous = getFirstRelation(VersionsRelation.class);
- if (previous != null)
+ if (previous != null) {
return (Document) previous.getTo();
- else
+ } else {
return null;
+ }
}
public ProgressState getProgressState() {
// --------------------------------
String[] table = myfile.getRelativePath().split("\\x2E");
StringBuffer path = new StringBuffer(table[0]);
- for (int i = 1; i < table.length - 1; i++)
+ for (int i = 1; i < table.length - 1; i++) {
path.append('.').append(table[i]);
+ }
return path.toString();
}
for (Iterator<Relation> i = this.getAllRelations().iterator(); i
.hasNext();) {
Relation link = i.next();
- if (link instanceof StampRelation)
+ if (link instanceof StampRelation) {
stamps.add(((StampRelation) link).getTo());
+ }
}
Timestamp[] result = stamps.toArray(new Timestamp[stamps.size()]);
ComparatorByDate bydate = new Timestamp.ComparatorByDate();
*/
public String getTitle() {
// -------------------------
- if (this.isUndefined())
+ if (this.isUndefined()) {
return "";
- else
+ } else {
return name;
+ }
}
/**
* Set document title.
* @param aTitle document title to set
*/
- public void setTitle(String aTitle) {
+ public void setTitle(final String aTitle) {
this.name = aTitle;
}
return (history == -1);
}
- public boolean isInto(Step container) {
+ public boolean isInto(final Step container) {
// --------------------------------------
return (step == container.getNumber());
}
* Set the step.
* @param step the step to set
*/
- public void setStep(int step) {
+ public void setStep(final int step) {
this.step = step;
}
* Set the did.
* @param did the did to set
*/
- public void setDid(String did) {
+ public void setDid(final String did) {
this.did = did;
}
* Set the myfile.
* @param myfile the myfile to set
*/
- public void setFile(File myfile) {
+ public void setFile(final File myfile) {
this.myfile = myfile;
}
* Set the history.
* @param history the history to set
*/
- public void setHistory(int history) {
+ public void setHistory(final int history) {
this.history = history;
}
* Set the version.
* @param version the version to set
*/
- public void setVersion(String version) {
+ public void setVersion(final String version) {
this.version = version;
}
* Set the state.
* @param state the state to set
*/
- public void setProgressState(ProgressState state) {
+ public void setProgressState(final ProgressState state) {
this.state = state;
}
* Set the countag.
* @param countag the countag to set
*/
- public void setCountag(int countag) {
+ public void setCountag(final int countag) {
this.countag = countag;
}
}
\ No newline at end of file
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
-import org.splat.service.technical.ProjectSettingsServiceImpl;
public class ValidationCycle extends Persistent {
// - Public services
- public void clear () {
+ @Override
+ public void clear () {
super.clear();
doctype = null;
publisher = null;
}
// - Protected services
- public Properties setDocumentType (DocumentType type)
+ public Properties setDocumentType (final DocumentType type)
{
doctype = type;
return this;
}
// - Properties setter
- public Properties setActor (ValidationStep step, User actor)
+ public Properties setActor (final ValidationStep step, final User actor)
{
- if (step == ValidationStep.PROMOTION) publisher = actor;
- else if (step == ValidationStep.REVIEW) reviewer = actor;
- else if (step == ValidationStep.APPROVAL) approver = actor;
- else if (step == ValidationStep.ACCEPTANCE || step == ValidationStep.REFUSAL) signatory = actor;
+ if (step == ValidationStep.PROMOTION) {
+ publisher = actor;
+ } else if (step == ValidationStep.REVIEW) {
+ reviewer = actor;
+ } else if (step == ValidationStep.APPROVAL) {
+ approver = actor;
+ } else if (step == ValidationStep.ACCEPTANCE || step == ValidationStep.REFUSAL) {
+ signatory = actor;
+ }
return this;
}
// - Global validity check
public void checkValidity() throws MissedPropertyException
{
- if (doctype == null) throw new MissedPropertyException("type");
+ if (doctype == null) {
+ throw new MissedPropertyException("type");
+ }
}
/**
// Database fetch constructor
public ValidationCycle () {
}
- public ValidationCycle (Study from, Properties vprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
-// --------------------------------------------------------
+ public ValidationCycle (final Study from, final Properties vprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
super(vprop); // Throws one of the above exception if not valid
mytype = vprop.doctype;
publisher = vprop.publisher; // May be null
* @param step the validation step checked.
* @return true if the given validation step is enabled.
*/
- public boolean enables (ValidationStep step) {
-// -------------------------------------------
- if (step == ValidationStep.PROMOTION) return true;
- else if (step == ValidationStep.REVIEW) return (reviewer != null);
- else if (step == ValidationStep.APPROVAL) return (approver != null);
- else if (step == ValidationStep.ACCEPTANCE || step == ValidationStep.REFUSAL) return (signatory != null);
+ public boolean enables (final ValidationStep step) {
+ if (step == ValidationStep.PROMOTION) {
+ return true;
+ } else if (step == ValidationStep.REVIEW) {
+ return (reviewer != null);
+ } else if (step == ValidationStep.APPROVAL) {
+ return (approver != null);
+ } else if (step == ValidationStep.ACCEPTANCE || step == ValidationStep.REFUSAL) {
+ return (signatory != null);
+ }
return false;
}
* @see #getAllActors()
* @see #enables
*/
- public User getActor (ValidationStep step) {
-// -----------------------------------------
- if (step == ValidationStep.PROMOTION) return publisher;
- else if (step == ValidationStep.REVIEW) return reviewer;
- else if (step == ValidationStep.APPROVAL) return approver;
- else if (step == ValidationStep.ACCEPTANCE || step == ValidationStep.REFUSAL) return signatory;
+ public User getActor (final ValidationStep step) {
+ if (step == ValidationStep.PROMOTION) {
+ return publisher;
+ } else if (step == ValidationStep.REVIEW) {
+ return reviewer;
+ } else if (step == ValidationStep.APPROVAL) {
+ return approver;
+ } else if (step == ValidationStep.ACCEPTANCE || step == ValidationStep.REFUSAL) {
+ return signatory;
+ }
return null;
}
public User[] getAllActors () {
// -----------------------------
Vector<User> result = new Vector<User>();
- if (publisher != null) result.add(publisher);
- if (reviewer != null) result.add(reviewer);
- if (approver != null) result.add(approver);
- if (signatory != null) result.add(signatory);
+ if (publisher != null) {
+ result.add(publisher);
+ }
+ if (reviewer != null) {
+ result.add(reviewer);
+ }
+ if (approver != null) {
+ result.add(approver);
+ }
+ if (signatory != null) {
+ result.add(signatory);
+ }
return result.toArray(new User[result.size()]);
}
* @see #isDefault()
*/
public DocumentType getDocumentType () {
- // --------------------------------------
return mytype; // May be null
}
* Set a document type for the validation cycle.
* @param aType the document type
*/
- public void setDocumentType (DocumentType aType) {
+ public void setDocumentType (final DocumentType aType) {
mytype = aType; // May be null
}
* @return true if this validation cycle is assigned to a study.
*/
public boolean isAssigned () {
-// ----------------------------
return (context != null);
}
*
* @return true if this validation cycle is a default one.
* @see #getDocumentType()
- * @see ProjectSettingsServiceImpl#getNewValidationCycle()
*/
public boolean isDefault () {
-// ---------------------------
return (mytype == null);
}
-// ==============================================================================================================================
-// Protected services
-// ==============================================================================================================================
-
public ValidationCycleRelation getContext () {
// -----------------------------------------------
return context;
* Set the publisher.
* @param publisher the publisher to set
*/
- public void setPublisher(User publisher) {
+ public void setPublisher(final User publisher) {
this.publisher = publisher;
}
/**
* Set the reviewer.
* @param reviewer the reviewer to set
*/
- public void setReviewer(User reviewer) {
+ public void setReviewer(final User reviewer) {
this.reviewer = reviewer;
}
/**
* Set the approver.
* @param approver the approver to set
*/
- public void setApprover(User approver) {
+ public void setApprover(final User approver) {
this.approver = approver;
}
/**
* Set the signatory.
* @param signatory the signatory to set
*/
- public void setSignatory(User signatory) {
+ public void setSignatory(final User signatory) {
this.signatory = signatory;
}
}
\ No newline at end of file
import org.splat.manox.Reader;
import org.splat.manox.Toolbox;
import org.splat.service.technical.ProjectSettingsService;
-import org.splat.service.technical.ProjectSettingsServiceImpl;
import org.splat.service.technical.RepositoryService;
import org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming;
import org.splat.som.Revision;
* @see org.splat.service.DocumentService#selectDocument(long)
*/
@Transactional(readOnly = true)
- public Document selectDocument(long index) {
+ public Document selectDocument(final long index) {
return getDocumentDAO().get(index);
}
* @see org.splat.service.DocumentService#selectDocument(java.lang.String, java.lang.String)
*/
@Transactional(readOnly = true)
- public Document selectDocument(String refid, String version) {
+ public Document selectDocument(final String refid, final String version) {
Criterion aCondition = Restrictions.and(Restrictions.eq("did", refid),
Restrictions.eq("version", version));
return getDocumentDAO().findByCriteria(aCondition);
* @see org.splat.service.DocumentService#generateDocumentId(org.splat.dal.bo.som.Document, org.splat.dal.bo.som.Document.Properties)
*/
@Transactional
- public void generateDocumentId(Document aDoc, Properties dprop) {
+ public void generateDocumentId(final Document aDoc, final Properties dprop) {
Study owner = null;
- if (dprop.getOwner() instanceof Study)
+ if (dprop.getOwner() instanceof Study) {
owner = (Study) dprop.getOwner();
- else
+ } else {
owner = ((Scenario) dprop.getOwner()).getOwnerStudy();
+ }
// Synchronize the object with the current Hibernate session.
owner = getStudyDAO().get(owner.getIndex());
-
+
SimpleDateFormat tostring = new SimpleDateFormat("yyyy");
String year = tostring.format(owner.getDate());
String filename = generateEncodedName(aDoc, owner);
String path = owner.getReference();
- ProjectSettingsService.Step step = ProjectSettingsServiceImpl
- .getStep(aDoc.getStep());
- aDoc.setDid(new StringBuffer(path).append(".%")
- .append(Document.suformat).toString()); // Document reference
+ ProjectSettingsService.Step step = getProjectSettings().getStep(
+ aDoc.getStep());
+ aDoc.setDid(new StringBuffer(path).append(".%").append(
+ Document.suformat).toString()); // Document reference
path = new StringBuffer(year).append("/").append(path).append("/")
.append(step.getPath())
// File path relative to the repository vault
* the study
* @return document reference name
*/
- private String generateEncodedName(Document aDoc, Study scope) {
+ private String generateEncodedName(final Document aDoc, final Study scope) {
StringBuffer encoding = new StringBuffer();
FileNaming scheme = getProjectSettings().getFileNamingScheme();
DecimalFormat tostring = new DecimalFormat(Document.suformat);
int number = getStudyService().generateLocalIndex(scope);
if (scheme == FileNaming.encoded) {
- encoding.append(scope.getReference()).append(".")
- .append(tostring.format(number));
+ encoding.append(scope.getReference()).append(".").append(
+ tostring.format(number));
} else { // title and (temporarily) asis
- encoding.append(aDoc.getTitle()).append(".")
- .append(tostring.format(number));
+ encoding.append(aDoc.getTitle()).append(".").append(
+ tostring.format(number));
}
return encoding.toString();
}
* the study
* @return file name
*/
- private String getEncodedRootName(Document aDoc, Study scope) {
+ private String getEncodedRootName(final Document aDoc, final Study scope) {
FileNaming scheme = getProjectSettings().getFileNamingScheme();
- if (scheme == FileNaming.encoded)
+ if (scheme == FileNaming.encoded) {
return scope.getReference();
- else
+ } else {
return aDoc.getTitle();
+ }
}
/**
* @see org.splat.service.DocumentService#initialize(org.splat.dal.bo.som.Document, org.splat.dal.bo.som.Document.Properties)
*/
@Transactional
- public void initialize(Document aDoc, Properties dprop)
+ public void initialize(final Document aDoc, final Properties dprop)
throws MissedPropertyException, InvalidPropertyException,
NotApplicableException {
- if (!aDoc.isUndefined())
+ if (!aDoc.isUndefined()) {
throw new NotApplicableException(
"Cannot initialize an existing Document");
- if (dprop.getName() == null)
+ }
+ if (dprop.getName() == null) {
throw new MissedPropertyException("name");
- if (dprop.getName().length() == 0)
+ }
+ if (dprop.getName().length() == 0) {
throw new InvalidPropertyException("name");
- if (dprop.getOwner() == null)
+ }
+ if (dprop.getOwner() == null) {
throw new MissedPropertyException("owner");
+ }
// if (dprop.owner instanceof Study && !ProjectSettings.getStep(step).appliesTo(Study.class)) {
// throw new InvalidPropertyException("step");
// }
aDoc.setTitle(dprop.getName());
aDoc.getFile().changePath(
- aDoc.getFile()
- .getRelativePath()
- .replace(
- "%n",
- getEncodedRootName(aDoc,
- (Study) dprop.getOwner())));
- if (aDoc.getHistory() == -1)
+ aDoc.getFile().getRelativePath().replace("%n",
+ getEncodedRootName(aDoc, (Study) dprop.getOwner())));
+ if (aDoc.getHistory() == -1) {
aDoc.setHistory(0);
+ }
if (dprop.getDate() == null) {
Calendar current = Calendar.getInstance();
aDoc.setLastModificationDate(current.getTime()); // Today
*
* @see org.splat.service.DocumentService#getSaveDirectory(org.splat.dal.bo.som.Document)
*/
- public java.io.File getSaveDirectory(Document aDoc) {
+ public java.io.File getSaveDirectory(final Document aDoc) {
String mypath = getRepositoryService().getRepositoryVaultPath()
+ aDoc.getSourceFile().getRelativePath();
String[] table = mypath.split("/");
// Cutting the filename
StringBuffer path = new StringBuffer(table[0]);
- for (int i = 1; i < table.length - 1; i++)
+ for (int i = 1; i < table.length - 1; i++) {
path = path.append("/").append(table[i]);
+ }
return new java.io.File(path.append("/").toString());
}
* the file to parse
* @return the extracted properties
*/
- public Properties extractProperties(java.io.File file) {
+ public Properties extractProperties(final java.io.File file) {
Properties fprop = new Properties();
Reader tool = Toolbox.getReader(file);
String value;
- if (tool != null)
+ if (tool != null) {
try {
value = tool.extractProperty("title");
- if (value != null)
+ if (value != null) {
fprop.setName(value);
+ }
value = tool.extractProperty("reference");
- if (value != null)
+ if (value != null) {
fprop.setReference(value);
+ }
} catch (Exception e) {
}
+ }
return fprop;
}
* the format
* @return the created "Converts" relation
*/
- public ConvertsRelation attach(Document aDoc, String format) {
+ public ConvertsRelation attach(final Document aDoc, final String format) {
return attach(aDoc, format, null);
}
* @return the created "Converts" relation
*/
@Transactional
- public ConvertsRelation attach(Document aDoc, String format,
- String description) {
+ public ConvertsRelation attach(final Document aDoc, final String format,
+ final String description) {
String path = aDoc.getRelativePath();
File export = new File(path + "." + format);
ConvertsRelation attach = new ConvertsRelation(aDoc, export,
* the original document
* @return true if the new reference is set
*/
- public boolean buildReferenceFrom(Document aDoc, ProjectElement scope,
- Document lineage) {
- if (aDoc.getProgressState() != ProgressState.inWORK)
+ public boolean buildReferenceFrom(final Document aDoc, final ProjectElement scope,
+ final Document lineage) {
+ if (aDoc.getProgressState() != ProgressState.inWORK) {
return false;
+ }
Study owner = null;
Scenario context = null;
- if (scope instanceof Study)
+ if (scope instanceof Study) {
owner = (Study) scope;
- else {
+ } else {
context = ((Scenario) scope);
owner = context.getOwnerStudy();
}
* the study
* @return true if the new reference is set
*/
- public boolean buildReferenceFrom(Document aDoc, Study scope) {
+ public boolean buildReferenceFrom(final Document aDoc, final Study scope) {
if (aDoc.getProgressState() != ProgressState.inWORK
- && aDoc.getProgressState() != ProgressState.EXTERN)
+ && aDoc.getProgressState() != ProgressState.EXTERN) {
return false;
+ }
DecimalFormat tostring = new DecimalFormat(Document.suformat);
aDoc.setDid(aDoc.getDid().replace("%" + Document.suformat,
* @return true if demoting succeeded
*/
@Transactional
- public boolean demote(Document aDoc) {
+ public boolean demote(final Document aDoc) {
ValidationStep torem;
if (aDoc.getProgressState() == ProgressState.inCHECK) {
for (Iterator<Relation> i = aDoc.getAllRelations().iterator(); i
.hasNext();) {
Relation link = i.next();
- if (!(link instanceof StampRelation))
+ if (!(link instanceof StampRelation)) {
continue;
- if (((StampRelation) link).getStampType() != torem)
+ }
+ if (((StampRelation) link).getStampType() != torem) {
continue;
+ }
i.remove();
break;
}
* @return true if promotion succeeded
*/
@Transactional
- public boolean promote(Document aDoc, Timestamp stamp) {
+ public boolean promote(final Document aDoc, final Timestamp stamp) {
ProgressState newstate = null;
if (aDoc.getProgressState() == ProgressState.inWORK) {
* @see #release()
*/
@Transactional
- public void hold(Document aDoc) {
+ public void hold(final Document aDoc) {
aDoc.setCountag(aDoc.getCountag() + 1);
if (aDoc.isSaved()) {
getDocumentDAO().update(aDoc);
* @see #hold()
*/
@Transactional
- public void release(Document aDoc) {
+ public void release(final Document aDoc) {
aDoc.setCountag(aDoc.getCountag() - 1);
if (aDoc.isSaved()) {
getDocumentDAO().merge(aDoc);
* if the new title is empty
*/
@Transactional
- public void rename(Document aDoc, String title)
+ public void rename(final Document aDoc, final String title)
throws InvalidPropertyException {
- if (title.length() == 0)
+ if (title.length() == 0) {
throw new InvalidPropertyException("name");
+ }
Calendar current = Calendar.getInstance();
aDoc.setTitle(title);
* @param newvers
* the new version
*/
- public void updateAs(Document aDoc, Revision newvers) {
+ public void updateAs(final Document aDoc, final Revision newvers) {
aDoc.setVersion(newvers.setBranch(aDoc.getVersion()).toString()); // Branch names are propagated by the versionning
ProgressState newstate = ProgressState.inCHECK;
- if (newvers.isMinor())
+ if (newvers.isMinor()) {
newstate = ProgressState.inWORK;
+ }
aDoc.setProgressState(null); // Just to tell updateAs(state) to not increment the version number
updateAs(aDoc, newstate);
}
* the new state
*/
@Transactional
- public void updateAs(Document aDoc, ProgressState state) {
+ public void updateAs(final Document aDoc, final ProgressState state) {
Document previous = null;
// Set of version number
if (state == ProgressState.EXTERN) {
- if (aDoc.getProgressState() != ProgressState.EXTERN)
+ if (aDoc.getProgressState() != ProgressState.EXTERN) {
aDoc.setVersion(null); // Strange use-case...
+ }
} else {
Revision myvers = new Revision(aDoc.getVersion());
if (!myvers.isNull()) { // Versionning context
for (Iterator<Relation> i = aDoc.getAllRelations().iterator(); i
.hasNext();) {
Relation link = i.next();
- if (!link.getClass().equals(VersionsRelation.class))
+ if (!link.getClass().equals(VersionsRelation.class)) {
continue;
+ }
previous = (Document) link.getTo(); // Versioned document
break;
}
}
- if (aDoc.getProgressState() != null)
+ if (aDoc.getProgressState() != null) {
myvers.incrementAs(state); // Incrementation if the reversion number is not imposed
+ }
aDoc.setVersion(myvers.toString());
}
// Update this document and the previous version, if exit
* @see #isStepResult()
* @see #isResultOf(org.splat.service.technical.ProjectSettingsServiceImpl.Step)
*/
- public boolean isStudyResult(DocumentType aType) {
+ public boolean isStudyResult(final DocumentType aType) {
// -------------------------------
List<ProjectSettingsService.Step> step = getProjectSettings()
.getAllSteps();
/**
* Get document by its path.
- * @param path the document path
+ *
+ * @param path
+ * the document path
* @return the document if found or null
*/
- @Transactional(readOnly=true)
+ @Transactional(readOnly = true)
public Document getDocumentByPath(String path) {
String[] parse = path.split("'");
* @param studyService
* the studyService to set
*/
- public void setStudyService(StudyService studyService) {
+ public void setStudyService(final StudyService studyService) {
_studyService = studyService;
}
* @param projectSettingsService
* project settings service
*/
- public void setProjectSettings(ProjectSettingsService projectSettingsService) {
+ public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
_projectSettingsService = projectSettingsService;
}
* @param documentDAO
* the documentDAO to set
*/
- public void setDocumentDAO(DocumentDAO documentDAO) {
+ public void setDocumentDAO(final DocumentDAO documentDAO) {
_documentDAO = documentDAO;
}
* @param repositoryService
* the repositoryService to set
*/
- public void setRepositoryService(RepositoryService repositoryService) {
+ public void setRepositoryService(final RepositoryService repositoryService) {
_repositoryService = repositoryService;
}
* @param documentTypeDAO
* the documentTypeDAO to set
*/
- public void setDocumentTypeDAO(DocumentTypeDAO documentTypeDAO) {
+ public void setDocumentTypeDAO(final DocumentTypeDAO documentTypeDAO) {
_documentTypeDAO = documentTypeDAO;
}
* @param fileDAO
* the fileDAO to set
*/
- public void setFileDAO(FileDAO fileDAO) {
+ public void setFileDAO(final FileDAO fileDAO) {
_fileDAO = fileDAO;
}
/**
* Get the studyDAO.
+ *
* @return the studyDAO
*/
public StudyDAO getStudyDAO() {
/**
* Set the studyDAO.
- * @param studyDAO the studyDAO to set
+ *
+ * @param studyDAO
+ * the studyDAO to set
*/
- public void setStudyDAO(StudyDAO studyDAO) {
+ public void setStudyDAO(final StudyDAO studyDAO) {
_studyDAO = studyDAO;
}
import org.splat.log.AppLogger;
import org.splat.service.dto.SimulationContextFacade;
import org.splat.service.technical.ProjectSettingsService;
-import org.splat.service.technical.ProjectSettingsServiceImpl;
import org.springframework.transaction.annotation.Transactional;
/**
*/
@Transactional(readOnly=true)
public Vector<SimulationContextFacade> getSimulationContextsInState(
- ProgressState aState) throws InvalidPropertyException {
+ final ProgressState aState) throws InvalidPropertyException {
SimulationContext.Properties cprop = new SimulationContext.Properties();
List<SimulationContext> context = selectSimulationContextsWhere(cprop
.setState(aState));
*
* @see org.splat.service.SimulationContextService#selectSimulationContext(int)
*/
- public SimulationContext selectSimulationContext(long index) {
+ public SimulationContext selectSimulationContext(final long index) {
return getSimulationContextDAO().get(index);
}
* @see org.splat.service.SimulationContextService#selectSimulationContext(org.splat.dal.bo.som.SimulationContextType, java.lang.String)
*/
public SimulationContext selectSimulationContext(
- SimulationContextType celt, String value) {
+ final SimulationContextType celt, final String value) {
SimulationContext result = null;
try {
SimulationContext.Properties cprop = new SimulationContext.Properties();
List<SimulationContext> clist = selectSimulationContextsWhere(cprop
.setType(celt).setValue(value));
- if (!clist.isEmpty())
+ if (!clist.isEmpty()) {
result = clist.get(0); // Supposed being the most used one if many exist
+ }
} catch (InvalidPropertyException error) {
logger.info("Attempt to select a simulation context \""
+ celt.getName() + "\" with an invalid value.");
*/
@Transactional(readOnly = true)
public List<SimulationContext> selectSimulationContextsWhere(
- SimulationContext.Properties cprop) {
+ final SimulationContext.Properties cprop) {
// StringBuffer query = new StringBuffer("from SimulationContext");
// String separator = " where";
SimulationContextType celt = cprop.getType();
* @see org.splat.service.SimulationContextService#selectTypesOf(org.splat.service.technical.ProjectSettingsService.Step[])
*/
public List<SimulationContextType> selectTypesOf(
- ProjectSettingsService.Step... step) {
+ final ProjectSettingsService.Step... step) {
// StringBuffer query = new StringBuffer(
// "from SimulationContextType where step='").append(
// step[0].getNumber()).append("'");
* @see org.splat.service.SimulationContextService#selectTypesWhere(org.splat.dal.bo.som.SimulationContextType.Properties)
*/
public List<SimulationContextType> selectTypesWhere(
- SimulationContextType.Properties sprop) {
+ final SimulationContextType.Properties sprop) {
// StringBuffer query = new StringBuffer("from SimulationContextType");
// String separator = " where";
ProjectSettingsService.Step step = sprop.getStep();
* @see org.splat.service.SimulationContextService#selectType(java.lang.String)
*/
@Transactional(readOnly = true)
- public SimulationContextType selectType(String name) {
+ public SimulationContextType selectType(final String name) {
return getSimulationContextTypeDAO().findByCriteria(
Restrictions.eq("name", name));
}
*
* @see org.splat.service.SimulationContextService#selectType(long)
*/
- public SimulationContextType selectType(long index) {
+ public SimulationContextType selectType(final long index) {
return getSimulationContextTypeDAO().get(index);
}
*
* @see org.splat.service.SimulationContextService#hold(org.splat.dal.bo.som.SimulationContext)
*/
- public void hold(SimulationContext simCtx) {
+ public void hold(final SimulationContext simCtx) {
simCtx.setCounter(simCtx.getCounter() + 1);
if (simCtx.isSaved()) {
getSimulationContextDAO().update(simCtx);
*
* @see org.splat.service.SimulationContextService#release(org.splat.dal.bo.som.SimulationContext)
*/
- public void release(SimulationContext simCtx) {
+ public void release(final SimulationContext simCtx) {
simCtx.setCounter(simCtx.getCounter() - 1);
if (simCtx.isSaved()) {
getSimulationContextDAO().update(simCtx);
* the context to approve
* @return true if approval succeeded
*/
- public boolean approve(SimulationContext simCtx) {
- if (simCtx.getProgressState() != ProgressState.inCHECK)
+ public boolean approve(final SimulationContext simCtx) {
+ if (simCtx.getProgressState() != ProgressState.inCHECK) {
return false;
+ }
simCtx.setProgressState(ProgressState.APPROVED); // The type name is supposed being localized
if (simCtx.isSaved()) {
getSimulationContextDAO().update(simCtx);
* @return
*/
public ProjectSettingsService.Step getAttachedStep(
- SimulationContextType simCtxType) {
- return ProjectSettingsServiceImpl.getStep(simCtxType.getStep());
+ final SimulationContextType simCtxType) {
+ return getProjectSettings().getStep(simCtxType.getStep());
}
/**
* the simulationContextDAO to set
*/
public void setSimulationContextDAO(
- SimulationContextDAO simulationContextDAO) {
+ final SimulationContextDAO simulationContextDAO) {
_simulationContextDAO = simulationContextDAO;
}
* the simulationContextTypeDAO to set
*/
public void setSimulationContextTypeDAO(
- SimulationContextTypeDAO simulationContextTypeDAO) {
+ final SimulationContextTypeDAO simulationContextTypeDAO) {
_simulationContextTypeDAO = simulationContextTypeDAO;
}
* @param projectSettingsService
* project settings service
*/
- public void setProjectSettings(ProjectSettingsService projectSettingsService) {
+ public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
_projectSettingsService = projectSettingsService;
}
}
import org.splat.kernel.NotApplicableException;
import org.splat.log.AppLogger;
import org.splat.service.technical.IndexService;
+import org.splat.service.technical.ProjectSettingsService;
import org.splat.som.Revision;
import org.splat.som.Step;
import org.springframework.transaction.annotation.Transactional;
* Injected versions relation DAO.
*/
private VersionsRelationDAO _versionsRelationDAO;
+ /**
+ * Injected project service.
+ */
+ private ProjectSettingsService _projectSettingsService;
/**
* {@inheritDoc}
*
* @see org.splat.service.StepService#addSimulationContext(org.splat.som.Step, org.splat.dal.bo.som.SimulationContext.Properties)
*/
- public SimulationContext addSimulationContext(Step aStep,
- SimulationContext.Properties dprop) throws MissedPropertyException,
+ public SimulationContext addSimulationContext(final Step aStep,
+ final SimulationContext.Properties dprop) throws MissedPropertyException,
InvalidPropertyException, MultiplyDefinedException {
SimulationContext context = new SimulationContext(dprop.setStep(aStep
.getStep()));
* @see org.splat.service.StepService#addSimulationContext(org.splat.som.Step, org.splat.dal.bo.som.SimulationContext)
*/
@Transactional
- public SimulationContext addSimulationContext(Step aStep,
- SimulationContext context) {
+ public SimulationContext addSimulationContext(final Step aStep,
+ final SimulationContext context) {
getSimulationContextService().hold(context); // Increments the reference count of simulation context
- if (aStep.getOwner().isSaved())
+ if (aStep.getOwner().isSaved()) {
try {
- if (!context.isSaved())
+ if (!context.isSaved()) {
getSimulationContextDAO().create(context);
+ }
aStep.getOwner().add(context);
aStep.getContex().add(context); // The context is also referenced from this (transient) Step
getProjectElementDAO().update(aStep.getOwner());
} catch (Exception error) {
return null;
}
- else { // Happens when copying a scenario
+ } else { // Happens when copying a scenario
aStep.getOwner().add(context);
aStep.getContex().add(context); // The context is also referenced from this (transient) Step
// In case of owner scenario, the Knowledge Element index will be updated later, when saving the scenario
* @param aStep
* the step (activity)
*/
- private void updateKnowledgeElementsIndex(Step aStep) {
+ private void updateKnowledgeElementsIndex(final Step aStep) {
Scenario[] scenarii;
if (aStep.getOwner() instanceof Scenario) {
scenarii = new Scenario[1];
* @throws IOException
* if can't update lucene index
*/
- private void updateScenarioIndex(Scenario scene) throws IOException {
+ private void updateScenarioIndex(final Scenario scene) throws IOException {
if (scene.getUcase() == null) {
for (Iterator<KnowledgeElement> i = scene.getKnowledgeElements()
.iterator(); i.hasNext();) {
KnowledgeElement kelm = i.next();
- if (!kelm.getType().equals("usecase"))
+ if (!kelm.getType().equals("usecase")) {
continue;
+ }
scene.setUcase(kelm);
break;
}
* @see org.splat.service.StepService#removeSimulationContext(org.splat.som.Step, org.splat.dal.bo.som.SimulationContext)
*/
@Transactional
- public boolean removeSimulationContext(Step aStep, SimulationContext context) {
+ public boolean removeSimulationContext(final Step aStep, final SimulationContext context) {
boolean isOk = false;
SimulationContext torem = aStep
.getSimulationContext(context.getIndex());
* @see org.splat.service.StepService#createDocument(org.splat.som.Step, org.splat.dal.bo.som.Document.Properties)
*/
@Transactional
- public Publication createDocument(Step aStep, Document.Properties dprop)
+ public Publication createDocument(final Step aStep, final Document.Properties dprop)
throws MissedPropertyException, InvalidPropertyException,
MultiplyDefinedException, IOException {
Document newdoc = new Document(dprop.setOwner(aStep.getOwner())
// Creation of the save directory
java.io.File wdir = getDocumentService().getSaveDirectory(newdoc);
- if (!wdir.exists())
- if (!wdir.mkdirs())
+ if (!wdir.exists()) {
+ if (!wdir.mkdirs()) {
throw new IOException(
"Cannot create the repository vault directory");
+ }
+ }
// Identification and save
getDocumentService().buildReferenceFrom(newdoc, aStep.getOwnerStudy());
*
* @see org.splat.service.StepService#assignDocument(org.splat.som.Step, org.splat.dal.bo.som.Document.Properties)
*/
- public Publication assignDocument(Step aStep, Document.Properties dprop)
+ public Publication assignDocument(final Step aStep, final Document.Properties dprop)
throws MissedPropertyException, InvalidPropertyException,
NotApplicableException {
String refid = dprop.getReference();
- if (refid == null)
+ if (refid == null) {
return null;
+ }
Document slot = getDocumentService().selectDocument(refid,
new Revision().toString());
- if (slot == null)
+ if (slot == null) {
return null;
- if (!slot.isUndefined())
+ }
+ if (!slot.isUndefined()) {
return null; // Should not happen
+ }
getDocumentService().initialize(slot,
dprop.setOwner(aStep.getOwnerStudy()));
* @throws MismatchException
* if the document is not applicable to the given study step
*/
- public Publication versionDocument(Step aStep, Publication base)
+ public Publication versionDocument(final Step aStep, final Publication base)
throws MissedPropertyException, InvalidPropertyException,
MultiplyDefinedException, IOException, MismatchException {
return versionDocument(aStep, base, new Document.Properties());
* @throws MismatchException
* if the document is not applicable to the given study step
*/
- public Publication versionDocument(Step aStep, Publication base,
- String reason) throws MissedPropertyException,
+ public Publication versionDocument(final Step aStep, final Publication base,
+ final String reason) throws MissedPropertyException,
InvalidPropertyException, MultiplyDefinedException, IOException,
MismatchException {
return versionDocument(aStep, base, new Document.Properties()
* if the document is not applicable to the given study step
*/
@Transactional
- public Publication versionDocument(Step aStep, Publication base,
- Document.Properties dprop) throws MissedPropertyException,
+ public Publication versionDocument(final Step aStep, final Publication base,
+ final Document.Properties dprop) throws MissedPropertyException,
InvalidPropertyException, MultiplyDefinedException, IOException,
MismatchException {
Document previous = base.value();
- dprop.setDocument(previous); // Initializes the Step property
- if (dprop.getStep().getNumber() != aStep.getNumber())
+ dprop.setDocument(previous, getProjectSettings().getStep(base.getStep().getNumber())); // Initializes the Step property
+ if (dprop.getStep().getNumber() != aStep.getNumber()) {
throw new MismatchException();
+ }
- if (dprop.getAuthor() == null)
+ if (dprop.getAuthor() == null) {
dprop.setAuthor(previous.getAuthor());
+ }
String summary = dprop.getDescription();
// Creation of the document
for (Iterator<Relation> i = relist.iterator(); i.hasNext();) {
UsedByRelation relation = (UsedByRelation) i.next();
Document relatedoc = relation.getTo();
- if (scope.shares(relatedoc))
+ if (scope.shares(relatedoc)) {
relatedoc.addRelation(new UsesRelation(relatedoc, newdoc));
- else
+ } else {
relation.moveTo(newdoc);
+ }
}
return new Publication(newdoc, aStep.getOwner());
}
* the study step
* @return the list of document types
*/
- public List<DocumentType> getValidDocumentTypes(Step aStep) {
+ public List<DocumentType> getValidDocumentTypes(final Step aStep) {
return getDocumentTypeService().selectTypesOf(aStep.getStep());
}
* the document publication to add
* @return true if publication succeeded
*/
- public boolean add(Step aStep, Publication newdoc) {
- if (!aStep.getOwner().add(newdoc))
+ public boolean add(final Step aStep, final Publication newdoc) {
+ if (!aStep.getOwner().add(newdoc)) {
return false; // Updates the study in memory
+ }
aStep.getDocuments().add(0, newdoc); // Updates this step
getDocumentService().hold(newdoc.value()); // Increments the configuration tag count of document
// If not yet saved, the Publication MUST NOT be saved here, although this creates a temporary inconsistent state into the
* the document publication to remove
* @return true if removing of the publication succeeded
*/
- public boolean remove(Step aStep, Publication oldoc) {
- if (!aStep.getOwner().remove(oldoc))
+ public boolean remove(final Step aStep, final Publication oldoc) {
+ if (!aStep.getOwner().remove(oldoc)) {
return false; // Updates the study in memory
+ }
aStep.getDocuments().remove(oldoc); // Updates this step
getDocumentService().release(oldoc.value()); // Decrements the configuration tag count of document
// The publication becoming orphan, it should automatically be removed from the database when updating of owner scenario.
* @return true if removing of the document succeeded
*/
@Transactional
- public boolean removeDocument(Step aStep, Publication doctag) {
+ public boolean removeDocument(final Step aStep, final Publication doctag) {
Document value = doctag.value();
getDocumentDAO().update(value);
Publication torem = aStep.getDocument(value.getIndex());
- if (torem == null)
+ if (torem == null) {
return false;
+ }
remove(aStep, torem);
getProjectElementDAO().update(aStep.getOwner());
* @param documentService
* the documentService to set
*/
- public void setDocumentService(DocumentService documentService) {
+ public void setDocumentService(final DocumentService documentService) {
_documentService = documentService;
}
* the simulationContextService to set
*/
public void setSimulationContextService(
- SimulationContextService simulationContextService) {
+ final SimulationContextService simulationContextService) {
_simulationContextService = simulationContextService;
}
* @param documentDAO
* the documentDAO to set
*/
- public void setDocumentDAO(DocumentDAO documentDAO) {
+ public void setDocumentDAO(final DocumentDAO documentDAO) {
_documentDAO = documentDAO;
}
* the simulationContextDAO to set
*/
public void setSimulationContextDAO(
- SimulationContextDAO simulationContextDAO) {
+ final SimulationContextDAO simulationContextDAO) {
_simulationContextDAO = simulationContextDAO;
}
* @param projectElementDAO
* the projectElementDAO to set
*/
- public void setProjectElementDAO(ProjectElementDAO projectElementDAO) {
+ public void setProjectElementDAO(final ProjectElementDAO projectElementDAO) {
_projectElementDAO = projectElementDAO;
}
* @param indexService
* the indexService to set
*/
- public void setIndexService(IndexService indexService) {
+ public void setIndexService(final IndexService indexService) {
_indexService = indexService;
}
* @param fileDAO
* the fileDAO to set
*/
- public void setFileDAO(FileDAO fileDAO) {
+ public void setFileDAO(final FileDAO fileDAO) {
_fileDAO = fileDAO;
}
* @param documentTypeService
* the documentTypeService to set
*/
- public void setDocumentTypeService(DocumentTypeService documentTypeService) {
+ public void setDocumentTypeService(final DocumentTypeService documentTypeService) {
_documentTypeService = documentTypeService;
}
* Set the versionsRelationDAO.
* @param versionsRelationDAO the versionsRelationDAO to set
*/
- public void setVersionsRelationDAO(VersionsRelationDAO versionsRelationDAO) {
+ public void setVersionsRelationDAO(final VersionsRelationDAO versionsRelationDAO) {
_versionsRelationDAO = versionsRelationDAO;
}
+
+ /**
+ * Get project settings.
+ *
+ * @return Project settings service
+ */
+ private ProjectSettingsService getProjectSettings() {
+ return _projectSettingsService;
+ }
+
+ /**
+ * Set project settings service.
+ *
+ * @param projectSettingsService
+ * project settings service
+ */
+ public void setProjectSettings(
+ final ProjectSettingsService projectSettingsService) {
+ _projectSettingsService = projectSettingsService;
+ }
}
* @see org.splat.service.StudyService#selectStudy(long)
*/
@Transactional
- public Study selectStudy(long index) {
+ public Study selectStudy(final long index) {
Study result = getStudyDAO().get(index);
loadWorkflow(result);
return result;
* @return found study or null
*/
@Transactional(readOnly = true)
- public Study selectStudy(String refid) {
+ public Study selectStudy(final String refid) {
Study result = getStudyDAO().findByCriteria(
Restrictions.eq("sid", refid));
loadWorkflow(result);
* @see org.splat.service.StudyService#createStudy(org.splat.dal.bo.som.Study.Properties)
*/
@Transactional
- public Study createStudy(Study.Properties sprop)
+ public Study createStudy(final Study.Properties sprop)
throws MissedPropertyException, InvalidPropertyException,
MultiplyDefinedException {
sprop.setReference(getProjectSettings().getReferencePattern());
* @see org.splat.service.StudyService#addProjectContext(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.SimulationContext.Properties)
*/
@Transactional
- public SimulationContext addProjectContext(Study aStudy,
- SimulationContext.Properties cprop) throws MissedPropertyException,
- InvalidPropertyException, MultiplyDefinedException {
+ public SimulationContext addProjectContext(final Study aStudy,
+ final SimulationContext.Properties cprop)
+ throws MissedPropertyException, InvalidPropertyException,
+ MultiplyDefinedException {
SimulationContext added = getStepService().addSimulationContext(
getProjectElementService().getFirstStep(aStudy), cprop);
update(aStudy);
* @see org.splat.service.StudyService#addProjectContext(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.SimulationContext)
*/
@Transactional
- public SimulationContext addProjectContext(Study aStudy,
- SimulationContext context) {
+ public SimulationContext addProjectContext(final Study aStudy,
+ final SimulationContext context) {
SimulationContext added = getStepService().addSimulationContext(
getProjectElementService().getFirstStep(aStudy), context);
update(aStudy);
*
* @see org.splat.service.StudyService#addContributor(org.splat.dal.bo.som.Study, org.splat.dal.bo.kernel.User)
*/
- public boolean addContributor(Study aStudy, User user) {
+ public boolean addContributor(final Study aStudy, final User user) {
List<User> contributor = getModifiableContributors(aStudy); // Initializes contributor
for (Iterator<User> i = contributor.iterator(); i.hasNext();) {
User present = i.next();
- if (present.equals(user))
+ if (present.equals(user)) {
return false;
+ }
}
boolean absent = getModifiableActors(aStudy).add(user); // User may already be a reviewer or an approver
aStudy.addRelation(new ContributorRelation(aStudy, user));
- if (absent)
+ if (absent) {
update(aStudy); // Else, useless to re-index the study
+ }
contributor.add(user);
return true;
}
* @see #isPublic()
* @see Publication#approve(Date)
*/
- public boolean moveToReference(Study aStudy) {
- if (aStudy.getProgressState() != ProgressState.APPROVED)
+ public boolean moveToReference(final Study aStudy) {
+ if (aStudy.getProgressState() != ProgressState.APPROVED) {
return false;
- if (aStudy.getVisibility() != Visibility.PUBLIC)
+ }
+ if (aStudy.getVisibility() != Visibility.PUBLIC) {
return false;
+ }
aStudy.setVisibility(Visibility.REFERENCE);
if (update(aStudy)) {
*
* @see org.splat.service.StudyService#update(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.Study.Properties)
*/
- public boolean update(Study aStudy, Properties sprop)
+ public boolean update(final Study aStudy, final Properties sprop)
throws InvalidPropertyException {
- if (sprop.getTitle() != null)
+ if (sprop.getTitle() != null) {
aStudy.setTitle(sprop.getTitle());
- if (sprop.getSummary() != null)
+ }
+ if (sprop.getSummary() != null) {
aStudy.setAttribute(new DescriptionAttribute(aStudy, sprop
.getSummary()));
+ }
// TODO: To be completed
return update(aStudy);
}
* the document
* @return true if the document is published in the study
*/
- private boolean publishes(Study aStudy, Document doc) {
+ private boolean publishes(final Study aStudy, final Document doc) {
if (!aStudy.publishes(doc)) {
Scenario[] scene = aStudy.getScenarii();
for (int i = 0; i < scene.length; i++) {
- if (scene[i].publishes(doc))
+ if (scene[i].publishes(doc)) {
return true;
+ }
}
}
return false;
*
* @see org.splat.service.StudyService#removeContributor(org.splat.dal.bo.som.Study, org.splat.dal.bo.kernel.User[])
*/
- public boolean removeContributor(Study aStudy, User... users) {
+ public boolean removeContributor(final Study aStudy, final User... users) {
List<User> contributor = getModifiableContributors(aStudy); // Initializes contributor
Boolean done = false;
for (int i = 0; i < users.length; i++) {
User user = users[i];
for (Iterator<User> j = contributor.iterator(); j.hasNext();) {
User present = j.next();
- if (!present.equals(user))
+ if (!present.equals(user)) {
continue;
+ }
aStudy.removeRelation(ContributorRelation.class, user);
j.remove(); // Updates the contributor shortcut
break;
}
}
- if (done)
+ if (done) {
update(aStudy);
+ }
return done;
}
*
* @see org.splat.service.StudyService#removeProjectContext(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.SimulationContext)
*/
- public boolean removeProjectContext(Study aStudy, SimulationContext context) {
+ public boolean removeProjectContext(final Study aStudy,
+ final SimulationContext context) {
boolean done = getStepService().removeSimulationContext(
getProjectElementService().getFirstStep(aStudy), context);
update(aStudy);
* org.splat.dal.bo.som.ValidationCycle.Properties)
*/
@Transactional
- public void setValidationCycle(Study aStudy, DocumentType type,
- ValidationCycle.Properties vprop) {
+ public void setValidationCycle(final Study aStudy, final DocumentType type,
+ final ValidationCycle.Properties vprop) {
Map<String, ValidationCycle> validactor = aStudy.getValidationCycles();
- if (validactor == null)
+ if (validactor == null) {
setShortCuts(aStudy); // Initializes validactor and actor
+ }
String cname = type.getName();
ValidationCycle cycle = validactor.get(cname);
if (cycle != null && cycle.isAssigned()) {
resetActors(cycle, vprop);
- } else
+ } else {
try {
cycle = new ValidationCycle(aStudy, vprop.setDocumentType(type));
error);
return;
}
+ }
resetActorsShortCut(aStudy);
update(aStudy); // Re-index the study, just in case
}
* a study to demote
* @return true if the demotion succeeded.
*/
- public boolean demote(Study aStudy) {
- if (aStudy.getProgressState() == ProgressState.inCHECK)
+ public boolean demote(final Study aStudy) {
+ if (aStudy.getProgressState() == ProgressState.inCHECK) {
aStudy.setProgressState(ProgressState.inDRAFT);
- else if (aStudy.getProgressState() == ProgressState.inDRAFT)
+ } else if (aStudy.getProgressState() == ProgressState.inDRAFT) {
aStudy.setProgressState(ProgressState.inWORK);
- else
+ } else {
return false;
+ }
return update(aStudy);
}
* @see org.splat.service.StudyService#generateLocalIndex(org.splat.dal.bo.som.Study)
*/
@Transactional
- public int generateLocalIndex(Study aStudy) {
+ public int generateLocalIndex(final Study aStudy) {
aStudy.setLastLocalIndex(aStudy.getLastLocalIndex() + 1);
getStudyDAO().update(aStudy);
return aStudy.getLastLocalIndex();
* a study to promote
* @return true if the demotion succeeded.
*/
- public boolean promote(Study aStudy) {
+ public boolean promote(final Study aStudy) {
if (aStudy.getProgressState() == ProgressState.inWORK) {
aStudy.setProgressState(ProgressState.inDRAFT);
} else if (aStudy.getProgressState() == ProgressState.inDRAFT) {
}
} else if (aStudy.getProgressState() == ProgressState.inCHECK) {
aStudy.setProgressState(ProgressState.APPROVED);
- } else
+ } else {
return false;
+ }
return update(aStudy);
}
* @return true if the move succeeded.
* @see #isPublic()
*/
- public boolean moveToPublic(Study aStudy) {
+ public boolean moveToPublic(final Study aStudy) {
boolean isOk = false;
if (aStudy.getVisibility() == Visibility.PRIVATE) {
aStudy.setVisibility(Visibility.PUBLIC);
* @return true if the study is updated successfully
*/
@Transactional
- private boolean update(Study aStudy) {
+ private boolean update(final Study aStudy) {
boolean isOk = false;
try {
getStudyDAO().update(aStudy); // Update of relational base
* @return true if reference building is succeded
*/
@Transactional
- private boolean buildReference(Study aStudy) {
+ private boolean buildReference(final Study aStudy) {
String pattern = aStudy.getReference(); // The study being supposed just created, its reference is the reference pattern
IDBuilder tool = selectIDBuilder(aStudy.getDate());
if (tool == null) {
* @return true if reference building is succeded
*/
@Transactional
- public String buildReference(IDBuilder aBuilder, String pattern, Study study) {
+ public String buildReference(final IDBuilder aBuilder,
+ final String pattern, final Study study) {
char[] format = pattern.toCharArray();
char[] ref = new char[80]; // Better evaluate the length of the generated string
int next = aBuilder.getBase() + 1;
int n = i;
while (format[i] == 'y') {
i += 1;
- if (i == format.length)
+ if (i == format.length) {
break;
+ }
}
SimpleDateFormat tostring = new SimpleDateFormat("yyyy");
String year = tostring.format(study.getDate());
int n = i;
while (format[i] == '0') {
i += 1;
- if (i == format.length)
+ if (i == format.length) {
break;
+ }
}
DecimalFormat tostring = new DecimalFormat(pattern
.substring(n, i));
* the date
* @return found id builder
*/
- private IDBuilder selectIDBuilder(Date date) {
+ private IDBuilder selectIDBuilder(final Date date) {
Calendar aDate = Calendar.getInstance();
aDate.setTime(date);
return getIDBuilderDAO().findByCriteria(
* @param aStudy
* the study
*/
- private void resetActorsShortCut(Study aStudy) {
+ private void resetActorsShortCut(final Study aStudy) {
getModifiableActors(aStudy).clear();
// Get all actors involved in validation cycles
for (Iterator<ValidationCycle> i = aStudy.getValidationCycles()
.values().iterator(); i.hasNext();) {
ValidationCycle cycle = i.next();
User[] user = cycle.getAllActors();
- for (int j = 0; j < user.length; j++)
+ for (int j = 0; j < user.length; j++) {
getModifiableActors(aStudy).add(user[j]);
+ }
}
// Get all other actors
for (Iterator<Relation> i = aStudy.getAllRelations().iterator(); i
.hasNext();) {
Relation link = i.next();
Class<?> kindof = link.getClass().getSuperclass();
- if (!kindof.equals(ActorRelation.class))
+ if (!kindof.equals(ActorRelation.class)) {
continue;
+ }
getModifiableActors(aStudy).add(((ActorRelation) link).getTo());
}
}
* the study
* @return true if reindexing succeeded
*/
- private boolean updateKnowledgeElementsIndex(Study aStudy) {
+ private boolean updateKnowledgeElementsIndex(final Study aStudy) {
boolean isOk = false;
try {
IndexService lucin = getIndex();
*/
private IndexService getIndex() throws IOException {
IndexService lucin = getIndexService();
- if (!lucin.exists())
+ if (!lucin.exists()) {
lucin.create(); // Happens when re-indexing all studies
+ }
return lucin;
}
* the cycle description
* @return the new validation cycle
*/
- protected ValidationCycle createValidationCycle(Study from,
- ProjectSettingsServiceImpl.ProjectSettingsValidationCycle cycle) {
- // -----------------------------------------------------------------------------
+ protected ValidationCycle createValidationCycle(
+ final Study from,
+ final ProjectSettingsServiceImpl.ProjectSettingsValidationCycle cycle) {
Actor[] actype = cycle.getActorTypes();
User.Properties uprop = new User.Properties();
ValidationCycle aValidationCycle = new ValidationCycle();
aValidationCycle.setDocumentType(getDocumentTypeService().selectType(
cycle.getName())); // Null in case of default validation cycle
- // context = new ValidationCycleRelation(from, this);
+ // context = new ValidationCycleRelation(from, vprop);
// RKV aValidationCycle.context = null; // Validation cycle defined in the workflow
for (int i = 0; i < actype.length; i++) {
User actor = null;
- if (actype[i] != null)
+ if (actype[i] != null) {
try {
if (actype[i] == Actor.manager) {
actor = from.getAuthor();
} else if (actype[i] == Actor.Nx1) {
List<User> manager = getUserService().selectUsersWhere(
uprop.setOrganizationName("Nx1"));
- if (manager.size() == 1)
+ if (manager.size() == 1) {
actor = manager.get(0);
+ }
} else if (actype[i] == Actor.Nx2) {
List<User> manager = getUserService().selectUsersWhere(
uprop.setOrganizationName("Nx2"));
- if (manager.size() == 1)
+ if (manager.size() == 1) {
actor = manager.get(0);
+ }
} else { /* Actor.customer */
actor = from.getAuthor();
// TODO: Get the customer of the study, if exists
} catch (Exception e) { // Should not happen
actor = null;
}
- if (i == 0)
+ }
+ if (i == 0) {
aValidationCycle.setReviewer(actor);
- else if (i == 1)
+ } else if (i == 1) {
aValidationCycle.setApprover(actor);
- else if (i == 2)
+ } else if (i == 2) {
aValidationCycle.setSignatory(actor);
+ }
}
return aValidationCycle;
}
* the validation step to remove
*/
@Transactional
- protected void remove(ValidationCycle aValidationCycle, ValidationStep step) {
- // ------------------------------------------
- if (step == ValidationStep.REVIEW)
+ protected void remove(final ValidationCycle aValidationCycle,
+ final ValidationStep step) {
+ if (step == ValidationStep.REVIEW) {
aValidationCycle.setReviewer(null);
- else if (step == ValidationStep.APPROVAL)
+ } else if (step == ValidationStep.APPROVAL) {
aValidationCycle.setApprover(null);
- else if (step == ValidationStep.ACCEPTANCE
- || step == ValidationStep.REFUSAL)
+ } else if (step == ValidationStep.ACCEPTANCE
+ || step == ValidationStep.REFUSAL) {
aValidationCycle.setSignatory(null);
+ }
if (aValidationCycle.isSaved()) {
getValidationCycleDAO().update(aValidationCycle);
}
* new validation cycle properties containing new actors
*/
@Transactional
- public void resetActors(ValidationCycle aValidationCycle,
- ValidationCycle.Properties vprop) {
+ public void resetActors(final ValidationCycle aValidationCycle,
+ final ValidationCycle.Properties vprop) {
aValidationCycle.setPublisher(vprop.getPublisher()); // May be null
aValidationCycle.setReviewer(vprop.getReviewer()); // May be null
aValidationCycle.setApprover(vprop.getApprover()); // May be null
* the actor to set
*/
@Transactional
- protected void setActor(ValidationCycle aValidationCycle,
- ValidationStep step, User actor) {
+ protected void setActor(final ValidationCycle aValidationCycle,
+ final ValidationStep step, final User actor) {
if (step == ValidationStep.PROMOTION) {
aValidationCycle.setPublisher(actor);
} else if (step == ValidationStep.REVIEW) {
* @return the actors of this study
* @see #hasActor(User)
*/
- public Set<User> getActors(Study aStudy) {
- if (aStudy.getActor() == null)
+ public Set<User> getActors(final Study aStudy) {
+ if (aStudy.getActor() == null) {
setShortCuts(aStudy);
+ }
return Collections.unmodifiableSet(aStudy.getActor());
}
* @return the modifiable set of actors of this study
* @see #hasActor(User)
*/
- public Set<User> getModifiableActors(Study aStudy) {
- if (aStudy.getActor() == null)
+ public Set<User> getModifiableActors(final Study aStudy) {
+ if (aStudy.getActor() == null) {
setShortCuts(aStudy);
+ }
return aStudy.getActor();
}
* the study
* @return the unmodifiable not null transient list of contributors of this study
*/
- public List<User> getContributors(Study aStudy) {
- if (aStudy.getContributor() == null)
+ public List<User> getContributors(final Study aStudy) {
+ if (aStudy.getContributor() == null) {
setShortCuts(aStudy);
+ }
return Collections.unmodifiableList(aStudy.getContributor()); // May be empty
}
* the study
* @return the modifiable not null transient list of contributors of this study
*/
- public List<User> getModifiableContributors(Study aStudy) {
- if (aStudy.getContributor() == null)
+ public List<User> getModifiableContributors(final Study aStudy) {
+ if (aStudy.getContributor() == null) {
setShortCuts(aStudy);
+ }
return aStudy.getContributor(); // May be empty
}
* the document type being subject of validation
* @return the validation cycle of the document, or null if not defined.
*/
- public ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type) {
- if (aStudy.getValidationCycles() == null)
+ public ValidationCycle getValidationCycleOf(final Study aStudy,
+ final DocumentType type) {
+ if (aStudy.getValidationCycles() == null) {
setShortCuts(aStudy);
+ }
ValidationCycle result = aStudy.getValidationCycles().get(
type.getName());
if (result == null) {
- if (type.isStepResult())
+ if (type.isStepResult()) {
result = aStudy.getValidationCycles().get("default"); // "default" validation cycle defined in the configuration, if exist
- if (result == null)
+ }
+ if (result == null) {
result = aStudy.getValidationCycles().get("built-in");
+ }
}
return result;
}
* @return true if the given user is actor of this study.
* @see #getActors()
*/
- public boolean hasActor(Study aStudy, User user) {
- if (user == null)
+ public boolean hasActor(final Study aStudy, final User user) {
+ if (user == null) {
return false;
+ }
for (Iterator<User> i = getActors(aStudy).iterator(); i.hasNext();) {
User involved = i.next();
- if (involved.equals(user))
+ if (involved.equals(user)) {
return true;
+ }
}
return false;
}
* @return true if the given user is actor of this study.
* @see #getContributors()
*/
- public boolean isStaffedBy(Study aStudy, User user) {
+ public boolean isStaffedBy(final Study aStudy, final User user) {
if (user == null) {
return false;
}
if (aStudy == null) {
return false;
}
- if (aStudy.getAuthor() == null) return false;
- if (aStudy.getAuthor().equals(user))
+ if (aStudy.getAuthor() == null) {
+ return false;
+ }
+ if (aStudy.getAuthor().equals(user)) {
return true;
+ }
for (Iterator<User> i = getContributors(aStudy).iterator(); i.hasNext();) {
- if (i.next().equals(user))
+ if (i.next().equals(user)) {
return true;
+ }
}
return false;
}
* @param aStudy
* the study
*/
- public void loadWorkflow(Study aStudy) {
+ public void loadWorkflow(final Study aStudy) {
setShortCuts(aStudy);
}
* @param aStudy
* the study
*/
- public void setShortCuts(Study aStudy) {
+ public void setShortCuts(final Study aStudy) {
aStudy.getContributor().clear();
aStudy.getValidationCycles().clear();
aStudy.getActor().clear();
// context
}
// Get the validation cycles coming from the configured workflow and not overridden in this study
- for (Iterator<ProjectSettingsServiceImpl.ProjectSettingsValidationCycle> i = ProjectSettingsServiceImpl
+ for (Iterator<ProjectSettingsServiceImpl.ProjectSettingsValidationCycle> i = getProjectSettings()
.getAllValidationCycles().iterator(); i.hasNext();) {
ProjectSettingsServiceImpl.ProjectSettingsValidationCycle cycle = i
.next();
String type = cycle.getName();
- if (!aStudy.getValidationCycles().containsKey(type))
+ if (!aStudy.getValidationCycles().containsKey(type)) {
aStudy.getValidationCycles().put(type,
createValidationCycle(aStudy, cycle));
+ }
}
// Get all corresponding actors
for (Iterator<ValidationCycle> i = aStudy.getValidationCycles()
.values().iterator(); i.hasNext();) {
ValidationCycle cycle = i.next();
User[] user = cycle.getAllActors();
- for (int j = 0; j < user.length; j++)
+ for (int j = 0; j < user.length; j++) {
aStudy.getActor().add(user[j]);
+ }
}
// Get all other actors
for (Iterator<Relation> i = aStudy.getAllRelations().iterator(); i
.hasNext();) {
Relation link = i.next();
Class<?> kindof = link.getClass().getSuperclass();
- if (!kindof.equals(ActorRelation.class))
+ if (!kindof.equals(ActorRelation.class)) {
continue;
+ }
aStudy.getActor().add(((ActorRelation) link).getTo());
}
}
* @param projectSettingsService
* project settings service
*/
- public void setProjectSettings(ProjectSettingsService projectSettingsService) {
+ public void setProjectSettings(
+ final ProjectSettingsService projectSettingsService) {
_projectSettingsService = projectSettingsService;
}
* the projectElementService to set
*/
public void setProjectElementService(
- ProjectElementService projectElementService) {
+ final ProjectElementService projectElementService) {
_projectElementService = projectElementService;
}
* @param stepService
* the stepService to set
*/
- public void setStepService(StepService stepService) {
+ public void setStepService(final StepService stepService) {
_stepService = stepService;
}
* @param indexService
* the indexService to set
*/
- public void setIndexService(IndexService indexService) {
+ public void setIndexService(final IndexService indexService) {
_indexService = indexService;
}
* @param studyDAO
* the studyDAO to set
*/
- public void setStudyDAO(StudyDAO studyDAO) {
+ public void setStudyDAO(final StudyDAO studyDAO) {
_studyDAO = studyDAO;
}
* @param builderDAO
* the iDBuilderDAO to set
*/
- public void setIDBuilderDAO(IDBuilderDAO builderDAO) {
+ public void setIDBuilderDAO(final IDBuilderDAO builderDAO) {
_iDBuilderDAO = builderDAO;
}
* @param scenarioDAO
* the scenarioDAO to set
*/
- public void setScenarioDAO(ScenarioDAO scenarioDAO) {
+ public void setScenarioDAO(final ScenarioDAO scenarioDAO) {
_scenarioDAO = scenarioDAO;
}
* @param validationCycleDAO
* the validationCycleDAO to set
*/
- public void setValidationCycleDAO(ValidationCycleDAO validationCycleDAO) {
+ public void setValidationCycleDAO(
+ final ValidationCycleDAO validationCycleDAO) {
_validationCycleDAO = validationCycleDAO;
}
* @param documentTypeService
* the documentTypeService to set
*/
- public void setDocumentTypeService(DocumentTypeService documentTypeService) {
+ public void setDocumentTypeService(
+ final DocumentTypeService documentTypeService) {
_documentTypeService = documentTypeService;
}
* @param userService
* the userService to set
*/
- public void setUserService(UserService userService) {
+ public void setUserService(final UserService userService) {
_userService = userService;
}
}
import org.splat.dal.bo.som.ProjectElement;
import org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming;
+import org.splat.service.technical.ProjectSettingsServiceImpl.ProjectSettingsValidationCycle;
/**
- * @author rkv
- *
+ * Project settings service interface.
*/
public interface ProjectSettingsService {
+ /**
+ * Transient study step data.
+ */
public static class Step {
- // ------------------------
+ /**
+ * The sequential number of the step.
+ */
int number;
- private Class<? extends ProjectElement> level; // Study or Scenario
- Set<Class<?>> contents; // Set of Document and/or Knowledge
+
+ /**
+ * The owner of the step: study or scenario.
+ */
+ private Class<? extends ProjectElement> level;
+ /**
+ * Set of Document and/or Knowledge applicable on this step.
+ */
+ Set<Class<?>> contents;
+ /**
+ * Data path for this step.
+ */
private String path;
- Step(int number, Class<? extends ProjectElement> level, String path) {
+ /**
+ * Create a transient study step definition.
+ *
+ * @param number
+ * the step sequential number
+ * @param level
+ * the level (study or scenario) the step is applied to
+ * @param path
+ * the step data path
+ */
+ Step(final int number, final Class<? extends ProjectElement> level,
+ final String path) {
this.initialize(number, level, path);
}
- private Step(int number, Class<? extends ProjectElement> level,
- Class<?> contents, String path) {
+ /**
+ * Create a transient study step definition.
+ *
+ * @param number
+ * the step sequential number
+ * @param level
+ * the level (study or scenario) the step is applied to
+ * @param contents
+ * the set of applicable data types
+ * @param path
+ * the step data path
+ */
+ @SuppressWarnings("unused")
+ private Step(final int number,
+ final Class<? extends ProjectElement> level,
+ final Class<?> contents, final String path) {
this.initialize(number, level, path);
this.contents.add(contents);
}
- private void initialize(int number,
- Class<? extends ProjectElement> level, String path) {
+ /**
+ * Initialize the study step.
+ *
+ * @param number
+ * the step sequential number
+ * @param level
+ * the level (study or scenario) the step is applied to
+ * @param path
+ * the step data path
+ */
+ private void initialize(final int number,
+ final Class<? extends ProjectElement> level, final String path) {
this.number = number;
this.level = level;
this.path = path + "/";
this.contents = new HashSet<Class<?>>();
}
- public boolean appliesTo(Class<? extends ProjectElement> level) {
+ /**
+ * Check if the step is applied to a study or a scenario level.
+ *
+ * @param level
+ * the study or a scenario to check the step applicability
+ * @return true if the step is applied to the given level
+ */
+ public boolean appliesTo(final Class<? extends ProjectElement> level) {
return (level == this.level);
}
- public boolean mayContain(Class<?> type) {
+ /**
+ * Check if the step can contain documents or knowledges of the given type.
+ *
+ * @param type
+ * the document type
+ * @return true if the step can contain data of the given type
+ */
+ public boolean mayContain(final Class<?> type) {
return contents.contains(type);
}
+ /**
+ * Get the sequential number of the step.
+ *
+ * @return the sequential number of the step
+ */
public int getNumber() {
return number;
}
+ /**
+ * Get data path for this step.
+ *
+ * @return data path for this step
+ */
public String getPath() {
return path;
}
}
- public FileNaming getFileNamingScheme();
-
+ /**
+ * Return the validation cycles of result documents defined in the workflow, ordered by study activities and ending by the default
+ * validation cycle, if defined.
+ *
+ * @return the validation cycles of the workflow
+ */
+ public List<ProjectSettingsValidationCycle> getAllValidationCycles();
+
+ /**
+ * Get a study step by its sequential number.
+ *
+ * @param number
+ * the step number
+ * @return the step
+ */
+ public ProjectSettingsService.Step getStep(final int number);
+
+ /**
+ * Get ordered list of (transient) study steps.
+ *
+ * @return the list of steps from project settings
+ */
public List<ProjectSettingsService.Step> getAllSteps();
+ /**
+ * Get file naming scheme setting.
+ *
+ * @return file naming scheme
+ * @see org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming
+ */
+ public FileNaming getFileNamingScheme();
+
+ /**
+ * Get a pattern of study references.
+ *
+ * @return the reference pattern
+ */
public String getReferencePattern();
+ /**
+ * Get a pattern of the presentation of version numbers.
+ *
+ * @return the version numbers presentation pattern
+ */
public String getRevisionPattern();
+ /**
+ * Load workflow configuration from the given file. <br/> Create necessary default staff in the database if it is not initialized yet.
+ *
+ * @param filename
+ * the workflow configuration file
+ * @throws IOException
+ * if there is a file reading or index creation problem
+ * @throws SQLException
+ * if there is a database population problem
+ */
public void configure(String filename) throws IOException, SQLException;
+ /**
+ * Get steps of the given project element (study or scenario).
+ *
+ * @param level
+ * the project element (study or scenario)
+ * @return the list of steps
+ */
public List<ProjectSettingsService.Step> getStepsOf(
Class<? extends ProjectElement> level);
}
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.log4j.Logger;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.service.DocumentTypeService;
import org.splat.service.KnowledgeElementTypeService;
import org.splat.service.SimulationContextTypeService;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+/**
+ * SIMAN configuration data service.
+ */
public class ProjectSettingsServiceImpl implements ProjectSettingsService {
/**
.getLogger(ProjectSettingsServiceImpl.class);
// Non persistent configuration information
- private Properties reprop; // Repository settings
- private String pattern; // Pattern of study references
- private FileNaming naming; // Scheme of file names stored into the repository
- private String versioning; // Pattern of the presentation of version numbers
- private Vector<ProjectSettingsService.Step> steps; // Ordered list of (transient) study steps
- private Vector<ProjectSettingsValidationCycle> concycles; // Configuration document validation cycles
+ /**
+ * Repository settings.
+ */
+ private final Properties reprop = new Properties();
+ /**
+ * Pattern of study references.
+ */
+ private String pattern;
+ /**
+ * Scheme of file names stored into the repository.
+ */
+ private FileNaming naming;
+ /**
+ * Pattern of the presentation of version numbers.
+ */
+ private String versioning;
+ /**
+ * Ordered list of (transient) study steps.
+ */
+ private final Vector<ProjectSettingsService.Step> steps = new Vector<ProjectSettingsService.Step>();
+ /**
+ * Configuration document validation cycles.
+ */
+ private Vector<ProjectSettingsValidationCycle> concycles;
// Temporary attributes initialized from the configuration file for populating the database with object types
- private LinkedHashMap<String, String> mapuse; // Document type names and uses mapping
- private Vector<String> context; // Simulation Context type names
- private Vector<String> kname; // Knowledge Element type names
- private Vector<NamedNodeMap> flows; // Document flows
- private Vector<NamedNodeMap> sclass; // Study classifications
+ /**
+ * Document type names and uses mapping.
+ */
+ private LinkedHashMap<String, String> mapuse;
+ /**
+ * Simulation Context type names.
+ */
+ private Vector<String> context;
+ /**
+ * Knowledge Element type names.
+ */
+ private Vector<String> kname;
+ /**
+ * Document flows.
+ */
+ private Vector<NamedNodeMap> flows;
+ /**
+ * Study classifications.
+ */
+ private Vector<NamedNodeMap> sclass;
// Other resources
- private static ProjectSettingsServiceImpl my = null; // Singleton instance
+ /**
+ * Database service to check its version, etc.
+ */
private Database _database;
/**
* Injected simulation context type service.
title, encoded, asis
}
+ /**
+ * Validation cycle defined in the XML configuration.
+ */
public static class ProjectSettingsValidationCycle {
- // -----------------------------------
- private String name;
- private Actor[] actor;
-
+ /**
+ * Cycle (document) type name.
+ */
+ private final String name;
+ /**
+ * Array of cycle actors positions in the organization. TODO: Must be replaced by Roles.
+ */
+ private final Actor[] actor;
+
+ /**
+ * Default constructor.
+ */
private ProjectSettingsValidationCycle() {
this.name = "built-in";
this.actor = new Actor[] { null, null, null };
}
- private ProjectSettingsValidationCycle(String name, Actor[] actor) {
+ /**
+ * Create a validation cycle definition for the given document type name and actors positions.
+ *
+ * @param name
+ * the document type name
+ * @param actor
+ * the array of actors positions
+ */
+ private ProjectSettingsValidationCycle(final String name,
+ final Actor[] actor) {
this.name = name;
this.actor = actor;
}
+ /**
+ * The processed document type name.
+ *
+ * @return the document type name
+ */
public String getName() {
return name;
}
+ /**
+ * Get an array of cycle actors positions.
+ *
+ * @return the array of actors positions
+ * @see org.splat.dal.bo.som.ValidationCycle.Actor
+ */
public Actor[] getActorTypes() {
return actor;
}
}
- // ==============================================================================================================================
- // Construction
- // ==============================================================================================================================
- protected ProjectSettingsServiceImpl() {
- // ----------------------------
- reprop = new Properties();
- steps = new Vector<ProjectSettingsService.Step>();
- my = this;
- }
-
// ==============================================================================================================================
// Public functions
// ==============================================================================================================================
- public void configure(String filename) throws IOException, SQLException {
- // ---------------------------------------
- if (!steps.isEmpty())
+ /**
+ * Load workflow configuration from the given file. <br/> Create necessary default staff in the database if it is not initialized yet.
+ *
+ * @param filename
+ * the workflow configuration file
+ * @throws IOException
+ * if there is a file reading or index creation problem
+ * @throws SQLException
+ * if there is a database population problem
+ */
+ public void configure(final String filename) throws IOException,
+ SQLException {
+ if (!steps.isEmpty()) {
return; // Project already configured
+ }
Database base = getDatabase().getCheckedDB();
File config = new File(filename);
}
}
+ /**
+ * Get ordered list of (transient) study steps.
+ *
+ * @return the list of steps from project settings
+ */
public List<ProjectSettingsService.Step> getAllSteps() {
- // ---------------------------------------
return steps;
}
*
* @return the validation cycles of the workflow
*/
- public static List<ProjectSettingsValidationCycle> getAllValidationCycles() {
- // -------------------------------------------------------------
- return my.concycles;
+ public List<ProjectSettingsValidationCycle> getAllValidationCycles() {
+ return concycles;
}
+ /**
+ * Get file naming scheme setting.
+ *
+ * @return file naming scheme
+ * @see org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming
+ */
public FileNaming getFileNamingScheme() {
- // -----------------------------------------------
return naming;
}
- public static ProjectSettingsValidationCycle getNewValidationCycle() {
- // ------------------------------------------------------
- return new ProjectSettingsValidationCycle();
- }
-
+ /**
+ * Get a pattern of study references.
+ *
+ * @return the reference pattern
+ */
public String getReferencePattern() {
return pattern;
}
+ /**
+ * Get a pattern of the presentation of version numbers.
+ *
+ * @return the version numbers presentation pattern
+ */
public String getRevisionPattern() {
- // ------------------------------------------
return versioning;
}
- public static ProjectSettingsService.Step getStep(int number) {
- // ---------------------------------------
- for (int i = 0; i < my.steps.size(); i++) {
- ProjectSettingsService.Step step = my.steps.get(i);
- if (step.number == number)
+ /**
+ * Get a study step by its sequential number.
+ *
+ * @param number
+ * the step number
+ * @return the step
+ */
+ public ProjectSettingsService.Step getStep(final int number) {
+ for (int i = 0; i < steps.size(); i++) {
+ ProjectSettingsService.Step step = steps.get(i);
+ if (step.number == number) {
return step;
+ }
}
return null;
}
+ /**
+ * Get steps of the given project element (study or scenario).
+ *
+ * @param level
+ * the project element (study or scenario)
+ * @return the list of steps
+ */
public List<ProjectSettingsService.Step> getStepsOf(
- Class<? extends ProjectElement> level) {
- // ---------------------------------------------------------------------------
+ final Class<? extends ProjectElement> level) {
Vector<ProjectSettingsService.Step> result = new Vector<ProjectSettingsService.Step>();
for (int i = 0; i < steps.size(); i++) {
ProjectSettingsService.Step step = steps.get(i);
- if (step.appliesTo(level))
+ if (step.appliesTo(level)) {
result.add(step);
+ }
}
return result;
}
- // ==============================================================================================================================
- // Protected member function
- // ==============================================================================================================================
-
- public void initialize() {
- // ----------------------------
+ /**
+ * Initialize the database: create all necessary default staff defined in the configuration file.
+ */
+ protected void initialize() {
createDocumentTypes();
createSimulationContextTypes();
createKnowledgeElementTypes();
// Private member function
// ==============================================================================================================================
- private void loadCustomization(File config) {
- // --------------------------------------------
+ /**
+ * Read the configuration file and fill transient project settings fields.
+ *
+ * @param config
+ * the configuration XML file
+ */
+ private void loadCustomization(final File config) {
try {
DocumentBuilderFactory dfactory = javax.xml.parsers.DocumentBuilderFactory
.newInstance();
String disk = datag.get("repository").getAttributes().getNamedItem(
"disk").getNodeValue();
- if (!disk.endsWith("/"))
+ if (!disk.endsWith("/")) {
disk = disk + "/";
+ }
logger.info("Database root set to " + disk);
reprop.setProperty("repository", disk);
NodeList slist = child.getChildNodes();
for (int j = 0; j < slist.getLength(); j++) {
child = slist.item(j);
- if (!child.getNodeName().equals("step"))
+ if (!child.getNodeName().equals("step")) {
continue;
+ }
HashMap<String, Node> tags = XDOM
.getNamedChildNodes(child);
natr = tags.get("flow").getAttributes();
flist.add(natr);
child = natr.getNamedItem("result");
- if (child != null)
+ if (child != null) {
resultype.add(child.getNodeValue());
+ }
child = tags.get("classification");
- if (child != null)
+ if (child != null) {
clist.add(child.getAttributes());
- else
+ } else {
clist.add(null);
+ }
if (natr.getNamedItem("contents").getNodeValue()
.equals("knowledge")) {
snum += 1;
}
} else {
- if (!child.getNodeName().equals("step"))
+ if (!child.getNodeName().equals("step")) {
continue;
+ }
HashMap<String, Node> tags = XDOM.getNamedChildNodes(child);
natr = tags.get("storage").getAttributes(); // Mandatory information
natr = tags.get("flow").getAttributes();
flist.add(natr);
child = natr.getNamedItem("result");
- if (child != null)
+ if (child != null) {
resultype.add(child.getNodeValue());
+ }
child = tags.get("classification"); // Optional information
- if (child != null)
+ if (child != null) {
clist.add(child.getAttributes());
- else
+ } else {
clist.add(null);
+ }
if (natr.getNamedItem("contents").getNodeValue().equals(
"knowledge")) {
Actor[] actor = { null, null, null };
String name = i.next();
child = datag.get(name);
- if (child == null)
+ if (child == null) {
continue; // Document type not subject of any validation
+ }
natr = child.getAttributes();
for (int j = 0; j < step.length; j++) {
child = natr.getNamedItem(step[j]);
- if (child == null)
+ if (child == null) {
continue; // Validation step not required
+ }
actor[j] = Actor.valueOf(child.getNodeValue());
}
concycles.add(new ProjectSettingsValidationCycle(name, actor));
}
concycles.add(new ProjectSettingsValidationCycle()); // Adds the built-in validation cycle
- if (getDatabase().getCheckedDB().isInitialized())
+ if (getDatabase().getCheckedDB().isInitialized()) {
return; // No need to load object type definitions as they are already stored
+ }
// Documents tag
child = children.get("documents");
mapuse = new LinkedHashMap<String, String>();
for (int i = 0; i < nlist.getLength(); i++) {
child = nlist.item(i);
- if (!child.getNodeName().equals("article"))
+ if (!child.getNodeName().equals("article")) {
continue;
+ }
natr = child.getAttributes();
String type = natr.getNamedItem("type").getNodeValue();
String uses = null;
child = natr.getNamedItem("uses");
- if (child != null)
+ if (child != null) {
uses = child.getNodeValue();
+ }
mapuse.put(type, uses); // Must be added to the map even if no (null) uses
}
// Simulation Contexts tag
context = new Vector<String>();
for (int i = 0; i < nlist.getLength(); i++) {
child = nlist.item(i);
- if (!child.getNodeName().equals("article"))
+ if (!child.getNodeName().equals("article")) {
continue;
+ }
context.add(child.getAttributes().getNamedItem("type")
.getNodeValue());
kname = new Vector<String>();
for (int i = 0; i < nlist.getLength(); i++) {
child = nlist.item(i);
- if (!child.getNodeName().equals("article"))
+ if (!child.getNodeName().equals("article")) {
continue;
+ }
kname.add(child.getAttributes().getNamedItem("type")
.getNodeValue());
}
}
+ /**
+ * Create in the database document types defined in the custom configuration.
+ */
private void createDocumentTypes() {
- // -----------------------------------
DocumentType.Properties tprop = new DocumentType.Properties();
HashMap<String, Vector<ProjectSettingsService.Step>> mapsteps = new HashMap<String, Vector<ProjectSettingsService.Step>>();
HashMap<String, ProjectSettingsService.Step> mapresult = new HashMap<String, ProjectSettingsService.Step>();
continue;
}
slist = mapsteps.get(type);
- if (slist == null)
+ if (slist == null) {
slist = new Vector<ProjectSettingsService.Step>();
+ }
slist.add(step);
mapsteps.put(type, slist);
}
Node result = flow.getNamedItem("result");
- if (result != null)
+ if (result != null) {
mapresult.put(result.getNodeValue(), step);
+ }
}
try {
DocumentType tdoc = null;
.size()]));
if (uses != null) {
tdoc = maptype.get(uses);
- if (tdoc == null)
+ if (tdoc == null) {
logger
.warn("Undefined \"" + uses
+ "\" document type.");
- else
+ } else {
tprop.setUses(tdoc);
+ }
}
- if (step != null)
+ if (step != null) {
tprop.setResult(step);
+ }
tprop.disableCheck();
tdoc = getDocumentTypeService().createType(tprop); // Creation of Document Types
}
}
+ /**
+ * Create in the database knowledge types defined in the custom configuration.
+ */
private void createKnowledgeElementTypes() {
- // -------------------------------------------
try {
KnowledgeElementType ktype = getKnowledgeElementTypeService()
.createType("usecase"); // Internal reserved knowledge element type
}
}
+ /**
+ * Create in the database simulation contexts types defined in the custom configuration.
+ */
private void createSimulationContextTypes() {
- // --------------------------------------------
HashMap<String, ProjectSettingsService.Step> mapstep = new HashMap<String, ProjectSettingsService.Step>();
int snum = 0;
for (Iterator<NamedNodeMap> i = sclass.iterator(); i.hasNext(); snum++) {
NamedNodeMap clatr = i.next();
- if (clatr == null)
+ if (clatr == null) {
continue;
+ }
String[] clist = clatr.getNamedItem("context").getNodeValue()
.split(",");
* @param database
* the database to set
*/
- public void setDatabase(Database database) {
+ public void setDatabase(final Database database) {
_database = database;
}
* the simulationContextTypeService to set
*/
public void setSimulationContextTypeService(
- SimulationContextTypeService simulationContextTypeService) {
+ final SimulationContextTypeService simulationContextTypeService) {
_simulationContextTypeService = simulationContextTypeService;
}
* the knowledgeElementTypeService to set
*/
public void setKnowledgeElementTypeService(
- KnowledgeElementTypeService knowledgeElementTypeService) {
+ final KnowledgeElementTypeService knowledgeElementTypeService) {
_knowledgeElementTypeService = knowledgeElementTypeService;
}
/**
* Get the documentTypeService.
+ *
* @return the documentTypeService
*/
public DocumentTypeService getDocumentTypeService() {
/**
* Set the documentTypeService.
- * @param documentTypeService the documentTypeService to set
+ *
+ * @param documentTypeService
+ * the documentTypeService to set
*/
- public void setDocumentTypeService(DocumentTypeService documentTypeService) {
+ public void setDocumentTypeService(
+ final DocumentTypeService documentTypeService) {
_documentTypeService = documentTypeService;
}
}
\ No newline at end of file
<property name="simulationContextDAO"
ref="simulationContextDAO" />
<property name="projectElementDAO" ref="projectElementDAO" />
+ <property name="projectSettings" ref="projectSettings" />
<property name="versionsRelationDAO" ref="versionsRelationDAO" />
</bean>
<bean id="simulationContextService"
class="org.splat.service.SimulationContextServiceImpl">
+ <property name="projectSettings" ref="projectSettings" />
<property name="simulationContextDAO"
ref="simulationContextDAO" />
<property name="simulationContextTypeDAO"