View Javadoc

1   /*
2    * Copyright 2009 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.dto.DocumentRouteLevelChangeDTO;
23  import org.kuali.rice.krad.document.TransactionalDocumentBase;
24  import org.kuali.rice.krad.workflow.SearchAttributeIndexRequestTest;
25  
26  /**
27   * Mock document for testing how document search carries out indexing 
28   * 
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   *
31   */
32  @Entity
33  @Table(name="TST_SEARCH_ATTR_INDX_TST_DOC_T")
34  public class SearchAttributeIndexTestDocument extends TransactionalDocumentBase {
35  	static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(SearchAttributeIndexRequestTest.class);
36  	private static final long serialVersionUID = -2290510385815271758L;
37  	@Column(name="RTE_LVL_CNT")
38  	private int routeLevelCount = 0;
39  	@Column(name="CNSTNT_STR")
40  	private String constantString;
41  	@Column(name="RTD_STR")
42  	private String routedString;
43  	@Column(name="HLD_RTD_STR")
44  	private String heldRoutedString;
45  	@Column(name="RD_ACCS_CNT")
46  	private int readAccessCount = 0;
47  	
48  	/**
49  	 * Constructor for the document which sets the constant string and keeps a hole of the routedString
50  	 * @param constantString the constant String to set
51  	 * @param routedString the routed String to hold on to, but not set until routing has occurred
52  	 */
53  	public void initialize(String constantString, String routedString) {
54  		this.constantString = constantString;
55  		this.heldRoutedString = routedString;
56  	}
57  	
58  	/**
59  	 * @return the count of how many route levels have been passed
60  	 */
61  	public int getRouteLevelCount() {
62  		readAccessCount += 1;
63  		return routeLevelCount;
64  	}
65  	
66  	/**
67  	 * @return a constant String
68  	 */
69  	public String getConstantString() {
70  		return constantString;
71  	}
72  	
73  	/**
74  	 * @return a routed String
75  	 */
76  	public String getRoutedString() {
77  		return routedString;
78  	}
79  	
80  	/**
81  	 * @return the readAccessCount
82  	 */
83  	public int getReadAccessCount() {
84  		return this.readAccessCount;
85  	}
86  
87  	/**
88  	 * Overridden to make the document state change as route levels occur
89  	 * 
90  	 * @see org.kuali.rice.krad.document.DocumentBase#doRouteLevelChange(org.kuali.rice.kew.dto.DocumentRouteLevelChangeDTO)
91  	 */
92  	@Override
93  	public void doRouteLevelChange(DocumentRouteLevelChangeDTO levelChangeEvent) {
94  		super.doRouteLevelChange(levelChangeEvent);
95  		routeLevelCount += 1;
96  		if (routedString == null) {
97  			routedString = heldRoutedString;
98  		}
99  		LOG.info("Performing route level change on SearchAttributeIndexTestDocument; routeLevelCount is "+routeLevelCount);
100 	}
101 	
102 }