// initialize the result object
Result result = getInitializedResult();
addErrorDetails(result,
getVerifierContext().getComponentNameConstructor());
result.setStatus(Result.PASSED); //default status is PASSED
BundleDescriptor bundleDescriptor = getBundleDescriptor(descriptor);
for (EntityManagerReferenceDescriptor emRefDesc : getEntityManagerReferenceDescriptors(descriptor)) {
String referringUnitName = emRefDesc.getUnitName();
PersistenceUnitDescriptor pu = bundleDescriptor.findReferencedPU(referringUnitName);
if (pu == null) {
result.failed(smh.getLocalString(
className + "failed",
"There is no unique persistence unit found by name " +
"[ {0} ] in the scope of this component.",
new Object[]{referringUnitName}));
} else {
result.passed(smh.getLocalString(
className + "passed",
"Found a persistence unit by name [ {0} ] in the scope of this component",
new Object[]{referringUnitName}));
}
}
for (EntityManagerFactoryReferenceDescriptor emfRefDesc : getEntityManagerFactoryReferenceDescriptors(descriptor)) {
String referringUnitName = emfRefDesc.getUnitName();
PersistenceUnitDescriptor pu = bundleDescriptor.findReferencedPU(referringUnitName);
if (pu == null) {
result.failed(smh.getLocalString(
className + "failed",
"There is no unique persistence unit found by name " +
"[ {0} ] in the scope of this component.",
new Object[]{referringUnitName}));
} else {
result.passed(smh.getLocalString(
className + "passed",
"Found a persistence unit by name [ {0} ] in the scope of this component",
new Object[]{referringUnitName}));
}
}
StringBuilder visiblePUNames = new StringBuilder();
final Map<String, PersistenceUnitDescriptor> visiblePUs =
bundleDescriptor.getVisiblePUs();
int count = 0;
for(String puName : visiblePUs.keySet()) {
visiblePUNames.append(puName);
if(visiblePUs.size() != ++count) { // end not yet reached
visiblePUNames.append(", ");
}
}
String message = smh.getLocalString(className + ".puList",
"PUs that are visible to this component are: [ {0} ]",
new Object[]{visiblePUNames});
result.addErrorDetails(message);
result.addGoodDetails(message);
return result;