use of org.openmrs.ConceptStateConversion in project openmrs-core by openmrs.
the class HibernateProgramWorkflowDAO method getConceptStateConversion.
/**
* @see org.openmrs.api.db.ProgramWorkflowDAO#getConceptStateConversion(org.openmrs.ProgramWorkflow,
* org.openmrs.Concept)
*/
@Override
public ConceptStateConversion getConceptStateConversion(ProgramWorkflow workflow, Concept trigger) {
ConceptStateConversion csc = null;
if (workflow != null && trigger != null) {
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(ConceptStateConversion.class, "csc");
criteria.add(Restrictions.eq("csc.programWorkflow", workflow));
criteria.add(Restrictions.eq("csc.concept", trigger));
csc = (ConceptStateConversion) criteria.uniqueResult();
}
return csc;
}
use of org.openmrs.ConceptStateConversion in project openmrs-core by openmrs.
the class StateConversionValidator method validate.
/**
* Checks the form object for any inconsistencies/errors
*
* @see org.springframework.validation.Validator#validate(java.lang.Object,
* org.springframework.validation.Errors)
* @should fail validation if concept is null or empty or whitespace
* @should fail validation if programWorkflow is null or empty or whitespace
* @should fail validation if programWorkflowState is null or empty or whitespace
* @should pass validation if all required fields have proper values
*/
@Override
public void validate(Object obj, Errors errors) {
ConceptStateConversion c = (ConceptStateConversion) obj;
if (c == null) {
log.debug("Rejecting because c is null");
errors.rejectValue("conceptStateConversion", "error.general");
} else {
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "concept", "error.concept");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "programWorkflow", "error.programWorkflow");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "programWorkflowState", "error.programWorkflowState");
}
}
use of org.openmrs.ConceptStateConversion in project openmrs-core by openmrs.
the class StateConversionValidatorTest method validate_shouldFailValidationIfProgramWorkflowIsNullOrEmptyOrWhitespace.
/**
* @see StateConversionValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfProgramWorkflowIsNullOrEmptyOrWhitespace() {
ConceptStateConversion csc = new ConceptStateConversion();
csc.setProgramWorkflow(null);
ProgramWorkflow workflow = Context.getProgramWorkflowService().getProgram(1).getAllWorkflows().iterator().next();
csc.setConcept(Context.getConceptService().getConcept(3));
csc.setProgramWorkflowState(workflow.getState(1));
Errors errors = new BindException(csc, "csc");
new StateConversionValidator().validate(csc, errors);
Assert.assertTrue(errors.hasFieldErrors("programWorkflow"));
}
use of org.openmrs.ConceptStateConversion in project openmrs-core by openmrs.
the class StateConversionValidatorTest method validate_shouldFailValidationIfProgramWorkflowStateIsNullOrEmptyOrWhitespace.
/**
* @see StateConversionValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfProgramWorkflowStateIsNullOrEmptyOrWhitespace() {
ConceptStateConversion csc = new ConceptStateConversion();
ProgramWorkflow workflow = Context.getProgramWorkflowService().getProgram(1).getAllWorkflows().iterator().next();
csc.setConcept(Context.getConceptService().getConcept(3));
csc.setProgramWorkflow(workflow);
csc.setProgramWorkflowState(null);
Errors errors = new BindException(csc, "csc");
new StateConversionValidator().validate(csc, errors);
Assert.assertTrue(errors.hasFieldErrors("programWorkflowState"));
}
use of org.openmrs.ConceptStateConversion in project openmrs-core by openmrs.
the class ProgramWorkflowServiceTest method getConceptStateConversionByUuid_shouldFindObjectGivenValidUuid.
/**
* @see ProgramWorkflowService#getConceptStateConversionByUuid(String)
*/
@Test
public void getConceptStateConversionByUuid_shouldFindObjectGivenValidUuid() {
String uuid = "6c72b064-506d-11de-80cb-001e378eb67e";
ConceptStateConversion conceptStateConversion = Context.getProgramWorkflowService().getConceptStateConversionByUuid(uuid);
Assert.assertEquals(1, (int) conceptStateConversion.getConceptStateConversionId());
}
Aggregations