import org.splat.dal.dao.som.PublicationDAO;
import org.splat.dal.dao.som.TimestampDAO;
import org.splat.dal.dao.som.VersionsRelationDAO;
-import org.splat.exception.BusinessException;
import org.splat.exception.IncompatibleDataException;
import org.splat.exception.InvalidParameterException;
import org.splat.exception.UserRightsException;
Document document = _documentService.selectDocument(doc.getIndex()); //get document attached to hibernate session
ProjectElement trueOwner = _projectElementDAO.merge(owner);
Document theLastVersion = null;
- if(trueOwner.getPublication(document) != null) {
- theLastVersion = document;
- } else { //start recursive search
+ if (trueOwner.getPublication(document) == null) {
List<VersionsRelation> relations = _versionsRelationDAO
.getFilteredList(Restrictions.eq("refer", theLastVersion));
- //there may be several next versions if document is shared between scenarios,
- //but only one leads to a publication from given project elements.
- for(Relation relation : relations) {
- Document candidate = getLastVersion((Document)(relation.getFrom()), trueOwner);
- if(candidate != null ) {
+ // there may be several next versions if document is shared between scenarios,
+ // but only one leads to a publication from given project elements.
+ for (Relation relation : relations) {
+ Document candidate = getLastVersion((Document) (relation
+ .getFrom()), trueOwner);
+ if (candidate != null) {
theLastVersion = candidate;
}
}
+ } else { // start recursive search
+ theLastVersion = document;
}
if(theLastVersion == null && owner instanceof Scenario) {
theLastVersion = getLastVersion(doc, ((Scenario)owner).getOwnerStudy());