001: /*
002: * Copyright (c) 1998 - 2005 Versant Corporation
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * Versant Corporation - initial API and implementation
010: */
011: package com.versant.core.storagemanager.logging;
012:
013: import com.versant.core.jdo.QueryDetails;
014: import com.versant.core.metadata.ModelMetaData;
015: import com.versant.core.metadata.ClassMetaData;
016: import com.versant.core.server.CompiledQuery;
017:
018: /**
019: * An event logged for compiling and executing a query.
020: */
021: public class SmQueryEvent extends SmStatesReturnedEvent {
022:
023: private String language;
024: private String candidateClass;
025: private String filter;
026: private String imports;
027: private String variables;
028: private String ordering;
029: private boolean ignoreCache;
030: private String params;
031:
032: private String fetchGroup;
033: private boolean randomAccess;
034: private boolean countStarOnSize;
035: private boolean bounded;
036:
037: private String compiledQuery;
038: private int count;
039: private int skipAmount;
040: private int index;
041: private int fetchAmount;
042:
043: public SmQueryEvent(int storageManagerId, int type, QueryDetails q,
044: CompiledQuery cq, ModelMetaData jmd) {
045: super (storageManagerId, type);
046: if (q == null && cq != null) {
047: q = cq.getQueryDetails();
048: }
049: if (q != null) {
050: language = q.getLanguageStr();
051: final Class c = q.getCandidateClass();
052: candidateClass = c == null ? null : c.getName();
053: filter = q.getFilter();
054: imports = q.getImports();
055: variables = q.getVariables();
056: ordering = q.getOrdering();
057: ignoreCache = q.isIgnoreCache();
058: int fgi = q.getFetchGroupIndex();
059: if (c != null && fgi >= 0) {
060: ClassMetaData cmd = jmd.getClassMetaData(c);
061: fetchGroup = cmd.fetchGroups[fgi].name;
062: }
063: randomAccess = q.isRandomAccess();
064: countStarOnSize = q.isCountOnSize();
065: bounded = q.isBounded();
066: }
067: if (cq != null) {
068: compiledQuery = cq.toString();
069: }
070: }
071:
072: /**
073: * Get a long description for this event (e.g. the query text).
074: */
075: public String getDescription() {
076: StringBuffer s = new StringBuffer();
077: s.append(language);
078: if (candidateClass != null) {
079: s.append(' ');
080: s.append(candidateClass);
081: }
082: if (filter != null) {
083: s.append(' ');
084: s.append(filter);
085: }
086: return s.toString();
087: }
088:
089: public String getLanguage() {
090: return language;
091: }
092:
093: public String getCandidateClass() {
094: return candidateClass;
095: }
096:
097: public String getFilter() {
098: return filter;
099: }
100:
101: public String getImports() {
102: return imports;
103: }
104:
105: public String getVariables() {
106: return variables;
107: }
108:
109: public String getOrdering() {
110: return ordering;
111: }
112:
113: public boolean isIgnoreCache() {
114: return ignoreCache;
115: }
116:
117: public String getParams() {
118: return params;
119: }
120:
121: public String getFetchGroup() {
122: return fetchGroup;
123: }
124:
125: public boolean getRandomAccess() {
126: return randomAccess;
127: }
128:
129: public boolean getCountStarOnSize() {
130: return countStarOnSize;
131: }
132:
133: public int getCount() {
134: return count;
135: }
136:
137: public void setCount(int count) {
138: this .count = count;
139: }
140:
141: public void setFilter(String filter) {
142: this .filter = filter;
143: }
144:
145: public void setImports(String imports) {
146: this .imports = imports;
147: }
148:
149: public void setVariables(String variables) {
150: this .variables = variables;
151: }
152:
153: public void setOrdering(String ordering) {
154: this .ordering = ordering;
155: }
156:
157: public void setParams(String params) {
158: this .params = params;
159: }
160:
161: public void setFetchGroup(String fetchGroup) {
162: this .fetchGroup = fetchGroup;
163: }
164:
165: public void setCandidateClass(String candidateClass) {
166: this .candidateClass = candidateClass;
167: }
168:
169: public boolean isBounded() {
170: return bounded;
171: }
172:
173: public void setBounded(boolean bounded) {
174: this .bounded = bounded;
175: }
176:
177: public String getCompiledQuery() {
178: return compiledQuery;
179: }
180:
181: public int getSkipAmount() {
182: return skipAmount;
183: }
184:
185: public void setSkipAmount(int skipAmount) {
186: this .skipAmount = skipAmount;
187: }
188:
189: public int getIndex() {
190: return index;
191: }
192:
193: public void setIndex(int index) {
194: this .index = index;
195: }
196:
197: public int getFetchAmount() {
198: return fetchAmount;
199: }
200:
201: public void setFetchAmount(int fetchAmount) {
202: this.fetchAmount = fetchAmount;
203: }
204:
205: }
|