private void execCallback(ISurveyCallback callback, Exception e) { execCallback(callback, new SurveyResponse(e.toString())); }
/** * @see org.carewebframework.api.context.IManagedContext#surveySubscribers(boolean, * ISurveyCallback) */ @Override public void surveySubscribers(boolean silent, ISurveyCallback callback) { SurveyResponse response = new SurveyResponse(silent); Iterator<IContextEvent> iter = getIterable(true).iterator(); surveySubscribers(iter, response, callback); }
/** * @see org.carewebframework.api.context.IContextManager#reset */ @Override public void reset(boolean silent, ISurveyCallback callback) { pendingStack.clear(); commitStack.clear(); SurveyResponse response = new SurveyResponse(); Iterator<IManagedContext<?>> iter = managedContexts.iterator(); reset(silent, iter, response, __ -> { boolean commit = silent || !response.rejected(); commitContexts(commit, commit); execCallback(callback, response); }); }
/** * Updates managed contexts based on the marshaledContext. * * @param marshaledContext The marshaled context to process. * @param commit If true the pending contexts are committed. * @param callback Callback to report subscriber responses. */ /*package*/void setMarshaledContext(ContextItems marshaledContext, boolean commit, ISurveyCallback callback) { ISurveyResponse response = new SurveyResponse(); Iterator<IManagedContext<?>> iter = managedContexts.iterator(); setMarshaledContext(marshaledContext, iter, response, __ -> { if (commit) { commitContexts(!response.rejected(), false); } }); }
/** * Initializes one or all managed contexts to their default state. * * @param item Managed context to initialize or, if null, initializes all managed contexts. * @param callback Callback to report subscriber responses. */ public void init(IManagedContext<?> item, ISurveyCallback callback) { contextItems.clear(); if (ccowIsActive()) { contextItems.addItems(ccowContextManager.getCCOWContext()); } if (item != null) { initItem(item, callback); } else { SurveyResponse response = new SurveyResponse(); initItem(managedContexts.iterator(), response, callback); } }
/** * Initializes the managed context. * * @param item Managed context to initialize. * @param callback Callback to report subscriber responses. */ private void initItem(IManagedContext<?> item, ISurveyCallback callback) { try { localChangeBegin(item); if (hasSubject(item.getContextName())) { item.setContextItems(contextItems); } else { item.init(); } localChangeEnd(item, callback); } catch (ContextException e) { log.error("Error initializing context.", e); execCallback(callback, new SurveyResponse(e.toString())); } }