use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method getDNotesForStudy.
/**
* Acquire the DiscrepancyNoteBeans for a specific study.
*
* @param currentStudy
* A StudyBean object.
* @param resolutionStatus
* An int resolution status; only DiscrepancyNoteBeans will be
* returned if they have this resolutionStatus id.
* @param dataSource
* A DataSource used for various DAO methods.
* @param discNoteType
* An int discrepancy note type id; only DiscrepancyNoteBeans
* will be returned if they have this discrepancyNoteTypeId.
* @return A List of DiscrepancyNoteBeans.
*/
public List<DiscrepancyNoteBean> getDNotesForStudy(StudyBean currentStudy, int resolutionStatus, DataSource dataSource, int discNoteType) {
List<DiscrepancyNoteBean> allDiscNotes = new ArrayList<DiscrepancyNoteBean>();
if (currentStudy == null)
return allDiscNotes;
// Do the returned DN's have to be filtered? A valid resolution status
// has to be between 1 and 5; 0 is "invalid";
// -1 means that no resolutionStatus parameter was passed into the
// servlet
boolean filterDiscNotes = resolutionStatus >= 1 && resolutionStatus <= 5;
boolean filterforDiscNoteType = discNoteType >= 1 && discNoteType <= 4;
DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
// what is the purpose of this data member?
discrepancyNoteDAO.setFetchMapping(true);
EventCRFDAO ecdao = new EventCRFDAO(dataSource);
ArrayList itemDataNotes = discrepancyNoteDAO.findAllItemDataByStudy(currentStudy);
ArrayList subjectNotes = discrepancyNoteDAO.findAllSubjectByStudy(currentStudy);
ArrayList studySubjectNotes = discrepancyNoteDAO.findAllStudySubjectByStudy(currentStudy);
ArrayList studyEventNotes = discrepancyNoteDAO.findAllStudyEventByStudy(currentStudy);
ArrayList eventCRFNotes = discrepancyNoteDAO.findAllEventCRFByStudy(currentStudy);
allDiscNotes.addAll(itemDataNotes);
allDiscNotes.addAll(subjectNotes);
allDiscNotes.addAll(studySubjectNotes);
allDiscNotes.addAll(studyEventNotes);
allDiscNotes.addAll(eventCRFNotes);
if (filterDiscNotes) {
// filter for the resolution status
allDiscNotes = filterDiscNotes(allDiscNotes, resolutionStatus);
}
if (filterforDiscNoteType) {
// filter for the ddiscrepancyNoteTypeId
allDiscNotes = filterforDiscNoteType(allDiscNotes, discNoteType);
}
return allDiscNotes;
}
use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method getDNotesForStudy.
/**
* An overloaded version of the prior method, the difference being a HashSet
* of resolution status ids, instead of a single id.
*
* @param currentStudy
* A StudyBean object.
* @param resolutionStatusIds
* A HashSet object consisting of resolution status ids (i.e.,
* 1,2,3).
* @param dataSource
* A DataSource used for various DAO methods.
* @param discNoteType
* An int discrepancy note type id; only DiscrepancyNoteBeans
* will be returned if they have this discrepancyNoteTypeId.
* @return A List of DiscrepancyNoteBeans.
*/
public List<DiscrepancyNoteBean> getDNotesForStudy(StudyBean currentStudy, Set<Integer> resolutionStatusIds, DataSource dataSource, int discNoteType) {
List<DiscrepancyNoteBean> allDiscNotes = new ArrayList<DiscrepancyNoteBean>();
if (currentStudy == null)
return allDiscNotes;
// Do the returned DN's have to be filtered? A valid resolution status
// has to be between 1 and 5; 0 is "invalid";
// -1 means that no resolutionStatus parameter was passed into the
// servlet
boolean filterDiscNotes = checkResolutionStatus(resolutionStatusIds);
boolean filterforDiscNoteType = discNoteType >= 1 && discNoteType <= 4;
DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
// what is the purpose of this data member?
discrepancyNoteDAO.setFetchMapping(true);
EventCRFDAO ecdao = new EventCRFDAO(dataSource);
ArrayList itemDataNotes = discrepancyNoteDAO.findAllItemDataByStudy(currentStudy);
ArrayList subjectNotes = discrepancyNoteDAO.findAllSubjectByStudy(currentStudy);
ArrayList studySubjectNotes = discrepancyNoteDAO.findAllStudySubjectByStudy(currentStudy);
ArrayList studyEventNotes = discrepancyNoteDAO.findAllStudyEventByStudy(currentStudy);
ArrayList eventCRFNotes = discrepancyNoteDAO.findAllEventCRFByStudy(currentStudy);
allDiscNotes.addAll(itemDataNotes);
allDiscNotes.addAll(subjectNotes);
allDiscNotes.addAll(studySubjectNotes);
allDiscNotes.addAll(studyEventNotes);
allDiscNotes.addAll(eventCRFNotes);
if (filterDiscNotes) {
// filter for the resolution status
allDiscNotes = filterDiscNotes(allDiscNotes, resolutionStatusIds);
}
if (filterforDiscNoteType) {
// filter for the ddiscrepancyNoteTypeId
allDiscNotes = filterforDiscNoteType(allDiscNotes, discNoteType);
}
return allDiscNotes;
}
use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.
the class DownloadDiscrepancyNote method downLoadDiscBeans.
public void downLoadDiscBeans(List<DiscrepancyNoteBean> listOfBeans, String format, OutputStream stream, String studyIdentifier) {
if (listOfBeans == null) {
return;
}
StringBuilder allContent = new StringBuilder();
String singleBeanContent = "";
int counter = 0;
if (CSV.equalsIgnoreCase(format)) {
for (DiscrepancyNoteBean discNoteBean : listOfBeans) {
++counter;
singleBeanContent = counter == 1 ? serializeToString(discNoteBean, true, 0) : serializeToString(discNoteBean, false, 0);
allContent.append(singleBeanContent);
allContent.append("\n");
}
}
//This must be a ServletOutputStream for our purposes
ServletOutputStream servletStream = (ServletOutputStream) stream;
try {
if (CSV.equalsIgnoreCase(format)) {
servletStream.print(allContent.toString());
} else {
//Create PDF version
this.serializeListToPDF(listOfBeans, servletStream, studyIdentifier);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (servletStream != null) {
try {
servletStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.
the class DownloadDiscrepancyNote method serializeListToPDF.
public void serializeListToPDF(List<DiscrepancyNoteBean> listOfBeans, OutputStream stream, String studyIdentifier) {
ServletOutputStream servletStream = (ServletOutputStream) stream;
Document pdfDoc = new Document();
try {
PdfWriter.getInstance(pdfDoc, servletStream);
pdfDoc.open();
//Create header for the study identifier or name
if (studyIdentifier != null) {
HeaderFooter header = new HeaderFooter(new Phrase("Study Identifier: " + studyIdentifier + " pg."), true);
header.setAlignment(Element.ALIGN_CENTER);
Paragraph para = new Paragraph("Study Identifier: " + studyIdentifier, new Font(Font.HELVETICA, 18, Font.BOLD, new Color(0, 0, 0)));
para.setAlignment(Element.ALIGN_CENTER);
pdfDoc.setHeader(header);
pdfDoc.add(para);
}
for (DiscrepancyNoteBean discNoteBean : listOfBeans) {
pdfDoc.add(this.createTableFromBean(discNoteBean));
pdfDoc.add(new Paragraph("\n"));
}
//pdfDoc.add(new Paragraph(content));
} catch (DocumentException e) {
e.printStackTrace();
}
pdfDoc.close();
}
use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.
the class DownloadDiscrepancyNote method serializeToPDF.
private void serializeToPDF(EntityBean bean, OutputStream stream) {
ServletOutputStream servletStream = (ServletOutputStream) stream;
DiscrepancyNoteBean discNBean = (DiscrepancyNoteBean) bean;
StringBuilder writer = new StringBuilder();
writer.append(serializeToString(discNBean, false, 0));
Document pdfDoc = new Document();
try {
PdfWriter.getInstance(pdfDoc, servletStream);
pdfDoc.open();
pdfDoc.add(new Paragraph(writer.toString()));
} catch (DocumentException e) {
e.printStackTrace();
}
pdfDoc.close();
}
Aggregations