Skip to content

Commit

Permalink
Applying auto format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
wluyima committed May 3, 2013
1 parent 9340305 commit 2a23a2e
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 33 deletions.
15 changes: 10 additions & 5 deletions api/src/main/java/org/openmrs/activelist/Allergy.java
Expand Up @@ -32,12 +32,14 @@ public class Allergy extends ActiveListItem {
private Concept reaction; // must be of class=Symptom

private AllergySeverity severity;

/**
* no argument constructor to construct a allergy
*/
public Allergy() {
this.activeListType = new ActiveListType(1);
}

/**
* Constructs an allergy with a given id
* @param activeListId the activeListId to set. this parameter is the id of the ActiveListItem
Expand All @@ -46,6 +48,7 @@ public Allergy(Integer activeListId) {
super(activeListId);
this.activeListType = new ActiveListType(1);
}

/**
* Convenience constructor to construct an allergy with a given Patient, Concept, start date of the allergy, allergy type and the reaction of the allergy
* @param person the person to set this Allergy
Expand Down Expand Up @@ -74,14 +77,15 @@ public AllergyType getAllergyType() {
* set the allergyType of the Allergy
* @param allergyType the allergyType to set
*/
public void setAllergyType(AllergyType allergyType) {
public void setAllergyType(AllergyType allergyType) {
this.allergyType = allergyType;
}

/**
* set the allergyType of the Allergy. Here the allergy type will be chosen from the enum values in the {@link AllergyType}, according to the given String type.
* @param type the allergyType to set
*/
public void setAllergyType(String type) {
public void setAllergyType(String type) {
this.allergyType = StringUtils.isBlank(type) ? null : AllergyType.valueOf(type);
}

Expand All @@ -104,22 +108,23 @@ public void setReaction(Concept reaction) {
/**
* @return the severity of the allergy
*/
public AllergySeverity getSeverity() {
public AllergySeverity getSeverity() {
return severity;
}

/**
* Set the severity of the allergy
* @param severity the severity to set
*/
public void setSeverity(AllergySeverity severity) {
public void setSeverity(AllergySeverity severity) {
this.severity = severity;
}

/**
* Set the severity of the allergy. Here the allergy type will be chosen from the enum values in the {@link AllergySeverity}, according to the given String severity.
* @param severity the severity to set
*/
public void setSeverity(String severity) {
public void setSeverity(String severity) {
this.severity = StringUtils.isBlank(severity) ? null : AllergySeverity.valueOf(severity);
}

Expand Down
6 changes: 3 additions & 3 deletions api/src/main/java/org/openmrs/api/db/PatientDAO.java
Expand Up @@ -69,16 +69,16 @@ public List<Patient> getPatients(String name, String identifier, List<PatientIde

/**
* @see org.openmrs.api.PatientService#getPatientIdentifiers(java.lang.String, java.util.List,
* java.util.List, java.util.List, java.lang.Boolean)
* java.util.List, java.util.List, java.lang.Boolean)
*
* @should return all matching non voided patient identifiers if is preferred is set to null
* @should return all matching non voided patient identifiers if is preferred is set to true
* @should return all matching non voided patient identifiers if is preferred is set to false
* @should fetch all patient identifiers belong to given patient
* @should fetch all patient identifiers belong to given patients
* @should fetch patient identifiers that equals given identifier
* @should not fetch patient identifiers that partially matches given identifier
* @should not get voided patient identifiers
* @should not fetch patient identifiers that partially matches given identifier
* @should not get voided patient identifiers
*/
public List<PatientIdentifier> getPatientIdentifiers(String identifier,
List<PatientIdentifierType> patientIdentifierTypes, List<Location> locations, List<Patient> patients,
Expand Down
Expand Up @@ -202,21 +202,21 @@ public List<DrugOrder> getDrugOrdersByPatientAndIngredient(Patient patient, Conc

return (List<DrugOrder>) searchDrugOrderCriteria.list();
}

/* (non-Javadoc)
* @see org.openmrs.api.db.OrderDAO#getOrderHistoryByOrderNumber(java.lang.String)
*/
@Override
public List<Order> getOrderHistoryByOrderNumber(String orderNumber) {

Order initial = getOrderByOrderNumber(orderNumber);

// Find previous orders
String workNumber = initial.getPreviousOrderNumber();
LinkedList<Order> previousOrders = new LinkedList<Order>();
while (workNumber != null) {
Order previous = getOrderByOrderNumber(workNumber);
previousOrders.addFirst(previous);
previousOrders.addFirst(previous);
workNumber = previous.getPreviousOrderNumber();
}

Expand All @@ -230,17 +230,17 @@ public List<Order> getOrderHistoryByOrderNumber(String orderNumber) {
searchCriteria.add(Restrictions.eq("order.previousOrderNumber", workNumber));
nextOrder = (Order) searchCriteria.uniqueResult();
if (nextOrder != null) {
nextOrders.add(nextOrder);
nextOrders.add(nextOrder);
workNumber = nextOrder.getOrderNumber();
}
} while (nextOrder != null);

List<Order> result = previousOrders;
result.add(initial);
result.addAll(nextOrders);

return result;

}

}
6 changes: 3 additions & 3 deletions api/src/main/java/org/openmrs/util/OpenmrsClassLoader.java
Expand Up @@ -325,7 +325,7 @@ public static void destroyInstance() {
}

MemoryLeakUtil.clearHibernateSessionFactories();

OpenmrsClassScanner.destroyInstance();

OpenmrsClassLoaderHolder.INSTANCE = null;
Expand Down Expand Up @@ -408,9 +408,9 @@ public static void onShutdown() {
//Threads like Finalizer, Reference Handler, etc have null class loader reference.
if (classLoader == null)
continue;

if (classLoader instanceof OpenmrsClassLoader) {
try {
try {
//Set to WebappClassLoader just in case stopping fails.
thread.setContextClassLoader(classLoader.getParent());

Expand Down
8 changes: 4 additions & 4 deletions api/src/test/java/org/openmrs/api/OrderServiceTest.java
Expand Up @@ -579,7 +579,7 @@ public void saveOrder_shouldAssignOrderNumberForNewOrder() throws Exception {
Assert.assertNotNull(order.getOrderId());
Assert.assertNotNull(order.getOrderNumber());
}

/**
* @throws Exception
* @see OrderService#getOrderHistoryByOrderNumber(String)
Expand All @@ -590,8 +590,8 @@ public void getOrderHistoryByOrderNumber_shouldReturnTheListOfOrdersInAHistory()

executeDataSet(ORDERS_DATASET_XML);

OrderService orderService = Context.getOrderService();

OrderService orderService = Context.getOrderService();
List<Order> expectedHistory = new ArrayList<Order>();
expectedHistory.add(orderService.getOrderByOrderNumber("ORD-111"));
expectedHistory.add(orderService.getOrderByOrderNumber("ORD-222"));
Expand All @@ -605,6 +605,6 @@ public void getOrderHistoryByOrderNumber_shouldReturnTheListOfOrdersInAHistory()

history = orderService.getOrderHistoryByOrderNumber("ORD-333");
Assert.assertEquals(expectedHistory, history);

}
}
11 changes: 4 additions & 7 deletions api/src/test/java/org/openmrs/api/db/PatientDAOTest.java
Expand Up @@ -279,19 +279,16 @@ public void getPatientIdentifiers_shouldLimitByResultsByLocation() throws Except
Assert.assertEquals(1, patientIdentifiers.size());
Assert.assertEquals("12345K", patientIdentifiers.get(0).getIdentifier());
}

/**
* @see PatientDAO#getPatientIdentifiers(String,List,List,List,Boolean)
* @verifies not get voided patient identifiers
*/
@Test
public void getPatientIdentifiers_shouldNotGetVoidedPatientIdentifiers()
throws Exception {
public void getPatientIdentifiers_shouldNotGetVoidedPatientIdentifiers() throws Exception {


List<PatientIdentifier> patientIdentifiers
= dao.getPatientIdentifiers(null, new ArrayList<PatientIdentifierType>(),
new ArrayList<Location>(), new ArrayList<Patient>(), null);
List<PatientIdentifier> patientIdentifiers = dao.getPatientIdentifiers(null, new ArrayList<PatientIdentifierType>(),
new ArrayList<Location>(), new ArrayList<Patient>(), null);

//standartTestDataset.xml contains 5 non-voided identifiers

Expand Down
4 changes: 2 additions & 2 deletions web/src/main/java/org/openmrs/web/DispatcherServlet.java
Expand Up @@ -69,7 +69,7 @@ protected void initFrameworkServlet() throws ServletException, BeansException {
public void reInitFrameworkServlet() throws ServletException {
log.debug("Framework being REinitialized");
Thread.currentThread().setContextClassLoader(OpenmrsClassLoader.getInstance());
((XmlWebApplicationContext)getWebApplicationContext()).setClassLoader(OpenmrsClassLoader.getInstance());
((XmlWebApplicationContext) getWebApplicationContext()).setClassLoader(OpenmrsClassLoader.getInstance());

refresh();

Expand Down Expand Up @@ -101,7 +101,7 @@ public void init(ServletConfig config) throws ServletException {
*/
public void stopAndCloseApplicationContext() {
try {
XmlWebApplicationContext ctx = (XmlWebApplicationContext)getWebApplicationContext();
XmlWebApplicationContext ctx = (XmlWebApplicationContext) getWebApplicationContext();
ctx.stop();
ctx.close();
}
Expand Down
Expand Up @@ -106,7 +106,7 @@ protected void onBind(HttpServletRequest request, Object command) throws Excepti
obs.setValueCoded(obs.getValueCodedName().getConcept());
}

if ( obs.getConcept() != null && obs.getConcept().isComplex()) {
if (obs.getConcept() != null && obs.getConcept().isComplex()) {
InputStream complexDataInputStream = setComplexData(obs, request);
if (complexDataInputStream != null) {
complexDataInputStream.close();
Expand Down Expand Up @@ -179,10 +179,12 @@ else if (request.getParameter("unvoidObs") != null) {
httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "Obs.unvoidedSuccessfully");
}

} catch (IllegalArgumentException e) {
}
catch (IllegalArgumentException e) {
errors.reject("invalidImage", "Obs.invalidImage");
return showForm(request, response, errors);
} catch (APIException e) {
}
catch (APIException e) {
httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, e.getMessage());
return showForm(request, response, errors);
}
Expand Down

0 comments on commit 2a23a2e

Please sign in to comment.