Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/CCAFS/MARLO into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
German Martinez committed Jun 1, 2022
2 parents b91c5c0 + 531ab0d commit ae67b94
Show file tree
Hide file tree
Showing 66 changed files with 3,337 additions and 1,280 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public interface CrpProgramLeaderDAO {
public List<CrpProgramLeader> findAll();


public CrpProgramLeader getCrpProgramLeaderByProgram(long crpProgramID, long globalUnitID, long userID);

/**
* This method saves the information of the given crpProgramLeader
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public interface InstitutionTypeDAO {
*/
public List<InstitutionType> findAll();

/**
* This method gets a list of institutionType that are IATI
*
* @return a list from InstitutionType; null if no exist records
*/
public List<InstitutionType> findAllIATITypes();

/**
* This method saves the information of the given institutionType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ public interface ProjectCenterOutcomeDAO {
*/
public List<ProjectCenterOutcome> findAll();

/**
* This method gets a list of projectCenterOutcome that are active
*
* @param PhaseID - phase identification
* @param ProjectID - project identification
* @param projectCenterOutcome identification.
* @return a list from ProjectCenterOutcome null if no exist records
*/
public List<ProjectCenterOutcome> getProjectCenterOutcomeByPhase(Long phaseID, Long projectID, Long centerOutcomeID);

/**
* This method saves the information of the given projectCenterOutcome
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.cgiar.ccafs.marlo.data.dao;

import org.cgiar.ccafs.marlo.data.model.RestApiAuditlog;

/**
*
* @author tonyshikali
*/
public interface RestApiAuditlogDAO {

public void logThis(RestApiAuditlog restApiAuditLog);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
import org.cgiar.ccafs.marlo.data.dao.CrpProgramLeaderDAO;
import org.cgiar.ccafs.marlo.data.model.CrpProgramLeader;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.inject.Named;
import javax.inject.Inject;
import javax.inject.Named;

import org.hibernate.SessionFactory;

@Named
Expand Down Expand Up @@ -68,6 +71,28 @@ public List<CrpProgramLeader> findAll() {

}

@Override
public CrpProgramLeader getCrpProgramLeaderByProgram(long crpProgramID, long globalUnitID, long userID) {
String query = "Select crp_program_leaders.id from crp_program_leaders "
+ "INNER JOIN crp_programs ON crp_programs.id=crp_program_leaders.crp_program_id "
+ "WHERE crp_program_leaders.is_active=1 and crp_program_leaders.crp_program_id=" + crpProgramID + " "
+ "AND crp_programs.global_unit_id=" + globalUnitID + " " + "AND crp_program_leaders.user_id=" + userID;
List<Map<String, Object>> rList = super.findCustomQuery(query.toString());
List<CrpProgramLeader> crpProgramLeaders = new ArrayList<CrpProgramLeader>();
if (rList != null) {
for (Map<String, Object> map : rList) {
CrpProgramLeader crpProgramLeader = this.find(Long.parseLong(map.get("id").toString()));
crpProgramLeaders.add(crpProgramLeader);
}
}
if (crpProgramLeaders.size() > 0) {
return crpProgramLeaders.get(0);
} else {
return null;
}

}

@Override
public CrpProgramLeader save(CrpProgramLeader crpProgramLeader) {
if (crpProgramLeader.getId() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@

import java.util.List;

import javax.inject.Named;
import javax.inject.Inject;
import javax.inject.Named;

import org.hibernate.SessionFactory;

@Named
Expand Down Expand Up @@ -68,6 +69,17 @@ public List<InstitutionType> findAll() {

}

@Override
public List<InstitutionType> findAllIATITypes() {
String query = "from " + InstitutionType.class.getName() + " where is_legacy = 0";
List<InstitutionType> list = super.findAll(query);
if (list.size() > 0) {
return list;
}

return null;
}

@Override
public InstitutionType save(InstitutionType institutionType) {
if (institutionType.getId() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@
import org.cgiar.ccafs.marlo.data.dao.ProjectCenterOutcomeDAO;
import org.cgiar.ccafs.marlo.data.model.ProjectCenterOutcome;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;
import javax.inject.Named;

import org.hibernate.SessionFactory;

@Named
public class ProjectCenterOutcomeMySQLDAO extends AbstractMarloDAO<ProjectCenterOutcome, Long> implements ProjectCenterOutcomeDAO {
public class ProjectCenterOutcomeMySQLDAO extends AbstractMarloDAO<ProjectCenterOutcome, Long>
implements ProjectCenterOutcomeDAO {


@Inject
Expand Down Expand Up @@ -69,6 +72,28 @@ public List<ProjectCenterOutcome> findAll() {

}

@Override
public List<ProjectCenterOutcome> getProjectCenterOutcomeByPhase(Long phaseID, Long projectID, Long centerOutcome) {
StringBuilder query = new StringBuilder();
query.append("SELECT project_center_outcomes.id as projectCenterOutcomeId FROM project_center_outcomes ");
query.append("INNER JOIN phases ON project_center_outcomes.id_phase = phases.id ");
query.append("WHERE project_id = ");
query.append(projectID);
query.append(" AND center_outcome_id = ");
query.append(centerOutcome);
query.append(" AND phases.id = ");
query.append(phaseID);
List<Map<String, Object>> list = super.findCustomQuery(query.toString());
List<ProjectCenterOutcome> ProjectCenterOutcomes = new ArrayList<ProjectCenterOutcome>();
for (Map<String, Object> map : list) {
String projectCenterOutcomeId = map.get("projectCenterOutcomeId").toString();
long longProjectCenterOutcomeId = Long.parseLong(projectCenterOutcomeId);
ProjectCenterOutcome projectCenterOutcome = this.find(longProjectCenterOutcomeId);
ProjectCenterOutcomes.add(projectCenterOutcome);
}
return ProjectCenterOutcomes;
}

@Override
public ProjectCenterOutcome save(ProjectCenterOutcome projectCenterOutcome) {
if (projectCenterOutcome.getId() == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.cgiar.ccafs.marlo.data.dao.mysql;

import javax.inject.Inject;
import javax.inject.Named;
import org.cgiar.ccafs.marlo.data.dao.RestApiAuditlogDAO;
import org.cgiar.ccafs.marlo.data.model.RestApiAuditlog;
import org.hibernate.SessionFactory;

/**
*
* @author tonyshikali
*/
@Named
public class RestApiAuditlogMySQLDAO extends AbstractMarloDAO<RestApiAuditlog, Long> implements RestApiAuditlogDAO{

@Inject
public RestApiAuditlogMySQLDAO(SessionFactory sessionFactory) {
super(sessionFactory);
}

@Override
public void logThis(RestApiAuditlog restApiAuditLog) {
super.saveEntity(restApiAuditLog);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public interface CrpProgramLeaderManager {
*/
public CrpProgramLeader getCrpProgramLeaderById(long crpProgramLeaderID);

public CrpProgramLeader getCrpProgramLeaderByProgram(long crpProgramID, long globalUnitID, long userID);

/**
* This method saves the information of the given crpProgramLeader
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public interface InstitutionTypeManager {
*/
public List<InstitutionType> findAll();

/**
* This method gets a list of institutionType that are IATI
*
* @return a list from InstitutionType; null if no exist records
*/
public List<InstitutionType> findAllIATITypes();

/**
* This method gets a institutionType object by a given institutionType identifier.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ public interface ProjectCenterOutcomeManager {
*/
public ProjectCenterOutcome getProjectCenterOutcomeById(long projectCenterOutcomeID);

/**
* This method gets a list of projectCenterOutcome information by
*
* @param PhaseID - phase identification
* @param ProjectID - project identification
* @param projectCenterOutcome identification.
* @return list of ProjectCenterOutcome object references.
*/
public List<ProjectCenterOutcome> getProjectCenterOutcomeByPhase(Long phaseID, Long ProjectID, Long centerOutcomeID);

/**
* This method saves the information of the given projectCenterOutcome
*
Expand All @@ -69,6 +79,4 @@ public interface ProjectCenterOutcomeManager {
* or -1 is some error occurred.
*/
public ProjectCenterOutcome saveProjectCenterOutcome(ProjectCenterOutcome projectCenterOutcome);


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.cgiar.ccafs.marlo.data.manager;

import org.cgiar.ccafs.marlo.data.model.RestApiAuditlog;

/**
*
* @author tonyshikali
*/
public interface RestApiAuditlogManager {

public void logApiCall(RestApiAuditlog restApiAuditlog);

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*****************************************************************
* This file is part of Managing Agricultural Research for Learning &
* Outcomes Platform (MARLO).
* This file is part of Managing Agricultural Research for Learning &
* Outcomes Platform (MARLO).
* MARLO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
Expand All @@ -21,8 +21,8 @@

import java.util.List;

import javax.inject.Named;
import javax.inject.Inject;
import javax.inject.Named;

/**
* @author Christian Garcia
Expand Down Expand Up @@ -67,6 +67,12 @@ public CrpProgramLeader getCrpProgramLeaderById(long crpProgramLeaderID) {
return crpProgramLeaderDAO.find(crpProgramLeaderID);
}

@Override
public CrpProgramLeader getCrpProgramLeaderByProgram(long crpProgramID, long globalUnitID, long userID) {

return crpProgramLeaderDAO.getCrpProgramLeaderByProgram(crpProgramID, globalUnitID, userID);
}

@Override
public CrpProgramLeader saveCrpProgramLeader(CrpProgramLeader crpProgramLeader) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,36 @@ public class InstitutionTypeManagerImpl implements InstitutionTypeManager {
@Inject
public InstitutionTypeManagerImpl(InstitutionTypeDAO institutionTypeDAO) {
this.institutionTypeDAO = institutionTypeDAO;


}

@Override
public void deleteInstitutionType(long institutionTypeId) {

institutionTypeDAO.deleteInstitutionType(institutionTypeId);
}

@Override
public boolean existInstitutionType(long institutionTypeID) {

return institutionTypeDAO.existInstitutionType(institutionTypeID);
}

@Override
public List<InstitutionType> findAll() {

return institutionTypeDAO.findAll();
}

@Override
public List<InstitutionType> findAllIATITypes() {
return this.institutionTypeDAO.findAllIATITypes();
}

@Override
public InstitutionType getInstitutionTypeById(long institutionTypeID) {

return institutionTypeDAO.find(institutionTypeID);
}

@Override
public InstitutionType saveInstitutionType(InstitutionType institutionType) {

return institutionTypeDAO.save(institutionType);
}

}
}
Loading

0 comments on commit ae67b94

Please sign in to comment.