Search in sources :

Example 76 with IValue

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

the class Utils method getName.

public static String getName(Object obj) {
    // $NON-NLS-1$
    String res = "";
    if (obj instanceof IPersistentClass) {
        IPersistentClass rootClass = (IPersistentClass) obj;
        if (rootClass.getEntityName() != null) {
            res = rootClass.getEntityName();
        } else {
            res = rootClass.getClassName();
        }
    } else if (obj instanceof ITable) {
        res = getTableName((ITable) obj);
    } else if (obj instanceof IProperty) {
        IProperty property = (IProperty) obj;
        // $NON-NLS-1$
        res = getName(property.getPersistentClass()) + "." + property.getName();
    } else if (obj instanceof IValue && ((IValue) obj).isSimpleValue()) {
        IValue sv = (IValue) obj;
        // $NON-NLS-1$
        res = getTableName(sv.getTable()) + "." + sv.getForeignKeyName();
    } else if (obj instanceof String) {
        res = (String) obj;
    }
    if (res.length() > 0 && res.indexOf(".") < 0) {
        // $NON-NLS-1$
        return "default." + res;
    }
    if (res.length() == 0) {
        // $NON-NLS-1$
        res = "null";
    }
    return res;
}
Also used : IValue(org.jboss.tools.hibernate.runtime.spi.IValue) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 77 with IValue

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

the class OrmLabelMap method getParticularLabel.

public static String getParticularLabel(IProperty field, final ConsoleConfiguration cfg) {
    StringBuffer name = new StringBuffer();
    name.append(field.getName());
    // $NON-NLS-1$
    name.append(" :");
    String typeString = null;
    IValue v = field.getValue();
    IType type = UtilTypeExtract.getTypeUsingExecContext(v, cfg);
    if (type != null && type.getAssociatedEntityName() != null) {
        typeString = type.getAssociatedEntityName();
    } else {
        IValue fieldValue = field.getValue();
        if (fieldValue != null && fieldValue.isComponent()) {
            typeString = fieldValue.getComponentClassName();
        } else if (fieldValue != null && fieldValue.isSimpleValue()) {
            typeString = fieldValue.getTypeName();
        }
    }
    if (typeString != null) {
        typeString = correctTypeString(typeString);
        name.append(SPACE);
        name.append(typeString);
        return name.toString();
    }
    IValue value = field.getValue();
    String typeName = null;
    if (value != null) {
        typeName = (String) new ValueTypeNameHelper(false).getTypeName(value);
        if (typeName != null) {
            // $NON-NLS-1$
            return field.getName() + " : " + typeName;
        }
    }
    return field.getName();
}
Also used : IValue(org.jboss.tools.hibernate.runtime.spi.IValue) ValueTypeNameHelper(org.hibernate.eclipse.console.workbench.ValueTypeNameHelper) IType(org.jboss.tools.hibernate.runtime.spi.IType)

Example 78 with IValue

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

the class ComponentShape method initModel.

/**
 * creates children of the shape,
 */
protected void initModel() {
    Object ormElement = getOrmElement();
    if (ormElement instanceof IProperty) {
        IValue collection = ((IProperty) ormElement).getValue();
        Shape bodyOrmShape = new Shape(collection.getKey(), getConsoleConfigName());
        bodyOrmShape.setIndent(20);
        addChild(bodyOrmShape);
        bodyOrmShape = new Shape(collection.getElement(), getConsoleConfigName());
        bodyOrmShape.setIndent(20);
        addChild(bodyOrmShape);
    }
}
Also used : IValue(org.jboss.tools.hibernate.runtime.spi.IValue) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty)

Example 79 with IValue

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

the class HbmExporterTest method testProperty.

public void testProperty() {
    // $NON-NLS-1$
    IConfiguration config = getConfigurationFor("pack.A");
    // $NON-NLS-1$ //$NON-NLS-2$
    checkClassesMaped(config, "pack.A", "pack.B");
    // $NON-NLS-1$
    IPersistentClass a = config.getClassMapping("pack.A");
    // $NON-NLS-1$
    IProperty prop = a.getProperty("prop");
    assertNotNull(prop.getValue());
    IValue value = prop.getValue();
    // $NON-NLS-1$
    assertTrue("Expected to get ManyToOne-type mapping", value.isManyToOne());
    // $NON-NLS-1$
    assertEquals("pack.B", value.getTypeName());
}
Also used : IValue(org.jboss.tools.hibernate.runtime.spi.IValue) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 80 with IValue

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

the class HbmExporterTest method testSet.

public void testSet() {
    // $NON-NLS-1$
    IConfiguration config = getConfigurationFor("pack.A");
    // $NON-NLS-1$ //$NON-NLS-2$
    checkClassesMaped(config, "pack.A", "pack.B");
    // $NON-NLS-1$
    IPersistentClass a = config.getClassMapping("pack.A");
    // $NON-NLS-1$
    IPersistentClass b = config.getClassMapping("pack.B");
    // $NON-NLS-1$
    IProperty setProp = a.getProperty("set");
    assertNotNull(setProp.getValue());
    IValue value = setProp.getValue();
    assertTrue("Expected to get Set-type mapping", value.isSet());
    assertTrue(value.getCollectionElement().isOneToMany());
    assertTrue(value.getCollectionTable().equals(b.getTable()));
    assertNotNull(value.getKey());
}
Also used : IValue(org.jboss.tools.hibernate.runtime.spi.IValue) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Aggregations

IValue (org.jboss.tools.hibernate.runtime.spi.IValue)144 Test (org.junit.Test)105 SimpleValue (org.hibernate.mapping.SimpleValue)68 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)59 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)40 Bag (org.hibernate.mapping.Bag)20 Set (org.hibernate.mapping.Set)20 IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)20 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)17 IdentifierBag (org.hibernate.mapping.IdentifierBag)16 KeyValue (org.hibernate.mapping.KeyValue)16 RootClass (org.hibernate.mapping.RootClass)16 Value (org.hibernate.mapping.Value)16 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)13 Collection (org.hibernate.mapping.Collection)8 Component (org.hibernate.mapping.Component)8 List (org.hibernate.mapping.List)8 PersistentClass (org.hibernate.mapping.PersistentClass)8 PrimitiveArray (org.hibernate.mapping.PrimitiveArray)8 Table (org.hibernate.mapping.Table)8