use of org.eclipse.persistence.tools.oracleddl.metadata.DatabaseType in project eclipselink by eclipse-ee4j.
the class OracleHelper method getStructureNameForField.
/**
* Return the structure name to be set on a mapping based on a given
* FieldType and packageName.
*/
protected String getStructureNameForField(FieldType fType, String packageName) {
DatabaseType type = fType.getEnclosedType();
String structureName = type.getTypeName();
if (packageName != null && packageName.length() > 0 && !packageName.equals(TOPLEVEL)) {
structureName = packageName + UNDERSCORE + structureName;
}
return structureName;
}
use of org.eclipse.persistence.tools.oracleddl.metadata.DatabaseType in project eclipselink by eclipse-ee4j.
the class OracleHelper method addToOXProjectForPLSQLTableArg.
/**
* Build descriptor and mappings for a PL/SQL collection argument. The newly
* created descriptor will be added to the given OX project.
*/
protected void addToOXProjectForPLSQLTableArg(DatabaseType dbType, Project oxProject, String tableName, String tableAlias, String targetTypeName, String catalogPattern) {
XMLDescriptor xdesc = (XMLDescriptor) oxProject.getDescriptorForAlias(tableAlias);
if (xdesc == null) {
xdesc = buildAndAddNewXMLDescriptor(oxProject, tableAlias, tableName.toLowerCase() + COLLECTION_WRAPPER_SUFFIX, nct.generateSchemaAlias(targetTypeName), buildCustomQName(targetTypeName, dbwsBuilder).getNamespaceURI());
}
boolean itemsMappingFound = xdesc.getMappingForAttributeName(ITEMS_MAPPING_ATTRIBUTE_NAME) == null ? false : true;
if (!itemsMappingFound) {
DatabaseType nestedType = ((PLSQLCollectionType) dbType).getEnclosedType();
if (nestedType.isPLSQLRecordType()) {
String referenceClassName = (catalogPattern + DOT + ((PLSQLRecordType) nestedType).getTypeName()).toLowerCase();
buildAndAddXMLCompositeCollectionMapping(xdesc, referenceClassName);
if (oxProject.getDescriptorForAlias(referenceClassName) == null) {
String refTypeName = catalogPattern + UNDERSCORE + ((PLSQLRecordType) nestedType).getTypeName();
addToOXProjectForPLSQLRecordArg(nestedType, oxProject, referenceClassName, refTypeName.toLowerCase(), refTypeName, catalogPattern);
}
} else if (nestedType.isObjectType()) {
buildAndAddXMLCompositeCollectionMapping(xdesc, getGeneratedJavaClassName(nestedType.getTypeName(), dbwsBuilder.getProjectName()));
} else {
if (nestedType.isComposite()) {
buildAndAddXMLCompositeCollectionMapping(xdesc, tableName.toLowerCase() + COLLECTION_WRAPPER_SUFFIX);
} else {
buildAndAddXMLCompositeDirectCollectionMapping(xdesc, ITEMS_MAPPING_ATTRIBUTE_NAME, ITEM_MAPPING_NAME + SLASH + TEXT, getAttributeClassForDatabaseType(nestedType));
}
}
}
}
use of org.eclipse.persistence.tools.oracleddl.metadata.DatabaseType in project eclipselink by eclipse-ee4j.
the class OracleHelper method addToOROXProjectsForComplexTypes.
/**
* Create OR/OX projects for complex types, i.e. PLSQLTypes, VArray, etc.
*/
@Override
public void addToOROXProjectsForComplexTypes(List<CompositeDatabaseType> types, Project orProject, Project oxProject) {
for (DatabaseType dbType : types) {
String name;
String alias;
if (dbType.isPLSQLType()) {
// set type name to upper case to avoid runtime SQLException
dbType.setTypeName(dbType.getTypeName().toUpperCase());
String catalogPattern = ((PLSQLType) dbType).getParentType().getPackageName();
String targetTypeName;
// for types enclosed in a ROWTYPEType, package doesn't apply
if (catalogPattern == null) {
name = dbType.getTypeName();
targetTypeName = dbType.getTypeName();
} else {
name = catalogPattern + DOT + dbType.getTypeName();
targetTypeName = catalogPattern + UNDERSCORE + dbType.getTypeName();
}
alias = targetTypeName.toLowerCase();
// remove '%' from target, alias, and name
name = name.replace(PERCENT, UNDERSCORE);
targetTypeName = targetTypeName.replace(PERCENT, UNDERSCORE);
alias = alias.replace(PERCENT, UNDERSCORE);
// handle PL/SQL record type
if (dbType.isPLSQLRecordType()) {
addToOXProjectForPLSQLRecordArg(dbType, oxProject, name, alias, targetTypeName, catalogPattern);
addToORProjectForPLSQLRecordArg(dbType, orProject, name, alias, targetTypeName, catalogPattern);
} else // handle PL/SQL collection type
{
addToOXProjectForPLSQLTableArg(dbType, oxProject, name, alias, targetTypeName, catalogPattern);
addToORProjectForPLSQLTableArg(dbType, orProject, name, alias, targetTypeName, catalogPattern);
}
} else {
// Advanced JDBC types need the (Java) package name prepended to the type name
if (Util.isTypeComplex(dbType)) {
name = getGeneratedJavaClassName(dbType.getTypeName(), dbwsBuilder.getProjectName());
} else {
name = dbType.getTypeName();
}
alias = getGeneratedAlias(dbType.getTypeName());
// handle VArray type
if (dbType.isVArrayType()) {
addToOXProjectForVArrayArg(dbType, oxProject, name, alias);
addToORProjectForVArrayArg(dbType, orProject, name, alias);
} else // handle ObjectType type
if (dbType.isObjectType()) {
addToOXProjectForObjectTypeArg(dbType, oxProject, name, alias);
addToORProjectForObjectTypeArg(dbType, orProject, name, alias);
} else // handle ObjectTable type
if (dbType.isObjectTableType()) {
addToOXProjectForObjectTableTypeArg(dbType, oxProject, name, alias);
addToORProjectForObjectTableTypeArg(dbType, orProject, name, alias);
}
}
}
}
use of org.eclipse.persistence.tools.oracleddl.metadata.DatabaseType in project eclipselink by eclipse-ee4j.
the class OracleHelper method addToOXProjectForObjectTableTypeArg.
/**
* Build descriptor and mappings for an OracleTableType argument. The
* newly created descriptor will be added to the given OX project.
*/
protected void addToOXProjectForObjectTableTypeArg(DatabaseType dbType, Project oxProject, String objectTableName, String objectTableAlias) {
XMLDescriptor xdesc = (XMLDescriptor) oxProject.getDescriptorForAlias(objectTableAlias);
if (xdesc == null) {
xdesc = buildAndAddNewXMLDescriptor(oxProject, objectTableAlias, objectTableName + COLLECTION_WRAPPER_SUFFIX, nct.generateSchemaAlias(dbType.getTypeName()), buildCustomQName(objectTableName, dbwsBuilder).getNamespaceURI());
}
boolean itemsMappingFound = xdesc.getMappingForAttributeName(ITEMS_MAPPING_ATTRIBUTE_NAME) == null ? false : true;
if (!itemsMappingFound) {
DatabaseType nType = ((ObjectTableType) dbType).getEnclosedType();
if (nType.isObjectType()) {
ObjectType oType = (ObjectType) nType;
String nestedTypeAlias = getGeneratedAlias(oType.getTypeName());
String nestedTypeName = getGeneratedJavaClassName(nestedTypeAlias, dbwsBuilder.getProjectName());
addToOXProjectForObjectTypeArg(oType, oxProject, nestedTypeName, nestedTypeAlias);
// ObjectType is composite
buildAndAddXMLCompositeCollectionMapping(xdesc, nestedTypeName);
} else {
buildAndAddXMLCompositeDirectCollectionMapping(xdesc, ITEMS_MAPPING_ATTRIBUTE_NAME, ITEM_MAPPING_NAME + SLASH + TEXT, getAttributeClassForDatabaseType(nType));
}
}
}
use of org.eclipse.persistence.tools.oracleddl.metadata.DatabaseType in project eclipselink by eclipse-ee4j.
the class OracleHelper method addToORProjectForPLSQLTableArg.
/**
* Build descriptor and mappings for a PL/SQL collection argument. The newly
* created descriptor will be added to the given OR project.
*/
protected void addToORProjectForPLSQLTableArg(DatabaseType dbType, Project orProject, String tableName, String tableAlias, String targetTypeName, String catalogPattern) {
ObjectRelationalDataTypeDescriptor ordt = (ObjectRelationalDataTypeDescriptor) orProject.getDescriptorForAlias(tableAlias);
if (ordt == null) {
ordt = buildAndAddNewObjectRelationalDataTypeDescriptor(orProject, tableAlias, tableName.toLowerCase() + COLLECTION_WRAPPER_SUFFIX);
}
boolean itemsMappingFound = ordt.getMappingForAttributeName(ITEMS_MAPPING_ATTRIBUTE_NAME) == null ? false : true;
if (!itemsMappingFound) {
DatabaseType nestedType = ((PLSQLCollectionType) dbType).getEnclosedType();
if (nestedType.isPLSQLRecordType()) {
String referenceClassName = (catalogPattern + DOT + ((PLSQLRecordType) nestedType).getTypeName()).toLowerCase();
buildAndAddObjectArrayMapping(ordt, ITEMS_MAPPING_ATTRIBUTE_NAME, ITEMS_MAPPING_FIELD_NAME, referenceClassName, targetTypeName);
if (orProject.getDescriptorForAlias(referenceClassName) == null) {
String refTypeName = catalogPattern + UNDERSCORE + ((PLSQLRecordType) nestedType).getTypeName();
addToORProjectForPLSQLRecordArg(nestedType, orProject, referenceClassName, refTypeName.toLowerCase(), refTypeName, catalogPattern);
}
} else if (nestedType.isObjectType()) {
buildAndAddObjectArrayMapping(ordt, ITEMS_MAPPING_ATTRIBUTE_NAME, ITEMS_MAPPING_FIELD_NAME, getGeneratedJavaClassName(nestedType.getTypeName(), dbwsBuilder.getProjectName()), targetTypeName);
} else {
buildAndAddArrayMapping(ordt, ITEMS_MAPPING_ATTRIBUTE_NAME, ITEMS_MAPPING_FIELD_NAME, targetTypeName);
}
}
}
Aggregations