From af653521a8372c67e05b29782e6ad3896bfd8b41 Mon Sep 17 00:00:00 2001 From: gakin <gakin> Date: Tue, 7 Mar 2017 15:42:17 +0000 Subject: [PATCH] SSDM-4394 : Retrieve attachments for resource list SVN: 37861 --- .../plugins/sync/common/EntityRetriever.java | 18 -------------- .../generic/shared/entitygraph/Node.java | 24 +++++++++---------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/common/EntityRetriever.java b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/common/EntityRetriever.java index ee41b4daa3e..e840fe5b07a 100644 --- a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/common/EntityRetriever.java +++ b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/common/EntityRetriever.java @@ -28,8 +28,6 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; import ch.ethz.sis.openbis.generic.asapi.v3.IApplicationServerApi; -import ch.ethz.sis.openbis.generic.asapi.v3.dto.attachment.Attachment; -import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.interfaces.IAttachmentsHolder; import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.interfaces.ICodeHolder; import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.search.SearchResult; import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.DataSet; @@ -128,7 +126,6 @@ public class EntityRetriever Node<Project> prjNode = new Node<Project>(project); graph.addNode(prjNode); findExperiments(prjNode); - findAndAddAttachments(prjNode); } findSpaceSamples(spaceId); @@ -154,21 +151,10 @@ public class EntityRetriever Node<Experiment> expNode = new Node<Experiment>(exp); graph.addEdge(prjNode, expNode, new Edge(CONNECTION)); findSamplesForExperiment(expNode); - findAndAddAttachments(expNode); findAndAttachDataSetsForExperiment(expNode); } } - private void findAndAddAttachments(Node<? extends IAttachmentsHolder> node) - { - List<Attachment> attachments = node.getEntity().getAttachments(); - for (Attachment attachment : attachments) - { - node.addBinaryData(attachment.getPermlink()); - // System.out.println("Attachment:" + attachment.getPermlink()); - } - } - private void findSpaceSamples(String spaceCode) { SampleSearchCriteria criteria = new SampleSearchCriteria(); @@ -190,7 +176,6 @@ public class EntityRetriever graph.addNode(sampleNode); findChildAndComponentSamples(sampleNode); findAndAttachDataSets(sampleNode); - findAndAddAttachments(sampleNode); } } @@ -214,7 +199,6 @@ public class EntityRetriever graph.addEdge(expNode, sampleNode, new Edge(CONNECTION)); findAndAttachDataSets(sampleNode); - findAndAddAttachments(sampleNode); findChildAndComponentSamples(sampleNode); } } @@ -295,7 +279,6 @@ public class EntityRetriever graph.addEdge(sampleNode, subSampleNode, new Edge(COMPONENT)); findAndAttachDataSets(subSampleNode); - findAndAddAttachments(subSampleNode); findChildAndComponentSamples(subSampleNode); } } @@ -311,7 +294,6 @@ public class EntityRetriever graph.addEdge(sampleNode, subSampleNode, new Edge(CHILD)); findAndAttachDataSets(subSampleNode); - findAndAddAttachments(subSampleNode); findChildAndComponentSamples(subSampleNode); } } diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/shared/entitygraph/Node.java b/openbis/source/java/ch/ethz/sis/openbis/generic/shared/entitygraph/Node.java index fd235896d03..25bc4a58981 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/shared/entitygraph/Node.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/shared/entitygraph/Node.java @@ -20,6 +20,8 @@ import java.util.Date; import java.util.List; import java.util.Map; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.attachment.Attachment; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.interfaces.IAttachmentsHolder; import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.interfaces.ICodeHolder; import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.interfaces.IExperimentHolder; import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.interfaces.IModificationDateHolder; @@ -42,7 +44,7 @@ public class Node<T extends ICodeHolder & IModificationDateHolder & IModifierHol private final List<EdgeNodePair> connections; - private final List<String> binaryData; + private final List<Attachment> attachments; public T getEntity() { @@ -53,7 +55,7 @@ public class Node<T extends ICodeHolder & IModificationDateHolder & IModifierHol { this.entity = entity; this.connections = new ArrayList<EdgeNodePair>(); - this.binaryData = new ArrayList<String>(); + this.attachments = new ArrayList<Attachment>(); } @Override @@ -253,21 +255,19 @@ public class Node<T extends ICodeHolder & IModificationDateHolder & IModifierHol return connections; } - public void addBinaryData(String link) + public void setAttachments(List<Attachment> attachmentList) { - binaryData.add(link); + attachments.clear(); + attachments.addAll(attachmentList); } - public List<String> getBinaryData() + public List<Attachment> getAttachmentsOrNull() { - return binaryData; - } - - public boolean hasBinaryData() { - if (entity instanceof DataSet) + if (entity instanceof IAttachmentsHolder) { - return true; + IAttachmentsHolder holder = (IAttachmentsHolder) entity; + return holder.getAttachments(); } - return binaryData.size() > 0; + return null; } } -- GitLab