# Automatic Business Role Naming for IAM System

## Task
Rename business roles based on assigned persons and sub-roles meaningfully. **IMPORTANT: Each name must be unique.**

## Input Data Format
Data will be provided in JSON format or as tables. Analyze the structure and use all available information.

## Naming Logic

### 1. Generate Base Name
- **Primary**: Derive functions from sub-roles
- **Secondary**: Consider job titles of assigned persons
- **Format**: English terms, capitalize first letters of main words, use hyphens as separators
- **Examples**: `HR-Administration`, `IT-Management`, `Sales-Support`, `Marketing-Coordination`

### 2. Organization Suffix with Gentle Org-Unit Preservation
**Rule for Single-Person Roles:**
- Append all available orgunit values of the person
- Format: `_orgunit1_orgunit2_orgunit3` (only if value present)

**Rule for Multi-Person Roles:**
- Only append orgunit values that ALL persons share in common
- Ignore empty values

**Extended Org-Unit Normalization (Parser Compatibility):**
**Basic Principle: Minimal adjustments - preserve originality as much as possible**

**Normalize these characters for unambiguous parsing:**
- **Spaces** → Hyphen: "Human Resources" → "Human-Resources"
- **&** → "and": "Research & Development" → "Research-and-Development"  
- **/** → Hyphen: "Finance/Accounting" → "Finance-Accounting"
- **_** → Hyphen: "IT_Support" → "IT-Support"
- **__** (double) → single hyphen: "Sales__North" → "Sales-North"
- **Remove brackets**: "Marketing (Digital)" → "Marketing-Digital"
- **Double spaces** → single hyphens

**Preserve these properties:**
- **Case sensitivity**: Maintain original where sensible
- **Department abbreviations**: Leave short designations (2-4 characters) unchanged
- **Proper names**: Respect company-specific designations
- **Technical terms**: Don't translate known department designations

**Extended Normalization Examples:**
```
"Human Resources" → "Human-Resources"
"Research & Development" → "Research-and-Development"
"Finance/Accounting" → "Finance-Accounting"  
"IT_Support" → "IT-Support"
"Sales_Region_North" → "Sales-Region-North"
"Quality_Assurance" → "Quality-Assurance"
"Customer_Service" → "Customer-Service"
"Project_Management_Office" → "Project-Management-Office"
"Regional__Sales__North" → "Regional-Sales-North"
"Marketing (Digital)" → "Marketing-Digital"
```

### 3. Ensure Uniqueness - EXTENDED
- **STEP 1**: Collect all already generated names during processing
- **STEP 2**: Check each name against the list before finalization
- **STEP 3**: In case of conflicts, use JobTitle differentiation INSTEAD of numeric suffixes:
  - Head of → `-Lead`
  - Director → `-Director`
  - Team Leader → `-Team-Lead`
  - Employee → `-Employee`
  - Manager → `-Manager`
- **STEP 4**: If conflict still exists, use Org-Unit differentiation
- **STEP 5**: Only as last resort: Numeric suffix (`-1`, `-2`, etc.)

## Sub-Role Interpretation
- Use the provided system role mappings
- If no mappings available: Derive from ID pattern:
  - `3sr*` → Basic permissions
  - `4sr*` → Application access  
  - `5sr*` → Workflow rights
  - `6sr*` → Administrative rights

## Output Format
```
BusinessRole_br0 = HR-Personnel-Administration_Board-of-Directors_HR
BusinessRole_br1 = IT-Compliance-Access_Board-of-Directors_IT-Support
BusinessRole_br2 = Sales-Coordination_Board-of-Directors_Sales-and-Marketing_Sales-Region-North
```

## Quality Guidelines
- **Maximum 60 characters** per role name (extended for org-unit names)
- **Descriptive names** that make the function recognizable
- **English terms** for functions where possible, capitalize first letters
- **Preserve original org-unit names** as much as possible with minimal normalization
- **Parser compatibility** through unambiguous separators
- **Consistent naming conventions** within the same organizational structure
- **Professional readability** through appropriate capitalization
- **Uniqueness takes precedence** - use each name only once

## Special Rules
- **Executive/CEO Roles**: Use prefix `Exec-`
- **Trainee/Intern Roles**: Use prefix `Trainee-`  
- **External/Consultant Roles**: Use suffix `-External` before Org-Units
- **Leadership/Team Lead Roles**: Use prefix `Lead-`

## Universal Org-Unit Handling Rules
**Always preserve - never change:**
- Short designations (2-4 characters): Likely abbreviations or codes
- Numbers in org-unit names: Could be cost centers/department numbers
- Company-specific terms: Respect unknown designations

**Normalize for parser compatibility:**
- All underscores to hyphens (prevents parsing conflicts)
- Spaces to hyphens (for system compatibility)
- Special characters (&, /) only normalize when necessary

**Cautious normalization:**
- Very long org-unit names (>25 characters): Only change necessary characters
- When uncertain: Rather too little than too much normalization

## Example Transformations (company-independent)
```
Person with JobTitle "Team Leader" in Org-Units: "Hauptverwaltung", "Vertrieb_Nord", "Region_A"
→ Lead-Sales-Administration_Hauptverwaltung_Vertrieb-Nord_Region-A

Person with JobTitle "Coordinator" in Org-Units: "Corporate", "Human_Resources"  
→ Personnel-Coordination_Corporate_Human-Resources

Multiple persons in shared Org-Unit: "Zentrale", "IT_Services"
→ IT-Administration_Zentrale_IT-Services

Person with external type in Org-Units: "Beratung", "Projekt_Alpha"
→ Consulting-Access-External_Beratung_Projekt-Alpha
```

## Adaptive Naming Logic
**Analyze the present org-unit structures:**
1. **Hierarchy depth**: How many org-unit levels exist?
2. **Naming conventions**: Are they German, English, or mixed terms?
3. **Name length**: Short abbreviations or spelled-out designations?
4. **Special character usage**: Do org-units contain underscores, slashes, or other characters?
5. **Consistency**: Does the structure follow recognizable patterns?

**Adapt normalization accordingly:**
- For German org-units: Minimal normalization
- For English org-units: Can be normalized more strongly
- For mixed systems: Consistency within a hierarchy level
- For special characters: Always normalize to hyphens (parser protection)

## Validation Before Output
**Check the generated names:**
- Are all names unique? (CRITICAL!)
- Are the org-unit names still recognizable as such?
- Was the hierarchy order maintained?
- Were company-specific terms respected?
- Were all underscores converted to hyphens (parser compatibility)?
- Does the system work consistently for all roles?
- Is the spelling professional and readable?

Analyze the specific organizational structure in the input data and generate appropriately adapted business role names with unambiguous parser compatibility.

---

## INPUT DATA