001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.module.chart.lookup;
017:
018: import java.util.Map;
019: import java.util.Properties;
020:
021: import org.kuali.core.bo.BusinessObject;
022: import org.kuali.core.lookup.KualiLookupableHelperServiceImpl;
023: import org.kuali.core.util.UrlFactory;
024: import org.kuali.kfs.KFSConstants;
025: import org.kuali.module.chart.bo.DelegateGlobal;
026:
027: /**
028: * This class overrides the getBackLocation, getReturnUrl, setFieldConversions and getActionUrls for
029: * {@link OrganizationRoutingModelName}
030: */
031: public class OrganizationRoutingModelNameLookupableHelperServiceImpl
032: extends KualiLookupableHelperServiceImpl {
033: private boolean initializingDelegate = true;
034:
035: /**
036: * Overrides the base implementation to always return to {@link KFSConstants.MAINTENANCE_ACTION}
037: *
038: * @see org.kuali.core.lookup.AbstractLookupableHelperServiceImpl#getBackLocation()
039: */
040: @Override
041: public String getBackLocation() {
042: // it doesn't really matter what the backLocation is set to; we're
043: // always going to return to the maintenance screen
044: return KFSConstants.MAINTENANCE_ACTION;
045: }
046:
047: /**
048: * Overrides the base implementation to add in new parameters to the return url
049: * <ul>
050: * <li>{@link KFSConstants.DISPATCH_REQUEST_PARAMETER}</li>
051: * <li>{@link KFSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE}</li>
052: * <li>{@link KFSConstants.OVERRIDE_KEYS}</li>
053: * </ul>
054: * {@link KFSConstants.DISPATCH_REQUEST_PARAMETER}
055: *
056: * @see org.kuali.core.lookup.AbstractLookupableHelperServiceImpl#getReturnUrl(org.kuali.core.bo.BusinessObject, java.util.Map,
057: * java.lang.String)
058: */
059: @Override
060: public String getReturnUrl(BusinessObject businessObject,
061: Map fieldConversions, String lookupImpl) {
062: Properties parameters = getParameters(businessObject,
063: fieldConversions, lookupImpl);
064: parameters.put(KFSConstants.DISPATCH_REQUEST_PARAMETER,
065: KFSConstants.MAINTENANCE_NEWWITHEXISTING_ACTION);
066: parameters.put(KFSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE,
067: DelegateGlobal.class.getName());
068: parameters.put(KFSConstants.OVERRIDE_KEYS, "modelName"
069: + KFSConstants.FIELD_CONVERSIONS_SEPERATOR
070: + "modelChartOfAccountsCode"
071: + KFSConstants.FIELD_CONVERSIONS_SEPERATOR
072: + "modelOrganizationCode");
073: return UrlFactory.parameterizeUrl(
074: KFSConstants.MAINTENANCE_ACTION, parameters);
075: }
076:
077: /**
078: * Overrides base implementation to determine whether or not we are dealing with looking up the model or editing it
079: *
080: * @see org.kuali.core.lookup.AbstractLookupableHelperServiceImpl#setFieldConversions(java.util.Map)
081: */
082: @Override
083: public void setFieldConversions(Map fieldConversions) {
084: super .setFieldConversions(fieldConversions);
085: if (fieldConversions == null || fieldConversions.size() == 0) {
086: // if we don't have any field conversions, then we must be
087: // actually dealing with the model, instead of looking up the model
088: // in order to initalize a new global account delegate
089: //
090: // yeah, it's a hack...but at least a semi-clever hack
091: initializingDelegate = false;
092: }
093: }
094:
095: /**
096: * Overrides base implementation to remove the action urls if we are initializing the delegate model
097: *
098: * @see org.kuali.core.lookup.AbstractLookupableHelperServiceImpl#getActionUrls(org.kuali.core.bo.BusinessObject)
099: */
100: @Override
101: public String getActionUrls(BusinessObject businessObject) {
102: if (!initializingDelegate) {
103: return super .getActionUrls(businessObject);
104: } else {
105: return "";
106: }
107: }
108: }
|