Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-12845

New EntityReference#extractFirstReference(EntityType)

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 7.3
    • Fix Version/s: 7.4-milestone-1
    • Component/s: Model
    • Labels:
      None
    • Tests:
      Unit
    • Difficulty:
      Unknown
    • Documentation:
      N/A
    • Similar issues:

      Description

      Right now when you have an EntityReference of type EntityType.SPACE and you wish to get the first space name, it's hard to do. I'm just proposing to add a new API:

          public EntityReference extractFirstReference(EntityType type)
          {
              EntityReference reference = extractReference(type);
      
              while (reference != null && reference.getParent() != null 
                  && reference.getParent().getType().equals(type))
              {
                  reference = reference.getParent();
              }
      
              return reference;
          }
      

        Attachments

          Activity

            People

            • Assignee:
              vmassol Vincent Massol
              Reporter:
              vmassol Vincent Massol
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: