Subversion Repositories bacoAlunos

Rev

Rev 1139 | Rev 1161 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
112 jmachado 1
package pt.estgp.estgweb.domain;
2
 
995 jmachado 3
import pt.estgp.estgweb.Globals;
489 jmachado 4
import pt.estgp.estgweb.domain.enums.CourseUnitContentsGrants;
5
 
146 jmachado 6
import java.io.Serializable;
204 jmachado 7
import java.util.List;
146 jmachado 8
 
112 jmachado 9
/**
10
 * Created by IntelliJ IDEA.
11
 * User: Jorge Machado
12
 * Date: 7/Mai/2008
13
 * Time: 20:21:15
14
 * To change this template use File | Settings | File Templates.
15
 */
204 jmachado 16
public class CourseUnitImpl extends CourseUnit implements ICanManage
146 jmachado 17
{
489 jmachado 18
 
19
    CourseUnitContentsGrants courseUnitContentsGrants = null;
20
 
146 jmachado 21
    public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable()
22
    {
23
        return getId();
24
    }
204 jmachado 25
 
489 jmachado 26
 
27
    public CourseUnitContentsGrants getCourseUnitContentsGrants() {
28
        if(courseUnitContentsGrants == null)
29
            courseUnitContentsGrants = CourseUnitContentsGrants.parse(super.getContentsGrants());
30
        return courseUnitContentsGrants;
31
    }
32
 
33
    public void setCourseUnitContentsGrants(CourseUnitContentsGrants courseUnitContentsGrants) {
34
        super.setContentsGrants(courseUnitContentsGrants.name());
35
        this.courseUnitContentsGrants = courseUnitContentsGrants;
36
    }
37
 
204 jmachado 38
    public boolean isValid()
39
    {
40
        return true;  //To change body of implemented methods use File | Settings | File Templates.
41
    }
42
 
43
    public boolean isOwnedBy(GenericUser u)
44
    {
208 jmachado 45
        return isOwnedBy(u, false);
204 jmachado 46
    }
47
 
208 jmachado 48
    public boolean isOwnedBy(GenericUser u, boolean transaction)
49
    {
50
        return u != null && u instanceof TeacherImpl && ((TeacherImpl)u).hasCourseUnit(getId(),transaction);
51
    }
52
 
204 jmachado 53
    /**
54
     * Not implemented can be variuous teachers
55
     * @return null
56
     * use isOwnedBy in this class
57
     */
58
    public GenericUser getOwner()
59
    {
60
        return null;
61
    }
62
    /**
63
     * Not implemented
64
     * @return
65
     */
66
    public List<String> getOwnerRoles()
67
    {
68
        return null;
69
    }
70
 
71
    /**
72
     * Not implemented
73
     * @return
74
     */
75
    public 1.5.0/docs/api/java/lang/String.html">String getChoosedOwnerRole()
76
    {
77
        return null;
78
    }
79
 
80
    public boolean isInternal()
81
    {
251 jmachado 82
        return true;
204 jmachado 83
    }
208 jmachado 84
 
85
    public CourseUnitBlogImpl getUnitBlog()
86
    {
87
        if(getBlogs()!=null && getBlogs().size() > 0)
88
            return (CourseUnitBlogImpl) getBlogs().iterator().next();
89
        return null;
90
    }
251 jmachado 91
 
92
    public boolean equals(5+0%2Fdocs%2Fapi+Object">Object anotherInstance)
93
    {
94
        if(anotherInstance instanceof CourseUnitImpl)
95
        {
96
            CourseUnitImpl anCourseUnit = (CourseUnitImpl) anotherInstance;
97
            return anCourseUnit.getCode() != null && getCode() != null && getCode().equals(anCourseUnit.getCode()) &&
98
                   anCourseUnit.getCourseCode() != null && getCourseCode() != null && getCourseCode().equals(anCourseUnit.getCourseCode()) &&
99
                   anCourseUnit.getSemestre() != null && getSemestre() != null && getSemestre().equals(anCourseUnit.getSemestre()) &&
1120 jmachado 100
                   anCourseUnit.getImportYear() != null && getImportYear() != null && getImportYear().equals(anCourseUnit.getImportYear()) &&
101
                   anCourseUnit.getCdTurma() != null && getCdTurma() != null && getCdTurma().equals(anCourseUnit.getCdTurma());
251 jmachado 102
        }
103
        return false;
104
 
105
    }
489 jmachado 106
 
973 jmachado 107
    /**
108
     * Means that is teacher os responsable teacher or from course commission
109
     * Only works in open transaction
110
     *
111
     * Needs Course and Responsable Teacher loaded
112
     */
113
    public boolean isFromCourseUnitCommission(UserSession userSession)
114
    {
115
        return userSession.getUser()!= null &&
116
                (((UserImpl) userSession.getUser()).isTeacherOfCourseUnit(getId(), true)
117
                        || (getResponsableTeacher() != null && getResponsableTeacher().getId() == userSession.getUser().getId())
118
                        || userSession.getUser().hasRole(getCourse().getValidationRole())
119
                );
120
    }
489 jmachado 121
 
973 jmachado 122
 
995 jmachado 123
    public 1.5.0/docs/api/java/lang/String.html">String getSummariosPathIntranet()
124
    {
125
        return Globals.FTP_IONLINE_START_PATH + "/" + getPathIntranet() + "/" + Globals.INTRANET_DTP + "/" + Globals.INTRANET_DTP_Sumarios;
126
    }
973 jmachado 127
 
1148 jmachado 128
    public 1.5.0/docs/api/java/lang/String.html">String getInqueritosPedagogicosPathIntranet()
129
    {
130
        return Globals.FTP_IONLINE_START_PATH + getPathIntranet() + "/" + Globals.INTRANET_DTP + "/" + Globals.INTRANET_DTP_InqueritoPedagogico;
131
    }
132
 
133
 
995 jmachado 134
    public 1.5.0/docs/api/java/lang/String.html">String getSummariosPathFileIntranet()
135
    {
136
        return getSummariosPathIntranet() + "/" + getSummariosFileNameIntranet();
137
    }
138
 
139
    public 1.5.0/docs/api/java/lang/String.html">String getSummariosFileNameIntranet(){
140
        return getCode() + "_" + getNormalizedName() + "_sumarios.pdf";
141
    }
142
 
143
 
996 jmachado 144
    public 1.5.0/docs/api/java/lang/String.html">String getSigesUniqueIdentifiers()
145
    {
146
        return "SIGES:" + getCode() + ", COURSE: " + getCourseCode() +
1139 jmachado 147
                ", " + getSemestre() + " of " + getImportYear() + " - " + getName() + " Turma - " + getCdTurma();
996 jmachado 148
    }
149
 
489 jmachado 150
 
112 jmachado 151
}