Skip to content

Commit

Permalink
Merge branch 'feature/dialog-exercise' into dev-backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemanja Tisma committed Dec 18, 2018
2 parents 8125d67 + 024d54e commit b8b6b32
Show file tree
Hide file tree
Showing 8 changed files with 292 additions and 3 deletions.
72 changes: 72 additions & 0 deletions core/src/main/java/ch/uzh/marugoto/core/data/entity/Character.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package ch.uzh.marugoto.core.data.entity;

import com.arangodb.springframework.annotation.Document;

import org.springframework.data.annotation.Id;

@Document
public class Character {
@Id
private String id;
private Salutation salutation;
private String firstname;
private String lastname;
private String mail;
private ImageResource image;

public Character() {
super();
}

public Character(Salutation salutation, String firstname, String lastname, String mail) {
this();
this.salutation = salutation;
this.firstname = firstname;
this.lastname = lastname;
this.mail = mail;
}

public String getId() {
return id;
}

public Salutation getSalutation() {
return salutation;
}

public void setSalutation(Salutation salutation) {
this.salutation = salutation;
}

public String getFirstname() {
return firstname;
}

public void setFirstname(String firstname) {
this.firstname = firstname;
}

public String getLastname() {
return lastname;
}

public void setLastname(String lastname) {
this.lastname = lastname;
}

public String getMail() {
return mail;
}

public void setMail(String mail) {
this.mail = mail;
}

public ImageResource getImage() {
return image;
}

public void setImage(ImageResource image) {
this.image = image;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package ch.uzh.marugoto.core.data.entity;

import com.arangodb.springframework.annotation.Ref;

/**
* Dialog exercise on page
* If placeholder text is not defined, dialog is shown immediately
* Requires Speaker and DialogSpeech
*/
public class DialogExercise extends Exercise {

private String placeholderText;
private boolean showOnPageLoad;
private Character speaker;
@Ref
private DialogSpeech speech;

public DialogExercise() {
super();
}

public DialogExercise(String placeholderText, Character speaker, DialogSpeech dialogSpeech) {
this();
this.placeholderText = placeholderText;
this.speaker = speaker;
this.speech = dialogSpeech;
}

public String getPlaceholderText() {
return placeholderText;
}

public void setPlaceholderText(String placeholderText) {
this.placeholderText = placeholderText;
}

public boolean isShownOnPageLoad() {
return placeholderText == null;
}

public Character getSpeaker() {
return speaker;
}

public void setSpeaker(Character speaker) {
this.speaker = speaker;
}

public DialogSpeech getSpeech() {
return speech;
}

public void setSpeech(DialogSpeech speech) {
this.speech = speech;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package ch.uzh.marugoto.core.data.entity;


import com.arangodb.springframework.annotation.Edge;
import com.arangodb.springframework.annotation.From;
import com.arangodb.springframework.annotation.Ref;
import com.arangodb.springframework.annotation.To;

import org.springframework.data.annotation.Id;

/**
* Answer for DialogSpeech which can point to another speech
* or can trigger page transition
*/
@Edge
public class DialogResponse {
@Id
private String id;
@From
private DialogSpeech from;
@To
private DialogSpeech to;
@Ref
private PageTransition pageTransition;

public DialogResponse() {
super();
}

public DialogResponse(DialogSpeech from, DialogSpeech to) {
this();
this.from = from;
this.to = to;
}

public DialogResponse(DialogSpeech from, DialogSpeech to, PageTransition pageTransition) {
this(from, to);
this.pageTransition = pageTransition;
}

public String getId() {
return id;
}

public DialogSpeech getFrom() {
return from;
}

public void setFrom(DialogSpeech from) {
this.from = from;
}

public DialogSpeech getTo() {
return to;
}

public void setTo(DialogSpeech to) {
this.to = to;
}

public PageTransition getPageTransition() {
return pageTransition;
}

public void setPageTransition(PageTransition pageTransition) {
this.pageTransition = pageTransition;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package ch.uzh.marugoto.core.data.entity;

import com.arangodb.springframework.annotation.Document;
import com.arangodb.springframework.annotation.Ref;

import org.springframework.data.annotation.Id;

/**
* Dialog speech
* Belongs to dialog exercise
*/
@Document
public class DialogSpeech {
@Id
private String id;
private String markdownContent;
@Ref
private DialogExercise dialogExercise;

public DialogSpeech() {
super();
}

public DialogSpeech(String markdownContent, DialogExercise dialogExercise) {
this();
this.markdownContent = markdownContent;
this.dialogExercise = dialogExercise;
}

public String getId() {
return id;
}

public String getMarkdownContent() {
return markdownContent;
}

public void setMarkdownContent(String markdownContent) {
this.markdownContent = markdownContent;
}

public DialogExercise getDialogExercise() {
return dialogExercise;
}

public void setDialogExercise(DialogExercise dialogExercise) {
this.dialogExercise = dialogExercise;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.arangodb.springframework.annotation.Ref;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;


@Document
@JsonIgnoreProperties({"page"})
public class NotebookEntry {
Expand All @@ -16,12 +15,19 @@ public class NotebookEntry {
private String text;
@Ref
private Page page;
@Ref
private DialogResponse dialogResponse;
private NotebookEntryAddToPageStateAt addToPageStateAt;

public NotebookEntry() {
super();
}

public NotebookEntry(String title, String text) {
this.title = title;
this.text = text;
}

public NotebookEntry(Page page, String title, String text) {
super();
this.page = page;
Expand All @@ -31,8 +37,6 @@ public NotebookEntry(Page page, String title, String text) {

public NotebookEntry(Page page, String title, String text, NotebookEntryAddToPageStateAt addToPageStateAt) {
this(page, title, text);
this.title = title;
this.text = text;
this.addToPageStateAt = addToPageStateAt;
}

Expand Down Expand Up @@ -64,6 +68,14 @@ public void setPage(Page page) {
this.page = page;
}

public DialogResponse getDialogResponse() {
return dialogResponse;
}

public void setDialogResponse(DialogResponse dialogResponse) {
this.dialogResponse = dialogResponse;
}

public NotebookEntryAddToPageStateAt getAddToPageStateAt() {
return addToPageStateAt;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package ch.uzh.marugoto.core.data.repository;

import com.arangodb.springframework.repository.ArangoRepository;

import ch.uzh.marugoto.core.data.entity.Character;

public interface CharacterRepository extends ArangoRepository<Character> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ch.uzh.marugoto.core.data.repository;

import com.arangodb.springframework.annotation.Query;
import com.arangodb.springframework.repository.ArangoRepository;

import org.springframework.data.repository.query.Param;

import java.util.List;

import ch.uzh.marugoto.core.data.entity.DialogResponse;

public interface DialogResponseRepository extends ArangoRepository<DialogResponse> {

@Query("FOR dialogSpeech, dialogResponse IN OUTBOUND @fromDialogSpeechId dialogResponse RETURN dialogResponse")
List<DialogResponse> findByDialogSpeech(@Param("fromDialogSpeechId") String fromDialogSpeech);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package ch.uzh.marugoto.core.data.repository;

import com.arangodb.springframework.repository.ArangoRepository;

import ch.uzh.marugoto.core.data.entity.DialogSpeech;

public interface DialogSpeechRepository extends ArangoRepository<DialogSpeech> {
}

0 comments on commit b8b6b32

Please sign in to comment.