Subversion Repositories bacoAlunos

Rev

Rev 1795 | 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 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();
    }

    private 1.5.0/docs/api/java/lang/String.html">String siglaNova;

    public 1.5.0/docs/api/java/lang/String.html">String getSiglaNova()
    {
        if(siglaNova == null || siglaNova.trim().length() == 0)
            siglaNova = getSigla();
        return siglaNova;
    }

    public void setSiglaNova(1.5.0/docs/api/java/lang/String.html">String siglaNova) {
        this.siglaNova = siglaNova;
    }

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

    public void setSchoolFromInstitutionalCode(1.5.0/docs/api/java/lang/String.html">String garbage)
    {

    }

    static Genson courseDepartmentGenson = new GensonBuilder()
            .exclude(5+0%2Fdocs%2Fapi+Object">Object.class)
            .include(CourseDepartmentImpl.class)
            .useRuntimeType(true)
            .useMethods(true)
            .useFields(false)
            .useClassMetadata(true)
            .include("sigla", CourseDepartment.class)
            .include("siglaNova", CourseDepartmentImpl.class)
            .include("active", CourseDepartment.class)
            .include("name", CourseDepartment.class)
            .include("nameEn", CourseDepartment.class)
            .include("nameEs", CourseDepartment.class)
            .include("nameFr",CourseDepartment.class)
            .include("directorRole",CourseDepartment.class)
            .include("boardRole",CourseDepartment.class)
            .include("courseSchool",CourseDepartment.class)
            .include("schoolFromInstitutionalCode",CourseDepartmentImpl.class)

            .include("id",CourseSchool.class)

            .create();

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


}