if (ctx == null)
isVerifyFlag = true;
File cmpMappingFile = getSunCmpMappingFile(inputFilesPath);
boolean mappedBeans = !ignoreSunDeploymentDescriptors
&& cmpMappingFile.exists();
ResourceReferenceDescriptor cmpResource = checkOrCreateCMPResource(
mappedBeans);
// Remember whether or not this mapping was created by Java2DB.
isJavaToDatabaseFlag = DeploymentHelper.isJavaToDatabase(
cmpResource.getSchemaGeneratorProperties());
// We *must* get a vendor name if either the beans are not mapped, or
// they are mapped and the javaToDatabase flag is set.
boolean mustHaveDBVendorName =
!mappedBeans || (mappedBeans && isJavaToDatabaseFlag);
// Read deployment settings from the deployment descriptor
// and CLI options.
Results deploymentArguments = getDeploymentArguments(
ctx, cmpResource, mustHaveDBVendorName);
dbVendorName = deploymentArguments.getDatabaseVendorName();
if (mappedBeans) {
// If sun-cmp-mappings.xml exists and we are doing a deployment,
// validate some arguments and make sure we have dbschema.
// If it is from verify, skip deployment arguments check.
if (!isVerifyFlag) {
String warning = null; // Warning for user, if required.
if (isJavaToDatabaseFlag) {
// If beans were already mapped, we will generate tables, but
// they will be as per the existing mapping. So if the user
// gave --uniquetablenames, warn them that we will not take
// that flag into account. I.e., the tables will be generated
// as per the mapping.
if (deploymentArguments.hasUniqueTableNames()) {
warning =
I18NHelper.getMessage(
messages,
"EXC_DisallowJava2DBUniqueTableNames", //NOI18N
bundle.getApplication().getRegistrationName(),
JDOCodeGeneratorHelper.getModuleName(bundle));
logger.warning(warning);
}
} else if (deploymentArguments.hasJavaToDatabaseArgs()) {
// If beans are already mapped but the user gave any Java2DB
// command line arguments, warn the user that these args
// should not be used when module is already mapped.
warning =
I18NHelper.getMessage(
messages,
"EXC_DisallowJava2DBCLIOverrides", //NOI18N
bundle.getApplication().getRegistrationName(),
JDOCodeGeneratorHelper.getModuleName(bundle));
logger.warning(warning);
}
if (warning != null) {
ActionReport subActionReport = ctx.getActionReport().addSubActionsReport();
// Propagte warning to client side so that the deployer can see the warning.
Java2DBProcessorHelper.warnUser(subActionReport, warning);
}
}
// Sun-cmp-mapping.xml exists, use normal MappingClass loading
SunCmpMappings sunCmpMappings = getSunCmpMappings(cmpMappingFile);
// Ensure that there is a dbschema for each element of
// sunCmpMappings.
ensureDBSchemaExistence(cmpResource, sunCmpMappings, inputFilesPath,
classout);
// load real mapping model and jdo model in memory
Map mappingClasses = loadMappingClasses(sunCmpMappings, getClassLoader());
// Get schema from one of the mapping classes.
// The mapping class element may be null if there is inconsistency
// in sun-cmp-mappings.xml and ejb-jar.xml. For example,
// the bean has mapping information in sun-cmp-mappings.xml but
// no definition in the ejb-jar.xml.
// So iterate over the mappings until the 1st non-null is found.
MappingClassElement mc = null;
Iterator iter = mappingClasses.values().iterator();
while (iter.hasNext()) {
mc = (MappingClassElement)iter.next();
if (mc != null) {
schema = SchemaElement.forName(mc.getDatabaseRoot());
break;
}
}
if (logger.isLoggable(Logger.FINE)){
logger.fine("Loaded mapped beans for " // NOI18N
+ cmpResource.getJndiName()
+ ", isJavaToDatabase=" + isJavaToDatabaseFlag); // NOI18N
}
}
else {
// Generate mapping file and dbschema, since either