Search in sources :

Example 51 with IProperty

use of org.jboss.tools.hibernate.runtime.spi.IProperty 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 52 with IProperty

use of org.jboss.tools.hibernate.runtime.spi.IProperty 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 53 with IProperty

use of org.jboss.tools.hibernate.runtime.spi.IProperty 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)

Example 54 with IProperty

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

the class HbmExporterTest method testArray.

public void testArray() {
    // $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 bs = a.getProperty("bs");
    assertNotNull(bs.getValue());
    IValue value = bs.getValue();
    assertTrue("Expected to get Array-type mapping", value.isArray());
    // $NON-NLS-1$
    assertEquals("pack.B", value.getElementClassName());
    assertTrue(// $NON-NLS-1$
    "Expected to get one-to-many array's element type", value.getCollectionElement().isOneToMany());
    // $NON-NLS-1$
    IProperty testIntArray = b.getProperty("testIntArray");
    assertNotNull(testIntArray);
    value = testIntArray.getValue();
    assertNotNull(value);
    assertTrue(// $NON-NLS-1$
    "Expected to get PrimitiveArray-type mapping", value.isPrimitiveArray());
    assertNotNull(value.getCollectionElement());
    // $NON-NLS-1$
    assertTrue("Expected to get int-type primitive array", value.getCollectionElement().getType().isIntegerType());
}
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 55 with IProperty

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

the class OpenMappingFileTest method testOpenMappingFileTest.

public void testOpenMappingFileTest() {
    final Object[] persClasses = getPersistenceClasses(false);
    final ConsoleConfiguration consCFG = getConsoleConfig();
    // $NON-NLS-1$
    final String testClass = "class";
    for (int i = 0; i < persClasses.length; i++) {
        assertTrue(persClasses[i] instanceof IPersistentClass);
        IPersistentClass persClass = (IPersistentClass) persClasses[i];
        openTest(persClass, consCFG);
        Object[] props = pcWorkbenchAdapter.getChildren(persClass);
        for (int j = 0; j < props.length; j++) {
            if (!(props[j] instanceof IProperty && ((IProperty) props[j]).classIsPropertyClass())) {
                continue;
            }
            openTest(props[j], consCFG);
            Object[] compProperties = propertyWorkbenchAdapter.getChildren(props[j]);
            for (int k = 0; k < compProperties.length; k++) {
                // test Composite properties
                if (!(compProperties[k] instanceof IProperty && ((IProperty) props[j]).classIsPropertyClass())) {
                    continue;
                }
                final IProperty prop = (IProperty) compProperties[k];
                if (testClass.equals(prop.getName()) || testClass.equals(prop.getName())) {
                    continue;
                }
                openPropertyTest((IProperty) compProperties[k], (IProperty) props[j], consCFG);
            }
        }
    }
// close all editors
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

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