Subversion Repositories bacoAlunos

Rev

Rev 1692 | Rev 1778 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1505 jmachado 1
package pt.estgp.estgweb.domain;
2
 
1626 jmachado 3
import com.owlike.genson.Genson;
1670 jmachado 4
import org.json.JSONException;
5
import org.json.JSONObject;
1505 jmachado 6
import pt.estgp.estgweb.utils.ConfigProperties;
7
 
1626 jmachado 8
import java.io.IOException;
1505 jmachado 9
import java.io.Serializable;
1626 jmachado 10
import java.util.ArrayList;
1505 jmachado 11
 
12
/**
13
 * Created by jorgemachado on 14/09/16.
14
 */
15
public class CourseDepartmentImpl extends CourseDepartment {
16
    @1.5.0/docs/api/java/lang/Override.html">Override
17
    public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable() {
18
        return getSigla();
19
    }
20
 
21
    public 1.5.0/docs/api/java/lang/String.html">String getSchoolFromInstitutionalCode()
22
    {
1692 jmachado 23
        return ConfigProperties.getProperty("institution.code.prefix." + getCourseSchool().getInstitutionalCode());
1505 jmachado 24
    }
1626 jmachado 25
 
26
    static Genson courseDepartmentGenson = new Genson.Builder()
27
            .exclude(5+0%2Fdocs%2Fapi+Object">Object.class)
1670 jmachado 28
            .include(CourseDepartmentImpl.class)
29
            .include("sigla", CourseDepartmentImpl.class)
30
            .include("active", CourseDepartmentImpl.class)
31
            .include("name", CourseDepartmentImpl.class)
32
            .include("nameEn", CourseDepartmentImpl.class)
33
            .include("nameEs", CourseDepartmentImpl.class)
34
            .include("nameFr",CourseDepartmentImpl.class)
35
            .include("directorRole",CourseDepartmentImpl.class)
36
            .include("boardRole",CourseDepartmentImpl.class)
37
            .include("courseSchool",CourseDepartmentImpl.class)
38
            .include("id",CourseSchoolImpl.class)
1626 jmachado 39
            .create();
40
 
1776 jmachado 41
    public 1.5.0/docs/api/java/lang/String.html">String getJson() throws 1.5.0/docs/api/java/io/IOException.html">IOException
1626 jmachado 42
    {
43
        return courseDepartmentGenson.serialize(this);
44
    }
1776 jmachado 45
    public JSONObject getJsonObject() throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException
1670 jmachado 46
    {
47
        return new JSONObject(courseDepartmentGenson.serialize(this));
48
    }
1626 jmachado 49
 
1776 jmachado 50
    public static 1.5.0/docs/api/java/lang/String.html">String getJson(ArrayList<CourseDepartment> departments) throws 1.5.0/docs/api/java/io/IOException.html">IOException
1626 jmachado 51
    {
52
        return courseDepartmentGenson.serialize(departments);
53
    }
1670 jmachado 54
 
1776 jmachado 55
    public static CourseDepartmentImpl loadFromJson(1.5.0/docs/api/java/lang/String.html">String json) throws 1.5.0/docs/api/java/io/IOException.html">IOException
1670 jmachado 56
    {
57
        return courseDepartmentGenson.deserialize(json,CourseDepartmentImpl.class);
58
    }
1505 jmachado 59
}