Search in sources :

Example 6 with ComposerAttributeNodeData

use of org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerAttributeNodeData in project scout.rt by eclipse.

the class FormDataStatementBuilder method getAttributeKind.

public AttributeKind getAttributeKind(TreeNodeData node) {
    if (!(node instanceof ComposerAttributeNodeData)) {
        return AttributeKind.Undefined;
    }
    // 
    ComposerAttributeNodeData attributeNode = (ComposerAttributeNodeData) node;
    Integer agg = attributeNode.getAggregationType();
    if (agg == null || agg == AGGREGATION_NONE) {
        if (!isZeroTraversingAttribute(attributeNode.getOperator(), attributeNode.getValues().toArray())) {
            return AttributeKind.NonAggregationNonZeroTraversing;
        }
        return AttributeKind.NonAggregation;
    }
    // 
    if (!isZeroTraversingAttribute(attributeNode.getOperator(), attributeNode.getValues().toArray())) {
        return AttributeKind.AggregationNonZeroTraversing;
    }
    return AttributeKind.Aggregation;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ComposerAttributeNodeData(org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerAttributeNodeData)

Example 7 with ComposerAttributeNodeData

use of org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerAttributeNodeData in project scout.rt by eclipse.

the class FormDataStatementBuilderWithComposerTest method testBuildComposerAttributeNodeStrategyBuildConstraintOfAttributeWithContextAggregationSum.

@Test
public void testBuildComposerAttributeNodeStrategyBuildConstraintOfAttributeWithContextAggregationSum() throws Exception {
    ComposerAttributeNodeData subAttributeNode = prepareComposer(DataModelConstants.AGGREGATION_SUM);
    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("SUM(T.SUB_ATTRIBUTE)=:__a1", attributeContribution.getWhereParts().get(0));
}
Also used : ComposerAttributeNodeData(org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerAttributeNodeData) Test(org.junit.Test)

Example 8 with ComposerAttributeNodeData

use of org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerAttributeNodeData in project scout.rt by eclipse.

the class FormDataStatementBuilderWithComposerTest method testBuildComposerEntityNodeStrategyBuildConstraintsAggregationNone.

@Test
public void testBuildComposerEntityNodeStrategyBuildConstraintsAggregationNone() throws Exception {
    ComposerAttributeNodeData subAttributeNode = prepareComposer(DataModelConstants.AGGREGATION_NONE);
    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 AND a0001.SUB_ATTRIBUTE=:__a2 )", StringUtility.cleanup(entityContribution.getWhereParts().get(0)));
}
Also used : ComposerEntityNodeData(org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerEntityNodeData) ComposerAttributeNodeData(org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerAttributeNodeData) Test(org.junit.Test)

Aggregations

ComposerAttributeNodeData (org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerAttributeNodeData)8 Test (org.junit.Test)6 ComposerEntityNodeData (org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerEntityNodeData)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AbstractDataModelEntity (org.eclipse.scout.rt.shared.data.model.AbstractDataModelEntity)1 EntityPath (org.eclipse.scout.rt.shared.data.model.EntityPath)1 IDataModelAttribute (org.eclipse.scout.rt.shared.data.model.IDataModelAttribute)1 IDataModelEntity (org.eclipse.scout.rt.shared.data.model.IDataModelEntity)1