001 /** 002 * Copyright 2005-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.rice.krad.test.document; 017 018 import javax.persistence.Column; 019 import javax.persistence.Entity; 020 import javax.persistence.Table; 021 022 import org.kuali.rice.kew.framework.postprocessor.DocumentRouteLevelChange; 023 import org.kuali.rice.krad.document.TransactionalDocumentBase; 024 import org.kuali.rice.krad.workflow.SearchAttributeIndexRequestTest; 025 026 /** 027 * Mock document for testing how document search carries out indexing 028 * 029 * @author Kuali Rice Team (rice.collab@kuali.org) 030 * 031 */ 032 @Entity 033 @Table(name="TST_SEARCH_ATTR_INDX_TST_DOC_T") 034 public class SearchAttributeIndexTestDocument extends TransactionalDocumentBase { 035 static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(SearchAttributeIndexRequestTest.class); 036 private static final long serialVersionUID = -2290510385815271758L; 037 @Column(name="RTE_LVL_CNT") 038 private int routeLevelCount = 0; 039 @Column(name="CNSTNT_STR") 040 private String constantString; 041 @Column(name="RTD_STR") 042 private String routedString; 043 @Column(name="HLD_RTD_STR") 044 private String heldRoutedString; 045 @Column(name="RD_ACCS_CNT") 046 private int readAccessCount = 0; 047 048 /** 049 * Constructor for the document which sets the constant string and keeps a hole of the routedString 050 * @param constantString the constant String to set 051 * @param routedString the routed String to hold on to, but not set until routing has occurred 052 */ 053 public void initialize(String constantString, String routedString) { 054 this.constantString = constantString; 055 this.heldRoutedString = routedString; 056 } 057 058 /** 059 * @return the count of how many route levels have been passed 060 */ 061 public int getRouteLevelCount() { 062 readAccessCount += 1; 063 return routeLevelCount; 064 } 065 066 /** 067 * @return a constant String 068 */ 069 public String getConstantString() { 070 return constantString; 071 } 072 073 /** 074 * @return a routed String 075 */ 076 public String getRoutedString() { 077 return routedString; 078 } 079 080 /** 081 * @return the readAccessCount 082 */ 083 public int getReadAccessCount() { 084 return this.readAccessCount; 085 } 086 087 /** 088 * Overridden to make the document state change as route levels occur 089 * 090 * @see org.kuali.rice.krad.document.DocumentBase#doRouteLevelChange(org.kuali.rice.kew.framework.postprocessor.DocumentRouteLevelChange) 091 */ 092 @Override 093 public void doRouteLevelChange(DocumentRouteLevelChange levelChangeEvent) { 094 super.doRouteLevelChange(levelChangeEvent); 095 routeLevelCount += 1; 096 if (routedString == null) { 097 routedString = heldRoutedString; 098 } 099 LOG.info("Performing route level change on SearchAttributeIndexTestDocument; routeLevelCount is "+routeLevelCount); 100 } 101 102 }