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));
}
}
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);
}
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;
}
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 + ");");
}
}
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);
}
Aggregations