/** * Sets the send time criterion to the time specified. Use this method to search on a * specific date/time; if a range is needed, use <code>withMessageTimeRange</code> instead. * * @param deliveryTimeRange the specific time on which to search * @return this <code>EmailRecordSearchCriteria</code> with its deliveryTimeRange criterion * set to the specified date/time */ public EmailRecordSearchCriteria withMessageTime(DateTime deliveryTimeRange) { this.deliveryTimeRange = new Range<>(deliveryTimeRange, deliveryTimeRange); return this; }
private String getDbPrefix() { return Tenant.current().getSuffixedId(); } }
public Set<DeliveryStatus> getDeliveryStatusFromSettings() { return MotechEnumUtils.toEnumSet(DeliveryStatus.class, deliveryStatus); } }
@Override public Object convert(Class type, Object value) { try { return new DateTime(new SimpleDateFormat(DATE_PATTERN + " " + TIME_PATTERN_12_HOURS).parse((String) value)); } catch (ParseException e) { throw new MotechException("Encountered exception while parsing mobile form", e); } } }
public CouchDbLuceneQuery withDateRange(String field, Range<DateTime> value) { if (value != null) { String minValue = value.getMin().toString(DATE_TIME_FORMAT); String maxValue = value.getMax().toString(DATE_TIME_FORMAT); if (isValid(field, minValue, maxValue)) { appendToQuery(format("%s<date>:[%s TO %s]", field, minValue, maxValue)); } } return this; }
private List<URL> getEntries(Bundle bundle) { Enumeration enumeration = bundle.findEntries("/webapp/js", "*.js", true); return cast(URL.class, enumeration); }
@Override public void removedService(ServiceReference reference, Object service) { super.removedService(reference, service); ApplicationContext applicationContext = (ApplicationContext) service; if (ApplicationContextServiceReferenceUtils.isValid(reference)) { eventAnnotationBeanPostProcessor.clearListeners(applicationContext); synchronized (getLock()) { removeFromProcessed(applicationContext); } } } }
public StubServer start() { try { server.start(); } catch (Exception e) { throw new MotechException("Stub Sever Could not be started", e); } return this; }
private String getQueuePrefix() { return Tenant.current().getSuffixedId(); }
public List<PasswordRecovery> getExpired() { Range<DateTime> range = new Range<>(new DateTime(0), DateUtil.now()); return dataService.findByExpirationDate(range); }
public void stop() { try { server.stop(); } catch (Exception e) { throw new MotechException("Stub Server could not be stopped", e); } }
private FieldValidator getValidationHandler(Annotation annotation) { Annotation validationMarker = annotation.annotationType().getAnnotation(ValidationMarker.class); if (validationMarker == null) { throw new MotechException("Field validator has not been annotated with ValidationMarker, " + annotation.annotationType().getName()); } try { Class<FieldValidator> fieldValidatorClass = (Class<FieldValidator>) validationMarker.annotationType().getMethod("handler").invoke(validationMarker); return fieldValidatorClass.newInstance(); } catch (Exception e) { throw new MotechException("Exception while instantiating validation handler, this should never happen", e); } }
@Override public Object convert(Class type, Object value) { try { Date parsedDate = new SimpleDateFormat(TIME_PATTERN_12_HOURS).parse((String) value); return Time.parseTime(new SimpleDateFormat(TIME_PATTERN_24_HOURS).format(parsedDate), ":"); } catch (ParseException e) { throw new MotechException("Encountered exception while parsing mobile form", e); } } }
@Override public void afterPropertiesSet() { if (getKey() == null || getKey().trim().isEmpty()) { throw new MotechException("Transition key is required"); } if (getNode() == null) { throw new MotechException("Transition node id is required"); } }
private void startAdmin() { Bundle adminBundle = getAdminBundle(); if (adminBundle == null) { LOGGER.warn("Admin bundle not installed"); } else if (adminBundle.getState() == Bundle.ACTIVE) { LOGGER.warn("Admin bundle already active"); } else { try { adminBundle.start(); } catch (BundleException e) { throw new MotechException("Cannot start admin bundle", e); } } }
public void setProperty(String key, String value) { String filename = findFilename(key); if (filename == null) { throw new MotechException("No file containing key " + key); } setProperty(filename, key, value); }
@Override public void afterPropertiesSet() { if (getMessage() == null || getMessage().trim().isEmpty()) { throw new MotechException("Message content is required"); } }
@Override public void afterPropertiesSet() { if (getName() == null || getName().trim().isEmpty()) { throw new MotechException("Tree name is required"); } if (getNodes() == null || getNodes().size() == 0) { throw new MotechException("Tree nodes is required"); } }
@Override public boolean matches(Object argument) { try { ObjectMapper objectMapper = new ObjectMapper(); String actual = (String) argument; JsonNode expectedTree = objectMapper.readTree(expected); JsonNode actualTree = objectMapper.readTree(actual); return expectedTree.equals(actualTree); } catch (IOException e) { throw new MotechException("Json parsing failure", e); } }
private void configurePolling(String pollingType, String pollingStartTime, String pollingInterval) { if (!ObjectUtils.equals("daily", pollingType) && !ObjectUtils.equals("interval", pollingType)) { throw new MotechException("Motech OpenMRS Atom Feed polling type can only be: interval or daily"); } parseRequiredConfigString(pollingStartTime); if ("interval".equals(pollingType)) { intervalPolling = true; parseIntervalConfigString(pollingInterval); } }