Search in sources :

Example 1 with MaintenanceDocumentRestrictions

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());
                }
            }
        }
    }
}
Also used : A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) MaintenanceDocumentRestrictions(org.kuali.kfs.kns.document.authorization.MaintenanceDocumentRestrictions) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) Account(org.kuali.kfs.coa.businessobject.Account) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) BusinessObjectAuthorizationService(org.kuali.kfs.kns.service.BusinessObjectAuthorizationService) Person(org.kuali.rice.kim.api.identity.Person) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount)

Example 2 with MaintenanceDocumentRestrictions

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;
}
Also used : MaintenanceDocumentRestrictions(org.kuali.kfs.kns.document.authorization.MaintenanceDocumentRestrictions) Field(org.kuali.kfs.kns.web.ui.Field) Row(org.kuali.kfs.kns.web.ui.Row) Section(org.kuali.kfs.kns.web.ui.Section)

Aggregations

MaintenanceDocumentRestrictions (org.kuali.kfs.kns.document.authorization.MaintenanceDocumentRestrictions)2 A21IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount)1 A21SubAccount (org.kuali.kfs.coa.businessobject.A21SubAccount)1 Account (org.kuali.kfs.coa.businessobject.Account)1 IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount)1 BusinessObjectAuthorizationService (org.kuali.kfs.kns.service.BusinessObjectAuthorizationService)1 Field (org.kuali.kfs.kns.web.ui.Field)1 Row (org.kuali.kfs.kns.web.ui.Row)1 Section (org.kuali.kfs.kns.web.ui.Section)1 Person (org.kuali.rice.kim.api.identity.Person)1