package pt.estgp.estgweb.domain;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.enums.CourseUnitContentsGrants;
import java.io.Serializable;
import java.util.List;
/**
* Created by IntelliJ IDEA.
* User: Jorge Machado
* Date: 7/Mai/2008
* Time: 20:21:15
* To change this template use File | Settings | File Templates.
*/
public class CourseUnitImpl
extends CourseUnit
implements ICanManage
{
CourseUnitContentsGrants courseUnitContentsGrants =
null;
public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable
()
{
return getId
();
}
public CourseUnitContentsGrants getCourseUnitContentsGrants
() {
if(courseUnitContentsGrants ==
null)
courseUnitContentsGrants = CourseUnitContentsGrants.
parse(super.
getContentsGrants());
return courseUnitContentsGrants
;
}
public void setCourseUnitContentsGrants
(CourseUnitContentsGrants courseUnitContentsGrants
) {
super.
setContentsGrants(courseUnitContentsGrants.
name());
this.
courseUnitContentsGrants = courseUnitContentsGrants
;
}
public boolean isValid
()
{
return true; //To change body of implemented methods use File | Settings | File Templates.
}
public boolean isOwnedBy
(GenericUser u
)
{
return isOwnedBy
(u,
false);
}
public boolean isOwnedBy
(GenericUser u,
boolean transaction
)
{
return u
!=
null && u
instanceof TeacherImpl
&& ((TeacherImpl
)u
).
hasCourseUnit(getId
(),transaction
);
}
/**
* Not implemented can be variuous teachers
* @return null
* use isOwnedBy in this class
*/
public GenericUser getOwner
()
{
return null;
}
/**
* Not implemented
* @return
*/
public List
<String
> getOwnerRoles
()
{
return null;
}
/**
* Not implemented
* @return
*/
public 1.5.0/docs/api/java/lang/String.html">String getChoosedOwnerRole
()
{
return null;
}
public boolean isInternal
()
{
return true;
}
public CourseUnitBlogImpl getUnitBlog
()
{
if(getBlogs
()!=
null && getBlogs
().
size() > 0
)
return (CourseUnitBlogImpl
) getBlogs
().
iterator().
next();
return null;
}
public boolean equals
(5+0%2Fdocs%2Fapi+Object">Object anotherInstance
)
{
if(anotherInstance
instanceof CourseUnitImpl
)
{
CourseUnitImpl anCourseUnit =
(CourseUnitImpl
) anotherInstance
;
return anCourseUnit.
getCode() !=
null && getCode
() !=
null && getCode
().
equals(anCourseUnit.
getCode()) &&
anCourseUnit.
getCourseCode() !=
null && getCourseCode
() !=
null && getCourseCode
().
equals(anCourseUnit.
getCourseCode()) &&
anCourseUnit.
getSemestre() !=
null && getSemestre
() !=
null && getSemestre
().
equals(anCourseUnit.
getSemestre()) &&
anCourseUnit.
getImportYear() !=
null && getImportYear
() !=
null && getImportYear
().
equals(anCourseUnit.
getImportYear()) &&
anCourseUnit.
getCdTurma() !=
null && getCdTurma
() !=
null && getCdTurma
().
equals(anCourseUnit.
getCdTurma());
}
return false;
}
/**
* Means that is teacher os responsable teacher or from course commission
* Only works in open transaction
*
* Needs Course and Responsable Teacher loaded
*/
public boolean isFromCourseUnitCommission
(UserSession userSession
)
{
return userSession.
getUser()!=
null &&
(((UserImpl
) userSession.
getUser()).
isTeacherOfCourseUnit(getId
(),
true)
||
(getResponsableTeacher
() !=
null && getResponsableTeacher
().
getId() == userSession.
getUser().
getId())
|| userSession.
getUser().
hasRole(getCourse
().
getValidationRole())
);
}
public 1.5.0/docs/api/java/lang/String.html">String getSummariosPathIntranet
()
{
return Globals.
FTP_IONLINE_START_PATH +
"/" + getPathIntranet
() +
"/" + Globals.
INTRANET_DTP +
"/" + Globals.
INTRANET_DTP_Sumarios;
}
public 1.5.0/docs/api/java/lang/String.html">String getSummariosPathFileIntranet
()
{
return getSummariosPathIntranet
() +
"/" + getSummariosFileNameIntranet
();
}
public 1.5.0/docs/api/java/lang/String.html">String getSummariosFileNameIntranet
(){
return getCode
() +
"_" + getNormalizedName
() +
"_sumarios.pdf";
}
public 1.5.0/docs/api/java/lang/String.html">String getSigesUniqueIdentifiers
()
{
return "SIGES:" + getCode
() +
", COURSE: " + getCourseCode
() +
", " + getSemestre
() +
" of " + getImportYear
() +
" - " + getName
();
}
}