use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class AbstractHQLCompletionProposalFacade method getProperty.
@Override
public IProperty getProperty() {
IProperty result = null;
Object targetProperty = Util.invokeMethod(getTarget(), "getProperty", new Class[] {}, new Object[] {});
if (targetProperty != null) {
result = getFacadeFactory().createProperty(targetProperty);
}
return result;
}
use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class SpecialRootClassFacadeImpl method getMetadataBuildingContext.
private static MetadataBuildingContext getMetadataBuildingContext(IProperty property) {
Property target = (Property) ((IFacade) property).getTarget();
PersistentClass pc = target.getPersistentClass();
MetadataBuildingContext result = null;
try {
Field field = PersistentClass.class.getDeclaredField("metadataBuildingContext");
field.setAccessible(true);
result = (MetadataBuildingContext) field.get(pc);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
throw new RuntimeException("Problem while trying to retrieve MetadataBuildingContext from field", e);
}
return result;
}
use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class ElementsFactory method createShape.
protected OrmShape createShape(Object ormElement) {
OrmShape ormShape = null;
if (ormElement instanceof IProperty) {
IPersistentClass specialRootClass = getService().newSpecialRootClass((IProperty) ormElement);
String key = Utils.getName(specialRootClass.getEntityName());
ormShape = elements.get(key);
if (null == ormShape) {
ormShape = new SpecialOrmShape(specialRootClass, consoleConfigName);
elements.put(key, ormShape);
}
} else {
String key = Utils.getName(ormElement);
ormShape = elements.get(key);
if (null == ormShape) {
ormShape = new OrmShape(ormElement, consoleConfigName);
elements.put(key, ormShape);
}
}
return ormShape;
}
use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class ElementsFactory method getOrCreatePersistentClass.
@SuppressWarnings({ "rawtypes" })
protected OrmShape getOrCreatePersistentClass(IPersistentClass persistentClass, ITable componentClassDatabaseTable) {
OrmShape classShape = null;
if (persistentClass == null) {
return classShape;
}
OrmShape shape = null;
classShape = getShape(persistentClass.getEntityName());
if (classShape == null) {
classShape = createShape(persistentClass);
}
if (componentClassDatabaseTable == null && persistentClass.getTable() != null) {
componentClassDatabaseTable = persistentClass.getTable();
}
if (componentClassDatabaseTable != null) {
shape = getShape(componentClassDatabaseTable);
if (shape == null) {
shape = getOrCreateDatabaseTable(componentClassDatabaseTable);
}
createConnections(classShape, shape);
if (shouldCreateConnection(classShape, shape)) {
connections.add(new Connection(classShape, shape));
}
}
IPersistentClass rc = persistentClass;
Iterator iter = rc.getSubclassIterator();
while (iter.hasNext()) {
Object element = iter.next();
if (element instanceof IPersistentClass && ((IPersistentClass) element).isInstanceOfSubclass()) {
IPersistentClass subclass = (IPersistentClass) element;
OrmShape subclassShape = getShape(subclass);
if (subclassShape == null) {
subclassShape = createShape(subclass);
}
if (((IPersistentClass) element).isJoinedSubclass()) {
ITable jcTable = ((IPersistentClass) element).getTable();
OrmShape jcTableShape = getOrCreateDatabaseTable(jcTable);
createConnections(subclassShape, jcTableShape);
if (shouldCreateConnection(subclassShape, jcTableShape)) {
connections.add(new Connection(subclassShape, jcTableShape));
}
} else {
createConnections(subclassShape, shape);
if (shouldCreateConnection(subclassShape, shape)) {
connections.add(new Connection(subclassShape, shape));
}
}
OrmShape ownerTableShape = getOrCreateDatabaseTable(((IPersistentClass) element).getRootTable());
createConnections(subclassShape, ownerTableShape);
Iterator<IJoin> joinIterator = subclass.getJoinIterator();
while (joinIterator.hasNext()) {
IJoin join = joinIterator.next();
Iterator<IProperty> iterator = join.getPropertyIterator();
while (iterator.hasNext()) {
IProperty property = iterator.next();
OrmShape tableShape = getOrCreateDatabaseTable(property.getValue().getTable());
createConnections(subclassShape, tableShape);
}
}
}
}
IValue identifier = persistentClass.getIdentifier();
if (identifier != null && identifier.isComponent()) {
if (identifier.getComponentClassName() != null && !identifier.getComponentClassName().equals(identifier.getOwner().getEntityName())) {
OrmShape componentClassShape = elements.get(identifier.getComponentClassName());
if (componentClassShape == null && persistentClass.isInstanceOfRootClass()) {
componentClassShape = getOrCreateComponentClass(persistentClass.getIdentifierProperty());
Shape idPropertyShape = classShape.getChild(persistentClass.getIdentifierProperty());
if (shouldCreateConnection(idPropertyShape, componentClassShape)) {
connections.add(new Connection(idPropertyShape, componentClassShape));
}
OrmShape tableShape = getOrCreateDatabaseTable(identifier.getTable());
if (componentClassShape != null) {
createConnections(componentClassShape, tableShape);
}
}
}
}
Iterator<IJoin> joinIterator = persistentClass.getJoinIterator();
while (joinIterator.hasNext()) {
IJoin join = (IJoin) joinIterator.next();
Iterator<IProperty> iterator = join.getPropertyIterator();
while (iterator.hasNext()) {
IProperty property = iterator.next();
OrmShape tableShape = getOrCreateDatabaseTable(property.getValue().getTable());
createConnections(classShape, tableShape);
}
}
return classShape;
}
use of org.jboss.tools.hibernate.runtime.spi.IProperty in project jbosstools-hibernate by jbosstools.
the class ElementsFactory method processExpand.
protected void processExpand(ExpandableShape shape) {
Object element = shape.getOrmElement();
if (!(element instanceof IProperty)) {
return;
}
OrmShape s = null;
IProperty property = (IProperty) element;
if (!property.isComposite()) {
final IConfiguration config = getConfig();
//
IValue v = property.getValue();
IType type = UtilTypeExtract.getTypeUsingExecContext(v, getConsoleConfig());
if (type != null && type.isEntityType()) {
Object clazz = config != null ? config.getClassMapping(type.getAssociatedEntityName()) : null;
if (clazz instanceof IPersistentClass && ((IPersistentClass) clazz).isInstanceOfRootClass()) {
IPersistentClass rootClass = (IPersistentClass) clazz;
s = getOrCreatePersistentClass(rootClass, null);
if (shouldCreateConnection(shape, s)) {
connections.add(new Connection(shape, s));
}
} else if (clazz instanceof IPersistentClass && ((IPersistentClass) clazz).isInstanceOfSubclass()) {
s = getOrCreatePersistentClass(((IPersistentClass) clazz).getRootClass(), null);
}
}
} else {
s = getOrCreatePersistentClass(getService().newSpecialRootClass(property), null);
if (shouldCreateConnection(shape, s)) {
connections.add(new Connection(shape, s));
}
createConnections(s, getOrCreateDatabaseTable(property.getValue().getTable()));
}
}
Aggregations