001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.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/ecl2.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.kfs.module.ar.document; 017 018 import java.util.ArrayList; 019 import java.util.List; 020 021 import org.kuali.kfs.module.ar.businessobject.CustomerInvoiceItemCode; 022 import org.kuali.rice.kns.bo.PersistableBusinessObject; 023 import org.kuali.rice.kns.document.MaintenanceLock; 024 import org.kuali.rice.kns.util.KNSConstants; 025 import org.kuali.rice.kns.util.ObjectUtils; 026 027 public class CustomerInvoiceItemCodeMaintainableImplUtil { 028 029 public final static String CHART_OF_ACCOUNTS_CODE_FIELD = "chartOfAccountsCode"; 030 public final static String ORGANIZATION_CODE_FIELD = "organizationCode"; 031 032 /** 033 * This utility is used for creating the special lock for customer invoice item code to ensure that 034 * no invoice item codes are created if a organization option maint. doc is pending with the same 035 * chart and organization. 036 */ 037 public static List<MaintenanceLock> generateCustomerInvoiceItemCodeMaintenanceLocks(PersistableBusinessObject bo, String documentNumber) { 038 039 List<MaintenanceLock> maintenanceLocks = new ArrayList<MaintenanceLock>(); 040 StringBuilder lockRepresentation = new StringBuilder(CustomerInvoiceItemCode.class.getName()); 041 lockRepresentation.append(KNSConstants.Maintenance.AFTER_CLASS_DELIM); 042 043 //get chart of accounts code locking representation 044 String chartOfAccountsCode = String.valueOf(ObjectUtils.getPropertyValue(bo, CHART_OF_ACCOUNTS_CODE_FIELD)); 045 lockRepresentation.append(CHART_OF_ACCOUNTS_CODE_FIELD); 046 lockRepresentation.append(KNSConstants.Maintenance.AFTER_FIELDNAME_DELIM); 047 lockRepresentation.append(chartOfAccountsCode); 048 049 //get organization code locking representation 050 String organizationCode = String.valueOf(ObjectUtils.getPropertyValue(bo, ORGANIZATION_CODE_FIELD)); 051 lockRepresentation.append(ORGANIZATION_CODE_FIELD); 052 lockRepresentation.append(KNSConstants.Maintenance.AFTER_FIELDNAME_DELIM); 053 lockRepresentation.append(organizationCode); 054 055 MaintenanceLock maintenanceLock = new MaintenanceLock(); 056 maintenanceLock.setDocumentNumber(documentNumber); 057 maintenanceLock.setLockingRepresentation(lockRepresentation.toString()); 058 maintenanceLocks.add(maintenanceLock); 059 return maintenanceLocks; 060 } 061 062 }