Skip to content

Commit

Permalink
♻️ refactor(Report action): Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjitm committed Mar 4, 2025
1 parent df231e8 commit aefeaa0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
package org.cgiar.ccafs.marlo.action.report;

import org.cgiar.ccafs.marlo.action.BaseAction;
import org.cgiar.ccafs.marlo.data.manager.PhaseManager;
import org.cgiar.ccafs.marlo.data.manager.ProjectManager;
import org.cgiar.ccafs.marlo.data.manager.ReportConfigurationManager;
import org.cgiar.ccafs.marlo.data.model.ReportConfiguration;
import org.cgiar.ccafs.marlo.utils.APConfig;
Expand Down Expand Up @@ -58,8 +56,6 @@ public class MicroserviceReportAction extends BaseAction {
private long projectID;

// Managers
private ProjectManager projectManager;
private PhaseManager phaseManager;
private ReportConfigurationManager reportConfigurationManager;

private String username = null;
Expand All @@ -75,11 +71,8 @@ public class MicroserviceReportAction extends BaseAction {


@Inject
public MicroserviceReportAction(APConfig config, ProjectManager projectManager, PhaseManager phaseManager,
ReportConfigurationManager reportConfigurationManager) {
public MicroserviceReportAction(APConfig config, ReportConfigurationManager reportConfigurationManager) {
super(config);
this.projectManager = projectManager;
this.phaseManager = phaseManager;
this.reportConfigurationManager = reportConfigurationManager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2295,16 +2295,30 @@ public String getCaseStudiesTableModelv2(List<ProjectExpectedStudyInfo> projectE
jsonRoot.put("options", jsonOptions);
jsonRoot.put("fileName", "AICCRA-Result-Generated.pdf");
jsonRoot.put("bucketName", "microservice-reports");
jsonRoot.put("credentials", jsonCredentials);

jsonCredentials.put("username", "____");
jsonCredentials.put("password", "___");
/*
* jsonRoot.put("credentials", jsonCredentials);
* jsonCredentials.put("username", "____");
* jsonCredentials.put("password", "___");
*/

String username = null, password = null;
try {
username = config.getMicroserviceUsername();
password = config.getMicroservicePassword();
} catch (Exception e) {
Log.error("error getting conf credentials " + e);
}
String credentialsJson = "{\"username\":\"" + username + "\",\"password\":\"" + password + "\"}";
jsonRoot.put("credentials", credentialsJson);

try {
String jsonOutput = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonRoot);
FileWriter fileWriter = new FileWriter(new File("D:/OICRs_Report.json"));
fileWriter.write(jsonOutput);
fileWriter.close();

// TODO: Call microservice action
return jsonOutput;
} catch (IOException e) {
e.printStackTrace();
Expand Down

0 comments on commit aefeaa0

Please # to comment.