use of org.kuali.kfs.kns.document.authorization.MaintenanceDocumentRestrictions in project cu-kfs by CU-CommunityApps.
the class CuSubAccountPreRules method copyICRFromAccount.
@SuppressWarnings("deprecation")
protected void copyICRFromAccount(MaintenanceDocument document) {
Person user = GlobalVariables.getUserSession().getPerson();
// get a new instance of MaintenanceDocumentAuthorizations for this context
MaintenanceDocumentRestrictions auths = SpringContext.getBean(BusinessObjectAuthorizationService.class).getMaintenanceDocumentRestrictions(document, user);
// don't need to copy if the user does not have the authority to edit the fields
if (!auths.getFieldRestriction("a21SubAccount.financialIcrSeriesIdentifier").isReadOnly()) {
// only need to do this of the account sub type is EX
A21SubAccount a21SubAccount = newSubAccount.getA21SubAccount();
Account account = newSubAccount.getAccount();
if (KFSConstants.SubAccountType.EXPENSE.equals(a21SubAccount.getSubAccountTypeCode())) {
if (ObjectUtils.isNull(account) || StringUtils.isBlank(account.getAccountNumber())) {
account = getAccountService().getByPrimaryId(newSubAccount.getChartOfAccountsCode(), newSubAccount.getAccountNumber());
}
if (ObjectUtils.isNotNull(account)) {
if (a21SubAccount.getA21ActiveIndirectCostRecoveryAccounts().isEmpty()) {
for (IndirectCostRecoveryAccount icrAccount : account.getActiveIndirectCostRecoveryAccounts()) {
A21IndirectCostRecoveryAccount copyAccount = A21IndirectCostRecoveryAccount.copyICRAccount(icrAccount);
copyAccount.setNewCollectionRecord(true);
a21SubAccount.getA21IndirectCostRecoveryAccounts().add(copyAccount);
}
}
if (StringUtils.isBlank(a21SubAccount.getFinancialIcrSeriesIdentifier())) {
a21SubAccount.setFinancialIcrSeriesIdentifier(account.getFinancialIcrSeriesIdentifier());
}
if (StringUtils.isBlank(a21SubAccount.getIndirectCostRecoveryTypeCode())) {
a21SubAccount.setIndirectCostRecoveryTypeCode(account.getAcctIndirectCostRcvyTypeCd());
}
}
}
}
}
use of org.kuali.kfs.kns.document.authorization.MaintenanceDocumentRestrictions in project cu-kfs by CU-CommunityApps.
the class CuVendorMaintainableImpl method getSections.
/**
* Overridden to forcibly populate the multi-select procurementMethodsArray KNS field values,
* and to forcibly hide the procurementMethods field's row.
*
* @see org.kuali.kfs.kns.maintenance.KualiMaintainableImpl#getSections(org.kuali.kfs.kns.document.MaintenanceDocument,
* org.kuali.kfs.kns.maintenance.Maintainable)
*/
@SuppressWarnings("rawtypes")
@Override
public List getSections(MaintenanceDocument document, Maintainable oldMaintainable) {
@SuppressWarnings("unchecked") List<Section> sections = super.getSections(document, oldMaintainable);
MaintenanceDocumentRestrictions restrictions = KNSServiceLocator.getBusinessObjectAuthorizationService().getMaintenanceDocumentRestrictions(document, GlobalVariables.getUserSession().getPerson());
// Perform the forcible updates on the generated sections.
boolean doneWithSections = false;
for (int i = 0; !doneWithSections && i < sections.size(); i++) {
Section section = sections.get(i);
if (VENDOR_SECTION_ID.equals(section.getSectionId())) {
// Find and update the appropriate fields/rows.
List<Row> rows = section.getRows();
int fieldsDone = 0;
for (int j = 0; fieldsDone < 2 && j < rows.size(); j++) {
List<Field> fields = rows.get(j).getFields();
for (int k = 0; fieldsDone < 2 && k < fields.size(); k++) {
String fieldName = fields.get(k).getPropertyName();
if (PROC_METHODS_MULTISELECT_FIELD_NAME.equals(fieldName)) {
// Update the property values and security on the multiselect field.
setupMultiselectField(document, restrictions, fields.get(k), MULTISELECT_FIELD_PATH_PREFIX + fieldName);
fieldsDone++;
} else if (PROC_METHODS_FIELD_NAME.equals(fieldName)) {
// Hide the row containing the flattened version of the multiselect field.
rows.get(j).setHidden(true);
fieldsDone++;
}
}
}
doneWithSections = true;
}
}
return sections;
}
Aggregations