Class OdfPageResolver
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.odfweb.repository.OdfPageResolver
- All Implemented Interfaces:
LogEnabled
,Initializable
,Component
,Serviceable
public class OdfPageResolver
extends AbstractLogEnabled
implements Component, Serviceable, Initializable
Resolves an ODF page path from the associated ODF content.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AmetysObjectResolver
The ametys object resolver.protected AbstractCacheManager
The cache managerprotected CoursePageFactory
The course page factoryprotected ODFHelper
ODF helperprotected OdfPageHandler
The odf page handlerprotected ProgramPageFactory
The program page factorystatic final String
The avalon role. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetCoursePage
(Course course, Course parentCourse, String siteName) Return the course pagegetCoursePage
(Course course, AbstractProgram parentProgram, String siteName) Return the course pagegetCoursePage
(Page odfRootPage, Course course, List<String> path) Returns the course page in given ODF root page,getCoursePage
(Page odfRootPage, Course course, List<String> path, boolean checkHierarchy) Returns the course page in given ODF root page,getCoursePage
(Page odfRootPage, Course course, Course parentCourse) Return the course pagegetCoursePage
(Page odfRootPage, Course course, AbstractProgram parentAbstractProgram) Return the course pagegetNearestAncestorAbstractProgram
(ProgramItem programItem, AbstractProgram parentProgram) Returns the nearestAbstractProgram
ancestor.getNearestAncestorAbstractPrograms
(ProgramPart programPart) Returns the nearestAbstractProgram
ancestors.getNearestAncestorCourse
(Course course, AbstractProgram parentProgram) Returns the nearestCourse
ancestor.getOdfRootPage
(String siteName, String language, String catalog) Get the ODF root page, either in the given site if it exists, or in the default ODF site.getPathInProgram
(ProgramItem programItem, AbstractProgram parentProgram) Get the path in sitemap of a ODF content into aProgram
orSubProgram
Be careful, this is the path in sitemap, to get the path of a item into a Program, useODFHelper.getPathInProgram(java.lang.String, java.lang.String)
instead.getProgramItemPagePath
(String siteName, String language, ProgramItem programItem, Program parentProgram) Get the path of aProgramItem
page into the givenProgram
getProgramPage
(Program program) Return the program pagegetProgramPage
(Program program, String siteName) Return the program pagegetProgramPage
(Page odfRootPage, Program program) Return the program pagegetProgramPagePath
(String siteName, String language, Program program) Get the path of a Program page from the Program content.getReferencingPages
(ProgramItem programItem) Get all referencing pages for this program item, in all sites and all sitemapsgetReferencingPages
(ProgramItem programItem, String siteName, String lang) Get all referencing pages for this program itemgetRootProgram
(Page odfRootPage, ProgramItem programItem, AbstractProgram parentAbstractProgram) Returns the firstProgram
ancestor matching an existingProgramPage
in given ODF root page, ensuring that the given parent content 'parentProgram' is in the hierarchy (if not null)
If 'parentProgram' is null, the firstProgram
ancestor will be returned regardless of parent hierarchy.
If 'parentProgram' is aSubProgram
, the firstProgram
ancestor from thisSubProgram
will be returned regardless of parent hierarchygetSubProgramPage
(SubProgram subProgram, AbstractProgram parentProgram, String siteName) Return the subprogram pagegetSubProgramPage
(Page odfRootPage, SubProgram subProgram, List<String> path, boolean checkHierarchy) Returns the subprogram pagegetSubProgramPage
(Page odfRootPage, SubProgram subProgram, AbstractProgram parentAbstractProgram) Return the subprogram pagevoid
boolean
isProgramPageExist
(Page odfRootPage, Program program) Determines if a program page existsvoid
service
(ServiceManager serviceManager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The avalon role. -
_ametysResolver
The ametys object resolver. -
_odfPageHandler
The odf page handler -
_odfHelper
ODF helper -
_cacheManager
The cache manager -
_coursePageFactory
The course page factory -
_programPageFactory
The program page factory
-
-
Constructor Details
-
OdfPageResolver
public OdfPageResolver()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
getReferencingPages
Get all referencing pages for this program item, in all sites and all sitemaps- Parameters:
programItem
- The program item- Returns:
- the referencing pages
-
getReferencingPages
Get all referencing pages for this program item- Parameters:
programItem
- The program itemsiteName
- The site name. Can be null to search on all siteslang
- The sitemap language. Can be null to search on all sitemaps- Returns:
- the referencing pages
-
getProgramPage
Return the program page- Parameters:
program
- the program- Returns:
- the page program or null
-
getProgramPage
Return the program page- Parameters:
program
- the programsiteName
- The current site name. If the no ODF root page is present in this site, the default ODF site will be used instead.- Returns:
- the page program or null
-
getProgramPage
Return the program page- Parameters:
odfRootPage
- the odf root pageprogram
- the program- Returns:
- the page program or null
-
getSubProgramPage
public ProgramPage getSubProgramPage(SubProgram subProgram, AbstractProgram parentProgram, String siteName) Return the subprogram page- Parameters:
subProgram
- the subprogramparentProgram
- The parent programsiteName
- The current site name. If the no ODF root page is present in this site, the default ODF site will be used instead.- Returns:
- the subprogram page or null
-
getSubProgramPage
public ProgramPage getSubProgramPage(Page odfRootPage, SubProgram subProgram, AbstractProgram parentAbstractProgram) Return the subprogram page- Parameters:
odfRootPage
- the odf root pagesubProgram
- the subprogramparentAbstractProgram
- The parent program or subprogram- Returns:
- the subprogram page or null
-
getSubProgramPage
public ProgramPage getSubProgramPage(Page odfRootPage, SubProgram subProgram, List<String> path, boolean checkHierarchy) Returns the subprogram page- Parameters:
odfRootPage
- the odf root pagesubProgram
- the subprogrampath
- a full or partial path of subprogramcheckHierarchy
- set to true to check that the given path is a valid hierarchy- Returns:
- the subprogram page or null if not found
-
getCoursePage
Return the course page- Parameters:
course
- the courseparentProgram
- the parent program or subprogram. Can be null.siteName
- The current site name. If the no ODF root page is present in this site, the default ODF site will be used instead.- Returns:
- the course page or null if not found
-
getCoursePage
public CoursePage getCoursePage(Page odfRootPage, Course course, AbstractProgram parentAbstractProgram) Return the course page- Parameters:
odfRootPage
- the odf root pagecourse
- the courseparentAbstractProgram
- the parent program or subprogram. Can be null.- Returns:
- the course page or null if not found
-
getCoursePage
Return the course page- Parameters:
course
- the courseparentCourse
- the parent course. Can NOT be null.siteName
- The current site name. If the no ODF root page is present in this site, the default ODF site will be used instead.- Returns:
- the course page or null if not found
-
getCoursePage
Return the course page- Parameters:
odfRootPage
- the odf root pagecourse
- the courseparentCourse
- the parent course. Can NOT be null.- Returns:
- the course page or null if not found
-
getCoursePage
Returns the course page in given ODF root page,- Parameters:
odfRootPage
- the odf root pagecourse
- the coursepath
- a (partial) education path or a (partial) sitemap path. Be careful, assume that the given path correspond to a valid path in ODF root. UsegetCoursePage(Page, Course, List, boolean)
with true if not sure.- Returns:
- the course page or null if not found
-
getCoursePage
public CoursePage getCoursePage(Page odfRootPage, Course course, List<String> path, boolean checkHierarchy) Returns the course page in given ODF root page,- Parameters:
odfRootPage
- the odf root pagecourse
- the coursepath
- a (partial) education path or a (partial) sitemap pathcheckHierarchy
- set to true to check that the given path correspond to a valid hierarchy- Returns:
- the course page or null if not found
-
isProgramPageExist
Determines if a program page exists- Parameters:
odfRootPage
- the ODF root pageprogram
- the program page- Returns:
- true if program page existes, false otherwise
-
getOdfRootPage
Get the ODF root page, either in the given site if it exists, or in the default ODF site.- Parameters:
siteName
- the desired site name.language
- the sitemap language to search in.catalog
- The ODF catalog- Returns:
- the ODF root page, either in the given site if it exists, or in the default ODF site.
-
getPathInProgram
Get the path in sitemap of a ODF content into aProgram
orSubProgram
Be careful, this is the path in sitemap, to get the path of a item into a Program, useODFHelper.getPathInProgram(java.lang.String, java.lang.String)
instead.- Parameters:
programItem
- The program itemparentProgram
- The parent root (sub)program. Can be null.- Returns:
- the path in sitemap from the parent program or null if no found ODF path for those program item and parent program
-
getRootProgram
public Program getRootProgram(Page odfRootPage, ProgramItem programItem, AbstractProgram parentAbstractProgram) Returns the firstProgram
ancestor matching an existingProgramPage
in given ODF root page, ensuring that the given parent content 'parentProgram' is in the hierarchy (if not null)
If 'parentProgram' is null, the firstProgram
ancestor will be returned regardless of parent hierarchy.
If 'parentProgram' is aSubProgram
, the firstProgram
ancestor from thisSubProgram
will be returned regardless of parent hierarchy- Parameters:
odfRootPage
- The ODf root page. Cannot be null.programItem
- aProgramItem
parentAbstractProgram
- The parent program or subprogram. Can be null.- Returns:
- the parent
Program
into this (sub)program that matchs an existing program page, or null if not found
-
getNearestAncestorAbstractPrograms
Returns the nearestAbstractProgram
ancestors.- Parameters:
programPart
- aProgramPart
- Returns:
- the nearest
AbstractProgram
ancestors containing this program part
-
getNearestAncestorAbstractProgram
public AbstractProgram getNearestAncestorAbstractProgram(ProgramItem programItem, AbstractProgram parentProgram) Returns the nearestAbstractProgram
ancestor.- Parameters:
programItem
- aProgramItem
parentProgram
- The parent program or subprogram- Returns:
- the nearest
AbstractProgram
ancestor into this (sub)program or null if not found
-
getNearestAncestorCourse
Returns the nearestCourse
ancestor. -
getProgramPagePath
Get the path of a Program page from the Program content.- Parameters:
siteName
- the site name.language
- the language.program
- the program.- Returns:
- the page path or empty if no page matches
-
getProgramItemPagePath
public String getProgramItemPagePath(String siteName, String language, ProgramItem programItem, Program parentProgram) Get the path of aProgramItem
page into the givenProgram
- Parameters:
siteName
- the site namelanguage
- the languageprogramItem
- the subprogram.parentProgram
- The parent program- Returns:
- the page path or empty if no page matches
-