Search in sources :

Example 1 with SecurityGroup

use of edu.cornell.kfs.ksr.businessobject.SecurityGroup in project cu-kfs by CU-CommunityApps.

the class SecurityGroupMaintainable method processAfterCopy.

@Override
public void processAfterCopy(MaintenanceDocument document, Map<String, String[]> parameters) {
    super.processAfterCopy(document, parameters);
    SecurityGroup securityGroup = (SecurityGroup) document.getNewMaintainableObject().getDataObject();
    if (CollectionUtils.isNotEmpty(securityGroup.getSecurityGroupTabs())) {
        SequenceAccessorService sas = SpringContext.getBean(SequenceAccessorService.class);
        for (SecurityGroupTab securityGroupTab : securityGroup.getSecurityGroupTabs()) {
            Long newId = sas.getNextAvailableSequenceNumber(KSRConstants.SECURITY_GROUP_TAB_SEQ_NAME);
            securityGroupTab.setTabId(newId);
        }
    }
}
Also used : SequenceAccessorService(org.kuali.kfs.krad.service.SequenceAccessorService) SecurityGroupTab(edu.cornell.kfs.ksr.businessobject.SecurityGroupTab) SecurityGroup(edu.cornell.kfs.ksr.businessobject.SecurityGroup)

Example 2 with SecurityGroup

use of edu.cornell.kfs.ksr.businessobject.SecurityGroup in project cu-kfs by CU-CommunityApps.

the class SecurityGroupRule method processCustomAddCollectionLineBusinessRules.

/**
 * Validate the new SecurityGroupTab against ones that are already in the list - tab order must be unique - tab name must be unique
 */
@Override
public boolean processCustomAddCollectionLineBusinessRules(MaintenanceDocument document, String collectionName, PersistableBusinessObject line) {
    boolean success = true;
    if (line instanceof SecurityGroupTab) {
        SecurityGroup securityGroup = (SecurityGroup) document.getDocumentDataObject();
        SecurityGroupTab tempTab = (SecurityGroupTab) line;
        if (CollectionUtils.isNotEmpty(securityGroup.getSecurityGroupTabs())) {
            for (SecurityGroupTab tab : securityGroup.getSecurityGroupTabs()) {
                if (tab.getTabOrder() != null && tab.getTabOrder().equals(tempTab.getTabOrder())) {
                    GlobalVariables.getMessageMap().putError(KSRPropertyConstants.SECURITY_GROUP_TAB_ORDER, KSRKeyConstants.ERROR_SECURITY_GROUP_TAB_ORDER_UNIQUE);
                    success = false;
                }
                if (StringUtils.isNotBlank(tab.getTabName()) && StringUtils.equalsIgnoreCase(tab.getTabName(), tempTab.getTabName())) {
                    GlobalVariables.getMessageMap().putError(KSRPropertyConstants.SECURITY_GROUP_TAB_NAME, KSRKeyConstants.ERROR_SECURITY_GROUP_TAB_NAME_UNIQUE);
                    success = false;
                }
            }
        }
    }
    return super.processCustomAddCollectionLineBusinessRules(document, collectionName, line) && success;
}
Also used : SecurityGroupTab(edu.cornell.kfs.ksr.businessobject.SecurityGroupTab) SecurityGroup(edu.cornell.kfs.ksr.businessobject.SecurityGroup)

Example 3 with SecurityGroup

use of edu.cornell.kfs.ksr.businessobject.SecurityGroup in project cu-kfs by CU-CommunityApps.

the class SecurityGroupRule method dataDictionaryValidate.

/**
 * Validates the maint. doc before it is written to the db.
 */
@Override
protected boolean dataDictionaryValidate(MaintenanceDocument document) {
    boolean success = true;
    SecurityGroup securityGroup = (SecurityGroup) document.getDocumentDataObject();
    if (!hasAtLeastOneActiveTab(securityGroup.getSecurityGroupTabs())) {
        GlobalVariables.getMessageMap().putErrorForSectionId(KSRConstants.SECTION_SECURITY_TABS, KSRKeyConstants.ERROR_SECURITY_GROUP_TAB_MISSING);
        success = false;
    }
    // Check the Security Group Name against the DB
    SecurityGroup temp = retrieveSecurityGroupByName(securityGroup.getSecurityGroupName());
    if (ObjectUtils.isNotNull(temp)) {
        if (securityGroup.getSecurityGroupId() != null) {
            if (StringUtils.equalsIgnoreCase(temp.getSecurityGroupName(), securityGroup.getSecurityGroupName()) && !temp.getSecurityGroupId().equals(securityGroup.getSecurityGroupId())) {
                GlobalVariables.getMessageMap().putError(KSRPropertyConstants.KSR_DOCUMENT_MAINTAINABLE + "." + KSRPropertyConstants.SECURITY_GROUP_NAME, KSRKeyConstants.ERROR_SECURITY_GROUP_NAME_UNIQUE);
                success = false;
            }
        } else {
            GlobalVariables.getMessageMap().putError(KSRPropertyConstants.KSR_DOCUMENT_MAINTAINABLE + "." + KSRPropertyConstants.SECURITY_GROUP_NAME, KSRKeyConstants.ERROR_SECURITY_GROUP_NAME_UNIQUE);
            success = false;
        }
    }
    success = validateSecurityGroupTabs(document);
    return (super.dataDictionaryValidate(document) && success);
}
Also used : SecurityGroup(edu.cornell.kfs.ksr.businessobject.SecurityGroup)

Example 4 with SecurityGroup

use of edu.cornell.kfs.ksr.businessobject.SecurityGroup in project cu-kfs by CU-CommunityApps.

the class SecurityGroupRule method validateSecurityGroupTabs.

/**
 * Determines uniqueness of each SecurityGroupTab in the maint. doc.
 *
 * @param document
 *            - the current maint. doc
 * @return true if there are no duplicate tab orders or names
 */
public boolean validateSecurityGroupTabs(MaintenanceDocument document) {
    boolean successTabOrder = true;
    boolean successTabName = true;
    List<SecurityGroupTab> securityGroupTabs = ((SecurityGroup) document.getDocumentDataObject()).getSecurityGroupTabs();
    if (CollectionUtils.isNotEmpty(securityGroupTabs)) {
        for (int i = 0; i < securityGroupTabs.size(); i++) {
            SecurityGroupTab tab = securityGroupTabs.get(i);
            for (int j = i + 1; j < securityGroupTabs.size(); j++) {
                SecurityGroupTab tempTab = securityGroupTabs.get(j);
                if (successTabOrder && tab.getTabOrder() != null && tab.getTabOrder().equals(tempTab.getTabOrder())) {
                    GlobalVariables.getMessageMap().putErrorForSectionId(KSRConstants.SECTION_SECURITY_TABS, KSRKeyConstants.ERROR_SECURITY_GROUP_TAB_ORDER_UNIQUE);
                    successTabOrder = false;
                }
                if (successTabName && StringUtils.isNotBlank(tab.getTabName()) && StringUtils.equalsIgnoreCase(tab.getTabName(), tempTab.getTabName())) {
                    GlobalVariables.getMessageMap().putErrorForSectionId(KSRConstants.SECTION_SECURITY_TABS, KSRKeyConstants.ERROR_SECURITY_GROUP_TAB_NAME_UNIQUE);
                    successTabName = false;
                }
            }
        }
    }
    return successTabOrder && successTabName;
}
Also used : SecurityGroupTab(edu.cornell.kfs.ksr.businessobject.SecurityGroupTab) SecurityGroup(edu.cornell.kfs.ksr.businessobject.SecurityGroup)

Example 5 with SecurityGroup

use of edu.cornell.kfs.ksr.businessobject.SecurityGroup in project cu-kfs by CU-CommunityApps.

the class SecurityGroupRule method retrieveSecurityGroupByName.

private SecurityGroup retrieveSecurityGroupByName(String securityGroupName) {
    if (StringUtils.isBlank(securityGroupName)) {
        return null;
    }
    SecurityGroup securityGroup = null;
    QueryByCriteria criteria = QueryByCriteria.Builder.fromPredicates(PredicateFactory.equalIgnoreCase(KSRPropertyConstants.SECURITY_GROUP_NAME, securityGroupName));
    List<SecurityGroup> securityGroups = getCriteriaLookupService().lookup(SecurityGroup.class, criteria).getResults();
    if (CollectionUtils.isNotEmpty(securityGroups)) {
        if (securityGroups.size() > 1) {
            throw new IllegalStateException("Found multiple security groups with name '" + securityGroupName + "' (case-insensitive); this should NEVER happen!");
        }
        securityGroup = securityGroups.get(0);
    }
    return securityGroup;
}
Also used : QueryByCriteria(org.kuali.kfs.core.api.criteria.QueryByCriteria) SecurityGroup(edu.cornell.kfs.ksr.businessobject.SecurityGroup)

Aggregations

SecurityGroup (edu.cornell.kfs.ksr.businessobject.SecurityGroup)6 SecurityGroupTab (edu.cornell.kfs.ksr.businessobject.SecurityGroupTab)3 QueryByCriteria (org.kuali.kfs.core.api.criteria.QueryByCriteria)1 WorkflowDocument (org.kuali.kfs.kew.api.WorkflowDocument)1 SequenceAccessorService (org.kuali.kfs.krad.service.SequenceAccessorService)1