Subversion Repositories bacoAlunos

Rev

Rev 1779 | Rev 1782 | 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
 
1780 jmachado 41
    public 1.5.0/docs/api/java/lang/String.html">String toJson()  {
1626 jmachado 42
        return courseDepartmentGenson.serialize(this);
43
    }
1780 jmachado 44
    public JSONObject toJsonObject() throws  JSONException
1670 jmachado 45
    {
46
        return new JSONObject(courseDepartmentGenson.serialize(this));
47
    }
1626 jmachado 48
 
1779 jmachado 49
    public static 1.5.0/docs/api/java/lang/String.html">String toJson(ArrayList<CourseDepartment> departments) throws 1.5.0/docs/api/java/io/IOException.html">IOException
1626 jmachado 50
    {
51
        return courseDepartmentGenson.serialize(departments);
52
    }
1670 jmachado 53
 
1776 jmachado 54
    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 55
    {
56
        return courseDepartmentGenson.deserialize(json,CourseDepartmentImpl.class);
57
    }
1778 jmachado 58
 
59
    public static void main(1.5.0/docs/api/java/lang/String.html">String[] args) throws 1.5.0/docs/api/java/io/IOException.html">IOException {
1779 jmachado 60
        1.5.0/docs/api/java/lang/System.html">System.out.println(new CourseDepartmentImpl().toJson());
1778 jmachado 61
    }
1505 jmachado 62
}