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