Search in sources :

Example 1 with IDataModelEntity

use of org.eclipse.scout.rt.shared.data.model.IDataModelEntity in project scout.rt by eclipse.

the class AbstractComposerNode method attachAddEntityMenus.

protected void attachAddEntityMenus(Collection<IMenu> menus) {
    EntityNode eNode = null;
    ITreeNode n = this;
    while (n != null) {
        if (n instanceof EntityNode) {
            eNode = (EntityNode) n;
            break;
        }
        n = n.getParentNode();
    }
    List<IDataModelEntity> childEntitites;
    if (eNode != null) {
        childEntitites = eNode.getEntity().getEntities();
    } else {
        childEntitites = getComposerField().getEntities();
    }
    for (IDataModelEntity e : childEntitites) {
        menus.add(createAddEntityMenu(e));
    }
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) IDataModelEntity(org.eclipse.scout.rt.shared.data.model.IDataModelEntity)

Example 2 with IDataModelEntity

use of org.eclipse.scout.rt.shared.data.model.IDataModelEntity in project scout.rt by eclipse.

the class AbstractComposerField method execResolveEntityPath.

/**
 * For {@link #exportFormFieldData(AbstractFormFieldData)}, {@link AbstractTree#exportTreeData(AbstractTreeFieldData)}
 * and {@link #storeToXml(Element)} it is necessary to export {@link IDataModelEntity} and {@link IDataModelAttribute}
 * as external strings. see {@link EntityPath}
 * <p>
 * This callback completes an entity path to its root. The parameter path contains the entity path represented in the
 * composer tree of {@link EntityNode}s, the last element is the deepest tree node.
 * <p>
 * The default traverses the tree up to the root and collects all non-null {@link EntityNode#getEntity()}
 * <p>
 * This is prefixed with {@link #interceptResolveRootPathForTopLevelEntity(IDataModelEntity, List)}
 */
@ConfigOperation
@Order(99)
protected EntityPath execResolveEntityPath(EntityNode node) {
    LinkedList<IDataModelEntity> list = new LinkedList<IDataModelEntity>();
    EntityNode tmp = node;
    while (tmp != null) {
        if (tmp.getEntity() != null) {
            list.add(0, tmp.getEntity());
        }
        // next
        tmp = tmp.getAncestorNode(EntityNode.class);
    }
    if (list.size() > 0) {
        interceptResolveRootPathForTopLevelEntity(list.get(0), list);
    }
    return new EntityPath(list);
}
Also used : EntityPath(org.eclipse.scout.rt.shared.data.model.EntityPath) IDataModelEntity(org.eclipse.scout.rt.shared.data.model.IDataModelEntity) LinkedList(java.util.LinkedList) EntityNode(org.eclipse.scout.rt.client.ui.form.fields.composer.node.EntityNode) Order(org.eclipse.scout.rt.platform.Order) ConfigOperation(org.eclipse.scout.rt.platform.annotations.ConfigOperation)

Example 3 with IDataModelEntity

use of org.eclipse.scout.rt.shared.data.model.IDataModelEntity 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 4 with IDataModelEntity

use of org.eclipse.scout.rt.shared.data.model.IDataModelEntity in project scout.rt by eclipse.

the class FormDataStatementBuilderCheck method checkDataModelEntity.

@SuppressWarnings("bsiRulesDefinition:htmlInString")
protected void checkDataModelEntity(EntityPath ePath) {
    IDataModelEntity e = ePath.lastElement();
    DataModelEntityPartDefinition part = builder.getDataModelEntityPartDefinitions().get(e.getClass());
    if (part == null) {
        String name = entityToName(ePath);
        String sqlTableName = toSqlTable(name);
        String sqlPKName = toSqlPrimaryKey(name);
        String parentName = name;
        String parentSqlPKName = sqlPKName;
        EntityPath parentPath = ePath.parent();
        if (!parentPath.isEmpty()) {
            parentName = entityToName(parentPath);
            parentSqlPKName = toSqlPrimaryKey(parentName);
        }
        String sqlTemplate = "\"EXISTS ( SELECT 1 \"+\n" + "\"FROM ${sqlTableName} @${name}@ \"+\n" + "\"WHERE @${name}@.${parentSqlPKName}=@parent.${parentName}@.${parentSqlPKName} \"+\n" + "\"<whereParts/> \"+\n" + "\"<groupBy> \"+\n" + "\"  GROUP BY @${name}@.${parentSqlPKName} \"+\n" + "\"  HAVING 1=1 \"+\n" + "\"  <havingParts/> \"+\n" + "\"</groupBy> \"+\n" + "\")\"";
        String sql = sqlTemplate.replace("${name}", name).replace("${parentName}", parentName).replace("${sqlTableName}", sqlTableName).replace("${parentSqlPKName}", parentSqlPKName);
        addBodyLine("//entity " + e.getClass().getSimpleName());
        addBodyLine("setComposerEntityDefinition(" + resolveImport(e.getClass()) + ".class," + sql + ");");
    }
}
Also used : EntityPath(org.eclipse.scout.rt.shared.data.model.EntityPath) IDataModelEntity(org.eclipse.scout.rt.shared.data.model.IDataModelEntity)

Example 5 with IDataModelEntity

use of org.eclipse.scout.rt.shared.data.model.IDataModelEntity in project scout.rt by eclipse.

the class MoveDataModelEntitiyAndAttributeTest method testMoveSubLevelAttribute.

@Test
public void testMoveSubLevelAttribute() {
    BEANS.get(IExtensionRegistry.class).registerMove(Sub1Top1Attribute.class, 40);
    TestDataModel dataModel = new TestDataModel();
    assertDataModelElements(dataModel.getEntities(), Top1Entity.class, Top2Entity.class, Top3Entity.class);
    assertDataModelElements(dataModel.getAttributes(), Top1Attribute.class, Top2Attribute.class, Top3Attribute.class);
    IDataModelEntity entity = dataModel.getEntities().get(0);
    assertDataModelElements(entity.getEntities(), Sub1Top1Entity.class, Sub2Top1Entity.class, Sub3Top1Entity.class);
    assertDataModelElements(entity.getAttributes(), Sub2Top1Attribute.class, Sub3Top1Attribute.class, Sub1Top1Attribute.class);
}
Also used : IDataModelEntity(org.eclipse.scout.rt.shared.data.model.IDataModelEntity) TestDataModel(org.eclipse.scout.rt.shared.extension.data.model.fixture.TestDataModel) IExtensionRegistry(org.eclipse.scout.rt.shared.extension.IExtensionRegistry) Test(org.junit.Test)

Aggregations

IDataModelEntity (org.eclipse.scout.rt.shared.data.model.IDataModelEntity)15 EntityPath (org.eclipse.scout.rt.shared.data.model.EntityPath)5 TestDataModel (org.eclipse.scout.rt.shared.extension.data.model.fixture.TestDataModel)5 Test (org.junit.Test)5 Order (org.eclipse.scout.rt.platform.Order)4 ConfigOperation (org.eclipse.scout.rt.platform.annotations.ConfigOperation)4 IExtensionRegistry (org.eclipse.scout.rt.shared.extension.IExtensionRegistry)4 LinkedList (java.util.LinkedList)2 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)2 EntityNode (org.eclipse.scout.rt.client.ui.form.fields.composer.node.EntityNode)2 ComposerEntityNodeData (org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerEntityNodeData)2 AttributePath (org.eclipse.scout.rt.shared.data.model.AttributePath)2 IDataModelAttribute (org.eclipse.scout.rt.shared.data.model.IDataModelAttribute)2 ArrayList (java.util.ArrayList)1 EitherOrNode (org.eclipse.scout.rt.client.ui.form.fields.composer.node.EitherOrNode)1 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)1 ComposerAttributeNodeData (org.eclipse.scout.rt.shared.data.form.fields.composer.ComposerAttributeNodeData)1 AbstractDataModelEntity (org.eclipse.scout.rt.shared.data.model.AbstractDataModelEntity)1 IDataModelAttributeOp (org.eclipse.scout.rt.shared.data.model.IDataModelAttributeOp)1 Element (org.w3c.dom.Element)1