/** * Returns a {@link ProgramWorkflowState} whose Concept matches the passed concept * * @param concept the Concept to match * @return Returns a {@link ProgramWorkflowState} whose {@link Concept} matches the passed * <code>concept</code> */ public ProgramWorkflowState getState(Concept concept) { for (ProgramWorkflowState s : getStates()) { if (s.getConcept().equals(concept)) { return s; } } return null; }
/** * Returns a {@link ProgramWorkflowState} whose Concept name matches the passed name in any * {@link Locale} * * @param name the Concept name to match in any {@link Locale} * @return a {@link ProgramWorkflowState} whose {@link Concept} name matches the passed * <code>name</code> */ public ProgramWorkflowState getState(String name) { for (ProgramWorkflowState s : getStates()) { if (s.getConcept().isNamed(name)) { return s; } } return null; }
/** * Returns a {@link ProgramWorkflowState} whose {@link Concept} has any {@link ConceptName} that * matches the given <code>name</code> * * @param name the {@link ProgramWorkflowState} name, in any {@link Locale} * @return a {@link ProgramWorkflowState} which has the passed <code>name</code> in any * {@link Locale} */ public ProgramWorkflowState getStateByName(String name) { for (ProgramWorkflowState s : getStates()) { if (s.getConcept().isNamed(name)) { return s; } } return null; }
/** * Returns a Set<{@link ProgramWorkflowState}> including all ProgramWorkflowStates, sorted by * {@link ConceptName} * * @return Set<ProgramWorkflowState> - all ProgramWorkflowStates, sorted by {@link ConceptName} * @should sort names containing numbers intelligently */ public Set<ProgramWorkflowState> getSortedStates() { final Comparator<String> naturalComparator = NaturalStrings.getNaturalComparator(); Comparator<ProgramWorkflowState> stateComparator = (o1, o2) -> naturalComparator.compare(o1.getConcept().getName().getName(), o2.getConcept().getName().getName()); Set<ProgramWorkflowState> sorted = new TreeSet<>(stateComparator); if (getStates() != null) { sorted.addAll(getStates()); } return sorted; }
/** @see Object#toString() */ @Override public String toString() { return "State " + getConcept().getName() + " initial=" + getInitial() + " terminal=" + getTerminal(); }
/** * @see org.openmrs.api.ProgramWorkflowService#saveProgram(org.openmrs.Program) */ @Override public Program saveProgram(Program program) throws APIException { // Program if (program.getConcept() == null) { throw new APIException("Program.concept.required", (Object[]) null); } for (ProgramWorkflow workflow : program.getAllWorkflows()) { if (workflow.getConcept() == null) { throw new APIException("ProgramWorkflow.concept.required", (Object[]) null); } ensureProgramIsSet(workflow, program); for (ProgramWorkflowState state : workflow.getStates()) { if (state.getConcept() == null || state.getInitial() == null || state.getTerminal() == null) { throw new APIException("ProgramWorkflowState.requires", (Object[]) null); } ensureProgramWorkflowIsSet(state, workflow); } } return dao.saveProgram(program); }
names.add(s.getConcept().getName().getName());
for (ProgramWorkflowState state : sortedStates) { if (x == 1) { Assert.assertEquals("Group 2", state.getConcept().getName(Context.getLocale()).getName()); } else if (x == 2) { Assert.assertEquals("Group 10", state.getConcept().getName(Context.getLocale()).getName()); } else { Assert.fail("Wha?!");
for (ProgramWorkflow workflow : program.getAllWorkflows()) { for (ProgramWorkflowState s : workflow.getStates(false)) { if (s.getConcept().equals(concept)) { return s;
if (concept != null) { for (ProgramWorkflowState s : workflow.getStates(false)) { if (s.getConcept().equals(concept)) { return s;
@Override public String getDisplayProperty() { return getObject().getState().getConcept().getDisplayString(); }
String label = state.getConcept().getName().getName(); if (tagParams.getStateLabels() != null) { label = tagParams.getStateLabels().get(i); String label = state.getConcept().getName().getName(); states.put(label, state);
if (ps != null && ps.getState() != null && ps.getState().getConcept().getName() != null) { return ps;