### Eclipse Workspace Patch 1.0 #P OMRS-logic Index: web/module/deleteSuccessToken.jsp =================================================================== --- web/module/deleteSuccessToken.jsp (revision 0) +++ web/module/deleteSuccessToken.jsp (revision 0) @@ -0,0 +1,3 @@ +<%@ include file="/WEB-INF/template/include.jsp" %> + + \ No newline at end of file Index: web/module/editSuccessToken.jsp =================================================================== --- web/module/editSuccessToken.jsp (revision 0) +++ web/module/editSuccessToken.jsp (revision 0) @@ -0,0 +1,3 @@ +<%@ include file="/WEB-INF/template/include.jsp" %> + + \ No newline at end of file Index: metadata/messages.properties =================================================================== --- metadata/messages.properties (revision 12751) +++ metadata/messages.properties (working copy) @@ -20,3 +20,25 @@ logic.init.status.running = Default Logic Rule Registration running logic.init.status.complete = Default Logic Rule Registration complete. logic.init.submit.button = Run now... + +logic.logicTokenForm.empty = All The Fields Have To Be Filled +logic.tokens.list.title = Available Tokens +logic.tokens.individual.Detail = Token Info +logic.token.string = Token Name +logic.token.className = Token Class Name +logic.token.error.class.name = Class Name cannot be empty +logic.token.manage.title = Individual Token Management +logic.token.state = Token State +logic.token.error.token = Token value cannot be empty +logic.token.error.state = State value cannot be empty +logic.token.tag.values = Tagged Values +logic.token.save = Save Changes +logic.token.saved = Token Saved +logic.token.delete = Delete +logic.view.token = Registered Tokens +logic.token.error.general = Error while submitting form +logic.token.error = Token value cannot be empty +logic.field.blank = Fields Cannot be left blank +logic.parameter.blank = Parameters cannot be left blank +logic.delete.success = Successfully Deleted +logic.delete.notsuccess = Not deleted \ No newline at end of file Index: web/module/tokenInit.jsp =================================================================== --- web/module/tokenInit.jsp (revision 0) +++ web/module/tokenInit.jsp (revision 0) @@ -0,0 +1,46 @@ +<%@ include file="/WEB-INF/template/include.jsp" %> +<%@ include file="/WEB-INF/template/header.jsp"%> + + + + + + + + + + + + + +"/> +
+ + + +<%@ include file="/WEB-INF/template/footer.jsp" %> + \ No newline at end of file Index: patch.diff =================================================================== --- patch.diff (revision 0) +++ patch.diff (revision 0) @@ -0,0 +1,852 @@ +### Eclipse Workspace Patch 1.0 +#P OMRS-logic +Index: metadata/messages.properties +=================================================================== +--- metadata/messages.properties (revision 12751) ++++ metadata/messages.properties (working copy) +@@ -20,3 +20,21 @@ + logic.init.status.running = Default Logic Rule Registration running + logic.init.status.complete = Default Logic Rule Registration complete. + logic.init.submit.button = Run now... ++ ++logic.logicTokenForm.empty = All The Fields Have To Be Filled ++logic.tokens.list.title = Available Tokens ++logic.tokens.individual.Detail = Token Info ++logic.token.string = Token Name ++logic.token.className = Token Class Name ++logic.token.error.class.name = Class Name cannot be empty ++logic.token.manage.title = Individual Token Management ++logic.token.state = Token State ++logic.token.error.token = Token value cannot be empty ++logic.token.error.state = State value cannot be empty ++logic.token.tag.values = Tagged Values ++logic.token.save = Save Changes ++logic.token.saved = Token Saved ++logic.token.delete = Delete ++logic.view.token = Registered TOkens ++logic.token.error.general = Error while submitting form ++logic.token.error = Token value cannot be empty +\ No newline at end of file +Index: patch.diff +=================================================================== +Index: src/api/org/openmrs/logic/rule/ReferenceRule.java +=================================================================== +--- src/api/org/openmrs/logic/rule/ReferenceRule.java (revision 12751) ++++ src/api/org/openmrs/logic/rule/ReferenceRule.java (working copy) +@@ -13,6 +13,7 @@ + */ + package org.openmrs.logic.rule; + ++ + import java.util.Map; + import java.util.Set; + +Index: src/api/org/openmrs/logic/extension/html/AdminList.java +=================================================================== +--- src/api/org/openmrs/logic/extension/html/AdminList.java (revision 12751) ++++ src/api/org/openmrs/logic/extension/html/AdminList.java (working copy) +@@ -20,6 +20,7 @@ + Map localHashMap = new LinkedHashMap(); + localHashMap.put("/module/logic/init.form", "logic.init.title"); + localHashMap.put("/module/logic/logic.form", "logic.start.title"); ++ localHashMap.put("/module/logic/tokensList.list", "logic.view.token"); + return localHashMap; + } + } +Index: src/api/org/openmrs/logic/LogicCache.java +=================================================================== +--- src/api/org/openmrs/logic/LogicCache.java (revision 12751) ++++ src/api/org/openmrs/logic/LogicCache.java (working copy) +@@ -28,7 +28,8 @@ + * A caching mechanism used by LogicContext to avoid recalculating a re-fetching the same results + * more than once during a single request of the logic service. + */ +-public class LogicCache { ++public class LogicCache ++{ + + private static Log log = LogFactory.getLog(LogicCache.class); + +Index: src/api/org/openmrs/logic/LogicRuleToken.java +=================================================================== +--- src/api/org/openmrs/logic/LogicRuleToken.java (revision 12751) ++++ src/api/org/openmrs/logic/LogicRuleToken.java (working copy) +@@ -27,8 +27,13 @@ + * Rule. Token is the ingredient to instantiate a rule. You can think of + * a LogicToken is a serialized version of a Rule + */ +-public class LogicRuleToken extends BaseOpenmrsObject implements Auditable { ++public class LogicRuleToken extends BaseOpenmrsObject implements Auditable{ + ++ /** ++ * ++ */ ++ //private static final long serialVersionUID = 1L; ++ + private Integer ruleTokenId; + + private User creator; +@@ -51,25 +56,44 @@ + // tags associated with this token + private Set ruleTokenTags; + ++// private Rule rule; ++ ++ ++ ++ + /** + * + */ +- public LogicRuleToken() { ++ public LogicRuleToken() ++ { ++ + } + + /** + * + */ +- public LogicRuleToken(String token, Rule rule) { ++ public LogicRuleToken(String token, Rule rule) ++ { + setToken(token); + setClassName(rule.getClass().getCanonicalName()); + if (StatefulRule.class.isAssignableFrom(rule.getClass())) + setState(((StatefulRule) rule).saveToString()); ++ + } + + /** + * @see org.openmrs.Auditable#getChangedBy() + */ ++ ++// public void setRule(Rule rule) ++// { ++// this.rule=rule; ++// } ++// ++// public Rule getRule() ++// { ++// return this.rule; ++// } + public User getChangedBy() { + return changedBy; + } +@@ -84,7 +108,8 @@ + /** + * @see org.openmrs.Auditable#getDateChanged() + */ +- public Date getDateChanged() { ++ public Date getDateChanged() ++ { + return dateChanged; + } + +@@ -147,10 +172,14 @@ + /** + * @param token the token to set + */ +- public void setToken(String token) { ++ public void setToken(String token) ++ { + this.token = token; ++ + } + ++ ++ + /** + * @return the className + */ +@@ -161,7 +190,8 @@ + /** + * @param className the className to set + */ +- public void setClassName(String className) { ++ public void setClassName(String className) ++ { + this.className = className; + } + +@@ -175,14 +205,16 @@ + /** + * @param state the state to set + */ +- public void setState(String state) { ++ public void setState(String state) ++ { + this.state = state; + } + + /** + * @return the tokenTags + */ +- public Set getRuleTokenTags() { ++ public Set getRuleTokenTags() ++ { + if (ruleTokenTags == null) + ruleTokenTags = new HashSet(); + return ruleTokenTags; +@@ -191,8 +223,12 @@ + /** + * @param ruleTokenTags the ruleTokenTags to set + */ +- public void setRuleTokenTags(Set ruleTokenTags) { ++ public void setRuleTokenTags(Set ruleTokenTags) ++ { + this.ruleTokenTags = ruleTokenTags; ++ ++ ++ + } + + /** +@@ -205,14 +241,16 @@ + /** + * @param tokenId the tokenId to set + */ +- public void setRuleTokenId(Integer tokenId) { ++ public void setRuleTokenId(Integer tokenId) ++ { + this.ruleTokenId = tokenId; + } + + /** + * @param tag the tag that will be added to the set of tags for this token + */ +- public void addTag(String tag) { ++ public void addTag(String tag) ++ { + getRuleTokenTags().add(tag); + } + +@@ -227,7 +265,11 @@ + * @param tag + * @return + */ +- public boolean hasTag(String tag) { ++ public boolean hasTag(String tag) ++ { + return getRuleTokenTags().contains(tag); + } ++ ++ ++ + } +Index: src/api/org/openmrs/logic/impl/RuleFactory.java +=================================================================== +--- src/api/org/openmrs/logic/impl/RuleFactory.java (revision 12751) ++++ src/api/org/openmrs/logic/impl/RuleFactory.java (working copy) +@@ -167,6 +167,7 @@ + logicToken.addTag(tags[i]); + } + } ++ + // fill the audit section + // logicToken.setCreator(Context.getAuthenticatedUser()); + // logicToken.setDateCreated(new Date()); +Index: web/src/org/openmrs/logic/web/controller/TokensListController.java +=================================================================== +--- web/src/org/openmrs/logic/web/controller/TokensListController.java (revision 0) ++++ web/src/org/openmrs/logic/web/controller/TokensListController.java (revision 0) +@@ -0,0 +1,170 @@ ++package org.openmrs.logic.web.controller; ++ ++ ++import java.util.Collections; ++ ++import java.util.List; ++ ++ ++import org.apache.commons.logging.Log; ++import org.apache.commons.logging.LogFactory; ++import org.openmrs.api.APIException; ++import org.openmrs.api.context.Context; ++import org.openmrs.logic.LogicService; ++ ++import org.springframework.beans.propertyeditors.CustomNumberEditor; ++import org.springframework.dao.DataIntegrityViolationException; ++import org.springframework.web.bind.ServletRequestDataBinder; ++ ++import javax.servlet.ServletException; ++import javax.servlet.http.HttpServletRequest; ++import javax.servlet.http.HttpServletResponse; ++import javax.servlet.http.HttpSession; ++ ++import org.openmrs.web.WebConstants; ++ ++import org.springframework.validation.BindException; ++import org.springframework.web.servlet.ModelAndView; ++import org.springframework.web.servlet.mvc.SimpleFormController; ++import org.springframework.web.servlet.view.RedirectView; ++ ++public class TokensListController extends SimpleFormController { ++ ++ /** Logger for this class and subclasses */ ++ protected final Log log = LogFactory.getLog(getClass()); ++ ++ /** ++ * Allows for Integers to be used as values in input tags. Normally, only strings and lists are ++ * expected ++ * ++ * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, ++ * org.springframework.web.bind.ServletRequestDataBinder) ++ */ ++ protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { ++ super.initBinder(request, binder); ++ binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); ++ } ++ ++ /** ++ * The onSubmit function receives the form/command object that was modified by the input form ++ * and saves it to the db ++ * ++ * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest, ++ * javax.servlet.http.HttpServletResponse, java.lang.Object, ++ * org.springframework.validation.BindException) ++ */ ++ protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, ++ BindException errors) throws Exception { ++ ++ HttpSession httpSession = request.getSession(); ++ ++ System.out.println("Entered in to onSubmit of tokeListController"); ++ ++ ++ String view = getFormView(); ++ if (Context.hasPrivilege("View Administration Functions")) ++ { ++ System.out.println("user has the privileges ro go further in to onSubmit of tokeListController"); ++ String success = ""; ++ String error = ""; ++ ++ ++ ++ String[] ruleTokenList = request.getParameterValues("tokenName"); ++ ++ ++ ++ String deleted = "Deleted"; ++ String notDeleted = "Not Deleted"; ++ ++ LogicService logicService = Context.getLogicService(); ++ if(ruleTokenList!=null) ++ { ++ for (String p : ruleTokenList) ++ { ++ ++ try{ ++ ++ logicService.removeRule(p); ++ if (!success.equals("")) ++ success += "
"; ++ success += p + " " + deleted; ++ } ++ ++ catch (DataIntegrityViolationException e) { ++ error = handleTokensIntegrityException(e, error, notDeleted); ++ } ++ catch (APIException e) { ++ error = handleTokensIntegrityException(e, error, notDeleted); ++ } ++ ++ System.out.println("The success message in onsubmit is "+success); ++ } ++ ++ } ++ ++ else ++ error = "Token Not Selected"; ++ ++ ++ ++ view = getSuccessView(); ++ if (!success.equals("")) ++ httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success); ++ if (!error.equals("")) ++ httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error); ++ } ++ ++ return new ModelAndView(new RedirectView(view)); ++ } ++ ++ ++ ++ /** ++ * Logs a Token/Rule delete data integrity violation exception and returns a user friedly message ++ * of the problem that occured. ++ * ++ * @param e the exception. ++ * @param error the error message. ++ * @param notDeleted the not deleted error message. ++ * @return the formatted error message. ++ */ ++ private String handleTokensIntegrityException(Exception e, String error, String notDeleted) { ++ log.warn("Error deleting Token", e); ++ if (!error.equals("")) ++ error += "
"; ++ error += notDeleted; ++ return error; ++ } ++ ++ ++protected Object formBackingObject(HttpServletRequest request) throws ServletException { ++ ++ ++ System.out.println("Entered in to formBackingObjectMethod of tokeList.list"); ++ ++ List ruleTokenList=null; ++ ++ if (Context.hasPrivilege("View Administration Functions")) ++ { ++ ++ LogicService logicService = Context.getLogicService(); ++ ruleTokenList = logicService.getAllTokens(); ++ ++ Collections.sort(ruleTokenList); ++ ++ ++ } ++ ++ else ++ { ++ //tokens ++ //tokens.add("Error"); ++ ++ } ++ ++ ++ return ruleTokenList; ++ } ++ ++} +Index: web/module/logicTokenForm.jsp +=================================================================== +--- web/module/logicTokenForm.jsp (revision 0) ++++ web/module/logicTokenForm.jsp (revision 0) +@@ -0,0 +1,127 @@ ++ ++<%@ include file="/WEB-INF/template/include.jsp" %> ++<%@ include file="/WEB-INF/template/header.jsp"%> ++ ++ ++ ++

++ ++ ++ ++ ++ ++ ++ ++ ++ ++
++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
++ "> ++ ++
++ "> ++ ++
++ "> ++ ++
++"> ++
++ ++ ++ ++
++ ++ +Index: web/module/tokensList.jsp +=================================================================== +--- web/module/tokensList.jsp (revision 0) ++++ web/module/tokensList.jsp (revision 0) +@@ -0,0 +1,32 @@ ++<%@ include file="/WEB-INF/template/include.jsp" %> ++<%@ include file="/WEB-INF/template/header.jsp"%> ++ ++ ++ ++ ++ ++
++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
++ "> ++ ++ "> ++ ++ ++
++ "> ++
++ ++<%@ include file="/WEB-INF/template/footer.jsp" %> +\ No newline at end of file +Index: metadata/config.xml +=================================================================== +--- metadata/config.xml (revision 12751) ++++ metadata/config.xml (working copy) +@@ -8,9 +8,7 @@ + 0.4 + org.openmrs.@MODULE_ID@ + OpenMRS Core Developer +- +- +- ++ + @MODULE_PACKAGE@.LogicModuleActivator + https://dev.openmrs.org/modules/download/@MODULE_ID@/update.rdf + +Index: web/src/org/openmrs/logic/web/controller/LogicInitController.java +=================================================================== +--- web/src/org/openmrs/logic/web/controller/LogicInitController.java (revision 12751) ++++ web/src/org/openmrs/logic/web/controller/LogicInitController.java (working copy) +@@ -41,7 +41,8 @@ + */ + @RequestMapping("/module/logic/load") + public void runInit() { +- if (Context.hasPrivilege("View Administration Functions")) { ++ if (Context.hasPrivilege("View Administration Functions")) ++ { + isInitRunning = ProcessStatus.STATUS_ON; + LogicUtil.registerDefaultRules(); + isInitRunning = ProcessStatus.STATUS_OFF; +Index: src/api/org/openmrs/logic/db/hibernate/HibernateLogicRuleTokenDAO.java +=================================================================== +--- src/api/org/openmrs/logic/db/hibernate/HibernateLogicRuleTokenDAO.java (revision 12751) ++++ src/api/org/openmrs/logic/db/hibernate/HibernateLogicRuleTokenDAO.java (working copy) +@@ -65,7 +65,8 @@ + /** + * @see org.openmrs.logic.db.LogicRuleTokenDAO#saveLogicRuleToken(org.openmrs.logic.LogicRuleToken) + */ +- public LogicRuleToken saveLogicRuleToken(LogicRuleToken logicToken) throws DAOException { ++ public LogicRuleToken saveLogicRuleToken(LogicRuleToken logicToken) throws DAOException ++ { + sessionFactory.getCurrentSession().saveOrUpdate(logicToken); + return logicToken; + } +@@ -74,6 +75,8 @@ + * @see org.openmrs.logic.db.LogicRuleTokenDAO#getLogicRuleToken(java.lang.String) + */ + public LogicRuleToken getLogicRuleToken(String token) { ++ System.out.println("Entered in to dangerous area"); ++ System.out.println("The value of the session at hibernate level"+sessionFactory.getCurrentSession()); + return (LogicRuleToken) sessionFactory.getCurrentSession().createQuery( + "from LogicRuleToken logicRuleToken where logicRuleToken.token = :token").setString("token", token) + .uniqueResult(); +Index: web/src/org/openmrs/logic/web/controller/LogicTokenFormController.java +=================================================================== +--- web/src/org/openmrs/logic/web/controller/LogicTokenFormController.java (revision 0) ++++ web/src/org/openmrs/logic/web/controller/LogicTokenFormController.java (revision 0) +@@ -0,0 +1,159 @@ ++package org.openmrs.logic.web.controller; ++ ++ ++ ++import javax.servlet.ServletException; ++import javax.servlet.http.HttpServletRequest; ++import javax.servlet.http.HttpServletResponse; ++import javax.servlet.http.HttpSession; ++import org.apache.commons.logging.Log; ++import org.apache.commons.logging.LogFactory; ++import org.openmrs.api.context.Context; ++import org.openmrs.logic.LogicRuleToken; ++import org.openmrs.logic.LogicService; ++import org.openmrs.logic.Rule; ++import org.openmrs.logic.StatefulRule; ++import org.openmrs.web.WebConstants; ++import org.springframework.beans.propertyeditors.CustomNumberEditor; ++import org.springframework.validation.BindException; ++import org.springframework.web.bind.ServletRequestDataBinder; ++import org.springframework.web.servlet.ModelAndView; ++import org.springframework.web.servlet.mvc.SimpleFormController; ++import org.springframework.web.servlet.view.RedirectView; ++ ++public class LogicTokenFormController extends SimpleFormController { ++ ++ /** Logger for this class and subclasses */ ++ protected final Log log = LogFactory.getLog(getClass()); ++ ++ /** ++ * Allows for Integers to be used as values in input tags. Normally, only strings and lists are ++ * expected ++ * ++ * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, ++ * org.springframework.web.bind.ServletRequestDataBinder) ++ */ ++ protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { ++ super.initBinder(request, binder); ++ //NumberFormat nf = NumberFormat.getInstance(new Locale("en_US")); ++ binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); ++ } ++ ++ /** ++ * The onSubmit function receives the form/command object that was modified by the input form ++ * and saves it to the db ++ * ++ * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest, ++ * javax.servlet.http.HttpServletResponse, java.lang.Object, ++ * org.springframework.validation.BindException) ++ */ ++ protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, ++ BindException errors) throws Exception { ++ ++ HttpSession httpSession = request.getSession(); ++ String view = getFormView(); ++ ++ ++ String requestTokenName = request.getParameter("newTokenName").trim().toString(); ++ String requestTokenState = request.getParameter("newTokenState").trim().toString(); ++ String requestTokenClass = request.getParameter("newClassName").trim().toString(); ++ ++ ++ LogicRuleToken logicToken = (LogicRuleToken) obj; ++ ++ if (Context.hasPrivilege("View Administration Functions")) ++ { ++ ++ System.out.println("onSubmit of LogicTokenFormController has admin privileges"); ++ try ++ { ++ LogicService logicService = Context.getLogicService(); ++ Class c = Context.loadClass(requestTokenClass); ++ Object obj1 = c.newInstance(); ++ Rule rule = (Rule) obj1; ++ ++ if(requestTokenClass.equalsIgnoreCase("org.openmrs.logic.rule.ReferenceRule")) ++ { ++ ++ ((StatefulRule)rule).restoreFromString(requestTokenState); ++ } ++ ++ ++ ++ String tempToken=logicToken.getToken(); ++ logicService.removeRule(tempToken); ++ logicService.updateRule(requestTokenName, rule); ++ ++ ++ ++ view = getSuccessView(); ++ httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "logic.token.saved"); ++ httpSession.setAttribute("ruleTokenID", requestTokenName); ++ ++ } ++ ++ catch(Exception ex) ++ { ++ ex.printStackTrace(); ++ } ++ ++ ++ ++ } ++ ++ return new ModelAndView(new RedirectView(view)); ++ ++ } ++ ++ ++ ++ ++ /** ++ * This is called prior to displaying a form for the first time. It tells Spring the ++ * form/command object to load into the request ++ * ++ * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) ++ */ ++ protected Object formBackingObject(HttpServletRequest request) throws ServletException { ++ ++ ++ ++ HttpSession httpSession = request.getSession(); ++ System.out.println("Entered in to formBackingObjectMethod of LogicToken.form"); ++ ++ LogicRuleToken logicToken=null; ++ String requestToken =null; ++ ++ ++ if((request.getParameter("ruleToken"))!=null) ++ { ++ requestToken = request.getParameter("ruleToken"); ++ } ++ ++ else ++ { ++ requestToken = (String)httpSession.getAttribute("ruleTokenID"); ++ } ++ ++ ++ System.out.println("The value used to view the token is "+requestToken); ++ if (requestToken != null) ++ { ++ LogicService logicService = Context.getLogicService(); ++ ++ Rule rule=logicService.getRule(requestToken); ++ logicToken=new LogicRuleToken(requestToken,rule); ++ ++ ++ } ++ if(logicToken == null) ++ new LogicRuleToken(); ++ ++ ++ ++ ++ return logicToken; ++ } ++ ++ ++} +Index: metadata/moduleApplicationContext.xml +=================================================================== +--- metadata/moduleApplicationContext.xml (revision 12751) ++++ metadata/moduleApplicationContext.xml (working copy) +@@ -19,6 +19,34 @@ + + + ++ ++ ++ ++ ++ tokensList ++ logicTokenForm ++ ++ ++ ++ ++ ++ true ++ ruleTokenList ++ /module/logic/tokensList ++ tokensList.list ++ ++ ++ ++ ++ ++ true ++ logicToken ++ /module/logic/logicTokenForm ++ logicToken.form ++ ++ ++ ++ + + + +Index: dist/logic-0.4.omod +=================================================================== +Cannot display: file marked as a binary type. +svn:mime-type = application/octet-stream Index: src/api/org/openmrs/logic/extension/html/AdminList.java =================================================================== --- src/api/org/openmrs/logic/extension/html/AdminList.java (revision 12751) +++ src/api/org/openmrs/logic/extension/html/AdminList.java (working copy) @@ -20,6 +20,7 @@ Map localHashMap = new LinkedHashMap(); localHashMap.put("/module/logic/init.form", "logic.init.title"); localHashMap.put("/module/logic/logic.form", "logic.start.title"); + localHashMap.put("/module/logic/tokenInit.list", "logic.view.token"); return localHashMap; } } Index: web/module/token.jsp =================================================================== --- web/module/token.jsp (revision 0) +++ web/module/token.jsp (revision 0) @@ -0,0 +1,32 @@ +<%@ include file="/WEB-INF/template/include.jsp" %> +<%@ include file="/WEB-INF/template/header.jsp"%> + + + + + +
+ + + + + + + + + + + + + +
+ "> + + "> + + +
+ "> +
+ +<%@ include file="/WEB-INF/template/footer.jsp" %> \ No newline at end of file Index: patch2.diff =================================================================== Index: web/src/org/openmrs/logic/web/controller/TokenController.java =================================================================== --- web/src/org/openmrs/logic/web/controller/TokenController.java (revision 0) +++ web/src/org/openmrs/logic/web/controller/TokenController.java (revision 0) @@ -0,0 +1,313 @@ +/** + * The contents of this file are subject to the OpenMRS Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://license.openmrs.org + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + * License for the specific language governing rights and limitations + * under the License. + * + * Copyright (C) OpenMRS, LLC. All Rights Reserved. + */ + +package org.openmrs.logic.web.controller; + + +import java.util.Collections; + +import java.util.List; +import java.util.ArrayList; +import java.util.Vector; + + + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openmrs.Patient; +import org.openmrs.api.APIException; +import org.openmrs.api.context.Context; +import org.openmrs.logic.LogicService; +import org.openmrs.messagesource.MessageSourceService; + +import org.springframework.beans.propertyeditors.CustomNumberEditor; +import org.springframework.context.support.MessageSourceAccessor; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.web.bind.ServletRequestDataBinder; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.openmrs.web.WebConstants; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.validation.BindException; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.mvc.SimpleFormController; +import org.springframework.web.servlet.view.RedirectView; + + + +import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable; +@Controller +public class TokenController { + + /** Logger for this class and subclasses */ + protected final Log log = LogFactory.getLog(getClass()); + + /** + * Initializes the entire process of viewing, editing and updating the Default Registered Tokens + * Responsible for performing ajax calls for corresponding pages + * + * + */ + + @RequestMapping(value = "/module/logic/tokenInit", method = RequestMethod.GET) + public void init(HttpServletRequest request, ModelMap model) + { + HttpSession session=request.getSession(); + int initPageValue=1; + log.debug("Entered in to the initialization stage of TokenController"); + + if((Integer)(session.getAttribute("requestPageNumberSession"))!=null) + { + model.addAttribute("reqPageNum", (Integer)(session.getAttribute("requestPageNumberSession"))); + } + + else + { + model.addAttribute("reqPageNum", initPageValue); + } + } + + /** + * Performing the Delete operation of entire tokens + * + * + */ + @RequestMapping(value = "/module/logic/deleteSuccessToken", method = RequestMethod.POST) + protected void onSubmit(HttpServletRequest request, ModelMap map) throws Exception { + HttpSession httpSession = request.getSession(); + + + + log.debug("Entered in to onSubmit of tokeListController"); + MessageSourceService msa = Context.getMessageSourceService(); + + if (Context.hasPrivilege("View Administration Functions")) + { + + + log.debug("user has the privileges ro go further in to onSubmit of tokeListController"); + String success = ""; + String error = ""; + + + + String[] ruleTokenList = request.getParameterValues("tokenName"); + + + + + String deleted = msa.getMessage("logic.delete.success"); + String notDeleted = msa.getMessage("logic.delete.notsuccess"); + + LogicService logicService = Context.getLogicService(); + if(ruleTokenList!=null) + { + for (String p : ruleTokenList) + { + + try{ + + logicService.removeRule(p); + if (!success.equals("")) + success += "
"; + success += p + " " + deleted; + } + + catch (DataIntegrityViolationException e) + { + error = handleTokensIntegrityException(e, error, notDeleted); + } + catch (APIException e) + { + error = handleTokensIntegrityException(e, error, notDeleted); + httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error); + } + + + log.debug("The success message in onsubmit is "+success); + } + + } + + else + error = notDeleted; + + + + + if (!success.equals("")) + httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success); + if (!error.equals("")) + httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error); + } + + + } + + + + /** + * Logs a Token/Rule delete data integrity violation exception and returns a user friedly message + * of the problem that occured. ++ * ++ * @param e the exception. ++ * @param error the error message. ++ * @param notDeleted the not deleted error message. ++ * @return the formatted error message. ++ */ + private String handleTokensIntegrityException(Exception e, String error, String notDeleted) { + log.warn("Error deleting Token", e); + if (!error.equals("")) + error += "
"; + error += notDeleted; + return error; + } + +/** + * Place holder for the token list. Performs the functionality of fetching necessary tokens + * + * @param model The ModelMap to be used by view to render page + */ + +@RequestMapping(value = "/module/logic/tokenTable") +public void showTokensListPage(HttpServletRequest request, ModelMap map) +{ + + HttpSession session=request.getSession(); + log.debug("Entered in to the showTokenListPage of TokenController"); + log.debug("Entered in to formBackingObjectMethod of tokeList.list"); + + int requestPageNumber=0; + + + requestPageNumber=Integer.parseInt((String)request.getParameter("page")); + List ruleTokenList=null; + Vector ruleFragmentedTokenList=new Vector(); + int pageNumbers=0; + ArrayList pageList = new ArrayList(); + + + + + log.debug("The value of the requested page is : "+requestPageNumber); + + if (Context.hasPrivilege("View Administration Functions")) + { + + log.debug("This user has the privileges : "); + LogicService logicService = Context.getLogicService(); + ruleTokenList = logicService.getAllTokens(); + log.debug("The ruleTokenList size is : "+ruleTokenList.size()); + Collections.sort(ruleTokenList); + + int size=ruleTokenList.size(); + + if(size%20!=0) + { + pageNumbers=(size/20)+1; + + } + + else + { + pageNumbers=(size/20); + + + } + + log.debug("The value od the page numbers : "+pageNumbers); + for(int i=1;i<=pageNumbers;i++) + { + pageList.add(i); + } + + log.debug("The object value of the page numbers : "+pageList.size()); + + int startingCountValue=((requestPageNumber-1)*20); + log.debug("The startign count value is : "+startingCountValue); + int finishingCountValue=(requestPageNumber*20); + if(finishingCountValue>ruleTokenList.size()) + { + finishingCountValue=ruleTokenList.size(); + } + log.debug("The finishing count value is : "+finishingCountValue); + + + String tempToeknValue=ruleTokenList.get(229); + + log.debug("229 th temporary token value is : "+tempToeknValue); + + + + int a=0; + + for(int i=startingCountValue; i0.4 org.openmrs.@MODULE_ID@ OpenMRS Core Developer - - - + @MODULE_PACKAGE@.LogicModuleActivator https://dev.openmrs.org/modules/download/@MODULE_ID@/update.rdf Index: web/src/org/openmrs/logic/web/controller/LogicInitController.java =================================================================== --- web/src/org/openmrs/logic/web/controller/LogicInitController.java (revision 12751) +++ web/src/org/openmrs/logic/web/controller/LogicInitController.java (working copy) @@ -41,7 +41,8 @@ */ @RequestMapping("/module/logic/load") public void runInit() { - if (Context.hasPrivilege("View Administration Functions")) { + if (Context.hasPrivilege("View Administration Functions")) + { isInitRunning = ProcessStatus.STATUS_ON; LogicUtil.registerDefaultRules(); isInitRunning = ProcessStatus.STATUS_OFF; Index: web/module/tokens.jsp =================================================================== --- web/module/tokens.jsp (revision 12751) +++ web/module/tokens.jsp (working copy) @@ -1,2 +1,3 @@ -<%@ include file="/WEB-INF/template/include.jsp"%>${keyword} +<%@ include file="/WEB-INF/template/include.jsp"%> +${keyword} \ No newline at end of file Index: src/api/org/openmrs/logic/db/hibernate/HibernateLogicRuleTokenDAO.java =================================================================== --- src/api/org/openmrs/logic/db/hibernate/HibernateLogicRuleTokenDAO.java (revision 12751) +++ src/api/org/openmrs/logic/db/hibernate/HibernateLogicRuleTokenDAO.java (working copy) @@ -65,7 +65,8 @@ /** * @see org.openmrs.logic.db.LogicRuleTokenDAO#saveLogicRuleToken(org.openmrs.logic.LogicRuleToken) */ - public LogicRuleToken saveLogicRuleToken(LogicRuleToken logicToken) throws DAOException { + public LogicRuleToken saveLogicRuleToken(LogicRuleToken logicToken) throws DAOException + { sessionFactory.getCurrentSession().saveOrUpdate(logicToken); return logicToken; } @@ -74,6 +75,8 @@ * @see org.openmrs.logic.db.LogicRuleTokenDAO#getLogicRuleToken(java.lang.String) */ public LogicRuleToken getLogicRuleToken(String token) { + System.out.println("Entered in to dangerous area"); + System.out.println("The value of the session at hibernate level"+sessionFactory.getCurrentSession()); return (LogicRuleToken) sessionFactory.getCurrentSession().createQuery( "from LogicRuleToken logicRuleToken where logicRuleToken.token = :token").setString("token", token) .uniqueResult(); Index: web/src/org/openmrs/logic/web/controller/LogicTokenController.java =================================================================== --- web/src/org/openmrs/logic/web/controller/LogicTokenController.java (revision 0) +++ web/src/org/openmrs/logic/web/controller/LogicTokenController.java (revision 0) @@ -0,0 +1,155 @@ +/** + * The contents of this file are subject to the OpenMRS Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://license.openmrs.org + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + * License for the specific language governing rights and limitations + * under the License. + * + * Copyright (C) OpenMRS, LLC. All Rights Reserved. + */ + +package org.openmrs.logic.web.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openmrs.api.context.Context; +import org.openmrs.logic.LogicRuleToken; +import org.openmrs.logic.LogicService; +import org.openmrs.logic.Rule; +import org.openmrs.logic.StatefulRule; +import org.openmrs.web.WebConstants; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +@Controller +public class LogicTokenController { + + /** Logger for this class and subclasses */ + protected final Log log = LogFactory.getLog(getClass()); + + + + /** ++ * The onSubmit function receives the form/command object that was modified by the token editing input form ++ * and saves it to the db ++ * ++ * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest, ++ * javax.servlet.http.HttpServletResponse, java.lang.Object, ++ * org.springframework.validation.BindException) ++ */ + @RequestMapping(value = "/module/logic/editSuccessToken", method = RequestMethod.POST) + public void onSubmit(HttpServletRequest request,ModelMap model,Object obj) throws Exception { + + HttpSession httpSession = request.getSession(); + String requestTokenState =null; + + + String requestTokenName = request.getParameter("newTokenName").trim().toString().toUpperCase(); + + //If the Rule is of Reference class then it will be having states. If not no states will be there. + if((request.getParameter("newClassName").trim().toString()).equalsIgnoreCase("org.openmrs.logic.rule.ReferenceRule")) + { + + requestTokenState = request.getParameter("newTokenState").trim().toString(); + } + + + String requestTokenClass = request.getParameter("newClassName").trim().toString(); + + + + String tempToken = request.getParameter("previousTokenName").trim().toString(); + + + if (Context.hasPrivilege("View Administration Functions")) + { + + log.debug("onSubmit of LogicTokenFormController has admin privileges"); + + LogicService logicService = Context.getLogicService(); + Class c = Context.loadClass(requestTokenClass); + Object obj1 = c.newInstance(); + Rule rule = (Rule) obj1; + + if(requestTokenClass.equalsIgnoreCase("org.openmrs.logic.rule.ReferenceRule")) + { + + ((StatefulRule)rule).restoreFromString(requestTokenState); + } + + + + + logicService.removeRule(tempToken); + logicService.updateRule(requestTokenName, rule); + + + + + httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "logic.token.saved"); + + + } + + + + } + + + + + /** + * This is called prior to displaying the token info for the first time. It tells Spring the + * form/command object to load into the request + * + * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) + */ + + + + + + @RequestMapping(value = "/module/logic/logicToken", method = RequestMethod.GET) + public @ModelAttribute("logicToken") Object showTokenDescriptionPage(@RequestParam(required = false, value = "ruleToken") String requestToken, ModelMap model) + { + log.debug("Entered in to formBackingObjectMethod of LogicToken.form"); + LogicRuleToken logicToken=null; + + + + + + + log.debug("Entered in to formBackingObjectMethod of LogicToken.form"); + if (requestToken != null) + { + LogicService logicService = Context.getLogicService(); + + Rule rule=logicService.getRule(requestToken); + logicToken=new LogicRuleToken(requestToken,rule); + + + } + if(logicToken == null) + new LogicRuleToken(); + + + log.debug("Completed Token Info fetching Operation"); + + return logicToken; + + + } + + +} \ No newline at end of file Index: web/module/tokenTable.jsp =================================================================== --- web/module/tokenTable.jsp (revision 0) +++ web/module/tokenTable.jsp (revision 0) @@ -0,0 +1,44 @@ +<%@ include file="/WEB-INF/template/include.jsp"%> + + + + + + + + + + + +
+ + + ${pList} + ${pList} + + +
+ +
+ + + + + + + + + + + + + +
+ "> + + "> + + +
+ "> +
\ No newline at end of file Index: metadata/moduleApplicationContext.xml =================================================================== --- metadata/moduleApplicationContext.xml (revision 12751) +++ metadata/moduleApplicationContext.xml (working copy) @@ -19,6 +19,7 @@ + Index: web/module/logicToken.jsp =================================================================== --- web/module/logicToken.jsp (revision 0) +++ web/module/logicToken.jsp (revision 0) @@ -0,0 +1,119 @@ +<%@ include file="/WEB-INF/template/include.jsp" %> +<%@ include file="/WEB-INF/template/header.jsp"%> + + + + + + + + + + + + +

+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ "> + "> +
+ "> + +
+ "> + +
+ "> +
+ + + +
+ + + \ No newline at end of file Index: dist/logic-0.4.omod =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream