use of org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerAttributeNodeData in project scout.rt by eclipse.
the class FormDataStatementBuilderWithComposerTest method testBuildComposerAttributeNodeStrategyBuildConstraintOfAttributeWithContextAggregationNone.
@Test
public void testBuildComposerAttributeNodeStrategyBuildConstraintOfAttributeWithContextAggregationNone() throws Exception {
ComposerAttributeNodeData subAttributeNode = prepareComposer(DataModelConstants.AGGREGATION_NONE);
m_builder.getAliasMapper().setNodeAlias(subAttributeNode.getParentNode(), "Table", "T");
EntityContribution attributeContribution = m_builder.buildComposerAttributeNode(subAttributeNode, AttributeStrategy.BuildConstraintOfAttributeWithContext);
assertNotNull(attributeContribution);
assertTrue(attributeContribution.getSelectParts().isEmpty());
assertTrue(attributeContribution.getFromParts().isEmpty());
assertTrue(attributeContribution.getGroupByParts().isEmpty());
assertTrue(attributeContribution.getHavingParts().isEmpty());
assertFalse(attributeContribution.getWhereParts().isEmpty());
assertEquals(1, attributeContribution.getWhereParts().size());
assertEquals("T.SUB_ATTRIBUTE=:__a1", attributeContribution.getWhereParts().get(0));
}
use of org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerAttributeNodeData in project scout.rt by eclipse.
the class FormDataStatementBuilderWithComposerTest method testBuildComposerEntityNodeStrategyBuildConstraintsAggregationSum.
@Test
public void testBuildComposerEntityNodeStrategyBuildConstraintsAggregationSum() throws Exception {
ComposerAttributeNodeData subAttributeNode = prepareComposer(DataModelConstants.AGGREGATION_SUM);
ComposerEntityNodeData subEntityNode = (ComposerEntityNodeData) subAttributeNode.getParentNode();
m_builder.getAliasMapper().setNodeAlias(subEntityNode.getParentNode(), "Table", "T");
EntityContribution entityContribution = m_builder.buildComposerEntityNodeContribution(subEntityNode, EntityStrategy.BuildConstraints);
assertNotNull(entityContribution);
assertTrue(entityContribution.getSelectParts().isEmpty());
assertTrue(entityContribution.getFromParts().isEmpty());
assertTrue(entityContribution.getGroupByParts().isEmpty());
assertTrue(entityContribution.getHavingParts().isEmpty());
assertFalse(entityContribution.getWhereParts().isEmpty());
assertEquals(1, entityContribution.getWhereParts().size());
assertEquals("EXISTS ( SELECT 1 FROM TABLE a0001 WHERE a0001.PRIMARY_KEY=T.PRIMARY_KEY GROUP BY T.PRIMARY_KEY HAVING 1=1 AND SUM(a0001.SUB_ATTRIBUTE)=:__a2 )", StringUtility.cleanup(entityContribution.getWhereParts().get(0)));
}
use of org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerAttributeNodeData in project scout.rt by eclipse.
the class FormDataStatementBuilderWithComposerTest method testBuildComposerAttributeNodeStrategyBuildConstraintOfAttributeAggregationNone.
@Test
public void testBuildComposerAttributeNodeStrategyBuildConstraintOfAttributeAggregationNone() throws Exception {
ComposerAttributeNodeData subAttributeNode = prepareComposer(DataModelConstants.AGGREGATION_NONE);
m_builder.getAliasMapper().setNodeAlias(subAttributeNode.getParentNode(), "Table", "T");
EntityContribution attributeContribution = m_builder.buildComposerAttributeNode(subAttributeNode, AttributeStrategy.BuildConstraintOfAttribute);
assertNotNull(attributeContribution);
assertTrue(attributeContribution.getSelectParts().isEmpty());
assertTrue(attributeContribution.getFromParts().isEmpty());
assertTrue(attributeContribution.getGroupByParts().isEmpty());
assertTrue(attributeContribution.getHavingParts().isEmpty());
assertFalse(attributeContribution.getWhereParts().isEmpty());
assertEquals(1, attributeContribution.getWhereParts().size());
assertEquals("T.SUB_ATTRIBUTE=:__a1", attributeContribution.getWhereParts().get(0));
}
use of org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerAttributeNodeData in project scout.rt by eclipse.
the class FormDataStatementBuilderWithComposerTest method prepareComposer.
private ComposerAttributeNodeData prepareComposer(int aggregationType) {
IDataModelEntity entity = m_dataModel.getEntity(TestDataModel.Entity.class);
IDataModelEntity subEntity = entity.getEntity(TestDataModel.Entity.SubEntity.class);
IDataModelAttribute subAttribute = subEntity.getAttribute(TestDataModel.Entity.SubEntity.SubAttribute.class);
ComposerAttributeNodeData subAttributeNode = new ComposerAttributeNodeData();
subAttributeNode.setAggregationType(aggregationType);
subAttributeNode.setOperator(DataModelConstants.OPERATOR_EQ);
String attributeExternalId = DataModelUtility.attributePathToExternalId(m_dataModel, new EntityPath().addToEnd(entity).addToEnd(subEntity).addToEnd(subAttribute));
subAttributeNode.setAttributeExternalId(attributeExternalId);
subAttributeNode.setValues(CollectionUtility.arrayList(10L));
ComposerEntityNodeData subEntityNode = new ComposerEntityNodeData();
subEntityNode.setEntityExternalId(DataModelUtility.entityPathToExternalId(m_dataModel, new EntityPath().addToEnd(entity).addToEnd(subEntity)));
subEntityNode.setChildNodes(Arrays.<TreeNodeData>asList(subAttributeNode));
ComposerEntityNodeData entityNode = new ComposerEntityNodeData();
entityNode.setEntityExternalId(DataModelUtility.entityPathToExternalId(m_dataModel, new EntityPath().addToEnd(entity)));
entityNode.setChildNodes(Arrays.<TreeNodeData>asList(subEntityNode));
return subAttributeNode;
}
use of org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerAttributeNodeData in project scout.rt by eclipse.
the class FormDataStatementBuilderWithComposerTest method testBuildComposerAttributeNodeStrategyBuildConstraintOfAttributeAggregationSum.
@Test
public void testBuildComposerAttributeNodeStrategyBuildConstraintOfAttributeAggregationSum() throws Exception {
ComposerAttributeNodeData subAttributeNode = prepareComposer(DataModelConstants.AGGREGATION_SUM);
m_builder.getAliasMapper().setNodeAlias(subAttributeNode.getParentNode(), "Table", "T");
EntityContribution attributeContribution = m_builder.buildComposerAttributeNode(subAttributeNode, AttributeStrategy.BuildConstraintOfAttribute);
assertNotNull(attributeContribution);
assertTrue(attributeContribution.getSelectParts().isEmpty());
assertTrue(attributeContribution.getFromParts().isEmpty());
assertTrue(attributeContribution.getGroupByParts().isEmpty());
assertFalse(attributeContribution.getHavingParts().isEmpty());
assertTrue(attributeContribution.getWhereParts().isEmpty());
assertEquals(1, attributeContribution.getHavingParts().size());
assertEquals("SUM(T.SUB_ATTRIBUTE)=:__a1", attributeContribution.getHavingParts().get(0));
}
Aggregations