use of org.eclipse.persistence.tools.oracleddl.metadata.ROWTYPEType in project eclipselink by eclipse-ee4j.
the class BaseDBWSBuilderHelper method buildTypesList.
/**
* Uses a custom visitor to traverse each procedure/function argument and build
* a list of required Types. Only on instance of a given type will exist in
* the list.
*/
public List<CompositeDatabaseType> buildTypesList(List<OperationModel> operations) {
EnclosedTypeVisitor etVisitor = new EnclosedTypeVisitor();
for (OperationModel opModel : operations) {
if (opModel.isProcedureOperation()) {
ProcedureOperationModel procedureOperation = (ProcedureOperationModel) opModel;
if (procedureOperation.isPLSQLProcedureOperation() || procedureOperation.isAdvancedJDBCProcedureOperation()) {
for (ProcedureType procType : procedureOperation.getDbStoredProcedures()) {
// build list of arguments to process (i.e. build descriptors for)
List<ArgumentType> args = new ArrayList<ArgumentType>();
// return argument
if (procType.isFunctionType()) {
// assumes that a function MUST have a return type
args.add(((FunctionType) procType).getReturnArgument());
}
args.addAll(procType.getArguments());
// now visit each argument
for (ArgumentType arg : args) {
// handle ROWTYPETypes
if (arg.getEnclosedType().isROWTYPEType()) {
ROWTYPEType rType = (ROWTYPEType) arg.getEnclosedType();
TableType tableType = (TableType) rType.getEnclosedType();
PLSQLRecordType plsqlRec = new PLSQLRecordType(rType.getTypeName());
plsqlRec.setParentType(new PLSQLPackageType());
for (FieldType col : tableType.getColumns()) {
FieldType ft = new FieldType(col.getFieldName());
ft.setEnclosedType(col.getEnclosedType());
plsqlRec.addField(ft);
}
arg.setEnclosedType(plsqlRec);
}
// now visit each, adding types (only one instance of each) to the list
if (arg.isComposite()) {
etVisitor.visit((CompositeDatabaseType) arg);
}
}
}
}
}
}
// gather Complex types to hand into XMLEntityMappingsGenerator
List<CompositeDatabaseType> types = etVisitor.getCompositeDatabaseTypes();
for (CompositeDatabaseType type : types) {
complextypes.add(type);
}
return etVisitor.getCompositeDatabaseTypes();
}
use of org.eclipse.persistence.tools.oracleddl.metadata.ROWTYPEType in project eclipselink by eclipse-ee4j.
the class JPAMetadataGenerator method processPLSQLArgument.
/**
* Generate a PL/SQL parameter based on the given ArgumentType. For
* non-PL/SQL arguments the processArgument method should be used.
*/
protected PLSQLParameterMetadata processPLSQLArgument(ArgumentType arg) {
// for %ROWTYPE, we need to create a PL/SQL record that mirrors the Table
if (arg.getEnclosedType().isROWTYPEType()) {
ROWTYPEType rType = (ROWTYPEType) arg.getEnclosedType();
TableType tableType = (TableType) rType.getEnclosedType();
PLSQLRecordType plsqlRec = new PLSQLRecordType(rType.getTypeName());
plsqlRec.setParentType(new PLSQLPackageType());
for (FieldType col : tableType.getColumns()) {
FieldType ft = new FieldType(col.getFieldName());
ft.setEnclosedType(col.getEnclosedType());
plsqlRec.addField(ft);
}
arg.setEnclosedType(plsqlRec);
}
PLSQLParameterMetadata param = new PLSQLParameterMetadata();
// handle cursor
if (arg.isPLSQLCursorType()) {
param.setDirection(OUT_CURSOR_STR);
}
// handle stored function return type
if (arg.getDirection() == ArgumentTypeDirection.RETURN) {
param.setName(arg.isPLSQLCursorType() ? CURSOR_STR : RESULT_STR);
} else {
// direction is already set for cursor type
if (!arg.isPLSQLCursorType()) {
param.setDirection(arg.getDirection().name());
}
param.setName(arg.getArgumentName());
}
String dbType = arg.getTypeName();
// handle composites
if (arg.isComposite()) {
DatabaseType enclosedType = arg.getEnclosedType();
// need to prepend the package name for most PL/SQL and Cursor types
if (enclosedType.isPLSQLType() || enclosedType.isPLSQLCursorType()) {
dbType = getQualifiedTypeName(enclosedType);
}
// process the composite enclosed type
processCompositeType(enclosedType, dbType);
}
param.setDatabaseType(processTypeName(dbType));
return param;
}
use of org.eclipse.persistence.tools.oracleddl.metadata.ROWTYPEType in project eclipselink by eclipse-ee4j.
the class OracleHelper method customizeSimpleXMLTagNames.
/**
* Customizes the simple-xml-format tags names to better represent the
* PL/SQL record/table/column type. This is possible only with
* strongly-typed ref cursors, since for weakly-typed ones we
* don't know anything about the cursor's output type.
*/
protected void customizeSimpleXMLTagNames(PLSQLCursorType plsqlCursor, ProcedureOperationModel procedureOperationModel) {
if (!plsqlCursor.isWeaklyTyped()) {
// do not override user tag customization
if (procedureOperationModel.getSimpleXMLFormatTag() == null) {
procedureOperationModel.setSimpleXMLFormatTag(plsqlCursor.getCursorName());
}
// - TYPEType
if (procedureOperationModel.getXmlTag() == null) {
if (plsqlCursor.getEnclosedType().isPLSQLRecordType()) {
PLSQLRecordType recType = (PLSQLRecordType) plsqlCursor.getEnclosedType();
procedureOperationModel.setXmlTag(recType.getTypeName());
} else if (plsqlCursor.getEnclosedType().isROWTYPEType()) {
// assumes ROWTYPEType has an enclosed TableType
ROWTYPEType rowType = (ROWTYPEType) plsqlCursor.getEnclosedType();
TableType tableType = (TableType) rowType.getEnclosedType();
procedureOperationModel.setXmlTag(tableType.getTableName());
}
}
}
}
Aggregations