01: /*
02: * Copyright 2006 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
07: * BI Platform. The Initial Developer is Pentaho Corporation.
08: *
09: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11: * the license for the specific language governing your rights and limitations.
12: *
13: * Created Dec 27, 2006
14: * @author mdamour
15: */
16:
17: package org.pentaho.plugin.hql;
18:
19: import java.util.Set;
20: import org.apache.commons.logging.Log;
21: import org.apache.commons.logging.LogFactory;
22: import org.pentaho.messages.Messages;
23: import org.pentaho.plugin.core.StandardSettings;
24:
25: public class HQLLookupRule extends HQLBaseComponent {
26:
27: /**
28: *
29: */
30: private static final long serialVersionUID = 4633628885885427927L;
31:
32: /**
33: *
34: */
35: public boolean validateSystemSettings() {
36: // This component does not have any system settings to validate
37: return true;
38: }
39:
40: public String getResultOutputName() {
41: Set outputs = getOutputNames();
42: if ((outputs == null) || (outputs.size() == 0)) {
43: // if( (outputs == null) || (outputs.size() == 0 ) ||
44: // (outputs.size() > 1 ) ) {
45: error(Messages
46: .getString("Template.ERROR_0002_OUTPUT_COUNT_WRONG")); //$NON-NLS-1$
47: return null;
48: }
49:
50: // Did we override the output name? // TODO Deprecation Warning
51: String outputName = getInputStringValue(StandardSettings.OUTPUT_NAME);
52: if (outputName == null && outputs.contains("query-result")) { //$NON-NLS-1$ // Get the query-result node - This is the preferred method to use
53: outputName = "query-result"; //$NON-NLS-1$
54: }
55:
56: if (outputName == null) { // Drop back to the old behavior
57: outputName = (String) outputs.iterator().next();
58: // TODO Deprecation Warning
59: }
60: return outputName;
61: }
62:
63: public Log getLogger() {
64: return LogFactory.getLog(HQLLookupRule.class);
65: }
66:
67: public boolean init() {
68: return true;
69: }
70: }
|