Skip to content

Commit

Permalink
ROO-2745: Post 1.2.0.M1 code refactor and clean up - docs and use exi…
Browse files Browse the repository at this point in the history
…sting method
  • Loading branch information
Alan Stewart committed Oct 18, 2011
1 parent 43eb782 commit 15deebc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
public class DbreDatabaseListenerImpl extends AbstractHashCodeTrackingMetadataNotifier implements IdentifierService, FileEventListener {

// Constants
private static final JavaSymbolName DB_MANAGED = new JavaSymbolName("dbManaged");
private static final String IDENTIFIER_TYPE = "identifierType";
private static final String VERSION_FIELD = "versionField";
private static final String VERSION = "version";
Expand Down Expand Up @@ -227,7 +228,7 @@ private Set<ClassOrInterfaceTypeDetails> getManagedIdentifiers() {
final Set<ClassOrInterfaceTypeDetails> identifierTypes = typeLocationService.findClassesOrInterfaceDetailsWithAnnotation(ROO_IDENTIFIER);
for (final ClassOrInterfaceTypeDetails managedIdentifierType : identifierTypes) {
final AnnotationMetadata identifierAnnotation = managedIdentifierType.getTypeAnnotation(ROO_IDENTIFIER);
final AnnotationAttributeValue<?> attrValue = identifierAnnotation.getAttribute(new JavaSymbolName("dbManaged"));
final AnnotationAttributeValue<?> attrValue = identifierAnnotation.getAttribute(DB_MANAGED);
if (attrValue != null && (Boolean) attrValue.getValue()) {
managedIdentifierTypes.add(managedIdentifierType);
}
Expand All @@ -238,7 +239,7 @@ private Set<ClassOrInterfaceTypeDetails> getManagedIdentifiers() {
private Table updateOrDeleteManagedEntity(final ClassOrInterfaceTypeDetails managedEntity, final Database database) {
// Update the attributes of the existing JPA-related annotation
final AnnotationMetadata jpaAnnotation = getJpaAnnotation(managedEntity);
Assert.state(jpaAnnotation != null, "Neither " + ROO_JPA_ACTIVE_RECORD.getSimpleTypeName() + " nor " + ROO_JPA_ENTITY.getSimpleTypeName() + " found on existing DBRE-managed entity " + managedEntity.getName().getFullyQualifiedTypeName());
Assert.state(jpaAnnotation != null, "Neither @" + ROO_JPA_ACTIVE_RECORD.getSimpleTypeName() + " nor @" + ROO_JPA_ENTITY.getSimpleTypeName() + " found on existing DBRE-managed entity " + managedEntity.getName().getFullyQualifiedTypeName());

// Find table in database using 'table' and 'schema' attributes from the JPA annotation
final AnnotationAttributeValue<?> tableAttribute = jpaAnnotation.getAttribute(new JavaSymbolName("table"));
Expand Down Expand Up @@ -407,7 +408,7 @@ private void createIdentifierClass(final JavaType identifierType) {
final List<AnnotationMetadataBuilder> identifierAnnotations = new ArrayList<AnnotationMetadataBuilder>();

final AnnotationMetadataBuilder identifierBuilder = new AnnotationMetadataBuilder(ROO_IDENTIFIER);
identifierBuilder.addBooleanAttribute("dbManaged", true);
identifierBuilder.addBooleanAttribute(DB_MANAGED.getSymbolName(), true);
identifierAnnotations.add(identifierBuilder);

// Produce identifier itself
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static Document readXml(InputStream inputStream) {
if (!(inputStream instanceof BufferedInputStream)) {
inputStream = new BufferedInputStream(inputStream);
}
return factory.newDocumentBuilder().parse(inputStream);
return getDocumentBuilder().parse(inputStream);
} catch (final Exception e) {
throw new IllegalStateException("Could not open input stream", e);
} finally {
Expand Down

0 comments on commit 15deebc

Please sign in to comment.