use of org.jboss.tools.hibernate.runtime.spi.IValue in project jbosstools-hibernate by jbosstools.
the class Utils method getName.
public static String getName(Object obj) {
// $NON-NLS-1$
String res = "";
if (obj instanceof IPersistentClass) {
IPersistentClass rootClass = (IPersistentClass) obj;
if (rootClass.getEntityName() != null) {
res = rootClass.getEntityName();
} else {
res = rootClass.getClassName();
}
} else if (obj instanceof ITable) {
res = getTableName((ITable) obj);
} else if (obj instanceof IProperty) {
IProperty property = (IProperty) obj;
// $NON-NLS-1$
res = getName(property.getPersistentClass()) + "." + property.getName();
} else if (obj instanceof IValue && ((IValue) obj).isSimpleValue()) {
IValue sv = (IValue) obj;
// $NON-NLS-1$
res = getTableName(sv.getTable()) + "." + sv.getForeignKeyName();
} else if (obj instanceof String) {
res = (String) obj;
}
if (res.length() > 0 && res.indexOf(".") < 0) {
// $NON-NLS-1$
return "default." + res;
}
if (res.length() == 0) {
// $NON-NLS-1$
res = "null";
}
return res;
}
use of org.jboss.tools.hibernate.runtime.spi.IValue in project jbosstools-hibernate by jbosstools.
the class OrmLabelMap method getParticularLabel.
public static String getParticularLabel(IProperty field, final ConsoleConfiguration cfg) {
StringBuffer name = new StringBuffer();
name.append(field.getName());
// $NON-NLS-1$
name.append(" :");
String typeString = null;
IValue v = field.getValue();
IType type = UtilTypeExtract.getTypeUsingExecContext(v, cfg);
if (type != null && type.getAssociatedEntityName() != null) {
typeString = type.getAssociatedEntityName();
} else {
IValue fieldValue = field.getValue();
if (fieldValue != null && fieldValue.isComponent()) {
typeString = fieldValue.getComponentClassName();
} else if (fieldValue != null && fieldValue.isSimpleValue()) {
typeString = fieldValue.getTypeName();
}
}
if (typeString != null) {
typeString = correctTypeString(typeString);
name.append(SPACE);
name.append(typeString);
return name.toString();
}
IValue value = field.getValue();
String typeName = null;
if (value != null) {
typeName = (String) new ValueTypeNameHelper(false).getTypeName(value);
if (typeName != null) {
// $NON-NLS-1$
return field.getName() + " : " + typeName;
}
}
return field.getName();
}
use of org.jboss.tools.hibernate.runtime.spi.IValue 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);
}
}
use of org.jboss.tools.hibernate.runtime.spi.IValue 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());
}
use of org.jboss.tools.hibernate.runtime.spi.IValue 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());
}
Aggregations