Subversion Repositories bacoAlunos

Rev

Rev 1730 | Rev 1779 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package pt.estgp.estgweb.domain;

import com.owlike.genson.Genson;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;

/**
 * Created by jorgemachado on 13/02/17.
 */

public class CourseSchoolImpl extends CourseSchool{
    @1.5.0/docs/api/java/lang/Override.html">Override
    public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable() {
        return getId();
    }


    static Genson courseSchoolGenson = new Genson.Builder()
            .exclude(5+0%2Fdocs%2Fapi+Object">Object.class)
            .include(CourseSchoolImpl.class)
            .include("id", CourseSchoolImpl.class)
            .include("active", CourseSchoolImpl.class)
            .include("institutionalCode", CourseSchoolImpl.class)
            .include("initials", CourseSchoolImpl.class)
            .include("name", CourseSchoolImpl.class)
            .include("nameEn", CourseSchoolImpl.class)
            .include("nameEs", CourseSchoolImpl.class)
            .include("nameFr",CourseSchoolImpl.class)

            .include("schoolDirectorRole", CourseSchoolImpl.class)
            .include("schoolBoardRole",CourseSchoolImpl.class)
            .include("schoolSecretariadoRole",CourseSchoolImpl.class)

            .include("ctcPresidentRole",CourseSchoolImpl.class)
            .include("ctcMemberRole",CourseSchoolImpl.class)
            .include("ctcSecretariadoRole",CourseSchoolImpl.class)

            .include("pedagogicoPresidentRole",CourseSchoolImpl.class)
            .include("pedagogicoMemberRole",CourseSchoolImpl.class)
            .include("pedagogicoSecretariadoRole",CourseSchoolImpl.class)

            .include("funcionarioRole",CourseSchoolImpl.class)
            .include("studentRole",CourseSchoolImpl.class)
            .include("teacherRole",CourseSchoolImpl.class)
            .create();

    public 1.5.0/docs/api/java/lang/String.html">String getJson() throws 1.5.0/docs/api/java/io/IOException.html">IOException
    {
        return courseSchoolGenson.serialize(this);
    }

    public static 1.5.0/docs/api/java/lang/String.html">String getJson(ArrayList<CourseSchool> schools) throws 1.5.0/docs/api/java/io/IOException.html">IOException
    {
        return courseSchoolGenson.serialize(schools);
    }

    public static CourseSchoolImpl loadFromJson(1.5.0/docs/api/java/lang/String.html">String json) throws 1.5.0/docs/api/java/io/IOException.html">IOException {
        return courseSchoolGenson.deserialize(json, CourseSchoolImpl.class);
    }

    public JSONObject getJsonObject() throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException {
        return new JSONObject(getJson());
    }
}