<commit_before>/*
 * Copyright 2005-2006 The Kuali Foundation.
 *
 *
 * Licensed under the Educational Community License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.opensource.org/licenses/ecl1.php
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kuali.rice.kew.rule;

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

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.Version;

import org.kuali.rice.core.reflect.ObjectDefinition;
import org.kuali.rice.core.resourceloader.GlobalResourceLoader;
import org.kuali.rice.kew.actionrequest.ActionRequestValue;
import org.kuali.rice.kew.bo.WorkflowPersistable;
import org.kuali.rice.kew.exception.KEWUserNotFoundException;
import org.kuali.rice.kew.exception.WorkflowException;
import org.kuali.rice.kew.service.KEWServiceLocator;
import org.kuali.rice.kew.user.UserService;
import org.kuali.rice.kew.user.WorkflowUser;
import org.kuali.rice.kew.user.WorkflowUserId;
import org.kuali.rice.kew.util.KEWConstants;
import org.kuali.rice.kew.util.Utilities;
import org.kuali.rice.kew.workgroup.WorkflowGroupId;
import org.kuali.rice.kew.workgroup.Workgroup;
import org.kuali.rice.kew.workgroup.WorkgroupService;
import org.kuali.rice.kim.bo.group.dto.GroupInfo;
import org.kuali.rice.kim.service.KIMServiceLocator;


/**
 * A model bean representing the responsibility of a user, workgroup, or role
 * to perform some action on a document.  Used by the rule system to
 * identify the appropriate responsibile parties to generate
 * {@link ActionRequestValue}s to.
 *
 * @author K<NAME> (<EMAIL>)
 */
@Entity
@Table(name="KREW_RULE_RSP_T")
public class RuleResponsibility implements WorkflowPersistable {

	private static final long serialVersionUID = -1565688857123316797L;
	@Id
	@Column(name="RULE_RSP_ID")
	private Long ruleResponsibilityKey;
    @Column(name="RSP_ID")
	private Long responsibilityId;
    @Column(name="RULE_ID")
	private Long ruleBaseValuesId;
    @Column(name="ACTN_RQST_CD")
	private String actionRequestedCd;
    @Column(name="NM")
	private String ruleResponsibilityName;
    @Column(name="TYP")
	private String ruleResponsibilityType;
    @Version
	@Column(name="VER_NBR")
	private Integer lockVerNbr;
    @Column(name="PRIO")
	private Integer priority;
    @Column(name="APPR_PLCY")
	private String approvePolicy;

    @ManyToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST})
	@JoinColumn(name="RULE_ID", insertable=false, updatable=false)
	private RuleBaseValues ruleBaseValues;
    @Transient
    private List delegationRules = new ArrayList();

    public WorkflowUser getWorkflowUser() throws KEWUserNotFoundException {
        if (isUsingWorkflowUser()) {
            return ((UserService) KEWServiceLocator.getService(KEWServiceLocator.USER_SERVICE)).getWorkflowUser(new WorkflowUserId(ruleResponsibilityName));
        }
        return null;
    }

    public GroupInfo getGroup() throws KEWUserNotFoundException {
        if (isUsingGroup()) {
        	GroupInfo grpInfo =KIMServiceLocator.getGroupService().createGroup(new GroupInfo());
        	grpInfo.setGroupName(ruleResponsibilityName);
            return  grpInfo;            
        }
        return null;
    }

    public String getRole() {
        if (isUsingRole()) {
            return ruleResponsibilityName;
        }
        return null;
    }

    public String getResolvedRoleName() {
        if (isUsingRole()) {<commit_msg>Fixed a bug in RuleResponsibility.getGroup<commit_after>/*
 * Copyright 2005-2006 The Kuali Foundation.
 *
 *
 * Licensed under the Educational Community License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.opensource.org/licenses/ecl1.php
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kuali.rice.kew.rule;

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

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.Version;

import org.kuali.rice.core.reflect.ObjectDefinition;
import org.kuali.rice.core.resourceloader.GlobalResourceLoader;
import org.kuali.rice.kew.actionrequest.ActionRequestValue;
import org.kuali.rice.kew.bo.WorkflowPersistable;
import org.kuali.rice.kew.exception.KEWUserNotFoundException;
import org.kuali.rice.kew.exception.WorkflowException;
import org.kuali.rice.kew.service.KEWServiceLocator;
import org.kuali.rice.kew.user.UserService;
import org.kuali.rice.kew.user.WorkflowUser;
import org.kuali.rice.kew.user.WorkflowUserId;
import org.kuali.rice.kew.util.KEWConstants;
import org.kuali.rice.kew.util.Utilities;
import org.kuali.rice.kim.bo.group.KimGroup;
import org.kuali.rice.kim.service.KIMServiceLocator;


/**
 * A model bean representing the responsibility of a user, workgroup, or role
 * to perform some action on a document.  Used by the rule system to
 * identify the appropriate responsibile parties to generate
 * {@link ActionRequestValue}s to.
 *
 * @author Kuali Rice Team (<EMAIL>)
 */
@Entity
@Table(name="KREW_RULE_RSP_T")
public class RuleResponsibility implements WorkflowPersistable {

	private static final long serialVersionUID = -1565688857123316797L;
	@Id
	@Column(name="RULE_RSP_ID")
	private Long ruleResponsibilityKey;
    @Column(name="RSP_ID")
	private Long responsibilityId;
    @Column(name="RULE_ID")
	private Long ruleBaseValuesId;
    @Column(name="ACTN_RQST_CD")
	private String actionRequestedCd;
    @Column(name="NM")
	private String ruleResponsibilityName;
    @Column(name="TYP")
	private String ruleResponsibilityType;
    @Version
	@Column(name="VER_NBR")
	private Integer lockVerNbr;
    @Column(name="PRIO")
	private Integer priority;
    @Column(name="APPR_PLCY")
	private String approvePolicy;

    @ManyToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST})
	@JoinColumn(name="RULE_ID", insertable=false, updatable=false)
	private RuleBaseValues ruleBaseValues;
    @Transient
    private List delegationRules = new ArrayList();

    public WorkflowUser getWorkflowUser() throws KEWUserNotFoundException {
        if (isUsingWorkflowUser()) {
            return ((UserService) KEWServiceLocator.getService(KEWServiceLocator.USER_SERVICE)).getWorkflowUser(new WorkflowUserId(ruleResponsibilityName));
        }
        return null;
    }

    public KimGroup getGroup() throws KEWUserNotFoundException {
        if (isUsingGroup()) {
        	return KIMServiceLocator.getIdentityManagementService().getGroup(ruleResponsibilityName);
        }
        return null;
    }

    public String getRole() {
        if (isUsingRole()) {
            return ruleResponsibilityName;
        }
        return null;
    }

    public String getResolvedRoleName() {
        if (isUsingRole()) {
{'fraction_non_alphanumeric': 0.09478435305917753, 'fraction_numerical': 0.007522567703109328, 'mean_word_length': 4.555013927576602, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6987599', 'n_tokens_mistral': 2484, 'n_tokens_neox': 2427, 'n_words': 581}