Subversion Repositories bacoAlunos

Rev

Rev 1778 | Rev 1780 | 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 pt.estgp.estgweb.utils.ConfigProperties;

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

/**
 * Created by jorgemachado on 14/09/16.
 */

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

    public 1.5.0/docs/api/java/lang/String.html">String getSchoolFromInstitutionalCode()
    {
        return ConfigProperties.getProperty("institution.code.prefix." + getCourseSchool().getInstitutionalCode());
    }

    static Genson courseDepartmentGenson = new Genson.Builder()
            .exclude(5+0%2Fdocs%2Fapi+Object">Object.class)
            .include(CourseDepartmentImpl.class)
            .include("sigla", CourseDepartmentImpl.class)
            .include("active", CourseDepartmentImpl.class)
            .include("name", CourseDepartmentImpl.class)
            .include("nameEn", CourseDepartmentImpl.class)
            .include("nameEs", CourseDepartmentImpl.class)
            .include("nameFr",CourseDepartmentImpl.class)
            .include("directorRole",CourseDepartmentImpl.class)
            .include("boardRole",CourseDepartmentImpl.class)
            .include("courseSchool",CourseDepartmentImpl.class)
            .include("id",CourseSchoolImpl.class)
            .create();

    public 1.5.0/docs/api/java/lang/String.html">String toJson() throws 1.5.0/docs/api/java/io/IOException.html">IOException
    {
        return courseDepartmentGenson.serialize(this);
    }
    public JSONObject toJsonObject() throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException
    {
        return new JSONObject(courseDepartmentGenson.serialize(this));
    }

    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
    {
        return courseDepartmentGenson.serialize(departments);
    }

    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
    {
        return courseDepartmentGenson.deserialize(json,CourseDepartmentImpl.class);
    }

    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 {
        1.5.0/docs/api/java/lang/System.html">System.out.println(new CourseDepartmentImpl().toJson());
    }
}