use of org.akaza.openclinica.bean.submit.SubjectBean in project OpenClinica by OpenClinica.
the class SubjectDAO method create.
/**
* @deprecated Creates a new subject
*/
@Deprecated
public EntityBean create(EntityBean eb) {
SubjectBean sb = (SubjectBean) eb;
HashMap variables = new HashMap();
HashMap nullVars = new HashMap();
// FATHER_ID,MOTHER_ID, STATUS_ID,
// DATE_OF_BIRTH,GENDER,UNIQUE_IDENTIFIER,DATE_CREATED,
// OWNER_ID
variables.put(new Integer(1), new Integer(sb.getStatus().getId()));
if (sb.getDateOfBirth() == null) {
nullVars.put(new Integer(4), new Integer(Types.DATE));
variables.put(new Integer(4), null);
} else {
variables.put(new Integer(4), sb.getDateOfBirth());
}
if (sb.getGender() != 'm' && sb.getGender() != 'f') {
nullVars.put(new Integer(5), new Integer(Types.CHAR));
variables.put(new Integer(5), null);
} else {
char[] ch = { sb.getGender() };
variables.put(new Integer(5), new String(ch));
}
variables.put(new Integer(6), sb.getUniqueIdentifier());
// DATE_CREATED is now()
variables.put(new Integer(7), new Integer(sb.getOwner().getId()));
execute(digester.getQuery("create"), variables, nullVars);
if (isQuerySuccessful()) {
sb.setId(getCurrentPK());
}
return sb;
}
use of org.akaza.openclinica.bean.submit.SubjectBean in project OpenClinica by OpenClinica.
the class SubjectDAO method findByUniqueIdentifierAndStudy.
public SubjectBean findByUniqueIdentifierAndStudy(String uniqueIdentifier, int studyId) {
SubjectBean answer = new SubjectBean();
this.setTypesExpected();
HashMap variables = new HashMap();
variables.put(new Integer(1), uniqueIdentifier);
variables.put(new Integer(2), new Integer(studyId));
String sql = digester.getQuery("findByUniqueIdentifierAndStudy");
ArrayList alist = this.select(sql, variables);
Iterator it = alist.iterator();
if (it.hasNext()) {
answer = (SubjectBean) this.getEntityFromHashMap((HashMap) it.next());
}
return answer;
}
use of org.akaza.openclinica.bean.submit.SubjectBean in project OpenClinica by OpenClinica.
the class SubjectDAO method update.
/**
* <b>update </b>, the method that returns an updated subject bean after it
* updates the database.
*
* @return sb, an updated study bean.
*/
public EntityBean update(EntityBean eb) {
SubjectBean sb = (SubjectBean) eb;
HashMap variables = new HashMap();
HashMap nullVars = new HashMap();
// UPDATE subject SET FATHER_ID=?,MOTHER_ID=?, STATUS_ID=?,
// DATE_OF_BIRTH=?,GENDER=?,UNIQUE_IDENTIFIER=?, DATE_UPDATED=?,
// UPDATE_ID=? DOB_COLLECTED=? WHERE SUBJECT_ID=?
// YW <<
int ind = 1;
variables.put(new Integer(ind++), new Integer(sb.getStatus().getId()));
if (sb.getDateOfBirth() != null) {
variables.put(new Integer(ind), sb.getDateOfBirth());
} else {
nullVars.put(new Integer(ind), new Integer(Types.DATE));
variables.put(new Integer(ind), null);
}
ind++;
if (sb.getGender() != 'm' && sb.getGender() != 'f') {
nullVars.put(new Integer(ind), new Integer(Types.CHAR));
variables.put(new Integer(ind), null);
} else {
char[] ch = { sb.getGender() };
variables.put(new Integer(ind), new String(ch));
}
ind++;
variables.put(new Integer(ind++), new String(sb.getUniqueIdentifier()));
// date_updated is set to now()
// variables.put(new Integer(ind++), new java.util.Date());
variables.put(new Integer(ind++), new Integer(sb.getUpdater().getId()));
variables.put(new Integer(ind++), new Boolean(sb.isDobCollected()));
// YW >>
variables.put(new Integer(ind++), new Integer(sb.getId()));
String sql = digester.getQuery("update");
this.execute(sql, variables, nullVars);
return sb;
}
use of org.akaza.openclinica.bean.submit.SubjectBean in project OpenClinica by OpenClinica.
the class SubjectDAO method findAllByLimit.
public Collection findAllByLimit(boolean hasLimit) {
this.setTypesExpected();
ArrayList alist = null;
if (hasLimit) {
alist = this.select(digester.getQuery("findAllByLimit"));
} else {
alist = this.select(digester.getQuery("findAll"));
}
ArrayList al = new ArrayList();
Iterator it = alist.iterator();
while (it.hasNext()) {
SubjectBean eb = (SubjectBean) this.getEntityFromHashMap((HashMap) it.next());
al.add(eb);
}
return al;
}
use of org.akaza.openclinica.bean.submit.SubjectBean in project OpenClinica by OpenClinica.
the class SubjectDAO method findAnotherByIdentifier.
public EntityBean findAnotherByIdentifier(String name, int subjectId) {
SubjectBean eb = new SubjectBean();
this.setTypesExpected();
HashMap variables = new HashMap();
variables.put(new Integer(1), name);
variables.put(new Integer(2), new Integer(subjectId));
String sql = digester.getQuery("findAnotherByIdentifier");
ArrayList alist = this.select(sql, variables);
Iterator it = alist.iterator();
if (it.hasNext()) {
eb = (SubjectBean) this.getEntityFromHashMap((HashMap) it.next());
}
return eb;
}
Aggregations