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;
}
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;
}
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);
}
}
}
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;
}
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;
}
Aggregations