final List<Long> docuses) throws MissedPropertyException,
InvalidPropertyException, MultiplyDefinedException, IOException,
NotApplicableException, InterruptedException, ParseException {
+ DocumentType type = getDocumentTypeService().selectType(
+ (int) documentTypeId);
User user = getUserService().selectUser(userId);
File updir = getRepositoryService().getDownloadDirectory(user);
File upfile = new File(updir.getPath() + "/" + fname);
+ String[] table = fname.split("\\x2E");
// Creation of the document
Document.Properties dprop = new Document.Properties();
if (reference.length() == 0) { // Importation of a foreign document
// TODO: Extract property of supported documents (DOCX, ODT...)
- DocumentType type = getDocumentTypeService().selectType(
- (int) documentTypeId);
- String[] table = fname.split("\\x2E");
addoc = getStepService().createDocument(
step,
dprop.setName(doctitle).setType(type).setFormat(
// Creation of uses relations
if (docuses != null) {
for (Long index : docuses) {
- Document used = getDocumentService().selectDocument(index);
+ Document used = getDocumentService().
+ selectDocument(index);
Publication pub = step.getDocument(index);
+ // updating uses relations on publication in step
if (pub == null) {
for (Publication doc : step.getOwner().
getDocums()) {
}
}
if (pub == null) {
- for (Publication doc : step.getOwnerStudy().getDocums()) {
+ for (Publication doc : step.getOwnerStudy().
+ getDocums()) {
if (doc.value().getIndex() == index) {
pub = doc;
break;
// Creation of uses relations
Publication syncronizedCurrent = _publicationDAO.get(current.getIndex());
- updateRelations(syncronizedCurrent, next, docuses, docusedby);
+ updateRelations(step, syncronizedCurrent, next, docuses, docusedby);
}
+ /**
+ * Find the documents, which using the old version of document.
+ *
+ * @param list
+ * the list of documents uses versioning document
+ * @param publication
+ * publication, which is check by use the documents in _defuses list
+ * @param defuses
+ * the list of default uses documents
+ */
+ public final void findSequenceUses(final List<Document> list,
+ final Publication publication, final List<Document> defuses) {
+ for (Iterator<Document> document = defuses.iterator(); document
+ .hasNext();) {
+ Publication pub = publication.getOwner().getPublication(
+ document.next());
+ if (pub != null
+ && pub.getRelations(UsesRelation.class).
+ contains(publication)) {
+ findSequenceUses(list, pub, defuses);
+ list.add(pub.value());
+ }
+ }
+ }
+
/**
* Update relations after creation of a new document version.
- *
+ *
+ * @param step
+ * current Step
* @param current
* the current version
* @param next
* @param docusedby
* ids of documents used by the versioned one.
*/
- private void updateRelations(final Publication current,
- final Publication next, final String[] docuses,
- final long[] docusedby) {
- if (docuses != null) {
- for (int i = 0; i < docuses.length; i++) {
- Long index = Long.valueOf(docuses[i].trim());
- Document used = getDocumentService().selectDocument(index);// RKV: getPublication(index, steps);
- next.addDependency(used);
- }
- }
- // Outdating impacted document
- HashSet<Long> compatible = new HashSet<Long>();
- if (docusedby != null) {
- for (int i = 0; i < docusedby.length; i++) {
- compatible.add(docusedby[i]);
- }
- }
- for (Publication using : current.getRelations(UsedByRelation.class)) {
- if (!compatible.contains(using.getIndex())) {
- outdate(using);
- }
- }
- }
-
+ public void updateRelations(final Step step, final Publication current,
+ final Publication next, final String[] docuses,
+ final long[] docusedby) {
+ if (docuses != null) {
+ for (int i = 0; i < docuses.length; i++) {
+ Long index = Long.valueOf(docuses[i].trim());
+ Document used = getDocumentService().selectDocument(index);// RKV:getPublication(index, steps);
+ next.addDependency(used);
+ if (used.getStep() == step.getNumber()) {
+ step.getDocument(used.getIndex()).setValue(used);
+ }
+ }
+ }
+ // Outdating impacted document
+ HashSet<Long> compatible = new HashSet<Long>();
+ if (docusedby != null) {
+ for (int i = 0; i < docusedby.length; i++) {
+ compatible.add(docusedby[i]);
+ }
+ }
+ for (Publication using : current.getRelations(UsedByRelation.class)) {
+ if (compatible.contains(using.getIndex())) {
+ current.value().removeRelation(UsedByRelation.class,
+ using.value());
+ using.addDependency(next);
+ if (step.getNumber() == using.value().getStep()) {
+ step.getDocument(using.value().getIndex()).setValue(
+ using.value());
+ }
+ } else {
+ outdate(using);
+ }
+ }
+ }
/*
* protected Publication getPublication(int index, List<Step> steps) { for (Iterator<Step> i = steps.iterator(); i.hasNext();) { List<Publication>
* published = i.next().getAllDocuments(); for (Iterator<Publication> j = published.iterator(); j.hasNext();) { Publication found =
import org.splat.kernel.InvalidPropertyException;
import org.splat.manox.Reader;
import org.splat.manox.Toolbox;
+import org.splat.service.PublicationService;
+import org.splat.service.StudyService;
import org.splat.som.Revision;
import org.splat.som.Step;
import org.splat.wapp.Constants;
File upfile = commonInitialize(Constants.TRUE);
_mystudy = getOpenStudy();
+ //updating relations of docs
_mystudy.updateCurrentStep();
_defuses = new ArrayList<Document>();
// Avoid using of documents dependent on the current version of the document being versioned
// (This case is possible only if both documents belong to the step of the same Project Element)
- for(Iterator<Document> document = _defuses.iterator(); document.hasNext(); ) {
- Publication pub = tag.getOwner().getPublication(document.next());
- if(pub != null && pub.getRelations(UsesRelation.class).contains(tag)) {
- document.remove();
+ List<Document> toDeleteFromDefuses = new ArrayList<Document>();
+ getPublicationService().findSequenceUses(toDeleteFromDefuses, tag,
+ _defuses);
+ for (Document document : toDeleteFromDefuses) {
+ if (_defuses.contains(document)) {
+ _defuses.remove(document);
}
}