Skip to content

Commit

Permalink
Merge pull request #260 from jogrimst/master
Browse files Browse the repository at this point in the history
Event structure
  • Loading branch information
literacyapp authored Oct 28, 2016
2 parents 61b34e2 + 9bf3b86 commit dfb27f5
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 39 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<literacyapp.model.version>1.1.12</literacyapp.model.version>
<literacyapp.model.version>1.1.18</literacyapp.model.version>
<hibernate.version>4.3.9.Final</hibernate.version>
<jetty.version>8.1.14.v20131031</jetty.version>
<spring.version>4.2.6.RELEASE</spring.version>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/literacyapp/model/Student.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotEmpty;
Expand All @@ -17,7 +18,7 @@ public class Student extends BaseEntity {
private Locale locale;

@NotEmpty
@OneToMany
@OneToMany(fetch = FetchType.EAGER)
private Set<Device> devices;

public Locale getLocale() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
package org.literacyapp.model.analytics;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotNull;
import org.literacyapp.model.Student;
import org.literacyapp.model.admin.Application;
import org.literacyapp.model.enums.content.TaskType;

@Entity
public class TaskEvent extends DeviceEvent {

@ManyToOne
private Student student;
public class UsageEvent extends DeviceEvent {

@NotNull
@ManyToOne
private Application application;

@NotNull
@Enumerated(EnumType.STRING)
private TaskType taskType;

@ManyToOne
private Student student;

public Student getStudent() {
return student;
}
Expand All @@ -38,12 +31,4 @@ public Application getApplication() {
public void setApplication(Application application) {
this.application = application;
}

public TaskType getTaskType() {
return taskType;
}

public void setTaskType(TaskType taskType) {
this.taskType = taskType;
}
}
32 changes: 15 additions & 17 deletions src/main/java/org/literacyapp/rest/v1/JavaToGsonConverter.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.literacyapp.rest.v1;

import java.util.HashSet;
import java.util.Set;
import org.literacyapp.model.admin.Application;
import org.literacyapp.model.Device;
import org.literacyapp.model.content.Word;
Expand Down Expand Up @@ -109,21 +107,21 @@ public static DeviceGson getDeviceGson(Device device) {

deviceJson.setId(device.getId());
deviceJson.setDeviceId(device.getDeviceId());
deviceJson.setDeviceModel(device.getDeviceModel());
deviceJson.setTimeRegistered(device.getTimeRegistered());
deviceJson.setOsVersion(device.getOsVersion());
deviceJson.setLocale(device.getLocale());

Set<DeviceGson> devicesNearby = new HashSet<DeviceGson>();
for (Device deviceNearby : device.getDevicesNearby()) {
DeviceGson deviceJsonNearby = getDeviceGson(deviceNearby);
if (deviceJsonNearby != null) {
devicesNearby.add(deviceJsonNearby);
}
}
if (!devicesNearby.isEmpty()) {
deviceJson.setDevicesNearby(devicesNearby);
}
// deviceJson.setDeviceModel(device.getDeviceModel());
// deviceJson.setTimeRegistered(device.getTimeRegistered());
// deviceJson.setOsVersion(device.getOsVersion());
// deviceJson.setLocale(device.getLocale());
//
// Set<DeviceGson> devicesNearby = new HashSet<DeviceGson>();
// for (Device deviceNearby : device.getDevicesNearby()) {
// DeviceGson deviceJsonNearby = getDeviceGson(deviceNearby);
// if (deviceJsonNearby != null) {
// devicesNearby.add(deviceJsonNearby);
// }
// }
// if (!devicesNearby.isEmpty()) {
// deviceJson.setDevicesNearby(devicesNearby);
// }

return deviceJson;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/db/migration/1001036.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# 1.1.36

DROP TABLE DeviceEvent;
DROP TABLE DeviceEvent;
DROP TABLE TaskEvent;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dfb27f5

Please sign in to comment.