Skip to content

Commit 00d448e

Browse files
author
Bob Garner
committed
Added count by relationship service/repository methods. Improved enums used for headline and breadcrumb to show their title instead of name.
1 parent 78ecdf0 commit 00d448e

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

repository/authors/RepositoryGetAuthor.eml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ $[/send]
124124
"LIMIT ?3 OFFSET ?2", nativeQuery = true)
125125
List<${responseModelName}> get${responseModelName}ListBy${relationship.name|capitalize}(${relationship.to.entity.primaryKey.type|language} ${relationship|domain|name}Id, long start, int limit);
126126

127+
/**
128+
* Gets the count of ${responseModelName} objects that all share the same reference to an object of ${relationship.to.entity.name}.
129+
* @param ${relationship|domain|name}Id The ID of the ${relationship.to.entity.name} object to which all results will share.
130+
* @return Count of ${responseModelName} objects that exist.
131+
*/
132+
Long count${responseModelName}By${relationship.name|capitalize}Id(${relationship.to.entity.primaryKey.type|language} ${relationship|domain|name}Id);
133+
127134
$[/if]
128135
$[/foreach]
129136
$[/author]

service/authors/ServiceGetAuthor.eml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,16 @@ $[*******************************]
197197
}
198198
}
199199

200+
public Long get${responseInMethodName}CountBy${relationship.name|capitalize}(
201+
${relationship.to.entity.pkType|language} ${toPrimaryKeyName}) throws ServiceException {
202+
203+
try {
204+
return ${repositoryVariableName}.count${responseModelName}By${relationship.name|capitalize}Id(${toPrimaryKeyName});
205+
} catch (DataAccessException ex) {
206+
throw new DaoException(ex.getMessage(), ex);
207+
}
208+
}
209+
200210
$[/function]
201211
$[foreach entity.relationships]
202212
$[if !relationship.isParent]$[continue]$[/if]

web/thymeleaf-bootstrap/WebPageFunctions.eml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,11 @@ $[function headlineExpression
181181
$[let titleAttribute = attribute]
182182
$[/if]
183183
$[/foreach]
184+
$[let titleAttributeField = ""]
185+
$[if titleAttribute.type.isEnumType]$[let titleAttributeField = ".title"]$[/if]
184186
$[let includeColon = entityAsHeader || numberAttribute != null]
185187
$[if entityAsHeader || numberAttribute != null || titleAttribute != null]
186-
$[capture thExpression]|$[if entityAsHeader]${entity|domain:AdminUI|title}$[/if]$[if numberAttribute != null] ${$}{${dtoEntity|name|uncapitalize}.${numberAttribute|name}}$[/if]$[if titleAttribute != null]${includeColon ? ": ":""}${$}{${dtoEntity|name|uncapitalize}.${titleAttribute|name}}$[/if]|$[/capture]
188+
$[capture thExpression]|$[if entityAsHeader]${entity|domain:AdminUI|title}$[/if]$[if numberAttribute != null] ${$}{${dtoEntity|name|uncapitalize}.${numberAttribute|name}}$[/if]$[if titleAttribute != null]${includeColon ? ": ":""}${$}{${dtoEntity|name|uncapitalize}.${titleAttribute|name}${titleAttributeField}}$[/if]|$[/capture]
187189
$[else]
188190
$[let thExpression = null]
189191
$[/if]
@@ -214,8 +216,10 @@ $[function breadcrumbExpression
214216
$[let titleAttribute = attribute]
215217
$[/if]
216218
$[/foreach]
219+
$[let titleAttributeField = ""]
220+
$[if titleAttribute.type.isEnumType]$[let titleAttributeField = ".title"]$[/if]
217221
$[let includeColon = entityAsHeader || numberAttribute != null]
218-
$[capture thExpression]|$[if entityAsHeader]${entity|domain:AdminUI|title}$[/if]$[if numberAttribute != null] ${$}{${dtoEntity|name|uncapitalize}.${numberAttribute|name}}$[/if]$[if titleAttribute != null]${includeColon ? ": ":""}${$}{${dtoEntity|name|uncapitalize}.${titleAttribute|name}}$[/if]|$[/capture]
222+
$[capture thExpression]|$[if entityAsHeader]${entity|domain:AdminUI|title}$[/if]$[if numberAttribute != null] ${$}{${dtoEntity|name|uncapitalize}.${numberAttribute|name}}$[/if]$[if titleAttribute != null]${includeColon ? ": ":""}${$}{${dtoEntity|name|uncapitalize}.${titleAttribute|name}${titleAttributeField}}$[/if]|$[/capture]
219223
$[/function]
220224
$[function canAccessAdminExpr
221225
(rolesArrayName,

0 commit comments

Comments
 (0)