Skip to content
This repository has been archived by the owner on Mar 16, 2018. It is now read-only.

Latest commit

 

History

History
85 lines (65 loc) · 1.66 KB

DOCS.md

File metadata and controls

85 lines (65 loc) · 1.66 KB

Developing for SpringBoot Java 8

New Models

Each new kind for entity must follow the following model:

For example the creation of a new class called David will follow:

 |
 \____ controller
          \_____ DavidController.java
 |
 \____ model
          \_____ David.java
 |
 \____ service
          \_____ DavidService.java
 |
 \____ repository
          \_____ DavidRepository.java

and within edu.monash.monplan.config we have the ObjectifyConfig class, we add the following

private void registerObjectifyEntities() {
    register(Diesel.class);
    register(Unit.class);
+   register(David.class);
}

So we can wire this up.

Making the David.class Model

package edu.monash.monplan.model;

import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Index;
import com.threewks.gaetools.search.SearchIndex;

@Entity
public class David {

    @Id
    private String id;

    @Index
    private String fullName;

    private List<String> memes;
    
    public String getId(){
        return id;
    }
    
    public String setId(String id){
        this.id = id;
    }
    
    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public List<String> getMemes() {
        return memes;
    }

    public void setMemes(List<String> memes) {
        this.memes = memes;
    }
    
    
    
    public void init() {
        // Protects us from accidentally re-initialising an object that's retrieved from db
        this.setId(UUID.randomUUID().toString());
    }
}