-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/openmrs/openmrs-module-attachments into ATT-1
- Loading branch information
Showing
12 changed files
with
345 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 22 additions & 5 deletions
27
api-2.0/src/main/java/org/openmrs/module/attachments/obs/ComplexViewHelper2_0.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,39 @@ | ||
package org.openmrs.module.attachments.obs; | ||
|
||
import static org.openmrs.obs.ComplexObsHandler.RAW_VIEW; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import org.openmrs.Obs; | ||
import org.openmrs.annotation.OpenmrsProfile; | ||
import org.openmrs.api.ObsService; | ||
import org.openmrs.module.attachments.AttachmentsConstants; | ||
import org.openmrs.obs.ComplexObsHandler; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component(AttachmentsConstants.COMPONENT_COMPLEXVIEW_HELPER) | ||
@OpenmrsProfile(openmrsPlatformVersion = "2.0.0") | ||
public class ComplexViewHelper2_0 implements ComplexViewHelper { | ||
|
||
private final Log log = LogFactory.getLog(getClass()); | ||
|
||
@Autowired | ||
private ObsService obsService; | ||
|
||
@Override | ||
public String getView(Obs obs, String view) { | ||
// TODO: Obs obs will help the 2.x implementation support fetching the | ||
// supported views for that obs, | ||
// See: | ||
// https://issues.openmrs.org/browse/ATT-34 | ||
|
||
return ComplexObsHandler.RAW_VIEW; | ||
ComplexObsHandler handler = obsService.getHandler(obs); | ||
|
||
if (handler.supportsView(view)) { | ||
return view; | ||
} else { | ||
log.warn("The requested view '" + view + "' is not supported by the complex obs handler '" | ||
+ handler.getClass().getCanonicalName() + "', reverting to the default view '" + RAW_VIEW + "'."); | ||
} | ||
|
||
return RAW_VIEW; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<!-- | ||
This Source Code Form is subject to the terms of the Mozilla Public License, | ||
v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
the terms of the Healthcare Disclaimer located at http://openmrs.org/license. | ||
Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
graphic logo is a trademark of OpenMRS Inc. | ||
--> | ||
<dataset> | ||
<concept concept_id="84069" retired="false" datatype_id="13" class_id="5" is_set="false" creator="1" date_created="2005-01-01 00:00:00.0" uuid="3fe44002-35b8-445e-9d46-692c56e6bdde"/> | ||
<concept_description concept_description_id="84069" concept_id="84069" description="TestBytesViewHandler Concept Complex" locale="en_GB" creator="1" date_created="2004-08-12 00:00:00.0" uuid="3a951971-34e9-4c88-954c-68d188f2c4de"/> | ||
|
||
<concept_complex concept_id="84069" handler="TestAttachmentBytesViewHandler" /> | ||
|
||
<concept_name concept_id="84069" name="TestAttachmentBytesViewHandler Concept Complex" locale="en_GB" creator="1" date_created="2008-08-15 13:52:53.0" concept_name_id="8007" concept_name_type="FULLY_SPECIFIED" locale_preferred="0" voided="false" uuid="86f4f6ff-2bfb-4a17-a96b-ca633a96dd13"/> | ||
|
||
<!-- This obs just exists so that there is a reference to an attachment associated with TestAttachmentBytesViewHandler to fetch it via REST --> | ||
<obs obs_id="84044" person_id="2" concept_id="84069" obs_datetime="2008-02-09 00:00:00.0" location_id="1" value_complex="m3ks | instructions.none" creator="1" date_created="2006-02-10 15:57:35.0" voided="false" uuid="bbec1b32-dbf1-4b7a-bd2b-8898543c1367"/> | ||
|
||
</dataset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...-2.0/src/test/java/org/openmrs/module/attachments/obs/TestAttachmentBytesViewHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.openmrs.module.attachments.obs; | ||
|
||
import static org.openmrs.module.attachments.obs.ValueComplex.INSTRUCTIONS_DEFAULT; | ||
|
||
import org.openmrs.Obs; | ||
import org.openmrs.obs.ComplexData; | ||
import org.openmrs.obs.handler.BinaryDataHandler; | ||
|
||
public class TestAttachmentBytesViewHandler extends AbstractAttachmentHandler { | ||
|
||
public static final String DEFAULT_VIEW = "VIEW_1"; | ||
|
||
public static final String DEFAULT_VIEW_DATA = "This is a string content for VIEW_1."; | ||
|
||
public static final String ALTERNATE_VIEW = "VIEW_2"; | ||
|
||
public static final String ALTERNATE_VIEW_DATA = "This is a string content for VIEW_2."; | ||
|
||
private static final String[] supportedViews = { DEFAULT_VIEW, ALTERNATE_VIEW }; | ||
|
||
@Override | ||
protected void setParentComplexObsHandler() { | ||
setParent(new BinaryDataHandler()); | ||
} | ||
|
||
@Override | ||
protected ComplexData readComplexData(Obs obs, ValueComplex valueComplex, String view) { | ||
|
||
if (ALTERNATE_VIEW.equals(view)) { | ||
return new AttachmentComplexData2_0(INSTRUCTIONS_DEFAULT, "extra_view", ALTERNATE_VIEW_DATA, "text/plain"); | ||
} | ||
|
||
return new AttachmentComplexData2_0(INSTRUCTIONS_DEFAULT, "default_view", DEFAULT_VIEW_DATA, "text/plain"); | ||
|
||
} | ||
|
||
@Override | ||
protected boolean deleteComplexData(Obs obs, AttachmentComplexData complexData) { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected ValueComplex saveComplexData(Obs obs, AttachmentComplexData complexData) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String[] getSupportedViews() { | ||
return supportedViews; | ||
} | ||
} |
126 changes: 0 additions & 126 deletions
126
omod-2.0/src/test/java/org/openmrs/module/attachments/rest/AttachmentController2_0Test.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.