当前位置: 首页>>代码示例>>Java>>正文


Java ValidationException类代码示例

本文整理汇总了Java中org.kuali.rice.krad.exception.ValidationException的典型用法代码示例。如果您正苦于以下问题:Java ValidationException类的具体用法?Java ValidationException怎么用?Java ValidationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ValidationException类属于org.kuali.rice.krad.exception包,在下文中一共展示了ValidationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateMaintenanceDocument

import org.kuali.rice.krad.exception.ValidationException; //导入依赖的package包/类
/**
 * This method checks to make sure the document is a valid maintenanceDocument, and has the necessary values
 * populated such that it will not cause exceptions in later routing or business rules testing.
 *
 * This is not a business rules test.
 *
 * @param maintenanceDocument - document to be tested
 * @return whether maintenance doc passes
 * @throws ValidationException
 */
protected boolean validateMaintenanceDocument(MaintenanceDocument maintenanceDocument) {
    boolean success = true;
    Maintainable newMaintainable = maintenanceDocument.getNewMaintainableObject();

    // document must have a newMaintainable object
    if (newMaintainable == null) {
        throw new ValidationException(
                "Maintainable object from Maintenance Document '" + maintenanceDocument.getDocumentTitle() +
                        "' is null, unable to proceed.");
    }

    // document's newMaintainable must contain an object (ie, not null)
    if (newMaintainable.getDataObject() == null) {
        throw new ValidationException("Maintainable's component data object is null.");
    }

    return success;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:29,代码来源:MaintenanceDocumentRuleBase.java

示例2: validateBusinessRules

import org.kuali.rice.krad.exception.ValidationException; //导入依赖的package包/类
@Override
public void validateBusinessRules(DocumentEvent event) {
    if (GlobalVariables.getMessageMap().hasErrors()) {
        logErrors();
        throw new ValidationException("errors occured before business rule");
    }

    // perform validation against rules engine
    LOG.info("invoking rules engine on document " + getDocumentNumber());
    boolean isValid = true;
    isValid = KRADServiceLocatorWeb.getKualiRuleService().applyRules(event);

    // check to see if the br eval passed or failed
    if (!isValid) {
        logErrors();
        // TODO: better error handling at the lower level and a better error message are
        // needed here
        throw new ValidationException("business rule evaluation failed");
    } else if (GlobalVariables.getMessageMap().hasErrors()) {
        logErrors();
        throw new ValidationException(
                "Unreported errors occured during business rule evaluation (rule developer needs to put meaningful error messages into global ErrorMap)");
    }
    LOG.debug("validation completed");

}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:27,代码来源:DocumentBase.java

示例3: saveDocument

import org.kuali.rice.krad.exception.ValidationException; //导入依赖的package包/类
@Override
    public Document saveDocument(Document document,
            Class<? extends DocumentEvent> kualiDocumentEventClass) throws WorkflowException, ValidationException {
        checkForNulls(document);
        if (kualiDocumentEventClass == null) {
            throw new IllegalArgumentException("invalid (null) kualiDocumentEventClass");
        }
        // if event is not an instance of a SaveDocumentEvent or a SaveOnlyDocumentEvent
        if (!SaveEvent.class.isAssignableFrom(kualiDocumentEventClass)) {
            throw new ConfigurationException("The KualiDocumentEvent class '" + kualiDocumentEventClass.getName() +
                    "' does not implement the class '" + SaveEvent.class.getName() + "'");
        }
//        if (!getDocumentActionFlags(document).getCanSave()) {
//            throw buildAuthorizationException("save", document);
//        }
        document.prepareForSave();
        Document savedDocument = validateAndPersistDocumentAndSaveAdHocRoutingRecipients(document,
                generateKualiDocumentEvent(document, kualiDocumentEventClass));
        prepareWorkflowDocument(savedDocument);
        getWorkflowDocumentService().save(savedDocument.getDocumentHeader().getWorkflowDocument(), null);

        UserSessionUtils.addWorkflowDocument(GlobalVariables.getUserSession(),
                savedDocument.getDocumentHeader().getWorkflowDocument());

        return savedDocument;
    }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:27,代码来源:DocumentServiceImpl.java

示例4: routeDocument

import org.kuali.rice.krad.exception.ValidationException; //导入依赖的package包/类
/**
 * @see org.kuali.rice.krad.service.DocumentService#routeDocument(org.kuali.rice.krad.document.Document,
 *      java.lang.String, java.util.List)
 */
@Override
public Document routeDocument(Document document, String annotation,
        List<AdHocRouteRecipient> adHocRecipients) throws ValidationException, WorkflowException {
    checkForNulls(document);
    //if (!getDocumentActionFlags(document).getCanRoute()) {
    //    throw buildAuthorizationException("route", document);
    //}
    document.prepareForSave();
    Document savedDocument = validateAndPersistDocument(document, new RouteDocumentEvent(document));
    prepareWorkflowDocument(savedDocument);
    getWorkflowDocumentService()
            .route(savedDocument.getDocumentHeader().getWorkflowDocument(), annotation, adHocRecipients);
    UserSessionUtils.addWorkflowDocument(GlobalVariables.getUserSession(),
            savedDocument.getDocumentHeader().getWorkflowDocument());
    removeAdHocPersonsAndWorkgroups(savedDocument);
    return savedDocument;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:DocumentServiceImpl.java

示例5: approveDocument

import org.kuali.rice.krad.exception.ValidationException; //导入依赖的package包/类
/**
 * @see org.kuali.rice.krad.service.DocumentService#approveDocument(org.kuali.rice.krad.document.Document,
 *      java.lang.String,
 *      java.util.List)
 */
@Override
public Document approveDocument(Document document, String annotation,
        List<AdHocRouteRecipient> adHocRecipients) throws ValidationException, WorkflowException {
    checkForNulls(document);
    //if (!getDocumentActionFlags(document).getCanApprove()) {
    //    throw buildAuthorizationException("approve", document);
    //}
    document.prepareForSave();
    Document savedDocument = validateAndPersistDocument(document, new ApproveDocumentEvent(document));
    prepareWorkflowDocument(savedDocument);
    getWorkflowDocumentService()
            .approve(savedDocument.getDocumentHeader().getWorkflowDocument(), annotation, adHocRecipients);
    UserSessionUtils.addWorkflowDocument(GlobalVariables.getUserSession(),
            savedDocument.getDocumentHeader().getWorkflowDocument());
    removeAdHocPersonsAndWorkgroups(savedDocument);
    return savedDocument;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:23,代码来源:DocumentServiceImpl.java

示例6: blanketApproveDocument

import org.kuali.rice.krad.exception.ValidationException; //导入依赖的package包/类
/**
 * @see org.kuali.rice.krad.service.DocumentService#blanketApproveDocument(org.kuali.rice.krad.document.Document,
 *      java.lang.String,
 *      java.util.List)
 */
@Override
public Document blanketApproveDocument(Document document, String annotation,
        List<AdHocRouteRecipient> adHocRecipients) throws ValidationException, WorkflowException {
    checkForNulls(document);
    //if (!getDocumentActionFlags(document).getCanBlanketApprove()) {
    //    throw buildAuthorizationException("blanket approve", document);
    //}
    document.prepareForSave();
    Document savedDocument = validateAndPersistDocument(document, new BlanketApproveDocumentEvent(document));
    prepareWorkflowDocument(savedDocument);
    getWorkflowDocumentService()
            .blanketApprove(savedDocument.getDocumentHeader().getWorkflowDocument(), annotation, adHocRecipients);
    UserSessionUtils.addWorkflowDocument(GlobalVariables.getUserSession(),
            savedDocument.getDocumentHeader().getWorkflowDocument());
    removeAdHocPersonsAndWorkgroups(savedDocument);
    return savedDocument;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:23,代码来源:DocumentServiceImpl.java

示例7: validateMaintenanceDocument

import org.kuali.rice.krad.exception.ValidationException; //导入依赖的package包/类
/**
 * This method checks to make sure the document is a valid maintenanceDocument, and has the necessary values
 * populated such that
 * it will not cause exceptions in later routing or business rules testing.
 *
 * This is not a business rules test.
 *
 * @param maintenanceDocument - document to be tested
 * @return whether maintenance doc passes
 * @throws org.kuali.rice.krad.exception.ValidationException
 *
 */
protected boolean validateMaintenanceDocument(MaintenanceDocument maintenanceDocument) {
    boolean success = true;
    Maintainable newMaintainable = maintenanceDocument.getNewMaintainableObject();

    // document must have a newMaintainable object
    if (newMaintainable == null) {
        throw new ValidationException(
                "Maintainable object from Maintenance Document '" + maintenanceDocument.getDocumentTitle() +
                        "' is null, unable to proceed.");
    }

    // document's newMaintainable must contain an object (ie, not null)
    if (newMaintainable.getDataObject() == null) {
        throw new ValidationException("Maintainable's component data object is null.");
    }

    return success;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:31,代码来源:MaintenanceDocumentRuleBase.java

示例8: verifyVersionNumber

import org.kuali.rice.krad.exception.ValidationException; //导入依赖的package包/类
@Override
public void verifyVersionNumber(Object dataObject) {
    if (isPersistable(dataObject.getClass())) {
        Object pbObject = businessObjectService.retrieve(dataObject);
        if ( dataObject instanceof Versioned ) {
         Long pbObjectVerNbr = KRADUtils.isNull(pbObject) ? null : ((Versioned) pbObject).getVersionNumber();
         Long newObjectVerNbr = ((Versioned) dataObject).getVersionNumber();
         if (pbObjectVerNbr != null && !(pbObjectVerNbr.equals(newObjectVerNbr))) {
             GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS,
                     RiceKeyConstants.ERROR_VERSION_MISMATCH);
             throw new ValidationException(
                     "Version mismatch between the local business object and the database business object");
         }
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:17,代码来源:KNSLegacyDataAdapterImpl.java

示例9: insertAccount

import org.kuali.rice.krad.exception.ValidationException; //导入依赖的package包/类
public ActionForward insertAccount(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    TravelDocumentForm2 travelForm = (TravelDocumentForm2) form;
    TravelAccount travAcct = (TravelAccount) KNSServiceLocator.getBusinessObjectService().retrieve(travelForm.getTravelAccount());
    // Make sure a travel account was actually retrieved.
    if (travAcct == null) {
    	GlobalVariables.getMessageMap().putError("travelAccount.number", RiceKeyConstants.ERROR_CUSTOM, "Invalid travel account number");
    	throw new ValidationException("Invalid travel account number");
    }
    // Insert the travel account into the list, if the list does not already contain it.
    boolean containsNewAcct = false;
    for (Iterator<TravelAccount> travAcctIter = ((TravelDocument2) travelForm.getDocument()).getTravelAccounts().iterator(); travAcctIter.hasNext();) {
    	if (travAcctIter.next().getNumber().equals(travAcct.getNumber())) {
    		containsNewAcct = true;
    		break;
    	}
    }
    if (!containsNewAcct) {
    	((TravelDocument2) travelForm.getDocument()).getTravelAccounts().add(travAcct);
    }
    travelForm.setTravelAccount(new TravelAccount());
    return mapping.findForward(RiceConstants.MAPPING_BASIC);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:23,代码来源:TravelDocumentAction2.java

示例10: postProcessSave

import org.kuali.rice.krad.exception.ValidationException; //导入依赖的package包/类
/**
 * @see org.kuali.rice.krad.document.DocumentBase#postProcessSave(org.kuali.rice.krad.rule.event.KualiDocumentEvent)
 */
@Override
public void postProcessSave(KualiDocumentEvent event) {
	super.postProcessSave(event);

	if (!(event instanceof SaveDocumentEvent)) { // don't lock until they
													// route
		ArrayList<Long> capitalAssetNumbers = new ArrayList<Long>();
		for (AssetPaymentAssetDetail assetPaymentAssetDetail : this.getAssetPaymentAssetDetail()) {
			if (assetPaymentAssetDetail.getCapitalAssetNumber() != null) {
				capitalAssetNumbers.add(assetPaymentAssetDetail.getCapitalAssetNumber());
			}
		}

		String documentTypeForLocking = CamsConstants.DocumentTypeName.ASSET_PAYMENT;
		if (this.isCapitalAssetBuilderOriginIndicator()) {
			documentTypeForLocking = CamsConstants.DocumentTypeName.ASSET_PAYMENT_FROM_CAB;
		}

		if (!this.getCapitalAssetManagementModuleService().storeAssetLocks(capitalAssetNumbers, this.getDocumentNumber(), documentTypeForLocking, null)) {
			throw new ValidationException("Asset " + capitalAssetNumbers.toString() + " is being locked by other documents.");
		}
	}
}
 
开发者ID:kuali,项目名称:kfs,代码行数:27,代码来源:AssetPaymentDocument.java

示例11: saveDocumentNoWorkFlow

import org.kuali.rice.krad.exception.ValidationException; //导入依赖的package包/类
/**
 * @see org.kuali.kfs.module.bc.document.service.BudgetDocumentService#saveDocumentNoWorkFlow(org.kuali.kfs.module.bc.document.BudgetConstructionDocument,
 *      org.kuali.kfs.module.bc.BCConstants.MonthSpreadDeleteType, boolean)
 */
@Transactional
public Document saveDocumentNoWorkFlow(BudgetConstructionDocument bcDoc, MonthSpreadDeleteType monthSpreadDeleteType, boolean doMonthRICheck) throws ValidationException {

    checkForNulls(bcDoc);

    bcDoc.prepareForSave();

    // validate and save the local objects not workflow objects
    // this eventually calls BudgetConstructionRules.processSaveDocument() which overrides the method in DocumentRuleBase
    if (doMonthRICheck) {
        validateAndPersistDocument(bcDoc, new SaveDocumentEvent(bcDoc));
    }
    else {
        validateAndPersistDocument(bcDoc, new DeleteMonthlySpreadEvent(bcDoc, monthSpreadDeleteType));
    }
    return bcDoc;
}
 
开发者ID:kuali,项目名称:kfs,代码行数:22,代码来源:BudgetDocumentServiceImpl.java

示例12: buildCashReceiptDoc

import org.kuali.rice.krad.exception.ValidationException; //导入依赖的package包/类
private CashReceiptDocument buildCashReceiptDoc(String campusCode, String description, String status, KualiDecimal currencyAmount, KualiDecimal checkAmount) throws WorkflowException {
    CashReceiptDocument crDoc = (CashReceiptDocument) SpringContext.getBean(DocumentService.class).getNewDocument(CashReceiptDocument.class);

    crDoc.getDocumentHeader().setDocumentDescription(description);
    crDoc.getFinancialSystemDocumentHeader().setFinancialDocumentStatusCode(status);

    crDoc.setCheckEntryMode(CashReceiptDocument.CHECK_ENTRY_TOTAL);
    crDoc.setTotalCheckAmount(checkAmount);

    crDoc.setCampusLocationCode(campusCode);

    crDoc.addSourceAccountingLine(CashReceiptFamilyTestUtil.buildSourceAccountingLine(crDoc.getDocumentNumber(), crDoc.getPostingYear(), crDoc.getNextSourceLineNumber()));

    try {
        SpringContext.getBean(DocumentService.class).saveDocument(crDoc);
    }
    catch (ValidationException e) {
        // If the business rule evaluation fails then give us more info for debugging this test.
        fail(e.getMessage() + ", " + GlobalVariables.getMessageMap());
    }
    return crDoc;
}
 
开发者ID:kuali,项目名称:kfs,代码行数:23,代码来源:CashReceiptServiceTest.java

示例13: createAndRouteContractManagerAssignmentDocument

import org.kuali.rice.krad.exception.ValidationException; //导入依赖的package包/类
private ContractManagerAssignmentDocument createAndRouteContractManagerAssignmentDocument(RequisitionDocument reqDoc) {
    ContractManagerAssignmentDocument acmDoc = null;
    try {
        acmDoc = (ContractManagerAssignmentDocument) documentService.getNewDocument(ContractManagerAssignmentDocument.class);
        List<ContractManagerAssignmentDetail> contractManagerAssignmentDetails = new ArrayList<ContractManagerAssignmentDetail>();
        ContractManagerAssignmentDetail detail = new ContractManagerAssignmentDetail(acmDoc, reqDoc);
        detail.setContractManagerCode(new Integer("10"));
        detail.refreshReferenceObject("contractManager");
        contractManagerAssignmentDetails.add(detail);
        acmDoc.setContractManagerAssignmentDetailss(contractManagerAssignmentDetails);
        acmDoc.getDocumentHeader().setDocumentDescription("batch-created");
        documentService.routeDocument(acmDoc, "Routing batch-created Contract Manager Assignment Document", null);
        ChangeWaiter waiter = new ChangeWaiter(documentService, acmDoc.getDocumentNumber(), "F");
        try {
            waiter.waitUntilChange(waiter, ROUTE_TO_FINAL_SECONDS_LIMIT, 5);
        } catch (Exception e) {
            throw new RuntimeException("ContractManagerAssignmentDocument timed out in routing to final.");
        }
    } catch (WorkflowException we) {
        we.printStackTrace();
    } catch (ValidationException ve) {
        ve.printStackTrace();
    }
    return acmDoc;
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:26,代码来源:PurapMassRequisitionStep.java

示例14: populateAndSavePaymentRequest

import org.kuali.rice.krad.exception.ValidationException; //导入依赖的package包/类
/**
 * @see org.kuali.ole.module.purap.document.service.PaymentRequestService#populateAndSavePaymentRequest(org.kuali.ole.module.purap.document.PaymentRequestDocument)
 */
@Override
public void populateAndSavePaymentRequest(PaymentRequestDocument preq) throws WorkflowException {
    try {
        preq.updateAndSaveAppDocStatus(PurapConstants.PaymentRequestStatuses.APPDOC_IN_PROCESS);
        documentService.saveDocument(preq, AttributedContinuePurapEvent.class);
        LOG.info("Payment request saved successfully" + preq.getDocumentNumber());
    } catch (ValidationException ve) {
        preq.updateAndSaveAppDocStatus(PurapConstants.PaymentRequestStatuses.APPDOC_INITIATE);
    } catch (WorkflowException we) {
        preq.updateAndSaveAppDocStatus(PurapConstants.PaymentRequestStatuses.APPDOC_INITIATE);

        String errorMsg = "Error saving document # " + preq.getDocumentHeader().getDocumentNumber() + " " + we.getMessage();
        LOG.error(errorMsg, we);
        throw new RuntimeException(errorMsg, we);
    }
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:20,代码来源:PaymentRequestServiceImpl.java

示例15: retransmitPurchaseOrderPDF

import org.kuali.rice.krad.exception.ValidationException; //导入依赖的package包/类
/**
 * @see org.kuali.ole.module.purap.document.service.PurchaseOrderService#retransmitPurchaseOrderPDF(org.kuali.ole.module.purap.document.PurchaseOrderDocument,
 * java.io.ByteArrayOutputStream)
 */
@Override
public void retransmitPurchaseOrderPDF(PurchaseOrderDocument po, ByteArrayOutputStream baosPDF) {

    String environment = kualiConfigurationService.getPropertyValueAsString(OLEConstants.ENVIRONMENT_KEY);
    List<PurchaseOrderItem> items = po.getItems();
    List<PurchaseOrderItem> retransmitItems = new ArrayList<PurchaseOrderItem>();
    for (PurchaseOrderItem item : items) {
        if (item.isItemSelectedForRetransmitIndicator()) {
            retransmitItems.add(item);
        }
    }
    Collection<String> generatePDFErrors = printService.generatePurchaseOrderPdfForRetransmission(po, baosPDF, environment, retransmitItems);

    if (generatePDFErrors.size() > 0) {
        addStringErrorMessagesToMessageMap(PurapKeyConstants.ERROR_PURCHASE_ORDER_PDF, generatePDFErrors);
        throw new ValidationException("found errors while trying to print po with doc id " + po.getDocumentNumber());
    }
    po.setPurchaseOrderLastTransmitTimestamp(dateTimeService.getCurrentTimestamp());
    purapService.saveDocumentNoValidation(po);
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:25,代码来源:PurchaseOrderServiceImpl.java


注:本文中的org.kuali.rice.krad.exception.ValidationException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。