import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.File;
import org.splat.dal.bo.som.KnowledgeElement;
-import org.splat.dal.bo.som.ProjectElement;
import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.Scenario;
import org.splat.dal.bo.som.SimulationContext;
}
// Identification and save
- aStep.getOwnerStudy().setLastLocalIndex(
- dprop.getOwner().getOwnerStudy().getLastLocalIndex());
if (LOG.isDebugEnabled()) {
LOG.debug("Local index after: "
- + dprop.getOwner().getOwnerStudy().getLastLocalIndex());
+ + aStep.getOwnerStudy().getLastLocalIndex());
}
getDocumentService().buildReferenceFrom(newdoc, aStep.getOwnerStudy());
getDocumentDAO().create(newdoc);
*/
public boolean remove(final Step aStep, final Publication oldoc) {
aStep.getDocuments().remove(oldoc); // Updates this step
- // Synchronize with database
- ProjectElement owner = getProjectElementDAO().merge(aStep.getOwner());
- if (owner != null) {
- aStep.getOwner().remove(oldoc); // in transient copy
- owner.remove(oldoc); // in persistent copy
- }
+ aStep.getOwner().remove(oldoc); // remove from the parent project element
+ getProjectElementDAO().merge(aStep.getOwner());
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;
Document value = torem.value();
if (!value.isPublished() && !value.isVersioned()) { // The referenced document is no more used
List<Document> using = new ArrayList<Document>();
- List<Relation> converts = new ArrayList<Relation>();
+ List<File> files = new ArrayList<File>();
for (Relation link : value.getAllRelations()) {
if (link.getClass().equals(ConvertsRelation.class)) { // File conversion
- converts.add(link);
+ files.add((File) link.getTo());
} else if (link.getClass().equals(UsesRelation.class)) { // Document dependency
using.add((Document) link.getTo());
}
}
- // value.getAllRelations().removeAll(converts);
// Remove relations from depending documents
if (LOG.isDebugEnabled()) {
LOG.debug("Remove " + using.size() + " UsedByRelation(s).");
if (LOG.isDebugEnabled()) {
LOG.debug("Remove UsedByRelation from "
+ doc.getTitle() + " to " + value.getTitle());
+ LOG.debug("Nb relations of doc " + doc.getTitle()
+ + " before: " + doc.getAllRelations().size());
}
doc.removeRelation(UsedByRelation.class, value);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Nb relations of doc " + doc.getTitle()
+ + " after: " + doc.getAllRelations().size());
+ }
getDocumentDAO().merge(doc);
}
- value = getPublicationDAO().merge(torem).value();
// Synchronize deleted objects with the database to avoid hibernate exception
- // org.hibernate.PropertyValueException: not-null property references a null or transient value:
- // org.splat.dal.bo.som.UsedByRelation.refer
- getDocumentDAO().flush(); // To show to the database that files from ConvertsRelation(s) are deleted already
- getDocumentDAO().delete(value); // The corresponding physical file is not removed from the vault
+ // org.hibernate.PropertyValueException: not-null property references a null or transient value
+ getDocumentDAO().flush();
+ // The corresponding physical file is not removed from the vault
+ getDocumentDAO().delete(getDocumentDAO().merge(torem.value()));
// Delete document's files
- for (Relation link : converts) {
- File file = (File) link.getTo();
- getFileDAO().delete(file); // The corresponding physical file is not removed from the vault
+ for (File file : files) {
+ getFileDAO().delete(getFileDAO().merge(file)); // The corresponding physical file is not removed from the vault
}
}
}