Navigation Menu

Skip to content

Commit

Permalink
Work around to solve CSM-112
Browse files Browse the repository at this point in the history
  • Loading branch information
k-joseph committed Jul 27, 2015
1 parent 30b0d4e commit c27e059
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 28 deletions.
8 changes: 8 additions & 0 deletions api/pom.xml
Expand Up @@ -39,6 +39,14 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openmrs.api</groupId>
<artifactId>openmrs-api</artifactId>
<version>${openMRSVersion}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Expand Up @@ -32,7 +32,6 @@
import org.openmrs.module.chartsearch.cache.ChartSearchNote;
import org.openmrs.module.chartsearch.solr.ChartSearchCustomIndexer;


/**
* It is a default implementation of {@link ChartSearchDAO}.
*/
Expand Down Expand Up @@ -180,7 +179,7 @@ public void deleteSearchHistory(ChartSearchHistory searchHistory) {
@Override
public ChartSearchHistory getSearchHistoryByUuid(String uuid) {
ChartSearchHistory history = (ChartSearchHistory) sessionFactory.getCurrentSession()
.createQuery("from ChartSearchHistory h where h.uuid = :uuid").setString("uuid", uuid).uniqueResult();
.createQuery("from ChartSearchHistory h where h.uuid = :uuid").setParameter("uuid", uuid).uniqueResult();

return history;
}
Expand Down Expand Up @@ -238,7 +237,7 @@ public ChartSearchNote getSearchNote(Integer noteId) {
@Override
public ChartSearchNote getSearchNoteByUuid(String uuid) {
ChartSearchNote note = (ChartSearchNote) sessionFactory.getCurrentSession()
.createQuery("from ChartSearchNote n where n.uuid = :uuid").setString("uuid", uuid).uniqueResult();
.createQuery("from ChartSearchNote n where n.uuid = :uuid").setParameter("uuid", uuid).uniqueResult();

return note;
}
Expand Down
Expand Up @@ -12,6 +12,7 @@
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;

import javax.persistence.Column;
import javax.persistence.Entity;
Expand All @@ -23,13 +24,12 @@
import javax.persistence.Table;

import org.apache.commons.lang3.StringUtils;
import org.openmrs.BaseOpenmrsObject;
import org.openmrs.Patient;
import org.openmrs.User;

@Entity
@Table(name = "chartsearch_bookmark")
public class ChartSearchBookmark extends BaseOpenmrsObject implements Serializable {
public class ChartSearchBookmark implements Serializable {

private static final long serialVersionUID = 1L;

Expand All @@ -38,6 +38,9 @@ public class ChartSearchBookmark extends BaseOpenmrsObject implements Serializab
@Column(name = "bookmark_id")
private Integer bookmarkId;

@Column(name = "uuid", unique = true, nullable = false, length = 38)
private String uuid = UUID.randomUUID().toString();

@Column(name = "bookmark_name", nullable = false)
private String bookmarkName;

Expand All @@ -62,14 +65,12 @@ public class ChartSearchBookmark extends BaseOpenmrsObject implements Serializab
@Column(name = "selected_categories")
private String selectedCategories;

@Override
public Integer getId() {
return getBookmarkId();
public String getUuid() {
return uuid;
}

@Override
public void setId(Integer id) {
setBookmarkId(id);
public void setUuid(String uuid) {
this.uuid = uuid;
}

public Integer getBookmarkId() {
Expand Down
Expand Up @@ -11,6 +11,7 @@

import java.io.Serializable;
import java.util.Date;
import java.util.UUID;

import javax.persistence.Column;
import javax.persistence.Entity;
Expand All @@ -21,20 +22,23 @@
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.openmrs.BaseOpenmrsObject;
import org.openmrs.Patient;
import org.openmrs.User;

@Entity
@Table(name = "chartsearch_history")
@SuppressWarnings("serial")
public class ChartSearchHistory extends BaseOpenmrsObject implements Serializable {
public class ChartSearchHistory implements Serializable {

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "search_id")
private Integer searchId;

@Column(name = "uuid", unique = true, nullable = false, length = 38)
private String uuid = UUID.randomUUID().toString();

/**
* Phrase or text searched for
*/
Expand All @@ -52,14 +56,12 @@ public class ChartSearchHistory extends BaseOpenmrsObject implements Serializabl
@JoinColumn(name = "user_id", nullable = false)
private User historyOwner;

@Override
public Integer getId() {
return getSearchId();
public String getUuid() {
return uuid;
}

@Override
public void setId(Integer id) {
setSearchId(id);
public void setUuid(String uuid) {
this.uuid = uuid;
}

public Integer getSearchId() {
Expand Down
Expand Up @@ -11,6 +11,7 @@

import java.io.Serializable;
import java.util.Date;
import java.util.UUID;

import javax.persistence.Column;
import javax.persistence.Entity;
Expand All @@ -21,7 +22,6 @@
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.openmrs.BaseOpenmrsObject;
import org.openmrs.Patient;
import org.openmrs.User;

Expand All @@ -30,7 +30,7 @@
*/
@Entity
@Table(name = "chartsearch_note")
public class ChartSearchNote extends BaseOpenmrsObject implements Serializable {
public class ChartSearchNote implements Serializable {

private static final long serialVersionUID = 1L;

Expand All @@ -39,6 +39,9 @@ public class ChartSearchNote extends BaseOpenmrsObject implements Serializable {
@Column(name = "note_id")
private Integer noteId;

@Column(name = "uuid", unique = true, nullable = false, length = 38)
private String uuid = UUID.randomUUID().toString();

@Column(name = "comment", nullable = false)
private String comment;

Expand All @@ -62,14 +65,12 @@ public class ChartSearchNote extends BaseOpenmrsObject implements Serializable {
@Column(name = "display_color", length = 10)
private String displayColor;

@Override
public Integer getId() {
return getNoteId();
public String getUuid() {
return uuid;
}

@Override
public void setId(Integer id) {
setNoteId(id);
public void setUuid(String uuid) {
this.uuid = uuid;
}

public Integer getNoteId() {
Expand Down

0 comments on commit c27e059

Please sign in to comment.