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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations