Example usage for org.hibernate.mapping RootClass getPropertyIterator

List of usage examples for org.hibernate.mapping RootClass getPropertyIterator

Introduction

In this page you can find the example usage for org.hibernate.mapping RootClass getPropertyIterator.

Prototype

public Iterator getPropertyIterator() 

Source Link

Document

Build an iterator over the properties defined on this class.

Usage

From source file:com.enonic.cms.store.hibernate.cache.invalidation.InvalidationRulesBuilder.java

License:Open Source License

/**
 * Build the root class.//w  w w  . j av  a  2  s  .c  om
 */
private void buildMapping(RootClass mapping) {
    for (Iterator i = mapping.getPropertyIterator(); i.hasNext();) {
        buildMapping((Property) i.next());
    }
}

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

License:Open Source License

private void initMappingData() {

    RootClass rc;
    // for (Iterator<RootClass> iter = CastUtils.cast(getConfiguration()
    for (Iterator iter = CastUtils.cast(getConfiguration().getClassMappings()); iter.hasNext();) {

        // RootClass rc = iter.next();
        Object obj = iter.next();
        if (obj instanceof RootClass) {
            rc = (RootClass) obj;/*from ww w.  j  a v  a 2  s. co m*/
        } else {
            rc = ((Subclass) obj).getRootClass();
        }

        String s = rc.getClassName();
        this.entityClassNames.add(s);
        this.entityNames.add(StringUtils.splitPackageAndClass(s).v2);

        this.rootClasses.put(rc.getMappedClass(), rc);
        this.entityClasses.add(rc.getMappedClass());

        Map<String, Property> propertiesMap = new HashMap<String, Property>();
        this.allPropertiesMap.put(rc.getClassName(), propertiesMap);

        for (Iterator<Property> iter2 = CastUtils.cast(rc.getPropertyIterator()); iter2.hasNext();) {

            Property p = iter2.next();
            initProperty(rc.getClassName(), p, propertiesMap);
        }

        Property id = rc.getIdentifierProperty();
        initProperty(rc.getClassName(), id, propertiesMap);
    }
}

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

License:Open Source License

/**
 * creates children of the shape, /*from   w  ww. j a v  a  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);
        }
    }
}

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

License:Open Source License

/**
 * creates children of the shape, /*  w  ww .  j a v a  2 s .c  om*/
 */
@SuppressWarnings("unchecked")
@Override
protected void initModel() {
    RootClass rootClass = (RootClass) getOrmElement();
    Property identifierProperty = rootClass.getIdentifierProperty();
    if (identifierProperty != null) {
        addChild(new Shape(identifierProperty, getConsoleConfigName()));
    }

    SpecialRootClass src = (SpecialRootClass) getOrmElement();
    if (src.getParentProperty() != null) {
        Shape bodyOrmShape = new Shape(src.getParentProperty(), getConsoleConfigName());
        addChild(bodyOrmShape);
        parentShape = bodyOrmShape;
    }

    Iterator<Property> iterator = rootClass.getPropertyIterator();
    while (iterator.hasNext()) {
        Property field = iterator.next();
        Type type = getTypeUsingExecContext(field.getValue());
        Shape bodyOrmShape = null;
        if (type != null && type.isEntityType()) {
            bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
        } else if (type != null && type.isCollectionType()) {
            bodyOrmShape = new ComponentShape(field, getConsoleConfigName());
        } else {
            bodyOrmShape = new Shape(field, getConsoleConfigName());
        }
        addChild(bodyOrmShape);
    }
}