Search in sources :

Example 91 with IPersistentClass

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

the class ConfigurationFacadeImpl method initializeClassMappings.

@Override
protected void initializeClassMappings() {
    HashMap<String, IPersistentClass> classMappings = new HashMap<String, IPersistentClass>();
    Iterator<PersistentClass> origin = getMetadata().getEntityBindings().iterator();
    while (origin.hasNext()) {
        IPersistentClass pc = getFacadeFactory().createPersistentClass(origin.next());
        classMappings.put(pc.getEntityName(), pc);
    }
    for (IPersistentClass pc : addedClasses) {
        classMappings.put(pc.getEntityName(), pc);
    }
    setClassMappings(classMappings);
}
Also used : HashMap(java.util.HashMap) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) PersistentClass(org.hibernate.mapping.PersistentClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 92 with IPersistentClass

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

the class ServiceImpl method newSingleTableSubclass.

@Override
public IPersistentClass newSingleTableSubclass(IPersistentClass persistentClass) {
    assert persistentClass instanceof IFacade;
    IPersistentClass result = facadeFactory.createPersistentClass(new SingleTableSubclass((PersistentClass) ((IFacade) persistentClass).getTarget(), null));
    ((AbstractPersistentClassFacade) result).setSuperClass(persistentClass);
    return result;
}
Also used : AbstractPersistentClassFacade(org.jboss.tools.hibernate.runtime.common.AbstractPersistentClassFacade) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) SingleTableSubclass(org.hibernate.mapping.SingleTableSubclass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) PersistentClass(org.hibernate.mapping.PersistentClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 93 with IPersistentClass

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

the class ShapeHideAction method canPerformAction.

private boolean canPerformAction() {
    boolean res = false;
    if (getSelectedObjects().isEmpty()) {
        return res;
    }
    Iterator<?> it = getSelectedObjects().iterator();
    while (it.hasNext() && !res) {
        Object firstElement = it.next();
        Object obj = null;
        if (firstElement instanceof OrmEditPart) {
            obj = ((OrmEditPart) firstElement).getModel();
        } else if (firstElement instanceof AbstractTreeEditPart) {
            obj = ((AbstractTreeEditPart) firstElement).getModel();
        }
        if (null != obj && obj instanceof OrmShape) {
            OrmShape ormShape = (OrmShape) obj;
            Object ormElement = ormShape.getOrmElement();
            if (ormElement instanceof IPersistentClass || ormElement instanceof ITable) {
                if (ormShape.isVisible()) {
                    res = true;
                }
            }
        }
    }
    return res;
}
Also used : OrmShape(org.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape) AbstractTreeEditPart(org.eclipse.gef.editparts.AbstractTreeEditPart) OrmEditPart(org.jboss.tools.hibernate.ui.diagram.editors.parts.OrmEditPart) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 94 with IPersistentClass

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

the class ElementsFactory method createConnections.

@SuppressWarnings("rawtypes")
private boolean createConnections(ExpandableShape persistentClass, ExpandableShape dbTable) {
    boolean res = false;
    if (persistentClass == null || dbTable == null) {
        return res;
    }
    IProperty parentProperty = null;
    if (persistentClass.getOrmElement() instanceof IPersistentClass && ((IPersistentClass) persistentClass.getOrmElement()).isInstanceOfSpecialRootClass()) {
        parentProperty = ((IPersistentClass) persistentClass.getOrmElement()).getParentProperty();
    }
    Iterator<Shape> itFields = persistentClass.getChildrenIterator();
    Set<Shape> processed = new HashSet<Shape>();
    while (itFields.hasNext()) {
        final Shape shape = itFields.next();
        Object element = shape.getOrmElement();
        if (!(element instanceof IProperty && parentProperty != element)) {
            continue;
        }
        IValue value = ((IProperty) element).getValue();
        Iterator iterator = value.getColumnIterator();
        while (iterator.hasNext()) {
            Object o = iterator.next();
            if (!(o instanceof IColumn)) {
                continue;
            }
            IColumn dbColumn = (IColumn) o;
            Iterator<Shape> itColumns = dbTable.getChildrenIterator();
            while (itColumns.hasNext()) {
                final Shape shapeCol = itColumns.next();
                if (processed.contains(shapeCol)) {
                    continue;
                }
                if (shape.equals(shapeCol)) {
                    continue;
                }
                Object ormElement = shapeCol.getOrmElement();
                // $NON-NLS-1$
                String name2 = "";
                if (ormElement instanceof IColumn) {
                    IColumn dbColumn2 = (IColumn) ormElement;
                    name2 = dbColumn2.getName();
                } else if (ormElement instanceof IProperty) {
                    IProperty property2 = (IProperty) ormElement;
                    name2 = property2.getName();
                }
                if (dbColumn.getName().equals(name2)) {
                    if (shouldCreateConnection(shape, shapeCol)) {
                        connections.add(new Connection(shape, shapeCol));
                        res = true;
                    }
                    processed.add(shapeCol);
                }
            }
        }
    }
    return res;
}
Also used : IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) IValue(org.jboss.tools.hibernate.runtime.spi.IValue) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) IColumn(org.jboss.tools.hibernate.runtime.spi.IColumn) Iterator(java.util.Iterator) HashSet(java.util.HashSet)

Example 95 with IPersistentClass

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

the class ElementsFactory method getShape.

public OrmShape getShape(Object ormElement) {
    OrmShape ormShape = null;
    if (ormElement instanceof IProperty) {
        IPersistentClass specialRootClass = getService().newSpecialRootClass((IProperty) ormElement);
        ormShape = elements.get(Utils.getName(specialRootClass.getEntityName()));
    } else {
        ormShape = elements.get(Utils.getName(ormElement));
    }
    return ormShape;
}
Also used : IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Aggregations

IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)175 Test (org.junit.Test)97 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)60 IValue (org.jboss.tools.hibernate.runtime.spi.IValue)51 RootClass (org.hibernate.mapping.RootClass)47 IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)46 PersistentClass (org.hibernate.mapping.PersistentClass)43 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)19 AbstractPersistentClassFacade (org.jboss.tools.hibernate.runtime.common.AbstractPersistentClassFacade)16 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)16 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)14 OneToMany (org.hibernate.mapping.OneToMany)12 HashMap (java.util.HashMap)8 Iterator (java.util.Iterator)8 JoinedSubclass (org.hibernate.mapping.JoinedSubclass)8 PrimitiveArray (org.hibernate.mapping.PrimitiveArray)8 Property (org.hibernate.mapping.Property)8 SingleTableSubclass (org.hibernate.mapping.SingleTableSubclass)8 IEditorPart (org.eclipse.ui.IEditorPart)7 PartInitException (org.eclipse.ui.PartInitException)7