001 /**
002 * Copyright 2005-2013 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
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")
032 public 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 int routeLevelCount = 0;
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 int readAccessCount = 0;
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 int getRouteLevelCount() {
060 readAccessCount += 1;
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 /**
079 * @return the readAccessCount
080 */
081 public int getReadAccessCount() {
082 return this.readAccessCount;
083 }
084
085 /**
086 * Overridden to make the document state change as route levels occur
087 *
088 * @see org.kuali.rice.krad.document.DocumentBase#doRouteLevelChange(org.kuali.rice.kew.framework.postprocessor.DocumentRouteLevelChange)
089 */
090 @Override
091 public void doRouteLevelChange(DocumentRouteLevelChange levelChangeEvent) {
092 super.doRouteLevelChange(levelChangeEvent);
093 routeLevelCount += 1;
094 if (routedString == null) {
095 routedString = heldRoutedString;
096 }
097 LOG.info("Performing route level change on SearchAttributeIndexTestDocument; routeLevelCount is "+routeLevelCount);
098 }
099
100 }