Skip to content

Commit

Permalink
1672 rename deviceid to androidid (elimu-ai#1764)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-kuruvilla authored Jul 23, 2024
2 parents 4650236 + 2d53887 commit d69a16d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/main/java/ai/elimu/dao/DeviceDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

public interface DeviceDao extends GenericDao<Device> {

Device read(String deviceId) throws DataAccessException;
Device read(String androidId) throws DataAccessException;
}
6 changes: 3 additions & 3 deletions src/main/java/ai/elimu/dao/jpa/DeviceDaoJpa.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
public class DeviceDaoJpa extends GenericDaoJpa<Device> implements DeviceDao {

@Override
public Device read(String deviceId) throws DataAccessException {
public Device read(String androidId) throws DataAccessException {
try {
return (Device) em.createQuery(
"SELECT d " +
"FROM Device d " +
"WHERE d.deviceId = :deviceId")
.setParameter("deviceId", deviceId)
"WHERE d.androidId = :androidId")
.setParameter("androidId", androidId)
.getSingleResult();
} catch (NoResultException e) {
return null;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/ai/elimu/model/Device.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Device extends BaseEntity {

@NotNull
@Column(unique=true)
private String deviceId;
private String androidId;

@NotNull
private String deviceManufacturer;
Expand All @@ -33,12 +33,12 @@ public class Device extends BaseEntity {
@NotNull
private Integer osVersion;

public String getDeviceId() {
return deviceId;
public String getAndroidId() {
return androidId;
}

public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
public void setAndroidId(String androidId) {
this.androidId = androidId;
}

public String getDeviceManufacturer() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/META-INF/jpa-schema-export.sql
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@

create table Device (
id bigint not null auto_increment,
deviceId varchar(255),
androidId varchar(255),
deviceManufacturer varchar(255),
deviceModel varchar(255),
deviceSerial varchar(255),
Expand Down Expand Up @@ -695,7 +695,7 @@
add constraint UK_gdl53lyf9qvi56fmbrk9nfrg9 unique (version);

alter table Device
add constraint UK_ktkbd0xm3q2nddw1xxtdaxjy7 unique (deviceId);
add constraint UK_c2646199whiqrkjbht7hwyr3v unique (androidId);

alter table Application
add constraint FKn1pft600om9qs7dn754chjk67
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/db/migration/2004020.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 2.4.20
ALTER TABLE `Device` DROP COLUMN `deviceId`;
ALTER TABLE `Device` CHANGE `deviceId` `androidId` VARCHAR(255);
8 changes: 4 additions & 4 deletions src/test/java/ai/elimu/dao/DeviceDaoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public void testRead() {
deviceDao.create(getDevice("22"));
deviceDao.create(getDevice("44"));

assertEquals("22", deviceDao.read("22").getDeviceId());
assertEquals("44", deviceDao.read("44").getDeviceId());
assertEquals("22", deviceDao.read("22").getAndroidId());
assertEquals("44", deviceDao.read("44").getAndroidId());
assertNull(deviceDao.read("33"));
}

private Device getDevice(String deviceId) {
private Device getDevice(String androidId) {
Device device = new Device();
device.setDeviceId(deviceId);
device.setAndroidId(androidId);
return device;
}
}

0 comments on commit d69a16d

Please sign in to comment.