Search in sources :

Example 1 with ComposerAttributeNodeData

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));
}
Also used : ComposerAttributeNodeData(org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerAttributeNodeData) Test(org.junit.Test)

Example 2 with ComposerAttributeNodeData

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)));
}
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)

Example 3 with ComposerAttributeNodeData

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));
}
Also used : ComposerAttributeNodeData(org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerAttributeNodeData) Test(org.junit.Test)

Example 4 with ComposerAttributeNodeData

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;
}
Also used : IDataModelEntity(org.eclipse.scout.rt.shared.data.model.IDataModelEntity) AbstractDataModelEntity(org.eclipse.scout.rt.shared.data.model.AbstractDataModelEntity) EntityPath(org.eclipse.scout.rt.shared.data.model.EntityPath) ComposerEntityNodeData(org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerEntityNodeData) ComposerAttributeNodeData(org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerAttributeNodeData) IDataModelEntity(org.eclipse.scout.rt.shared.data.model.IDataModelEntity) IDataModelAttribute(org.eclipse.scout.rt.shared.data.model.IDataModelAttribute)

Example 5 with ComposerAttributeNodeData

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));
}
Also used : 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