Subversion Repositories bacoAlunos

Rev

Rev 1782 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package pt.estgp.estgweb.domain;

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

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

/**
 * 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 GensonBuilder()
            .exclude(5+0%2Fdocs%2Fapi+Object">Object.class)
            .useRuntimeType(true)
            .useMethods(true)
            .useFields(false)
            .useClassMetadata(true)
            .include(CourseSchoolImpl.class)
            .include("id", CourseSchool.class)
            .include("active", CourseSchool.class)
            .include("institutionalCode", CourseSchool.class)
            .include("initials", CourseSchool.class)
            .include("name", CourseSchool.class)
            .include("nameEn", CourseSchool.class)
            .include("nameEs", CourseSchool.class)
            .include("nameFr",CourseSchool.class)

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

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

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

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

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

    public static 1.5.0/docs/api/java/lang/String.html">String toJson(List<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 toJsonObject() throws  JSONException {
        return new JSONObject(toJson());
    }
}