Search in sources :

Example 16 with PersistableBusinessObject

use of org.kuali.kfs.krad.bo.PersistableBusinessObject in project cu-kfs by CU-CommunityApps.

the class PurchasingActionBase method changeSystem.

public ActionForward changeSystem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingAccountsPayableFormBase purchasingForm = (PurchasingAccountsPayableFormBase) form;
    PurchasingDocument document = (PurchasingDocument) purchasingForm.getDocument();
    Object question = request.getParameter(PurapConstants.QUESTION_INDEX);
    Object buttonClicked = request.getParameter(KFSConstants.QUESTION_CLICKED_BUTTON);
    if (question == null) {
        String questionText = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(PurapKeyConstants.PURCHASING_QUESTION_CONFIRM_CHANGE_SYSTEM);
        return this.performQuestionWithoutInput(mapping, form, request, response, PurapConstants.CapitalAssetTabStrings.SYSTEM_SWITCHING_QUESTION, questionText, KFSConstants.CONFIRMATION_QUESTION, KFSConstants.ROUTE_METHOD, "0");
    } else if (ConfirmationQuestion.YES.equals(buttonClicked)) {
        // Add a note if system change occurs when the document is a PO that is being amended.
        if ((document instanceof PurchaseOrderDocument) && (PurapConstants.PurchaseOrderStatuses.APPDOC_CHANGE_IN_PROCESS.equals(document.getApplicationDocumentStatus()))) {
            Integer poId = document.getPurapDocumentIdentifier();
            PurchaseOrderDocument currentPO = SpringContext.getBean(PurchaseOrderService.class).getCurrentPurchaseOrder(poId);
            String oldSystemTypeCode = "";
            if (currentPO != null) {
                oldSystemTypeCode = currentPO.getCapitalAssetSystemTypeCode();
            }
            CapitalAssetSystemType oldSystemType = new CapitalAssetSystemType();
            oldSystemType.setCapitalAssetSystemTypeCode(oldSystemTypeCode);
            Map<String, String> keys = SpringContext.getBean(PersistenceService.class).getPrimaryKeyFieldValues(oldSystemType);
            oldSystemType = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(CapitalAssetSystemType.class, keys);
            String description = ((oldSystemType == null) ? "(NONE)" : oldSystemType.getCapitalAssetSystemTypeDescription());
            if (document instanceof PurchaseOrderAmendmentDocument) {
                String noteText = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(PurapKeyConstants.PURCHASE_ORDER_AMEND_MESSAGE_CHANGE_SYSTEM_TYPE);
                noteText = StringUtils.replace(noteText, "{0}", description);
                try {
                    Note systemTypeChangeNote = getDocumentService().createNoteFromDocument(document, noteText);
                    purchasingForm.setNewNote(systemTypeChangeNote);
                    insertBONote(mapping, purchasingForm, request, response);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        }
        if (form instanceof RequisitionForm) {
            ((RequisitionForm) form).resetNewPurchasingCapitalAssetLocationLine();
        }
        // remove capital assets from db
        if (document instanceof PurchaseOrderAmendmentDocument) {
            for (PurchasingCapitalAssetItem assetItem : document.getPurchasingCapitalAssetItems()) {
                SpringContext.getBean(BusinessObjectService.class).delete((PersistableBusinessObject) assetItem);
            }
        }
        document.clearCapitalAssetFields();
        SpringContext.getBean(PurapService.class).saveDocumentNoValidation(document);
        KNSGlobalVariables.getMessageList().add(PurapKeyConstants.PURCHASING_MESSAGE_SYSTEM_CHANGED);
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PurchaseOrderAmendmentDocument(org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument) CapitalAssetSystemType(org.kuali.kfs.module.purap.businessobject.CapitalAssetSystemType) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) ItemParserException(org.kuali.kfs.module.purap.exception.ItemParserException) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) Note(org.kuali.kfs.krad.bo.Note) PurchasingCapitalAssetItem(org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) ConfigurationService(org.kuali.rice.core.api.config.property.ConfigurationService) Map(java.util.Map) MessageMap(org.kuali.kfs.krad.util.MessageMap)

Example 17 with PersistableBusinessObject

use of org.kuali.kfs.krad.bo.PersistableBusinessObject in project cu-kfs by CU-CommunityApps.

the class UserProcurementProfileLookupableHelperServiceImpl method getSearchResultsNoAcctCriteria.

private List<PersistableBusinessObject> getSearchResultsNoAcctCriteria(List<PersistableBusinessObject> searchResults) {
    List<PersistableBusinessObject> returnResults = new ArrayList<PersistableBusinessObject>();
    for (PersistableBusinessObject pbo : searchResults) {
        UserProcurementProfile userProfile = (UserProcurementProfile) pbo;
        if (CollectionUtils.isEmpty(userProfile.getFavoriteAccounts())) {
            userProfile.setResultAccount(new FavoriteAccount());
            returnResults.add(userProfile);
        } else {
            for (FavoriteAccount account : userProfile.getFavoriteAccounts()) {
                returnResults.add(buildUserProfile(userProfile, account));
            }
        }
    }
    sortList(returnResults);
    return returnResults;
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) FavoriteAccount(edu.cornell.kfs.sys.businessobject.FavoriteAccount) ArrayList(java.util.ArrayList) UserProcurementProfile(edu.cornell.kfs.sys.businessobject.UserProcurementProfile)

Example 18 with PersistableBusinessObject

use of org.kuali.kfs.krad.bo.PersistableBusinessObject in project cu-kfs by CU-CommunityApps.

the class CuFinancialMaintenanceDocumentActionTest method createMockMaintainable.

protected Maintainable createMockMaintainable(Class<? extends PersistableBusinessObject> dataObjectClass, String objectId) {
    PersistableBusinessObject mockDataObject = createMockDataObject(dataObjectClass, objectId);
    Maintainable maintainable = mock(FinancialSystemMaintainable.class);
    when(maintainable.getDataObjectClass()).thenReturn(dataObjectClass);
    when(maintainable.getDataObject()).thenReturn(mockDataObject);
    when(maintainable.getBusinessObject()).thenReturn(mockDataObject);
    return maintainable;
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) Maintainable(org.kuali.kfs.kns.maintenance.Maintainable) FinancialSystemMaintainable(org.kuali.kfs.sys.document.FinancialSystemMaintainable)

Example 19 with PersistableBusinessObject

use of org.kuali.kfs.krad.bo.PersistableBusinessObject in project cu-kfs by CU-CommunityApps.

the class CuElectronicInvoiceHelperServiceImpl method addRejectReasonsToNote.

protected void addRejectReasonsToNote(String rejectReasons, ElectronicInvoiceRejectDocument eInvoiceRejectDocument) {
    try {
        Note note = SpringContext.getBean(DocumentService.class).createNoteFromDocument(eInvoiceRejectDocument, rejectReasons);
        // KFSCNTRB-1369: Can't add note without remoteObjectIdentifier
        note.setRemoteObjectIdentifier(eInvoiceRejectDocument.getNoteTarget().getObjectId());
        PersistableBusinessObject noteParent = eInvoiceRejectDocument.getNoteTarget();
        SpringContext.getBean(NoteService.class).save(note);
    } catch (Exception e) {
        LOG.error("Error creating reject reason note - " + e.getMessage());
    }
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) Note(org.kuali.kfs.krad.bo.Note) NoteService(org.kuali.kfs.krad.service.NoteService) WorkflowDocumentService(org.kuali.kfs.krad.workflow.service.WorkflowDocumentService) DocumentService(org.kuali.kfs.krad.service.DocumentService) FinancialSystemDocumentService(org.kuali.kfs.sys.document.service.FinancialSystemDocumentService) ValidationException(org.kuali.kfs.krad.exception.ValidationException) IOException(java.io.IOException) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) CxmlParseException(org.kuali.kfs.module.purap.exception.CxmlParseException)

Example 20 with PersistableBusinessObject

use of org.kuali.kfs.krad.bo.PersistableBusinessObject in project cu-kfs by CU-CommunityApps.

the class CuAttachmentServiceImplTest method createAttachmentWithVirus.

@Test
public void createAttachmentWithVirus() throws Exception {
    PersistableBusinessObject pbo = setupPersistableBusinessObject();
    InputStream inputStream = setupInputStream(ATTACHMENT_TEST_FILE_PATH + File.separator + VIRUS_FILE_NAME);
    setupExpectedException("file contents failed virus scan");
    attachmentService.createAttachment(pbo, VIRUS_FILE_NAME, "txt", 50, inputStream, "txt");
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Test(org.junit.Test)

Aggregations

PersistableBusinessObject (org.kuali.kfs.krad.bo.PersistableBusinessObject)21 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)6 BufferedInputStream (java.io.BufferedInputStream)5 FileInputStream (java.io.FileInputStream)5 InputStream (java.io.InputStream)5 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)4 FavoriteAccount (edu.cornell.kfs.sys.businessobject.FavoriteAccount)2 Maintainable (org.kuali.kfs.kns.maintenance.Maintainable)2 Note (org.kuali.kfs.krad.bo.Note)2 MessageMap (org.kuali.kfs.krad.util.MessageMap)2 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)2 DummyAntiVirusServiceImpl (edu.cornell.cynergy.antivirus.service.DummyAntiVirusServiceImpl)1 AccountReversionService (edu.cornell.kfs.coa.service.AccountReversionService)1 UserProcurementProfile (edu.cornell.kfs.sys.businessobject.UserProcurementProfile)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 RemoteException (java.rmi.RemoteException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1