Search in sources :

Example 1 with SequenceAccessorService

use of org.kuali.kfs.krad.service.SequenceAccessorService in project cu-kfs by CU-CommunityApps.

the class BalanceInquiryLookupAction method performMultipleValueLookup.

/**
 * This method performs the lookup and returns a collection of lookup items. Also initializes values in the form
 * that will allow the multiple value lookup page to render.
 *
 * @param multipleValueLookupForm
 * @param resultTable            a list of result rows (used to generate what's shown in the UI). This list will be
 *                               modified by this method
 * @param maxRowsPerPage
 * @param bounded                whether the results will be bounded
 * @return the list of result BOs, possibly bounded by size
 */
protected Collection performMultipleValueLookup(MultipleValueLookupForm multipleValueLookupForm, List<ResultRow> resultTable, int maxRowsPerPage, boolean bounded) {
    Lookupable lookupable = multipleValueLookupForm.getLookupable();
    Collection displayList = lookupable.performLookup(multipleValueLookupForm, resultTable, bounded);
    List defaultSortColumns = lookupable.getDefaultSortColumns();
    if (defaultSortColumns != null && !defaultSortColumns.isEmpty() && resultTable != null && !resultTable.isEmpty()) {
        // there's a default sort order, just find the first sort column, and we can't go wrong
        String firstSortColumn = (String) defaultSortColumns.get(0);
        // go thru the first result row to find the index of the column (more efficient than calling
        // lookupable.getColumns since we don't have to recreate column list)
        int firstSortColumnIdx = -1;
        List<Column> columnsForFirstResultRow = resultTable.get(0).getColumns();
        for (int i = 0; i < columnsForFirstResultRow.size(); i++) {
            if (StringUtils.equals(firstSortColumn, columnsForFirstResultRow.get(i).getPropertyName())) {
                firstSortColumnIdx = i;
                break;
            }
        }
        multipleValueLookupForm.setColumnToSortIndex(firstSortColumnIdx);
    } else {
        // don't know how results were sorted, so we just say -1
        multipleValueLookupForm.setColumnToSortIndex(-1);
    }
    // we just performed the lookup, so we're on the first page (indexed from 0)
    multipleValueLookupForm.jumpToFirstPage(resultTable.size(), maxRowsPerPage);
    SequenceAccessorService sequenceAccessorService = SpringContext.getBean(SequenceAccessorService.class);
    String lookupResultsSequenceNumber = String.valueOf(sequenceAccessorService.getNextAvailableSequenceNumber(KRADConstants.LOOKUP_RESULTS_SEQUENCE));
    multipleValueLookupForm.setLookupResultsSequenceNumber(lookupResultsSequenceNumber);
    try {
        LookupResultsService lookupResultsService = SpringContext.getBean(LookupResultsService.class);
        lookupResultsService.persistResultsTable(lookupResultsSequenceNumber, resultTable, GlobalVariables.getUserSession().getPerson().getPrincipalId());
    } catch (Exception e) {
        LOG.error("error occurred trying to persist multiple lookup results", e);
        throw new RuntimeException("error occurred trying to persist multiple lookup results");
    }
    // since new search, nothing's checked
    multipleValueLookupForm.setCompositeObjectIdMap(new HashMap<>());
    return displayList;
}
Also used : SequenceAccessorService(org.kuali.kfs.krad.service.SequenceAccessorService) Lookupable(org.kuali.kfs.kns.lookup.Lookupable) Column(org.kuali.kfs.kns.web.ui.Column) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) LookupResultsService(org.kuali.kfs.kns.lookup.LookupResultsService)

Example 2 with SequenceAccessorService

use of org.kuali.kfs.krad.service.SequenceAccessorService in project cu-kfs by CU-CommunityApps.

the class PurchaseOrderDocument method customPrepareForSave.

@Override
public void customPrepareForSave(KualiDocumentEvent event) {
    super.customPrepareForSave(event);
    if (ObjectUtils.isNull(getPurapDocumentIdentifier())) {
        // need retrieve the next available PO id to save in GL entries (only do if purap id is null which should
        // be on first save)
        SequenceAccessorService sas = SpringContext.getBean(SequenceAccessorService.class);
        Long poSequenceNumber = sas.getNextAvailableSequenceNumber("PO_ID", this.getClass());
        setPurapDocumentIdentifier(poSequenceNumber.intValue());
    }
    // Set outstanding encumbered quantity/amount on items
    for (Object anItem : this.getItems()) {
        PurchaseOrderItem item = (PurchaseOrderItem) anItem;
        // Set quantities
        item.setItemOutstandingEncumberedQuantity(item.getItemQuantity());
        if (item.getItemInvoicedTotalQuantity() == null) {
            item.setItemInvoicedTotalQuantity(KualiDecimal.ZERO);
        }
        if (item.getItemInvoicedTotalAmount() == null) {
            item.setItemInvoicedTotalAmount(KualiDecimal.ZERO);
        }
        item.setItemOutstandingEncumberedAmount(item.getTotalAmount() == null ? KualiDecimal.ZERO : item.getTotalAmount());
        List accounts = item.getSourceAccountingLines();
        Collections.sort(accounts);
        for (Object anAcct : accounts) {
            PurchaseOrderAccount account = (PurchaseOrderAccount) anAcct;
            if (!account.isEmpty()) {
                account.setItemAccountOutstandingEncumbranceAmount(account.getAmount());
            }
        }
    }
    this.setSourceAccountingLines(SpringContext.getBean(PurapAccountingService.class).generateSummaryWithNoZeroTotals(this.getItems()));
}
Also used : SequenceAccessorService(org.kuali.kfs.krad.service.SequenceAccessorService) PurchaseOrderItem(org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem) PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) ArrayList(java.util.ArrayList) List(java.util.List) PurchaseOrderAccount(org.kuali.kfs.module.purap.businessobject.PurchaseOrderAccount)

Example 3 with SequenceAccessorService

use of org.kuali.kfs.krad.service.SequenceAccessorService in project cu-kfs by CU-CommunityApps.

the class PurchaseOrderDocument method populatePurchaseOrderFromRequisition.

/**
 * Populates this Purchase Order from the related Requisition Document.
 *
 * @param requisitionDocument the Requisition Document from which field values are copied.
 */
public void populatePurchaseOrderFromRequisition(RequisitionDocument requisitionDocument) {
    this.setPurchaseOrderCreateTimestamp(SpringContext.getBean(DateTimeService.class).getCurrentTimestamp());
    this.getDocumentHeader().setOrganizationDocumentNumber(requisitionDocument.getDocumentHeader().getOrganizationDocumentNumber());
    this.getDocumentHeader().setDocumentDescription(requisitionDocument.getDocumentHeader().getDocumentDescription());
    this.getDocumentHeader().setExplanation(requisitionDocument.getDocumentHeader().getExplanation());
    this.setBillingName(requisitionDocument.getBillingName());
    this.setBillingLine1Address(requisitionDocument.getBillingLine1Address());
    this.setBillingLine2Address(requisitionDocument.getBillingLine2Address());
    this.setBillingCityName(requisitionDocument.getBillingCityName());
    this.setBillingStateCode(requisitionDocument.getBillingStateCode());
    this.setBillingPostalCode(requisitionDocument.getBillingPostalCode());
    this.setBillingCountryCode(requisitionDocument.getBillingCountryCode());
    this.setBillingPhoneNumber(requisitionDocument.getBillingPhoneNumber());
    this.setBillingEmailAddress(requisitionDocument.getBillingEmailAddress());
    this.setReceivingName(requisitionDocument.getReceivingName());
    this.setReceivingCityName(requisitionDocument.getReceivingCityName());
    this.setReceivingLine1Address(requisitionDocument.getReceivingLine1Address());
    this.setReceivingLine2Address(requisitionDocument.getReceivingLine2Address());
    this.setReceivingStateCode(requisitionDocument.getReceivingStateCode());
    this.setReceivingPostalCode(requisitionDocument.getReceivingPostalCode());
    this.setReceivingCountryCode(requisitionDocument.getReceivingCountryCode());
    this.setAddressToVendorIndicator(requisitionDocument.getAddressToVendorIndicator());
    this.setDeliveryBuildingCode(requisitionDocument.getDeliveryBuildingCode());
    this.setDeliveryBuildingRoomNumber(requisitionDocument.getDeliveryBuildingRoomNumber());
    this.setDeliveryBuildingName(requisitionDocument.getDeliveryBuildingName());
    this.setDeliveryCampusCode(requisitionDocument.getDeliveryCampusCode());
    this.setDeliveryCityName(requisitionDocument.getDeliveryCityName());
    this.setDeliveryCountryCode(requisitionDocument.getDeliveryCountryCode());
    this.setDeliveryInstructionText(requisitionDocument.getDeliveryInstructionText());
    this.setDeliveryBuildingLine1Address(requisitionDocument.getDeliveryBuildingLine1Address());
    this.setDeliveryBuildingLine2Address(requisitionDocument.getDeliveryBuildingLine2Address());
    this.setDeliveryPostalCode(requisitionDocument.getDeliveryPostalCode());
    this.setDeliveryRequiredDate(requisitionDocument.getDeliveryRequiredDate());
    this.setDeliveryRequiredDateReasonCode(requisitionDocument.getDeliveryRequiredDateReasonCode());
    this.setDeliveryStateCode(requisitionDocument.getDeliveryStateCode());
    this.setDeliveryToEmailAddress(requisitionDocument.getDeliveryToEmailAddress());
    this.setDeliveryToName(requisitionDocument.getDeliveryToName());
    this.setDeliveryToPhoneNumber(requisitionDocument.getDeliveryToPhoneNumber());
    this.setDeliveryBuildingOtherIndicator(requisitionDocument.isDeliveryBuildingOtherIndicator());
    this.setPurchaseOrderBeginDate(requisitionDocument.getPurchaseOrderBeginDate());
    this.setPurchaseOrderCostSourceCode(requisitionDocument.getPurchaseOrderCostSourceCode());
    this.setPostingYear(requisitionDocument.getPostingYear());
    this.setPurchaseOrderEndDate(requisitionDocument.getPurchaseOrderEndDate());
    this.setChartOfAccountsCode(requisitionDocument.getChartOfAccountsCode());
    this.setDocumentFundingSourceCode(requisitionDocument.getDocumentFundingSourceCode());
    this.setInstitutionContactEmailAddress(requisitionDocument.getInstitutionContactEmailAddress());
    this.setInstitutionContactName(requisitionDocument.getInstitutionContactName());
    this.setInstitutionContactPhoneNumber(requisitionDocument.getInstitutionContactPhoneNumber());
    this.setNonInstitutionFundAccountNumber(requisitionDocument.getNonInstitutionFundAccountNumber());
    this.setNonInstitutionFundChartOfAccountsCode(requisitionDocument.getNonInstitutionFundChartOfAccountsCode());
    this.setNonInstitutionFundOrgChartOfAccountsCode(requisitionDocument.getNonInstitutionFundOrgChartOfAccountsCode());
    this.setNonInstitutionFundOrganizationCode(requisitionDocument.getNonInstitutionFundOrganizationCode());
    this.setOrganizationCode(requisitionDocument.getOrganizationCode());
    this.setRecurringPaymentTypeCode(requisitionDocument.getRecurringPaymentTypeCode());
    this.setRequestorPersonEmailAddress(requisitionDocument.getRequestorPersonEmailAddress());
    this.setRequestorPersonName(requisitionDocument.getRequestorPersonName());
    this.setRequestorPersonPhoneNumber(requisitionDocument.getRequestorPersonPhoneNumber());
    this.setRequisitionIdentifier(requisitionDocument.getPurapDocumentIdentifier());
    this.setPurchaseOrderTotalLimit(requisitionDocument.getPurchaseOrderTotalLimit());
    this.setPurchaseOrderTransmissionMethodCode(requisitionDocument.getPurchaseOrderTransmissionMethodCode());
    this.setUseTaxIndicator(requisitionDocument.isUseTaxIndicator());
    this.setVendorCityName(requisitionDocument.getVendorCityName());
    this.setVendorContractGeneratedIdentifier(requisitionDocument.getVendorContractGeneratedIdentifier());
    this.setVendorCountryCode(requisitionDocument.getVendorCountryCode());
    this.setVendorCustomerNumber(requisitionDocument.getVendorCustomerNumber());
    this.setVendorAttentionName(requisitionDocument.getVendorAttentionName());
    this.setVendorDetailAssignedIdentifier(requisitionDocument.getVendorDetailAssignedIdentifier());
    this.setVendorFaxNumber(requisitionDocument.getVendorFaxNumber());
    this.setVendorHeaderGeneratedIdentifier(requisitionDocument.getVendorHeaderGeneratedIdentifier());
    this.setVendorLine1Address(requisitionDocument.getVendorLine1Address());
    this.setVendorLine2Address(requisitionDocument.getVendorLine2Address());
    this.setVendorAddressInternationalProvinceName(requisitionDocument.getVendorAddressInternationalProvinceName());
    this.setVendorName(requisitionDocument.getVendorName());
    this.setVendorNoteText(requisitionDocument.getVendorNoteText());
    this.setVendorPhoneNumber(requisitionDocument.getVendorPhoneNumber());
    this.setVendorPostalCode(requisitionDocument.getVendorPostalCode());
    this.setVendorStateCode(requisitionDocument.getVendorStateCode());
    this.setVendorRestrictedIndicator(requisitionDocument.getVendorRestrictedIndicator());
    this.setJustification(requisitionDocument.getJustification());
    // KFSPTS-1458, KFSPTS-16990: Also copy vendorEmailAddress from Requisition to PO
    this.setVendorEmailAddress(requisitionDocument.getVendorEmailAddress());
    this.setExternalOrganizationB2bSupplierIdentifier(requisitionDocument.getExternalOrganizationB2bSupplierIdentifier());
    this.setRequisitionSourceCode(requisitionDocument.getRequisitionSourceCode());
    this.setAccountsPayablePurchasingDocumentLinkIdentifier(requisitionDocument.getAccountsPayablePurchasingDocumentLinkIdentifier());
    this.setReceivingDocumentRequiredIndicator(requisitionDocument.isReceivingDocumentRequiredIndicator());
    this.setPaymentRequestPositiveApprovalIndicator(requisitionDocument.isPaymentRequestPositiveApprovalIndicator());
    setApplicationDocumentStatus(PurchaseOrderStatuses.APPDOC_IN_PROCESS);
    this.setAccountDistributionMethod(requisitionDocument.getAccountDistributionMethod());
    // Copy items from requisition (which will copy the item's accounts and capital assets)
    List<PurchaseOrderItem> items = new ArrayList<>();
    for (PurApItem reqItem : ((PurchasingAccountsPayableDocument) requisitionDocument).getItems()) {
        RequisitionCapitalAssetItem reqCamsItem = (RequisitionCapitalAssetItem) requisitionDocument.getPurchasingCapitalAssetItemByItemIdentifier(reqItem.getItemIdentifier());
        items.add(new PurchaseOrderItem((RequisitionItem) reqItem, this, reqCamsItem));
    }
    this.setItems(items);
    // Copy capital asset information that is directly off the document.
    this.setCapitalAssetSystemTypeCode(requisitionDocument.getCapitalAssetSystemTypeCode());
    this.setCapitalAssetSystemStateCode(requisitionDocument.getCapitalAssetSystemStateCode());
    for (CapitalAssetSystem capitalAssetSystem : requisitionDocument.getPurchasingCapitalAssetSystems()) {
        this.getPurchasingCapitalAssetSystems().add(new PurchaseOrderCapitalAssetSystem(capitalAssetSystem));
    }
    this.fixItemReferences();
    // KFSUPGRADE-346/KITI-727
    if (ObjectUtils.isNull(getPurapDocumentIdentifier())) {
        // need retrieve the next available PO id to save in GL entries (only do if purap id is null which should be on first
        // save)
        SequenceAccessorService sas = SpringContext.getBean(SequenceAccessorService.class);
        Long poSequenceNumber = sas.getNextAvailableSequenceNumber("PO_ID", this.getClass());
        setPurapDocumentIdentifier(poSequenceNumber.intValue());
    }
    // KFSUPGRADE-337/KITI-2414 : checking for duplicate sensitive data types
    Set<String> currentSensitiveDataCodes = new HashSet<String>();
    if (purchaseOrderSensitiveData != null) {
        for (PurchaseOrderSensitiveData sensitiveData : purchaseOrderSensitiveData) {
            currentSensitiveDataCodes.add(sensitiveData.getSensitiveDataCode());
        }
    }
    if (requisitionDocument.isSensitive()) {
        for (PurchasingItemBase pib : (List<PurchasingItemBase>) requisitionDocument.getItems()) {
            CommodityCode cc = pib.getCommodityCode();
            if (cc != null && cc.getSensitiveDataCode() != null && currentSensitiveDataCodes.add(cc.getSensitiveDataCode())) {
                if (purchaseOrderSensitiveData == null) {
                    boolean addNewData = true;
                    purchaseOrderSensitiveData = getPurchaseOrderSensitiveData();
                    for (PurchaseOrderSensitiveData sensitiveData : purchaseOrderSensitiveData) {
                        if (!currentSensitiveDataCodes.add(sensitiveData.getSensitiveDataCode())) {
                            addNewData = false;
                        }
                    }
                    if (addNewData) {
                        purchaseOrderSensitiveData.add(new PurchaseOrderSensitiveData(getPurapDocumentIdentifier(), getRequisitionIdentifier(), cc.getSensitiveDataCode()));
                    }
                } else {
                    purchaseOrderSensitiveData.add(new PurchaseOrderSensitiveData(getPurapDocumentIdentifier(), getRequisitionIdentifier(), cc.getSensitiveDataCode()));
                }
            }
        }
    }
    if (purchaseOrderSensitiveData != null) {
        SpringContext.getBean(BusinessObjectService.class).save(purchaseOrderSensitiveData);
    }
}
Also used : PurchaseOrderSensitiveData(org.kuali.kfs.module.purap.businessobject.PurchaseOrderSensitiveData) PurchaseOrderCapitalAssetSystem(org.kuali.kfs.module.purap.businessobject.PurchaseOrderCapitalAssetSystem) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) ArrayList(java.util.ArrayList) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) PurchaseOrderItem(org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem) SequenceAccessorService(org.kuali.kfs.krad.service.SequenceAccessorService) RequisitionCapitalAssetItem(org.kuali.kfs.module.purap.businessobject.RequisitionCapitalAssetItem) RequisitionItem(org.kuali.kfs.module.purap.businessobject.RequisitionItem) PurchasingItemBase(org.kuali.kfs.module.purap.businessobject.PurchasingItemBase) CommodityCode(org.kuali.kfs.vnd.businessobject.CommodityCode) ArrayList(java.util.ArrayList) List(java.util.List) CapitalAssetSystem(org.kuali.kfs.integration.purap.CapitalAssetSystem) PurchaseOrderCapitalAssetSystem(org.kuali.kfs.module.purap.businessobject.PurchaseOrderCapitalAssetSystem) HashSet(java.util.HashSet)

Example 4 with SequenceAccessorService

use of org.kuali.kfs.krad.service.SequenceAccessorService 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 5 with SequenceAccessorService

use of org.kuali.kfs.krad.service.SequenceAccessorService in project cu-kfs by CU-CommunityApps.

the class IdentityManagementGroupDocument method initializeDocumentForNewGroup.

public void initializeDocumentForNewGroup() {
    if (StringUtils.isBlank(this.groupId)) {
        SequenceAccessorService sas = getSequenceAccessorService();
        Long nextSeq = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_GROUP_ID_S, this.getClass());
        this.groupId = nextSeq.toString();
    }
    if (StringUtils.isBlank(this.groupTypeId)) {
        /*
             * CU Customization: Backport the FINP-7913 fix.
             */
        final KimType defaultKimType = KimApiServiceLocator.getKimTypeInfoService().findKimTypeByNameAndNamespace(KFSConstants.CoreModuleNamespaces.KFS, KimConstants.KIM_TYPE_DEFAULT_NAME);
        if (defaultKimType != null) {
            groupTypeId = defaultKimType.getId();
        }
    }
}
Also used : SequenceAccessorService(org.kuali.kfs.krad.service.SequenceAccessorService) KimType(org.kuali.kfs.kim.impl.type.KimType)

Aggregations

SequenceAccessorService (org.kuali.kfs.krad.service.SequenceAccessorService)11 ArrayList (java.util.ArrayList)3 List (java.util.List)3 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)2 SecurityGroup (edu.cornell.kfs.ksr.businessobject.SecurityGroup)1 SecurityGroupTab (edu.cornell.kfs.ksr.businessobject.SecurityGroupTab)1 NoteExtendedAttribute (edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 CapitalAssetSystem (org.kuali.kfs.integration.purap.CapitalAssetSystem)1 KimAttributeField (org.kuali.kfs.kim.api.type.KimAttributeField)1 GroupDocumentMember (org.kuali.kfs.kim.bo.ui.GroupDocumentMember)1 GroupDocumentQualifier (org.kuali.kfs.kim.bo.ui.GroupDocumentQualifier)1 KimDocumentRoleMember (org.kuali.kfs.kim.bo.ui.KimDocumentRoleMember)1 KimDocumentRolePermission (org.kuali.kfs.kim.bo.ui.KimDocumentRolePermission)1 KimDocumentRoleQualifier (org.kuali.kfs.kim.bo.ui.KimDocumentRoleQualifier)1 KimDocumentRoleResponsibility (org.kuali.kfs.kim.bo.ui.KimDocumentRoleResponsibility)1 KimDocumentRoleResponsibilityAction (org.kuali.kfs.kim.bo.ui.KimDocumentRoleResponsibilityAction)1 RoleDocumentDelegation (org.kuali.kfs.kim.bo.ui.RoleDocumentDelegation)1 RoleDocumentDelegationMember (org.kuali.kfs.kim.bo.ui.RoleDocumentDelegationMember)1