Class ODFHelper

All Implemented Interfaces:
LogEnabled, PluginAware, Initializable, Component, Contextualizable, Serviceable

Helper for ODF contents
  • Field Details

  • Constructor Details

  • Method Details

    • contextualize

      public void contextualize(Context context) throws ContextException
      Specified by:
      contextualize in interface Contextualizable
      Throws:
      ContextException
    • service

      public void service(ServiceManager manager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • setPluginInfo

      public void setPluginInfo(String pluginName, String featureName, String id)
      Description copied from interface: PluginAware
      Sets the plugin info relative to the current component.
      Note : The feature name may be null if the targeted component in declared at plugin level.
      Specified by:
      setPluginInfo in interface PluginAware
      Parameters:
      pluginName - Unique identifier for the plugin hosting the extension
      featureName - Unique feature identifier (unique for a given pluginName)
      id - Unique identifier of this component
    • initialize

      public void initialize() throws Exception
      Specified by:
      initialize in interface Initializable
      Throws:
      Exception
    • getRootContent

      Gets the root for ODF contents
      Returns:
      the root for ODF contents
    • getRootContent

      public AmetysObjectCollection getRootContent(boolean create)
      Gets the root for ODF contents
      Parameters:
      create - true to create automatically the root when missing.
      Returns:
      the root for ODF contents
    • getProgramItems

      public <C extends Content> AmetysObjectIterable<C> getProgramItems(String cTypeId, String code, String catalogName, String lang)
      Get the ProgramItems matching the given arguments
      Type Parameters:
      C - The content return type
      Parameters:
      cTypeId - The id of content type. Can be null to get program's items whatever their content type.
      code - The code. Can be null to get program's items regardless of their code
      catalogName - The search catalog. Can be null to get program's items regardless the catalog they belong to.
      lang - The search language. Can be null to get program's items regardless of their language
      Returns:
      The matching program items
    • getProgramItems

      public <C extends Content> AmetysObjectIterable<C> getProgramItems(Collection<String> cTypeIds, String code, String catalogName, String lang)
      Get the ProgramItems matching the given arguments
      Type Parameters:
      C - The content return type
      Parameters:
      cTypeIds - The id of content types. Can be empty to get program's items whatever their content type.
      code - The code. Can be null to get program's items regardless of their code
      catalogName - The search catalog. Can be null to get program's items regardless the catalog they belong to.
      lang - The search language. Can be null to get program's items regardless of their language
      Returns:
      The matching program items
    • getProgramItems

      public <C extends Content> AmetysObjectIterable<C> getProgramItems(String cTypeId, String code, String catalogName, String lang, Expression additionnalExpr, SortCriteria sortCriteria)
      Get the ProgramItems matching the given arguments
      Type Parameters:
      C - The content return type
      Parameters:
      cTypeId - The id of content type. Can be null to get program's items whatever their content type.
      code - The code. Can be null to get program's items regardless of their code
      catalogName - The search catalog. Can be null to get program's items regardless the catalog they belong to.
      lang - The search language. Can be null to get program's items regardless of their language
      additionnalExpr - An additional expression for filtering result. Can be null
      sortCriteria - criteria for sorting results
      Returns:
      The matching program items
    • getProgramItems

      public <C extends Content> AmetysObjectIterable<C> getProgramItems(Collection<String> cTypeIds, String code, String catalogName, String lang, Expression additionnalExpr, SortCriteria sortCriteria)
      Get the ProgramItems matching the given arguments
      Type Parameters:
      C - The content return type
      Parameters:
      cTypeIds - The id of content types. Can be empty to get program's items whatever their content type.
      code - The code. Can be null to get program's items regardless of their code
      catalogName - The search catalog. Can be null to get program's items regardless the catalog they belong to.
      lang - The search language. Can be null to get program's items regardless of their language
      additionnalExpr - An additional expression for filtering result. Can be null
      sortCriteria - criteria for sorting results
      Returns:
      The matching program items
    • getCoursePart

      public CoursePart getCoursePart(CoursePart srcCoursePart, String catalogName, String lang)
      Get the equivalent CoursePart of the source CoursePart in given catalog and language
      Parameters:
      srcCoursePart - The source course part
      catalogName - The name of catalog to search into
      lang - The search language
      Returns:
      The equivalent program item or null if not exists
    • getProgramItem

      public <T extends ProgramItem> T getProgramItem(T srcProgramItem, String catalogName, String lang)
      Get the equivalent ProgramItem of the source ProgramItem in given catalog and language
      Type Parameters:
      T - The type of returned object, it have to be a subclass of ProgramItem
      Parameters:
      srcProgramItem - The source program item
      catalogName - The name of catalog to search into
      lang - The search language
      Returns:
      The equivalent program item or null if not exists
    • getODFContent

      public <T extends AmetysObject> T getODFContent(String contentType, String odfContentCode, String catalogName, String lang)
      Get the equivalent Content having the same code in given catalog and language
      Type Parameters:
      T - The type of returned object, it have to be a subclass of AmetysObject
      Parameters:
      contentType - The content type to search for
      odfContentCode - The code of the ODF content
      catalogName - The name of catalog to search into
      lang - The search language
      Returns:
      The equivalent content or null if not exists
    • getChildProgramItems

      Get the child program items of a ProgramItem
      Parameters:
      programItem - The program item
      Returns:
      The child program items
    • getChildSubPrograms

      Get the child subprograms of a ProgramPart
      Parameters:
      programPart - The program part
      Returns:
      The child subprograms
    • getParentContainers

      Gets (recursively) parent containers of this program item.
      Parameters:
      programItem - The program item
      Returns:
      parent containers of this program item.
    • getParentContainers

      public Set<Container> getParentContainers(ProgramItem programItem, boolean continueIfFound)
      Gets (recursively) parent containers of this program item.
      Parameters:
      programItem - The program item
      continueIfFound - If true continue searching corresponding parents in the parent structure, otherwise only closest items are returned.
      Returns:
      parent containers of this program item.
    • getParentPrograms

      public Set<Program> getParentPrograms(CoursePart coursePart)
      Gets (recursively) parent programs of this course part.
      Parameters:
      coursePart - The course part
      Returns:
      parent programs of this course part.
    • getParentPrograms

      public Set<Program> getParentPrograms(ProgramItem programItem)
      Gets (recursively) parent programs of this program item.
      Parameters:
      programItem - The program item
      Returns:
      parent programs of this program item.
    • getParentSubPrograms

      Gets (recursively) parent subprograms of this course part.
      Parameters:
      coursePart - The course part
      Returns:
      parent subprograms of this course part.
    • getParentSubPrograms

      public Set<SubProgram> getParentSubPrograms(CoursePart coursePart, boolean continueIfFound)
      Gets (recursively) parent subprograms of this course part.
      Parameters:
      coursePart - The course part
      continueIfFound - If true continue searching corresponding parents in the parent structure, otherwise only closest items are returned.
      Returns:
      parent subprograms of this course part.
    • getParentSubPrograms

      Gets (recursively) parent subprograms of this program item.
      Parameters:
      programItem - The program item
      Returns:
      parent subprograms of this program item.
    • getParentSubPrograms

      public Set<SubProgram> getParentSubPrograms(ProgramItem programItem, boolean continueIfFound)
      Gets (recursively) parent subprograms of this program item.
      Parameters:
      programItem - The program item
      continueIfFound - If true continue searching corresponding parents in the parent structure, otherwise only closest items are returned.
      Returns:
      parent subprograms of this program item.
    • getParentAbstractPrograms

      Gets (recursively) parent abstract programs of this course part.
      Parameters:
      coursePart - The course part
      Returns:
      parent abstract programs of this course part.
    • getParentAbstractPrograms

      public Set<AbstractProgram> getParentAbstractPrograms(CoursePart coursePart, boolean continueIfFound)
      Gets (recursively) parent abstract programs of this course part.
      Parameters:
      coursePart - The course part
      continueIfFound - If true continue searching corresponding parents in the parent structure, otherwise only closest items are returned.
      Returns:
      parent abstract programs of this course part.
    • getParentAbstractPrograms

      Gets (recursively) parent abstract programs of this program item.
      Parameters:
      programItem - The program item
      Returns:
      parent abstract programs of this program item.
    • getParentAbstractPrograms

      public Set<AbstractProgram> getParentAbstractPrograms(ProgramItem programItem, boolean continueIfFound)
      Gets (recursively) parent abstract programs of this program item.
      Parameters:
      programItem - The program item
      continueIfFound - If true continue searching corresponding parents in the parent structure, otherwise only closest items are returned.
      Returns:
      parent abstract programs of this program item.
    • getProgramsFromOrgUnit

      public List<Program> getProgramsFromOrgUnit(OrgUnit orgUnit, String catalog, String lang)
      Get the child programs of an OrgUnit
      Parameters:
      orgUnit - the orgUnit, can be null
      catalog - the catalog
      lang - the lang
      Returns:
      The child programs
    • getSubOrgUnitIds

      public List<String> getSubOrgUnitIds(OrgUnit orgUnit)
      Get the current orgunit and its suborgunits recursively identifiers.
      Parameters:
      orgUnit - The orgunit at the top
      Returns:
      A List of OrgUnit ids
    • hasParentProgramItems

      public boolean hasParentProgramItems(ProgramItem programItem)
      Determines if the ProgramItem has parent program items
      Parameters:
      programItem - The program item
      Returns:
      true if has parent program items
    • getParentProgramItems

      Get the parent program items of a ProgramItem
      Parameters:
      programItem - The program item
      Returns:
      The parent program items
    • getParentProgramItems

      public List<ProgramItem> getParentProgramItems(ProgramItem programItem, ProgramPart parentProgramPart)
      Get the program item parents into the given ancestor ProgramPart
      Parameters:
      programItem - The program item
      parentProgramPart - The parent program, subprogram or container. If null, all parents program items will be returned.
      Returns:
      The parent program items which have given parent program part has an ancestor
    • getParentProgramItem

      public ProgramItem getParentProgramItem(ProgramItem programItem, AbstractProgram parentProgram)
      Get the first nearest program item parent into the given parent AbstractProgram
      Parameters:
      programItem - The program item
      parentProgram - The parent program or subprogram. If null, the nearest abstract program will be returned.
      Returns:
      The parent program item or null if not found.
    • getProgramItemInfo

      public Map<String,Object> getProgramItemInfo(String programItemId, List<String> programItemPathIds)
      Get information of the program item
      Parameters:
      programItemId - the program item id
      programItemPathIds - the list of program item ids containing in the path of the program item ... starting with itself. Can be null or empty
      Returns:
      a map of information
    • getStructureInfo

      public Map<String,Object> getStructureInfo(String contentId)
      Get information of the program item structure (type, if program has children) or orgunit (no structure for now)
      Parameters:
      contentId - the content id
      Returns:
      a map of information
    • getStructureInfo

      public Map<String,Map<String,Object>> getStructureInfo(List<String> programItemIds)
      Get information of the program item structure (type, if program has children)
      Parameters:
      programItemIds - the list of program item id
      Returns:
      a map of information
    • getOrgUnitPath

      public String getOrgUnitPath(OrgUnit orgunit, String separator)
      Get all the path of the orgunit.
      The path is built with the contents' title and code
      Parameters:
      orgunit - The orgunit
      separator - The path separator
      Returns:
      the path in parent orgunit
    • getPaths

      public List<String> getPaths(ProgramItem item, String separator)
      Get all EducationalPath of a ProgramItem as readable values The path is built with the contents' title and code
      Parameters:
      item - The program item
      separator - The path separator
      Returns:
      the paths in parent program items
    • getPaths

      public List<String> getPaths(ProgramItem item, String separator, Function<ProgramItem,String> mapper, boolean includeItself)
      Get all EducationalPath of a ProgramItem as readable values The path is built with the mapper function.
      Parameters:
      item - The program item
      separator - The path separator
      mapper - the function to apply to each program item to build the path
      includeItself - set to false to not include final item in path
      Returns:
      the paths in parent program items
    • getPaths

      public List<String> getPaths(ProgramItem item, String separator, Function<ProgramItem,String> mapper, Predicate<ProgramItem> filterPathSegment, boolean includeItself, boolean ignoreOrphanPath)
      Get all EducationalPath of a ProgramItem as readable values The path is built with the mapper function.
      Parameters:
      item - The program item
      separator - The path separator
      mapper - the function to apply to each program item to build the path
      filterPathSegment - predicate to exclude some program item of path
      includeItself - set to false to not include final item in path
      ignoreOrphanPath - set to true to ignore paths that is not part of a Program
      Returns:
      the paths in parent program items
    • getValueForPath

      public <T> Optional<T> getValueForPath(ProgramItem programItem, String dataPath, EducationalPath path)
      Get the value of an attribute for a given educational path. The attribute is necessarily in a repeater composed of at least one educational path attribute and the attribute to be retrieved.
      Type Parameters:
      T - The type of the value returned by the path
      Parameters:
      programItem - The program item
      path - Full or partial educational path. Cannot be null. In case of partial educational path (ie., no root program) the full possible paths will be computed.
      dataPath - The full path of attribute to retrieve. The path must contain the path of repeater holding the value (ex: path/to/repeater/attributeName)
      Returns:
      the value for this educational path
    • getValueForPath

      public <T> Optional<T> getValueForPath(ProgramItem programItem, String dataPath, List<EducationalPath> paths)
      Get the value of an attribute for a given educational path. The attribute is necessarily in a repeater composed of at least one educational path attribute and the attribute to be retrieved.
      Type Parameters:
      T - The type of the value returned by the path
      Parameters:
      programItem - The program item
      paths - Full educational paths (from root program). Cannot be null nor empty.
      dataPath - The full path of attribute to retrieve. The path must contain the path of repeater holding the value (ex: path/to/repeater/attributeName)
      Returns:
      the value for this educational path
    • getValuesForPaths

      public <T> Map<EducationalPath,T> getValuesForPaths(ProgramItem programItem, String dataPath, T defaultValue)
      Get the value of an attribute for each available educational paths
      Type Parameters:
      T - The type of the values returned by the path
      Parameters:
      programItem - The program item
      dataPath - The full path of attribute to retrieve. The path must contain the path of repeater holding the value (ex: path/to/repeater/attributeName)
      defaultValue - The default value to use if the repeater contains no entry for this educational path. Can be null.
      Returns:
      the values for each educational paths
    • getValuesForPaths

      public <T> Map<EducationalPath,T> getValuesForPaths(ProgramItem programItem, String dataPath, List<EducationalPath> paths, T defaultValue)
      Get the value of an attribute for each given educational paths
      Type Parameters:
      T - The type of the value returned by the path
      Parameters:
      programItem - The program item
      dataPath - The full path of attribute to retrieve. The path must contain the path of repeater holding the value (ex: path/to/repeater/attributeName)
      paths - The full educational paths (from root programs)
      defaultValue - The default value to use if the repeater contains no entry for this educational path. Can be null.
      Returns:
      the values for each educational paths
    • isSameValueForAllPaths

      public boolean isSameValueForAllPaths(ProgramItem programItem, String dataPath)
      Determines if the values of an attribute depending of a educational path is the same for all available educational paths
      Parameters:
      programItem - The program item
      dataPath - The full path of attribute to retrieve. The path must contain the path of repeater holding the value (ex: path/to/repeater/attributeName)
      Returns:
      true if the value is the same for all available educational paths
    • isSameValueForPaths

      public boolean isSameValueForPaths(ProgramItem programItem, String dataPath, List<EducationalPath> paths)
      Determines if the values of an attribute depending of a educational path is the same for all available educational paths
      Parameters:
      programItem - The program item
      dataPath - The full path of attribute to retrieve. The path must contain the path of repeater holding the value (ex: path/to/repeater/attributeName)
      paths - The full educational paths (from root programs)
      Returns:
      true if the value is the same for all available educational paths
    • getRepeaterEntryPositionForPath

      public int getRepeaterEntryPositionForPath(ProgramItem programItem, String dataPath, EducationalPath path)
      Get a position of repeater entry that match the given educational path
      Parameters:
      programItem - The program item
      dataPath - The full path of attribute to retrieve. The path must contain the path of repeater holding the value (ex: path/to/repeater/attributeName)
      path - The full educational path (from root program). Cannot be null.
      Returns:
      the index position of the entry matching the educational path with a non-empty value for requested attribute, -1 otherwise
    • getRepeaterEntryPositionForPath

      public int getRepeaterEntryPositionForPath(ProgramItem programItem, String dataPath, List<EducationalPath> paths)
      Get a position of repeater entry that match the given educational path
      Parameters:
      programItem - The program item
      dataPath - The full path of attribute to retrieve. The path must contain the path of repeater holding the value (ex: path/to/repeater/attributeName)
      paths - The full educational paths (from root program). Cannot be null.
      Returns:
      the index position of the entry matching the educational path with a non-empty value for requested attribute, -1 otherwise
    • getEducationPathFromPath

      Get the full educations paths (from a root Program) from a full or partial path
      Parameters:
      path - A full or partial path composed by program item ancestors
      Returns:
      the full educational paths
    • getEducationPathFromPaths

      Get the full educations paths (from a root Program) from full or partial paths
      Parameters:
      paths - full or partial paths composed by program item ancestors
      Returns:
      the full educational paths
    • getEducationPathFromPaths

      Get the full educations paths (from a root Program)from full or partial paths
      Parameters:
      paths - full or partial paths composed by program item ancestors
      withAncestor - filter the educational paths that contains this ancestor. Can be null.
      Returns:
      the full educational paths
    • getEducationalPaths

      Get all EducationalPath of a ProgramItem The path is built with the mapper function.
      Parameters:
      programItem - The program item
      Returns:
      the paths in parent program items
    • getEducationalPaths

      public List<EducationalPath> getEducationalPaths(ProgramItem programItem, boolean includeItself)
      Get all EducationalPath of a ProgramItem The path is built with the mapper function.
      Parameters:
      programItem - The program item
      includeItself - set to false to not include final item in path
      Returns:
      the paths in parent program items
    • getEducationalPaths

      public List<EducationalPath> getEducationalPaths(ProgramItem programItem, boolean includeItself, boolean ignoreOrphanPath)
      Get all EducationalPath of a ProgramItem The path is built with the mapper function.
      Parameters:
      programItem - The program item
      includeItself - set to false to not include final item in path
      ignoreOrphanPath - set to true to ignore paths that is not part of a Program
      Returns:
      the paths in parent program items
    • getEducationalPathAsString

      Get a readable value of a EducationalPath
      Parameters:
      path - the educational path
      Returns:
      a String representing the path with program item's title separated by '>'
    • getEducationalPathAsString

      Get a readable value of a EducationalPath
      Parameters:
      path - the educational path
      mapper - the function to use for the readable value of a program item
      separator - the separator to use
      Returns:
      a String representing the path with program item's readable value given by mapper function and separated by given separator
    • getEducationalPathAsString

      Get a readable value of a EducationalPath
      Parameters:
      path - the educational path
      mapper - the function to use for the readable value of a program item
      separator - the separator to use
      filterPathSegment - predicate to exclude some program item of path
      Returns:
      a String representing the path with program item's readable value given by mapper function and separated by given separator
    • getPathOfAncestors

      protected List<List<ProgramItem>> getPathOfAncestors(ProgramItem programItem)
      Get the full path to program item for highest ancestors. The path includes this final item.
      Parameters:
      programItem - the program item
      Returns:
      a list for each highest ancestors found. Each item of the list contains the program items to the path to this program item.
    • getEducationalPathsEnumeration

      Get the enumeration of educational paths for a program item for highest ancestors. The paths does not includes this final item.
      Parameters:
      programItemId - the id of program item
      Returns:
      a list of educational paths with paths' label (composed by ancestors' title separated by '>') and paths' id (composed by ancestors' id seperated by coma)
    • getPathInProgram

      public String getPathInProgram(String programItemId, String programId)
      Get the path of a ProgramItem into a Program
      The path is construct with the contents' names and the used separator is '/'.
      Parameters:
      programItemId - The id of the program item
      programId - The id of program. Can not be null.
      Returns:
      the path into the parent program or null if the item is not part of this program.
    • getPathInProgram

      public String getPathInProgram(ProgramItem item, Program parentProgram)
      Get the path of a ODF content into a Program.
      The path is construct with the contents' names and the used separator is '/'.
      Parameters:
      item - The program item
      parentProgram - The parent root (sub)program. Can not be null.
      Returns:
      the path from the parent program
    • getPathInCourse

      public String getPathInCourse(String contentId, String parentCourseId)
      Get the path of a Course or a CourseList into a Course
      The path is construct with the contents' names and the used separator is '/'.
      Parameters:
      contentId - The id of the content
      parentCourseId - The id of parent course. Can not be null.
      Returns:
      the path into the parent course or null if the item is not part of this course.
    • getPathInCourse

      public String getPathInCourse(Content courseOrList, Course parentCourse)
      Get the path of a Course or a CourseList into a Course
      The path is construct with the contents' names and the used separator is '/'.
      Parameters:
      courseOrList - The course or the course list
      parentCourse - The parent course. Can not be null.
      Returns:
      the path into the parent course or null if the item is not part of this course.
    • getOrgUnitPath

      public String getOrgUnitPath(String orgUnitId, String rootOrgUnitId)
      Get the hierarchical path of a OrgUnit from the root orgunit id.
      The path is construct with the contents' names and the used separator is '/'.
      Parameters:
      orgUnitId - The id of the orgunit
      rootOrgUnitId - The root orgunit id
      Returns:
      the path into the parent program or null if the item is not part of this program.
    • getOrgUnitPath

      public String getOrgUnitPath(String orgUnitId)
      Get the hierarchical path of a OrgUnit from the root orgunit.
      The path is construct with the contents' names and the used separator is '/'.
      Parameters:
      orgUnitId - The id of the orgunit
      Returns:
      the path into the parent program or null if the item is not part of this program.
    • hasAncestor

      public boolean hasAncestor(ProgramPart part, String parentId)
      Return true if the given ProgramPart has in its hierarchy a parent of given id
      Parameters:
      part - The program part
      parentId - The ancestor id
      Returns:
      true if the given ProgramPart has in its hierarchy a parent of given id
    • isShared

      public boolean isShared(ProgramItem programItem)
      Determines if a program item is shared
      Parameters:
      programItem - the program item
      Returns:
      true if the program item is shared
    • isRelationCompatible

      public boolean isRelationCompatible(Content srcContent, Content targetContent, List<I18nizableText> errors, Map<String,Object> contextualParameters)
      Check if a relation can be establish between two ODF contents
      Parameters:
      srcContent - The source content (copied or moved)
      targetContent - The target content
      errors - The list of error messages
      contextualParameters - the contextual parameters
      Returns:
      true if the relation is valid, false otherwise
    • getDescendantRelationAttributeName

      public String getDescendantRelationAttributeName(ProgramItem parentProgramItem, ProgramItem childProgramItem)
      Get the name of attribute holding the relation between a parent content and its children
      Parameters:
      parentProgramItem - the parent content
      childProgramItem - the child content
      Returns:
      the name of attribute the child relation
    • copyProgramItem

      public <C extends ModifiableContent> C copyProgramItem(ProgramItem srcContent, String targetCatalog, boolean fullCopy, Map<Content,Content> copiedContents) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
      Type Parameters:
      C - The modifiable content return type
      Parameters:
      srcContent - The program item to copy
      targetCatalog - The target catalog. Can be null. The target catalog will be the catalog of the source object.
      fullCopy - Set to true to copy the sub-structure
      copiedContents - the initial contents with their copied content
      Returns:
      The created content
      Throws:
      AmetysRepositoryException - If an error occurred during copy
      com.opensymphony.workflow.WorkflowException - If an error occurred during copy
    • copyProgramItem

      public <C extends ModifiableContent> C copyProgramItem(ProgramItem srcContent, String targetContentName, String targetContentLanguage, String targetCatalog, boolean fullCopy, Map<Content,Content> copiedContents) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
      Type Parameters:
      C - The modifiable content return type
      Parameters:
      srcContent - The program item to copy
      targetContentName - The name of content to created. Can be null. If null, the new name will be get from the source object.
      targetContentLanguage - The name of content to created. Can be null. If null, the language of target content will be the same as source object.
      targetCatalog - The target catalog. Can be null. The target catalog will be the catalog of the source object.
      fullCopy - Set to true to copy the sub-structure
      copiedContents - the initial contents with their copied content
      Returns:
      The created content
      Throws:
      AmetysObjectExistsException - If a program item with same code, catalog and language already exists
      AmetysRepositoryException - If an error occurred
      com.opensymphony.workflow.WorkflowException - If an error occurred
    • copyCoursePart

      public <C extends ModifiableContent> C copyCoursePart(CoursePart srcContent, String targetContentName, String targetContentLanguage, int initWorkflowActionId, String targetCatalog, boolean fullCopy, Map<Content,Content> copiedContents) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
      Copy a CoursePart
      Type Parameters:
      C - The modifiable content return type
      Parameters:
      srcContent - The course part to copy
      targetContentName - The name of content to created. Can be null. If null, the new name will be get from the source object.
      targetContentLanguage - The name of content to created. Can be null. If null, the language of target content will be the same as source object.
      initWorkflowActionId - The initial workflow action id
      fullCopy - Set to true to copy the sub-structure
      targetCatalog - The target catalog. Can be null. The target catalog will be the catalog of the source object.
      copiedContents - the initial contents with their copied content
      Returns:
      The created content
      Throws:
      AmetysObjectExistsException - If a program item with same code, catalog and language already exists
      AmetysRepositoryException - If an error occurred
      com.opensymphony.workflow.WorkflowException - If an error occurred
    • copyProgramItem

      public <C extends ModifiableContent> C copyProgramItem(ProgramItem srcContent, String targetContentName, String targetContentLanguage, int initWorkflowActionId, String targetCatalog, boolean fullCopy, Map<Content,Content> copiedContents) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
      Type Parameters:
      C - The modifiable content return type
      Parameters:
      srcContent - The program item to copy
      targetContentName - The name of content to created. Can be null. If null, the new name will be get from the source object.
      targetContentLanguage - The name of content to created. Can be null. If null, the language of target content will be the same as source object.
      initWorkflowActionId - The initial workflow action id
      fullCopy - Set to true to copy the sub-structure
      targetCatalog - The target catalog. Can be null. The target catalog will be the catalog of the source object.
      copiedContents - the initial contents with their copied content
      Returns:
      The created content
      Throws:
      AmetysObjectExistsException - If a program item with same code, catalog and language already exists
      AmetysRepositoryException - If an error occurred
      com.opensymphony.workflow.WorkflowException - If an error occurred
    • copyProgramItemStructure

      protected void copyProgramItemStructure(ProgramItem srcContent, ModifiableContent targetContent, String targetContentLanguage, int initWorkflowActionId, String targetCatalogName, Map<Content,Content> copiedContents) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
      Copy the structure of a ProgramItem
      Parameters:
      srcContent - the content to copy
      targetContent - the target content
      targetContentLanguage - The name of content to created. Can be null. If null, the language of target content will be the same as source object.
      initWorkflowActionId - The initial workflow action id
      targetCatalogName - The target catalog. Can be null. The target catalog will be the catalog of the source object.
      copiedContents - the initial contents with their copied content
      Throws:
      AmetysRepositoryException - If an error occurred during copy
      com.opensymphony.workflow.WorkflowException - If an error occurred during copy
    • _cleanContentMetadata

      protected void _cleanContentMetadata(ModifiableContent createdContent)
      Clean the CONTENT metadata created after a copy but whose values reference the initial content' structure
      Parameters:
      createdContent - The created content to clean
    • switchToLiveVersion

      Switch the ametys object to Live version if it has one
      Parameters:
      ao - the Ametys object
      Throws:
      NoLiveVersionException - if the content has no live version
    • switchToLiveVersionIfNeeded

      Switch to Live version if is required
      Parameters:
      ao - the Ametys object
      Throws:
      NoLiveVersionException - if the Live version is required but not exist
    • getCumulatedHours

      public Double getCumulatedHours(ProgramItem programItem)
      Count the hours accumulation in the ProgramItem
      Parameters:
      programItem - The program item on which we compute the total number of hours
      Returns:
      The hours accumulation
    • _getRequest

      protected Request _getRequest()
      Get the request
      Returns:
      the request
    • getOrgUnitByUAICode

      Get the first orgunit matching the given UAI code
      Parameters:
      uaiCode - the UAI code
      Returns:
      the orgunit or null if not found