Skip to content
Snippets Groups Projects
Commit af653521 authored by gakin's avatar gakin
Browse files

SSDM-4394 : Retrieve attachments for resource list

SVN: 37861
parent 52ba62c3
No related branches found
No related tags found
No related merge requests found
...@@ -28,8 +28,6 @@ import javax.xml.parsers.ParserConfigurationException; ...@@ -28,8 +28,6 @@ import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerException;
import ch.ethz.sis.openbis.generic.asapi.v3.IApplicationServerApi; 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.interfaces.ICodeHolder;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.search.SearchResult; import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.search.SearchResult;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.DataSet; import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.DataSet;
...@@ -128,7 +126,6 @@ public class EntityRetriever ...@@ -128,7 +126,6 @@ public class EntityRetriever
Node<Project> prjNode = new Node<Project>(project); Node<Project> prjNode = new Node<Project>(project);
graph.addNode(prjNode); graph.addNode(prjNode);
findExperiments(prjNode); findExperiments(prjNode);
findAndAddAttachments(prjNode);
} }
findSpaceSamples(spaceId); findSpaceSamples(spaceId);
...@@ -154,21 +151,10 @@ public class EntityRetriever ...@@ -154,21 +151,10 @@ public class EntityRetriever
Node<Experiment> expNode = new Node<Experiment>(exp); Node<Experiment> expNode = new Node<Experiment>(exp);
graph.addEdge(prjNode, expNode, new Edge(CONNECTION)); graph.addEdge(prjNode, expNode, new Edge(CONNECTION));
findSamplesForExperiment(expNode); findSamplesForExperiment(expNode);
findAndAddAttachments(expNode);
findAndAttachDataSetsForExperiment(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) private void findSpaceSamples(String spaceCode)
{ {
SampleSearchCriteria criteria = new SampleSearchCriteria(); SampleSearchCriteria criteria = new SampleSearchCriteria();
...@@ -190,7 +176,6 @@ public class EntityRetriever ...@@ -190,7 +176,6 @@ public class EntityRetriever
graph.addNode(sampleNode); graph.addNode(sampleNode);
findChildAndComponentSamples(sampleNode); findChildAndComponentSamples(sampleNode);
findAndAttachDataSets(sampleNode); findAndAttachDataSets(sampleNode);
findAndAddAttachments(sampleNode);
} }
} }
...@@ -214,7 +199,6 @@ public class EntityRetriever ...@@ -214,7 +199,6 @@ public class EntityRetriever
graph.addEdge(expNode, sampleNode, new Edge(CONNECTION)); graph.addEdge(expNode, sampleNode, new Edge(CONNECTION));
findAndAttachDataSets(sampleNode); findAndAttachDataSets(sampleNode);
findAndAddAttachments(sampleNode);
findChildAndComponentSamples(sampleNode); findChildAndComponentSamples(sampleNode);
} }
} }
...@@ -295,7 +279,6 @@ public class EntityRetriever ...@@ -295,7 +279,6 @@ public class EntityRetriever
graph.addEdge(sampleNode, subSampleNode, new Edge(COMPONENT)); graph.addEdge(sampleNode, subSampleNode, new Edge(COMPONENT));
findAndAttachDataSets(subSampleNode); findAndAttachDataSets(subSampleNode);
findAndAddAttachments(subSampleNode);
findChildAndComponentSamples(subSampleNode); findChildAndComponentSamples(subSampleNode);
} }
} }
...@@ -311,7 +294,6 @@ public class EntityRetriever ...@@ -311,7 +294,6 @@ public class EntityRetriever
graph.addEdge(sampleNode, subSampleNode, new Edge(CHILD)); graph.addEdge(sampleNode, subSampleNode, new Edge(CHILD));
findAndAttachDataSets(subSampleNode); findAndAttachDataSets(subSampleNode);
findAndAddAttachments(subSampleNode);
findChildAndComponentSamples(subSampleNode); findChildAndComponentSamples(subSampleNode);
} }
} }
......
...@@ -20,6 +20,8 @@ import java.util.Date; ...@@ -20,6 +20,8 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; 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.ICodeHolder;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.interfaces.IExperimentHolder; import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.interfaces.IExperimentHolder;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.interfaces.IModificationDateHolder; import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.interfaces.IModificationDateHolder;
...@@ -42,7 +44,7 @@ public class Node<T extends ICodeHolder & IModificationDateHolder & IModifierHol ...@@ -42,7 +44,7 @@ public class Node<T extends ICodeHolder & IModificationDateHolder & IModifierHol
private final List<EdgeNodePair> connections; private final List<EdgeNodePair> connections;
private final List<String> binaryData; private final List<Attachment> attachments;
public T getEntity() public T getEntity()
{ {
...@@ -53,7 +55,7 @@ public class Node<T extends ICodeHolder & IModificationDateHolder & IModifierHol ...@@ -53,7 +55,7 @@ public class Node<T extends ICodeHolder & IModificationDateHolder & IModifierHol
{ {
this.entity = entity; this.entity = entity;
this.connections = new ArrayList<EdgeNodePair>(); this.connections = new ArrayList<EdgeNodePair>();
this.binaryData = new ArrayList<String>(); this.attachments = new ArrayList<Attachment>();
} }
@Override @Override
...@@ -253,21 +255,19 @@ public class Node<T extends ICodeHolder & IModificationDateHolder & IModifierHol ...@@ -253,21 +255,19 @@ public class Node<T extends ICodeHolder & IModificationDateHolder & IModifierHol
return connections; 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; if (entity instanceof IAttachmentsHolder)
}
public boolean hasBinaryData() {
if (entity instanceof DataSet)
{ {
return true; IAttachmentsHolder holder = (IAttachmentsHolder) entity;
return holder.getAttachments();
} }
return binaryData.size() > 0; return null;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment