- 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);
+ }
+ }
+ }