use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.
the class OdmImportServiceImpl method saveOrUpdateCrfAndFormLayouts.
private void saveOrUpdateCrfAndFormLayouts(String crfOid, List<OCodmComplexTypeDefinitionFormLayoutDef> formLayoutDefs, Form[] fmCrfs, UserAccount userAccount, Study study, String crfName) {
DataBinder dataBinder = new DataBinder(new FormLayout());
Errors errors = dataBinder.getBindingResult();
StudyBean currentStudy = new StudyBean();
currentStudy.setId(study.getStudyId());
UserAccountBean ub = new UserAccountBean();
ub.setId(userAccount.getUserId());
ub.setActiveStudyId(currentStudy.getId());
for (Form crf : fmCrfs) {
if (crf.getOcoid().equals(crfOid)) {
ExecuteIndividualCrfObject eicObj = new ExecuteIndividualCrfObject(crf, formLayoutDefs, errors, currentStudy, ub, true, null);
xformService.executeIndividualCrf(eicObj);
}
}
}
use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.
the class AnonymousFormControllerV2 method createAnonymousEnketoUrl.
private String createAnonymousEnketoUrl(String studyOID, FormLayoutBean formLayout, EventDefinitionCRFBean edcBean, boolean isOffline) throws Exception {
StudyBean parentStudyBean = getParentStudy(studyOID);
PFormCache cache = PFormCache.getInstance(context);
String enketoURL = cache.getPFormURL(parentStudyBean.getOid(), formLayout.getOid(), isOffline);
String contextHash = cache.putAnonymousFormContext(studyOID, formLayout.getOid(), edcBean.getStudyEventDefinitionId());
String url = null;
if (isOffline)
url = enketoURL.split("#", 2)[0] + "?" + FORM_CONTEXT + "=" + contextHash + "#" + enketoURL.split("#", 2)[1];
else
url = enketoURL + "?" + FORM_CONTEXT + "=" + contextHash;
logger.debug("Enketo URL for " + formLayout.getName() + "= " + url);
return url;
}
use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.
the class AccountController method isStudyASiteLevelStudy.
private Boolean isStudyASiteLevelStudy(String studyOid) {
StudyBean studyBean = getStudy(studyOid);
if (studyBean.getParentStudyId() != 0) {
logger.info("***Study provided in the URL is a Site study***");
System.out.println("***Study provided in the URL is a Site study***");
return true;
}
return false;
}
use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.
the class OpenRosaServices method getUserXml.
private String getUserXml(ServletContext context) throws Exception {
HashMap<String, String> value = getSubjectContextCacheValue(context);
String studySubjectOid = value.get("studySubjectOID");
StudySubject ssBean = ssDao.findByOcOID(studySubjectOid);
StudyBean study = getStudy(ssBean.getStudy().getOc_oid());
StudyBean parentStudy = getParentStudy(ssBean.getStudy().getOc_oid());
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element root = doc.createElement("root");
doc.appendChild(root);
List<UserAccount> users = userAccountDao.findNonRootNonParticipateUsersByStudyId(study.getId(), parentStudy.getId());
for (UserAccount userAccount : users) {
Element item = doc.createElement("item");
Element userName = doc.createElement("user_name");
userName.appendChild(doc.createTextNode(userAccount.getUserName()));
Element firstName = doc.createElement("first_name");
firstName.appendChild(doc.createTextNode(userAccount.getFirstName()));
Element lastName = doc.createElement("last_name");
lastName.appendChild(doc.createTextNode(userAccount.getLastName()));
item.appendChild(userName);
item.appendChild(firstName);
item.appendChild(lastName);
root.appendChild(item);
}
DOMSource dom = new DOMSource(doc);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
transformer.transform(dom, result);
String userXml = writer.toString();
return userXml;
}
use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.
the class RestoreStudyUserRoleServlet method sendEmail.
/**
* Send email to the user, director and administrator
*
* @param request
* @param response
*/
private String sendEmail(UserAccountBean u, StudyUserRoleBean sub) throws Exception {
StudyDAO sdao = new StudyDAO(sm.getDataSource());
StudyBean study = (StudyBean) sdao.findByPK(sub.getStudyId());
logger.info("Sending email...");
String body = u.getFirstName() + " " + u.getLastName() + "(" + resword.getString("username") + ": " + u.getName() + ") " + respage.getString("has_been_restored_to_the_study_site") + " " + study.getName() + respage.getString("with_the_role") + " " + sub.getRoleName() + ". " + respage.getString("the_user_is_now_be_able_to_access_study");
sendEmail(u.getEmail().trim(), respage.getString("restore_user_role"), body, false);
sendEmail(ub.getEmail().trim(), respage.getString("restore_user_role"), body, false);
sendEmail(EmailEngine.getAdminEmail(), respage.getString("restore_user_role"), body, false);
return body;
}
Aggregations