You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(141) |
Sep
(184) |
Oct
(159) |
Nov
(77) |
Dec
(114) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(212) |
Feb
(302) |
Mar
(323) |
Apr
(360) |
May
(302) |
Jun
(392) |
Jul
(299) |
Aug
(858) |
Sep
(499) |
Oct
(489) |
Nov
(324) |
Dec
(438) |
2008 |
Jan
(449) |
Feb
(388) |
Mar
(811) |
Apr
(583) |
May
(949) |
Jun
(1431) |
Jul
(943) |
Aug
(527) |
Sep
(576) |
Oct
(440) |
Nov
(1046) |
Dec
(658) |
2009 |
Jan
(259) |
Feb
(192) |
Mar
(495) |
Apr
(2322) |
May
(2023) |
Jun
(1387) |
Jul
(722) |
Aug
(771) |
Sep
(167) |
Oct
(142) |
Nov
(384) |
Dec
(884) |
2010 |
Jan
(344) |
Feb
(82) |
Mar
(248) |
Apr
(341) |
May
(389) |
Jun
(289) |
Jul
(19) |
Aug
(478) |
Sep
(274) |
Oct
(431) |
Nov
(322) |
Dec
(207) |
2011 |
Jan
(125) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: John C. <jc...@us...> - 2007-02-24 21:30:50
|
Update of /cvsroot/tolven/tolvenWEB/src/org/tolven/web/security/auth In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv2962/src/org/tolven/web/security/auth Removed Files: KeyLdapCallbackHandler.java Log Message: move browse to browse project --- KeyLdapCallbackHandler.java DELETED --- |
From: John C. <jc...@us...> - 2007-02-24 20:20:34
|
Update of /cvsroot/tolven/tolven/conf In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv31483/conf Modified Files: application.xml Log Message: Add build for tolvenBrowse.war and tolvenMobile.war Index: application.xml =================================================================== RCS file: /cvsroot/tolven/tolven/conf/application.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** application.xml 8 Jan 2007 07:23:03 -0000 1.3 --- application.xml 24 Feb 2007 20:20:30 -0000 1.4 *************** *** 9,12 **** --- 9,24 ---- </module> <module> + <web> + <web-uri>tolvenBrowse.war</web-uri> + <context-root>/Browse</context-root> + </web> + </module> + <module> + <web> + <web-uri>tolvenMobile.war</web-uri> + <context-root>/Mobile</context-root> + </web> + </module> + <module> <ejb>tolvenEJB.jar</ejb> </module> |
From: John C. <jc...@us...> - 2007-02-24 20:20:06
|
Update of /cvsroot/tolven/tolven In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv30975 Modified Files: build.xml Log Message: Add build for tolvenBrowse.war and tolvenMobile.war Index: build.xml =================================================================== RCS file: /cvsroot/tolven/tolven/build.xml,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** build.xml 24 Jan 2007 04:17:17 -0000 1.73 --- build.xml 24 Feb 2007 20:19:59 -0000 1.74 *************** *** 181,184 **** --- 181,186 ---- <ant dir="${tolvenEJB.location}" antfile="${tolvenEJB.location}/build.xml" target="init" /> <ant dir="${tolvenWEB.location}" antfile="${tolvenWEB.location}/build.xml" target="init" /> + <ant dir="${tolvenMobileServer.location}" antfile="${tolvenMobileServer.location}/build.xml" target="init" /> + <ant dir="${tolvenBrowse.location}" antfile="${tolvenBrowse.location}/build.xml" target="init" /> </target> <target name="clean"> *************** *** 186,189 **** --- 188,193 ---- <ant dir="${tolvenEJB.location}" antfile="${tolvenEJB.location}/build.xml" target="clean" /> <ant dir="${tolvenWEB.location}" antfile="${tolvenWEB.location}/build.xml" target="clean" /> + <ant dir="${tolvenMobileServer.location}" antfile="${tolvenMobileServer.location}/build.xml" target="clean" /> + <ant dir="${tolvenBrowse.location}" antfile="${tolvenBrowse.location}/build.xml" target="clean" /> </target> *************** *** 204,207 **** --- 208,217 ---- <include name="tolvenWEB.war"/> </zipfileset> + <zipfileset dir="${tolvenMobileServer.location}/build"> + <include name="tolvenMobile.war"/> + </zipfileset> + <zipfileset dir="${tolvenBrowse.location}/build"> + <include name="tolvenBrowse.war"/> + </zipfileset> <zipfileset dir="conf" prefix="META-INF"/> </jar> *************** *** 219,222 **** --- 229,234 ---- <ant dir="${tolvenEJB.location}" antfile="${tolvenEJB.location}/build.xml" target="packaging" /> <ant dir="${tolvenWEB.location}" antfile="${tolvenWEB.location}/build.xml" target="packaging" /> + <ant dir="${tolvenMobileServer.location}" antfile="${tolvenMobileServer.location}/build.xml" target="packaging" /> + <ant dir="${tolvenBrowse.location}" antfile="${tolvenBrowse.location}/build.xml" target="packaging" /> </target> <target name="undeploy"> |
From: John C. <jc...@us...> - 2007-02-24 20:18:31
|
Update of /cvsroot/tolven/tolvenMobileClient/src/org/tolven/mobile/client/view/list In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv30300/src/org/tolven/mobile/client/view/list Modified Files: ObservationsPage.java ListPage.java Log Message: Only allow drilldown on items we have a vewer for Index: ListPage.java =================================================================== RCS file: /cvsroot/tolven/tolvenMobileClient/src/org/tolven/mobile/client/view/list/ListPage.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ListPage.java 24 Feb 2007 09:03:48 -0000 1.1 --- ListPage.java 24 Feb 2007 20:18:29 -0000 1.2 *************** *** 72,75 **** --- 72,81 ---- /** + * Override this if this allows drilldown. + */ + protected boolean canDrilldown(){ + return false; + } + /** * Our list has arrived so update the display * @param request *************** *** 100,105 **** item.setLayout( Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_VSHRINK); // Doesn't help item.setPreferredSize(form.getWidth(), -1); ! item.addCommand(cmdDrilldown); ! item.setDefaultCommand(cmdDrilldown); item.setItemCommandListener(this); form.insert(insertLocation, item); --- 106,113 ---- item.setLayout( Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_VSHRINK); // Doesn't help item.setPreferredSize(form.getWidth(), -1); ! if (canDrilldown()) { ! item.addCommand(cmdDrilldown); ! item.setDefaultCommand(cmdDrilldown); ! } item.setItemCommandListener(this); form.insert(insertLocation, item); Index: ObservationsPage.java =================================================================== RCS file: /cvsroot/tolven/tolvenMobileClient/src/org/tolven/mobile/client/view/list/ObservationsPage.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ObservationsPage.java 24 Feb 2007 09:03:48 -0000 1.1 --- ObservationsPage.java 24 Feb 2007 20:18:29 -0000 1.2 *************** *** 15,18 **** --- 15,24 ---- this.patient = patient; } + /** + * Override this if this allows drilldown. + */ + protected boolean canDrilldown(){ + return true; + } /** |
From: John C. <jc...@us...> - 2007-02-24 20:18:31
|
Update of /cvsroot/tolven/tolvenMobileClient/lib In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv30300/lib Added Files: proguard.jar jadmaker.jar Log Message: Only allow drilldown on items we have a vewer for --- NEW FILE: jadmaker.jar --- (This appears to be a binary file; contents omitted.) --- NEW FILE: proguard.jar --- (This appears to be a binary file; contents omitted.) |
From: John C. <jc...@us...> - 2007-02-24 20:18:24
|
Update of /cvsroot/tolven/tolvenMobileClient/lib In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv30280/lib Log Message: Directory /cvsroot/tolven/tolvenMobileClient/lib added to the repository |
From: John C. <jc...@us...> - 2007-02-24 20:17:20
|
Update of /cvsroot/tolven/tolvenWEB/web/WEB-INF In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv29724/web/WEB-INF Modified Files: web.xml Log Message: Remove browse servlet which is now in its own WAR. Index: web.xml =================================================================== RCS file: /cvsroot/tolven/tolvenWEB/web/WEB-INF/web.xml,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** web.xml 21 Feb 2007 12:19:11 -0000 1.20 --- web.xml 24 Feb 2007 20:17:19 -0000 1.21 *************** *** 120,123 **** --- 120,127 ---- <filter-mapping> <filter-name>GeneralSecurityFilter</filter-name> + <url-pattern>/wizard/*</url-pattern> + </filter-mapping> + <filter-mapping> + <filter-name>GeneralSecurityFilter</filter-name> <url-pattern>/five/*</url-pattern> </filter-mapping> *************** *** 192,221 **** <url-pattern>*.graph</url-pattern> </servlet-mapping> ! <servlet> ! <servlet-name>Browse Index Servlet</servlet-name> ! <servlet-class>org.tolven.index.Browse</servlet-class> ! <load-on-startup>8</load-on-startup> ! </servlet> ! <servlet-mapping> ! <servlet-name>Browse Index Servlet</servlet-name> ! <url-pattern>*.browse</url-pattern> ! </servlet-mapping> ! <filter> ! <filter-name>BrowseTransactionFilter</filter-name> ! <filter-class>org.tolven.index.BrowseTransactionFilter</filter-class> ! </filter> ! <filter-mapping> ! <filter-name>BrowseTransactionFilter</filter-name> ! <servlet-name>Browse Index Servlet</servlet-name> ! </filter-mapping> ! <filter> ! <filter-name>BrowseSecurityFilter</filter-name> ! <filter-class>org.tolven.index.BrowseSecurityFilter</filter-class> ! </filter> ! <filter-mapping> ! <filter-name>BrowseSecurityFilter</filter-name> ! <servlet-name>Browse Index Servlet</servlet-name> ! </filter-mapping> ! <session-config><session-timeout> 300 --- 196,200 ---- <url-pattern>*.graph</url-pattern> </servlet-mapping> ! <session-config><session-timeout> 300 *************** *** 284,302 **** </user-data-constraint> </security-constraint> - <security-constraint> - <web-resource-collection> - <web-resource-name>Protected Area</web-resource-name> - <!-- Define the context-relative URL(s) to be protected --> - <!-- All resources protected unless otherwise listed in previous security-constraints --> - <url-pattern>*.browse</url-pattern> - </web-resource-collection> - <auth-constraint> - <!-- Anyone with one of the listed roles may access this area --> - <role-name>*</role-name> - </auth-constraint> - <user-data-constraint> - <transport-guarantee>CONFIDENTIAL</transport-guarantee> - </user-data-constraint> - </security-constraint> <login-config> <auth-method>FORM</auth-method> --- 263,266 ---- |
From: John C. <jc...@us...> - 2007-02-24 20:15:53
|
Update of /cvsroot/tolven/tolvenMobileServer In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv28669 Added Files: build.xml Log Message: Mobile server --- NEW FILE: build.xml --- <?xml version="1.0" encoding="UTF-8"?> <project basedir="." default="packaging" name="tolvenMobileServer"> <property file="../tolven/resources/ant-build.properties"/> <path id="project.classpath"> <fileset dir="${tolvenEJB.location}/build"> <include name="*.jar"/> </fileset> <fileset dir="${commons-fileupload.location}"> <include name="*.jar"/> </fileset> <fileset dir="${jboss.location}"> <include name="client/*.jar"/> </fileset> <fileset dir="${jfreechart.location}"> <include name="*.jar"/> </fileset> <pathelement location="${junit.location}/junit.jar"/> </path> <target name="init"> <mkdir dir="${tolvenMobileServer.location}/build/bin"/> <mkdir dir="${tolvenMobileServer.location}/build/doc"/> </target> <target name="clean"> <delete dir="${tolvenMobileServer.location}/build"/> </target> <target depends="init" name="compile"> <echo message="${ant.project.name}: ${ant.file}"/> <javac destdir="${tolvenMobileServer.location}/build/bin" debug="true" > <src path="${tolvenMobileServer.location}/src"/> <classpath refid="project.classpath"/> </javac> </target> <target name="packaging" depends="compile" description="tolvenMobile.war"> <jar destfile="${tolvenMobileServer.location}/build/tolvenMobile.war"> <zipfileset dir="${commons-fileupload.location}" prefix="WEB-INF/lib"> <include name="*.jar"/> </zipfileset> <zipfileset dir="${jfreechart.location}" prefix="WEB-INF/lib"> <include name="*.jar"/> </zipfileset> <zipfileset dir="${commons-io.location}" prefix="WEB-INF/lib"> <include name="*.jar"/> </zipfileset> <zipfileset dir="${tolvenMobileServer.location}/build/bin" prefix="WEB-INF/classes" includes="**/*.class"/> <zipfileset dir="${tolvenMobileServer.location}/web"/> </jar> </target> <target name="javadoc" description="Generate Javadoc"> <javadoc access="public" author="true" destdir="${tolvenMobileServer.location}/build/doc" doctitle="Tolven Mobile Server" packagenames="*" classpathref="project.classpath" source="1.5" sourcepath="${tolvenMobileServer.location}/src" splitindex="true" use="true" version="true"/> </target> </project> |
From: John C. <jc...@us...> - 2007-02-24 20:15:53
|
Update of /cvsroot/tolven/tolvenMobileServer/src/org/tolven/web/security In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv28669/src/org/tolven/web/security Added Files: GeneralSecurityFilter.java VestibuleSecurityFilter.java SecurityFilter.java Log Message: Mobile server --- NEW FILE: VestibuleSecurityFilter.java --- /* * Copyright (C) 2006 Tolven Inc * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * Contact: in...@to... */ package org.tolven.web.security; import java.io.IOException; import java.security.GeneralSecurityException; import java.security.Principal; import java.security.acl.Group; import java.util.Date; import java.util.Set; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.security.auth.Subject; import javax.security.jacc.PolicyContext; import javax.security.jacc.PolicyContextException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import javax.xml.bind.JAXBException; import org.tolven.core.AccountDAOLocal; import org.tolven.core.ActivationLocal; import org.tolven.core.InvitationLocal; import org.tolven.core.bean.InvitationException; import org.tolven.core.entity.AccountUser; import org.tolven.core.entity.Status; import org.tolven.core.entity.TolvenUser; import org.tolven.security.LoginLocal; import org.tolven.security.key.PrivateKeyRing; import org.tolven.security.key.UserPrivateKey; import org.tolven.security.key.UserPublicKey; /** * The original post-login code, which was located in the class TopAction (author John Churin), has been copied to this * location in order to use filters to provide greater flexibility in controlling access to accounts after login * * @author Joseph Isaac */ public class VestibuleSecurityFilter extends SecurityFilter implements Filter { private static String INVITATION_ID = "invitationId"; private static String TOLVEN_NOW = "tolvenNow"; public static String ACCOUNT_ID = "accountId"; public static String ACCOUNTUSER_ID = "accountUserId"; public static String TOLVENUSER_ID = "TolvenUserId"; public static String VESTIBULE_PASS = "vestibulePass"; private ActivationLocal activation; private LoginLocal loginBean; private InvitationLocal invitationBean; private AccountDAOLocal accountBean; public void init(FilterConfig config) throws ServletException { try { InitialContext ctx = new InitialContext(); activation = (ActivationLocal) ctx.lookup("tolven/ActivationBean/local"); loginBean = (LoginLocal) ctx.lookup("tolven/LoginBean/local"); invitationBean = (InvitationLocal) ctx.lookup("tolven/InvitationBean/local"); accountBean = (AccountDAOLocal) ctx.lookup("tolven/AccountDAOBean/local"); //TODO: This needs to be done once per deployment and thus may need to be moved } catch (NamingException e) { throw new ServletException(e); } } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException { try { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; //System.out.println(getClass() + " :REQUEST=" + request.getRequestURL()); if (!request.isRequestedSessionIdValid()) { logout("INVALID SESSION", request, response); return; } Subject subject = (Subject) PolicyContext.getContext("javax.security.auth.Subject.container"); if (subject == null) { logout("NO SUBJECT", request, response); return; } Principal principal = null; Object obj = null; for (java.util.Iterator iter = subject.getPrincipals().iterator(); iter.hasNext();) { obj = iter.next(); if (obj instanceof Principal && !(obj instanceof Group)) { principal = (Principal) obj; break; } } if (principal == null) { logout("NO PRINCIPAL", request, response); return; } String principalName = principal.getName(); Set<PrivateKeyRing> privateCredentials = subject.getPrivateCredentials(PrivateKeyRing.class); if (privateCredentials.isEmpty()) { logout("NO PRIVATE KEY RING", request, response); return; } PrivateKeyRing privateKeyRing = (PrivateKeyRing) privateCredentials.iterator().next(); // PHASE ONE: User Authentication HttpSession session = request.getSession(); TolvenUser user = null; obj = session.getAttribute(TOLVENUSER_ID); boolean justLoggedIn = obj == null; if (justLoggedIn) { user = activation.loginUser(principalName, (Date) request.getAttribute(TOLVEN_NOW)); // top.setUser(user); session.setAttribute(VESTIBULE_PASS, "true"); } else { user = activation.findTolvenUser(((Long) obj).longValue()); } if ((user == null || Status.NEW_LOGIN.value().equalsIgnoreCase(user.getStatus())) && request.getParameter(INVITATION_ID) != null) { // Since we have no user yet, we'll try executing an activation invitation (if it works) long invitationId = Long.parseLong(request.getParameter(INVITATION_ID)); Date now = (Date) request.getAttribute(TOLVEN_NOW); if (!loginBean.activate(principalName, invitationId, now)) { logout("COULD NOT ACTIVATE INVITATION", request, response); return; } // try TolvenUser again user = activation.loginUser(principalName, now); if (user == null) { logout("COULD NOT COMPLETE ACTIVATION", request, response); return; } else { // top.setUser(user); } invitationBean.executeInvitation(invitationId, now); } if (user == null) { logout("USER IS NULL", request, response); return; } session.setAttribute(TOLVENUSER_ID, user.getId()); if (!user.hasUserPrivateKey()) { addKeysToUser(user, subject); } //If the user has a pass, they don't need to supply a password again if ("true".equals(session.getAttribute(VESTIBULE_PASS)) || request.getRequestURL().indexOf("password.jsf") != -1) { // Let the user have the request } else { ((HttpServletResponse) servletResponse).sendRedirect("password.jsf"); return; } // PHASE TWO: Account Authentication String accountUserIdString = request.getParameter(ACCOUNTUSER_ID); if (accountUserIdString != null && accountUserIdString.trim().length() > 0) { // User has selected an account home page, identify the page and let them through AccountUser accountUser = activation.findAccountUser(Long.parseLong(accountUserIdString.trim())); if (accountUser == null) { logout("ACCOUNTUSER IS NULL", request, response); return; } // SAFETY CHECK HERE - Don't trust the accountUserId alone, it must match user. if (accountUser.getUser().getId() != user.getId()) { logout("ACCOUNTUSER DOES NOT BELONG TO USER", request, response); return; } // Give TolvenUser the AccountPrivateKey for the selected account if (accountUser.getAccountPrivateKey() == null) { //For backward compatibility with accounts which didn't originally have keys, we add them here accountBean.setupAccountKeys(accountUser.getAccount(), accountUser, null, user); } privateKeyRing.setAccountPrivateKey(accountUser.getAccountPrivateKey()); session.removeAttribute(VESTIBULE_PASS); session.setAttribute(ACCOUNT_ID, accountUser.getAccount().getId()); session.setAttribute(ACCOUNTUSER_ID, accountUser.getId()); ((HttpServletResponse) servletResponse).sendRedirect("../private/" + accountUser.getAccount().getAccountType().getHomePage()); return; } // If user has not been sent on there way by here, remove all account related information...they are in the vestibule privateKeyRing.setAccountPrivateKey(null); // top.setAccountUser(null); session.removeAttribute(ACCOUNT_ID); session.removeAttribute(ACCOUNTUSER_ID); } catch (PolicyContextException ex) { ex.printStackTrace(); throw new ServletException(ex); } catch (NamingException ex) { ex.printStackTrace(); throw new ServletException(ex); } catch (InvitationException ex) { ex.printStackTrace(); throw new ServletException(ex); } catch (JAXBException ex) { ex.printStackTrace(); throw new ServletException(ex); } catch (GeneralSecurityException ex) { ex.printStackTrace(); throw new ServletException(ex); } chain.doFilter(servletRequest, servletResponse); } /** * Add Keys from the Subject to what should be a new TolvenUser who is logging in * @throws PolicyContextException * @throws GeneralSecurityException */ private void addKeysToUser(TolvenUser aTolvenUser, Subject subject) throws GeneralSecurityException { Set<PrivateKeyRing> privateCredentials = subject.getPrivateCredentials(PrivateKeyRing.class); if (privateCredentials.isEmpty()) throw new GeneralSecurityException(getClass() + " :No PrivateKeyRing found for " + aTolvenUser.getLdapUID()); UserPrivateKey userPrivateKey = privateCredentials.iterator().next().getUserPrivateKey(); if (userPrivateKey == null) throw new GeneralSecurityException(getClass() + " :No UserPrivateKey found for " + aTolvenUser.getLdapUID()); Set<UserPublicKey> publicCredentials = subject.getPublicCredentials(UserPublicKey.class); if (publicCredentials.isEmpty()) throw new GeneralSecurityException(getClass() + " :No UserPublicKey found for " + aTolvenUser.getLdapUID()); if (!aTolvenUser.hasUserPrivateKey()) { aTolvenUser.setUserPrivateKey(userPrivateKey); aTolvenUser.setUserPublicKey(publicCredentials.iterator().next()); } } public void destroy() { } } --- NEW FILE: GeneralSecurityFilter.java --- /* * Copyright (C) 2006 Tolven Inc * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * Contact: in...@to... */ package org.tolven.web.security; import java.io.IOException; import java.security.Principal; import java.security.acl.Group; import java.util.Set; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.security.auth.Subject; import javax.security.jacc.PolicyContext; import javax.security.jacc.PolicyContextException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.tolven.core.ActivationLocal; import org.tolven.core.entity.AccountUser; import org.tolven.security.key.PrivateKeyRing; /** * This class guards the /private area, checking that users are logged into both Tolven and restricted to an Account * * @author Joseph Isaac */ public class GeneralSecurityFilter extends SecurityFilter implements Filter { private ActivationLocal activation; public void init(FilterConfig config) throws ServletException { try { InitialContext ctx = new InitialContext(); activation = (ActivationLocal) ctx.lookup("tolven/ActivationBean/local"); } catch (NamingException e) { throw new ServletException(e); } } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; try { //System.out.println(getClass() + " :REQUEST=" + request.getRequestURL()); if (!request.isRequestedSessionIdValid()) { logout("INVALID SESSION", request, response); return; } Subject subject = (Subject) PolicyContext.getContext("javax.security.auth.Subject.container"); if (subject == null) { logout("NO SUBJECT", request, response); return; } Principal principal = null; Object obj = null; for (java.util.Iterator iter = subject.getPrincipals().iterator(); iter.hasNext();) { obj = iter.next(); if (obj instanceof Principal && !(obj instanceof Group)) { principal = (Principal) obj; break; } } if (principal == null) { logout("NO PRINCIPAL", request, response); return; } Set<PrivateKeyRing> privateCredentials = subject.getPrivateCredentials(PrivateKeyRing.class); if (privateCredentials.isEmpty()) { logout("NO PRIVATE KEY RING", request, response); return; } PrivateKeyRing privateKeyRing = (PrivateKeyRing) privateCredentials.iterator().next(); if (privateKeyRing.getAccountPrivateKey() == null) { response.sendRedirect("../vestibule/selectAccount.jsf?" + request.getQueryString()); return; } if (request.getRequestURL().indexOf("dispatch.jsf") != -1) { HttpSession session = request.getSession(); Object accountUserIdObj = session.getAttribute(VestibuleSecurityFilter.ACCOUNTUSER_ID); if (accountUserIdObj == null) { response.sendRedirect("../vestibule/selectAccount.jsf"); return; } AccountUser accountUser = activation.findAccountUser(((Long) accountUserIdObj).longValue()); if (accountUser == null) { response.sendRedirect("../vestibule/selectAccount.jsf"); return; } // Make absolutely certain the user owns this account if(!principal.getName().equals(accountUser.getUser().getLdapUID())) { logout(principal.getName() + " DOES NOT MATCH ACCOUNTUSER", request, response); } ((HttpServletResponse) servletResponse).sendRedirect("../private/" + accountUser.getAccount().getAccountType().getHomePage()); return; } HttpSession session = request.getSession(); // If we don't have an accountUserId, we have no business being here Long accountUserId = (Long) session.getAttribute(VestibuleSecurityFilter.ACCOUNTUSER_ID); // Set accountUser in request for the duration of this request request.setAttribute("accountUser", activation.findAccountUser( accountUserId )); chain.doFilter(servletRequest, servletResponse); } catch (PolicyContextException ex) { ex.printStackTrace(); throw new ServletException(ex); } } public void destroy() { } } --- NEW FILE: SecurityFilter.java --- /* * Copyright (C) 2006 Tolven Inc * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * Contact: in...@to... */ package org.tolven.web.security; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * An abstract class to handle common security filtering operations * * @author Joseph Isaac */ public abstract class SecurityFilter implements Filter { protected static String TOP = "top"; public void logout(String reason, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { System.out.println(getClass() + ":INVALIDATE SESSION: " + reason + " : LOGOUT"); request.getSession().invalidate(); response.sendRedirect("../vestibule/loggedOut.jsf"); } } |
From: John C. <jc...@us...> - 2007-02-24 20:15:53
|
Update of /cvsroot/tolven/tolvenMobileServer/web In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv28669/web Added Files: tolven.jar tolven.jad Log Message: Mobile server --- NEW FILE: tolven.jad --- MIDlet-1: Personal Health Record, /img/ePHR.png, org.tolven.mobile.client.TolvenMidlet MIDlet-Description: Tolven Applications MIDlet-Icon: /img/ePHR.png MIDlet-Jar-Size: 117877 MIDlet-Jar-URL: tolven.jar MIDlet-Name: Tolven MIDlet-Permissions: javax.microedition.io.Connector.http,javax.microedition.io.Connector.https MIDlet-Vendor: Tolven Inc MIDlet-Version: 1.4.0 MicroEdition-Configuration: CLDC-1.1 MicroEdition-Profile: MIDP-2.1 --- NEW FILE: tolven.jar --- (This appears to be a binary file; contents omitted.) |
From: John C. <jc...@us...> - 2007-02-24 20:15:53
|
Update of /cvsroot/tolven/tolvenMobileServer/src/org/tolven/web/security/auth In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv28669/src/org/tolven/web/security/auth Added Files: KeyLdapCallbackHandler.java Log Message: Mobile server --- NEW FILE: KeyLdapCallbackHandler.java --- package org.tolven.web.security.auth; import java.io.IOException; import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.NameCallback; import javax.security.auth.callback.PasswordCallback; import javax.security.auth.callback.UnsupportedCallbackException; /** * This class, in conjuction with the tolvenLDAP security domain to provides a way to verify a user's identity. * * @author Joseph Isaac * */ public class KeyLdapCallbackHandler implements CallbackHandler { private String username; private char[] password; public KeyLdapCallbackHandler(String username, char[] password) { this.username = username; this.password = password; } public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof NameCallback) { NameCallback nc = (NameCallback) callbacks[i]; nc.setName(username); } else if (callbacks[i] instanceof PasswordCallback) { PasswordCallback pc = (PasswordCallback) callbacks[i]; pc.setPassword(password); } else { throw new UnsupportedCallbackException(callbacks[i], "Unsupported Callback"); } } } } |
From: John C. <jc...@us...> - 2007-02-24 20:15:47
|
Update of /cvsroot/tolven/tolvenMobileServer/src/org/tolven/web In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv28635/src/org/tolven/web Log Message: Directory /cvsroot/tolven/tolvenMobileServer/src/org/tolven/web added to the repository |
From: John C. <jc...@us...> - 2007-02-24 20:15:47
|
Update of /cvsroot/tolven/tolvenMobileServer/src/org/tolven/web/security/auth In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv28635/src/org/tolven/web/security/auth Log Message: Directory /cvsroot/tolven/tolvenMobileServer/src/org/tolven/web/security/auth added to the repository |
From: John C. <jc...@us...> - 2007-02-24 20:15:47
|
Update of /cvsroot/tolven/tolvenMobileServer/src/org/tolven/web/security In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv28635/src/org/tolven/web/security Log Message: Directory /cvsroot/tolven/tolvenMobileServer/src/org/tolven/web/security added to the repository |
From: John C. <jc...@us...> - 2007-02-24 09:49:44
|
Update of /cvsroot/tolven/tolven/template In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv15904/template Modified Files: ant-build.template Log Message: Add location of new tolven components included in build Index: ant-build.template =================================================================== RCS file: /cvsroot/tolven/tolven/template/ant-build.template,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** ant-build.template 16 Jan 2007 06:07:38 -0000 1.50 --- ant-build.template 24 Feb 2007 09:49:42 -0000 1.51 *************** *** 76,79 **** --- 76,82 ---- tolvenEJB.location=${tolven.home}/tolvenEJB tolvenWEB.location=${tolven.home}/tolvenWEB + tolvenBrowse.location=${tolven.home}/tolvenBrowse + tolvenMobileServer.location=${tolven.home}/tolvenMobileServer + tolvenMobileClient.location=${tolven.home}/tolvenMobileClient jboss-rules.location=${tolven.location}/lib/jboss-rules |
From: John C. <jc...@us...> - 2007-02-24 09:07:09
|
Update of /cvsroot/tolven/tolvenMobileClient/res/img In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv30809/res/img Added Files: ePHRHeader.png ePHR.png Log Message: Tolven Mobile Client --- NEW FILE: ePHR.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: ePHRHeader.png --- (This appears to be a binary file; contents omitted.) |
From: John C. <jc...@us...> - 2007-02-24 09:07:06
|
Update of /cvsroot/tolven/tolvenMobileClient/res/img In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv30709/res/img Log Message: Directory /cvsroot/tolven/tolvenMobileClient/res/img added to the repository |
From: John C. <jc...@us...> - 2007-02-24 09:07:06
|
Update of /cvsroot/tolven/tolvenMobileClient/res In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv30709/res Log Message: Directory /cvsroot/tolven/tolvenMobileClient/res added to the repository |
From: John C. <jc...@us...> - 2007-02-24 09:03:51
|
Update of /cvsroot/tolven/tolvenMobileClient/src/org/tolven/mobile/client/control In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv29080/src/org/tolven/mobile/client/control Added Files: PatientController.java Application.java EPHRApplication.java CommandProcessor.java AllPatientController.java Controller.java Log Message: Tolven Mobile Client --- NEW FILE: Application.java --- package org.tolven.mobile.client.control; import java.util.Vector; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import org.tolven.mobile.client.comm.Session; /** * Overall application, except the login page * @author John Churin */ public abstract class Application extends CommandProcessor { private CommandListener outerCommandListener; private Vector controllers; private int currentController = -1; private Session session; public Application(Session session, CommandListener outerCommandListener ) { super(null); this.session = session; this.outerCommandListener = outerCommandListener; } /** * If our subclass needs to get some data, then this is the time to do it. */ protected abstract void initData(); public void init( ) { initData(); } /** * Figure out which page to display and display it * @param display */ public abstract void show(Display display ); public boolean doAction(Command command, Displayable displayable) { if (outerCommandListener!=null) { outerCommandListener.commandAction(command, displayable); return true; } return false; } public abstract Vector getData( ); /** * We're called back from one controller typically to select another controller * @param item */ public void show( Display display, int newCurrent ) { setCurrentController(newCurrent); Controller controller = (Controller) controllers.elementAt(getCurrentController()); // System.out.println( "Application: Showing..."); controller.show( display ); // System.out.println( "Application: Shown"); } public Vector getControllers() { if (controllers==null) controllers = new Vector(); return controllers; } public void addController(Controller controller) { getControllers().addElement(controller); } public int getCurrentController() { return currentController; } public void setCurrentController(int currentController) { this.currentController = currentController; } public abstract void buildCommands( Form form ); public Session getSession() { return session; } public void setSession(Session session) { this.session = session; } } --- NEW FILE: Controller.java --- package org.tolven.mobile.client.control; import java.util.Vector; import javax.microedition.lcdui.ChoiceGroup; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.Item; import javax.microedition.lcdui.ItemStateListener; import org.tolven.mobile.client.comm.Session; import org.tolven.mobile.client.data.Data; import org.tolven.mobile.client.view.TolvenPage; public abstract class Controller extends CommandProcessor implements ItemStateListener { private Application application; private Vector tolvenPages; private int currentPage = 0; private Display display; private int lastPage = 0; /** * Add a page to the list of pages we maintain. * @param tolvenPage */ public void addPage(TolvenPage tolvenPage ) { if (tolvenPages==null) tolvenPages = new Vector(); tolvenPages.addElement(tolvenPage); } public void refreshPage( String formName ) { for (int x = 0; x < tolvenPages.size(); x++) { TolvenPage page = (TolvenPage) tolvenPages.elementAt(x); if (page.getFormName().equals(formName)) { page.refresh(); return; } } } /** * Make the specified displayable current */ public void display( Displayable displayable ) { display.setCurrent(displayable); } public Application getApplication() { return application; } public Session getSession() { return getApplication().getSession(); } public Vector getTolvenPages() { return tolvenPages; } public Controller(Application application, CommandProcessor outerCommandProcessor) { super(outerCommandProcessor); this.application = application; } /** * We can usually pass a getData request on to the application * @return */ public Vector getData( ) { return application.getData(); } public abstract Data getDataItem(); /** * The page asks us to prepare the data (usually patients) popup list on every page * @param form */ public ChoiceGroup buildData( Form form ) { Vector data = getData( ); ChoiceGroup dataChoices = new ChoiceGroup( "", ChoiceGroup.POPUP ); for (int x = 0; x < data.size(); x++) { Data datum = (Data) data.elementAt(x); dataChoices.append( datum.getShortName(), null ); if (datum==getDataItem()) dataChoices.setSelectedIndex(x, true); } form.append( dataChoices ); form.setItemStateListener(this); return dataChoices; } /** * The page asks us to decorate the page with commands * @param form */ public void buildCommands( Form form ) { for (int x = 0; x < tolvenPages.size(); x++) { TolvenPage page = (TolvenPage) tolvenPages.elementAt(x); form.addCommand( new Command( page.getFormName(), Command.ITEM, 5 )); } application.buildCommands(form); form.setCommandListener(this); } /** * Show the current page selected for this controller * @param display */ public void show( Display display ) { if (display==null) throw new IllegalArgumentException("[Controller::show] Display cannot be null" ); if (tolvenPages==null) throw new IllegalStateException("[Controller::show] no TolvenPages defined in controller" ); if (currentPage >= tolvenPages.size()) throw new IllegalStateException("[Controller::show] Current page invalid" ); this.display = display; TolvenPage page = (TolvenPage) tolvenPages.elementAt(currentPage); // System.out.println( "controller: Showing..."); page.show(display); // System.out.println( "controller: Shown"); } // If the command is for a page we control, make that page visible. public boolean doAction(Command command, Displayable displayable) { if (command.getCommandType()==Command.BACK) { currentPage = lastPage; show(getDisplay()); return true; } String label = command.getLabel(); for (int x = 0; x < tolvenPages.size(); x++) { TolvenPage tolvenPage = (TolvenPage) tolvenPages.elementAt(x); if (label.equals(tolvenPage.getFormName())) { if (x!=currentPage) { lastPage = currentPage; currentPage = x; } System.out.println( label ); show(getDisplay()); return true; } } return false; } public Display getDisplay() { return display; } public void itemStateChanged(Item item) { System.out.println( item.getLabel() ); ChoiceGroup pageChoices = (ChoiceGroup) item; System.out.println( "Selected: " + pageChoices.getSelectedIndex()); application.show(display, pageChoices.getSelectedIndex()); } } --- NEW FILE: AllPatientController.java --- package org.tolven.mobile.client.control; import org.tolven.mobile.client.data.AllPatientData; import org.tolven.mobile.client.data.Data; import org.tolven.mobile.client.view.list.AllPatientAppointments; import org.tolven.mobile.client.view.list.AllPatientReminders; public class AllPatientController extends Controller { AllPatientData allPatientData; public AllPatientController(AllPatientData allPatientData, Application application, CommandProcessor outerCommandProcessor) { super(application, outerCommandProcessor); this.allPatientData = allPatientData; addPage( new AllPatientAppointments(allPatientData, "All Appointments", this)); addPage( new AllPatientReminders(allPatientData, "All Reminders", this)); } public Data getDataItem() { return allPatientData; } } --- NEW FILE: PatientController.java --- package org.tolven.mobile.client.control; import java.util.Vector; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import org.tolven.mobile.client.data.Data; import org.tolven.mobile.client.data.Patient; import org.tolven.mobile.client.view.PatientEntryMenu; import org.tolven.mobile.client.view.list.AllergiesPage; import org.tolven.mobile.client.view.list.AppointmentsPage; import org.tolven.mobile.client.view.list.DiagnosisPage; import org.tolven.mobile.client.view.list.MedicationsPage; import org.tolven.mobile.client.view.list.ObservationsPage; import org.tolven.mobile.client.view.list.ProblemsPage; import org.tolven.mobile.client.view.list.ProceduresPage; import org.tolven.mobile.client.view.list.RemindersPage; import org.tolven.mobile.client.view.list.ResultsPage; /** * A Controller for one patient. * @author John Churin */ public class PatientController extends Controller { Patient patient; Vector pages; public PatientController(Patient patient, Application application, CommandProcessor outerCommandProcessor) { super(application, outerCommandProcessor); this.patient = patient; addPage(new AllergiesPage(patient, this)); addPage(new AppointmentsPage(patient, this)); addPage(new DiagnosisPage(patient, this)); addPage(new MedicationsPage(patient, this)); addPage(new ObservationsPage(patient, this)); addPage(new ProblemsPage(patient, this)); addPage(new ProceduresPage(patient, this)); addPage(new RemindersPage(patient, this)); addPage(new ResultsPage(patient, this)); } public Data getDataItem() { return patient; } /** * The page asks us to decorate the page with commands * @param form */ public void buildCommands( Form form ) { // System.out.println( "PatientController: Build Commands #1..."); // The bulk is done by the base class super.buildCommands(form); // System.out.println( "PatientController: Build Commands #2..."); form.addCommand(new Command("New", Command.ITEM, 1)); // System.out.println( "PatientController: Build Commands #3..."); } // If the command is for a page we control, make that page visible. public boolean doAction(Command command, Displayable displayable) { if ("New".equals(command.getLabel())) { new PatientEntryMenu( this, getDisplay()); return true; } return super.doAction(command, displayable); } public Patient getPatient() { return patient; } } --- NEW FILE: CommandProcessor.java --- package org.tolven.mobile.client.control; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Displayable; public abstract class CommandProcessor implements CommandListener { private CommandProcessor outerCommandProcessor; public CommandProcessor( CommandProcessor outerCommandProcessor) { this.outerCommandProcessor = outerCommandProcessor; } public abstract boolean doAction(Command command, Displayable displayable); // Route commands to this item and if unsatisfied, then route to the next outer processor public void commandAction(Command command, Displayable displayable) { if (doAction( command, displayable)) return; System.out.println( "Command " + command.getLabel() + " not found in " + this.getClass().getName() + " passing to " + outerCommandProcessor.getClass().getName()); outerCommandProcessor.commandAction(command, displayable); } } --- NEW FILE: EPHRApplication.java --- package org.tolven.mobile.client.control; import java.util.Vector; import javax.microedition.lcdui.Alert; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Form; import org.tolven.mobile.client.comm.MenuDataRequest; import org.tolven.mobile.client.comm.ServerRequest; import org.tolven.mobile.client.comm.ServerRequestListener; import org.tolven.mobile.client.comm.Session; import org.tolven.mobile.client.data.AllPatientData; import org.tolven.mobile.client.data.Patient; public class EPHRApplication extends Application implements ServerRequestListener{ private Vector patients; private long days = 1000*60*60*24; private long years = days*365; private Display display; // private ServerProgress progress; // private int progressItemIndex; public EPHRApplication(Session session, CommandListener outerCommandListener) { super(session, outerCommandListener); } /** * Our patient list has arrived so update the display * @param request */ public void serverRequestAction (ServerRequest request) { // progress.setDone(); // progress = null; // form.delete(progressItemIndex); if (!(request instanceof MenuDataRequest) ) return; patients = new Vector(); AllPatientData allPatientData = new AllPatientData( ); patients.addElement(allPatientData); Controller controller = new AllPatientController( allPatientData, this, this ); addController(controller); MenuDataRequest mdr = (MenuDataRequest)request; String response = mdr.getResponse(); int cur = 0; while ( true ) { if (cur >= response.length()) break; int eol = response.indexOf('\n', cur); String line = response.substring(cur, eol); cur = eol+1; Patient patient = new Patient( line ); patients.addElement(patient); controller = new PatientController( patient, this, this ); addController(controller); System.out.println( "Added controller for: " + patient.getShortName()); } // Initial controller - patient - usually all patients // System.out.println( "Showing..."); show( display, 0 ); // System.out.println( "...Shown"); } protected void initData() { // Date now = new Date(); // // get data from server here // patients = new Vector(); // patients.addElement(new AllPatientData( )); // Patient patient1 = new Patient(); // patient1.setFirstName("Abe"); // patient1.setLastName("Westinghouse"); // patient1.setDob(new Date(now.getTime()-(37*years))); // patients.addElement(patient1); // Patient patient2 = new Patient(); // patient2.setFirstName("Laura"); // patient2.setLastName("Westinghouse"); // patient2.setDob(new Date(now.getTime()-(24*years))); // patients.addElement(patient2); // Patient patient3 = new Patient(); // patient3.setFirstName("Elizabeth"); // patient3.setLastName("Westinghouse"); // patient3.setDob(new Date(now.getTime()-(2*years))); // patients.addElement(patient3); // for (int x = 0; x < 10; x++) { // Patient pat = new Patient(); // pat.setFirstName("First " + x); // pat.setLastName("Last " + x); // pat.setDob(new Date(now.getTime()-(x*7*years))); // patients.addElement(pat); // } } public Vector getData( ) { if (patients==null) initData(); return patients; } /** * show the page as soon as we have a patient list. */ public void show(Display display) { this.display = display; // progress = new ServerProgress( "Get Members"); // progressItemIndex = form.append(progress); if (getCurrentController()<0) { ServerRequest requestPatientList = new MenuDataRequest( getSession(), this, "ephr:family:myfam:members"); requestPatientList.start(); return; } show( display, getCurrentController() ); } public void buildCommands( Form form ) { form.addCommand(new Command("Exit", Command.EXIT, 1)); form.addCommand(new Command("Back", Command.BACK, 2)); form.addCommand(new Command("Help", Command.HELP, 10)); form.addCommand(new Command("About", Command.HELP, 10)); } } |
From: John C. <jc...@us...> - 2007-02-24 09:03:51
|
Update of /cvsroot/tolven/tolvenMobileClient/src/org/tolven/mobile/client/util In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv29080/src/org/tolven/mobile/client/util Added Files: DateUtil.java Log Message: Tolven Mobile Client --- NEW FILE: DateUtil.java --- package org.tolven.mobile.client.util; import java.util.Calendar; import java.util.Date; public class DateUtil { public static final String monthNames[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; public static String toDateString( Date date ) { if (date==null) return ""; Calendar d = Calendar.getInstance(); d.setTime( date ); return d.get(Calendar.DAY_OF_MONTH) + "-" + DateUtil.monthNames[d.get(Calendar.MONTH)] + "-" + d.get(Calendar.YEAR); } public static String toShortDateString( Date date ) { if (date==null) return ""; Calendar d = Calendar.getInstance(); d.setTime( date ); return d.get(Calendar.DAY_OF_MONTH) + "-" + DateUtil.monthNames[d.get(Calendar.MONTH)] + "-" + (Integer.toString(d.get(Calendar.YEAR)).substring(2,4)); } public static String toAgeString( Date dob, Date now ) { Calendar n = Calendar.getInstance(); n.setTime( now ); Calendar b = Calendar.getInstance(); b.setTime( dob ); if (b.after(n)) return "Unborn"; // Get age in years int years = n.get(Calendar.YEAR)- b.get(Calendar.YEAR); long diff = now.getTime() - dob.getTime(); long days = diff / (1000*60*60*24); if (years > 1) return Integer.toString( years ) + "y"; if (years == 0 && days < 30) { return Long.toString( days )+ "d"; } return Long.toString( years * 12 + (days/30) )+ "m"; } public static String toDobString( Date dob ) { if (dob==null) return "no dob"; Calendar d = Calendar.getInstance(); d.setTime( dob ); return d.get(Calendar.DAY_OF_MONTH) + "-" + DateUtil.monthNames[d.get(Calendar.MONTH)] + "-" + d.get(Calendar.YEAR); } } |
From: John C. <jc...@us...> - 2007-02-24 09:03:51
|
Update of /cvsroot/tolven/tolvenMobileClient/src/org/tolven/mobile/client/view/form In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv29080/src/org/tolven/mobile/client/view/form Added Files: PeakFlowForm.java LoginPage.java ObservationForm.java WeightForm.java BPForm.java GlucoseForm.java TemperatureForm.java Log Message: Tolven Mobile Client --- NEW FILE: LoginPage.java --- package org.tolven.mobile.client.view.form; import javax.microedition.lcdui.Alert; import javax.microedition.lcdui.ChoiceGroup; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.Item; import javax.microedition.lcdui.StringItem; import javax.microedition.lcdui.TextField; import javax.microedition.rms.RecordStore; import org.tolven.mobile.client.comm.LoginRequest; import org.tolven.mobile.client.comm.ServerProgress; import org.tolven.mobile.client.comm.ServerRequest; import org.tolven.mobile.client.comm.ServerRequestListener; import org.tolven.mobile.client.comm.Session; import org.tolven.mobile.client.control.Application; import org.tolven.mobile.client.control.EPHRApplication; import org.tolven.mobile.client.view.HeaderItem; /** * Build and display a login form. * @author John Churin * */ public class LoginPage implements CommandListener, ServerRequestListener { private Display display; private CommandListener outerCommandListener; private Form loginForm; private Alert progressForm; private boolean loggedIn = false; private HeaderItem header = null; private TextField userText, pwdText, acctText, urlText; private String accountUserId; protected ChoiceGroup rememberMe; private Application application; private Session session; private ServerProgress progress; private boolean phase1; private String message; protected static Command cmdLogin = new Command("Login", Command.SCREEN, 4); protected static Command cmdHelp = new Command("Help", Command.SCREEN, 6); protected static Command cmdExit = new Command("Exit", Command.EXIT, 10); protected static String settingsFile = "rememberMe"; // Used by response from server. protected static Command cmdLoggedIn = new Command("LoggedIn", Command.SCREEN, 4); public void showLoginForm( ) { loginForm = new Form("Tolven"); header = new HeaderItem("Login", loginForm.getWidth()); userText = new TextField("User ID: ", session.getUserName(), 40, TextField.ANY); pwdText = new TextField("Password: ", session.getPassword(), 40, TextField.PASSWORD); acctText = new TextField("Account: ", session.getAccountId(), 40, TextField.NUMERIC); rememberMe = new ChoiceGroup(null, ChoiceGroup.MULTIPLE); rememberMe.append("Remember me", null); rememberMe.setPreferredSize( (loginForm.getWidth() * 2) / 3, -1); rememberMe.setLayout(Item.LAYOUT_CENTER | Item.LAYOUT_2); rememberMe.setSelectedIndex(0, session.isRecovered()); urlText = new TextField("URL: ", session.getUrl(), 80, TextField.ANY); loginForm.append(header); loginForm.append("\n"); loginForm.append(userText); loginForm.append(pwdText); loginForm.append(acctText); loginForm.append("\n"); if (message!=null) { StringItem messageItem; messageItem = new StringItem( "Error", message); loginForm.append(messageItem); } loginForm.append(rememberMe); loginForm.append(urlText); loginForm.append("\n"); loginForm.addCommand(cmdLogin); loginForm.addCommand(cmdHelp); loginForm.addCommand(cmdExit); loginForm.setCommandListener(this); display.setCurrent(loginForm); } public LoginPage( Display display, CommandListener outerCommandListener ) { this.display = display; this.outerCommandListener = outerCommandListener; session = recoverSession(); showLoginForm(); } // private final int urlRecord = 1; // private final int userNameRecord = 2; // private final int passwordRecord = 3; // private final int accountIdRecord = 3; /** * Attempt to recover session data from persistent store if it exists. * @return */ public Session recoverSession( ) { session = new Session( ); try { RecordStore rs = RecordStore.openRecordStore(settingsFile, true); if (rs.getNumRecords() < 3) { // System.out.println( "No saved settings found"); session.setUserName( ""); session.setPassword( ""); session.setAccountId( ""); session.setUrl("http://67.161.50.91:8080/Mobile/"); session.setRecovered( false); } else { // System.out.println( "Recovered saved settings"); int recordNum=0; session.setUrl(new String( rs.getRecord(++recordNum))); session.setUserName(new String( rs.getRecord(++recordNum))); // session.setPassword (new String( rs.getRecord(passwordRecord))); session.setAccountId(new String( rs.getRecord(++recordNum))); session.setRecovered( true); } rs.closeRecordStore(); } catch (Exception e) { e.printStackTrace(); } return session; } public void saveSession(Session session ) { try { System.out.println( "Saving settings"); RecordStore rs = RecordStore.openRecordStore(settingsFile, true); byte[] urlBytes = session.getUrl().getBytes(); rs.addRecord(urlBytes, 0, urlBytes.length ); System.out.println( "Saved url"); byte[] userNameBytes = session.getUserName().getBytes(); rs.addRecord(userNameBytes, 0, userNameBytes.length ); System.out.println( "Saved userName"); // byte[] passwordBytes = session.getPassword().getBytes(); // rs.addRecord(passwordBytes, 0, passwordBytes.length ); // System.out.println( "Saved password"); byte[] accountIdBytes = session.getAccountId().getBytes(); rs.addRecord(accountIdBytes, 0, accountIdBytes.length ); System.out.println( "Saved accountId"); rs.closeRecordStore(); } catch (Exception e) { e.printStackTrace(); } } /** * Make an error message visible * */ public void addError(String message ) { this.message = message; showLoginForm(); } /** * A serverRequest has completed. Deal with it. * In this case, login complete, now we can continue * @param request */ public void serverRequestAction (ServerRequest request) { // form.delete(progressItemIndex); if (phase1) { // System.out.println( "Start Phase 2, response=" + request.getResponse() ); if (request.isSuccess() && request.getResponse().startsWith("Login")) { LoginRequest loginRequest2 = new LoginRequest( session, this ); loginRequest2.setupLogin(); loginRequest2.start(); phase1=false; } else { // System.out.println( " Login failed response=" + request.getResponse() ); stopProgress(); addError( "Login failed, try again (correct URL?)" ); } } else { // Phase 2 complete stopProgress(); if (request.isSuccess() && request.getResponse().startsWith("ephr")) { // System.out.println( "rememberMe: " + rememberMe.getSelectedIndex()); try { RecordStore.deleteRecordStore(settingsFile); } catch (Exception e) { } if (rememberMe.isSelected(0)) { saveSession(session); } application = new EPHRApplication( session, this ); application.init(); application.show(display); } else { if (request.isSuccess()) { addError( "Invalid account type: " + request.getResponse() ); } else { // System.out.println( " Login failed response=" + request.getResponse() ); addError( "Login failed, try again" ); } } } } public void stopProgress( ) { progress.setDone(); progressForm = null; } public void showProgressForm( String name ) { if (progressForm==null) { progressForm = new Alert( name ); progress = new ServerProgress( null); progressForm.setIndicator(progress); } display.setCurrent(progressForm); } public void commandAction(Command command, Displayable displayable) { if (command==cmdLogin) { session.setUrl( this.getUrl() ); session.setUserName( this.getUserName() ); session.setPassword(this.getPassword()); session.setAccountId(this.getAccountId()); showProgressForm( "Login"); System.out.println( "Start Phase 1 " ); phase1=true; LoginRequest loginRequest = new LoginRequest( session, this ); // loginRequest.login(); loginRequest.setupAccount(); loginRequest.start(); return; } outerCommandListener.commandAction(command, displayable); } public String getUrl() { return urlText.getString(); } public String getUserName() { return userText.getString(); } public String getPassword() { return pwdText.getString(); } public String getAccountId() { return acctText.getString(); } /** * AccountUserId is returned from the server upon a successful login. * @return */ public String getAccountUserId() { return accountUserId; } public void setAccountUserId(String accountUserId) { this.accountUserId = accountUserId; } public boolean isLoggedIn() { return loggedIn; } public void setLoggedIn(boolean loggedIn) { this.loggedIn = loggedIn; } } --- NEW FILE: GlucoseForm.java --- package org.tolven.mobile.client.view.form; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.TextField; import org.tolven.mobile.client.control.PatientController; import org.tolven.mobile.client.data.Observation; public class GlucoseForm extends ObservationForm { TextField glucoseField; public GlucoseForm(PatientController controller, Observation data) { super(controller, data); } public GlucoseForm() {}; /** * Initialize new data for this observation * @return */ public void initData( ) { super.initData(); getData().setString01("Blood Glucose"); getData().setPqUnits01("mg/dL"); } public void buildFormBody(Form form) { glucoseField = new TextField("Glucose in mg/dL: ", getData().getPqStringVal01(), 5, TextField.DECIMAL | ( getData().isNew() ? 0 : TextField.UNEDITABLE)); // setValue( glucoseField ); form.append(glucoseField); } /** * Companion to buildFormBody, this method extracts data from the form and * puts it into the MenuData record. */ public void storeBodyData( ) { super.storeBodyData(); getData().setPqStringVal01(glucoseField.getString()); } public String getFormName() { return "Serum Glucose"; } public boolean validate() { // TODO Auto-generated method stub return true; } } --- NEW FILE: PeakFlowForm.java --- package org.tolven.mobile.client.view.form; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.Item; import javax.microedition.lcdui.TextField; import org.tolven.mobile.client.control.PatientController; import org.tolven.mobile.client.data.MenuData; import org.tolven.mobile.client.data.Observation; public class PeakFlowForm extends ObservationForm { TextField valueField; TextField commentField; public PeakFlowForm(PatientController controller, Observation data) { super(controller, data); } public PeakFlowForm() { } /** * Initialize new data for this observation * @return */ public void initData( ) { super.initData(); getData().setString01("Peak Flow"); getData().setString04(commentField.getString()); getData().setPqUnits01("L/min"); } /** * Companion to buildFormBody, this method extracts data from the form and * puts it into the MenuData record. */ public void storeBodyData( ) { super.storeBodyData(); getData().setPqStringVal01(valueField.getString()); } public void buildFormBody(Form form) { valueField = new TextField("Reading in L/min: ", getData().getPqStringVal01(), 5, TextField.DECIMAL | ( getData().isNew() ? 0 : TextField.UNEDITABLE)); form.append(valueField); commentField = new TextField("Comments: ", getData().getString04(), 50, TextField.PLAIN | ( getData().isNew() ? 0 : TextField.UNEDITABLE)); form.append(commentField); } public String getFormName() { return "Peak Flow"; } public MenuData submit( ) { Observation data = new Observation(); data.setParent01(getPatient().getId()); data.setDate01(this.getEffectiveTime().getDate()); data.setString01("PeakFlow"); data.setString02(getUserName()); data.setString04(commentField.getString()); data.setPqStringVal01(valueField.getString()); data.setPqUnits01("L/min"); return data; } public boolean validate() { // TODO Auto-generated method stub return true; } } --- NEW FILE: ObservationForm.java --- package org.tolven.mobile.client.view.form; import java.util.Date; import java.util.Vector; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.DateField; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.StringItem; import javax.microedition.lcdui.TextField; import org.tolven.mobile.client.comm.ServerRequest; import org.tolven.mobile.client.comm.ServerRequestListener; import org.tolven.mobile.client.comm.SubmitMenuData; import org.tolven.mobile.client.control.PatientController; import org.tolven.mobile.client.data.MenuData; import org.tolven.mobile.client.data.Observation; import org.tolven.mobile.client.data.Patient; import org.tolven.mobile.client.util.DateUtil; public abstract class ObservationForm implements CommandListener, ServerRequestListener{ private static final Command okCmd = new Command( "OK", Command.OK, 1); private static final Command cancelCmd = new Command( "Cancel", Command.CANCEL, 2); private static final Command closeCmd = new Command( "Close", Command.CANCEL, 2); private PatientController controller; protected Form form; private DateField effectiveTime; // private Vector values; private StringItem messageItem; private Observation data; /** * Return the name of this form * @return */ public abstract String getFormName(); /** * Add any for-specific contents. * @param form */ protected abstract void buildFormBody( Form form ); /** * Validate the form. return false if invalid. * @return */ protected abstract boolean validate( ); /** * Prepare a new Data item to be shipped to the server */ public MenuData submit( ) { return getData(); } public void initData( ) { System.out.println( "[ObservationForm] initData for patient: " + getPatient()); System.out.println( "Patient id: " + getPatient().getId()); getData().setParent01(getPatient().getId()); getData().setDate01(new Date()); getData().setString02(getUserName()); getData().setString01("Blood Pressure"); getData().setPqUnits01("mm/hg"); getData().setPqUnits02("mm/hg"); getData().setPqUnits03("mm/hg"); } public ObservationForm() { } /** * Create an observation form and make it visible * @param controller * @param display */ public ObservationForm( PatientController controller, Observation data) { this.controller = controller; show(); } public void show() { if (controller==null) throw new IllegalStateException("Missing controller" ); // If no previous data supplied, we create new data. if (getData()==null) { setData(new Observation()); initData( ); System.out.println( "Edit new data data" ); } else { setData(data); System.out.println( "Display existing data" ); } form = new Form( getFormName() ); StringItem patientName = new StringItem( "For: ", getPatient().getShortName()); form.append(patientName); if (getData().isNew()) { effectiveTime = new DateField("Date: ", DateField.DATE_TIME ); effectiveTime.setDate(getData().getDate01()); form.append(effectiveTime); } else { form.append(new StringItem( "Date: ", DateUtil.toDateString(getData().getDate01()))); } buildFormBody( form ); messageItem = new StringItem( " ", ""); form.append( messageItem ); if (getData().isNew()) { form.addCommand(okCmd); form.addCommand(cancelCmd); } else { form.addCommand(closeCmd); } form.setCommandListener(this); getController().display(form); } public void storeBodyData( ) { getData().setDate01(this.getEffectiveTime().getDate()); } /** * Make an error message visible */ public void addError(String message ) { messageItem.setLabel("Error: "); messageItem.setText(message); } /** * If the item is already instantiated, then */ public void commandAction(Command command, Displayable displayable ) { if ( command==cancelCmd || command==closeCmd) { // Back to where we came from controller.show(getController().getDisplay()); return; } if (command==okCmd && validate()) { // Notice that validation must use form data not menuData since we don't load up the menuData until validation is successful storeBodyData(); // System.out.println( "Submitting " + getFormName() + ": " + getValue().getString()); MenuData menuData = submit(); ServerRequest requestMD = new SubmitMenuData( controller.getSession(), this, menuData); requestMD.start(); controller.refreshPage("Observations"); controller.show(getController().getDisplay()); } } // public Vector getValues( ) { // if (values==null) values = new Vector(); // return values; // } // // /** // * Assume there is only one value in the array // * @return // */ // public TextField getValue() { // if (getValues().size() == 1) return (TextField) getValues().elementAt(0); // return null; // } // public void setValue(TextField value) { // if (getValues().size() > 0) getValues().setElementAt(value, 0); // getValues( ).addElement(value); // } public void setEffectiveTime(DateField effectiveTime) { this.effectiveTime = effectiveTime; } public DateField getEffectiveTime() { return effectiveTime; } public Observation getData() { return data; } public void setData(Observation data) { this.data = data; } public Patient getPatient() { return controller.getPatient(); } public String getUserName() { return controller.getApplication().getSession().getUserName(); } /** * Submit completed * @param request */ public void serverRequestAction (ServerRequest request) { System.out.println( "Result: " + request.getResponse()); } public PatientController getController() { return controller; } public void setController(PatientController controller) { this.controller = controller; } } --- NEW FILE: WeightForm.java --- package org.tolven.mobile.client.view.form; import javax.microedition.lcdui.ChoiceGroup; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.StringItem; import javax.microedition.lcdui.TextField; import org.tolven.mobile.client.control.PatientController; import org.tolven.mobile.client.data.Observation; public class WeightForm extends ObservationForm { TextField weightField; ChoiceGroup unitsField; public WeightForm(PatientController controller, Observation data) { super(controller, data); } public WeightForm() {} /** * Initialize new data for this observation * @return */ public void initData( ) { super.initData(); getData().setString01("Weight"); getData().setPqUnits01("mg/dL"); } public void buildFormBody(Form form) { weightField = new TextField("Weight: ", getData().getPqStringVal01(), 5, TextField.DECIMAL | ( getData().isNew() ? 0 : TextField.UNEDITABLE)); form.append(weightField); if (getData().isNew()) { unitsField = new ChoiceGroup(" ", ChoiceGroup.POPUP, new String[] {"lb","kg"}, null); form.append(unitsField); } else { form.append( new StringItem( " ", getData().getPqUnits01())); } } /** * Companion to buildFormBody, this method extracts data from the form and * puts it into the MenuData record. */ public void storeBodyData( ) { super.storeBodyData(); getData().setPqStringVal01(weightField.getString()); getData().setPqUnits01(unitsField.getString(unitsField.getSelectedIndex())); } public String getFormName() { return "Weight"; } public boolean validate() { int weight = Integer.parseInt(weightField.getString()); if (weight==0 || weight > 10000) { addError("Invalid weight"); return false; } return true; } } --- NEW FILE: BPForm.java --- package org.tolven.mobile.client.view.form; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.Item; import javax.microedition.lcdui.TextField; import org.tolven.mobile.client.control.PatientController; import org.tolven.mobile.client.data.Observation; public class BPForm extends ObservationForm { TextField systolicField; TextField diastolicField; public BPForm(PatientController controller, Observation data ) { super(controller, data); } public BPForm() {}; /** * Initialize new data for this observation * @return */ public void initData( ) { super.initData(); getData().setString01("Blood Pressure"); getData().setPqUnits01("mm/hg"); getData().setPqUnits02("mm/hg"); getData().setPqUnits03("mm/hg"); } public void buildFormBody(Form form) { System.out.println("Systolic: " + getData().getPqStringVal02()); systolicField = new TextField("Systolic: ", getData().getPqStringVal02(), 3, TextField.NUMERIC | ( getData().isNew() ? 0 : TextField.UNEDITABLE)); systolicField.setInitialInputMode( "IS_LATIN_DIGITS"); form.append(systolicField); diastolicField = new TextField("Diastolic: ", getData().getPqStringVal03(), 3, TextField.NUMERIC | ( getData().isNew() ? 0 : TextField.UNEDITABLE)); systolicField.setInitialInputMode( "IS_LATIN_DIGITS"); form.append(diastolicField); } /** * Companion to buildFormBody, this method extracts data from the form and * puts it into the MenuData record. */ public void storeBodyData( ) { super.storeBodyData(); getData().setPqStringVal01(systolicField.getString()+"/"+diastolicField.getString()); getData().setPqStringVal02(systolicField.getString()); getData().setPqStringVal03(diastolicField.getString()); } public String getFormName() { return "Blood Pressure"; } public boolean validate() { // TODO Auto-generated method stub return true; } } --- NEW FILE: TemperatureForm.java --- package org.tolven.mobile.client.view.form; import javax.microedition.lcdui.ChoiceGroup; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.DateField; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.StringItem; import javax.microedition.lcdui.TextField; import org.tolven.mobile.client.control.PatientController; import org.tolven.mobile.client.data.Observation; /** * A modal data entry form * @author John Churin * */ public class TemperatureForm extends ObservationForm { TextField temperatureField; ChoiceGroup unitsField; ChoiceGroup methodField; ChoiceGroup stateField; TextField commentField; public TemperatureForm(PatientController controller, Observation data ) { super( controller, data); } public TemperatureForm() {} public String getFormName( ) { return "Temperature"; } /** * Initialize new data for this observation * @return */ public void initData( ) { super.initData(); getData().setString01("Temperature"); getData().setPqUnits01("mg/dL"); } public void buildFormBody( Form form ) { temperatureField = new TextField("Temperature: ", getData().getPqStringVal01(), 5, TextField.DECIMAL | ( getData().isNew() ? 0 : TextField.UNEDITABLE)); form.append(temperatureField); if (getData().isNew()) { unitsField = new ChoiceGroup(" ", ChoiceGroup.POPUP, new String[] {"F","C"}, null); form.append(unitsField); methodField = new ChoiceGroup(" ", ChoiceGroup.POPUP, new String[] {"Method", "Axillary", "Oral","Rectal", "Surface", "Typanic" }, null); form.append(methodField); stateField = new ChoiceGroup(" ", ChoiceGroup.POPUP, new String[] {"Thremal State", "Indoor - Normal Clothing or Bedding", "Indoor - Reduced Clothing Bedding", "Indoor - Increased Clothing Bedding", "Outdoor - Normal Clothing or Bedding", "Outdoor - Reduced Clothing Bedding", "Outdoor - Increased Clothing Bedding", "Thermal Stress - Downward", "Thermal Stress - Upward", "Pediatric Incubator"}, null); form.append(stateField); } else { form.append( new StringItem(" ", getData().getPqUnits01()) ); form.append( new StringItem("Method: ", getData().getString03()) ); form.append( new StringItem("Thremal State: ", getData().getString04()) ); } commentField = new TextField("Comments: ", "", 50, TextField.PLAIN | ( getData().isNew() ? 0 : TextField.UNEDITABLE)); form.append(commentField); } /** * Companion to buildFormBody, this method extracts data from the form and * puts it into the MenuData record. */ public void storeBodyData( ) { super.storeBodyData(); getData().setPqStringVal01(temperatureField.getString()); getData().setPqUnits01(unitsField.getString(unitsField.getSelectedIndex())); getData().setString03(methodField.getString(methodField.getSelectedIndex())); getData().setString04(stateField.getString(stateField.getSelectedIndex())); } public boolean validate() { // TODO Auto-generated method stub return true; } } |
From: John C. <jc...@us...> - 2007-02-24 09:03:51
|
Update of /cvsroot/tolven/tolvenMobileClient/src/org/tolven/mobile/client In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv29080/src/org/tolven/mobile/client Added Files: TolvenMidlet.java Log Message: Tolven Mobile Client --- NEW FILE: TolvenMidlet.java --- package org.tolven.mobile.client; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; import org.tolven.mobile.client.view.form.LoginPage; /** * Tolven mobile client application (MIDlet). * @author John Churin * */ public class TolvenMidlet extends MIDlet implements CommandListener { protected void destroyApp(boolean arg0) throws MIDletStateChangeException { } protected void pauseApp() { } /** * We start by logging in. This in turn calls the correct application based on the account selected. */ protected void startApp() throws MIDletStateChangeException { LoginPage loginPage = new LoginPage( Display.getDisplay(this), this ); } /** * If our application asks to be destroyed, do so. */ public void commandAction(Command command, Displayable displayable) { if ( command.getCommandType()==Command.EXIT) { notifyDestroyed(); } } } |
From: John C. <jc...@us...> - 2007-02-24 09:03:51
|
Update of /cvsroot/tolven/tolvenMobileClient/src/org/tolven/mobile/client/view In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv29080/src/org/tolven/mobile/client/view Added Files: PageCommand.java PatientEntryMenu.java TolvenPage.java HeaderItem.java Log Message: Tolven Mobile Client --- NEW FILE: PatientEntryMenu.java --- package org.tolven.mobile.client.view; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.List; import org.tolven.mobile.client.control.PatientController; import org.tolven.mobile.client.view.form.BPForm; import org.tolven.mobile.client.view.form.GlucoseForm; import org.tolven.mobile.client.view.form.PeakFlowForm; import org.tolven.mobile.client.view.form.TemperatureForm; import org.tolven.mobile.client.view.form.WeightForm; /** * A short-lived UI object that presents a menu of choices for data entry and then displays that entry form. * @author John Churin * */ public class PatientEntryMenu implements CommandListener { PatientController controller; Display display; List list; private static final Command backCmd = new Command( "Back", Command.ITEM, 1); public PatientEntryMenu( PatientController controller, Display display ) { this.controller = controller; this.display = display; list = new List( controller.getDataItem().getShortName(), List.IMPLICIT); list.append("Blood Glucose", null); list.append("Blood Pressure", null); list.append("Peak Flow", null); list.append("Temperature", null); list.append("Weight", null); list.addCommand(backCmd); // list.setSelectCommand(backCmd); list.setCommandListener(this); display.setCurrent(list); } public void commandAction(Command command, Displayable displayable ) { System.out.println( "Command: " + command.getLabel()); if (command==backCmd) { // Back to where we came from controller.show(display); return; } String selection = list.getString(list.getSelectedIndex()); System.out.println( "Selected: " + selection); if ("Temperature".equals(selection)) { new TemperatureForm( controller, null ); return; } if ("Blood Glucose".equals(selection)) { new GlucoseForm( controller, null ); return; } if ("Blood Pressure".equals(selection)) { // Create a new Blood Pressure new BPForm( controller, null ); return; } if ("Weight".equals(selection)) { new WeightForm( controller, null ); return; } if ("Peak Flow".equals(selection)) { new PeakFlowForm( controller, null ); return; } } } --- NEW FILE: PageCommand.java --- package org.tolven.mobile.client.view; public class PageCommand { String shortName; Class tolvenPageClass; public PageCommand( String shortName, Class tolvenPageClass ) { this.shortName = shortName; this.tolvenPageClass = tolvenPageClass; } } --- NEW FILE: TolvenPage.java --- package org.tolven.mobile.client.view; import java.io.IOException; import java.util.Vector; import javax.microedition.lcdui.ChoiceGroup; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.Item; import org.tolven.mobile.client.control.CommandProcessor; import org.tolven.mobile.client.control.Controller; /** * Generic page layout for all but the login page. All pages contain a list of patients (or some other * top-level context) which comes from the controller - we really just pass it through. * It also contains a list of commands indicating other pages that can be selected. * commands are also passed to the controller. * This list is actually shared among the different pages but displayed on each page. * @author John Churin */ public abstract class TolvenPage extends CommandProcessor { private Controller controller; private Form form; private String formName; private ChoiceGroup dataChoices; private int thisDataChoice; /** * Construct a standard Tolven page consisting of a patient list and a list of alternate page * which include all other pages except this page. * We can't build the page list until all of the pages are built and stored in the pages Vector. */ public TolvenPage( String formName, Controller controller ) { super(controller); this.controller = controller; this.formName = formName; } /** * Insure that the next time this page shows we get fresh data. * */ public void refresh( ) { form = null; } // /** // * One-time initialization of this page. Note: the patient list may change but the list of pages // * is constant (at this point). // * @throws IOException // */ // public void init(PageList pageList ) throws IOException { // // Build a list of pages // Vector pages = pageList.getTolvenPages(); // ChoiceGroup pageChoices = new ChoiceGroup( "Member", ChoiceGroup.POPUP ); // for (int x = 0; x < pages.size(); x++) { // TolvenPage page = (TolvenPage) pages.elementAt(x); // form.addCommand( new Command( page.getFormName(), Command.ITEM, 5 )); // pageChoices.append( page.getFormName(), null ); // } // form.append( pageChoices ); // } /** * Append an item to the enclosing form * @param item */ protected void append( Item item) { form.append(item); } protected void buildPage( Form form ) { // System.out.println( "TolvenPage: Build Page #1..."); form.append( new HeaderItem(formName, form.getWidth() ) ); // form.append(Image.createImage("/img/ePHR.png")); controller.buildCommands(form); // System.out.println( "TolvenPage: Build Page #2..."); dataChoices = controller.buildData( form ); // System.out.println( "TolvenPage: Build Page #3..."); thisDataChoice = dataChoices.getSelectedIndex(); } /** * Show this page on the specified display * @param display */ public void show( Display display ) { if (display==null) throw new IllegalArgumentException("[tolvenPage::show] Display cannot be null" ); if (form==null) { // System.out.println( "TolvenPage: Showing #2..."); form = new Form(getFormName()); buildPage(form); } // System.out.println( "TolvenPage: Showing #3..."); // Need to reset this because when the user selects a different patient, it's now on that patient. dataChoices.setSelectedIndex(thisDataChoice, true); System.out.println( "Displaying TolvenPage: " + getFormName() + " for " + controller.getDataItem().getShortName()); display.setCurrent(form); // System.out.println( "TolvenPage: Shown..."); } public String getFormName() { return formName; } public void setFormName(String formName) { this.formName = formName; } // Local page behavior detected. public boolean doAction(Command command, Displayable displayable) { String label = command.getLabel(); System.out.println( label ); return false; } public Controller getController() { return controller; } } --- NEW FILE: HeaderItem.java --- package org.tolven.mobile.client.view; import javax.microedition.lcdui.*; import java.io.*; /** * <p>Title: HeaderItem</p> * <p>Description: Screen header Item</p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: </p> * @author not attributable * @version 1.0 */ public class HeaderItem extends CustomItem { protected static Image bground = null;//hdImg = null, private String header = null; private int width = 10; private int dspOff = 50; // width of ePHR image private Font font = null; /** * class construction * @param header String * @param width int */ public HeaderItem(String header, int width) { super(null); this.init(header, null, width); } /** * class construction * @param header String * @param width int */ public HeaderItem(String header, String hDate, int width) { super(null); this.init(header, hDate, width); } /** * class initalization * @param header String * @param hDate String * @param width int */ public void init(String header, String hDate, int width) { this.header = header; this.width = width; this.font = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_MEDIUM); if (bground == null) { try { //hdImg = Image.createImage("/img/ePHR.png"); bground = Image.createImage("/img/ePHRHeader.png"); } catch (IOException ex1) { System.out.println("Failed to load header background images"); } } } /** * Set item header * @param header String */ public void setHeader(String header) { this.header = header; } /** * Returns the minimal height of the content area * @return int */ protected int getMinContentHeight() { return 10; } /** * Returns the minimal width of the content area * @return int */ protected int getMinContentWidth() { return width / 2; } /** * Returns the preferred height of the content * area. A tentative value for the opposite * dimension -- the width -- is passed to aid * in the height calculation. The tentative value * should be ignored if it is -1. * @param width int * @return int */ protected int getPrefContentHeight(int width) { int h = this.font.getHeight() + 4; int imgH = 0; if (bground != null) { imgH = bground.getHeight(); if (h < imgH) h = imgH; } return h; } /** * Returns the preferred width of the content * area. A tentative value for the opposite * dimension -- the height -- is passed to aid * in the width calculation. The tentative value * should be ignored if it is -1. * @param height int * @return int */ protected int getPrefContentWidth(int height) { return this.width; } /** * Draws the item's content area, whose dimensions * are given by the width and height parameters. * @param g Graphics * @param width int * @param height int */ protected void paint(Graphics g, int width, int height) { //g.setClip((j * dx) + 1, i * dy, dx - 1, dy - 1); Font oldFont = g.getFont(); if (bground != null) g.drawImage(bground, 0, 0, Graphics.TOP | Graphics.LEFT); // if (hdImg != null) { // g.drawImage(hdImg, 1 , 1, // Graphics.TOP | Graphics.LEFT); // } g.setColor(0xFFFFFF); // White int dy = (height - font.getHeight())/2; int dx = ((width-dspOff-font.stringWidth(header))/2)+dspOff; g.setFont(font); g.drawString(header, dx, dy, Graphics.TOP | Graphics.LEFT); g.setFont(oldFont); } } |
From: John C. <jc...@us...> - 2007-02-24 09:03:50
|
Update of /cvsroot/tolven/tolvenMobileClient/src/org/tolven/mobile/client/data In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv29080/src/org/tolven/mobile/client/data Added Files: Observation.java Procedure.java Medication.java Appointment.java Data.java Problem.java Diagnosis.java Allergy.java MenuData.java Patient.java Reminder.java Result.java AllPatientData.java Log Message: Tolven Mobile Client --- NEW FILE: MenuData.java --- package org.tolven.mobile.client.data; import java.util.Calendar; import java.util.Date; import org.tolven.mobile.client.comm.ServerRequest; public abstract class MenuData implements Data { private String trim; private String id; private String path; private Date date01; private Date date02; private Date date03; private Date date04; private String string01; private String string02; private String string03; private String string04; private String parent01; private String parent02; private String parent03; private String parent04; private long long01; private long long02; private long long03; private long long04; private String pqStringVal01; private String pqUnits01; private String pqStringVal02; private String pqUnits02; private String pqStringVal03; private String pqUnits03; private String pqStringVal04; private String pqUnits04; public abstract String getShortName(); /** * Return a Form class suitable for displaying this kind of Menudata. * @return */ public abstract Class getFormClass( ); public MenuData() { } /** * Return true if this data item is new. In our case, an ID that is null indicates that it is new. * @return */ public boolean isNew() { return (getId()==null); } /** * construct a menuDataItem based on the attributes provided in a compact format * @param line */ public MenuData( String line ) { // System.out.println( "Parsing: " + line); int f = 0; int t; t = line.indexOf('|', f); setId( line.substring(f, t)); f = t+1; t = line.indexOf('|', f);setPath( line.substring(f, t));f = t+1; t = line.indexOf('|', f);setString01( line.substring(f, t));f = t+1; t = line.indexOf('|', f);setString02( line.substring(f, t));f = t+1; t = line.indexOf('|', f);setString03( line.substring(f, t));f = t+1; t = line.indexOf('|', f);setString04( line.substring(f, t));f = t+1; t = line.indexOf('|', f);setDate01( parseDate( line, f, t));f = t+1; t = line.indexOf('|', f);setDate02( parseDate( line, f, t));f = t+1; t = line.indexOf('|', f);setDate03( parseDate( line, f, t));f = t+1; t = line.indexOf('|', f);setDate04( parseDate( line, f, t));f = t+1; t = line.indexOf('|', f);setPqStringVal01( line.substring(f, t));f = t+1; t = line.indexOf('|', f);setPqUnits01( line.substring(f, t));f = t+1; t = line.indexOf('|', f);setPqStringVal02( line.substring(f, t));f = t+1; t = line.indexOf('|', f);setPqUnits02( line.substring(f, t));f = t+1; t = line.indexOf('|', f);setPqStringVal03( line.substring(f, t));f = t+1; t = line.indexOf('|', f);setPqUnits03( line.substring(f, t));f = t+1; t = line.indexOf('|', f);setPqStringVal04( line.substring(f, t));f = t+1; t = line.indexOf('|', f);setPqUnits04( line.substring(f, t));f = t+1; } public Date parseDate( String line, int f, int t) { if (f==t) return null; return new Date( Long.parseLong(line.substring(f, t))); } /** * This method sets parameters in the request suitable for upload of a new or updated data item. * Path is the unique id of an existing item. If the path and Id are null, it means the item is new. */ public void setUploadParameters( ServerRequest request) { request.setPage("submit.mobile"); if (getTrim()!=null) request.addParameter("trim", getTrim()); if (getId()!=null) request.addParameter("id", getId()); if (getPath()!=null) request.addParameter("path", getPath()); if (getParent01()!=null) request.addParameter("parent01", getParent01()); if (getParent02()!=null) request.addParameter("parent02", getParent02()); if (getParent03()!=null) request.addParameter("parent03", getParent03()); if (getParent04()!=null) request.addParameter("parent04", getParent04()); if (getString01()!=null) request.addParameter("string01", getString01()); if (getString02()!=null) request.addParameter("string02", getString02()); if (getString03()!=null) request.addParameter("string03", getString03()); if (getString04()!=null) request.addParameter("string04", getString04()); if (getDate01()!=null) request.addParameter("date01", Long.toString(getDate01().getTime())); if (getDate02()!=null) request.addParameter("date02", Long.toString(getDate02().getTime())); if (getDate03()!=null) request.addParameter("date03", Long.toString(getDate03().getTime())); if (getDate04()!=null) request.addParameter("date04", Long.toString(getDate04().getTime())); if (getPqStringVal01()!=null) request.addParameter("pqValue01", getPqStringVal01()); if (getPqUnits01()!=null) request.addParameter("pqUnits01", getPqUnits01()); if (getPqStringVal02()!=null) request.addParameter("pqValue02", getPqStringVal02()); if (getPqUnits02()!=null) request.addParameter("pqUnits02", getPqUnits02()); if (getPqStringVal03()!=null) request.addParameter("pqValue03", getPqStringVal03()); if (getPqUnits03()!=null) request.addParameter("pqUnits03", getPqUnits03()); if (getPqStringVal04()!=null) request.addParameter("pqValue04", getPqStringVal04()); if (getPqUnits04()!=null) request.addParameter("pqUnits04", getPqUnits04()); } public Date getDate01() { return date01; } public void setDate01(Date date01) { this.date01 = date01; } public Date getDate02() { return date02; } public void setDate02(Date date02) { this.date02 = date02; } public Date getDate03() { return date03; } public void setDate03(Date date03) { this.date03 = date03; } public Date getDate04() { return date04; } public void setDate04(Date date04) { this.date04 = date04; } public String getId() { return id; } public void setId(String id) { this.id = id; } public long getLong01() { return long01; } public void setLong01(long long01) { this.long01 = long01; } public long getLong02() { return long02; } public void setLong02(long long02) { this.long02 = long02; } public long getLong03() { return long03; } public void setLong03(long long03) { this.long03 = long03; } public long getLong04() { return long04; } public void setLong04(long long04) { this.long04 = long04; } public String getPath() { return path; } public void setPath(String path) { this.path = path; } public String getPqStringVal01() { return pqStringVal01; } public void setPqStringVal01(String pqStringVal01) { this.pqStringVal01 = pqStringVal01; } public String getPqStringVal02() { return pqStringVal02; } public void setPqStringVal02(String pqStringVal02) { this.pqStringVal02 = pqStringVal02; } public String getPqStringVal03() { return pqStringVal03; } public void setPqStringVal03(String pqStringVal03) { this.pqStringVal03 = pqStringVal03; } public String getPqStringVal04() { return pqStringVal04; } public void setPqStringVal04(String pqStringVal04) { this.pqStringVal04 = pqStringVal04; } public String getPqUnits01() { return pqUnits01; } public void setPqUnits01(String pqUnits01) { this.pqUnits01 = pqUnits01; } public String getPqUnits02() { return pqUnits02; } public void setPqUnits02(String pqUnits02) { this.pqUnits02 = pqUnits02; } public String getPqUnits03() { return pqUnits03; } public void setPqUnits03(String pqUnits03) { this.pqUnits03 = pqUnits03; } public String getString01() { return string01; } public void setString01(String string01) { this.string01 = string01; } public String getString02() { return string02; } public void setString02(String string02) { this.string02 = string02; } public String getString03() { return string03; } public void setString03(String string03) { this.string03 = string03; } public String getString04() { return string04; } public void setString04(String string04) { this.string04 = string04; } public String getPqUnits04() { return pqUnits04; } public void setPqUnits04(String pqUnits04) { this.pqUnits04 = pqUnits04; } public String getParent01() { return parent01; } public void setParent01(String parent01) { this.parent01 = parent01; } public String getParent02() { return parent02; } public void setParent02(String parent02) { this.parent02 = parent02; } public String getParent03() { return parent03; } public void setParent03(String parent03) { this.parent03 = parent03; } public String getParent04() { return parent04; } public void setParent04(String parent04) { this.parent04 = parent04; } public String getTrim() { return trim; } public void setTrim(String trim) { this.trim = trim; } } --- NEW FILE: Reminder.java --- package org.tolven.mobile.client.data; public class Reminder extends MenuData implements Data { public Reminder(String line) { super(line); } public String getShortName() { return getString01(); } public Class getFormClass() { return null; } } --- NEW FILE: Result.java --- package org.tolven.mobile.client.data; import org.tolven.mobile.client.util.DateUtil; public class Result extends MenuData implements Data { public Result(String line) { super(line); } public String getShortName() { return DateUtil.toShortDateString(getDate01()) + " " + getString01() + " " + getValue(); } public String getValue() { return getPqStringVal01() + " " + getPqUnits01(); } public Class getFormClass() { return null; } } --- NEW FILE: Medication.java --- package org.tolven.mobile.client.data; public class Medication extends MenuData implements Data { public Medication(String line) { super(line); } public String getShortName() { return getString01(); } public Class getFormClass() { return null; } } --- NEW FILE: Patient.java --- package org.tolven.mobile.client.data; import java.util.Calendar; import java.util.Date; import java.util.Vector; import org.tolven.mobile.client.util.DateUtil; public class Patient implements Data { private String id; private String path; private String firstName; private String middleName; private String lastName; private Date dob; private String gender; private Vector problems; private Vector allergies; private Vector appointments; private Vector diagnosis; private Vector medications; private Vector procedures; private Vector reminders; private Vector results; private Vector observations; public Patient() { } /** * Innitialize a patient by parsing the contents of the passed line * <pre> * id | path | first | middle | last | dob | gender * </pre> * @param line */ public Patient( String line ) { int f = 0; int t; t = line.indexOf('|', f); setId( line.substring(f, t)); f = t+1; t = line.indexOf('|', f); setPath( line.substring(f, t)); f = t+1; t = line.indexOf('|', f); setLastName( line.substring(f, t)); f = t+1; t = line.indexOf('|', f); setFirstName( line.substring(f, t)); f = t+1; t = line.indexOf('|', f); setMiddleName( line.substring(f, t)); f = t+1; t = line.indexOf('|', f); setDob( new Date( Long.parseLong(line.substring(f, t)))); // Millisecond time is passed f = t+1; setGender( line.substring(f)); } public String getShortName( ) { // return getFirstName() + " " + getLastName() + " " + toAgeString(getDob(), new Date()); return getFirstName() + " " + getLastName() + " " + DateUtil.toDobString(getDob()); } public Date getDob() { return dob; } public void setDob(Date dob) { this.dob = dob; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getGender() { return gender; } public void setGender(String gender) { this.gender = gender; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getMiddleName() { return middleName; } public void setMiddleName(String middleName) { this.middleName = middleName; } public Vector getAllergies() { if (allergies==null) allergies = new Vector(); return allergies; } public void addAllergy(Data allergy) { getAllergies().addElement(allergy); } public Vector getAppointments() { if (appointments==null) appointments = new Vector(); return appointments; } public void addAppointment(Data appointment) { getAppointments().addElement(appointment); } public Vector getDiagnosis() { if (diagnosis==null) diagnosis = new Vector(); return diagnosis; } public void addDiagnosis(Data diagnosis) { getDiagnosis().addElement(diagnosis); } public Vector getMedications() { if (medications==null) medications = new Vector(); return medications; } public void addMedication(Data medication) { getMedications().addElement(medication); } public Vector getProblems() { if (problems==null) problems = new Vector(); return problems; } public void addProblem(Data problem) { getProblems().addElement(problem); } public Vector getProcedures() { if (procedures==null) procedures = new Vector(); return procedures; } public void addProcedure(Data procedure) { getProcedures().addElement(procedure); } public Vector getReminders() { if (reminders==null) reminders = new Vector(); return reminders; } public void addReminder(Data reminder) { getReminders().addElement(reminder); } public Vector getResults() { if (results==null) results = new Vector(); return results; } public void addResult(Data result) { getResults().addElement(result); } public Vector getObservations() { if (observations==null) observations = new Vector(); return observations; } public void addObservations(Data observation) { getObservations().addElement(observation); } public String getPath() { return path; } public void setPath(String path) { this.path = path; } } --- NEW FILE: Procedure.java --- package org.tolven.mobile.client.data; public class Procedure extends MenuData implements Data { public Procedure(String line) { super(line); } public String getShortName() { return getString01(); } public Class getFormClass() { return null; } } --- NEW FILE: Allergy.java --- package org.tolven.mobile.client.data; import java.util.Date; import org.tolven.mobile.client.util.DateUtil; public class Allergy extends MenuData implements Data { public Allergy(String line) { super(line); } public String getShortName() { return getAllergy() + " " + DateUtil.toShortDateString(getOnset()); } public String getAllergy() { return getString01(); } public void setAllergy(String allergy) { this.setString01(allergy); } public Date getOnset() { return getDate01(); } public void setOnset(Date onset) { this.setDate01( onset ); } public Class getFormClass() { return null; } } --- NEW FILE: Data.java --- package org.tolven.mobile.client.data; public interface Data { /** * Return a string suitable for displaying on a small screen * @return */ public String getShortName(); } --- NEW FILE: Diagnosis.java --- package org.tolven.mobile.client.data; public class Diagnosis extends MenuData implements Data { public Diagnosis(String line) { super(line); } public String getShortName() { return getString01(); } public Class getFormClass() { return null; } } --- NEW FILE: AllPatientData.java --- package org.tolven.mobile.client.data; public class AllPatientData implements Data { public String getShortName() { return "All Members"; } } --- NEW FILE: Appointment.java --- package org.tolven.mobile.client.data; import org.tolven.mobile.client.util.DateUtil; public class Appointment extends MenuData implements Data { public Appointment(String line) { super(line); } public String getShortName() { return DateUtil.toShortDateString( getDate01()) + " " + getString01(); } public Class getFormClass() { return null; } } --- NEW FILE: Observation.java --- package org.tolven.mobile.client.data; import org.tolven.mobile.client.util.DateUtil; import org.tolven.mobile.client.view.form.BPForm; import org.tolven.mobile.client.view.form.GlucoseForm; import org.tolven.mobile.client.view.form.PeakFlowForm; import org.tolven.mobile.client.view.form.TemperatureForm; import org.tolven.mobile.client.view.form.WeightForm; public class Observation extends MenuData implements Data { public Observation() { super(); } public Observation(String line) { super(line); } public Class getFormClass() { if ("Temperature".equals(getString01())) { return TemperatureForm.class; } if ("Blood Glucose".equals(getString01())) { return GlucoseForm.class; } if ("Blood Pressure".equals(getString01())) { return BPForm.class; } if ("Weight".equals(getString01())) { return WeightForm.class; } if ("Peak Flow".equals(getString01())) { return PeakFlowForm.class; } if ("PeakFlow".equals(getString01())) { return PeakFlowForm.class; } return null; } public String getShortName() { return DateUtil.toShortDateString(getDate01()) + " " + getString01() + " " + getPqStringVal01() + " " + getPqUnits01(); } } --- NEW FILE: Problem.java --- package org.tolven.mobile.client.data; import org.tolven.mobile.client.util.DateUtil; public class Problem extends MenuData implements Data { public Problem(String line) { super(line); } public String getShortName() { return getProblem() + " " + DateUtil.toShortDateString(getDate01()); } public String getProblem( ) { return getString01(); } public Class getFormClass() { return null; } } |
Update of /cvsroot/tolven/tolvenMobileClient/src/org/tolven/mobile/client/view/list In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv29080/src/org/tolven/mobile/client/view/list Added Files: ResultsPage.java AllPatientReminders.java PatientList.java ObservationsPage.java ProblemsPage.java ListPage.java ProceduresPage.java MedicationsPage.java AllergiesPage.java AppointmentsPage.java RemindersPage.java AllPatientAppointments.java DiagnosisPage.java Log Message: Tolven Mobile Client --- NEW FILE: RemindersPage.java --- package org.tolven.mobile.client.view.list; import java.util.Vector; import org.tolven.mobile.client.control.Controller; import org.tolven.mobile.client.data.MenuData; import org.tolven.mobile.client.data.Patient; import org.tolven.mobile.client.data.Reminder; public class RemindersPage extends ListPage { Patient patient; public RemindersPage(Patient patient, Controller controller ) { super( "Reminders", controller); this.patient = patient; } /** * Provide the query string * @return */ public String getQuery( ) { return "ephr:patient-"+patient.getId()+":XXXXXXXXXXXXXXXX"; } public MenuData createItem( String line ) { return new Reminder( line ); } public Vector getList( ) { return patient.getReminders(); } } --- NEW FILE: ListPage.java --- package org.tolven.mobile.client.view.list; import java.util.Vector; import javax.microedition.lcdui.Choice; import javax.microedition.lcdui.ChoiceGroup; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Font; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.Item; import javax.microedition.lcdui.ItemCommandListener; import javax.microedition.lcdui.ItemStateListener; import javax.microedition.lcdui.List; import javax.microedition.lcdui.StringItem; import org.tolven.mobile.client.comm.MenuDataRequest; import org.tolven.mobile.client.comm.ServerProgress; import org.tolven.mobile.client.comm.ServerRequest; import org.tolven.mobile.client.comm.ServerRequestListener; import org.tolven.mobile.client.control.Controller; import org.tolven.mobile.client.control.PatientController; import org.tolven.mobile.client.data.MenuData; import org.tolven.mobile.client.data.Observation; import org.tolven.mobile.client.view.TolvenPage; import org.tolven.mobile.client.view.form.ObservationForm; /** * A List page presents some kind of a list with a capability to drill down on the list. * Subclasses will determine the specific list but in mose cases, this class can handle the list itself. * @author John Churin */ public abstract class ListPage extends TolvenPage implements ItemStateListener, ItemCommandListener, ServerRequestListener { ChoiceGroup patientChoices; int insertLocation; Form form; private ServerProgress progress; private int progressItemIndex; protected static Command cmdDrilldown = new Command("Details", Command.ITEM, 4); public ListPage( String formName, Controller controller) { super(formName, controller); } /** * Subclass will need to provide the query string * @return */ public abstract String getQuery( ); public abstract Vector getList( ); public abstract MenuData createItem( String line ); /** * We play a part in building the page by adding a list to the body. * But in reality, all we can do is start getting the list from the server * and then populate the list upon its arrival. */ protected void buildPage( Form form ) { super.buildPage(form); insertLocation = form.size(); this.form = form; progress = new ServerProgress( "Getting " + getFormName() + "..."); progressItemIndex = form.append(progress); ServerRequest requestMD = new MenuDataRequest( getController().getSession(), this, getQuery()); requestMD.start(); } /** * Our list has arrived so update the display * @param request */ public void serverRequestAction (ServerRequest request) { if (!(request instanceof MenuDataRequest) ) return; Vector list = getList(); // Item emptyItem = new StringItem( "", null); progress.setDone(); progress = null; if (!request.isSuccess()) { // Replace progress with an error message. form.set(progressItemIndex, new StringItem( "Error", "Code: " + request.getResponseCode()) ); return; } form.delete(progressItemIndex); MenuDataRequest mdr = (MenuDataRequest)request; String response = mdr.getResponse(); int cur = 0; while ( true ) { if (cur >= response.length()) break; int eol = response.indexOf('\n', cur); String line = response.substring(cur, eol); cur = eol+1; MenuData md = createItem( line ); list.addElement(md); StringItem item = new TolvenListItem(getController(), md ); item.setLayout( Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_VSHRINK); // Doesn't help item.setPreferredSize(form.getWidth(), -1); item.addCommand(cmdDrilldown); item.setDefaultCommand(cmdDrilldown); item.setItemCommandListener(this); form.insert(insertLocation, item); insertLocation++; } if (list.size()==0) { form.append(new StringItem( "No ", this.getFormName())); } } public void commandAction( Command command, Item item ) { System.out.println( "got: " + command.getLabel() + " on " + ((TolvenListItem)item).getData().getId()); ((TolvenListItem)item).commandAction(command, form); } public void itemStateChanged(Item item) { System.out.println( "got: " + item.getLabel()); } class TolvenListItem extends StringItem implements CommandListener { private PatientController controller; private MenuData data; public TolvenListItem(Controller controller, MenuData data) { super("", data.getShortName()); this.controller = (PatientController) controller; this.data = data; } public MenuData getData() { return data; } /** * The form gets the initial command and redirects it here. We usually do something like open the form. */ public void commandAction(Command command, Displayable displayable) { if (controller==null) throw new IllegalStateException("Missing controller" ); Class formClass = data.getFormClass(); if (formClass==null) return; // System.out.println( " formClass: " + formClass.getName()); try { ObservationForm form = (ObservationForm)(formClass).newInstance( ); form.setController( controller ); form.setData((Observation)data); form.show(); } catch (Exception e) { e.printStackTrace(); } } } } --- NEW FILE: AllPatientAppointments.java --- package org.tolven.mobile.client.view.list; import org.tolven.mobile.client.control.Controller; import org.tolven.mobile.client.data.AllPatientData; import org.tolven.mobile.client.view.TolvenPage; public class AllPatientAppointments extends TolvenPage { AllPatientData allPatient; public AllPatientAppointments(AllPatientData allPatient, String formName, Controller controller) { super(formName, controller); this.allPatient = allPatient; } } --- NEW FILE: PatientList.java --- package org.tolven.mobile.client.view.list; /** * A UI Element containing a list of patients/family members. * @author John Churin * */ public class PatientList { } --- NEW FILE: AllergiesPage.java --- package org.tolven.mobile.client.view.list; import java.util.Vector; import org.tolven.mobile.client.control.Controller; import org.tolven.mobile.client.data.Allergy; import org.tolven.mobile.client.data.MenuData; import org.tolven.mobile.client.data.Patient; public class AllergiesPage extends ListPage { Patient patient; public AllergiesPage(Patient patient, Controller controller ) { super( "Allergies", controller); this.patient = patient; } /** * Provide the query string * @return */ public String getQuery( ) { return "ephr:patient-"+patient.getId()+":doc:allergies"; } public MenuData createItem( String line ) { return new Allergy( line ); } public Vector getList( ) { return patient.getAllergies( ); } } --- NEW FILE: AppointmentsPage.java --- package org.tolven.mobile.client.view.list; import java.util.Vector; import org.tolven.mobile.client.control.Controller; import org.tolven.mobile.client.data.Appointment; import org.tolven.mobile.client.data.MenuData; import org.tolven.mobile.client.data.Patient; public class AppointmentsPage extends ListPage { Patient patient; public AppointmentsPage(Patient patient, Controller controller ) { super( "Appointments", controller); this.patient = patient; } /** * Provide the query string * @return */ public String getQuery( ) { return "ephr:patient-"+patient.getId()+":pers:appts:past"; } public MenuData createItem( String line ) { return new Appointment( line ); } public Vector getList( ) { return patient.getAppointments( ); } } --- NEW FILE: ObservationsPage.java --- package org.tolven.mobile.client.view.list; import java.util.Vector; import org.tolven.mobile.client.control.Controller; import org.tolven.mobile.client.data.MenuData; import org.tolven.mobile.client.data.Observation; import org.tolven.mobile.client.data.Patient; public class ObservationsPage extends ListPage { Patient patient; public ObservationsPage(Patient patient, Controller controller ) { super( "Observations", controller); this.patient = patient; } /** * Provide the query string * @return */ public String getQuery( ) { return "ephr:patient-"+patient.getId()+":doc:obs:values"; } public MenuData createItem( String line ) { return new Observation( line ); } public Vector getList( ) { return patient.getObservations(); } } --- NEW FILE: ProblemsPage.java --- package org.tolven.mobile.client.view.list; import java.util.Vector; import org.tolven.mobile.client.control.Controller; import org.tolven.mobile.client.data.MenuData; import org.tolven.mobile.client.data.Patient; import org.tolven.mobile.client.data.Problem; public class ProblemsPage extends ListPage { Patient patient; public ProblemsPage(Patient patient, Controller controller ) { super( "Problems", controller); this.patient = patient; } /** * Provide the query string * @return */ public String getQuery( ) { return "ephr:patient-"+patient.getId()+":hx:problems"; } public MenuData createItem( String line ) { return new Problem( line ); } public Vector getList( ) { return patient.getProblems(); } } --- NEW FILE: DiagnosisPage.java --- package org.tolven.mobile.client.view.list; import java.util.Vector; import org.tolven.mobile.client.control.Controller; import org.tolven.mobile.client.data.Diagnosis; import org.tolven.mobile.client.data.MenuData; import org.tolven.mobile.client.data.Patient; public class DiagnosisPage extends ListPage { Patient patient; public DiagnosisPage(Patient patient, Controller controller ) { super( "Diagnoses", controller); this.patient = patient; } /** * Provide the query string * @return */ public String getQuery( ) { return "ephr:patient-"+patient.getId()+":XXXXXXXXXXXXX"; } public MenuData createItem( String line ) { return new Diagnosis( line ); } public Vector getList( ) { return patient.getDiagnosis(); } } --- NEW FILE: ResultsPage.java --- package org.tolven.mobile.client.view.list; import java.util.Vector; import org.tolven.mobile.client.control.Controller; import org.tolven.mobile.client.data.MenuData; import org.tolven.mobile.client.data.Patient; import org.tolven.mobile.client.data.Result; public class ResultsPage extends ListPage { Patient patient; public ResultsPage(Patient patient, Controller controller ) { super( "Results", controller); this.patient = patient; } /** * Provide the query string * @return */ public String getQuery( ) { return "ephr:patient-"+patient.getId()+":results:lab"; } public MenuData createItem( String line ) { return new Result( line ); } public Vector getList( ) { return patient.getResults(); } } --- NEW FILE: ProceduresPage.java --- package org.tolven.mobile.client.view.list; import java.util.Vector; import org.tolven.mobile.client.control.Controller; import org.tolven.mobile.client.data.MenuData; import org.tolven.mobile.client.data.Patient; import org.tolven.mobile.client.data.Procedure; public class ProceduresPage extends ListPage { Patient patient; public ProceduresPage(Patient patient, Controller controller ) { super( "Procedures", controller); this.patient = patient; } /** * Provide the query string * @return */ public String getQuery( ) { return "ephr:patient-"+patient.getId()+":XXXXXXXXXXXXXXXX"; } public MenuData createItem( String line ) { return new Procedure( line ); } public Vector getList( ) { return patient.getProcedures(); } } --- NEW FILE: AllPatientReminders.java --- package org.tolven.mobile.client.view.list; import org.tolven.mobile.client.control.Controller; import org.tolven.mobile.client.data.AllPatientData; import org.tolven.mobile.client.view.TolvenPage; public class AllPatientReminders extends TolvenPage { AllPatientData allPatient; public AllPatientReminders(AllPatientData allPatient, String formName, Controller controller) { super(formName, controller); this.allPatient = allPatient; } } --- NEW FILE: MedicationsPage.java --- package org.tolven.mobile.client.view.list; import java.util.Vector; import org.tolven.mobile.client.control.Controller; import org.tolven.mobile.client.data.Medication; import org.tolven.mobile.client.data.MenuData; import org.tolven.mobile.client.data.Patient; public class MedicationsPage extends ListPage { Patient patient; public MedicationsPage(Patient patient, Controller controller ) { super( "Medications", controller); this.patient = patient; } /** * Provide the query string * @return */ public String getQuery( ) { return "ephr:patient-"+patient.getId()+":med:meds"; } public MenuData createItem( String line ) { return new Medication( line ); } public Vector getList( ) { return patient.getMedications(); } } |