List of usage examples for java.lang Integer equals
public boolean equals(Object obj)
From source file:net.droidsolutions.droidcharts.core.plot.XYPlot.java
/** * A utility method that returns a list of datasets that are mapped to a * particular axis.// ww w . j a v a 2s . c om * * @param axisIndex * the axis index (<code>null</code> not permitted). * * @return A list of datasets. */ private List getDatasetsMappedToRangeAxis(Integer axisIndex) { if (axisIndex == null) { throw new IllegalArgumentException("Null 'axisIndex' argument."); } List result = new ArrayList(); for (int i = 0; i < this.datasets.size(); i++) { List mappedAxes = (List) this.datasetToRangeAxesMap.get(new Integer(i)); if (mappedAxes == null) { if (axisIndex.equals(ZERO)) { result.add(this.datasets.get(i)); } } else { if (mappedAxes.contains(axisIndex)) { result.add(this.datasets.get(i)); } } } return result; }
From source file:net.droidsolutions.droidcharts.core.plot.XYPlot.java
/** * A utility method that returns a list of datasets that are mapped to a * particular axis./*from w w w . ja v a 2s . c o m*/ * * @param axisIndex * the axis index (<code>null</code> not permitted). * * @return A list of datasets. */ private List getDatasetsMappedToDomainAxis(Integer axisIndex) { if (axisIndex == null) { throw new IllegalArgumentException("Null 'axisIndex' argument."); } List result = new ArrayList(); for (int i = 0; i < this.datasets.size(); i++) { List mappedAxes = (List) this.datasetToDomainAxesMap.get(new Integer(i)); if (mappedAxes == null) { if (axisIndex.equals(ZERO)) { result.add(this.datasets.get(i)); } } else { if (mappedAxes.contains(axisIndex)) { result.add(this.datasets.get(i)); } } } return result; }
From source file:com.genscript.gsscm.product.service.ProductService.java
@Transactional(readOnly = true) public List<ProductPriceListBeanDTO> getProductPriceApproveList(Integer sessProductId) { List<Integer> objectIdList = approveRequestBeanDao .getApprovedRequestId(RequestApproveType.ProductPrice.name()); List<ProductPriceListBeanDTO> productPriceDTOList = new ArrayList<ProductPriceListBeanDTO>(); String catalogId = ""; Integer productId = 0;/*from w ww . ja v a 2 s. c o m*/ if (objectIdList != null && objectIdList.size() > 0) { // System.out.println(objectIdList.size()); ProductPrice productPrice = new ProductPrice(); for (Integer objectId : objectIdList) { productPrice = productPriceDao.getObjectByID(objectId); if (productPrice != null) { if (productPrice.getCatalogId() != null && productPrice.getProductId() != null) { catalogId = productPrice.getCatalogId(); productId = productPrice.getProductId(); if (sessProductId.equals(productId)) { ProductInCategoryBean productInCategoryBean = productInCategoryBeanDao .getBeanByBaseCatalog(catalogId, productId); if (productInCategoryBean != null) { List<ApproveRequestBean> approveRequestBeanList = approveRequestBeanDao .getApprovedRequest(objectId, RequestApproveType.ProductPrice.name()); if (approveRequestBeanList != null && approveRequestBeanList.size() > 0) { for (ApproveRequestBean approveRequestBean : approveRequestBeanList) { ProductPriceListBeanDTO productPriceListBeanDTO = new ProductPriceListBeanDTO(); productPriceListBeanDTO = dozer.map(productInCategoryBean, ProductPriceListBeanDTO.class); if (approveRequestBean.getColumnName().equals("standardPrice")) { productPriceListBeanDTO .setPriceNewVal(approveRequestBean.getNewValue()); productPriceListBeanDTO .setPriceOldVal(approveRequestBean.getOldValue()); productPriceListBeanDTO.setPriceReason(approveRequestBean.getReason()); productPriceListBeanDTO.setRequestId(approveRequestBean.getRequestId()); productPriceListBeanDTO .setRequestDate(approveRequestBean.getRequestDate()); productPriceListBeanDTO .setRequestedBy(approveRequestBean.getRequestedBy()); } productPriceDTOList.add(productPriceListBeanDTO); } } } } } } } } return productPriceDTOList; }
From source file:com.gst.portfolio.charge.serialization.ChargeDefinitionCommandFromApiJsonDeserializer.java
public void validateForCreate(final String json) { if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }/*from w w w .j a v a 2s .c o m*/ final Type typeOfMap = new TypeToken<Map<String, Object>>() { }.getType(); this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters); final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) .resource("charge"); final JsonElement element = this.fromApiJsonHelper.parse(json); final Integer chargeAppliesTo = this.fromApiJsonHelper.extractIntegerSansLocaleNamed("chargeAppliesTo", element); baseDataValidator.reset().parameter("chargeAppliesTo").value(chargeAppliesTo).notNull(); if (chargeAppliesTo != null) { baseDataValidator.reset().parameter("chargeAppliesTo").value(chargeAppliesTo) .isOneOfTheseValues(ChargeAppliesTo.validValues()); } final Integer chargeCalculationType = this.fromApiJsonHelper .extractIntegerSansLocaleNamed("chargeCalculationType", element); baseDataValidator.reset().parameter("chargeCalculationType").value(chargeCalculationType).notNull(); final Integer feeInterval = this.fromApiJsonHelper.extractIntegerNamed("feeInterval", element, Locale.getDefault()); baseDataValidator.reset().parameter("feeInterval").value(feeInterval).integerGreaterThanZero(); final Integer feeFrequency = this.fromApiJsonHelper.extractIntegerNamed("feeFrequency", element, Locale.getDefault()); baseDataValidator.reset().parameter("feeFrequency").value(feeFrequency).inMinMaxRange(0, 3); if (feeFrequency != null) { baseDataValidator.reset().parameter("feeInterval").value(feeInterval).notNull(); } final ChargeAppliesTo appliesTo = ChargeAppliesTo.fromInt(chargeAppliesTo); if (appliesTo.isLoanCharge()) { // loan applicable validation final Integer chargeTimeType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed("chargeTimeType", element); baseDataValidator.reset().parameter("chargeTimeType").value(chargeTimeType).notNull(); if (chargeTimeType != null) { baseDataValidator.reset().parameter("chargeTimeType").value(chargeTimeType) .isOneOfTheseValues(ChargeTimeType.validLoanValues()); } final Integer chargePaymentMode = this.fromApiJsonHelper .extractIntegerSansLocaleNamed("chargePaymentMode", element); baseDataValidator.reset().parameter("chargePaymentMode").value(chargePaymentMode).notNull() .isOneOfTheseValues(ChargePaymentMode.validValues()); if (chargePaymentMode != null) { baseDataValidator.reset().parameter("chargePaymentMode").value(chargePaymentMode) .isOneOfTheseValues(ChargePaymentMode.validValues()); } if (chargeCalculationType != null) { baseDataValidator.reset().parameter("chargeCalculationType").value(chargeCalculationType) .isOneOfTheseValues(ChargeCalculationType.validValuesForLoan()); } if (chargeTimeType != null && chargeCalculationType != null) { performChargeTimeNCalculationTypeValidation(baseDataValidator, chargeTimeType, chargeCalculationType); } } else if (appliesTo.isSavingsCharge()) { // savings applicable validation final Integer chargeTimeType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed("chargeTimeType", element); baseDataValidator.reset().parameter("chargeTimeType").value(chargeTimeType).notNull(); if (chargeTimeType != null) { baseDataValidator.reset().parameter("chargeTimeType").value(chargeTimeType) .isOneOfTheseValues(ChargeTimeType.validSavingsValues()); } final ChargeTimeType ctt = ChargeTimeType.fromInt(chargeTimeType); if (ctt.isWeeklyFee()) { final String monthDay = this.fromApiJsonHelper.extractStringNamed("feeOnMonthDay", element); baseDataValidator.reset().parameter("feeOnMonthDay").value(monthDay) .mustBeBlankWhenParameterProvidedIs("chargeTimeType", chargeTimeType); } if (ctt.isMonthlyFee()) { final MonthDay monthDay = this.fromApiJsonHelper.extractMonthDayNamed("feeOnMonthDay", element); baseDataValidator.reset().parameter("feeOnMonthDay").value(monthDay).notNull(); baseDataValidator.reset().parameter("feeInterval").value(feeInterval).notNull().inMinMaxRange(1, 12); } if (ctt.isAnnualFee()) { final MonthDay monthDay = this.fromApiJsonHelper.extractMonthDayNamed("feeOnMonthDay", element); baseDataValidator.reset().parameter("feeOnMonthDay").value(monthDay).notNull(); } if (chargeCalculationType != null) { baseDataValidator.reset().parameter("chargeCalculationType").value(chargeCalculationType) .isOneOfTheseValues(ChargeCalculationType.validValuesForSavings()); } } else if (appliesTo.isClientCharge()) { // client applicable validation final Integer chargeTimeType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed("chargeTimeType", element); baseDataValidator.reset().parameter("chargeTimeType").value(chargeTimeType).notNull(); if (chargeTimeType != null) { baseDataValidator.reset().parameter("chargeTimeType").value(chargeTimeType) .isOneOfTheseValues(ChargeTimeType.validClientValues()); } if (chargeCalculationType != null) { baseDataValidator.reset().parameter("chargeCalculationType").value(chargeCalculationType) .isOneOfTheseValues(ChargeCalculationType.validValuesForClients()); } // GL Account can be linked to clients if (this.fromApiJsonHelper.parameterExists(ChargesApiConstants.glAccountIdParamName, element)) { final Long glAccountId = this.fromApiJsonHelper .extractLongNamed(ChargesApiConstants.glAccountIdParamName, element); baseDataValidator.reset().parameter(ChargesApiConstants.glAccountIdParamName).value(glAccountId) .notNull().longGreaterThanZero(); } } else if (appliesTo.isSharesCharge()) { final Integer chargeTimeType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed("chargeTimeType", element); baseDataValidator.reset().parameter("chargeTimeType").value(chargeTimeType).notNull(); if (chargeTimeType != null) { baseDataValidator.reset().parameter("chargeTimeType").value(chargeTimeType) .isOneOfTheseValues(ChargeTimeType.validShareValues()); } if (chargeCalculationType != null) { baseDataValidator.reset().parameter("chargeCalculationType").value(chargeCalculationType) .isOneOfTheseValues(ChargeCalculationType.validValuesForShares()); } if (chargeTimeType != null && chargeTimeType.equals(ChargeTimeType.SHAREACCOUNT_ACTIVATION.getValue())) { if (chargeCalculationType != null) { baseDataValidator.reset().parameter("chargeCalculationType").value(chargeCalculationType) .isOneOfTheseValues(ChargeCalculationType.validValuesForShareAccountActivation()); } } } final String name = this.fromApiJsonHelper.extractStringNamed("name", element); baseDataValidator.reset().parameter("name").value(name).notBlank().notExceedingLengthOf(100); final String currencyCode = this.fromApiJsonHelper.extractStringNamed("currencyCode", element); baseDataValidator.reset().parameter("currencyCode").value(currencyCode).notBlank().notExceedingLengthOf(3); final BigDecimal amount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed("amount", element.getAsJsonObject()); baseDataValidator.reset().parameter("amount").value(amount).notNull().positiveAmount(); if (this.fromApiJsonHelper.parameterExists("penalty", element)) { final Boolean penalty = this.fromApiJsonHelper.extractBooleanNamed("penalty", element); baseDataValidator.reset().parameter("penalty").value(penalty).notNull(); } if (this.fromApiJsonHelper.parameterExists("active", element)) { final Boolean active = this.fromApiJsonHelper.extractBooleanNamed("active", element); baseDataValidator.reset().parameter("active").value(active).notNull(); } if (this.fromApiJsonHelper.parameterExists("minCap", element)) { final BigDecimal minCap = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed("minCap", element.getAsJsonObject()); baseDataValidator.reset().parameter("minCap").value(minCap).notNull().positiveAmount(); } if (this.fromApiJsonHelper.parameterExists("maxCap", element)) { final BigDecimal maxCap = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed("maxCap", element.getAsJsonObject()); baseDataValidator.reset().parameter("maxCap").value(maxCap).notNull().positiveAmount(); } if (this.fromApiJsonHelper.parameterExists(ChargesApiConstants.taxGroupIdParamName, element)) { final Long taxGroupId = this.fromApiJsonHelper.extractLongNamed(ChargesApiConstants.taxGroupIdParamName, element); baseDataValidator.reset().parameter(ChargesApiConstants.taxGroupIdParamName).value(taxGroupId).notNull() .longGreaterThanZero(); } throwExceptionIfValidationWarningsExist(dataValidationErrors); }
From source file:com.aurel.track.exchange.excel.ExcelImportBL.java
/** * Prepare the conflicts//from ww w . ja v a2 s . co m * * @param workItemBeansList * @param presentFieldIDs * @param personID * @param locale * @return */ static SortedMap<Integer, SortedMap<Integer, Map<Integer, Object>>> conflictResolutionWorkItems( Collection<TWorkItemBean> workItemBeansList, Set<Integer> presentFieldIDs, Map<Integer, WorkItemContext> existingIssueContextsMap, Map<Integer, Map<Integer, Map<Integer, TFieldConfigBean>>> projectsIssueTypesFieldConfigsMap, Map<Integer, String> columnIndexToColumNameMap, Map<Integer, Integer> fieldIDToColumnIndexMap, Integer personID, Locale locale, Map<String, Boolean> overwriteMap) { Map<Integer, Map<Integer, Boolean>> workItemAndFieldBasedMap = getWorkItemAndFieldBasedMap(overwriteMap); SortedMap<Integer, SortedMap<Integer, Map<Integer, Object>>> conflictsMap = new TreeMap<Integer, SortedMap<Integer, Map<Integer, Object>>>(); Iterator<TWorkItemBean> itrWorkItemBean = workItemBeansList.iterator(); Set<Integer> hardcodedExplicitHistoryFields = HistorySaverBL.getHardCodedExplicitHistoryFields(); int row = 1; Calendar calendar = Calendar.getInstance(); while (itrWorkItemBean.hasNext()) { TWorkItemBean workItemBean = itrWorkItemBean.next(); Integer workItemID = workItemBean.getObjectID(); row++; Map<Integer, TFieldConfigBean> fieldConfigsMap = projectsIssueTypesFieldConfigsMap .get(workItemBean.getProjectID()).get(workItemBean.getListTypeID()); WorkItemContext workItemContext = existingIssueContextsMap.get(workItemID); if (workItemContext != null) { // conflicts can happen only for existing workItems TWorkItemBean workItemBeanOriginal = workItemContext.getWorkItemBeanOriginal(); Date excelLastEdited = null; if (fieldIDToColumnIndexMap.get(SystemFields.INTEGER_LASTMODIFIEDDATE) != null) { // it was overwritten in workItemBean from excel only if the // field was mapped excelLastEdited = workItemBean.getLastEdit(); } if (workItemBeanOriginal != null) { List<Integer> changedFields = getFieldsChanged(workItemBean, workItemBeanOriginal, presentFieldIDs); if (changedFields == null || changedFields.isEmpty()) { // no field change at all -> no conflict continue; } SortedMap<Integer, Map<Integer, HistoryValues>> workItemHistoryChanges = null; Map<Integer, Boolean> fieldForWorkItemOverwrite = workItemAndFieldBasedMap.get(workItemID); /* * if (fieldForWorkItemOverwrite!=null) { //after submitting * the overwrite map (the conflict handling is done by the * user) for (Iterator<Integer> iterator = * changedFields.iterator(); iterator.hasNext();) { Integer * fieldID = iterator.next(); Boolean overwrite = * fieldForWorkItemOverwrite.get(fieldID); if * (overwrite==null || !overwrite.booleanValue()) { * //overwrite==null there was no conflict at all (no * checkbox was rendered) //if user decided to leave the * track+ value change back to original * workItemBean.setAttribute(fieldID, * workItemBeanOriginal.getAttribute(fieldID)); } } //once * fieldOverwrite is already specified no further conflict * processing is needed continue; } */ if (excelLastEdited == null) { // no last edit field specified, no usable history data // available at all: each field change means conflict for (Iterator<Integer> itrField = changedFields.iterator(); itrField.hasNext();) { Integer fieldID = itrField.next(); addAsConfict(conflictsMap, row, fieldID, workItemBean, workItemBeanOriginal, columnIndexToColumNameMap, fieldIDToColumnIndexMap, overwriteMap, fieldForWorkItemOverwrite, locale); if (LOGGER.isDebugEnabled()) { LOGGER.debug("WorkItem " + workItemBean.getObjectID() + " row " + row + " fieldID " + fieldID + " has conficts (no lastEdit specified)"); } } } else { // last edited is specified in excel: search the history // changed fields are either with explicit history or // not List<Integer> changedFieldsWithExplicitHistory = new LinkedList<Integer>(); List<Integer> changedFieldsWithoutExplicitHistory = new LinkedList<Integer>(); for (Iterator<Integer> iterator = changedFields.iterator(); iterator.hasNext();) { Integer fieldID = iterator.next(); TFieldConfigBean fieldConfigBean = fieldConfigsMap.get(fieldID); if (fieldConfigBean.isHistoryString() || hardcodedExplicitHistoryFields.contains(fieldID)) { changedFieldsWithExplicitHistory.add(fieldID); } else { changedFieldsWithoutExplicitHistory.add(fieldID); } } if (!changedFieldsWithoutExplicitHistory.isEmpty()) { // if at least one changed field hat no explicit // history then take the commons history field also changedFieldsWithExplicitHistory.add(TFieldChangeBean.COMPOUND_HISTORY_FIELD); } Integer[] changedFieldIDs = GeneralUtils.createIntegerArrFromIntArr( GeneralUtils.createIntArrFromIntegerList(changedFieldsWithExplicitHistory)); if (changedFieldsWithExplicitHistory != null && !changedFieldsWithExplicitHistory.isEmpty()) { // get the changes for fields since excelLastEdited: // explicit fields and // and the common field if at least one field hasn't // explicit history // TODO not really correct to add a minute but: // the last edited date from excel // (DateFormat.SHORT) doesn't contain seconds, // while the last history entry from the Genji // issue contains even milliseconds. // Consequently the history entry's date from Genji // is after the one exported to excel // even if in track+ no further history entry exists // (no further change was made). // Consequently we would generate false conflicts. // If we add this extra minute then we get rid of // those false conflicts but there is a small risk // that if also another change was made in the same // minute, it will be overwritten by excel value // without conflict warning calendar.setTime(excelLastEdited); calendar.add(Calendar.MINUTE, 1); workItemHistoryChanges = HistoryLoaderBL.getWorkItemRawHistory( workItemBean.getObjectID(), changedFieldIDs, null, calendar.getTime(), null); } if (workItemHistoryChanges != null) { // there is some history data for (Iterator<Integer> itrField = changedFieldsWithExplicitHistory.iterator(); itrField .hasNext();) { IFieldTypeRT fieldTypeRT = null; Integer fieldID = itrField.next(); if (!fieldID.equals(TFieldChangeBean.COMPOUND_HISTORY_FIELD)) { fieldTypeRT = FieldTypeManager.getFieldTypeRT(fieldID); } HistoryValues historyValues = null; for (Iterator<Integer> itrTransaction = workItemHistoryChanges.keySet() .iterator(); itrTransaction.hasNext();) { // get the first entry from the history // after excelLastEdited Integer transactionID = itrTransaction.next(); Map<Integer, HistoryValues> historyValuesMap = workItemHistoryChanges .get(transactionID); if (historyValuesMap.containsKey(fieldID)) { historyValues = historyValuesMap.get(fieldID); break; } } // changedFields contains fields with explicit // history, without explicit history and commons // field if (historyValues != null) {// if no history // value, no // conflict if (fieldTypeRT != null) {// explicit // history // the actual excel value differs from // the first oldValue -> the field was // probably changed in excel also if (fieldTypeRT.valueModified(workItemBean.getAttribute(fieldID), historyValues.getOldValue())) { // field with explicit history // changed in excel and track+: that // is a conflict addAsConfict(conflictsMap, row, fieldID, workItemBean, workItemBeanOriginal, columnIndexToColumNameMap, fieldIDToColumnIndexMap, overwriteMap, fieldForWorkItemOverwrite, locale); if (LOGGER.isDebugEnabled()) { LOGGER.debug("WorkItem " + workItemBean.getObjectID() + " row " + row + " fieldID " + fieldID + " has conficts (explicit history found)"); } } else { // the excel value is the same with // the first old value from the // history // since the excel last modified // date: the value was modified only // in track+, // leave the track+ version without // conflict resolution workItemBean.setAttribute(fieldID, workItemBeanOriginal.getAttribute(fieldID)); if (LOGGER.isDebugEnabled()) { LOGGER.debug("WorkItem " + workItemBean.getObjectID() + " row " + row + " fieldID " + fieldID + "no conflict (value changed only in Genji)"); } } } else { // common history: history for fields // without explicit history // add a conflict for each field without // explicit history for (Iterator<Integer> iterator = changedFieldsWithoutExplicitHistory .iterator(); iterator.hasNext();) { Integer fieldWithoutExplicitHistory = iterator.next(); addAsConfict(conflictsMap, row, fieldWithoutExplicitHistory, workItemBean, workItemBeanOriginal, columnIndexToColumNameMap, fieldIDToColumnIndexMap, overwriteMap, fieldForWorkItemOverwrite, locale); if (LOGGER.isDebugEnabled()) { LOGGER.debug("WorkItem " + workItemBean.getObjectID() + " row " + row + " fieldID " + fieldID + " has conficts (common history found)"); } } } } else { // no history entry found for field: the // field was modified only in excel, no // conflict handling needed if (LOGGER.isDebugEnabled()) { LOGGER.debug("WorkItem " + workItemBean.getObjectID() + " row " + row + " fieldID " + fieldID + " no conflict: no fieldID history found, value changed only in Excel)"); } } } } else { // no history entry found for the entire workItem: // the workItem was modified only in excel, no // conflict handling needed if (LOGGER.isDebugEnabled()) { LOGGER.debug("WorkItem " + workItemBean.getObjectID() + " row " + row + " no conflict: no workItem history found, value changed only in Excel"); } } } } } } return conflictsMap; }
From source file:org.openmrs.module.rwandaprimarycare.RwandaPrimaryCarePatientDashboardController.java
@RequestMapping("/module/rwandaprimarycare/patient") public String setupForm(@RequestParam("patientId") int patientId, @RequestParam(required = false, value = "skipPresentQuestion") Boolean skipPresentQuestion, @RequestParam(required = false, value = "printBarCode") Boolean printBarCode, @RequestParam(required = false, value = "serviceRequested") Integer serviceRequested, @RequestParam(required = false, value = "serviceRequestResponse") Integer serviceRequestResponse, @RequestParam(required = false, value = "gatherInsurance") Integer gatherInsurance, @RequestParam(required = false, value = "insuranceNumber") String insuranceNumber, @RequestParam(required = false, value = "insuranceType") Integer insuranceType, @RequestParam(required = false, value = "visitDate") Long visitDate, HttpSession session, ModelMap model) throws PrimaryCareException { //LK: Need to ensure that all primary care methods only throw a PrimaryCareException //So that errors will be directed to a touch screen error page try {/* ww w . j a v a 2 s . co m*/ // default to skipping the present question and not printing the bar code if (skipPresentQuestion == null) skipPresentQuestion = true; if (printBarCode == null) printBarCode = false; Patient patient = Context.getPatientService().getPatient(patientId); if (Context.getAdministrationService().getGlobalProperty("registration.overrideHealthCenterAttribute") .equals("true")) { PrimaryCareBusinessLogic.setHealthCenter(patient, PrimaryCareWebLogic.getCurrentLocation(session)); } // lazy loading for (PersonAttribute pa : patient.getAttributes()) { pa.getAttributeType().getName(); } for (PatientIdentifier pi : patient.getIdentifiers()) { pi.getLocation().getName(); } model.addAttribute(patient); //if patient doensn't have a primary identifier, generate one behind the scenes and save. //No UI necessary. // boolean needIDForThisLocation = PrimaryCareBusinessLogic.doesPatientNeedAnIDForThisLocation(patient, PrimaryCareWebLogic.getCurrentLocation(session)); if (needIDForThisLocation) { try { String addIdentifier = PrimaryCareBusinessLogic.getNewPrimaryIdentifierString(); PatientIdentifier pi = new PatientIdentifier(addIdentifier, PrimaryCareBusinessLogic.getPrimaryPatientIdentiferType(), PrimaryCareWebLogic.getCurrentLocation(session)); pi.setPreferred(true); patient.addIdentifier(pi); patient = PrimaryCareBusinessLogic.preferredIdentifierSafeSavePatient(patient); } catch (Exception ex) { ex.printStackTrace(System.out); log.error("Could not create a primary id for patient: " + ex.getMessage()); } } try { RecentlyViewedPatients recent = (RecentlyViewedPatients) session.getAttribute("RECENT_PATIENTS"); if (recent != null) recent.nowViewingPatient(patient); } catch (ClassCastException ex) { // this means the module has been reloaded } Encounter registrationEncounterToday = null; { Date[] day = null; if (visitDate != null) { day = PrimaryCareBusinessLogic.getStartAndEndOfDay(new Date(visitDate)); model.addAttribute("visitDate", visitDate); model.addAttribute("todaysDate", new Date(visitDate)); } else { day = PrimaryCareBusinessLogic.getStartAndEndOfDay(new Date()); } List<Encounter> today = Context.getEncounterService().getEncounters(patient, null, day[0], day[1], null, null, false); Collections.sort(today, new Comparator<Encounter>() { public int compare(Encounter left, Encounter right) { return OpenmrsUtil.compareWithNullAsEarliest(left.getEncounterDatetime(), right.getEncounterDatetime()); } }); model.addAttribute("encountersToday", today); for (Encounter enc : today) { if (PrimaryCareConstants.ENCOUNTER_TYPE_REGISTRATION.equals(enc.getEncounterType())) { registrationEncounterToday = enc; break; } } Date endOfYesterday; { Calendar cal = Calendar.getInstance(); cal.setTime(day[0]); cal.add(Calendar.MILLISECOND, -1); endOfYesterday = cal.getTime(); } List<Encounter> beforeToday = Context.getEncounterService().getEncounters(patient, null, null, endOfYesterday, null, null, false); model.addAttribute("beforeToday", beforeToday); } List<Person> parents = PrimaryCareBusinessLogic .getParents(Context.getPatientService().getPatient(patientId)); if (parents != null) { model.addAttribute("parents", parents); } // if the patient has no registration encounter today, we need to ask "is the patient present?" if (!skipPresentQuestion && registrationEncounterToday == null) return "/module/rwandaprimarycare/patientIsPresent"; // show the print bar code dialogue if needed if (printBarCode == true) return "/module/rwandaprimarycare/printBarCode"; if (serviceRequested != null && serviceRequested.equals(0)) { Concept c = PrimaryCareUtil.getServiceRequestedConcept(); //lazy loading: for (ConceptAnswer ca : c.getAnswers()) { ca.getAnswerConcept().getNames(); } model.addAttribute("servicesRequested", c); return "/module/rwandaprimarycare/serviceRequested"; } if (serviceRequestResponse != null && registrationEncounterToday != null) { Concept c = PrimaryCareUtil.getServiceRequestedConcept(); //create new obs if necessary if (!PrimaryCareUtil.doesEncounterContainObsWithConcept(registrationEncounterToday, PrimaryCareUtil.getServiceRequestedConcept())) { Obs o = PrimaryCareUtil.newObs(patient, c, registrationEncounterToday.getEncounterDatetime(), PrimaryCareBusinessLogic.getLocationLoggedIn(session)); o.setValueCoded(Context.getConceptService().getConcept(serviceRequestResponse)); registrationEncounterToday.addObs(o); registrationEncounterToday = PrimaryCareBusinessLogic .saveEncounterAndVerifyVisit(registrationEncounterToday); /** * ______________________ Appointment goes here: */ PrimaryCareUtil.createWaitingAppointment(registrationEncounterToday.getProvider(), registrationEncounterToday, o, session, Context.getConceptService().getConcept(serviceRequestResponse)); /** * ______________________ End of Appointment stuff */ } else { //edit existing obs int count = 0; for (Obs o : registrationEncounterToday.getObs()) { if (o.getConcept().equals(c)) { if (count == 0) { //update the service o.setValueCoded(Context.getConceptService().getConcept(serviceRequestResponse)); registrationEncounterToday = PrimaryCareBusinessLogic .saveEncounterAndVerifyVisit(registrationEncounterToday); } else { //void the duplicate Context.getObsService().voidObs(o, "duplicate service requested in touchscreen app"); } count++; } } } } if (gatherInsurance != null && gatherInsurance.equals(0)) { model.addAttribute("mostRecentType", PrimaryCareBusinessLogic.getLastInsuranceType(patient)); model.addAttribute("mostRecentInsuranceNumber", PrimaryCareBusinessLogic.getLastInsuranceNumber(patient)); model.addAttribute("insuranceTypes", PrimaryCareBusinessLogic.getInsuranceTypeAnswers()); return "/module/rwandaprimarycare/insuranceInformation"; } if (insuranceType != null && registrationEncounterToday != null) { //for edit, just void //TODO: don't update Obs if you don't need to... for (Obs o : registrationEncounterToday.getObs()) { if (o.getConcept().equals(PrimaryCareUtil.getInsuranceTypeConcept())) { Context.getObsService().voidObs(o, "edited through touchscreen UI"); } if (o.getConcept().equals(PrimaryCareUtil.getInsuranceNumberConcept())) { Context.getObsService().voidObs(o, "edited through touchscreen UI"); } } //and then recreate. Obs insType = PrimaryCareUtil.newObs(patient, PrimaryCareUtil.getInsuranceTypeConcept(), registrationEncounterToday.getEncounterDatetime(), PrimaryCareBusinessLogic.getLocationLoggedIn(session)); insType.setValueCoded(Context.getConceptService().getConcept(insuranceType)); Obs insNum = null; if (insuranceNumber != null && !insuranceNumber.trim().equals("")) { insNum = PrimaryCareUtil.newObs(patient, PrimaryCareUtil.getInsuranceNumberConcept(), registrationEncounterToday.getEncounterDatetime(), PrimaryCareBusinessLogic.getLocationLoggedIn(session)); insNum.setValueText(insuranceNumber); if (insuranceType == 6738) { // Mutuelle PatientIdentifierType Mutuelle = Context.getPatientService() .getPatientIdentifierTypeByName("Mutuelle"); if (Mutuelle != null) { PatientIdentifier pi = new PatientIdentifier(insuranceNumber, Mutuelle, PrimaryCareWebLogic.getCurrentLocation(session)); pi.setDateCreated(new Date()); pi.setCreator(Context.getAuthenticatedUser()); patient.addIdentifier(pi); Context.getPatientService().savePatient(patient); } } if (insuranceType == 6739) { // RAMA PatientIdentifierType RAMA = Context.getPatientService() .getPatientIdentifierTypeByName("RAMA"); if (RAMA != null) { PatientIdentifier pi = new PatientIdentifier(insuranceNumber, RAMA, PrimaryCareWebLogic.getCurrentLocation(session)); pi.setDateCreated(new Date()); pi.setCreator(Context.getAuthenticatedUser()); patient.addIdentifier(pi); Context.getPatientService().savePatient(patient); } } } if (insNum != null) registrationEncounterToday.addObs(insNum); registrationEncounterToday.addObs(insType); registrationEncounterToday = PrimaryCareBusinessLogic .saveEncounterAndVerifyVisit(registrationEncounterToday); } if (Context.getAdministrationService().getGlobalProperty("registration.showDiagnosisLink") .equals("true")) { model.addAttribute("showDiagnosisLink", Boolean.TRUE); } if (registrationEncounterToday != null) model.addAttribute("registrationEncounterToday", registrationEncounterToday); model.addAttribute("registrationEncounterType", PrimaryCareBusinessLogic.getRegistrationEncounterType()); } catch (Exception e) { throw new PrimaryCareException(e); } return "/module/rwandaprimarycare/patient"; }
From source file:com.topsec.tsm.sim.report.model.ReportModel.java
/** * ?sql where?/*from w ww .j av a 2s. c o m*/ * * @param int * mstType (/?) * @param List * ruleResult ??? * @param HttpServletRequest * request HttpServletRequest * @param ExpStruct * exp * @return SqlStruct ?sql where? */ private static SqlStruct getHqlTerm(int mstType, List ruleResult, HttpServletRequest request, ExpStruct exp, Map<Object, Object> subMap, String sTime, String eTime) { String _TalStartTime = ReportUiUtil.getNowTime(ReportUiConfig.dFormat2) + ReportUiConfig.sTimePostfix;// String _TalEndTime = ReportUiUtil.getNowTime(ReportUiConfig.dFormat2) + ReportUiConfig.eTimePostfix;//? String type = null; try { type = request.getParameter(ReportUiConfig.dvctype); } catch (Exception e) { } boolean isevtReport = "Profession/Group".equals(type); boolean evtOther = false; SqlStruct sqlStruct = new SqlStruct(); List sqlParam = new ArrayList(); Integer paramIndex = null; // ????? StringBuffer sqlTerm = new StringBuffer(); Map<Object, Object> map = new HashMap<Object, Object>(); for (int i = 0; i < ruleResult.size(); i++) { map = (Map) ruleResult.get(i); paramIndex = (Integer) map.get("htmlField"); String talCategoryKey = (String) map.get("sqlParam"); boolean onlyDvc = false; //IP if ("and paramIps = ?".equals(talCategoryKey)) { List<String> paramipList = getparamIpList(request); map.put("sqlParam", TopoUtil.getIpSqlParm(paramipList)); } if ("and DVC_ADDRESS in ?".equals(talCategoryKey)) { List<String> paramipList = getparamIpList(request); String paramString = TopoUtil.getIpSqlParmScope(paramipList); map.put("sqlParam", "and DVC_ADDRESS in " + paramString); } if ("and dvcAddress = ?".equals(talCategoryKey) || "and alias.dvcAddress = ?".equals(talCategoryKey) || "and fwrisk.dvcAddress = ?".equals(talCategoryKey)) { if (request != null) { String onlyByDvctype = request.getParameter("onlyByDvctype"); if (onlyByDvctype != null && onlyByDvctype.equals("onlyByDvctype")) { if (request.getParameter("dvctype") != null) { map.remove("sqlParam"); String key = talCategoryKey.replace("= ?", " = ").replace("and", ""); map.put("sqlParam", " and (" + getDvcIp(request.getParameter("dvctype"), key) + ")"); onlyDvc = true; } } } String sqlValue = (String) map.get("sqlValue"); if (sqlValue != null && sqlValue.indexOf("onlyByDvctype") != -1) { String[] sqlValueArray = sqlValue.split(";;;"); if (request != null) { request.setAttribute("dvctype", sqlValueArray[1]); request.setAttribute("onlyByDvctype", sqlValueArray[0]); } sqlStruct.setDevTypeName(sqlValueArray[1]); sqlStruct.setDvcIp("onlyByDvctype"); String deviceTypeZh = ReportUiUtil.getDeviceTypeName(sqlValueArray[1], Locale.getDefault()); sqlStruct.setOnlyByDvctype(deviceTypeZh); map.remove("sqlParam"); String key = talCategoryKey.replace("= ?", " = ").replace("and", ""); map.put("sqlParam", " and (" + getDvcIp(sqlValueArray[1], key) + ")"); onlyDvc = true; } if (exp != null) { String onlyByDvctype2 = null; onlyByDvctype2 = exp.getOnlyByDvctype(); if (onlyByDvctype2 != null && onlyByDvctype2.equals("onlyByDvctype")) { map.remove("sqlParam"); String key = talCategoryKey.replace("= ?", " = ").replace("and", ""); if (exp.getDvc() != null) { String[] sqlValueArray = exp.getDvc().split(";;;"); map.put("sqlParam", " and (" + getDvcIp(sqlValueArray[1], key) + ")"); } onlyDvc = true; } onlyByDvctype2 = exp.getRptIp(); if (onlyByDvctype2 != null && onlyByDvctype2.equals("onlyByDvctype")) { map.remove("sqlParam"); String key = talCategoryKey.replace("= ?", " = ").replace("and", ""); map.put("sqlParam", " and (" + getDvcIp(exp.getDvc(), key) + ")"); onlyDvc = true; } } } // ???? String htmlField = null; // ?requestnull // viewItem 2: 3:? // _TalStartTime:_TalEndTime:? if ((subMap.get("viewItem") == null || subMap.get("viewItem").equals("")) && paramIndex.equals(2)) { if (ReportUiUtil.checkNull(sTime)) { htmlField = sTime; } else { htmlField = _TalStartTime; } } else if ((subMap.get("viewItem") == null || subMap.get("viewItem").equals("")) && paramIndex.equals(3)) { if (ReportUiUtil.checkNull(eTime)) { htmlField = eTime; } else { htmlField = _TalEndTime; } } if (request != null) { if (subMap.get("viewItem") != null && !subMap.get("viewItem").equals("") && paramIndex.equals(2)) { htmlField = getHtmlField(request, paramIndex, talCategoryKey); } else if (subMap.get("viewItem") != null && !subMap.get("viewItem").equals("") && paramIndex.equals(3)) { htmlField = getHtmlField(request, paramIndex, talCategoryKey); } else if (htmlField == null) { htmlField = getHtmlField(request, paramIndex, talCategoryKey); } } // if (htmlField == null && exp != null && paramIndex == 6) { // {sqlParam=and cat1ID = ?, htmlField=6, ruleDisplay=1, // sqlValue=, sqlDefValue=, ruleName=19} if (mstType == 3 && map.get("ruleDisplay") != null && map.get("sqlValue") != null && map.get("sqlDefValue") != null) { if ((Integer) map.get("ruleDisplay") == 1 && map.get("sqlValue").equals(map.get("sqlDefValue"))) { htmlField = (String) map.get("sqlValue"); } } else { String param = ReportUiConfig.Html_Field.get(paramIndex); htmlField = (String) exp.getMap().get(param); } } String ruleName = map.get("ruleName").toString().trim();// ?? if (ruleName.equals("1")) {// 1 top // ???? Object top = null;// HB??DB if (request != null) { top = (htmlField == null ? getDefValue(map, mstType) : htmlField); } else { top = exp.getTop(); } sqlStruct.setSqlpage(Integer.parseInt(top.toString())); continue; } if (ruleName.equals("7")) {// union sqlParam = getUnion(sqlParam, Integer.parseInt(getDefValue(map, mstType).toString())); sqlStruct.setSqlparam(sqlParam); return sqlStruct; } // ??,0?1?,? ????? if (!ruleName.equals("0") && !onlyDvc) { Object tmpO = null; // ??? ? sqlDefValue /*String param = ReportUiConfig.Html_Field.get(6); if (htmlField == null && exp != null && paramIndex == 0 && exp.getMap().containsKey(param)){ htmlField = (String) exp.getMap().get(param); }*/ if (htmlField == null) { tmpO = getDefValue(map, mstType, exp, request); } else { tmpO = htmlField; } if (isevtReport) { if (!GlobalUtil.isNullOrEmpty(tmpO)) { sqlParam.add(tmpO); } } else { if (null != tmpO) { sqlParam.add(tmpO); } } // ,?? setExpTime(sqlStruct, ruleName, map, mstType, tmpO);// String? // ?? if (ReportUiConfig.digRuleList.indexOf("," + ruleName + ",") >= 0) { String[] talCategoryArray = sqlStruct.getTalCategory(); String[] talCategoryArrayNew; if (talCategoryArray == null) { talCategoryArrayNew = new String[1]; } else { talCategoryArrayNew = new String[talCategoryArray.length + 1]; System.arraycopy(talCategoryArray, 0, talCategoryArrayNew, 0, talCategoryArray.length); } talCategoryArrayNew[talCategoryArrayNew.length - 1] = sqlParam.get(sqlParam.size() - 1) .toString(); sqlStruct.setTalCategory(talCategoryArrayNew); } } Object oSqlParam = map.get("sqlParam"); if (oSqlParam != null) sqlTerm.append(" " + map.get("sqlParam") + " "); } sqlStruct.setSql(sqlTerm.toString()); sqlStruct.setSqlparam(sqlParam); return sqlStruct; }
From source file:forge.game.card.Card.java
private void addCounter(final CounterType counterType, final int n, final boolean applyMultiplier, final boolean fireEvents) { int addAmount = n; if (addAmount < 0) { addAmount = 0; // As per rule 107.1b }/*from ww w . j a va2 s . c om*/ final HashMap<String, Object> repParams = new HashMap<>(); repParams.put("Event", "AddCounter"); repParams.put("Affected", this); repParams.put("CounterType", counterType); repParams.put("CounterNum", addAmount); repParams.put("EffectOnly", applyMultiplier); if (getGame().getReplacementHandler().run(repParams) != ReplacementResult.NotReplaced) { return; } if (canReceiveCounters(counterType)) { if (counterType == CounterType.DREAM && hasKeyword("CARDNAME can't have more than seven dream counters on it.")) { addAmount = Math.min(7 - getCounters(CounterType.DREAM), addAmount); } } else { addAmount = 0; } if (addAmount == 0) { return; } setTotalCountersToAdd(addAmount); if (fireEvents) { final Integer oldValue = counters.get(counterType); final Integer newValue = addAmount + (oldValue == null ? 0 : oldValue); if (!newValue.equals(oldValue)) { final int powerBonusBefore = getPowerBonusFromCounters(); final int toughnessBonusBefore = getToughnessBonusFromCounters(); final int loyaltyBefore = getCurrentLoyalty(); counters.put(counterType, newValue); view.updateCounters(this); //fire card stats changed event if p/t bonuses or loyalty changed from added counters if (powerBonusBefore != getPowerBonusFromCounters() || toughnessBonusBefore != getToughnessBonusFromCounters() || loyaltyBefore != getCurrentLoyalty()) { getGame().fireEvent(new GameEventCardStatsChanged(this)); } // play the Add Counter sound getGame().fireEvent( new GameEventCardCounters(this, counterType, oldValue == null ? 0 : oldValue, newValue)); } // Run triggers final Map<String, Object> runParams = new TreeMap<>(); runParams.put("Card", this); runParams.put("CounterType", counterType); for (int i = 0; i < addAmount; i++) { getGame().getTriggerHandler().runTrigger(TriggerType.CounterAdded, runParams, false); } if (addAmount > 0) { getGame().getTriggerHandler().runTrigger(TriggerType.CounterAddedOnce, runParams, false); } } }