Example usage for org.hibernate.mapping Value isSimpleValue

List of usage examples for org.hibernate.mapping Value isSimpleValue

Introduction

In this page you can find the example usage for org.hibernate.mapping Value isSimpleValue.

Prototype

public boolean isSimpleValue();

Source Link

Usage

From source file:com.wavemaker.runtime.data.hibernate.DataServiceMetaData_Hib.java

License:Open Source License

private void initProperty(String owningClassName, Property p, Map<String, Property> propertiesMap) {
    this.allProperties.put(owningClassName, p);
    if (p != null) {
        this.allPropertyNames.put(owningClassName, p.getName());
        propertiesMap.put(p.getName(), p);
        Value v = p.getValue();
        if (v.getType().isEntityType() || !v.isSimpleValue()) {
            this.relProperties.put(owningClassName, p);
            this.relPropertyNames.put(owningClassName, p.getName());
        }/*from w  ww. j  a  v a2 s .  c  o m*/

        if (p.getType().isComponentType()) {
            addComponentProperties(p);
        }
    }
}

From source file:org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape.java

License:Open Source License

/**
 * creates children of the shape, /*from   ww w  .  java  2 s  .c o  m*/
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void initModel() {
    Object ormElement = getOrmElement();
    if (ormElement instanceof RootClass) {
        RootClass rootClass = (RootClass) ormElement;
        Property identifierProperty = rootClass.getIdentifierProperty();
        if (identifierProperty != null) {
            addChild(new Shape(identifierProperty, getConsoleConfigName()));
        }

        KeyValue identifier = rootClass.getIdentifier();
        if (identifier instanceof Component) {
            Component component = (Component) identifier;
            if (component.isEmbedded()) {
                Iterator<Property> iterator = ((Component) identifier).getPropertyIterator();
                while (iterator.hasNext()) {
                    Property property = iterator.next();
                    addChild(new Shape(property, getConsoleConfigName()));
                }
            }
        }

        Iterator<Property> iterator = rootClass.getPropertyIterator();
        while (iterator.hasNext()) {
            Property field = iterator.next();
            if (!field.isBackRef()) {
                if (!field.isComposite()) {
                    final Value val = field.getValue();
                    Shape bodyOrmShape = null;
                    if (val.isSimpleValue() && !((SimpleValue) val).isTypeSpecified()) {
                        bodyOrmShape = new Shape(field, getConsoleConfigName());
                    } else {
                        if (val instanceof Collection) {
                            bodyOrmShape = new ComponentShape(field, getConsoleConfigName());
                        } else {
                            Type type = getTypeUsingExecContext(val);
                            if (type != null && type.isEntityType()) {
                                bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
                            } else {
                                bodyOrmShape = new Shape(field, getConsoleConfigName());
                            }
                        }
                    }
                    addChild(bodyOrmShape);
                } else {
                    Shape bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
                    addChild(bodyOrmShape);
                }
            }
        }
    } else if (ormElement instanceof Subclass) {
        RootClass rootClass = ((Subclass) ormElement).getRootClass();

        Property identifierProperty = rootClass.getIdentifierProperty();
        if (identifierProperty != null) {
            addChild(new Shape(identifierProperty, getConsoleConfigName()));
        }

        KeyValue identifier = rootClass.getIdentifier();
        if (identifier instanceof Component) {
            Iterator<Property> iterator = ((Component) identifier).getPropertyIterator();
            while (iterator.hasNext()) {
                Property property = iterator.next();
                addChild(new Shape(property, getConsoleConfigName()));
            }
        }

        Iterator<Property> iterator = rootClass.getPropertyIterator();
        while (iterator.hasNext()) {
            Property field = iterator.next();
            if (!field.isBackRef()) {
                if (!field.isComposite()) {

                    boolean typeIsAccessible = true;
                    if (field.getValue().isSimpleValue()
                            && ((SimpleValue) field.getValue()).isTypeSpecified()) {
                        try {
                            field.getValue().getType();
                        } catch (Exception e) {
                            typeIsAccessible = false;
                        }
                    }
                    Shape bodyOrmShape = null;
                    if (typeIsAccessible && field.getValue().isSimpleValue()) {
                        bodyOrmShape = new Shape(field, getConsoleConfigName());
                    } else if (typeIsAccessible && field.getValue().getType().isEntityType()) {
                        bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
                    } else if (typeIsAccessible && field.getValue().getType().isCollectionType()) {
                        bodyOrmShape = new ComponentShape(field, getConsoleConfigName());
                    } else {
                        bodyOrmShape = new Shape(field, getConsoleConfigName());
                    }
                    addChild(bodyOrmShape);
                } else {
                    Shape bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
                    addChild(bodyOrmShape);
                }
            }
        }
        Iterator<Property> iter = ((Subclass) ormElement).getPropertyIterator();
        while (iter.hasNext()) {
            Property property = iter.next();
            if (!property.isBackRef()) {
                if (!property.isComposite()) {

                    boolean typeIsAccessible = true;
                    if (property.getValue().isSimpleValue()
                            && ((SimpleValue) property.getValue()).isTypeSpecified()) {
                        try {
                            property.getValue().getType();
                        } catch (Exception e) {
                            typeIsAccessible = false;
                        }
                    }
                    Shape bodyOrmShape = null;
                    if (typeIsAccessible && property.getValue().getType().isEntityType()) {
                        bodyOrmShape = new ExpandableShape(property, getConsoleConfigName());
                    } else if (typeIsAccessible && property.getValue().getType().isCollectionType()) {
                        bodyOrmShape = new ComponentShape(property, getConsoleConfigName());
                    } else {
                        bodyOrmShape = new Shape(property, getConsoleConfigName());
                    }
                    addChild(bodyOrmShape);
                } else {
                    Shape bodyOrmShape = new ExpandableShape(property, getConsoleConfigName());
                    addChild(bodyOrmShape);
                }
            }
        }
    } else if (ormElement instanceof Table) {
        Iterator iterator = ((Table) getOrmElement()).getColumnIterator();
        while (iterator.hasNext()) {
            Column column = (Column) iterator.next();
            Shape bodyOrmShape = new Shape(column, getConsoleConfigName());
            addChild(bodyOrmShape);
        }
    }
}