From 1220ec3b08a6c479c237ade47f80833cdcf918c3 Mon Sep 17 00:00:00 2001 From: gakin <gakin> Date: Thu, 9 Mar 2017 14:53:08 +0000 Subject: [PATCH] SSDM-4394 : Add hasAttachments flag to parsed entities to be used in downloading attachments. SVN: 37879 --- .../synchronizer/ResourceListParser.java | 14 ++++++++ .../synchronizer/ResourceListParserData.java | 34 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/ResourceListParser.java b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/ResourceListParser.java index 65ae2e7e5ee..a549eab46ec 100644 --- a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/ResourceListParser.java +++ b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/ResourceListParser.java @@ -352,6 +352,7 @@ public class ResourceListParser ProjectWithConnections newPrjWithConns = data.new ProjectWithConnections(newProject, lastModificationDate); data.getProjectsToProcess().put(permId, newPrjWithConns); + newPrjWithConns.setHasAttachments(hasAttachments(xpath, xdNode)); newPrjWithConns.setConnections(parseConnections(xpath, xdNode)); } @@ -385,6 +386,17 @@ public class ResourceListParser return conns; } + private boolean hasAttachments(XPath xpath, Node xdNode) + { + Element docElement = (Element) xdNode; + NodeList connsNode = docElement.getElementsByTagName("x:binaryData"); + if (connsNode.getLength() == 1) + { + return true; + } + return false; + } + private List<NewProperty> parseDataSetProperties(XPath xpath, Node xdNode) { @@ -451,6 +463,7 @@ public class ResourceListParser ExperimentWithConnections newExpWithConns = data.new ExperimentWithConnections(newExp, lastModificationDate); data.getExperimentsToProcess().put(permId, newExpWithConns); newExpWithConns.setConnections(parseConnections(xpath, xdNode)); + newExpWithConns.setHasAttachments(hasAttachments(xpath, xdNode)); newExp.setProperties(parseProperties(xpath, xdNode)); } @@ -469,6 +482,7 @@ public class ResourceListParser newSample.setPermID(permId); SampleWithConnections newSampleWithConns = data.new SampleWithConnections(newSample, lastModificationDate); data.getSamplesToProcess().put(permId, newSampleWithConns); + newSampleWithConns.setHasAttachments(hasAttachments(xpath, xdNode)); newSampleWithConns.setConnections(parseConnections(xpath, xdNode)); newSample.setProperties(parseProperties(xpath, xdNode)); } diff --git a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/ResourceListParserData.java b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/ResourceListParserData.java index ef5c79a49ea..3c263a0e249 100644 --- a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/ResourceListParserData.java +++ b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/ResourceListParserData.java @@ -149,6 +149,17 @@ public class ResourceListParserData private final Date lastModificationDate; + private boolean hasAttachments; + + public boolean hasAttachments() + { + return hasAttachments; + } + + public void setHasAttachments(boolean hasAttachments) + { + this.hasAttachments = hasAttachments; + } public NewProject getProject() { return project; @@ -190,6 +201,18 @@ public class ResourceListParserData private final Date lastModificationDate; + private boolean hasAttachments; + + public boolean hasAttachments() + { + return hasAttachments; + } + + public void setHasAttachments(boolean hasAttachments) + { + this.hasAttachments = hasAttachments; + } + public NewExperiment getExperiment() { return experiment; @@ -226,6 +249,17 @@ public class ResourceListParserData private final Date lastModificationDate; + private boolean hasAttachments; + + public boolean hasAttachments() + { + return hasAttachments; + } + + public void setHasAttachments(boolean hasAttachments) + { + this.hasAttachments = hasAttachments; + } public Date getLastModificationDate() { return lastModificationDate; -- GitLab