From: <jma...@rh...> - 2008-12-09 18:43:40
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><style type="text/css"><!-- #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } --></style> <title>[rhq-project.org rhq] [2261] suppress private property results in dynagroup calculations;</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>2261</dd> <dt>Author</dt> <dd>jmarques</dd> <dt>Date</dt> <dd>2008-12-09 12:43:36 -0600 (Tue, 09 Dec 2008)</dd> </dl> <h3>Log Message</h3> <pre>suppress private property results in dynagroup calculations;</pre> <h3>Modified Paths</h3> <ul> <li><a href="#rhqbranchesRHQ_1_1_2_SPmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverresourcegroupdefinitionframeworkExpressionEvaluatorjava">rhq/branches/RHQ_1_1_2_SP/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java</a></li> <li><a href="#rhqbranchesRHQ_1_1_2_SPmodulesenterpriseserverjarsrctestjavaorgrhqenterpriseserverresourcegroupdefinitionframeworktestExpressionEvaluatorTestjava">rhq/branches/RHQ_1_1_2_SP/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="rhqbranchesRHQ_1_1_2_SPmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverresourcegroupdefinitionframeworkExpressionEvaluatorjava"></a> <div class="modfile"><h4>Modified: rhq/branches/RHQ_1_1_2_SP/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java (2260 => 2261)</h4> <pre class="diff"> <span class="info">--- rhq/branches/RHQ_1_1_2_SP/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java 2008-12-09 17:55:49 UTC (rev 2260) +++ rhq/branches/RHQ_1_1_2_SP/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/framework/ExpressionEvaluator.java 2008-12-09 18:43:36 UTC (rev 2261) </span><span class="lines">@@ -46,6 +46,7 @@ </span><span class="cx"> private static final String INVALID_EXPRESSION_FORM_MSG = "Expression must be in the form of 'condition = value' or 'groupBy condition'"; private static final String PROP_SIMPLE_ALIAS = "simple"; </span><span class="add">+ private static final String PROP_SIMPLE_DEF_ALIAS = "simpleDef"; </span><span class="cx"> private static final String TRAIT_ALIAS = "trait"; private static final String METRIC_DEF_ALIAS = "def"; </span><span class="lines">@@ -53,7 +54,10 @@ </span><span class="cx"> RESOURCE_CONFIGURATION(".resourceConfiguration", "conf"), // PLUGIN_CONFIGURATION(".pluginConfiguration", "pluginConf"), // SCHEDULES(".schedules", "sched"), // </span><span class="rem">- RESOURCE_CHILD(".childResources", "child"); </span><span class="add">+ RESOURCE_CHILD(".childResources", "child"), // + AVAILABILITY(".availability", "avail"), // + RESOURCE_CONFIGURATION_DEFINITION(".resourceType.resourceConfigurationDefinition", "confDef"), // + PLUGIN_CONFIGURATION_DEFINITION(".resourceType.pluginConfigurationDefinition", "pluginConfDef"); </span><span class="cx"> String subexpression; String alias; </span><span class="lines">@@ -386,13 +390,16 @@ </span><span class="cx"> } else if (context == ParseContext.Configuration) { String prefix; JoinCondition joinCondition; </span><span class="add">+ JoinCondition definitionJoinCondition; </span><span class="cx"> if (subcontext == ParseSubContext.PluginConfiguration) { prefix = "pluginconfiguration"; joinCondition = JoinCondition.PLUGIN_CONFIGURATION; </span><span class="add">+ definitionJoinCondition = JoinCondition.PLUGIN_CONFIGURATION_DEFINITION; </span><span class="cx"> } else if (subcontext == ParseSubContext.ResourceConfiguration) { prefix = "resourceconfiguration"; joinCondition = JoinCondition.RESOURCE_CONFIGURATION; </span><span class="add">+ definitionJoinCondition = JoinCondition.RESOURCE_CONFIGURATION_DEFINITION; </span><span class="cx"> } else { throw new InvalidExpressionException("Invalid 'configuration' subexpression: " + subcontext); } </span><span class="lines">@@ -410,9 +417,16 @@ </span><span class="cx"> String propertyName = suffix.substring(1, suffix.length() - 1); joinConditions.add(joinCondition); </span><span class="add">+ joinConditions.add(definitionJoinCondition); + </span><span class="cx"> populatePredicateCollections(PROP_SIMPLE_ALIAS + ".name", propertyName, false); populatePredicateCollections(PROP_SIMPLE_ALIAS + ".stringValue", value); </span><span class="add">+ </span><span class="cx"> whereStatics.add(PROP_SIMPLE_ALIAS + ".configuration = " + joinCondition.alias); </span><span class="add">+ whereStatics.add(PROP_SIMPLE_DEF_ALIAS + ".configurationDefinition = " + definitionJoinCondition.alias); + whereStatics.add(PROP_SIMPLE_ALIAS + ".name = " + PROP_SIMPLE_DEF_ALIAS + ".name"); + whereStatics.add(PROP_SIMPLE_DEF_ALIAS + ".type != 'PASSWORD'"); + </span><span class="cx"> } else if (context == ParseContext.StringMatch) { if (expressionType != String.class) { throw new InvalidExpressionException( </span><span class="lines">@@ -729,14 +743,33 @@ </span><span class="cx"> private String getQueryJoinConditions() { String result = ""; </span><span class="rem">- for (JoinCondition joinCondition : joinConditions) { </span><span class="add">+ + JoinCondition[] orderedConditionProcessing = new JoinCondition[] { JoinCondition.RESOURCE_CHILD, + JoinCondition.AVAILABILITY, JoinCondition.SCHEDULES, JoinCondition.PLUGIN_CONFIGURATION, + JoinCondition.PLUGIN_CONFIGURATION_DEFINITION, JoinCondition.RESOURCE_CONFIGURATION, + JoinCondition.RESOURCE_CONFIGURATION_DEFINITION }; + + /* + * process JoinConditions in a specific order, because hibernate AST parsing requires + * tokens to have been identified in the JPQL before their first use; in this case, + * JoinCondition.RESOURCE_CHILD must be first because ANY of the others might be joining + * down the resource hierarchy (note: joining up the resource hierarchy doesn't require + * any special processing because it follows from the "many" to the "one" side of the + * relationship, for instance "resource.parent.parent" for grandparents. + */ + for (JoinCondition joinCondition : orderedConditionProcessing) { + if (joinConditions.contains(joinCondition) == false) { + continue; + } + </span><span class="cx"> result += " JOIN res" + joinCondition.subexpression + " " + joinCondition.alias; if (joinCondition == JoinCondition.SCHEDULES) { result += " JOIN " + joinCondition.alias + ".definition " + METRIC_DEF_ALIAS; result += ", MeasurementDataTrait " + TRAIT_ALIAS + " "; } else if (joinCondition == JoinCondition.PLUGIN_CONFIGURATION || joinCondition == JoinCondition.RESOURCE_CONFIGURATION) { </span><span class="rem">- result += ", PropertySimple " + PROP_SIMPLE_ALIAS + " "; </span><span class="add">+ result += ", PropertySimple " + PROP_SIMPLE_ALIAS; + result += ", PropertyDefinition " + PROP_SIMPLE_DEF_ALIAS; </span><span class="cx"> } } </span></pre></div> <a id="rhqbranchesRHQ_1_1_2_SPmodulesenterpriseserverjarsrctestjavaorgrhqenterpriseserverresourcegroupdefinitionframeworktestExpressionEvaluatorTestjava"></a> <div class="modfile"><h4>Modified: rhq/branches/RHQ_1_1_2_SP/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java (2260 => 2261)</h4> <pre class="diff"> <span class="info">--- rhq/branches/RHQ_1_1_2_SP/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java 2008-12-09 17:55:49 UTC (rev 2260) +++ rhq/branches/RHQ_1_1_2_SP/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/definition/framework/test/ExpressionEvaluatorTest.java 2008-12-09 18:43:36 UTC (rev 2261) </span><span class="lines">@@ -58,18 +58,24 @@ </span><span class="cx"> { "resource.pluginConfiguration[partition] = cluster-1", "SELECT res.id FROM Resource res " + // </span><span class="rem">- " JOIN res.pluginConfiguration pluginConf, PropertySimple simple " + // </span><span class="add">+ " JOIN res.pluginConfiguration pluginConf, PropertySimple simple, PropertyDefinition simpleDef " + // + " JOIN res.resourceType.pluginConfigurationDefinition pluginConfDef " + // </span><span class="cx"> " WHERE simple.name = :arg1 " + // " AND simple.stringValue = :arg2 " + // </span><span class="rem">- " AND simple.configuration = pluginConf " }, </span><span class="add">+ " AND simple.configuration = pluginConf " + // + " AND simpleDef.configurationDefinition = pluginConfDef " + // + " AND simple.name = simpleDef.name AND simpleDef.type != 'PASSWORD' " }, </span><span class="cx"> </span><span class="rem">- { "resource.resourceConfiguration[partition] = cluster-1", </span><span class="add">+ { "resource.resourceConfiguration[partition].contains = cluster-1", </span><span class="cx"> "SELECT res.id FROM Resource res " + // </span><span class="rem">- " JOIN res.resourceConfiguration conf, PropertySimple simple " + // </span><span class="add">+ " JOIN res.resourceConfiguration conf, PropertySimple simple, PropertyDefinition simpleDef " + // + " JOIN res.resourceType.resourceConfigurationDefinition confDef " + // </span><span class="cx"> " WHERE simple.name = :arg1 " + // </span><span class="rem">- " AND simple.stringValue = :arg2 " + // - " AND simple.configuration = conf " }, </span><span class="add">+ " AND simple.stringValue like :arg2 " + // + " AND simple.configuration = conf " + // + " AND simpleDef.configurationDefinition = confDef " + // + " AND simple.name = simpleDef.name AND simpleDef.type != 'PASSWORD' " }, </span><span class="cx"> { "groupBy resource.type.plugin; " + // "groupBy resource.type.name", </span><span class="lines">@@ -85,16 +91,22 @@ </span><span class="cx"> { "groupBy resource.resourceConfiguration[partition-name]", " SELECT simple.stringValue FROM Resource res " + // </span><span class="rem">- " JOIN res.resourceConfiguration conf, PropertySimple simple " + // </span><span class="add">+ " JOIN res.resourceConfiguration conf, PropertySimple simple, PropertyDefinition simpleDef " + // + " JOIN res.resourceType.resourceConfigurationDefinition confDef " + // </span><span class="cx"> " WHERE simple.name = :arg1 " + // " AND simple.configuration = conf " + // </span><span class="add">+ " AND simpleDef.configurationDefinition = confDef " + // + " AND simple.name = simpleDef.name AND simpleDef.type != 'PASSWORD' " + // </span><span class="cx"> "GROUP BY simple.stringValue ", " SELECT res.id FROM Resource res " + // </span><span class="rem">- " JOIN res.resourceConfiguration conf, PropertySimple simple " + // </span><span class="add">+ " JOIN res.resourceConfiguration conf, PropertySimple simple, PropertyDefinition simpleDef " + // + " JOIN res.resourceType.resourceConfigurationDefinition confDef " + // </span><span class="cx"> " WHERE simple.name = :arg1 " + // " AND simple.stringValue = :arg2 " + // </span><span class="rem">- " AND simple.configuration = conf " }, </span><span class="add">+ " AND simple.configuration = conf " + // + " AND simpleDef.configurationDefinition = confDef " + // + " AND simple.name = simpleDef.name AND simpleDef.type != 'PASSWORD' " }, </span><span class="cx"> { "resource.type.name = Windows;" + // "resource.trait[Trait.osversion] = 5.1", </span><span class="lines">@@ -106,16 +118,8 @@ </span><span class="cx"> " AND trait.value = :arg3 " + // " AND trait.schedule = sched " + // " AND trait.id.timestamp = " + // </span><span class="rem">- " (SELECT max(mdt.id.timestamp) FROM MeasurementDataTrait mdt WHERE sched.id = mdt.schedule.id)" }, </span><span class="add">+ " (SELECT max(mdt.id.timestamp) FROM MeasurementDataTrait mdt WHERE sched.id = mdt.schedule.id)" } }; </span><span class="cx"> </span><span class="rem">- { "resource.pluginConfiguration[partition].contains = cluster-1", - - "SELECT res.id FROM Resource res " + // - " JOIN res.pluginConfiguration pluginConf, PropertySimple simple " + // - " WHERE simple.name = :arg1 " + // - " AND simple.stringValue like :arg2 " + // - " AND simple.configuration = pluginConf " } }; - </span><span class="cx"> @Test(groups = "integration.session") public void testWellFormedExpressions() throws Exception { List<Integer> suppressedCases = Arrays.asList(); </span> </pre> </div> </div> </body> </html> |