Subversion Repositories bacoAlunos

Rev

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