Search in sources :

Example 1 with SecurityGroupTab

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

the class SecurityGroupTabValuesFinder method getKeyValues.

@Override
public List<KeyValue> getKeyValues() {
    List<KeyValue> keyValues = new ArrayList<KeyValue>();
    Long securityGroupID = null;
    KualiForm form = KNSGlobalVariables.getKualiForm();
    if ((form != null) && (form instanceof KualiDocumentFormBase)) {
        Document doc = ((KualiDocumentFormBase) form).getDocument();
        if (doc instanceof MaintenanceDocument) {
            SecurityProvisioning securityProvisioning = (SecurityProvisioning) ((MaintenanceDocument) doc).getDocumentDataObject();
            securityGroupID = securityProvisioning.getSecurityGroupId();
        }
    }
    Collection<SecurityGroupTab> tabs;
    if (securityGroupID != null) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put(KSRPropertyConstants.SECURITY_GROUP_ID, securityGroupID);
        tabs = SpringContext.getBean(BusinessObjectService.class).findMatching(SecurityGroupTab.class, map);
        for (SecurityGroupTab tab : tabs) {
            keyValues.add(new ConcreteKeyValue(tab.getTabId().toString(), tab.getTabOrder() + " - " + tab.getTabName()));
        }
    }
    return keyValues;
}
Also used : ConcreteKeyValue(org.kuali.kfs.core.api.util.ConcreteKeyValue) SecurityGroupTab(edu.cornell.kfs.ksr.businessobject.SecurityGroupTab) ConcreteKeyValue(org.kuali.kfs.core.api.util.ConcreteKeyValue) KeyValue(org.kuali.kfs.core.api.util.KeyValue) MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument) Document(org.kuali.kfs.krad.document.Document) SecurityProvisioning(edu.cornell.kfs.ksr.businessobject.SecurityProvisioning) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) KualiForm(org.kuali.kfs.kns.web.struts.form.KualiForm)

Example 2 with SecurityGroupTab

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

the class SecurityRequestDocumentAction method buildTabRoleIndexes.

@SuppressWarnings({ "rawtypes", "unchecked" })
protected List<SecurityRequestDocumentForm.TabRoleIndexes> buildTabRoleIndexes(final SecurityRequestDocument document) {
    final List<SecurityRequestDocumentForm.TabRoleIndexes> tabRoleIndexes = new ArrayList<SecurityRequestDocumentForm.TabRoleIndexes>();
    List sortPropertyNames = new ArrayList();
    sortPropertyNames.add(KSRPropertyConstants.SECURITY_REQUEST_DOCUMENT_TAB_ORDER);
    List<SecurityGroupTab> securityGroupTabs = document.getSecurityGroup().getSecurityGroupTabs().stream().collect(Collectors.toCollection(ArrayList::new));
    Collections.sort(securityGroupTabs, new BeanPropertyComparator(sortPropertyNames));
    for (SecurityGroupTab groupTab : securityGroupTabs) {
        SecurityRequestDocumentForm.TabRoleIndexes tabIndexes = new SecurityRequestDocumentForm.TabRoleIndexes();
        tabIndexes.setTabId(groupTab.getTabId());
        tabIndexes.setTabName(groupTab.getTabName());
        sortPropertyNames = new ArrayList();
        sortPropertyNames.add(KSRPropertyConstants.SECURITY_REQUEST_DOCUMENT_ROLE_TAB_ORDER);
        List<SecurityProvisioningGroup> provisioningGroups = groupTab.getSecurityProvisioningGroups().stream().collect(Collectors.toCollection(ArrayList::new));
        Collections.sort(provisioningGroups, new BeanPropertyComparator(sortPropertyNames));
        List<Integer> requestRoleIndexes = new ArrayList<Integer>();
        for (SecurityProvisioningGroup provisioningGroup : provisioningGroups) {
            if (provisioningGroup.isActive()) {
                int roleIndex = findSecurityRequestRoleIndex(document, provisioningGroup.getRoleId());
                if (roleIndex == -1) {
                    LOG.warn("buildTabRoleIndexes, Unable to find security request role record for role id '" + provisioningGroup.getRoleId() + "' on document '" + document.getDocumentNumber() + "'; this role will be omitted from the document");
                } else {
                    requestRoleIndexes.add(new Integer(roleIndex));
                }
            }
        }
        if (requestRoleIndexes.size() > 0) {
            tabIndexes.setRoleRequestIndexes(requestRoleIndexes);
            tabRoleIndexes.add(tabIndexes);
        }
    }
    return tabRoleIndexes;
}
Also used : SecurityGroupTab(edu.cornell.kfs.ksr.businessobject.SecurityGroupTab) BeanPropertyComparator(org.kuali.kfs.krad.util.BeanPropertyComparator) ArrayList(java.util.ArrayList) SecurityProvisioningGroup(edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with SecurityGroupTab

use of edu.cornell.kfs.ksr.businessobject.SecurityGroupTab 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 4 with SecurityGroupTab

use of edu.cornell.kfs.ksr.businessobject.SecurityGroupTab 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 5 with SecurityGroupTab

use of edu.cornell.kfs.ksr.businessobject.SecurityGroupTab 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)

Aggregations

SecurityGroupTab (edu.cornell.kfs.ksr.businessobject.SecurityGroupTab)6 SecurityGroup (edu.cornell.kfs.ksr.businessobject.SecurityGroup)3 ArrayList (java.util.ArrayList)3 SecurityProvisioningGroup (edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup)2 SecurityProvisioning (edu.cornell.kfs.ksr.businessobject.SecurityProvisioning)1 SecurityRequestRole (edu.cornell.kfs.ksr.businessobject.SecurityRequestRole)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ConcreteKeyValue (org.kuali.kfs.core.api.util.ConcreteKeyValue)1 KeyValue (org.kuali.kfs.core.api.util.KeyValue)1 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)1 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)1 KualiForm (org.kuali.kfs.kns.web.struts.form.KualiForm)1 Document (org.kuali.kfs.krad.document.Document)1 SequenceAccessorService (org.kuali.kfs.krad.service.SequenceAccessorService)1 BeanPropertyComparator (org.kuali.kfs.krad.util.BeanPropertyComparator)1