Skip to content

Commit f9581c8

Browse files
committed
ATT-39: Old AttachmentsController to use ComplexViewHelper when fetching obs.
1 parent 263e0ca commit f9581c8

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

omod-1.10/src/main/java/org/openmrs/module/attachments/rest/AttachmentBytesResource1_10.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void getFile(@PathVariable("uuid") String uuid, @RequestParam(required =
6060

6161
String mimeType = attComplexData.getMimeType();
6262

63-
// The attachment meta data is sent as HTTP headers.
63+
// The attachment metadata is sent as HTTP headers.
6464
response.setContentType(mimeType);
6565
response.addHeader("Content-Family", getContentFamily(mimeType).name());
6666
response.addHeader("File-Name", attComplexData.getTitle());

omod-2.0/src/test/java/org/openmrs/module/attachments/rest/AttachmentRestController2_0Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ public void postAttachment_shouldUpdateObsComment() throws Exception {
116116
}
117117

118118
@Test
119-
public void doSearch_shouldReturnResult() {
119+
public void doSearch_shouldReturnResults() {
120120

121121
// Setup
122-
AttachmentResource1_10 res = new AttachmentResource1_10();
122+
AttachmentResource2_0 res = new AttachmentResource2_0();
123123
Patient patient = patientService.getPatient(2);
124124

125125
List<Attachment> attachments = as.getAttachments(patient, false);

omod/src/main/java/org/openmrs/module/attachments/web/controller/AttachmentsController.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
package org.openmrs.module.attachments.web.controller;
22

3+
import static org.openmrs.module.attachments.AttachmentsContext.getContentFamily;
4+
5+
import java.io.IOException;
6+
import java.util.Iterator;
7+
8+
import javax.servlet.http.HttpServletResponse;
9+
310
import org.apache.commons.lang.StringUtils;
411
import org.apache.commons.logging.Log;
512
import org.apache.commons.logging.LogFactory;
13+
import org.openmrs.Encounter;
614
import org.openmrs.Obs;
715
import org.openmrs.Patient;
816
import org.openmrs.Provider;
917
import org.openmrs.Visit;
10-
import org.openmrs.Encounter;
1118
import org.openmrs.module.attachments.AttachmentsConstants;
1219
import org.openmrs.module.attachments.AttachmentsContext;
1320
import org.openmrs.module.attachments.ComplexObsSaver;
1421
import org.openmrs.module.attachments.VisitCompatibility;
1522
import org.openmrs.module.attachments.obs.AttachmentComplexData;
23+
import org.openmrs.module.attachments.obs.ComplexViewHelper;
1624
import org.openmrs.module.attachments.obs.ValueComplex;
1725
import org.openmrs.module.attachments.rest.AttachmentBytesResource1_10;
1826
import org.openmrs.module.webservices.rest.web.ConversionUtil;
@@ -28,12 +36,6 @@
2836
import org.springframework.web.multipart.MultipartFile;
2937
import org.springframework.web.multipart.MultipartHttpServletRequest;
3038

31-
import javax.servlet.http.HttpServletResponse;
32-
import java.io.IOException;
33-
import java.util.Iterator;
34-
35-
import static org.openmrs.module.attachments.AttachmentsContext.getContentFamily;
36-
3739
/*
3840
* @Deprecated and replaced by
3941
* {@link org.openmrs.module.attachments.rest.AttachmentBytesResource1_10 AttachmentBytesResource}
@@ -56,6 +58,10 @@ public class AttachmentsController {
5658
@Qualifier(AttachmentsConstants.COMPONENT_COMPLEXOBS_SAVER)
5759
protected ComplexObsSaver obsSaver;
5860

61+
@Autowired
62+
@Qualifier(AttachmentsConstants.COMPONENT_COMPLEXVIEW_HELPER)
63+
protected ComplexViewHelper complexViewHelper;
64+
5965
protected final Log log = LogFactory.getLog(getClass());
6066

6167
@RequestMapping(value = AttachmentsConstants.LEGACY_UPLOAD_ATTACHMENT_URL, method = RequestMethod.POST)
@@ -110,7 +116,7 @@ public void downloadDocument(@RequestParam("obs") String obsUuid,
110116

111117
// Getting the Core/Platform complex data object
112118
Obs obs = context.getObsService().getObsByUuid(obsUuid);
113-
Obs complexObs = context.getObsService().getComplexObs(obs.getObsId(), view);
119+
Obs complexObs = context.getObsService().getComplexObs(obs.getObsId(), complexViewHelper.getView(obs, view));
114120
ComplexData complexData = complexObs.getComplexData();
115121

116122
// Switching to our complex data object

0 commit comments

Comments
 (0)