private JavaAnnotationTypeReferenceModel findTableAnnotation(GraphRewrite event, List<AbstractJavaSourceModel> sourceModels) { for (AbstractJavaSourceModel sourceModel : sourceModels) { Optional<JavaAnnotationTypeReferenceModel> tableAnnotation = sourceModel.getAllTypeReferences().stream() .filter(reference -> reference instanceof JavaAnnotationTypeReferenceModel) .map(reference -> (JavaAnnotationTypeReferenceModel)reference) .filter(annotationReference -> annotationReference.getResolvedSourceSnippit() != null && annotationReference.getResolvedSourceSnippit().contains("javax.persistence.Table")) .findFirst(); if (tableAnnotation.isPresent()) return tableAnnotation.get(); else return findTableAnnotation(event, getParentSourceFiles(event, sourceModel)); } return null; }
private void addNamedQuery(GraphService<JPANamedQueryModel> namedQueryService, JPAEntityModel jpaEntity, JavaAnnotationTypeReferenceModel reference) { String name = getAnnotationLiteralValue(reference, "name"); String query = getAnnotationLiteralValue(reference, "query"); LOG.info("Found query: " + name + " -> " + query); JPANamedQueryModel namedQuery = namedQueryService.create(); namedQuery.setQueryName(name); namedQuery.setQuery(query); namedQuery.setJpaEntity(jpaEntity); }
entityTypeReference.getFile().setGenerateSourceReport(true); JavaAnnotationTypeReferenceModel entityAnnotationTypeReference = (JavaAnnotationTypeReferenceModel) entityTypeReference; JavaAnnotationTypeReferenceModel tableAnnotationTypeReference = findTableAnnotation(event, entityTypeReference); JavaClassModel ejbClass = getJavaClass(entityTypeReference); String ejbName = getAnnotationLiteralValue(entityAnnotationTypeReference, "name"); if (ejbName == null) String tableName = tableAnnotationTypeReference == null ? ejbName : getAnnotationLiteralValue(tableAnnotationTypeReference, "name"); if (tableName == null) String catalogName = tableAnnotationTypeReference == null ? null : getAnnotationLiteralValue(tableAnnotationTypeReference, "catalog"); String schemaName = tableAnnotationTypeReference == null ? null : getAnnotationLiteralValue(tableAnnotationTypeReference, "schema"); addNamedQuery(namedQueryService, jpaEntity, reference); addNamedQuery(namedQueryService, jpaEntity, reference);
entityTypeReference.getFile().setGenerateSourceReport(true); JavaAnnotationTypeReferenceModel entityAnnotationTypeReference = (JavaAnnotationTypeReferenceModel) entityTypeReference; JavaAnnotationTypeReferenceModel tableAnnotationTypeReference = findTableAnnotation(event, entityTypeReference); JavaClassModel ejbClass = getJavaClass(entityTypeReference); String ejbName = getAnnotationLiteralValue(entityAnnotationTypeReference, "name"); if (ejbName == null) String tableName = tableAnnotationTypeReference == null ? ejbName : getAnnotationLiteralValue(tableAnnotationTypeReference, "name"); if (tableName == null) String catalogName = tableAnnotationTypeReference == null ? null : getAnnotationLiteralValue(tableAnnotationTypeReference, "catalog"); String schemaName = tableAnnotationTypeReference == null ? null : getAnnotationLiteralValue(tableAnnotationTypeReference, "schema"); addNamedQuery(namedQueryService, jpaEntity, reference); addNamedQuery(namedQueryService, jpaEntity, reference);
private JavaAnnotationTypeReferenceModel findTableAnnotation(GraphRewrite event, List<AbstractJavaSourceModel> sourceModels) { for (AbstractJavaSourceModel sourceModel : sourceModels) { Optional<JavaAnnotationTypeReferenceModel> tableAnnotation = sourceModel.getAllTypeReferences().stream() .filter(reference -> reference instanceof JavaAnnotationTypeReferenceModel) .map(reference -> (JavaAnnotationTypeReferenceModel)reference) .filter(annotationReference -> annotationReference.getResolvedSourceSnippit() != null && annotationReference.getResolvedSourceSnippit().contains("javax.persistence.Table")) .findFirst(); if (tableAnnotation.isPresent()) return tableAnnotation.get(); else return findTableAnnotation(event, getParentSourceFiles(event, sourceModel)); } return null; }
private void addNamedQuery(GraphService<JPANamedQueryModel> namedQueryService, JPAEntityModel jpaEntity, JavaAnnotationTypeReferenceModel reference) { String name = getAnnotationLiteralValue(reference, "name"); String query = getAnnotationLiteralValue(reference, "query"); LOG.info("Found query: " + name + " -> " + query); JPANamedQueryModel namedQuery = namedQueryService.create(); namedQuery.setQueryName(name); namedQuery.setQuery(query); namedQuery.setJpaEntity(jpaEntity); }
private JavaAnnotationTypeReferenceModel findTableAnnotation(GraphRewrite event, JavaTypeReferenceModel entityTypeReference) { JavaAnnotationTypeReferenceModel tableAnnotationTypeReference = null; final Iterable<? extends WindupVertexFrame> tableAnnotationList = Variables.instance(event).findVariable(TABLE_ANNOTATIONS_LIST); if (tableAnnotationList != null) { for (WindupVertexFrame annotationTypeReferenceBase : tableAnnotationList) { JavaAnnotationTypeReferenceModel annotationTypeReference = (JavaAnnotationTypeReferenceModel) annotationTypeReferenceBase; if (annotationTypeReference.getFile().equals(entityTypeReference.getFile())) { tableAnnotationTypeReference = annotationTypeReference; break; } } } if (tableAnnotationTypeReference == null) { AbstractJavaSourceModel sourceModel = entityTypeReference.getFile(); tableAnnotationTypeReference = findTableAnnotation(event, getParentSourceFiles(event, sourceModel)); } return tableAnnotationTypeReference; }
private JavaAnnotationTypeReferenceModel findTableAnnotation(GraphRewrite event, JavaTypeReferenceModel entityTypeReference) { JavaAnnotationTypeReferenceModel tableAnnotationTypeReference = null; final Iterable<? extends WindupVertexFrame> tableAnnotationList = Variables.instance(event).findVariable(TABLE_ANNOTATIONS_LIST); if (tableAnnotationList != null) { for (WindupVertexFrame annotationTypeReferenceBase : tableAnnotationList) { JavaAnnotationTypeReferenceModel annotationTypeReference = (JavaAnnotationTypeReferenceModel) annotationTypeReferenceBase; if (annotationTypeReference.getFile().equals(entityTypeReference.getFile())) { tableAnnotationTypeReference = annotationTypeReference; break; } } } if (tableAnnotationTypeReference == null) { AbstractJavaSourceModel sourceModel = entityTypeReference.getFile(); tableAnnotationTypeReference = findTableAnnotation(event, getParentSourceFiles(event, sourceModel)); } return tableAnnotationTypeReference; }