Skip to content

Commit dc29b15

Browse files
committed
Corrected coderabit suggestion
1 parent 3747e91 commit dc29b15

1 file changed

Lines changed: 27 additions & 25 deletions

File tree

sormas-app/app/src/main/java/de/symeda/sormas/app/backend/common/AbstractAdoDao.java

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ public Date getLatestChangeDate() {
332332
String query = "SELECT MAX(" + AbstractDomainObject.CHANGE_DATE + ") FROM " + getTableName();
333333
GenericRawResults<Object[]> maxChangeDateResult = queryRaw(
334334
query,
335-
new DataType[] {
336-
DataType.DATE_LONG });
335+
new DataType[]{
336+
DataType.DATE_LONG});
337337
try {
338338
List<Object[]> dateResults = maxChangeDateResult.getResults();
339339
if (!dateResults.isEmpty()) {
@@ -378,8 +378,8 @@ protected Date getLatestChangeDateSubJoinReverse(String joinTableName, String jo
378378
protected Date getLatestChangeDateJoinFromQuery(String query) {
379379
GenericRawResults<Object[]> maxChangeDateResult = queryRaw(
380380
query,
381-
new DataType[] {
382-
DataType.DATE_LONG });
381+
new DataType[]{
382+
DataType.DATE_LONG});
383383
try {
384384
List<Object[]> dateResults = maxChangeDateResult.getResults();
385385
if (!dateResults.isEmpty()) {
@@ -943,35 +943,37 @@ public void accept(ADO ado) throws DaoException {
943943

944944
try {
945945
// accept all collection elements
946-
Collection<?> sourceCollection = (Collection<?>) property.getReadMethod().invoke(ado);
947-
if(sourceCollection != null && !sourceCollection.isEmpty()) {
946+
final Collection<?> sourceCollection = (Collection<?>) property.getReadMethod().invoke(ado);
947+
if (sourceCollection != null && !sourceCollection.isEmpty()) {
948948
for (Object sourceElement : sourceCollection) {
949-
if(!(sourceElement instanceof AbstractDomainObject)) {
949+
if (!(sourceElement instanceof AbstractDomainObject)) {
950950
continue;
951951
}
952-
AbstractDomainObject e = (AbstractDomainObject) sourceElement;
952+
final AbstractDomainObject e = (AbstractDomainObject) sourceElement;
953953
DatabaseHelper.getAdoDao(e.getClass()).acceptWithCast(e);
954954
}
955+
}
955956

956-
if (snapshot != null) {
957-
// delete remaining snapshots
958-
Collection<?> snapshotCollection =
959-
(Collection<?>) property.getReadMethod().invoke(snapshot);
960-
if (snapshotCollection != null && !snapshotCollection.isEmpty()) {
961-
for (Object snapshotElement : snapshotCollection) {
962-
if (!(snapshotElement instanceof AbstractDomainObject)) {
963-
continue;
964-
}
965-
if(sourceCollection.contains(snapshotElement)) {
966-
continue;
967-
}
968-
final AbstractDomainObject e = (AbstractDomainObject) snapshotElement;
969-
970-
DatabaseHelper.getAdoDao(e.getClass()).deleteCascadeWithCast(e);
957+
if (snapshot != null) {
958+
// delete remaining snapshots
959+
final Collection<?> snapshotCollection =
960+
(Collection<?>) property.getReadMethod().invoke(snapshot);
961+
if (snapshotCollection != null && !snapshotCollection.isEmpty()) {
962+
for (Object snapshotElement : snapshotCollection) {
963+
if (!(snapshotElement instanceof AbstractDomainObject)) {
964+
continue;
965+
}
966+
if (sourceCollection != null && sourceCollection.contains(snapshotElement)) {
967+
continue;
971968
}
969+
final AbstractDomainObject e = (AbstractDomainObject) snapshotElement;
970+
971+
DatabaseHelper.getAdoDao(e.getClass()).deleteCascadeWithCast(e);
972972
}
973973
}
974+
974975
}
976+
975977
} catch (ClassCastException e) {
976978
// Collection does not contain ADOs and doesn't have to be handled
977979
}
@@ -1124,8 +1126,8 @@ public List<String> filterMissing(List<String> uuids) {
11241126
try {
11251127
GenericRawResults<Object[]> existingUuids = dao.queryRaw(
11261128
"SELECT uuid FROM " + getTableName(),
1127-
new DataType[] {
1128-
DataType.STRING });
1129+
new DataType[]{
1130+
DataType.STRING});
11291131
List<String> results = new ArrayList<>(uuids);
11301132
for (Object[] existingUuid : existingUuids) {
11311133
results.remove(existingUuid[0]);

0 commit comments

Comments
 (0)