View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.test.document;
17  
18  import javax.persistence.Column;
19  import javax.persistence.Entity;
20  import javax.persistence.Table;
21  
22  import org.kuali.rice.kew.framework.postprocessor.DocumentRouteLevelChange;
23  import org.kuali.rice.krad.document.TransactionalDocumentBase;
24  
25  /**
26   * Mock document for testing how document search carries out indexing 
27   * 
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   */
30  @Entity
31  @Table(name="TST_SEARCH_ATTR_INDX_TST_DOC_T")
32  public class SearchAttributeIndexTestDocument extends TransactionalDocumentBase {
33  	static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(SearchAttributeIndexTestDocument.class);
34  	private static final long serialVersionUID = -2290510385815271758L;
35  	@Column(name="RTE_LVL_CNT")
36  	private Long routeLevelCount = 0L;
37  	@Column(name="CNSTNT_STR")
38  	private String constantString;
39  	@Column(name="RTD_STR")
40  	private String routedString;
41  	@Column(name="HLD_RTD_STR")
42  	private String heldRoutedString;
43  	@Column(name="RD_ACCS_CNT")
44  	private Long readAccessCount = 0L;
45  	
46  	/**
47  	 * Constructor for the document which sets the constant string and keeps a hole of the routedString
48  	 * @param constantString the constant String to set
49  	 * @param routedString the routed String to hold on to, but not set until routing has occurred
50  	 */
51  	public void initialize(String constantString, String routedString) {
52  		this.constantString = constantString;
53  		this.heldRoutedString = routedString;
54  	}
55  	
56  	/**
57  	 * @return the count of how many route levels have been passed
58  	 */
59  	public Long getRouteLevelCount() {
60  		readAccessCount += 1L;
61  		return routeLevelCount;
62  	}
63  	
64  	/**
65  	 * @return a constant String
66  	 */
67  	public String getConstantString() {
68  		return constantString;
69  	}
70  	
71  	/**
72  	 * @return a routed String
73  	 */
74  	public String getRoutedString() {
75  		return routedString;
76  	}
77  
78      public String getHeldRoutedString() {
79          return heldRoutedString;
80      }
81  
82      /**
83  	 * @return the readAccessCount
84  	 */
85  	public Long getReadAccessCount() {
86  		return this.readAccessCount;
87  	}
88  
89  	/**
90  	 * Overridden to make the document state change as route levels occur
91  	 * 
92  	 * @see org.kuali.rice.krad.document.DocumentBase#doRouteLevelChange(org.kuali.rice.kew.framework.postprocessor.DocumentRouteLevelChange)
93  	 */
94  	@Override
95  	public void doRouteLevelChange(DocumentRouteLevelChange levelChangeEvent) {
96  		super.doRouteLevelChange(levelChangeEvent);
97  		routeLevelCount += 1L;
98  		if (routedString == null) {
99  			routedString = heldRoutedString;
100 		}
101 		LOG.info("Performing route level change on SearchAttributeIndexTestDocument; routeLevelCount is "+routeLevelCount);
102 	}
103 	
104 }