Skip to content

Instantly share code, notes, and snippets.

@jcarvalho
Last active August 29, 2015 14:00
Show Gist options
  • Save jcarvalho/0c16a878255a7afe6971 to your computer and use it in GitHub Desktop.
Save jcarvalho/0c16a878255a7afe6971 to your computer and use it in GitHub Desktop.
package pt.ist.fenix;
import java.util.Locale;
import net.sourceforge.fenixedu.domain.cms.AssemblySiteController;
import net.sourceforge.fenixedu.domain.cms.DegreeSiteController;
import net.sourceforge.fenixedu.domain.cms.DepartmentSiteController;
import net.sourceforge.fenixedu.domain.cms.ExecutionCourseController;
import net.sourceforge.fenixedu.domain.cms.HomepageController;
import net.sourceforge.fenixedu.domain.cms.ManagementCouncilSiteController;
import net.sourceforge.fenixedu.domain.cms.OldCmsPortalBackend;
import net.sourceforge.fenixedu.domain.cms.PedagogicalCouncilSiteController;
import net.sourceforge.fenixedu.domain.cms.ResearchUnitSiteController;
import net.sourceforge.fenixedu.domain.cms.ScientificAreaUnitSiteController;
import net.sourceforge.fenixedu.domain.cms.ScientificCouncilSiteController;
import net.sourceforge.fenixedu.domain.cms.SiteTemplate;
import net.sourceforge.fenixedu.domain.cms.SiteTemplateController;
import net.sourceforge.fenixedu.domain.cms.StudentSiteController;
import net.sourceforge.fenixedu.domain.cms.TemplatedSection;
import net.sourceforge.fenixedu.domain.cms.ThesisSiteController;
import net.sourceforge.fenixedu.domain.cms.TutorUnitSiteProcessor;
import net.sourceforge.fenixedu.domain.cms.UnitSiteController;
import org.fenixedu.bennu.portal.domain.MenuFunctionality;
import org.fenixedu.bennu.portal.domain.PortalConfiguration;
import org.fenixedu.bennu.scheduler.custom.CustomTask;
import org.fenixedu.commons.i18n.LocalizedString;
import pt.utl.ist.fenix.tools.util.i18n.MultiLanguageString;
public class CreateSiteTemplates extends CustomTask {
@Override
public void runTask() throws Exception {
departamentos();
homepage();
cursos();
disciplinas();
pedagogicalCouncil();
cientificCouncil();
thesisSite();
assemblySite();
studentsSite();
tutorSite();
researchUnitSite();
scientificAreaSite();
managementCouncil();
units();
}
private void scientificAreaSite() {
SiteTemplate template =
createTemplated(new ScientificAreaUnitSiteController(), "areacientifica", "Area Cientifica", "Scientific Area");
new TemplatedSection(template, makeMLS("Início", "Home"), "/publico/scientificArea/viewSite.do?method=presentation", true);
new TemplatedSection(template, makeMLS("Disciplinas", "Courses"),
"/publico/scientificArea/viewSite.do?method=viewCourses", false);
new TemplatedSection(template, makeMLS("Funcionários", "Employees"),
"/publico/scientificArea/viewSite.do?method=viewEmployees", false);
new TemplatedSection(template, makeMLS("Docentes", "Teachers"),
"/publico/scientificArea/viewSite.do?method=viewTeachers", false);
new TemplatedSection(template, makeMLS("SubUnidades", "SubUnits"), "/publico/scientificArea/viewSite.do?method=subunits",
false);
new TemplatedSection(template, makeMLS("Organização", "Organization"),
"/publico/scientificArea/viewSite.do?method=organization", false);
new TemplatedSection(template, makeMLS("Anúncios", "Announcements"),
"/publico/scientificArea/announcements.do?method=viewAnnouncements", false);
new TemplatedSection(template, makeMLS("Eventos", "Events"),
"/publico/scientificArea/events.do?method=viewAnnouncements", false);
new TemplatedSection(template, makeMLS("Publicações", "Publications"),
"/publico/scientificArea/viewSiteResearch.do?method=showPublications", false);
}
private void researchUnitSite() {
SiteTemplate template = createTemplated(new ResearchUnitSiteController(), "investigacao", "Investigação", "Research");
new TemplatedSection(template, makeMLS("Início", "Home"),
"/publico/researchSite/viewResearchUnitSite.do?method=presentation", true);
new TemplatedSection(template, makeMLS("Subunidades", "Subunits"),
"/publico/researchSite/viewResearchUnitSite.do?method=subunits", false);
new TemplatedSection(template, makeMLS("Estrutura", "Organization"),
"/publico/researchSite/viewResearchUnitSite.do?method=organization", false);
new TemplatedSection(template, makeMLS("Publicações", "Publications"),
"/publico/researchSite/viewResearchUnitSiteResearch.do?method=showPublications", false);
new TemplatedSection(template, makeMLS("Membros", "Researchers"),
"/publico/researchSite/viewResearchUnitSite.do?method=showResearchers", false);
new TemplatedSection(template, makeMLS("Eventos", "Events"),
"/publico/researchSite/manageResearchUnitAnnouncements.do?method=viewEvents", false);
}
private void tutorSite() {
SiteTemplate template = createTemplated(new TutorUnitSiteProcessor(), "tutorado", "Tutorado", "Tutor");
new TemplatedSection(template, makeMLS("Início", "Home"), "/publico/units/viewSite.do?method=presentation", true);
}
private void studentsSite() {
SiteTemplate template = createTemplated(new StudentSiteController(), "alunos-cd", "Alunos", "Students");
new TemplatedSection(template, makeMLS("Início", "Home"), "/publico/units/viewSite.do?method=presentation", true);
}
private void assemblySite() {
SiteTemplate template = createTemplated(new AssemblySiteController(), "aestatutaria", "Aestatutaria", "Assembly");
new TemplatedSection(template, makeMLS("Início", "Home"), "/publico/units/viewSite.do?method=presentation", true);
}
private void thesisSite() {
SiteTemplate template = createTemplated(new ThesisSiteController(), "dissertacoes", "Dissertacoes", "Theses");
new TemplatedSection(template, makeMLS("Dissertacao", "Thesis"), "/publico/theses/thesis.do", true);
}
private void cientificCouncil() {
SiteTemplate template =
createTemplated(new ScientificCouncilSiteController(), "conselhocientifico", "Conselho Científico",
"Cientific Council");
new TemplatedSection(template, makeMLS("Início", "Home"), "/publico/scientificCouncil/viewSite.do?method=presentation",
true);
new TemplatedSection(template, makeMLS("Estrutura", "Structure"),
"/publico/scientificCouncil/viewSite.do?method=organization", false);
}
public void pedagogicalCouncil() {
SiteTemplate template =
createTemplated(new PedagogicalCouncilSiteController(), "conselhopedagogico", "Conselho Pedagógico",
"Pedagogical Council");
new TemplatedSection(template, makeMLS("Início", "Home"), "/publico/pedagogicalCouncil/viewSite.do?method=presentation",
true);
}
public void managementCouncil() {
SiteTemplate template =
createTemplated(new ManagementCouncilSiteController(), "cg", "Conselho de Gestão", "Management Council");
new TemplatedSection(template, makeMLS("Início", "Home"), "/publico/units/viewSite.do?method=presentation", true);
}
public void departamentos() {
SiteTemplate template = createTemplated(new DepartmentSiteController(), "departamentos", "Departamentos", "Departments");
new TemplatedSection(template, makeMLS("Início", "Home"), "/publico/department/departmentSite.do?method=presentation",
true);
new TemplatedSection(template, makeMLS("Anúncios", "Announcements"),
"/publico/department/announcements.do?method=viewAnnouncements", false);
new TemplatedSection(template, makeMLS("Eventos", "Events"), "/publico/department/events.do?method=viewAnnouncements",
false);
new TemplatedSection(template, makeMLS("Docentes", "Faculty"), "/publico/department/teachers.do", false);
new TemplatedSection(template, makeMLS("Funcionários", "Staff"), "/publico/department/departmentEmployees.do", false);
new TemplatedSection(template, makeMLS("Disciplinas", "Courses"),
"/publico/department/showDepartmentCompetenceCourses.faces", false);
new TemplatedSection(template, makeMLS("Cursos", "Degrees"), "/publico/department/degrees.do", false);
new TemplatedSection(template, makeMLS("Estrutura", "Organization"),
"/publico/department/departmentSite.do?method=organization", false);
new TemplatedSection(template, makeMLS("Áreas Científicas", "Scientific Areas"),
"/publico/department/departmentSite.do?method=subunits", false);
new TemplatedSection(template, makeMLS("Dissertações", "Dissertations"),
"/publico/department/theses.do?method=showTheses", false);
new TemplatedSection(template, makeMLS("Publicações", "Publications"),
"/publico/department/departmentSiteResearch.do?method=showPublications", false);
}
public void homepage() {
SiteTemplate template = createTemplated(new HomepageController(), "homepage", "Homepage", "Homepage");
new TemplatedSection(template, makeMLS("Apresentação", "Presentation"), "/publico/viewHomepage.do?method=show", true);
new TemplatedSection(template, makeMLS("Interesses Científicos", "Research Interests"),
"/publico/viewHomepageResearch.do?method=showInterests", false);
new TemplatedSection(template, makeMLS("Publicações", "Publications"),
"/publico/viewHomepageResearch.do?method=showPublications", false);
new TemplatedSection(template, makeMLS("Patentes", "Patents"), "/publico/viewHomepageResearch.do?method=showPatents",
false);
new TemplatedSection(template, makeMLS("Actividades Científicas", "Scientifical Activities"),
"/publico/viewHomepageResearch.do?method=showParticipations", false);
new TemplatedSection(template, makeMLS("Prémios", "Prizes"), "/publico/viewHomepageResearch.do?method=showPrizes", false);
}
public void cursos() {
SiteTemplate template = createTemplated(new DegreeSiteController(), "cursos", "Cursos", "Degrees");
new TemplatedSection(template, makeMLS("Descrição", "Description"), "/publico/showDegreeSite.do?method=showDescription",
true);
new TemplatedSection(template, makeMLS("Regime de Acesso", "Admission Requirements"),
"/publico/showDegreeSite.do?method=showAccessRequirements", true);
new TemplatedSection(template, makeMLS("Estatuto Profissional", "Professional Status"),
"/publico/showDegreeSite.do?method=showProfessionalStatus", true);
new TemplatedSection(template, makeMLS("Plano Curricular", "Curricular Plan"),
"/publico/showDegreeSite.do?method=showCurricularPlan", true);
new TemplatedSection(template, makeMLS("Páginas de Disciplinas", "Course Web Pages"),
"/publico/showExecutionCourseSites.do?method=listSites&showTwoSemesters=true", true);
new TemplatedSection(template, makeMLS("Horários por Turma", "Class timetable"),
"/publico/showClasses.do?method=listClasses", true);
new TemplatedSection(template, makeMLS("Avaliações", "Evaluations"), "/publico/degreeSite/publicEvaluations.faces", true);
new TemplatedSection(template, makeMLS("Dissertações", "Dissertations"),
"/publico/showDegreeTheses.do?method=showTheses", true);
}
public void disciplinas() {
SiteTemplate template = createTemplated(new ExecutionCourseController(), "disciplinas", "Disciplinas", "Courses");
new TemplatedSection(template, makeMLS("Página Inicial", "Initial Page"), "/publico/executionCourse.do?method=firstPage",
true);
new TemplatedSection(template, makeMLS("Agrupamentos", "Groups"), "/publico/executionCourse.do?method=groupings", true);
new TemplatedSection(template, makeMLS("Anúncios", "Announcements"), "/publico/announcementManagement.do?method=start",
true);
new TemplatedSection(template, makeMLS("Avaliação", "Evaluation"), "/publico/executionCourse.do?method=evaluations", true);
new TemplatedSection(template, makeMLS("Bibliografia", "Bibliography"),
"/publico/executionCourse.do?method=bibliographicReference", true);
new TemplatedSection(template, makeMLS("Horário", "Timesheet"), "/publico/executionCourse.do?method=schedule", true);
new TemplatedSection(template, makeMLS("Método de Avaliação", "Evaluation Method"),
"/publico/executionCourse.do?method=evaluationMethod", true);
new TemplatedSection(template, makeMLS("Objectivos", "Objectives"), "/publico/executionCourse.do?method=objectives", true);
new TemplatedSection(template, makeMLS("Pesquisa de Conteúdos", "Search Contents"),
"/publico/searchFileContent.do?method=prepareSearchForExecutionCourse", true);
new TemplatedSection(template, makeMLS("Planeamento", "Planning"), "/publico/executionCourse.do?method=lessonPlannings",
true);
new TemplatedSection(template, makeMLS("Programa", "Program"), "/publico/executionCourse.do?method=program", true);
new TemplatedSection(template, makeMLS("Resultados QUC", "Inquiries Results"),
"/publico/executionCourse.do?method=studentInquiriesResults", true);
new TemplatedSection(template, makeMLS("Sumários", "Summaries"), "/publico/executionCourse.do?method=summaries", true);
new TemplatedSection(template, makeMLS("Turnos", "Shifts"), "/publico/executionCourse.do?method=shifts", true);
}
public void units() {
SiteTemplate template = createTemplated(new UnitSiteController(), "units", "Unidades", "Units");
new TemplatedSection(template, makeMLS("Início", "Home"), "/publico/units/viewSite.do?method=presentation", true);
}
@SuppressWarnings("deprecation")
private MultiLanguageString makeMLS(String pt, String en) {
return new MultiLanguageString(PT, pt).with(EN, en);
}
private static final Locale PT = new Locale.Builder().setLanguageTag("pt-PT").build();
private static final Locale EN = new Locale.Builder().setLanguageTag("en-GB").build();
private SiteTemplate createTemplated(SiteTemplateController controller, String path, String namePt, String nameEn) {
SiteTemplate template = new SiteTemplate(controller);
LocalizedString str = new LocalizedString(PT, namePt).with(EN, nameEn);
MenuFunctionality functionality =
new MenuFunctionality(PortalConfiguration.getInstance().getMenu(), false, path, OldCmsPortalBackend.BACKEND_KEY,
"anyone", str, str, path);
template.setFunctionality(functionality);
return template;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment