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


Java KNSGlobalVariables.setKualiForm方法代码示例

本文整理汇总了Java中org.kuali.rice.kns.util.KNSGlobalVariables.setKualiForm方法的典型用法代码示例。如果您正苦于以下问题:Java KNSGlobalVariables.setKualiForm方法的具体用法?Java KNSGlobalVariables.setKualiForm怎么用?Java KNSGlobalVariables.setKualiForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kuali.rice.kns.util.KNSGlobalVariables的用法示例。


在下文中一共展示了KNSGlobalVariables.setKualiForm方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createNewKualiMaintenanceForm

import org.kuali.rice.kns.util.KNSGlobalVariables; //导入方法依赖的package包/类
/**
 * Creates a KualiMaintenanceForm with the given rule template inside of its RuleBaseValues instance.
 * 
 * @param rtName The rule template to use.
 */
private void createNewKualiMaintenanceForm(String rtName) {
	// Initialize the required variables.
	final KualiMaintenanceForm kmForm = new KualiMaintenanceForm();
	final MaintenanceDocument maintDoc = new MaintenanceDocumentBase();
	final Maintainable oldMaint = new RoutingRuleMaintainable();
	final Maintainable newMaint = new RoutingRuleMaintainable();
	final RuleBaseValues rbValues = new RuleBaseValues();
	// Setup the rule base and the maintainables.
	rbValues.setRuleTemplate(KEWServiceLocator.getRuleTemplateService().findByRuleTemplateName(rtName));
	oldMaint.setBusinessObject(rbValues);
	oldMaint.setBoClass(rbValues.getClass());
	newMaint.setBusinessObject(rbValues);
	newMaint.setBoClass(rbValues.getClass());
	// Setup the maintenance document and the maintenance form.
	maintDoc.setOldMaintainableObject(oldMaint);
	maintDoc.setNewMaintainableObject(newMaint);
	kmForm.setDocument(maintDoc);
	KNSGlobalVariables.setKualiForm(kmForm);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:RuleTemplateDefaultsTest.java

示例2: testCorrectKeyValuesReturnedBasedOnKualiFormInstance

import org.kuali.rice.kns.util.KNSGlobalVariables; //导入方法依赖的package包/类
/**
 * Tests to ensure that the proper key values are returned based upon the class type of the currently-set Kuali form.
 * 
 * @throws Exception
 */
@Test public void testCorrectKeyValuesReturnedBasedOnKualiFormInstance() throws Exception {
	// First, check that the proper values are returned when the Kuali form is *not* a KualiMaintenanceForm.
	KNSGlobalVariables.setKualiForm(new KualiForm());
	assertRuleTemplateHasExpectedKeyValues(
			createExpectedKeysSet(true, true, true, true),
			createSetOfKeyValueKeys((new RuleMaintenanceActionRequestCodeValuesFinder()).getKeyValues()));
	// Next, check that the proper values are returned when the Kuali form is a KualiMaintenanceForm containing a given rule template.
	loadXmlFile("RT_ValidRuleTemplatesWithVaryingDefaults.xml");
	createNewKualiMaintenanceForm("Test_Rule_Template2");
	assertRuleTemplateHasExpectedKeyValues(
			createExpectedKeysSet(false, false, false, true),
			createSetOfKeyValueKeys((new RuleMaintenanceActionRequestCodeValuesFinder()).getKeyValues()));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:RuleTemplateDefaultsTest.java

示例3: processPopulate

import org.kuali.rice.kns.util.KNSGlobalVariables; //导入方法依赖的package包/类
/**
 * Hooks into populate process to call form populate method if form is an
 * instanceof PojoForm.
 */
@Override
protected void processPopulate(HttpServletRequest request, HttpServletResponse response, ActionForm form, ActionMapping mapping) throws ServletException {
	if (form instanceof KualiForm) {
		// Add the ActionForm to GlobalVariables
		// This will allow developers to retrieve both the Document and any
		// request parameters that are not
		// part of the Form and make them available in ValueFinder classes
		// and other places where they are needed.
		KNSGlobalVariables.setKualiForm((KualiForm) form);
	}

	// if not PojoForm, call struts populate
	if (!(form instanceof PojoForm)) {
		super.processPopulate(request, response, form, mapping);
		return;
	}

	final String previousRequestGuid = request.getParameter(KualiRequestProcessor.PREVIOUS_REQUEST_EDITABLE_PROPERTIES_GUID_PARAMETER_NAME);

	((PojoForm)form).clearEditablePropertyInformation();
	((PojoForm)form).registerStrutsActionMappingScope(mapping.getScope());

	String multipart = mapping.getMultipartClass();
	if (multipart != null) {
		request.setAttribute(Globals.MULTIPART_KEY, multipart);
	}

	form.setServlet(this.servlet);
	form.reset(mapping, request);

	((PojoForm)form).setPopulateEditablePropertiesGuid(previousRequestGuid);
	// call populate on ActionForm
	((PojoForm) form).populate(request);
	request.setAttribute("UnconvertedValues", ((PojoForm) form).getUnconvertedValues().keySet());
	request.setAttribute("UnconvertedHash", ((PojoForm) form).getUnconvertedValues());
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:41,代码来源:KualiRequestProcessor.java

示例4: processPopulate

import org.kuali.rice.kns.util.KNSGlobalVariables; //导入方法依赖的package包/类
/**
 * Hooks into populate process to call form populate method if form is an
 * instanceof PojoForm.
 */
@Override
protected void processPopulate(HttpServletRequest request, HttpServletResponse response, ActionForm form, ActionMapping mapping) throws ServletException {
	if (form instanceof KualiForm) {
		// Add the ActionForm to GlobalVariables
		// This will allow developers to retrieve both the Document and any
		// request parameters that are not
		// part of the Form and make them available in ValueFinder classes
		// and other places where they are needed.
		KNSGlobalVariables.setKualiForm((KualiForm) form);
	}

	// if not PojoForm, call struts populate
	if (!(form instanceof PojoForm)) {
		super.processPopulate(request, response, form, mapping);
		return;
	}
	
	final String previousRequestGuid = request.getParameter(KualiRequestProcessor.PREVIOUS_REQUEST_EDITABLE_PROPERTIES_GUID_PARAMETER_NAME);

	((PojoForm)form).clearEditablePropertyInformation();
	((PojoForm)form).registerStrutsActionMappingScope(mapping.getScope());
	
	String multipart = mapping.getMultipartClass();
	if (multipart != null) {
		request.setAttribute(Globals.MULTIPART_KEY, multipart);
	}

	form.setServlet(this.servlet);
	form.reset(mapping, request);

	((PojoForm)form).setPopulateEditablePropertiesGuid(previousRequestGuid);
	// call populate on ActionForm
	((PojoForm) form).populate(request);
	request.setAttribute("UnconvertedValues", ((PojoForm) form).getUnconvertedValues().keySet());
	request.setAttribute("UnconvertedHash", ((PojoForm) form).getUnconvertedValues());
}
 
开发者ID:kuali,项目名称:rice,代码行数:41,代码来源:KualiRequestProcessor.java

示例5: execute

import org.kuali.rice.kns.util.KNSGlobalVariables; //导入方法依赖的package包/类
/**
 * Entry point to all actions.
 *
 * NOTE: No need to hook into execute for handling framework setup anymore. Just implement the methodToCall for the framework
 * setup, Constants.METHOD_REQUEST_PARAMETER will contain the full parameter, which can be sub stringed for getting framework
 * parameters.
 *
 * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm,
 *      javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    ActionForward returnForward = null;

    String methodToCall = findMethodToCall(form, request);
    
    if(isModuleLocked(form, methodToCall, request)) {
        return mapping.findForward(RiceConstants.MODULE_LOCKED_MAPPING);
    }
    
    if (form instanceof KualiForm && StringUtils.isNotEmpty(((KualiForm) form).getMethodToCall())) {
        if (StringUtils.isNotBlank(getImageContext(request, KRADConstants.ANCHOR))) {
            ((KualiForm) form).setAnchor(getImageContext(request, KRADConstants.ANCHOR));
        }
        else if (StringUtils.isNotBlank(request.getParameter(KRADConstants.ANCHOR))) {
            ((KualiForm) form).setAnchor(request.getParameter(KRADConstants.ANCHOR));
        }
        else {
            ((KualiForm) form).setAnchor(KRADConstants.ANCHOR_TOP_OF_FORM);
        }
    }
    // if found methodToCall, pass control to that method, else return the basic forward
    if (StringUtils.isNotBlank(methodToCall)) {
        if ( LOG.isDebugEnabled() ) {
            LOG.debug("methodToCall: '" + methodToCall+"'");
        }
        returnForward = dispatchMethod(mapping, form, request, response, methodToCall);
        if ( returnForward!=null && returnForward.getRedirect() && returnForward.getName()!=null && returnForward.getName().equals(KRADConstants.KRAD_INITIATED_DOCUMENT_VIEW_NAME)) {
            return returnForward;
        }
    }
    else {
        returnForward = defaultDispatch(mapping, form, request, response);
    }

    // make sure the user can do what they're trying to according to the module that owns the functionality
    if ( !methodToCallsToNotCheckAuthorization.contains(methodToCall) ) {
        if ( LOG.isDebugEnabled() ) {
            LOG.debug( "'" + methodToCall + "' not in set of excempt methods: " + methodToCallsToNotCheckAuthorization);
        }
        checkAuthorization(form, methodToCall);
    } else {
        if ( LOG.isDebugEnabled() ) {
            LOG.debug("'" + methodToCall + "' is exempt from auth checks." );
        }
    }

    // Add the ActionForm to GlobalVariables
    // This will allow developers to retrieve both the Document and any request parameters that are not
    // part of the Form and make them available in ValueFinder classes and other places where they are needed.
    if(KNSGlobalVariables.getKualiForm() == null) {
        KNSGlobalVariables.setKualiForm((KualiForm)form);
    }

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

示例6: process

import org.kuali.rice.kns.util.KNSGlobalVariables; //导入方法依赖的package包/类
@Override
public void process(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
	if ( LOG.isInfoEnabled() ) {
		LOG.info(new StringBuffer("Started processing request: '").append(request.getRequestURI()).append("' w/ query string: '").append(request.getQueryString()).append("'"));
	}

	try {
		strutsProcess(request, response);
	} catch (FileUploadLimitExceededException e) {
		ActionForward actionForward = processException(request, response, e, e.getActionForm(), e.getActionMapping());
		processForwardConfig(request, response, actionForward);
	} finally {
		KNSGlobalVariables.setKualiForm(null);
	}

	try {
		ActionForm form = WebUtils.getKualiForm(request);

		if (form != null && form instanceof KualiDocumentFormBase) {
			String docId = ((KualiDocumentFormBase) form).getDocId();
			if (docId != null) { MDC.put(MDC_DOC_ID, docId); }
		}

		String refreshCaller = request.getParameter(KRADConstants.REFRESH_CALLER);
		if (form!=null && KualiDocumentFormBase.class.isAssignableFrom(form.getClass())
				&& !KRADConstants.QUESTION_REFRESH.equalsIgnoreCase(refreshCaller)) {
			KualiDocumentFormBase docForm = (KualiDocumentFormBase) form;
			Document document = docForm.getDocument();
			String docFormKey = docForm.getFormKey();

			UserSession userSession = (UserSession) request.getSession().getAttribute(KRADConstants.USER_SESSION_KEY);

			if (WebUtils.isDocumentSession(document, docForm)) {
				getSessionDocumentService().setDocumentForm(docForm, userSession, request.getRemoteAddr());
			}

			Boolean exitingDocument = (Boolean) request.getAttribute(KRADConstants.EXITING_DOCUMENT);

			if (exitingDocument != null && exitingDocument.booleanValue()) {
				// remove KualiDocumentFormBase object from session and
				// table.
				getSessionDocumentService().purgeDocumentForm(docForm.getDocument().getDocumentNumber(), docFormKey, userSession, request.getRemoteAddr());
			}
		}

		if ( LOG.isInfoEnabled() ) {
			LOG.info(new StringBuffer("Finished processing request: '").append(request.getRequestURI()).append("' w/ query string: '").append(request.getQueryString()).append("'"));
		}

	} finally {
		// MDC docId key is set above, and also during super.process() in the call to processActionForm
		MDC.remove(MDC_DOC_ID);
	}

}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:56,代码来源:KualiRequestProcessor.java

示例7: testCalculateDailyTotal_oneDay

import org.kuali.rice.kns.util.KNSGlobalVariables; //导入方法依赖的package包/类
/**
 *
 * This method tests calculateDailyTotal using a single per diem expense.
 */
public final void testCalculateDailyTotal_oneDay() {
    TravelReimbursementDocument trDoc = new TravelReimbursementDocument();
    TravelFormBase form = new TravelReimbursementForm();
    form.setDocument(trDoc);
    KNSGlobalVariables.setKualiForm(form);

    PerDiemExpense perDiemExpense = new PerDiemExpense() {

        @Override
        public MileageRate getMileageRate(java.sql.Date effectiveDate) {
            MileageRate rate = new MileageRate();
            rate.setRate(new BigDecimal(0.45));
            rate.setExpenseTypeCode("MP");
            return rate;
        }
    };

    perDiemExpense.setProrated(false);
    //perDiemExpense.setPersonal(true);

    perDiemExpense.setMiles(0);
    perDiemExpense.setBreakfast(false);
    perDiemExpense.setLunch(false);
    perDiemExpense.setDinner(false);
    Map<String, KualiDecimal> dailyTotal = travelDocumentService.calculateDailyTotal(perDiemExpense);

    assertEquals(KualiDecimal.ZERO, dailyTotal.get(MILEAGE_TOTAL_ATTRIBUTE));
    assertEquals(KualiDecimal.ZERO, dailyTotal.get(LODGING_TOTAL_ATTRIBUTE));
    assertEquals(KualiDecimal.ZERO, dailyTotal.get(MEALS_AND_INC_TOTAL_ATTRIBUTE));

    perDiemExpense.setPersonal(false);
    perDiemExpense.setMiles(20);
    perDiemExpense.setLodging(new KualiDecimal(575.00));

    perDiemExpense.setBreakfast(true);
    perDiemExpense.setLunch(true);
    perDiemExpense.setDinner(true);
    perDiemExpense.setBreakfastValue(new KualiDecimal(12));
    perDiemExpense.setLunchValue(new KualiDecimal(13));
    perDiemExpense.setDinnerValue(new KualiDecimal(25));
    perDiemExpense.setIncidentalsValue(new KualiDecimal(10));

    dailyTotal = travelDocumentService.calculateDailyTotal(perDiemExpense);
    assertEquals(new KualiDecimal(9), dailyTotal.get(MILEAGE_TOTAL_ATTRIBUTE));
    assertEquals(new KualiDecimal(575.00), dailyTotal.get(LODGING_TOTAL_ATTRIBUTE));
    assertEquals(new KualiDecimal(60), dailyTotal.get(MEALS_AND_INC_TOTAL_ATTRIBUTE));

}
 
开发者ID:kuali,项目名称:kfs,代码行数:53,代码来源:TravelDocumentServiceTest.java

示例8: process

import org.kuali.rice.kns.util.KNSGlobalVariables; //导入方法依赖的package包/类
@Override
public void process(final HttpServletRequest request,
        final HttpServletResponse response) throws IOException, ServletException {
    // indicates that we are running in legacy KNS context
    LegacyUtils.beginLegacyContext();
    try {
        if (LOG.isInfoEnabled()) {
            LOG.info(new StringBuffer("Started processing request: '").append(request.getRequestURI()).append(
                    "' w/ query string: '").append(request.getQueryString()).append("'"));
        }

        try {
            strutsProcess(request, response);
        } catch (FileUploadLimitExceededException e) {
            ActionForward actionForward = processException(request, response, e, e.getActionForm(),
                    e.getActionMapping());
            processForwardConfig(request, response, actionForward);
        } finally {
            KNSGlobalVariables.setKualiForm(null);
        }

        try {
            ActionForm form = WebUtils.getKualiForm(request);

            if (form != null && form instanceof KualiDocumentFormBase) {
                String docId = ((KualiDocumentFormBase) form).getDocId();
                if (docId != null) {
                    MDC.put(MDC_DOC_ID, docId);
                }
            }

            String refreshCaller = request.getParameter(KRADConstants.REFRESH_CALLER);
            if (form != null && KualiDocumentFormBase.class.isAssignableFrom(form.getClass()) && !KRADConstants
                    .QUESTION_REFRESH.equalsIgnoreCase(refreshCaller)) {
                KualiDocumentFormBase docForm = (KualiDocumentFormBase) form;
                Document document = docForm.getDocument();
                String docFormKey = docForm.getFormKey();

                UserSession userSession = (UserSession) request.getSession().getAttribute(
                        KRADConstants.USER_SESSION_KEY);

                if (WebUtils.isDocumentSession(document, docForm)) {
                    getSessionDocumentService().setDocumentForm(docForm, userSession, request.getRemoteAddr());
                }

                Boolean exitingDocument = (Boolean) request.getAttribute(KRADConstants.EXITING_DOCUMENT);

                if (exitingDocument != null && exitingDocument.booleanValue()) {
                    // remove KualiDocumentFormBase object from session and
                    // table.
                    getSessionDocumentService().purgeDocumentForm(docForm.getDocument().getDocumentNumber(),
                            docFormKey, userSession, request.getRemoteAddr());
                }
            }

            if (LOG.isInfoEnabled()) {
                LOG.info(new StringBuffer("Finished processing request: '").append(request.getRequestURI()).append(
                        "' w/ query string: '").append(request.getQueryString()).append("'"));
            }

        } finally {
            // MDC docId key is set above, and also during super.process() in the call to processActionForm
            MDC.remove(MDC_DOC_ID);
        }
    } finally {
        LegacyUtils.endLegacyContext();
    }
}
 
开发者ID:kuali,项目名称:rice,代码行数:69,代码来源:KualiRequestProcessor.java


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