-
-
Save kombadzomba/54ba600e3fb3f8c963e01e622e73164d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public LinkedList<TerminEntity> getTerminByDateAndClientName(StaffEntity staff, Date startDate, Date endDate, String clientName) { | |
if (couchDbOrg == null) { | |
EventBus.getDefault().post(new DbNotInitializedEvent()); | |
return new LinkedList<>(); | |
} | |
synchronized (viewFactory.terminByClientNameView) { | |
TerminByClientNameView view = viewFactory.terminByClientNameView; | |
view.setDescending(true); | |
LinkedList<TerminEntity> results = (LinkedList<TerminEntity>) view.getData(); | |
return new LinkedList(results); | |
} | |
} | |
public LinkedList<StaffEntity> getStaffAll() { | |
try { | |
if (couchDbOrg == null) { | |
EventBus.getDefault().post(new DbNotInitializedEvent()); | |
return new LinkedList<>(); | |
} | |
synchronized (viewFactory.staffByIdView) { | |
StaffByIdView view = viewFactory.staffByIdView; | |
view.setStartKey(null); | |
view.setEndKey(null); | |
LinkedList<StaffEntity> results = (LinkedList<StaffEntity>) view.getData(); | |
Log.d(TAG, "Staff fetched - count = " + (results != null ? results.size() : 0)); | |
return new LinkedList(results); | |
} | |
} catch (Exception ex) { | |
LogUtil.reportToDevelopers(ex); | |
return new LinkedList<>(); | |
} | |
} | |
public ServiceEntity getServiceById(String id) { | |
try { | |
if (couchDbOrg == null) { | |
EventBus.getDefault().post(new DbNotInitializedEvent()); | |
return null; | |
} | |
if (id == null) return null; | |
synchronized (viewFactory.serviceByIdView) { | |
ServiceByIdView view = viewFactory.serviceByIdView; | |
view.setStartKey(id); | |
view.setEndKey(id); | |
LinkedList<ServiceEntity> results = (LinkedList<ServiceEntity>) view.getData(); | |
return results.isEmpty() ? null : results.get(0); | |
} | |
} catch (Exception ex) { | |
LogUtil.reportToDevelopers(ex); | |
return null; | |
} | |
} | |
public LinkedList<ServiceEntity> getServicesActiveAll() { | |
try { | |
if (couchDbOrg == null) { | |
EventBus.getDefault().post(new DbNotInitializedEvent()); | |
return null; | |
} | |
synchronized (viewFactory.serviceActiveByNameView) { | |
ServiceActiveByNameView view = viewFactory.serviceActiveByNameView; | |
view.setStartKey(null); | |
view.setEndKey(null); | |
view.setDescending(false); | |
LinkedList<ServiceEntity> results = (LinkedList<ServiceEntity>) view.getData(); | |
return new LinkedList(results); | |
} | |
} catch (Exception ex) { | |
LogUtil.reportToDevelopers(ex); | |
return new LinkedList<>(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment