Subversion Repositories bacoAlunos

Rev

Rev 973 | Rev 996 | 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()) &&
100
                   anCourseUnit.getImportYear() != null && getImportYear() != null && getImportYear().equals(anCourseUnit.getImportYear());
101
        }
102
        return false;
103
 
104
    }
489 jmachado 105
 
973 jmachado 106
    /**
107
     * Means that is teacher os responsable teacher or from course commission
108
     * Only works in open transaction
109
     *
110
     * Needs Course and Responsable Teacher loaded
111
     */
112
    public boolean isFromCourseUnitCommission(UserSession userSession)
113
    {
114
        return userSession.getUser()!= null &&
115
                (((UserImpl) userSession.getUser()).isTeacherOfCourseUnit(getId(), true)
116
                        || (getResponsableTeacher() != null && getResponsableTeacher().getId() == userSession.getUser().getId())
117
                        || userSession.getUser().hasRole(getCourse().getValidationRole())
118
                );
119
    }
489 jmachado 120
 
973 jmachado 121
 
995 jmachado 122
    public 1.5.0/docs/api/java/lang/String.html">String getSummariosPathIntranet()
123
    {
124
        return Globals.FTP_IONLINE_START_PATH + "/" + getPathIntranet() + "/" + Globals.INTRANET_DTP + "/" + Globals.INTRANET_DTP_Sumarios;
125
    }
973 jmachado 126
 
995 jmachado 127
    public 1.5.0/docs/api/java/lang/String.html">String getSummariosPathFileIntranet()
128
    {
129
        return getSummariosPathIntranet() + "/" + getSummariosFileNameIntranet();
130
    }
131
 
132
    public 1.5.0/docs/api/java/lang/String.html">String getSummariosFileNameIntranet(){
133
        return getCode() + "_" + getNormalizedName() + "_sumarios.pdf";
134
    }
135
 
136
 
489 jmachado 137
 
112 jmachado 138
}