Skip to content

Commit

Permalink
removing new ArrayList<>(this)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhavya031 committed Aug 7, 2023
1 parent fb57207 commit 0664b5b
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void elaborate() {
* To avoid this, turn off automatic elaboration.
*/
autoElab = false;
mode.elaborate(new ArrayList(), elaboratorParams);
mode.elaborate(this, elaboratorParams);
//we are done, turn automatic elaboration back to what it was.
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public DataResult<T> slice(int fromIndex, int toIndex) {
public void elaborate(Map<String, Object> values) {
elabParams = values;
if (mode != null) {
mode.elaborate(new ArrayList<>(this), values);
mode.elaborate(this, values);
}
}
/**
Expand All @@ -155,10 +155,10 @@ public void elaborate(Map<String, Object> values) {
public void elaborate() {
if (mode != null) {
if (getElaborationParams() == null) {
mode.elaborate(new ArrayList<>(this), Collections.emptyMap());
mode.elaborate(this, Collections.emptyMap());
}
else {
mode.elaborate(new ArrayList<>(this), getElaborationParams());
mode.elaborate(this, getElaborationParams());
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.io.StringWriter;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -113,7 +114,7 @@ protected String getExportColumns(HttpServletRequest request, HttpSession sessio
* @param session HTTP session
* @return page data
*/
protected List<Object> getPageData(HttpServletRequest request, HttpSession session) {
protected List<BaseDto> getPageData(HttpServletRequest request, HttpSession session) {
String paramQuery = request.getParameter(QUERY_DATA);
if (paramQuery != null) {
CachedStatement query = (CachedStatement) session.getAttribute(paramQuery);
Expand Down Expand Up @@ -179,7 +180,7 @@ protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form,
}

String exportColumns = getExportColumns(request, session);
List<Object> pageData = getPageData(request, session);
List<BaseDto> pageData = getPageData(request, session);

// Read the CSV separator from user preferences
User user = new RequestContext(request).getCurrentUser();
Expand All @@ -194,7 +195,7 @@ protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form,

Elaborator elaborator = TagHelper.lookupElaboratorFor(getUniqueName(request), request);
if (elaborator != null) {
elaborator.elaborate(pageData, HibernateFactory.getSession());
elaborator.elaborate(pageData.stream().collect(Collectors.toList()), HibernateFactory.getSession());
}

String contentType = csvWriter.getMimeType() + ";charset=" + response.getCharacterEncoding();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@ public static List<PackageOverview> performSearch(Long sessionId, String searchS

List<Long> pids = new ArrayList<>();
Set<String> names = new HashSet<>();
for (Object itemObject : results) {
Map<String, Object> item = (Map<String, Object>) itemObject;
for (Map<String, Object> item : results) {
names.add((String) item.get("name"));
Long pid = Long.valueOf((String)item.get("id"));
Long pid = Long.valueOf((String) item.get("id"));
pids.add(pid);
}

Expand Down Expand Up @@ -146,9 +145,8 @@ public static List<PackageOverview> performSearch(Long sessionId, String searchS

// Iterate through in the order that the search server returned, add packages
// to the return list in the order they appear in the search results.
for (Object resultObject : results) {
Map<String, Object> result = (Map<String, Object>) resultObject;
Long pid = Long.valueOf((String)result.get("id"));
for (Map<String, Object> result : results) {
Long pid = Long.valueOf((String) result.get("id"));
if (pidToPackageMap.get(pid) != null) {
ordered.add(pidToPackageMap.get(pid));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ private ActionForward handleUserDownload(HttpServletRequest request, String url,
protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {

String path = "";
String path;
Map<String, Object> params = (Map<String, Object>) request.getAttribute(PARAMS);
String type = (String) params.get(TYPE);
User currentUser = new RequestContext(request).getCurrentUser();
Expand Down Expand Up @@ -641,9 +641,6 @@ else if (actualFile.exists()) {
}
}
log.debug("Final path before returning getStreamForPath(): {}", diskPath);
if (log.isDebugEnabled()) {
log.debug("Final path before returning getStreamForPath(): {}", diskPath);
}
if (log.isDebugEnabled()) {
Enumeration<String> e = request.getHeaderNames();
while (e.hasMoreElements()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,18 @@

/**
* PackageDependenciesAction
*
* @param <T> is used in DataResult
*/
public class PackageDependenciesAction extends RhnAction {

private List<String> createDependenciesStrings(DataResult dr) {
public class PackageDependenciesAction<T> extends RhnAction {
/**
* Creates dependency strings for the given data result.
*
* @param <T> the type of data in the result
* @param dr the data result to process
* @return a list of dependency strings
*/
private <T> List<String> createDependenciesStrings(DataResult<T> dr) {

if (dr == null || dr.isEmpty()) {
return null;
Expand All @@ -50,8 +58,8 @@ private List<String> createDependenciesStrings(DataResult dr) {
List<String> lines = new ArrayList<>();

// Loop through all items in data result
for (Object oIn : dr) {
Map<String, Object> item = (Map) oIn;
for (T oIn : dr) {
Map<String, T> item = (Map) oIn;

String name = (String) item.get("name");
String version = (String) item.get("version");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private String getEmailBodySummary(Errata errata, String host) {
return ls.getMessage("email.errata.notification.body.summary", args);
}

private String getEmailBodyAffectedSystems(String host, List servers) {
private String getEmailBodyAffectedSystems(String host, List<Row> servers) {
LocalizationService ls = LocalizationService.getInstance();

//Render the header of the affected systems section along with helpful text.
Expand Down Expand Up @@ -235,7 +235,7 @@ private String getEmailBodyAffectedSystems(String host, List servers) {
// the table according to the String Resource bundle.
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer, true);
for (Object serverIn : servers) {
for (Row serverIn : servers) {
Map<String, Object> row = (Map<String, Object>) serverIn;
String release = (String) row.get("release");
printWriter.print(release);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
/**
* Cleans up stale Kickstarts
*
* @param <T> is used in DataResult
*/

public class KickstartCleanup extends RhnJavaJob {
public class KickstartCleanup<T> extends RhnJavaJob {

@Override
public String getConfigNamespace() {
Expand All @@ -54,7 +55,7 @@ public void execute(JobExecutionContext ctx) throws JobExecutionException {
try {
SelectMode select = ModeFactory.getMode(TaskConstants.MODE_NAME,
TaskConstants.TASK_QUERY_KSCLEANUP_FIND_CANDIDATES);
DataResult dr = select.execute(Collections.emptyMap());
DataResult<T> dr = select.execute(Collections.emptyMap());
if (log.isDebugEnabled()) {
log.debug("Found {} entries to process", dr.size());
}
Expand All @@ -68,7 +69,7 @@ public void execute(JobExecutionContext ctx) throws JobExecutionException {
log.warn("Failed kickstart state id not found");
return;
}
for (Object oIn : dr) {
for (T oIn : dr) {
Map<String, Object> row = (Map<String, Object>) oIn;
processRow(failedStateId, row);
}
Expand Down

0 comments on commit 0664b5b

Please sign in to comment.