package com.ffii.fhsmsc.modules.User_group.constant;

import java.util.Map;
import java.util.Set;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Collections;

public class RelationshipRules {
    private static final Map<String, Set<String>> ALLOWED_OPERATIONS;
    
    static {
        Map<String, Set<String>> map = new HashMap<>();
        
        // Admin permissions
        Set<String> adminOps = new HashSet<>();
        adminOps.add("ADD_MEMBER");
        adminOps.add("REMOVE_MEMBER");
        adminOps.add("UPDATE_MEMBER");
        adminOps.add("ADD_ADMIN");
        map.put(RelationshipTypes.ADMIN, Collections.unmodifiableSet(adminOps));
        
        // Member permissions
        Set<String> memberOps = new HashSet<>();
        memberOps.add("VIEW_MEMBER");
        map.put(RelationshipTypes.MEMBER, Collections.unmodifiableSet(memberOps));
        
        // Delegate permissions
        Set<String> delegateOps = new HashSet<>();
        delegateOps.add("ADD_MEMBER");
        delegateOps.add("REMOVE_MEMBER");
        delegateOps.add("UPDATE_MEMBER");
        map.put(RelationshipTypes.DELEGATE, Collections.unmodifiableSet(delegateOps));
        
        ALLOWED_OPERATIONS = Collections.unmodifiableMap(map);
    }
    
    public static boolean canPerformOperation(String relationshipType, String operation) {
        Set<String> allowedOps = ALLOWED_OPERATIONS.get(relationshipType);
        return allowedOps != null && allowedOps.contains(operation);
    }
    
    private RelationshipRules() {
        // Private constructor to prevent instantiation
    }
} 