for (JsonElement componentAsJsonElement : components) {
JsonObject componentAsJsonObject = componentAsJsonElement.getAsJsonObject();
componentDb.insertComponentAndSnapshot(new ComponentDto()
- .setUuid(getJsonField(componentAsJsonObject, "id"))
- .setKey(getJsonField(componentAsJsonObject, "key"))
- .setName(getJsonField(componentAsJsonObject, "name"))
- .setPath(getJsonField(componentAsJsonObject, "path"))
- .setProjectUuid(project.projectUuid())
- .setQualifier(getJsonField(componentAsJsonObject, "qualifier"))
- .setDescription(getJsonField(componentAsJsonObject, "description"))
- .setEnabled(true)
- .setCreatedAt(now),
+ .setUuid(getJsonField(componentAsJsonObject, "id"))
+ .setKey(getJsonField(componentAsJsonObject, "key"))
+ .setName(getJsonField(componentAsJsonObject, "name"))
+ .setPath(getJsonField(componentAsJsonObject, "path"))
+ .setProjectUuid(project.projectUuid())
+ .setQualifier(getJsonField(componentAsJsonObject, "qualifier"))
+ .setDescription(getJsonField(componentAsJsonObject, "description"))
+ .setEnabled(true)
+ .setCreatedAt(now),
projectSnapshot);
}
db.commit();
this.page = builder.page;
this.pageSize = builder.pageSize;
this.baseSnapshot = builder.baseSnapshot;
- this.baseSnapshotPath = buildLikeValue(baseSnapshot.getPath() + baseSnapshot.getId() + ".", WildcardPosition.AFTER);
+ this.baseSnapshotPath = buildBaseSnapshotPath(baseSnapshot);
this.direction = builder.asc ? "ASC" : "DESC";
this.sqlSort = sortFieldsToSqlSort(builder.sortFields, direction);
}
return Joiner.on(", ").join(sqlSortFields);
}
+ private String buildBaseSnapshotPath(SnapshotDto baseSnapshot) {
+ String existingSnapshotPath = baseSnapshot.getPath() == null ? "" : baseSnapshot.getPath();
+ return buildLikeValue(existingSnapshotPath + baseSnapshot.getId() + ".", WildcardPosition.AFTER);
+ }
+
public static class Builder {
@CheckForNull
private String nameOrKeyQuery;