use of org.jkiss.dbeaver.model.meta.Property in project dbeaver by serge-rider.
the class OracleDataType method getComponentType.
@Property(viewable = true, order = 8)
public OracleDataType getComponentType(@NotNull DBRProgressMonitor monitor) throws DBCException {
if (componentType != null) {
return componentType;
}
OracleSchema schema = getSchema();
if (schema == null || !TYPE_CODE_COLLECTION.equals(typeCode) || !getDataSource().isAtLeastV10()) {
return null;
}
try (JDBCSession session = DBUtils.openMetaSession(monitor, getDataSource(), "Load collection types")) {
try (JDBCPreparedStatement dbStat = session.prepareStatement("SELECT ELEM_TYPE_OWNER,ELEM_TYPE_NAME,ELEM_TYPE_MOD FROM SYS.ALL_COLL_TYPES WHERE OWNER=? AND TYPE_NAME=?")) {
dbStat.setString(1, schema.getName());
dbStat.setString(2, getName());
try (JDBCResultSet dbResults = dbStat.executeQuery()) {
if (dbResults.next()) {
String compTypeSchema = JDBCUtils.safeGetString(dbResults, "ELEM_TYPE_OWNER");
String compTypeName = JDBCUtils.safeGetString(dbResults, "ELEM_TYPE_NAME");
//String compTypeMod = JDBCUtils.safeGetString(dbResults, "ELEM_TYPE_MOD");
componentType = OracleDataType.resolveDataType(monitor, getDataSource(), compTypeSchema, compTypeName);
} else {
log.warn("Can't resolve collection type [" + getName() + "]");
}
}
}
} catch (Exception e) {
log.warn("Error reading collection types", e);
}
return componentType;
}
use of org.jkiss.dbeaver.model.meta.Property in project dbeaver by serge-rider.
the class PostgreViewBase method getObjectDefinitionText.
@Override
@Property(hidden = true, editable = true, updatable = true, order = -1)
public String getObjectDefinitionText(DBRProgressMonitor monitor) throws DBException {
if (source == null) {
if (isPersisted()) {
try (JDBCSession session = DBUtils.openMetaSession(monitor, getDataSource(), "Read view definition")) {
String definition = JDBCUtils.queryString(session, "SELECT pg_get_viewdef(?, true)", getObjectId());
this.source = PostgreUtils.getViewDDL(this, definition);
} catch (SQLException e) {
throw new DBException("Error reading view definition", e);
}
} else {
source = "";
}
}
return source;
}
use of org.jkiss.dbeaver.model.meta.Property in project dbeaver by serge-rider.
the class ObjectAttributeDescriptor method extractAnnotations.
static void extractAnnotations(DBPPropertySource source, ObjectPropertyGroupDescriptor parent, Class<?> theClass, List<ObjectPropertyDescriptor> annoProps, IPropertyFilter filter) {
Method[] methods = theClass.getMethods();
Map<String, Method> passedNames = new HashMap<>();
for (Method method : methods) {
String methodFullName = method.getDeclaringClass().getName() + "." + method.getName();
final Method prevMethod = passedNames.get(methodFullName);
if (prevMethod != null) {
// The same method but probably with another return type
final Class<?> prevReturnType = prevMethod.getReturnType();
final Class<?> newReturnType = method.getReturnType();
if (newReturnType == null || prevReturnType == null || newReturnType == prevReturnType || !prevReturnType.isAssignableFrom(newReturnType)) {
continue;
}
// Let it another chance. New return types seems to be subclass of previous
}
final PropertyGroup propGroupInfo = method.getAnnotation(PropertyGroup.class);
if (propGroupInfo != null && method.getReturnType() != null) {
// Property group
ObjectPropertyGroupDescriptor groupDescriptor = new ObjectPropertyGroupDescriptor(source, parent, method, propGroupInfo, filter);
annoProps.addAll(groupDescriptor.getChildren());
} else {
final Property propInfo = method.getAnnotation(Property.class);
if (propInfo == null || !BeanUtils.isGetterName(method.getName()) || method.getReturnType() == null) {
continue;
}
// Single property
ObjectPropertyDescriptor desc = new ObjectPropertyDescriptor(source, parent, propInfo, method);
if (filter != null && !filter.select(desc)) {
continue;
}
if (prevMethod != null) {
// Remove previous anno
for (Iterator<ObjectPropertyDescriptor> iter = annoProps.iterator(); iter.hasNext(); ) {
if (iter.next().getId().equals(desc.getId())) {
iter.remove();
}
}
}
annoProps.add(desc);
passedNames.put(methodFullName, method);
}
}
Collections.sort(annoProps, ATTRIBUTE_DESCRIPTOR_COMPARATOR);
}
Aggregations