Skip to content

Commit

Permalink
Added @transactional annotation to services, which is required for su…
Browse files Browse the repository at this point in the history
…ccessful commit to DB - Module JSSLab

- cleanup of classes on DAO/service/db level
- minor bugfixes
  • Loading branch information
martinlosse committed Jul 14, 2012
1 parent 6360757 commit 3b53f05
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 67 deletions.
Expand Up @@ -13,6 +13,7 @@
import org.openmrs.api.OpenmrsService;
import org.springframework.transaction.annotation.Transactional;

@Transactional
public interface LabCatalogService extends OpenmrsService {

//-----------------------------------------------------------------------
Expand Down
Expand Up @@ -9,6 +9,7 @@
import org.openmrs.module.jsslab.db.LabSupplyItem;
import org.springframework.transaction.annotation.Transactional;

@Transactional
public interface LabManagementService extends OpenmrsService {

/**
Expand Down Expand Up @@ -125,11 +126,11 @@ public interface LabManagementService extends OpenmrsService {
/**
* Get the <code>LabInstrument</code> with the given propertyTag or serialNumber
*
* @param propertyTag or serialNumber to find
* @param name propertyTag, serialNumber or model to find
* @return the LabInstrument that was found or null
*/
@Authorized( PrivilegeConstants.VIEW_LAB_MGMT )
public LabInstrument getLabInstrument(Integer idNumber);
public LabInstrument getLabInstrument(String name);

/**
* Save or update the given <code>LabSupplyItem</code> in the database
Expand Down
Expand Up @@ -14,6 +14,7 @@
import org.openmrs.api.OpenmrsService;
import org.springframework.transaction.annotation.Transactional;

@Transactional
public interface LabOrderService extends OpenmrsService {

/**
Expand Down
Expand Up @@ -12,6 +12,7 @@
import org.openmrs.module.jsslab.db.LabTestRange;
import org.springframework.transaction.annotation.Transactional;

@Transactional
public interface LabTestingService extends OpenmrsService {

@Authorized( PrivilegeConstants.VIEW_LAB_TEST )
Expand Down
Expand Up @@ -58,7 +58,8 @@ public class LabInstrument extends BaseOpenmrsMetadata {

protected Set<LabTestRun> testRuns = new HashSet<LabTestRun>();

private String name;
// TODO decide if needed - currently unused
// private String name;

public LabInstrument() {
super();
Expand Down Expand Up @@ -219,7 +220,7 @@ public String getReceivedFrom() {
* @param receivedFrom The receivedFrom to set.
*/
@Attribute(required = false)
public void setreceivedFrom(String ReceivedFrom) {
public void setReceivedFrom(String receivedFrom) {
this.receivedFrom = receivedFrom;
}

Expand Down
Expand Up @@ -58,7 +58,7 @@ public interface LabInstrumentDAO {
/**
* Get a labInstrument by name
*
* @param name String name of the <code>LabInstrument</code> to get
* @param name String value of the propertyTag, serialNumber or model properties of <code>LabInstrument</code> to match
* @return the requested <code>LabInstrument</code>
*/
public LabInstrument getLabInstrument(String name);
Expand Down
36 changes: 11 additions & 25 deletions api/src/main/java/org/openmrs/module/jsslab/db/LabReport.java
Expand Up @@ -15,25 +15,17 @@

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

import org.openmrs.BaseOpenmrsMetadata;
import org.openmrs.Patient;
import org.openmrs.Person;
import org.openmrs.User;
import org.openmrs.Location;
import org.openmrs.Concept;
import org.openmrs.Order;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.BaseOpenmrsMetadata;
import org.openmrs.Concept;
import org.openmrs.User;
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;

/**
Expand Down Expand Up @@ -66,14 +58,12 @@ public class LabReport extends BaseOpenmrsMetadata implements Serializable {

protected Set<LabSpecimen> specimens = new HashSet<LabSpecimen>();

public void LabReport() {

public LabReport() {
this.setUuid(UUID.randomUUID().toString());
}

@Override
public int hashCode() {

return this.getUuid().hashCode();
}

Expand All @@ -87,28 +77,25 @@ public boolean equals(Object other) {
}
}

/* (non-Javadoc)
* @see org.openmrs.OpenmrsObject#getId()
*/
@Override
public Integer getId() {
return reportId;
}

public void setReportId(Integer reportId) {
this.reportId = reportId;
@Override
public void setId(Integer id) {
this.reportId = id;

}

public Integer getReportId() {
return reportId;
}

/* (non-Javadoc)
* @see org.openmrs.OpenmrsObject#setId(java.lang.Integer)
*/
public void setId(Integer reportId) {
public void setReportId(Integer reportId) {
this.reportId = reportId;
}

/**
* @return Returns the labReportId.
*/
Expand Down Expand Up @@ -238,6 +225,5 @@ public Set<LabSpecimen> getSpecimens(){
public void setSpecimens(Set<LabSpecimen> specimens) {
this.specimens = specimens;
}


}
Expand Up @@ -371,15 +371,15 @@ public void setHidden(Boolean hidden) {
* @return Returns the testspecimens set.
*/
@Attribute(required = false)
public Set<LabTestSpecimen> getTestSpecimens(){
public Set<LabTestSpecimen> getTestSpecimens() {
return testSpecimens;
}

/**
* @param testspecimens The set of testspecimens to set.
*/
@Attribute(required = false)
public void setTestSpecimens(Set<LabTestSpecimen> TestSpecimens) {
public void setTestSpecimens(Set<LabTestSpecimen> testSpecimens) {
this.testSpecimens = testSpecimens;
}

Expand Down
Expand Up @@ -14,19 +14,14 @@
package org.openmrs.module.jsslab.db;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.Locale;
import java.lang.Comparable;
import java.util.UUID;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.BaseOpenmrsMetadata;
import org.openmrs.Concept;
import org.openmrs.User;
import org.openmrs.api.context.Context;
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Root;
Expand All @@ -42,10 +37,10 @@ public class LabSpecimenTemplate extends BaseOpenmrsMetadata implements Serializ

private static final Log log = LogFactory.getLog(LabSpecimenTemplate.class);

private Locale textLocale;

private Integer specimenTemplateId;

private Locale textLocale;

private Concept parentRoleConcept;

private String parentRoleName;
Expand Down Expand Up @@ -108,14 +103,6 @@ public void setSpecimenTemplateId(Integer specimenTemplateId) {
this.specimenTemplateId = specimenTemplateId;
}

public Integer getTestSpecimenId() {
return specimenTemplateId;
}

public void setTestSpecimenId(Integer specimenTemplateId) {
this.specimenTemplateId = specimenTemplateId;
}

/**
* @return Returns the parentRole concept.
*/
Expand Down
Expand Up @@ -49,7 +49,6 @@ public LabSupplyItem() {

@Override
public int hashCode() {

return this.getUuid().hashCode();
}

Expand Down
2 changes: 0 additions & 2 deletions api/src/main/java/org/openmrs/module/jsslab/db/LabTest.java
Expand Up @@ -58,13 +58,11 @@ public class LabTest extends BaseOpenmrsMetadata implements Serializable {
private Set<LabTestRange> testRanges = new HashSet<LabTestRange>();

public LabTest() {

this.setUuid(UUID.randomUUID().toString());
}

@Override
public int hashCode() {

return this.getUuid().hashCode();
}

Expand Down
16 changes: 5 additions & 11 deletions api/src/main/java/org/openmrs/module/jsslab/db/LabTestPanel.java
Expand Up @@ -14,21 +14,17 @@
package org.openmrs.module.jsslab.db;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.math.BigDecimal;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.math.BigDecimal;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.BaseOpenmrsMetadata;
import org.openmrs.Location;
import org.openmrs.Concept;
import org.openmrs.Location;
import org.openmrs.api.context.Context;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Root;

Expand Down Expand Up @@ -75,14 +71,12 @@ public class LabTestPanel extends BaseOpenmrsMetadata implements Serializable {

private Set<LabSpecimenTemplate> specimenTemplates = new HashSet<LabSpecimenTemplate>();

public void LabTestPanel() {

public LabTestPanel() {
this.setUuid(UUID.randomUUID().toString());
}

@Override
public int hashCode() {

return this.getUuid().hashCode();
}

Expand Down
Expand Up @@ -22,7 +22,6 @@
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.openmrs.api.APIException;
import org.openmrs.api.context.Context;
import org.openmrs.module.jsslab.db.LabInstrument;
import org.openmrs.module.jsslab.db.LabInstrumentDAO;
import org.openmrs.module.jsslab.db.LabTestRun;
Expand All @@ -45,10 +44,10 @@ public void setSessionFactory(SessionFactory sessionFactory) {
* @see org.openmrs.api.db.LabInstrumentDAO#saveLabInstrument(org.openmrs.LabInstrument)
*/
public LabInstrument saveLabInstrument(LabInstrument instrument) {
if (instrument.getInstrumentId() == null) {
throw new APIException(Context.getMessageSourceService().getMessage("JSSLab.HibernateLabInstrumentDAO.saveLabInstrument.instrumentIdRequired", null,
"Attribute 'instrumentId' is required", Context.getLocale()));
}
// if (instrument.getInstrumentId() == null) {
// throw new APIException(Context.getMessageSourceService().getMessage("JSSLab.HibernateLabInstrumentDAO.saveLabInstrument.instrumentIdRequired", null,
// "Attribute 'instrumentId' is required", Context.getLocale()));
// }
/**
* TODO: implement TestRuns if (instrument.getTestRuns() != null && instrument.getId() !=
* null) { // Hibernate has a problem updating child collections // if the parent object was
Expand Down

0 comments on commit 3b53f05

Please sign in to comment.