use of org.jboss.tools.hibernate.runtime.spi.IPersistentClass in project jbosstools-hibernate by jbosstools.
the class OrmDiagram method equals.
public boolean equals(Object obj) {
boolean res = false;
if (!(obj instanceof OrmDiagram)) {
return res;
}
final OrmDiagram od = (OrmDiagram) obj;
if (consoleConfigName == null) {
if (od.getConsoleConfigName() != null) {
return res;
}
} else if (!consoleConfigName.equals(od.getConsoleConfigName())) {
return res;
}
final ArrayList<IPersistentClass> rootsOd = od.roots;
if (roots.size() != rootsOd.size()) {
return res;
}
res = true;
for (int i = 0; i < roots.size(); i++) {
IPersistentClass rc = roots.get(i);
if (rc == null) {
if (rc != rootsOd.get(i)) {
res = false;
break;
}
} else if (!rc.equals(rootsOd.get(i))) {
res = false;
break;
}
}
return res;
}
use of org.jboss.tools.hibernate.runtime.spi.IPersistentClass in project jbosstools-hibernate by jbosstools.
the class OrmShape method initModel.
/**
* creates children of the shape,
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void initModel() {
Object ormElement = getOrmElement();
if (ormElement instanceof IPersistentClass && ((IPersistentClass) ormElement).isInstanceOfRootClass()) {
IPersistentClass rootClass = (IPersistentClass) ormElement;
IProperty identifierProperty = rootClass.getIdentifierProperty();
if (identifierProperty != null) {
addChild(new Shape(identifierProperty, getConsoleConfigName()));
}
IValue identifier = rootClass.getIdentifier();
if (identifier != null && identifier.isComponent()) {
IValue component = identifier;
if (component.isEmbedded()) {
Iterator<IProperty> iterator = identifier.getPropertyIterator();
while (iterator.hasNext()) {
IProperty property = iterator.next();
addChild(new Shape(property, getConsoleConfigName()));
}
}
}
Iterator<IProperty> iterator = rootClass.getPropertyIterator();
while (iterator.hasNext()) {
IProperty field = iterator.next();
if (!field.isBackRef()) {
if (!field.isComposite()) {
final IValue val = field.getValue();
Shape bodyOrmShape = null;
if (val.isSimpleValue() && val.isTypeSpecified()) {
bodyOrmShape = new Shape(field, getConsoleConfigName());
} else {
if (val.isCollection()) {
bodyOrmShape = new ComponentShape(field, getConsoleConfigName());
} else {
IType type = getTypeUsingExecContext(val);
if (type != null && type.isEntityType()) {
bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
} else {
bodyOrmShape = new Shape(field, getConsoleConfigName());
}
}
}
addChild(bodyOrmShape);
} else {
Shape bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
addChild(bodyOrmShape);
}
}
}
} else if (ormElement instanceof IPersistentClass && ((IPersistentClass) ormElement).isInstanceOfSubclass()) {
IPersistentClass rootClass = ((IPersistentClass) ormElement).getRootClass();
IProperty identifierProperty = rootClass.getIdentifierProperty();
if (identifierProperty != null) {
addChild(new Shape(identifierProperty, getConsoleConfigName()));
}
IValue identifier = rootClass.getIdentifier();
if (identifier.isComponent()) {
Iterator<IProperty> iterator = identifier.getPropertyIterator();
while (iterator.hasNext()) {
IProperty property = iterator.next();
addChild(new Shape(property, getConsoleConfigName()));
}
}
Iterator<IProperty> iterator = rootClass.getPropertyIterator();
while (iterator.hasNext()) {
IProperty field = iterator.next();
if (!field.isBackRef()) {
if (!field.isComposite()) {
IValue fieldValue = field.getValue();
boolean typeIsAccessible = true;
if (fieldValue.isSimpleValue() && fieldValue.isTypeSpecified()) {
try {
field.getValue().getType();
} catch (Exception e) {
typeIsAccessible = false;
}
}
Shape bodyOrmShape = null;
if (typeIsAccessible && field.getValue().isSimpleValue()) {
bodyOrmShape = new Shape(field, getConsoleConfigName());
} else if (typeIsAccessible && field.getValue().getType().isEntityType()) {
bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
} else if (typeIsAccessible && field.getValue().getType().isCollectionType()) {
bodyOrmShape = new ComponentShape(field, getConsoleConfigName());
} else {
bodyOrmShape = new Shape(field, getConsoleConfigName());
}
addChild(bodyOrmShape);
} else {
Shape bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
addChild(bodyOrmShape);
}
}
}
Iterator<IProperty> iter = ((IPersistentClass) ormElement).getPropertyIterator();
while (iter.hasNext()) {
IProperty property = iter.next();
if (!property.isBackRef()) {
if (!property.isComposite()) {
boolean typeIsAccessible = true;
IValue propertyValue = property.getValue();
if (propertyValue.isSimpleValue() && propertyValue.isTypeSpecified()) {
try {
property.getValue().getType();
} catch (Exception e) {
typeIsAccessible = false;
}
}
Shape bodyOrmShape = null;
if (typeIsAccessible && property.getValue().getType().isEntityType()) {
bodyOrmShape = new ExpandableShape(property, getConsoleConfigName());
} else if (typeIsAccessible && property.getValue().getType().isCollectionType()) {
bodyOrmShape = new ComponentShape(property, getConsoleConfigName());
} else {
bodyOrmShape = new Shape(property, getConsoleConfigName());
}
addChild(bodyOrmShape);
} else {
Shape bodyOrmShape = new ExpandableShape(property, getConsoleConfigName());
addChild(bodyOrmShape);
}
}
}
} else if (ormElement instanceof ITable) {
Iterator iterator = ((ITable) getOrmElement()).getColumnIterator();
while (iterator.hasNext()) {
IColumn column = (IColumn) iterator.next();
Shape bodyOrmShape = new Shape(column, getConsoleConfigName());
addChild(bodyOrmShape);
}
}
}
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 ShapeShowAction 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 ToggleShapeVisibleStateAction method canPerformAction.
@SuppressWarnings("unchecked")
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) {
Object ormElement = ((OrmShape) obj).getOrmElement();
if (ormElement instanceof IPersistentClass || ormElement instanceof ITable) {
res = true;
}
}
}
return res;
}
Aggregations