Search in sources :

Example 91 with IProperty

use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.

the class TypeVisitor method visit.

@Override
public boolean visit(MethodDeclaration node) {
    if (!entityInfo.isInterfaceFlag())
        return super.visit(node);
    org.eclipse.jdt.core.dom.TypeDeclaration type = (org.eclipse.jdt.core.dom.TypeDeclaration) node.getParent();
    // TODO check Abstract methods
    if (type.isInterface()) {
        String varName = Utils.getFieldNameByGetter(node);
        if (varName != null) {
            String primaryIdName = entityInfo.getPrimaryIdName();
            Type methodType = node.getReturnType2();
            if (varName.toLowerCase().equals(primaryIdName.toLowerCase()))
                varName = primaryIdName;
            IProperty prop = createProperty(varName, methodType);
            if (varName.equals(primaryIdName)) {
                rootClass.setIdentifierProperty(prop);
            } else {
                rootClass.addProperty(prop);
            }
        }
    }
    return super.visit(node);
}
Also used : TypeDeclaration(org.eclipse.jdt.core.dom.TypeDeclaration) SimpleType(org.eclipse.jdt.core.dom.SimpleType) Type(org.eclipse.jdt.core.dom.Type) RefType(org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefType) WildcardType(org.eclipse.jdt.core.dom.WildcardType) IType(org.eclipse.jdt.core.IType) QualifiedType(org.eclipse.jdt.core.dom.QualifiedType) PrimitiveType(org.eclipse.jdt.core.dom.PrimitiveType) ArrayType(org.eclipse.jdt.core.dom.ArrayType) ParameterizedType(org.eclipse.jdt.core.dom.ParameterizedType) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) TypeDeclaration(org.eclipse.jdt.core.dom.TypeDeclaration)

Example 92 with IProperty

use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.

the class TypeVisitor method visit.

@SuppressWarnings("unchecked")
public boolean visit(FieldDeclaration node) {
    // do not map static or final fields
    if ((node.getModifiers() & (Modifier.FINAL | Modifier.STATIC)) != 0) {
        return false;
    }
    Type type = node.getType();
    if (type == null) {
        return true;
    }
    String primaryIdName = entityInfo.getPrimaryIdName();
    Iterator<VariableDeclarationFragment> itVarNames = node.fragments().iterator();
    while (itVarNames.hasNext()) {
        VariableDeclarationFragment var = itVarNames.next();
        IProperty prop = createProperty(var);
        if (prop == null) {
            continue;
        }
        if (!varHasGetterAndSetter(var)) {
            // $NON-NLS-1$
            prop.setPropertyAccessorName("field");
        }
        String name = var.getName().getIdentifier();
        if (name.equals(primaryIdName)) {
            rootClass.setIdentifierProperty(prop);
        } else {
            rootClass.addProperty(prop);
        }
    }
    return true;
}
Also used : SimpleType(org.eclipse.jdt.core.dom.SimpleType) Type(org.eclipse.jdt.core.dom.Type) RefType(org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefType) WildcardType(org.eclipse.jdt.core.dom.WildcardType) IType(org.eclipse.jdt.core.IType) QualifiedType(org.eclipse.jdt.core.dom.QualifiedType) PrimitiveType(org.eclipse.jdt.core.dom.PrimitiveType) ArrayType(org.eclipse.jdt.core.dom.ArrayType) ParameterizedType(org.eclipse.jdt.core.dom.ParameterizedType) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) VariableDeclarationFragment(org.eclipse.jdt.core.dom.VariableDeclarationFragment)

Example 93 with IProperty

use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.

the class TypeVisitor method createProperty.

protected IProperty createProperty(String varName, Type varType) {
    typeVisitor.init(varName, entityInfo);
    varType.accept(typeVisitor);
    IProperty p = typeVisitor.getProperty();
    return p;
}
Also used : IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty)

Aggregations

IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)93 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)53 Property (org.hibernate.mapping.Property)40 Test (org.junit.Test)33 RootClass (org.hibernate.mapping.RootClass)27 IValue (org.jboss.tools.hibernate.runtime.spi.IValue)20 PersistentClass (org.hibernate.mapping.PersistentClass)18 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)12 SimpleValue (org.hibernate.mapping.SimpleValue)12 AbstractPropertyFacade (org.jboss.tools.hibernate.runtime.common.AbstractPropertyFacade)12 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)12 FileNotFoundException (java.io.FileNotFoundException)9 IColumn (org.jboss.tools.hibernate.runtime.spi.IColumn)9 Component (org.hibernate.mapping.Component)8 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)8 IEditorPart (org.eclipse.ui.IEditorPart)7 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)7 JavaModelException (org.eclipse.jdt.core.JavaModelException)6 Mappings (org.hibernate.cfg.Mappings)6 PartInitException (org.eclipse.ui.PartInitException)5