Skip to content

Commit

Permalink
Merge pull request #2518 from CCAFS/aiccra-dev-A2-392-IPI-2.3
Browse files Browse the repository at this point in the history
Aiccra dev a2 392 ipi 2.3
  • Loading branch information
MetalPrime authored Apr 26, 2024
2 parents 7997371 + 5c21875 commit 1a8492f
Show file tree
Hide file tree
Showing 25 changed files with 730 additions and 308 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ public List<Deliverable> getDeliverablesByParameters(Phase phase, boolean filter

public List<Deliverable> getPublicationsByPhase(long phase);

/**
* get deliverables without activities
*
* @author IBD
* @param phase phase of the project
* @param projectId project id
* @return quantity deliverables without activities
*/
int getQuantityDeliverablesWithActivities(long phase, long projectId);

public Boolean isDeliverableExcluded(Long deliverableId, Long phaseId);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public interface FeedbackQACommentDAO {
*/
public List<FeedbackQAComment> findAll();

/**
* This method gets a list of feedbackQAComment by phase, that are active
*
* @return a list from FeedbackQAComment null if no exist records
*/
List<FeedbackQAComment> findAllByPhase(long phaseId);

/**
* This method gets a list of feedbackQAComment that are active by Parent id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ public interface FeedbackQACommentableFieldsDAO {
public List<FeedbackQACommentableFields> findBySectionName(String sectionName);


/**
* Get the answered comment by phase
*
* @author IBD
* @param phase phase of the project
* @return deliverable list with the comment count. olny coment with answer
*/
List<String> getAnsweredCommentByPhaseToStudy(long phase);

/**
* Get the commentstatus by phase
*
* @author IBD
* @param phase phase of the project
* @return deliverable list with the comment count
*/
List<String> getCommentStatusByPhaseToStudy(long phase);

/**
* This method saves the information of the given internalQaCommentableFields
*
Expand All @@ -74,4 +92,6 @@ public interface FeedbackQACommentableFieldsDAO {
* or -1 is some error occurred.
*/
public FeedbackQACommentableFields save(FeedbackQACommentableFields feedbackQACommentableFields);


}
Original file line number Diff line number Diff line change
Expand Up @@ -21,71 +21,85 @@

public interface LocElementDAO {

/**
* This method removes a specific locElement value from the database.
*
* @param locElementId is the locElement identifier.
* @return true if the locElement was successfully deleted, false otherwise.
*/
public void deleteLocElement(long locElementId);
/**
* This method removes a specific locElement value from the database.
*
* @param locElementId is the locElement identifier.
* @return true if the locElement was successfully deleted, false otherwise.
*/
public void deleteLocElement(long locElementId);

/**
* This method validate if the locElement identify with the given id exists
* in the system.
*
* @param locElementID is a locElement identifier.
* @return true if the locElement exists, false otherwise.
*/
public boolean existLocElement(long locElementID);
/**
* This method validate if the locElement identify with the given id exists
* in the system.
*
* @param locElementID is a locElement identifier.
* @return true if the locElement exists, false otherwise.
*/
public boolean existLocElement(long locElementID);

/**
* This method gets a locElement object by a given locElement identifier.
*
* @param locElementID is the locElement identifier.
* @return a LocElement object.
*/
public LocElement find(long id);
/**
* This method gets a locElement object by a given locElement identifier.
*
* @param locElementID is the locElement identifier.
* @return a LocElement object.
*/
public LocElement find(long id);

/**
* This method gets a list of locElement that are active
*
* @return a list from LocElement null if no exist records
*/
public List<LocElement> findAll();
/**
* This method gets a list of locElement that are active
*
* @return a list from LocElement null if no exist records
*/
public List<LocElement> findAll();

/**
* This method gets a locElement object by a given locElement IsoCode.
*
* @param ISOCode of the LocElement.
* @return a LocElement object.
*/
public LocElement findISOCode(String ISOcode);
/**
* This method gets a list of locElement that are active, only conutries
*
* @return a list from LocElement null if no exist records
*/
List<LocElement> findAllToCountries();

/**
* This method gets a locElement object by a parent locElement.
*
* @param parentId is the locElement parent id.
* @return a LocElement object.
*/
public List<LocElement> findLocElementByParent(Long parentId);
/**
* This method gets a list of locElement that are active, only regions
*
* @return a list from LocElement null if no exist records
*/
List<LocElement> findAllToRegions();

/**
* This method gets a locElement object by a given locElement numeric
* IsoCode.
*
* @param numeric ISOCode of the LocElement.
* @return a LocElement object.
*/
LocElement findNumericISOCode(Long ISOcode);
/**
* This method gets a locElement object by a given locElement IsoCode.
*
* @param ISOCode of the LocElement.
* @return a LocElement object.
*/
public LocElement findISOCode(String ISOcode);

/**
* This method saves the information of the given locElement
*
* @param locElement - is the locElement object with the new information to
* be added/updated.
* @return a number greater than 0 representing the new ID assigned by the
* database, 0 if the locElement was updated or -1 is some error occurred.
*/
public LocElement save(LocElement locElement);
/**
* This method gets a locElement object by a parent locElement.
*
* @param parentId is the locElement parent id.
* @return a LocElement object.
*/
public List<LocElement> findLocElementByParent(Long parentId);

/**
* This method gets a locElement object by a given locElement numeric
* IsoCode.
*
* @param numeric ISOCode of the LocElement.
* @return a LocElement object.
*/
LocElement findNumericISOCode(Long ISOcode);

/**
* This method saves the information of the given locElement
*
* @param locElement - is the locElement object with the new information to
* be added/updated.
* @return a number greater than 0 representing the new ID assigned by the
* database, 0 if the locElement was updated or -1 is some error occurred.
*/
public LocElement save(LocElement locElement);

}
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public List<Deliverable> getDeliverablesByProjectAndPhase(long phaseId, long pro
return deliverables;
}


@Override
public List<DeliverableHomeDTO> getDeliverablesByProjectAndPhaseHome(long phaseId, long projectId) {
String query = "select d.id as deliverableId, coalesce(di.newExpectedYear, -1) as newExpectedYear, "
Expand Down Expand Up @@ -395,6 +396,44 @@ public List<Deliverable> getPublicationsByPhase(long phase) {
return deliverables;
}

/**
* get deliverables without activities
*
* @author IBD
* @param phase phase of the project
* @param projectId project id
* @return quantity deliverables without activities
*/
@Override
public int getQuantityDeliverablesWithActivities(long phase, long projectId) {
StringBuilder query = new StringBuilder();
query.append("SELECT count(*) as count FROM deliverables d ");
query.append("join deliverables_info di on d.id = di.deliverable_id ");
query.append("join phases p on p.id = d.id_phase");
query.append(" WHERE d.id_phase=" + phase);
query.append(" and d.id_phase = di.id_phase ");
query.append(" and d.is_active = 1 and d.is_active =di.is_active ");
query.append(" and d.project_id=" + projectId);
query.append(
" and (d.id not in (select da.deliverable_id from deliverable_activities da where da.deliverable_id = d.id and da.is_active =1 ) ");
query.append(
" or d.id not in (select da.deliverable_id from deliverable_activities da where deliverable_id = d.id and da.is_active =1 and da.id_phase =p.id) ");
query.append(
" or d.id not in (select da.deliverable_id from deliverable_activities da join activities a on da.activity_id = a.id where deliverable_id = d.id and da.is_active =1 and a.is_active =1 and da.id_phase =p.id)) ");


List<Map<String, Object>> rList = super.findCustomQuery(query.toString());
int deliverable = 0;

if (rList != null) {
for (Map<String, Object> map : rList) {
deliverable = Integer.parseInt(map.get("count").toString());
}
}

return deliverable;
}

@Override
public Boolean isDeliverableExcluded(Long deliverableId, Long phaseId) {
StringBuilder query = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ public List<FeedbackQAComment> findAll() {

}

@Override
public List<FeedbackQAComment> findAllByPhase(long phaseId) {
String query = "from " + FeedbackQAComment.class.getName() + " where id_phase = " + phaseId;
List<FeedbackQAComment> list = super.findAll(query);
if (list.size() > 0) {
return list;
}
return null;

}

@Override
public List<FeedbackQAComment> getFeedbackQACommentsByParentId(long parentID) {
String query = "from " + FeedbackQAComment.class.getName() + " where parent_id=" + parentID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import org.cgiar.ccafs.marlo.data.dao.FeedbackQACommentableFieldsDAO;
import org.cgiar.ccafs.marlo.data.model.FeedbackQACommentableFields;

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

import javax.inject.Inject;
import javax.inject.Named;
Expand Down Expand Up @@ -81,6 +83,71 @@ public List<FeedbackQACommentableFields> findBySectionName(String sectionName) {
return Collections.emptyList();
}

/**
* Get the answered comment by phase
*
* @author IBD
* @param phase phase of the project
* @return deliverable list with the comment count. olny coment with answer
*/
@Override
public List<String> getAnsweredCommentByPhaseToStudy(long phase) {
StringBuilder query = new StringBuilder();
query.append("SELECT parent_id as parent_id,count(*) as count ");
query.append("FROM feedback_qa_comments fqc");
query.append(" WHERE id_phase=" + phase);
query.append(" and status_id = 1 ");
query.append(" and field_id in (select id from feedback_qa_commentable_fields fqcf ");
query.append(" where section_name = 'study') ");
query.append(" and reply_id is not null ");
query.append(" group by parent_id ");

List<Map<String, Object>> rList = super.findCustomQuery(query.toString());
List<String> comments = new ArrayList<>();

if (rList != null) {
for (Map<String, Object> map : rList) {
String tmp = map.get("parent_id").toString() + "|" + map.get("count").toString();
comments.add(tmp);
}
}

return comments;
}


/**
* Get the commentstatus by phase
*
* @author IBD
* @param phase phase of the project
* @return deliverable list with the comment count
*/
@Override
public List<String> getCommentStatusByPhaseToStudy(long phase) {
StringBuilder query = new StringBuilder();
query.append("SELECT parent_id as parent_id,count(*) as count ");
query.append("FROM feedback_qa_comments fqc");
query.append(" WHERE id_phase=" + phase);
query.append(" and status_id <> 6 ");
query.append(" and field_id in (select id from feedback_qa_commentable_fields fqcf ");
query.append(" where section_name = 'study') ");
query.append(" group by parent_id ");

List<Map<String, Object>> rList = super.findCustomQuery(query.toString());
List<String> comments = new ArrayList<>();

if (rList != null) {
for (Map<String, Object> map : rList) {
String tmp = map.get("parent_id").toString() + "|" + map.get("count").toString();
comments.add(tmp);
}
}

return comments;
}


@Override
public FeedbackQACommentableFields save(FeedbackQACommentableFields feedbackQACommentableFields) {
if (feedbackQACommentableFields.getId() == null) {
Expand Down
Loading

0 comments on commit 1a8492f

Please sign in to comment.