package com.fp.bpmlib.task.util;

import java.util.ArrayList;
import java.util.List;

import javax.enterprise.inject.Alternative;

import com.fp.bpmlib.task.client.HumanTaskClient;

@Alternative
public class MaiaUserGroupCallback implements org.kie.internal.task.api.UserGroupCallback {

    public MaiaUserGroupCallback() {
    }

    @Override
    public boolean existsUser(String userId) {
        return true;
        // return userId.equals("jvaca") || userId.equals("john") || userId.equals("mary") || userId.equals("Administrator");
    }

    @Override
    public boolean existsGroup(String groupId) {
        return true;
        // return groupId.equals("PM") || groupId.equals("HR");
    }

    @Override
    public List<String> getGroupsForUser(String userId, List<String> groupIds, List<String> allExistingGroupIds) {
        List<String> groups = new ArrayList<>();
        try {
            groups = HumanTaskClient.groupsByUser(userId);
        } catch (Exception e) {
            // retorn la lista vacia.
        }

        return groups;
    }
}
